This patch should be applied to an un-modified XFree86 version 4.0.1
source tree.  It is the third of four patches that will convert the
source tree to XFree86 version 4.0.2.

To apply the patches, run the following from the directory containing your
'xc' directory:

    patch -p0 -E < 4.0.1-4.0.2.diff1
    patch -p0 -E < 4.0.1-4.0.2.diff2
    patch -p0 -E < 4.0.1-4.0.2.diff3
    patch -p0 -E < 4.0.1-4.0.2.diff4
    gzip -d < 4.0.2.tgz | tar vxf -

-------------------------------------------------------------------------------

Index: xc/include/Imakefile
diff -u xc/include/Imakefile:3.24 xc/include/Imakefile:3.25
--- xc/include/Imakefile:3.24	Fri Jun 30 17:51:51 2000
+++ xc/include/Imakefile	Sun Jul  2 15:23:34 2000
@@ -3,7 +3,7 @@
 
 
 
-XCOMM $XFree86: xc/include/Imakefile,v 3.24 2000/06/30 21:51:51 dawes Exp $
+XCOMM $XFree86: xc/include/Imakefile,v 3.25 2000/07/02 19:23:34 dawes Exp $
 #define IHaveSubdirs
 #define PassCDebugFlags /**/
 
@@ -73,8 +73,9 @@
 XCOMM For the Linux/OpenGL base standard
 #if LinkGLToUsrInclude && AlternateIncRoot
 install::
-/*	-$(RM) $(SYSTEMUSRINCDIR)/GL */
-	@if [ ! -d $(SYSTEMUSRINCDIR)/GL ]; then \
-		set -x; $(LN) $(INCDIR)/GL $(SYSTEMUSRINCDIR)/GL; \
+	MakeDir($(DESTDIR)$(SYSTEMUSRINCDIR))
+	-$(RM) $(DESTDIR)$(SYSTEMUSRINCDIR)/GL
+	@if [ ! -d $(DESTDIR)$(SYSTEMUSRINCDIR)/GL ]; then \
+		set -x; $(LN) $(INCDIR)/GL $(DESTDIR)$(SYSTEMUSRINCDIR)/GL; \
 	fi
 #endif
Index: xc/include/XF86keysym.h
diff -u xc/include/XF86keysym.h:1.4 xc/include/XF86keysym.h:1.6
--- xc/include/XF86keysym.h:1.4	Fri Jun 16 20:27:29 2000
+++ xc/include/XF86keysym.h	Wed Nov  1 21:51:09 2000
@@ -1,12 +1,30 @@
-/* $XFree86: xc/include/XF86keysym.h,v 1.4 2000/06/17 00:27:29 dawes Exp $ */
+/* $XFree86: xc/include/XF86keysym.h,v 1.6 2000/11/02 02:51:09 dawes Exp $ */
 
 /*
- * ModeLock (not needed since XKB offers this functionality)
+ * XFree86 vendor specific keysyms.
+ *
+ * The XFree86 keysym range is 0x1008FF01 - 0x1008FFFF.
+ *
+ * When adding new entries, the xc/lib/XKeysymDB file should also be
+ * updated to make the new entries visible to Xlib.
  */
 
+/*
+ * ModeLock
+ *
+ * This one is old, and not really used any more since XKB offers this
+ * functionality.
+ */
+
 #define XF86XK_ModeLock		0x1008FF01	/* Mode Switch Lock */
 
 /*
+ * Note, 0x1008FF02 - 0x1008FF0F are free and should be used for misc new
+ * keysyms that don't fit into any of the groups below.
+ */
+
+
+/*
  * Keys found on some "Internet" keyboards.
  */
 #define XF86XK_Standby		0x1008FF10
@@ -39,6 +57,12 @@
 #define XF86XK_Forward		0x1008FF27
 #define XF86XK_Stop		0x1008FF28
 #define XF86XK_Refresh		0x1008FF29
+#define XF86XK_PowerOff		0x1008FF1A
+#define XF86XK_WakeUp		0x1008FF1B
+
+/* Note, 0x1008FF2C - 0x1008FF2F are free and should be used next */
+
+/* Some more ... */
 #define XF86XK_Favorites	0x1008FF30
 #define XF86XK_AudioPause	0x1008FF31
 #define XF86XK_AudioMedia	0x1008FF32
Index: xc/include/Xmd.h
diff -u xc/include/Xmd.h:3.6 xc/include/Xmd.h:3.8
--- xc/include/Xmd.h:3.6	Mon Feb 21 19:59:40 2000
+++ xc/include/Xmd.h	Wed Aug 23 18:10:01 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/include/Xmd.h,v 3.6 2000/02/22 00:59:40 mvojkovi Exp $ */
+/* $XFree86: xc/include/Xmd.h,v 3.8 2000/08/23 22:10:01 tsi Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -54,7 +54,8 @@
 #ifdef CRAY
 #define WORD64				/* 64-bit architecture */
 #endif
-#if defined(__alpha) || defined(__alpha__) || defined(__ia64__)
+#if defined(__alpha) || defined(__alpha__) || \
+    defined(__ia64__) || defined(ia64)
 #define LONG64				/* 32/64-bit architecture */
 #endif
 #ifdef __sgi
@@ -145,6 +146,7 @@
 typedef CARD32		BITS32;
 typedef CARD16		BITS16;
 
+#ifndef __CYGWIN__
 #ifndef __EMX__
 typedef CARD8		BYTE;
 typedef CARD8           BOOL;
@@ -156,7 +158,14 @@
 #define BYTE		CARD8
 #define BOOL		CARD8
 #endif
+#endif
 
+#ifdef __CYGWIN__
+#undef BYTE
+#undef BOOL
+#define BYTE CARD8
+#define BOOL CARD8
+#endif
 
 /*
  * definitions for sign-extending bitfields on 64-bit architectures
Index: xc/include/Xos.h
diff -u xc/include/Xos.h:3.28 xc/include/Xos.h:3.30
--- xc/include/Xos.h:3.28	Wed Apr  5 14:13:15 2000
+++ xc/include/Xos.h	Thu Aug 10 13:40:27 2000
@@ -23,7 +23,7 @@
  * The X Window System is a Trademark of The Open Group.
  *
  */
-/* $XFree86: xc/include/Xos.h,v 3.28 2000/04/05 18:13:15 dawes Exp $ */
+/* $XFree86: xc/include/Xos.h,v 3.30 2000/08/10 17:40:27 dawes Exp $ */
 
 /* This is a collection of things to try and minimize system dependencies
  * in a "signficant" number of source files.
@@ -121,7 +121,7 @@
 /*
  * Get open(2) constants
  */
-#ifdef X_NOT_POSIX
+#if defined(X_NOT_POSIX) && !defined(__CYGWIN__)
 #include <fcntl.h>
 #if defined(USL) || defined(CRAY) || defined(MOTOROLA) || (defined(i386) && (defined(SYSV) || defined(SVR4))) || defined(__sxg__)
 #include <unistd.h>
@@ -291,7 +291,7 @@
 #define NGROUPS 16
 #endif
 
-#if defined(ISC) || (defined(__QNX__) && !defined(UNIXCONN))
+#if defined(ISC) || (defined(__QNX__) && !defined(UNIXCONN)) || defined(__CYGWIN__)
 /*
  *	Some OS's may not have this
  */
Index: xc/include/Xos_r.h
diff -u xc/include/Xos_r.h:1.6 xc/include/Xos_r.h:1.7
--- xc/include/Xos_r.h:1.6	Fri Jun 16 20:27:29 2000
+++ xc/include/Xos_r.h	Mon Aug 28 11:29:11 2000
@@ -18,7 +18,7 @@
 used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization from The Open Group.
 */
-/* $XFree86: xc/include/Xos_r.h,v 1.6 2000/06/17 00:27:29 dawes Exp $ */
+/* $XFree86: xc/include/Xos_r.h,v 1.7 2000/08/28 15:29:11 dawes Exp $ */
 
 /* 
  * Various and sundry Thread-Safe functions used by X11, Motif, and CDE.
@@ -242,6 +242,42 @@
   struct passwd* pwp;
   size_t len;
 } _Xgetpwparams;
+
+/* NetBSD, at least, is missing several of the unixware passwd fields. */
+   
+#if defined(__NetBSD__)
+__inline__ void _Xpw_copyPasswd(_Xgetpwparams p)
+{
+   memcpy(&(p).pws, (p).pwp, sizeof(struct passwd));
+
+   (p).pws.pw_name = (p).pwbuf;
+   (p).len = strlen((p).pwp->pw_name);
+   strcpy((p).pws.pw_name, (p).pwp->pw_name);
+
+   (p).pws.pw_passwd = (p).pws.pw_name + (p).len + 1;
+   (p).len = strlen((p).pwp->pw_passwd);
+   strcpy((p).pws.pw_passwd,(p).pwp->pw_passwd);
+
+   (p).pws.pw_class = (p).pws.pw_passwd + (p).len + 1;
+   (p).len = strlen((p).pwp->pw_class);
+   strcpy((p).pws.pw_class, (p).pwp->pw_class);
+
+   (p).pws.pw_gecos = (p).pws.pw_class + (p).len + 1;
+   (p).len = strlen((p).pwp->pw_gecos);
+   strcpy((p).pws.pw_gecos, (p).pwp->pw_gecos);
+
+   (p).pws.pw_dir = (p).pws.pw_gecos + (p).len + 1;
+   (p).len = strlen((p).pwp->pw_dir);
+   strcpy((p).pws.pw_dir, (p).pwp->pw_dir);
+
+   (p).pws.pw_shell = (p).pws.pw_dir + (p).len + 1;
+   (p).len = strlen((p).pwp->pw_shell);
+   strcpy((p).pws.pw_shell, (p).pwp->pw_shell);
+
+   (p).pwp = &(p).pws;
+}
+
+#else
 # define _Xpw_copyPasswd(p) \
    (memcpy(&(p).pws, (p).pwp, sizeof(struct passwd)), \
     ((p).pws.pw_name = (p).pwbuf), \
@@ -267,6 +303,7 @@
     strcpy((p).pws.pw_shell, (p).pwp->pw_shell), \
     ((p).pwp = &(p).pws), \
     0 )
+#endif
 # define _XGetpwuid(u,p) \
 ( (_Xos_processLock), \
   (((p).pwp = getpwuid((u))) ? _Xpw_copyPasswd(p) : 0), \
@@ -374,6 +411,10 @@
 #elif !defined(XOS_USE_MTSAFE_NETDBAPI) || defined(XNO_MTSAFE_NETDBAPI)
 /* UnixWare 2.0, or other systems with thread support but no _r API. */
 /* WARNING:  The h_addr_list and s_aliases values are *not* copied! */
+
+#if defined(__NetBSD__)
+#include <sys/param.h>
+#endif
 
 typedef struct {
   struct hostent hent;
Index: xc/include/Xpoll.h
diff -u xc/include/Xpoll.h:3.6 xc/include/Xpoll.h:3.7
--- xc/include/Xpoll.h:3.6	Sun Dec 26 19:39:19 1999
+++ xc/include/Xpoll.h	Tue Sep 19 08:46:05 2000
@@ -23,7 +23,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/include/Xpoll.h,v 3.6 1999/12/27 00:39:19 robin Exp $ */
+/* $XFree86: xc/include/Xpoll.h,v 3.7 2000/09/19 12:46:05 eich Exp $ */
 
 #ifndef _XPOLL_H_
 #define _XPOLL_H_
@@ -101,13 +101,13 @@
 #endif
 
 #ifndef FD_SET
-#define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
+#define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= ((fd_mask)1 << ((n) % NFDBITS)))
 #endif
 #ifndef FD_CLR
-#define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
+#define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~((fd_mask)1 << ((n) % NFDBITS)))
 #endif
 #ifndef FD_ISSET
-#define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
+#define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & ((fd_mask)1 << ((n) % NFDBITS)))
 #endif
 #ifndef FD_ZERO
 #define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))
Index: xc/include/keysym.h
diff -u xc/include/keysym.h:1.1.1.3 xc/include/keysym.h:1.2
--- xc/include/keysym.h:1.1.1.3	Sun Sep 27 07:04:38 1998
+++ xc/include/keysym.h	Fri Oct 27 14:30:46 2000
@@ -42,6 +42,7 @@
 SOFTWARE.
 
 ******************************************************************/
+/* $XFree86: xc/include/keysym.h,v 1.2 2000/10/27 18:30:46 dawes Exp $ */
 
 /* default keysyms */
 #define XK_MISCELLANY
@@ -50,8 +51,20 @@
 #define XK_LATIN2
 #define XK_LATIN3
 #define XK_LATIN4
+#define XK_LATIN8
 #define XK_LATIN9
+#define XK_CAUCASUS
 #define XK_GREEK
+#define XK_KATAKANA
+#define XK_ARABIC
+#define XK_CYRILLIC
+#define XK_HEBREW
+#define XK_THAI
+#define XK_KOREAN
+#define XK_ARMENIAN
+#define XK_GEORGIAN
+#define XK_VIETNAMESE
 #define XK_CURRENCY
 
 #include <X11/keysymdef.h>
+
Index: xc/include/keysymdef.h
diff -u xc/include/keysymdef.h:1.9 xc/include/keysymdef.h:1.10
--- xc/include/keysymdef.h:1.9	Tue Jul  6 07:38:02 1999
+++ xc/include/keysymdef.h	Fri Oct 27 14:30:46 2000
@@ -43,7 +43,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/include/keysymdef.h,v 1.9 1999/07/06 11:38:02 dawes Exp $ */
+/* $XFree86: xc/include/keysymdef.h,v 1.10 2000/10/27 18:30:46 dawes Exp $ */
 
 #define XK_VoidSymbol		0xFFFFFF	/* void symbol */
 
@@ -324,6 +324,8 @@
 #define	XK_dead_voiced_sound				0xFE5E
 #define	XK_dead_semivoiced_sound			0xFE5F
 #define	XK_dead_belowdot				0xFE60
+#define XK_dead_hook					0xFE61
+#define XK_dead_horn					0xFE62
 
 #define	XK_First_Virtual_Screen				0xFED0
 #define	XK_Prev_Virtual_Screen				0xFED1
@@ -576,6 +578,7 @@
 #define XK_Odiaeresis          0x0d6
 #define XK_multiply            0x0d7
 #define XK_Ooblique            0x0d8
+#define XK_Oslash              XK_Ooblique
 #define XK_Ugrave              0x0d9
 #define XK_Uacute              0x0da
 #define XK_Ucircumflex         0x0db
@@ -609,6 +612,7 @@
 #define XK_odiaeresis          0x0f6
 #define XK_division            0x0f7
 #define XK_oslash              0x0f8
+#define XK_ooblique            XK_oslash
 #define XK_ugrave              0x0f9
 #define XK_uacute              0x0fa
 #define XK_ucircumflex         0x0fb
@@ -759,6 +763,39 @@
 #endif /* XK_LATIN4 */
 
 /*
+ * Latin-8
+ * Byte 3 = 18
+ */
+#ifdef XK_LATIN8
+#define XK_Babovedot           0x12a1
+#define XK_babovedot           0x12a2
+#define XK_Dabovedot           0x12a6
+#define XK_Wgrave              0x12a8
+#define XK_Wacute              0x12aa
+#define XK_dabovedot           0x12ab
+#define XK_Ygrave              0x12ac
+#define XK_Fabovedot           0x12b0
+#define XK_fabovedot           0x12b1
+#define XK_Mabovedot           0x12b4
+#define XK_mabovedot           0x12b5
+#define XK_Pabovedot           0x12b7
+#define XK_wgrave              0x12b8
+#define XK_pabovedot           0x12b9
+#define XK_wacute              0x12ba
+#define XK_Sabovedot           0x12bb
+#define XK_ygrave              0x12bc
+#define XK_Wdiaeresis          0x12bd
+#define XK_wdiaeresis          0x12be
+#define XK_sabovedot           0x12bf
+#define XK_Wcircumflex         0x12d0
+#define XK_Tabovedot           0x12d7
+#define XK_Ycircumflex         0x12de
+#define XK_wcircumflex         0x12f0
+#define XK_tabovedot           0x12f7
+#define XK_ycircumflex         0x12fe
+#endif /* XK_LATIN8 */
+
+/*
  * Latin-9 (a.k.a. Latin-0)
  * Byte 3 = 19
  */
@@ -853,7 +890,35 @@
  */
 
 #ifdef XK_ARABIC
+#define XK_Farsi_0                                     0x590
+#define XK_Farsi_1                                     0x591
+#define XK_Farsi_2                                     0x592
+#define XK_Farsi_3                                     0x593
+#define XK_Farsi_4                                     0x594
+#define XK_Farsi_5                                     0x595
+#define XK_Farsi_6                                     0x596
+#define XK_Farsi_7                                     0x597
+#define XK_Farsi_8                                     0x598
+#define XK_Farsi_9                                     0x599
+#define XK_Arabic_percent                              0x5a5
+#define XK_Arabic_superscript_alef                     0x5a6
+#define XK_Arabic_tteh                                 0x5a7
+#define XK_Arabic_peh                                  0x5a8
+#define XK_Arabic_tcheh                                0x5a9
+#define XK_Arabic_ddal                                 0x5aa
+#define XK_Arabic_rreh                                 0x5ab
 #define XK_Arabic_comma                                0x5ac
+#define XK_Arabic_fullstop                             0x5ae
+#define XK_Arabic_0                                    0x5b0
+#define XK_Arabic_1                                    0x5b1
+#define XK_Arabic_2                                    0x5b2
+#define XK_Arabic_3                                    0x5b3
+#define XK_Arabic_4                                    0x5b4
+#define XK_Arabic_5                                    0x5b5
+#define XK_Arabic_6                                    0x5b6
+#define XK_Arabic_7                                    0x5b7
+#define XK_Arabic_8                                    0x5b8
+#define XK_Arabic_9                                    0x5b9
 #define XK_Arabic_semicolon                            0x5bb
 #define XK_Arabic_question_mark                        0x5bf
 #define XK_Arabic_hamza                                0x5c1
@@ -902,6 +967,19 @@
 #define XK_Arabic_kasra                                0x5f0
 #define XK_Arabic_shadda                               0x5f1
 #define XK_Arabic_sukun                                0x5f2
+#define XK_Arabic_madda_above                          0x5f3
+#define XK_Arabic_hamza_above                          0x5f4
+#define XK_Arabic_hamza_below                          0x5f5
+#define XK_Arabic_jeh                                  0x5f6
+#define XK_Arabic_veh                                  0x5f7
+#define XK_Arabic_keheh                                0x5f8
+#define XK_Arabic_gaf                                  0x5f9
+#define XK_Arabic_noon_ghunna                          0x5fa
+#define XK_Arabic_heh_doachashmee                      0x5fb
+#define XK_Farsi_yeh                                   0x5fc
+#define XK_Arabic_farsi_yeh                     XK_Farsi_yeh
+#define XK_Arabic_yeh_baree                            0x5fd
+#define XK_Arabic_heh_goal                             0x5fe
 #define XK_Arabic_switch        0xFF7E  /* Alias for mode_switch */
 #endif /* XK_ARABIC */
 
@@ -910,6 +988,38 @@
  * Byte 3 = 6
  */
 #ifdef XK_CYRILLIC
+#define XK_Cyrillic_GHE_bar	                           0x680
+#define XK_Cyrillic_ghe_bar	                           0x690
+#define XK_Cyrillic_ZHE_descender	                   0x681
+#define XK_Cyrillic_zhe_descender	                   0x691
+#define XK_Cyrillic_KA_descender	                   0x682
+#define XK_Cyrillic_ka_descender	                   0x692
+#define XK_Cyrillic_KA_vertstroke	                   0x683
+#define XK_Cyrillic_ka_vertstroke	                   0x693
+#define XK_Cyrillic_EN_descender	                   0x684
+#define XK_Cyrillic_en_descender	                   0x694
+#define XK_Cyrillic_U_straight	                       0x685
+#define XK_Cyrillic_u_straight	                       0x695
+#define XK_Cyrillic_U_straight_bar	                   0x686
+#define XK_Cyrillic_u_straight_bar	                   0x696
+#define XK_Cyrillic_HA_descender	                   0x687
+#define XK_Cyrillic_ha_descender	                   0x697
+#define XK_Cyrillic_CHE_descender	                   0x688
+#define XK_Cyrillic_che_descender	                   0x698
+#define XK_Cyrillic_CHE_vertstroke	                   0x689
+#define XK_Cyrillic_che_vertstroke	                   0x699
+#define XK_Cyrillic_SHHA	                           0x68a
+#define XK_Cyrillic_shha	                           0x69a
+
+#define XK_Cyrillic_SCHWA	                           0x68c
+#define XK_Cyrillic_schwa	                           0x69c
+#define XK_Cyrillic_I_macron		                   0x68d
+#define XK_Cyrillic_i_macron		                   0x69d
+#define XK_Cyrillic_O_bar	                           0x68e
+#define XK_Cyrillic_o_bar	                           0x69e
+#define XK_Cyrillic_U_macron		                   0x68f
+#define XK_Cyrillic_u_macron		                   0x69f
+
 #define XK_Serbian_dje                                 0x6a1
 #define XK_Macedonia_gje                               0x6a2
 #define XK_Cyrillic_io                                 0x6a3
@@ -1031,7 +1141,8 @@
 #define XK_Greek_EPSILONaccent                         0x7a2
 #define XK_Greek_ETAaccent                             0x7a3
 #define XK_Greek_IOTAaccent                            0x7a4
-#define XK_Greek_IOTAdiaeresis                         0x7a5
+#define XK_Greek_IOTAdieresis                          0x7a5
+#define XK_Greek_IOTAdiaeresis         XK_Greek_IOTAdieresis /* old typo */
 #define XK_Greek_OMICRONaccent                         0x7a7
 #define XK_Greek_UPSILONaccent                         0x7a8
 #define XK_Greek_UPSILONdieresis                       0x7a9
@@ -1588,7 +1699,7 @@
 
 #ifdef XK_ARMENIAN
 #define XK_Armenian_eternity				0x14a1
-#define XK_Armenian_section_sign			0x14a2
+#define XK_Armenian_ligature_ew				0x14a2
 #define XK_Armenian_full_stop				0x14a3
 #define XK_Armenian_verjaket				0x14a3
 #define XK_Armenian_parenright				0x14a4
@@ -1688,7 +1799,7 @@
 #define XK_Armenian_FE					0x14fc
 #define XK_Armenian_fe					0x14fd
 #define XK_Armenian_apostrophe				0x14fe
-#define XK_Armenian_ligature_ew				0x14ff
+#define XK_Armenian_section_sign			0x14ff
 #endif /* XK_ARMENIAN */
 
 /*
@@ -1737,6 +1848,152 @@
 #define XK_Georgian_hoe					0x15f5
 #define XK_Georgian_fi					0x15f6
 #endif /* XK_GEORGIAN */
+
+/*
+ * Azeri (and other Turkic or Caucasian languages of ex-USSR)
+ * Byte 3 = 0x16
+ */
+
+#ifdef XK_CAUCASUS
+/* latin */
+#define XK_Ccedillaabovedot	0x16a2
+#define XK_Xabovedot		0x16a3
+#define XK_Qabovedot		0x16a5
+#define	XK_Ibreve		0x16a6
+#define XK_IE			0x16a7
+#define XK_UO			0x16a8
+#define XK_Zstroke		0x16a9
+#define	XK_Gcaron		0x16aa
+#define	XK_Obarred		0x16af
+#define XK_ccedillaabovedot	0x16b2
+#define XK_xabovedot		0x16b3
+#define	XK_Ocaron		0x16b4
+#define XK_qabovedot		0x16b5
+#define	XK_ibreve		0x16b6
+#define XK_ie			0x16b7
+#define XK_uo			0x16b8
+#define XK_zstroke		0x16b9
+#define	XK_gcaron		0x16ba
+#define	XK_ocaron		0x16bd
+#define	XK_obarred		0x16bf
+#define XK_SCHWA		0x16c6
+#define XK_schwa		0x16f6
+/* those are not really Caucasus, but I put them here for now */
+/* For Inupiak */
+#define XK_Lbelowdot		0x16d1
+#define XK_Lstrokebelowdot	0x16d2
+#define XK_lbelowdot		0x16e1
+#define XK_lstrokebelowdot	0x16e2
+/* For Guarani */
+#define XK_Gtilde		0x16d3
+#define XK_gtilde		0x16e3
+#endif /* XK_CAUCASUS */
+
+/*
+ *   Vietnamese
+ *   Byte 3 = 0x1e
+ */
+ 
+#ifdef XK_VIETNAMESE
+#define XK_Abelowdot					0x1ea0
+#define XK_abelowdot					0x1ea1
+#define XK_Ahook					0x1ea2
+#define XK_ahook					0x1ea3
+#define XK_Acircumflexacute				0x1ea4
+#define XK_acircumflexacute				0x1ea5
+#define XK_Acircumflexgrave				0x1ea6
+#define XK_acircumflexgrave				0x1ea7
+#define XK_Acircumflexhook				0x1ea8
+#define XK_acircumflexhook				0x1ea9
+#define XK_Acircumflextilde				0x1eaa
+#define XK_acircumflextilde				0x1eab
+#define XK_Acircumflexbelowdot				0x1eac
+#define XK_acircumflexbelowdot				0x1ead
+#define XK_Abreveacute					0x1eae
+#define XK_abreveacute					0x1eaf
+#define XK_Abrevegrave					0x1eb0
+#define XK_abrevegrave					0x1eb1
+#define XK_Abrevehook					0x1eb2
+#define XK_abrevehook					0x1eb3
+#define XK_Abrevetilde					0x1eb4
+#define XK_abrevetilde					0x1eb5
+#define XK_Abrevebelowdot				0x1eb6
+#define XK_abrevebelowdot				0x1eb7
+#define XK_Ebelowdot					0x1eb8
+#define XK_ebelowdot					0x1eb9
+#define XK_Ehook					0x1eba
+#define XK_ehook					0x1ebb
+#define XK_Etilde					0x1ebc
+#define XK_etilde					0x1ebd
+#define XK_Ecircumflexacute				0x1ebe
+#define XK_ecircumflexacute				0x1ebf
+#define XK_Ecircumflexgrave				0x1ec0
+#define XK_ecircumflexgrave				0x1ec1
+#define XK_Ecircumflexhook				0x1ec2
+#define XK_ecircumflexhook				0x1ec3
+#define XK_Ecircumflextilde				0x1ec4
+#define XK_ecircumflextilde				0x1ec5
+#define XK_Ecircumflexbelowdot				0x1ec6
+#define XK_ecircumflexbelowdot				0x1ec7
+#define XK_Ihook					0x1ec8
+#define XK_ihook					0x1ec9
+#define XK_Ibelowdot					0x1eca
+#define XK_ibelowdot					0x1ecb
+#define XK_Obelowdot					0x1ecc
+#define XK_obelowdot					0x1ecd
+#define XK_Ohook					0x1ece
+#define XK_ohook					0x1ecf
+#define XK_Ocircumflexacute				0x1ed0
+#define XK_ocircumflexacute				0x1ed1
+#define XK_Ocircumflexgrave				0x1ed2
+#define XK_ocircumflexgrave				0x1ed3
+#define XK_Ocircumflexhook				0x1ed4
+#define XK_ocircumflexhook				0x1ed5
+#define XK_Ocircumflextilde				0x1ed6
+#define XK_ocircumflextilde				0x1ed7
+#define XK_Ocircumflexbelowdot				0x1ed8
+#define XK_ocircumflexbelowdot				0x1ed9
+#define XK_Ohornacute					0x1eda
+#define XK_ohornacute					0x1edb
+#define XK_Ohorngrave					0x1edc
+#define XK_ohorngrave					0x1edd
+#define XK_Ohornhook					0x1ede
+#define XK_ohornhook					0x1edf
+#define XK_Ohorntilde					0x1ee0
+#define XK_ohorntilde					0x1ee1
+#define XK_Ohornbelowdot				0x1ee2
+#define XK_ohornbelowdot				0x1ee3
+#define XK_Ubelowdot					0x1ee4
+#define XK_ubelowdot					0x1ee5
+#define XK_Uhook					0x1ee6
+#define XK_uhook					0x1ee7
+#define XK_Uhornacute					0x1ee8
+#define XK_uhornacute					0x1ee9
+#define XK_Uhorngrave					0x1eea
+#define XK_uhorngrave					0x1eeb
+#define XK_Uhornhook					0x1eec
+#define XK_uhornhook					0x1eed
+#define XK_Uhorntilde					0x1eee
+#define XK_uhorntilde					0x1eef
+#define XK_Uhornbelowdot				0x1ef0
+#define XK_uhornbelowdot				0x1ef1
+#define XK_Ybelowdot					0x1ef4
+#define XK_ybelowdot					0x1ef5
+#define XK_Yhook					0x1ef6
+#define XK_yhook					0x1ef7
+#define XK_Ytilde					0x1ef8
+#define XK_ytilde					0x1ef9
+#define XK_Ohorn					0x1efa /* U+01a0 */
+#define XK_ohorn					0x1efb /* U+01a1 */
+#define XK_Uhorn					0x1efc /* U+01af */
+#define XK_uhorn					0x1efd /* U+01b0 */
+
+#define XK_combining_tilde				0x1e9f /* U+0303 */
+#define XK_combining_grave				0x1ef2 /* U+0300 */
+#define XK_combining_acute				0x1ef3 /* U+0301 */
+#define XK_combining_hook				0x1efe /* U+0309 */
+#define XK_combining_belowdot				0x1eff /* U+0323 */
+#endif /* XK_VIETNAMESE */
 
 #ifdef XK_CURRENCY
 #define XK_EcuSign					0x20a0
Index: xc/include/DPS/dpsconfig.h
diff -u xc/include/DPS/dpsconfig.h:1.1 xc/include/DPS/dpsconfig.h:1.3
--- xc/include/DPS/dpsconfig.h:1.1	Sat Feb 12 19:12:46 2000
+++ xc/include/DPS/dpsconfig.h	Thu Aug 31 15:03:54 2000
@@ -35,6 +35,7 @@
  * 
  * Author:  Adobe Systems Incorporated
  */
+/* $XFree86: xc/include/DPS/dpsconfig.h,v 1.3 2000/08/31 19:03:54 tsi Exp $ */
 
 #ifndef	DPSCONFIG_H
 #define	DPSCONFIG_H
@@ -85,18 +86,19 @@
 #define IEEEFLOAT 1
 #endif /* _IBMR2 */
 
-#ifndef IEEEFLOAT
+#if defined(__alpha) || defined(__alpha__) || \
+    defined(__ia64__) || defined(ia64)
 #define IEEEFLOAT 1
-#endif /* IEEEFLOAT */
-
-#ifdef __alpha
-#define IEEEFLOAT 1
 #endif /* __alpha */
 
 #ifdef __i386__
 #define IEEEFLOAT 1
 #endif /* __i386__ */
 
+#ifndef IEEEFLOAT
+#define IEEEFLOAT 1
+#endif /* IEEEFLOAT */
+
 #endif /* IEEEFLOAT */
 
 #ifndef DPS_FORMATNAME
@@ -124,9 +126,10 @@
 
 #ifndef SWAPBITS
 
-#ifdef __alpha
+#if defined(__alpha) || defined(__alpha__) || \
+    defined(__ia64__) || defined(ia64)
 #define SWAPBITS 1
-#endif /* alpha */
+#endif /* __alpha */
 
 #ifdef vax
 #define SWAPBITS 1
@@ -169,14 +172,15 @@
  * MIN_POINTER_ALIGN.  MIN_POINTER_ALIGN must be a power of 2.
  *
  * MIN_POINTER_ALIGN must be 8 on
- *	Alpha
+ *	Alpha, IA-64
  * MIN_POINTER_ALIGN must be 4 on
  *	VAX, i80x86 series, MIPS, mc680x0 series, IBM R6000, SPARC, HPPA
  */
 
 #ifndef MIN_POINTER_ALIGN
  
-#ifdef __alpha
+#if defined(__alpha) || defined(__alpha__) || \
+    defined(__ia64__) || defined(ia64)
 #define MIN_POINTER_ALIGN 8
 #endif /* __alpha */
 
Index: xc/include/GL/Imakefile
diff -u xc/include/GL/Imakefile:1.9 xc/include/GL/Imakefile:1.10
--- xc/include/GL/Imakefile:1.9	Fri Jun 16 20:02:46 2000
+++ xc/include/GL/Imakefile	Thu Aug  3 23:51:40 2000
@@ -1,12 +1,12 @@
 
-XCOMM $XFree86: xc/include/GL/Imakefile,v 1.9 2000/06/17 00:02:46 martin Exp $
+XCOMM $XFree86: xc/include/GL/Imakefile,v 1.10 2000/08/04 03:51:40 tsi Exp $
 
 LinkSourceFile(gl.h, ../../extras/Mesa/include/GL)
 LinkSourceFile(glext.h, ../../extras/Mesa/include/GL)
 LinkSourceFile(osmesa.h, ../../extras/Mesa/include/GL)
 
 #if BuildGLXLibrary
-GLXHEADERS = gl.h glext.h glx.h glxtokens.h osmesa.h
+GLXHEADERS = gl.h glext.h glx.h glxint.h glxtokens.h osmesa.h
 #endif
 
 HEADERS = $(GLXHEADERS)
Index: xc/include/GL/glxint.h
diff -u xc/include/GL/glxint.h:1.2 xc/include/GL/glxint.h:1.3
--- xc/include/GL/glxint.h:1.2	Mon Jun 14 03:23:28 1999
+++ xc/include/GL/glxint.h	Sat Nov 18 14:37:04 2000
@@ -1,7 +1,7 @@
 #ifndef __GLX_glxint_h__
 #define __GLX_glxint_h__
 
-/* $XFree86: xc/include/GL/glxint.h,v 1.2 1999/06/14 07:23:28 dawes Exp $ */
+/* $XFree86: xc/include/GL/glxint.h,v 1.3 2000/11/18 19:37:04 tsi Exp $ */
 /*
 ** The contents of this file are subject to the GLX Public License Version 1.0
 ** (the "License"). You may not use this file except in compliance with the
@@ -22,6 +22,9 @@
 **
 ** $SGI$
 */
+
+#include "X.h"
+#include "Xdefs.h"
 
 typedef struct __GLXvisualConfigRec __GLXvisualConfig;
 
Index: xc/include/extensions/Imakefile
diff -u xc/include/extensions/Imakefile:3.34 xc/include/extensions/Imakefile:3.36
--- xc/include/extensions/Imakefile:3.34	Fri Mar 31 17:55:18 2000
+++ xc/include/extensions/Imakefile	Sat Aug 26 12:15:52 2000
@@ -1,5 +1,5 @@
 XCOMM $TOG: Imakefile /main/50 1997/11/24 16:47:55 kaleb $
-XCOMM $XFree86: xc/include/extensions/Imakefile,v 3.34 2000/03/31 22:55:18 dawes Exp $
+XCOMM $XFree86: xc/include/extensions/Imakefile,v 3.36 2000/08/26 16:15:52 keithp Exp $
 
 #if BuildScreenSaverLibrary
 SCREENSAVERHEADERS = saver.h saverproto.h scrnsaver.h
@@ -32,11 +32,14 @@
 #if BuildXinerama
 XINERAMAHEADERS = panoramiXext.h panoramiXproto.h Xinerama.h
 #endif
+#if BuildRenderLibrary
+RENDERHEADERS = render.h renderproto.h
+#endif
 
 EXTRAHEADERS = $(SCREENSAVERHEADERS) $(XF86MISCHEADERS) $(XF86BIGFONTHEADERS) \
 	       $(XF86VIDMODEHEADERS) $(XF86DGAHEADERS) $(XINERAMAHEADERS) \
 	       $(LBXHEADERS) $(XVHEADERS) $(XF86RUSHHEADERS) \
-	       $(FONTCACHEHEADERS)
+	       $(FONTCACHEHEADERS) $(RENDERHEADERS)
 
 
 
Index: xc/include/extensions/XAnti.h
diff -u xc/include/extensions/XAnti.h:1.2 xc/include/extensions/XAnti.h:removed
--- xc/include/extensions/XAnti.h:1.2	Sun Jun  6 04:47:48 1999
+++ xc/include/extensions/XAnti.h	Mon Dec 18 14:23:19 2000
@@ -1,103 +0,0 @@
-/*
-   Copyright (C) 1998 by The XFree86 Project Inc.
-
-*/
-/* $XFree86: xc/include/extensions/XAnti.h,v 1.2 1999/06/06 08:47:48 dawes Exp $ */
-
-
-#ifndef _XANTI_H
-#define _XANTI_H
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-
-Bool
-XAntiQueryExtension(
-    Display *dpy,
-    unsigned int *p_version, 
-    unsigned int *p_revision
-);
-
-int
-XAntiSetInterpolationPixels(
-    Display *dpy,
-    GC gc,
-    unsigned long *pixels
-);
-
-int
-XAntiInterpolateColors(
-    Display *dpy,
-    GC gc,
-    Colormap cmap,
-    XColor *colors
-);
-
-
-int
-XAntiDrawString(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x,
-    int y,
-    _Xconst char *string,
-    int length
-);
-
-int
-XAntiDrawString16(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x,
-    int y,
-    _Xconst XChar2b *string,
-    int length
-);
-
-int
-XAntiDrawText(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x, 
-    int y,
-    XTextItem *items,
-    int nitems
-);
-
-int
-XAntiDrawText16(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x, 
-    int y,
-    XTextItem16 *items,
-    int nitems
-);
-
-int
-XAntiDrawImageString(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x,
-    int y,
-    _Xconst char *string,
-    int length
-);
-
-int
-XAntiDrawImageString16(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x,
-    int y,
-    _Xconst XChar2b *string,
-    int length
-);
-
-#endif /* _XANTI_H */
Index: xc/include/extensions/XAntiproto.h
diff -u xc/include/extensions/XAntiproto.h:1.1 xc/include/extensions/XAntiproto.h:removed
--- xc/include/extensions/XAntiproto.h:1.1	Sat Nov 14 23:29:56 1998
+++ xc/include/extensions/XAntiproto.h	Mon Dec 18 14:23:19 2000
@@ -1,125 +0,0 @@
-/*
-   Copyright (C) 1998 by The XFree86 Project Inc.
-
-*/
-/* $XFree86: xc/include/extensions/XAntiproto.h,v 1.1 1998/11/15 04:29:56 dawes Exp $ */
-
-
-#ifndef _XANTIPROTO_H
-#define _XANTIPROTO_H
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-
-#define XAntiName "XAnti"
-#define XAntiVersion 1
-#define XAntiRevision 0
-
-#define XAnti_QueryExtension		0
-#define XAnti_SetInterpolationPixels	1
-#define XAnti_InterpolateColors		2
-#define XAnti_PolyText8			3
-#define XAnti_PolyText16		4
-#define XAnti_ImageText8		5
-#define XAnti_ImageText16		6
-#define XAnti_LastRequest		7
-
-
-#define XAntiNumRequest			XAnti_LastRequest
-
-/* Requests */
-
-typedef struct {
-  CARD8 reqType;
-  CARD8 xAntiReqType;
-  CARD16 length B16;
-} xAntiQueryExtensionReq;
-#define sz_xAntiQueryExtensionReq 4
-
-typedef struct {
-  CARD8 reqType;
-  CARD8 xAntiReqType;
-  CARD16 length B16;
-  GContext gc B32;
-  CARD32 number B32;
-} xAntiSetInterpolationPixelsReq;
-#define sz_xAntiSetInterpolationPixelsReq 12
-
-typedef struct {
-  CARD8 reqType;
-  CARD8 xAntiReqType;
-  CARD16 length B16;
-  GContext gc B32;
-  Colormap colormap B32;
-  CARD32 number;
-} xAntiInterpolateColorsReq;
-#define sz_xAntiInterpolateColorsReq 16
-
-
-typedef struct {
-    CARD8 reqType;
-    CARD8 xAntiReqType;
-    CARD16 length B16;
-    Drawable drawable B32;
-    GContext gc B32;
-    INT16 x B16, y B16;		/* items (xTextElt) start after struct */
-} xAntiPolyTextReq;    
-#define sz_xAntiPolyTextReq 16
-
-typedef xAntiPolyTextReq xAntiPolyText8Req;
-typedef xAntiPolyTextReq xAntiPolyText16Req;
-#define sz_xAntiPolyText8Req sz_xAntiPolyTextReq
-#define sz_xAntiPolyText16Req sz_xAntiPolyTextReq
-
-typedef struct {
-    CARD8 reqType;
-    CARD8 xAntiReqType;
-    CARD16 length B16;
-    BYTE nChars;
-    CARD8 pad1;
-    CARD16 pad2;
-    Drawable drawable B32;
-    GContext gc B32;
-    INT16 x B16, y B16;
-} xAntiImageTextReq;    
-#define sz_xAntiImageTextReq 20
-
-typedef xAntiImageTextReq xAntiImageText8Req;
-typedef xAntiImageTextReq xAntiImageText16Req;
-#define sz_xAntiImageText8Req sz_xAntiImageTextReq 
-#define sz_xAntiImageText16Req sz_xAntiImageTextReq 
-
-/* Replies */
-
-typedef struct {
-  BYTE type;   /* X_Reply */
-  CARD8 pad1;
-  CARD16 sequenceNumber B16;
-  CARD32 length B32;
-  CARD16 version B16;
-  CARD16 revision B16;
-  CARD32 pad2 B32;
-  CARD32 pad3 B32;
-  CARD32 pad4 B32;
-  CARD32 pad5 B32;
-  CARD32 pad6 B32;
-} xAntiQueryExtensionReply;
-#define sz_xAntiQueryExtensionReply 32
-
-
-typedef struct {
-  BYTE type;   /* X_Reply */
-  CARD8 pad1;
-  CARD16 sequenceNumber B16;
-  CARD32 length B32;
-  CARD32 pad2 B32;
-  CARD32 pad3 B32;
-  CARD32 pad4 B32;
-  CARD32 pad5 B32;
-  CARD32 pad6 B32;
-  CARD32 pad7 B32;
-} xAntiInterpolateColorsReply;
-#define sz_xAntiInterpolateColorsReply 32
-
-
-#endif /* _XANTIPROTO_H */
Index: xc/include/extensions/XKB.h
diff -u xc/include/extensions/XKB.h:1.1.1.6 xc/include/extensions/XKB.h:1.3
--- xc/include/extensions/XKB.h:1.1.1.6	Fri Feb  9 04:37:46 1996
+++ xc/include/extensions/XKB.h	Tue Oct 24 18:45:01 2000
@@ -24,6 +24,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
+/* $XFree86: xc/include/extensions/XKB.h,v 1.3 2000/10/24 22:45:01 dawes Exp $ */
 
 #ifndef _XKB_H_
 #define	_XKB_H_
@@ -257,6 +258,8 @@
 #define	XkbPerKeyRepeatMask	 (1L << 30)
 #define	XkbControlsEnabledMask	 (1L << 31)
 
+#define	XkbAccessXOptionsMask    (XkbStickyKeysMask|XkbAccessXFeedbackMask)
+
 #define	XkbAllBooleanCtrlsMask	 (0x00001FFF)
 #define	XkbAllControlsMask	 (0xF8001FFF)
 #define	XkbAllControlEventsMask	 XkbAllControlsMask
@@ -675,8 +678,9 @@
 #define	XkbIM_UseCompat		(1L << 4)
 
 #define	XkbIM_UseNone	  0
-#define	XkbIM_UseAnyGroup (XkbIM_UseLatched|XkbIM_UseLocked|XkbIM_UseEffective)
-#define	XkbIM_UseAnyMods  (XkbIM_UseAnyGroup|XkbIM_UseCompat|XkbIM_UseBase)
+#define	XkbIM_UseAnyGroup (XkbIM_UseBase|XkbIM_UseLatched|XkbIM_UseLocked\
+                           |XkbIM_UseEffective)
+#define	XkbIM_UseAnyMods  (XkbIM_UseAnyGroup|XkbIM_UseCompat)
 
     /*
      * Compatibility Map Compontents:
Index: xc/include/extensions/XKBsrv.h
diff -u xc/include/extensions/XKBsrv.h:3.16 xc/include/extensions/XKBsrv.h:3.17
--- xc/include/extensions/XKBsrv.h:3.16	Sun Jan 31 07:21:16 1999
+++ xc/include/extensions/XKBsrv.h	Sat Aug 26 11:11:23 2000
@@ -24,7 +24,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
-/* $XFree86: xc/include/extensions/XKBsrv.h,v 3.16 1999/01/31 12:21:16 dawes Exp $ */
+/* $XFree86: xc/include/extensions/XKBsrv.h,v 3.17 2000/08/26 15:11:23 dawes Exp $ */
 
 #ifndef _XKBSRV_H_
 #define	_XKBSRV_H_
@@ -235,7 +235,7 @@
 
 #define XkbAX_KRGMask	 (XkbSlowKeysMask|XkbBounceKeysMask)
 #define	XkbAllFilteredEventsMask \
-			(XkbAccessXKeysMask|XkbRepeatKeysMask|XkbAX_KRGMask)
+	(XkbAccessXKeysMask|XkbRepeatKeysMask|XkbMouseKeysAccelMask|XkbAX_KRGMask)
 
 /***====================================================================***/
 
Index: xc/include/extensions/extutil.h
diff -u xc/include/extensions/extutil.h:1.2 xc/include/extensions/extutil.h:1.4
--- xc/include/extensions/extutil.h:1.2	Sun Mar  7 03:29:27 1999
+++ xc/include/extensions/extutil.h	Tue Sep 26 11:56:45 2000
@@ -27,7 +27,7 @@
  * protocol extensions.  THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
  * ARE SUBJECT TO CHANGE!
  */
-/* $XFree86: xc/include/extensions/extutil.h,v 1.2 1999/03/07 08:29:27 dawes Exp $ */
+/* $XFree86: xc/include/extensions/extutil.h,v 1.4 2000/09/26 15:56:45 tsi Exp $ */
 
 #ifndef _EXTUTIL_H_
 #define _EXTUTIL_H_
@@ -188,8 +188,8 @@
     return dpyinfo; \
 }
 
-#define XEXT_FIND_DISLPAY_PROTO(proc) \
-	XExtDisplayInfo *proc(Display dpy)
+#define XEXT_FIND_DISPLAY_PROTO(proc) \
+	XExtDisplayInfo *proc(Display *dpy)
 
 #define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
 int proc (Display *dpy, XExtCodes *codes) \
Index: xc/include/extensions/render.h
diff -u /dev/null xc/include/extensions/render.h:1.3
--- /dev/null	Mon Dec 18 14:23:21 2000
+++ xc/include/extensions/render.h	Mon Nov 20 02:13:09 2000
@@ -0,0 +1,113 @@
+/*
+ * $XFree86: xc/include/extensions/render.h,v 1.3 2000/11/20 07:13:09 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _RENDER_H_
+#define _RENDER_H_
+
+typedef unsigned long	Glyph;
+typedef unsigned long	GlyphSet;
+typedef unsigned long	Picture;
+typedef unsigned long	PictFormat;
+
+#define RENDER_NAME	"RENDER"
+#define RENDER_MAJOR	0
+#define RENDER_MINOR	1
+
+#define X_RenderQueryVersion		    0
+#define X_RenderQueryPictFormats	    1
+#define X_RenderQueryPictIndexValues	    2
+#define X_RenderQueryDithers		    3
+#define X_RenderCreatePicture		    4
+#define X_RenderChangePicture		    5
+#define X_RenderSetPictureClipRectangles    6
+#define X_RenderFreePicture		    7
+#define X_RenderComposite		    8
+#define X_RenderScale			    9
+#define X_RenderTrapezoids		    10
+#define X_RenderTriangles		    11
+#define X_RenderTriStrip		    12
+#define X_RenderTriFan			    13
+#define X_RenderColorTrapezoids		    14
+#define X_RenderColorTriangles		    15
+#define X_RenderTransform		    16
+#define X_RenderCreateGlyphSet		    17
+#define X_RenderReferenceGlyphSet	    18
+#define X_RenderFreeGlyphSet		    19
+#define X_RenderAddGlyphs		    20
+#define X_RenderAddGlyphsFromPicture	    21
+#define X_RenderFreeGlyphs		    22
+#define X_RenderCompositeGlyphs8	    23
+#define X_RenderCompositeGlyphs16	    24
+#define X_RenderCompositeGlyphs32	    25
+#define X_RenderFillRectangles		    26
+
+#define BadPictFormat			    0
+#define BadPicture			    1
+#define BadPictOp			    2
+#define BadGlyphSet			    3
+#define BadGlyph			    4
+#define RenderNumberErrors		    (BadGlyph+1)
+
+#define PictTypeIndexed			    0
+#define PictTypeDirect			    1
+
+#define PictOpClear			    0
+#define PictOpSrc			    1
+#define PictOpDst			    2
+#define PictOpOver			    3
+#define PictOpOverReverse		    4
+#define PictOpIn			    5
+#define PictOpInReverse			    6
+#define PictOpOut			    7
+#define PictOpOutReverse		    8
+#define PictOpAtop			    9
+#define PictOpAtopReverse		    10
+#define PictOpXor			    11
+#define PictOpAdd			    12
+#define PictOpSaturate			    13
+#define PictOpMaximum			    13
+
+#define PolyEdgeSharp			    0
+#define PolyEdgeSmooth			    1
+
+#define PolyModePrecise			    0
+#define PolyModeImprecise		    1
+
+#define CPRepeat			    (1 << 0)
+#define CPAlphaMap			    (1 << 1)
+#define CPAlphaXOrigin			    (1 << 2)
+#define CPAlphaYOrigin			    (1 << 3)
+#define CPClipXOrigin			    (1 << 4)
+#define CPClipYOrigin			    (1 << 5)
+#define CPClipMask			    (1 << 6)
+#define CPGraphicsExposure		    (1 << 7)
+#define CPSubwindowMode			    (1 << 8)
+#define CPPolyEdge			    (1 << 9)
+#define CPPolyMode			    (1 << 10)
+#define CPDither			    (1 << 11)
+#define CPComponentAlpha		    (1 << 12)
+#define CPLastBit			    11
+
+#endif	/* _RENDER_H_ */
Index: xc/include/extensions/renderproto.h
diff -u /dev/null xc/include/extensions/renderproto.h:1.5
--- /dev/null	Mon Dec 18 14:23:21 2000
+++ xc/include/extensions/renderproto.h	Mon Nov 20 02:13:09 2000
@@ -0,0 +1,425 @@
+/*
+ * $XFree86: xc/include/extensions/renderproto.h,v 1.5 2000/11/20 07:13:09 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _XRENDERP_H_
+#define _XRENDERP_H_
+
+#include "render.h"
+
+#define Window CARD32
+#define Drawable CARD32
+#define Font CARD32
+#define Pixmap CARD32
+#define Cursor CARD32
+#define Colormap CARD32
+#define GContext CARD32
+#define Atom CARD32
+#define VisualID CARD32
+#define Time CARD32
+#define KeyCode CARD8
+#define KeySym CARD32
+
+#define Picture	    CARD32
+#define PictFormat  CARD32
+#define Fixed	    INT32
+#define Glyphset    CARD32
+#define Glyph	    CARD32
+
+/*
+ * data structures
+ */
+
+typedef struct {
+    CARD16  red B16;
+    CARD16  redMask B16;
+    CARD16  green B16;
+    CARD16  greenMask B16;
+    CARD16  blue B16;
+    CARD16  blueMask B16;
+    CARD16  alpha B16;
+    CARD16  alphaMask B16;
+} xDirectFormat;
+
+#define sz_xDirectFormat    16
+
+typedef struct {
+    PictFormat	id B32;
+    CARD8	type;
+    CARD8	depth;
+    CARD16	pad1 B16;
+    xDirectFormat   direct;
+    Colormap	colormap;
+} xPictFormInfo;
+
+#define sz_xPictFormInfo    16
+
+typedef struct {
+    VisualID	visual;
+    PictFormat	format;
+} xPictVisual;
+
+#define sz_xPictVisual	    8
+
+typedef struct {
+    CARD8	depth;
+    CARD8	pad1;
+    CARD16	nPictVisuals B16;
+    CARD32	pad2 B32;
+} xPictDepth;
+
+#define sz_xPictDepth	8
+
+typedef struct {
+    CARD32	nDepth B32;
+    PictFormat	fallback B32;
+} xPictScreen;
+
+#define sz_xPictScreen	8
+
+typedef struct {
+    CARD32	pixel B32;
+    CARD16	red B16;
+    CARD16	green B16;
+    CARD16	blue B16;
+    CARD16	alpha B16;
+} xIndexValue;
+
+#define sz_xIndexValue	12
+
+typedef struct {
+    CARD16	red B16;
+    CARD16	green B16;
+    CARD16	blue B16;
+    CARD16	alpha B16;
+} xRenderColor;
+
+#define sz_xRenderColor	8
+
+typedef struct {
+    Fixed	x B32;
+    Fixed	y B32;
+} xPointFixed;
+
+#define sz_xPointFixed	8
+
+typedef struct {
+    xPointFixed	p1, p2, p3;
+} xTriangle;
+
+#define sz_xTriangle	24
+
+typedef struct {
+    CARD16  width B16;
+    CARD16  height B16;
+    INT16   x B16;
+    INT16   y B16;
+    INT16   xOff B16;
+    INT16   yOff B16;
+} xGlyphInfo;
+
+#define sz_xGlyphInfo	12
+
+typedef struct {
+    CARD8   len;
+    CARD8   pad1;
+    CARD16  pad2;
+    INT16   deltax;
+    INT16   deltay;
+} xGlyphElt;
+
+#define sz_xGlyphElt	8
+
+/* 
+ * requests and replies
+ */
+typedef struct {
+    CARD8   reqType;
+    CARD8   renderReqType;
+    CARD16  length B16;
+    CARD32  majorVersion B32;
+    CARD32  minorVersion B32;
+} xRenderQueryVersionReq;
+
+#define sz_xRenderQueryVersionReq   12
+
+typedef struct {
+    BYTE    type;   /* X_Reply */
+    BYTE    pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  majorVersion B32;
+    CARD32  minorVersion B32;
+    CARD32  pad2 B32;
+    CARD32  pad3 B32;
+    CARD32  pad4 B32;
+    CARD32  pad5 B32;
+} xRenderQueryVersionReply;
+
+#define sz_xRenderQueryVersionReply	32
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   renderReqType;
+    CARD16  length B16;
+} xRenderQueryPictFormatsReq;
+
+#define sz_xRenderQueryPictFormatsReq	4
+
+typedef struct {
+    BYTE    type;   /* X_Reply */
+    BYTE    pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  numFormats B32;
+    CARD32  numScreens B32;
+    CARD32  numDepths B32;
+    CARD32  numVisuals B32;
+    CARD32  pad4 B32;
+    CARD32  pad5 B32;
+} xRenderQueryPictFormatsReply;
+
+#define sz_xRenderQueryPictFormatsReply	32
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   renderReqType;
+    CARD16  length B16;
+    PictFormat	format B32;
+} xRenderQueryPictIndexValuesReq;
+
+#define sz_xRenderQueryPictIndexValuesReq   8
+
+typedef struct {
+    BYTE    type;   /* X_Reply */
+    BYTE    pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  numIndexValues;
+    CARD32  pad2 B32;
+    CARD32  pad3 B32;
+    CARD32  pad4 B32;
+    CARD32  pad5 B32;
+    CARD32  pad6 B32;
+} xRenderQueryPictIndexValuesReply;
+
+#define sz_xRenderQueryPictIndexValuesReply 32
+
+typedef struct {
+    CARD8	reqType;
+    CARD8	renderReqType;
+    CARD16	length B16;
+    Picture	pid B32;
+    Drawable	drawable B32;
+    PictFormat	format B32;
+    CARD32	mask B32;
+} xRenderCreatePictureReq;
+
+#define sz_xRenderCreatePictureReq	    20
+
+typedef struct {
+    CARD8	reqType;
+    CARD8	renderReqType;
+    CARD16	length B16;
+    Picture	picture B32;
+    CARD32	mask B32;
+} xRenderChangePictureReq;
+
+#define sz_xRenderChangePictureReq	    12
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    Picture     picture B32;
+    INT16	xOrigin B16;
+    INT16	yOrigin B16;
+} xRenderSetPictureClipRectanglesReq;
+
+#define sz_xRenderSetPictureClipRectanglesReq	    12
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    Picture     picture B32;
+} xRenderFreePictureReq;
+
+#define sz_xRenderFreePictureReq	    8
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    CARD8	op;
+    CARD8	pad1;
+    CARD16	pad2 B16;
+    Picture	src B32;
+    Picture	mask B32;
+    Picture	dst B32;
+    INT16	xSrc B16;
+    INT16	ySrc B16;
+    INT16	xMask B16;
+    INT16	yMask B16;
+    INT16	xDst B16;
+    INT16	yDst B16;
+    CARD16	width B16;
+    CARD16	height B16;
+} xRenderCompositeReq;
+
+#define sz_xRenderCompositeReq		    36
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    Picture	src B32;
+    Picture	dst B32;
+    CARD32	colorScale B32;
+    CARD32	alphaScale B32;
+    INT16	xSrc B16;
+    INT16	ySrc B16;
+    INT16	xDst B16;
+    INT16	yDst B16;
+    CARD16	width B16;
+    CARD16	height B16;
+} xRenderScaleReq;
+
+#define sz_xRenderScaleReq			    32
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    Picture	src B32;
+    Picture	dst B32;
+    INT16	xSrc B16;
+    INT16	ySrc B16;
+} xRenderTrianglesReq;
+
+#define sz_xRenderTrianglesReq			    16
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    Glyphset	gsid B32;
+    PictFormat	format B32;
+} xRenderCreateGlyphSetReq;
+
+#define sz_xRenderCreateGlyphSetReq		    12
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    Glyphset    gsid B32;
+    Glyphset    existing B32;
+} xRenderReferenceGlyphSetReq;
+
+#define sz_xRenderReferenceGlyphSetReq		    24
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    Glyphset    glyphset B32;
+} xRenderFreeGlyphSetReq;
+
+#define sz_xRenderFreeGlyphSetReq		    8
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    Glyphset    glyphset B32;
+    CARD32	nglyphs;
+} xRenderAddGlyphsReq;
+
+#define sz_xRenderAddGlyphsReq			    12
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    Glyphset    glyphset B32;
+} xRenderFreeGlyphsReq;
+
+#define sz_xRenderFreeGlyphsReq			    8
+
+typedef struct {
+    CARD8       reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    CARD8	op;
+    CARD8	pad1;
+    CARD16	pad2 B16;
+    Picture	src B32;
+    Picture	dst B32;
+    PictFormat	maskFormat B32;
+    Glyphset    glyphset B32;
+    INT16	xSrc B16;
+    INT16	ySrc B16;
+} xRenderCompositeGlyphsReq, xRenderCompositeGlyphs8Req, 
+xRenderCompositeGlyphs16Req, xRenderCompositeGlyphs32Req;
+
+#define sz_xRenderCompositeGlyphs8Req		    28
+#define sz_xRenderCompositeGlyphs16Req		    28
+#define sz_xRenderCompositeGlyphs32Req		    28
+
+/* 0.1 and higher */
+
+typedef struct {
+    CARD8	reqType;
+    CARD8       renderReqType;
+    CARD16      length B16;
+    CARD8	op;
+    CARD8	pad1;
+    CARD16	pad2 B16;
+    Picture	dst B32;
+    xRenderColor    color;
+} xRenderFillRectanglesReq;
+
+#define sz_xRenderFillRectanglesReq		    20
+
+#undef Window
+#undef Drawable
+#undef Font
+#undef Pixmap
+#undef Cursor
+#undef Colormap
+#undef GContext
+#undef Atom
+#undef VisualID
+#undef Time
+#undef KeyCode
+#undef KeySym
+
+#undef Picture
+#undef PictFormat
+#undef Fixed
+#undef Glyphset
+#undef Glyph
+
+#endif /* _XRENDERP_H_ */
Index: xc/include/fonts/font.h
diff -u xc/include/fonts/font.h:3.3 xc/include/fonts/font.h:3.4
--- xc/include/fonts/font.h:3.3	Sun Oct 25 02:11:11 1998
+++ xc/include/fonts/font.h	Sun Nov 26 19:10:02 2000
@@ -1,5 +1,4 @@
 /* $XConsortium: font.h /main/14 1996/09/28 16:32:33 rws $ */
-/* $XFree86: xc/include/fonts/font.h,v 3.3 1998/10/25 07:11:11 dawes Exp $ */
 /***********************************************************
 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
@@ -22,6 +21,7 @@
 SOFTWARE.
 
 ******************************************************************/
+/* $XFree86: xc/include/fonts/font.h,v 3.4 2000/11/27 00:10:02 dawes Exp $ */
 /* $NCDId: @(#)font.h,v 1.7 1991/06/24 17:00:23 lemke Exp $ */
 
 #ifndef FONT_H
@@ -96,7 +96,7 @@
 #define CACHING_OFF 0
 #define CACHE_16_BIT_GLYPHS 1
 #define CACHE_ALL_GLYPHS 2
-#define DEFAULT_GLYPH_CACHING_MODE CACHING_OFF
+#define DEFAULT_GLYPH_CACHING_MODE CACHE_16_BIT_GLYPHS
 extern int glyphCachingMode;
 
 struct _Client;
@@ -104,7 +104,7 @@
 extern int StartListFontsWithInfo(
     struct _Client * /*client*/,
     int /*length*/,
-    unsigned char */*pattern*/,
+    unsigned char * /*pattern*/,
     int /*max_names*/
 );
 
Index: xc/lib/Imakefile
diff -u xc/lib/Imakefile:3.36 xc/lib/Imakefile:3.41
--- xc/lib/Imakefile:3.36	Wed Mar  1 07:52:01 2000
+++ xc/lib/Imakefile	Thu Nov  2 15:39:07 2000
@@ -1,5 +1,5 @@
 XCOMM $TOG: Imakefile /main/39 1997/02/26 18:09:44 kaleb $
-XCOMM $XFree86: xc/lib/Imakefile,v 3.36 2000/03/01 12:52:01 tsi Exp $
+XCOMM $XFree86: xc/lib/Imakefile,v 3.41 2000/11/02 20:39:07 dawes Exp $
 #define IHaveSubdirs
 #define PassCDebugFlags
 
@@ -55,12 +55,9 @@
 XINERAMADIR=Xinerama
 #endif
 
-#if BuildXantiLibrary
-XANTILIBDIR = Xanti
-#endif
-
 #if BuildGLXLibrary
 GLXLIBDIR = GL
+GLWLIBDIR = GLw
 #endif
 
 #if BuildDPSLibrary
@@ -75,6 +72,14 @@
 PSRESLIBDIR = psres
 #endif
 
+#if BuildRenderLibrary
+RENDERLIBDIR = Xrender
+#endif
+
+#if BuildXftLibrary
+XFTLIBDIR = Xft
+#endif
+
 XF86EXTLIBS = $(XF86MISCLIBDIR) $(XF86VMLIBDIR) \
 		$(XF86DGALIBDIR) $(XF86RUSHLIBDIR)
 
@@ -105,9 +110,9 @@
 	     $(SSLIBDIR) $(XF86MISCLIBDIR) $(XF86VMLIBDIR) $(XF86DGALIBDIR) \
 	     $(XF86RUSHLIBDIR) Xmu Xpm Xaw $(XAW6LIBDIR) XIE Xi Xtst FS \
 	     PEX5 $(XKBLIBDIR) $(XKBUILIBDIR) $(LBXUTILDIR) $(XALIBDIR) \
-	     Xp $(XVLIBDIR) $(XANTILIBDIR) $(GLXLIBDIR) $(DPSLIBDIR) \
+	     Xp $(XVLIBDIR) $(GLXLIBDIR) $(GLWLIBDIR) $(DPSLIBDIR) \
 	     $(DPSTKLIBDIR) $(PSRESLIBDIR) $(XINERAMADIR) \
-	     $(ZLIBDIR) $(REGEXDIR)
+	     $(ZLIBDIR) $(REGEXDIR) $(RENDERLIBDIR) $(XFTLIBDIR)
 #else
 #if XnestServer || BuildGLXLibrary
 XEXTDIR = Xext
@@ -115,7 +120,8 @@
 
 LINTSUBDIRS = Xau Xdmcp X11 $(XINERAMADIR) $(XEXTDIR) $(XKBLIBDIR) \
 	      $(XKBUILIBDIR) $(LBXUTILDIR) $(XF86EXTLIBS) $(XVLIBDIR) \
-	      $(GLXLIBDIR) $(ZLIBDIR) $(REGEXDIR)
+	      $(GLXLIBDIR) $(GLWLIBDIR) $(ZLIBDIR) $(REGEXDIR) $(RENDERLIBDIR) \
+	      $(XFTLIBDIR)
 #endif
 
 SUBDIRS = $(BERKDIR) xtrans $(LINTSUBDIRS) $(FONTSUBDIR) $(FONTCACHELIBDIR)
Index: xc/lib/GL/GL-def.cpp
diff -u /dev/null xc/lib/GL/GL-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:23:22 2000
+++ xc/lib/GL/GL-def.cpp	Wed Aug  9 19:40:11 2000
@@ -0,0 +1,431 @@
+LIBRARY libGL
+VERSION LIBRARY_VERSION
+EXPORTS
+	glClearIndex @ 1 
+	glClearColor @ 2 
+	glClear @ 3 
+	glIndexMask @ 4 
+	glColorMask @ 5 
+	glAlphaFunc @ 6 
+	glBlendFunc @ 7 
+	glLogicOp @ 8 
+	glCullFace @ 9 
+	glFrontFace @ 10 
+	glPointSize @ 11 
+	glLineWidth @ 12 
+	glLineStipple @ 13 
+	glPolygonMode @ 14 
+	glPolygonStipple @ 15 
+	glGetPolygonStipple @ 16 
+	glEdgeFlag @ 17 
+	glEdgeFlagv @ 18 
+	glScissor @ 19 
+	glClipPlane @ 20 
+	glGetClipPlane @ 21 
+	glDrawBuffer @ 22 
+	glReadBuffer @ 23 
+	glEnable @ 24 
+	glDisable @ 25 
+	glIsEnabled @ 26 
+	glGetBooleanv @ 27 
+	glGetDoublev @ 28 
+	glGetFloatv @ 29 
+	glGetIntegerv @ 30 
+	glPushAttrib @ 31 
+	glPopAttrib @ 32 
+	glRenderMode @ 33 
+	glGetError @ 34 
+	glGetString @ 35 
+	glFinish @ 36 
+	glFlush @ 37 
+	glHint @ 38 
+	glClearDepth @ 39 
+	glDepthFunc @ 40 
+	glDepthMask @ 41 
+	glDepthRange @ 42 
+	glClearAccum @ 43 
+	glAccum @ 44 
+	glMatrixMode @ 45 
+	glOrtho @ 46 
+	glFrustum @ 47 
+	glViewport @ 48 
+	glPushMatrix @ 49 
+	glPopMatrix @ 50 
+	glLoadIdentity @ 51 
+	glLoadMatrixd @ 52 
+	glLoadMatrixf @ 53 
+	glMultMatrixd @ 54 
+	glMultMatrixf @ 55 
+	glRotated @ 56 
+	glRotatef @ 57 
+	glScaled @ 58 
+	glScalef @ 59 
+	glTranslated @ 60 
+	glTranslatef @ 61 
+	glIsList @ 62 
+	glDeleteLists @ 63 
+	glGenLists @ 64 
+	glNewList @ 65 
+	glEndList @ 66 
+	glCallList @ 67 
+	glCallLists @ 68 
+	glListBase @ 69 
+	glBegin @ 70 
+	glEnd @ 71 
+	glVertex2d @ 72 
+	glVertex2f @ 73 
+	glVertex2i @ 74 
+	glVertex2s @ 75 
+	glVertex3d @ 76 
+	glVertex3f @ 77 
+	glVertex3i @ 78 
+	glVertex3s @ 79 
+	glVertex4d @ 80 
+	glVertex4f @ 81 
+	glVertex4i @ 82 
+	glVertex4s @ 83 
+	glVertex2dv @ 84 
+	glVertex2fv @ 85 
+	glVertex2iv @ 86 
+	glVertex2sv @ 87 
+	glVertex3dv @ 88 
+	glVertex3fv @ 89 
+	glVertex3iv @ 90 
+	glVertex3sv @ 91 
+	glVertex4dv @ 92 
+	glVertex4fv @ 93 
+	glVertex4iv @ 94 
+	glVertex4sv @ 95 
+	glNormal3b @ 96 
+	glNormal3d @ 97 
+	glNormal3f @ 98 
+	glNormal3i @ 99 
+	glNormal3s @ 100 
+	glNormal3bv @ 101 
+	glNormal3dv @ 102 
+	glNormal3fv @ 103 
+	glNormal3iv @ 104 
+	glNormal3sv @ 105 
+	glIndexd @ 106 
+	glIndexf @ 107 
+	glIndexi @ 108 
+	glIndexs @ 109 
+	glIndexdv @ 110 
+	glIndexfv @ 111 
+	glIndexiv @ 112 
+	glIndexsv @ 113 
+	glColor3b @ 114 
+	glColor3d @ 115 
+	glColor3f @ 116 
+	glColor3i @ 117 
+	glColor3s @ 118 
+	glColor3ub @ 119 
+	glColor3ui @ 120 
+	glColor3us @ 121 
+	glColor4b @ 122 
+	glColor4d @ 123 
+	glColor4f @ 124 
+	glColor4i @ 125 
+	glColor4s @ 126 
+	glColor4ub @ 127 
+	glColor4ui @ 128 
+	glColor4us @ 129 
+	glColor3bv @ 130 
+	glColor3dv @ 131 
+	glColor3fv @ 132 
+	glColor3iv @ 133 
+	glColor3sv @ 134 
+	glColor3ubv @ 135 
+	glColor3uiv @ 136 
+	glColor3usv @ 137 
+	glColor4bv @ 138 
+	glColor4dv @ 139 
+	glColor4fv @ 140 
+	glColor4iv @ 141 
+	glColor4sv @ 142 
+	glColor4ubv @ 143 
+	glColor4uiv @ 144 
+	glColor4usv @ 145 
+	glTexCoord1d @ 146 
+	glTexCoord1f @ 147 
+	glTexCoord1i @ 148 
+	glTexCoord1s @ 149 
+	glTexCoord2d @ 150 
+	glTexCoord2f @ 151 
+	glTexCoord2i @ 152 
+	glTexCoord2s @ 153 
+	glTexCoord3d @ 154 
+	glTexCoord3f @ 155 
+	glTexCoord3i @ 156 
+	glTexCoord3s @ 157 
+	glTexCoord4d @ 158 
+	glTexCoord4f @ 159 
+	glTexCoord4i @ 160 
+	glTexCoord4s @ 161 
+	glTexCoord1dv @ 162 
+	glTexCoord1fv @ 163 
+	glTexCoord1iv @ 164 
+	glTexCoord1sv @ 165 
+	glTexCoord2dv @ 166 
+	glTexCoord2fv @ 167 
+	glTexCoord2iv @ 168 
+	glTexCoord2sv @ 169 
+	glTexCoord3dv @ 170 
+	glTexCoord3fv @ 171 
+	glTexCoord3iv @ 172 
+	glTexCoord3sv @ 173 
+	glTexCoord4dv @ 174 
+	glTexCoord4fv @ 175 
+	glTexCoord4iv @ 176 
+	glTexCoord4sv @ 177 
+	glRasterPos2d @ 178 
+	glRasterPos2f @ 179 
+	glRasterPos2i @ 180 
+	glRasterPos2s @ 181 
+	glRasterPos3d @ 182 
+	glRasterPos3f @ 183 
+	glRasterPos3i @ 184 
+	glRasterPos3s @ 185 
+	glRasterPos4d @ 186 
+	glRasterPos4f @ 187 
+	glRasterPos4i @ 188 
+	glRasterPos4s @ 189 
+	glRasterPos2dv @ 190 
+	glRasterPos2fv @ 191 
+	glRasterPos2iv @ 192 
+	glRasterPos2sv @ 193 
+	glRasterPos3dv @ 194 
+	glRasterPos3fv @ 195 
+	glRasterPos3iv @ 196 
+	glRasterPos3sv @ 197 
+	glRasterPos4dv @ 198 
+	glRasterPos4fv @ 199 
+	glRasterPos4iv @ 200 
+	glRasterPos4sv @ 201 
+	glRectd @ 202 
+	glRectf @ 203 
+	glRecti @ 204 
+	glRects @ 205 
+	glRectdv @ 206 
+	glRectfv @ 207 
+	glRectiv @ 208 
+	glRectsv @ 209 
+	glShadeModel @ 210 
+	glLightf @ 211 
+	glLighti @ 212 
+	glLightfv @ 213 
+	glLightiv @ 214 
+	glGetLightfv @ 215 
+	glGetLightiv @ 216 
+	glLightModelf @ 217 
+	glLightModeli @ 218 
+	glLightModelfv @ 219 
+	glLightModeliv @ 220 
+	glMaterialf @ 221 
+	glMateriali @ 222 
+	glMaterialfv @ 223 
+	glMaterialiv @ 224 
+	glGetMaterialfv @ 225 
+	glGetMaterialiv @ 226 
+	glColorMaterial @ 227 
+	glPixelZoom @ 228 
+	glPixelStoref @ 229 
+	glPixelStorei @ 230 
+	glPixelTransferf @ 231 
+	glPixelTransferi @ 232 
+	glPixelMapfv @ 233 
+	glPixelMapuiv @ 234 
+	glPixelMapusv @ 235 
+	glGetPixelMapfv @ 236 
+	glGetPixelMapuiv @ 237 
+	glGetPixelMapusv @ 238 
+	glBitmap @ 239 
+	glReadPixels @ 240 
+	glDrawPixels @ 241 
+	glCopyPixels @ 242 
+	glStencilFunc @ 243 
+	glStencilMask @ 244 
+	glStencilOp @ 245 
+	glClearStencil @ 246 
+	glTexGend @ 247 
+	glTexGenf @ 248 
+	glTexGeni @ 249 
+	glTexGendv @ 250 
+	glTexGenfv @ 251 
+	glTexGeniv @ 252 
+	glGetTexGendv @ 253 
+	glGetTexGenfv @ 254 
+	glGetTexGeniv @ 255 
+	glTexEnvf @ 256 
+	glTexEnvi @ 257 
+	glTexEnvfv @ 258 
+	glTexEnviv @ 259 
+	glGetTexEnvfv @ 260 
+	glGetTexEnviv @ 261 
+	glTexParameterf @ 262 
+	glTexParameteri @ 263 
+	glTexParameterfv @ 264 
+	glTexParameteriv @ 265 
+	glGetTexParameterfv @ 266 
+	glGetTexParameteriv @ 267 
+	glGetTexLevelParameterfv @ 268 
+	glGetTexLevelParameteriv @ 269 
+	glTexImage1D @ 270 
+	glTexImage2D @ 271 
+	glGetTexImage @ 272 
+	glMap1d @ 273 
+	glMap1f @ 274 
+	glMap2d @ 275 
+	glMap2f @ 276 
+	glGetMapdv @ 277 
+	glGetMapfv @ 278 
+	glGetMapiv @ 279 
+	glEvalCoord1d @ 280 
+	glEvalCoord1f @ 281 
+	glEvalCoord1dv @ 282 
+	glEvalCoord1fv @ 283 
+	glEvalCoord2d @ 284 
+	glEvalCoord2f @ 285 
+	glEvalCoord2dv @ 286 
+	glEvalCoord2fv @ 287 
+	glMapGrid1d @ 288 
+	glMapGrid1f @ 289 
+	glMapGrid2d @ 290 
+	glMapGrid2f @ 291 
+	glEvalPoint1 @ 292 
+	glEvalPoint2 @ 293 
+	glEvalMesh1 @ 294 
+	glEvalMesh2 @ 295 
+	glFogf @ 296 
+	glFogi @ 297 
+	glFogfv @ 298 
+	glFogiv @ 299 
+	glFeedbackBuffer @ 300 
+	glPassThrough @ 301 
+	glSelectBuffer @ 302 
+	glInitNames @ 303 
+	glLoadName @ 304 
+	glPushName @ 305 
+	glPopName @ 306 
+;	glBlendEquationEXT @ 307 
+;	glBlendColorEXT @ 308 
+	glPolygonOffset @ 309 
+;	glVertexPointerEXT @ 310 
+;	glNormalPointerEXT @ 311 
+;	glColorPointerEXT @ 312 
+;	glIndexPointerEXT @ 313 
+;	glTexCoordPointerEXT @ 314 
+;	glEdgeFlagPointerEXT @ 315 
+;	glGetPointervEXT @ 316 
+;	glArrayElementEXT @ 317 
+;	glDrawArraysEXT @ 318 
+;	OSMesaCreateContext @ 319 
+;	OSMesaDestroyContext @ 320 
+;	OSMesaMakeCurrent @ 321 
+;	XMesaCreateContext @ 322 
+;	XMesaDestroyContext @ 323 
+;	XMesaMakeCurrent @ 326 
+;	XMesaGetCurrentContext @ 327 
+;	XMesaSwapBuffers @ 328 
+;	XMesaGetBackBuffer @ 329 
+	glXChooseVisual @ 330 
+	glXCreateContext @ 331 
+	glXDestroyContext @ 332 
+	glXMakeCurrent @ 333 
+	glXCopyContext @ 334 
+	glXSwapBuffers @ 335 
+	glXCreateGLXPixmap @ 336 
+	glXDestroyGLXPixmap @ 337 
+	glXQueryExtension @ 338 
+	glXQueryVersion @ 339 
+	glXIsDirect @ 340 
+	glXGetConfig @ 341 
+	glXGetCurrentContext @ 342 
+	glXGetCurrentDrawable @ 343 
+	glXWaitGL @ 344 
+	glXWaitX @ 345 
+	glXUseXFont @ 346 
+	glXQueryExtensionsString @ 347 
+	glXQueryServerString @ 348 
+	glXGetClientString @ 349 
+	glPushClientAttrib @ 350 
+	glPopClientAttrib @ 351 
+	glIndexub @ 352 
+	glIndexubv @ 353 
+	glVertexPointer @ 354 
+	glNormalPointer @ 355 
+	glColorPointer @ 356 
+	glIndexPointer @ 357 
+	glTexCoordPointer @ 358 
+	glEdgeFlagPointer @ 359 
+	glGetPointerv @ 360 
+	glArrayElement @ 361 
+	glDrawArrays @ 362 
+	glDrawElements @ 363 
+	glInterleavedArrays @ 364 
+	glGenTextures @ 365 
+	glDeleteTextures @ 366 
+	glBindTexture @ 367 
+	glPrioritizeTextures @ 368 
+	glAreTexturesResident @ 369 
+	glIsTexture @ 370 
+	glTexSubImage1D @ 371 
+	glTexSubImage2D @ 372 
+	glCopyTexImage1D @ 373 
+	glCopyTexImage2D @ 374 
+	glCopyTexSubImage1D @ 375 
+	glCopyTexSubImage2D @ 376 
+;	glWindowPos2iMESA @ 377 
+;	glWindowPos2sMESA @ 378 
+;	glWindowPos2fMESA @ 379 
+;	glWindowPos2dMESA @ 380 
+;	glWindowPos2ivMESA @ 381 
+;	glWindowPos2svMESA @ 382 
+;	glWindowPos2fvMESA @ 383 
+;	glWindowPos2dvMESA @ 384 
+;	glWindowPos3iMESA @ 385 
+;	glWindowPos3sMESA @ 386 
+;	glWindowPos3fMESA @ 387 
+;	glWindowPos3dMESA @ 388 
+;	glWindowPos3ivMESA @ 389 
+;	glWindowPos3svMESA @ 390 
+;	glWindowPos3fvMESA @ 391 
+;	glWindowPos3dvMESA @ 392 
+;	glWindowPos4iMESA @ 393 
+;	glWindowPos4sMESA @ 394 
+;	glWindowPos4fMESA @ 395 
+;	glWindowPos4dMESA @ 396 
+;	glWindowPos4ivMESA @ 397 
+;	glWindowPos4svMESA @ 398 
+;	glWindowPos4fvMESA @ 399 
+;	glWindowPos4dvMESA @ 400 
+;	glXCreateGLXPixmapMESA @ 401 
+;	glXReleaseBuffersMESA @ 402 
+;	OSMesaGetCurrentContext @ 403 
+;	OSMesaPixelStore @ 404 
+;	OSMesaGetIntegerv @ 405 
+;	XMesaCreateVisual @ 406 
+;	XMesaDestroyVisual @ 407 
+;	XMesaCreateWindowBuffer @ 408 
+;	XMesaCreatePixmapBuffer @ 409 
+;	XMesaDestroyBuffer @ 410 
+;	XMesaGetCurrentBuffer @ 411 
+;	XMesaFlush @ 412 
+;	XMesaGetString @ 413 
+;	glPolygonOffsetEXT @ 414 
+	glDisableClientState @ 450
+	glEnableClientState @ 451
+	glXFreeContextEXT @ 452
+	glXGetContextIDEXT @ 453
+	glXGetCurrentDisplay @ 454
+	glXImportContextEXT @ 455
+	glXQueryContextInfoEXT @ 456
+	glXGetCurrentDrawableEXT @ 457
+	glCopyTexSubImage3D @ 458
+	glDrawRangeElements @ 459
+	glTexSubImage3D @ 460
+	glBlendColorEXT @ 461
+	glBlendEquationEXT @ 462
+	glTexImage3D @ 463
+
+/* $XFree86: xc/lib/GL/GL-def.cpp,v 1.1 2000/08/09 23:40:11 dawes Exp $ */
Index: xc/lib/GL/Imakefile
diff -u xc/lib/GL/Imakefile:1.28 xc/lib/GL/Imakefile:1.34
--- xc/lib/GL/Imakefile:1.28	Fri Jun 30 15:30:16 2000
+++ xc/lib/GL/Imakefile	Tue Dec 12 18:24:26 2000
@@ -1,8 +1,9 @@
-XCOMM $XFree86: xc/lib/GL/Imakefile,v 1.28 2000/06/30 19:30:16 dawes Exp $
+XCOMM $XFree86: xc/lib/GL/Imakefile,v 1.34 2000/12/12 23:24:26 dawes Exp $
 
 #include <Threads.tmpl>
 
 #define IHaveSubdirs
+
 #define PassCDebugFlags
 
 #define DoNormalLib NormalLibGlx
@@ -18,45 +19,59 @@
 REQUIREDLIBS = SharedGLReqs
 #endif
 
-#if 0
-      LOWSRC = lowpc.c
-      LOWOBJ = lowpc.o
+XCOMM
+XCOMM Not related to ProfileLibGlx - I dont know how that works.  KW.
+XCOMM
+#ifdef GlxSoProf
+      PROFSRC = lowpc.c highpc.c
+      PROFOBJ = lowpc.o highpc.o
 
-       HISRC = highpc.c
-       HIOBJ = highpc.o
+SubdirLibraryRule($(PROFOBJ))
+NormalLintTarget($(PROFSRC))
 #endif
 
 #if BuildXF86DRI && defined(i386Architecture)
-   GLAPI_OBJ = glx/glapi_x86.o
+    GLAPI_OBJ = glx/glapi_x86.o
 #endif
 
-     GLXOBJS = glx/?*.o
-    GLXUOBJS = glx/unshared/?*.o $(GLAPI_OBJ)
-    GLXDOBJS = glx/debugger/?*.o $(GLAPI_OBJ)
-    GLXPOBJS = glx/profiled/?*.o $(GLAPI_OBJ)
-    GLXDONES = glx/DONE
+      GLXOBJS = glx/?*.o
+     GLXUOBJS = glx/unshared/?*.o $(GLAPI_OBJ)
+     GLXDOBJS = glx/debugger/?*.o $(GLAPI_OBJ)
+     GLXPOBJS = glx/profiled/?*.o $(GLAPI_OBJ)
+     GLXDONES = glx/DONE
 
 #if BuildXF86DRI
-     DRIOBJS = dri/XF86dri.o dri/dri_glx.o
-    DRIUOBJS = dri/unshared/XF86dri.o dri/unshared/dri_glx.o
-    DRIDOBJS = dri/debugger/XF86dri.o dri/debugger/dri_glx.o
-    DRIPOBJS = dri/profiled/XF86dri.o dri/profiled/dri_glx.o
-    DRIDONES = dri/DONE
-
-     DRMOBJS = dri/drm/?*.o
-    DRMUOBJS = dri/drm/unshared/?*.o
-    DRMDOBJS = dri/drm/debugger/?*.o
-    DRMPOBJS = dri/drm/profiled/?*.o
-    DRMDONES = dri/drm/DONE
+      DRIOBJS = dri/XF86dri.o dri/dri_glx.o
+     DRIUOBJS = dri/unshared/XF86dri.o dri/unshared/dri_glx.o
+     DRIDOBJS = dri/debugger/XF86dri.o dri/debugger/dri_glx.o
+     DRIPOBJS = dri/profiled/XF86dri.o dri/profiled/dri_glx.o
+     DRIDONES = dri/DONE
+
+      DRMOBJS = dri/drm/?*.o
+     DRMUOBJS = dri/drm/unshared/?*.o
+     DRMDOBJS = dri/drm/debugger/?*.o
+     DRMPOBJS = dri/drm/profiled/?*.o
+     DRMDONES = dri/drm/DONE
 
+     MESAOBJS = mesa/src/?*.o
 #ifdef i386Architecture
-    ASM_OBJS =  mesa/src/X86/common_x86asm.o \
-		mesa/src/X86/mmx_blend.o \
-		mesa/src/X86/vertex.o \
-		mesa/src/X86/x86a.o
-#ifdef MesaUse3DNow
-    ASM_OBJS += mesa/src/X86/3dnow_norm.o \
-		mesa/src/X86/3dnow_norm_raw.o \
+ASM_BASE_OBJS = mesa/src/X86/common_x86_asm.o \
+		mesa/src/X86/x86_cliptest.o \
+		mesa/src/X86/x86_vertex.o \
+		mesa/src/X86/x86_xform_masked2.o \
+		mesa/src/X86/x86_xform_masked3.o \
+		mesa/src/X86/x86_xform_masked4.o \
+		mesa/src/X86/x86_xform_raw2.o \
+		mesa/src/X86/x86_xform_raw3.o \
+		mesa/src/X86/x86_xform_raw4.o
+
+#if MesaUseMMX
+    MMX_OBJS =	mesa/src/X86/mmx_blend.o
+#endif
+
+#if MesaUse3DNow
+   3DNOW_OBJS = mesa/src/X86/3dnow_norm_raw.o \
+		mesa/src/X86/3dnow_vertex.o \
 		mesa/src/X86/3dnow_xform_masked1.o \
 		mesa/src/X86/3dnow_xform_masked2.o \
 		mesa/src/X86/3dnow_xform_masked3.o \
@@ -64,12 +79,26 @@
 		mesa/src/X86/3dnow_xform_raw1.o \
 		mesa/src/X86/3dnow_xform_raw2.o \
 		mesa/src/X86/3dnow_xform_raw3.o \
-		mesa/src/X86/3dnow_xform_raw4.o \
-		mesa/src/X86/vertex_3dnow.o
+		mesa/src/X86/3dnow_xform_raw4.o
 #endif
+#if MesaUseKatmai
+  KATMAI_OBJS = mesa/src/X86/katmai_norm_raw.o \
+		mesa/src/X86/katmai_vertex.o \
+		mesa/src/X86/katmai_xform_masked1.o \
+		mesa/src/X86/katmai_xform_masked2.o \
+		mesa/src/X86/katmai_xform_masked3.o \
+		mesa/src/X86/katmai_xform_masked4.o \
+		mesa/src/X86/katmai_xform_raw1.o \
+		mesa/src/X86/katmai_xform_raw2.o \
+		mesa/src/X86/katmai_xform_raw3.o \
+		mesa/src/X86/katmai_xform_raw4.o
 #endif
 
+    ASM_OBJS = $(ASM_BASE_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS)
+
     MESAOBJS = mesa/src/?*.o mesa/src/X86/?*.o
+#endif
+
    MESAUOBJS = mesa/src/unshared/?*.o mesa/src/X86/unshared/?*.o $(ASM_OBJS)
    MESADOBJS = mesa/src/debugger/?*.o mesa/src/X86/debugger/?*.o $(ASM_OBJS)
    MESAPOBJS = mesa/src/profiled/?*.o mesa/src/X86/profiled/?*.o $(ASM_OBJS)
@@ -122,7 +151,7 @@
     DRVPOBJS = $(TDFXPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS)
     DRVDONES = $(TDFXDONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES)
 
-REQUIREDLIBS += -lglide3x -ldl
+REQUIREDLIBS += -lglide3 -ldl
 
   GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src mesa/src/drv/tdfx
 
@@ -150,11 +179,11 @@
     MGAPOBJS = mesa/src/drv/mga/profiled/?*.o
     MGADONES = mesa/src/drv/mga/DONE
 
-     DRVOBJS = $(MGAOBJS) $(COMMONOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS)
-    DRVUOBJS = $(MGAUOBJS) $(COMMONUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS)
-    DRVDOBJS = $(MGADOBJS) $(COMMONDOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS)
-    DRVPOBJS = $(MGAPOBJS) $(COMMONPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS)
-    DRVDONES = $(MGADONES) $(COMMONDONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES)
+     DRVOBJS = $(MGAOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS)
+    DRVUOBJS = $(MGAUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS)
+    DRVDOBJS = $(MGADOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS)
+    DRVPOBJS = $(MGAPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS)
+    DRVDONES = $(MGADONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES)
 
   GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src mesa/src/drv/mga
 
@@ -241,28 +270,19 @@
 #ifdef OS2Architecture
         OBJS = $(LIBNAME).a
 #else
-        OBJS = $(LOWOBJ) $(GLXOBJS) $(DRIOBJS) $(DRVOBJS) $(HIOBJ)
+        OBJS = $(GLXOBJS) $(DRIOBJS) $(DRVOBJS) 
 #endif
 
 #if HasSharedLibraries
-#if 1
        UOBJS = $(GLXUOBJS) $(DRIUOBJS) $(DRVUOBJS)
 #else
        UOBJS = $(OBJS)
 #endif
-#else
-       UOBJS = $(OBJS)
-#endif
 
        DOBJS = $(GLXDOBJS) $(DRIDOBJS) $(DRVDOBJS)
        POBJS = $(GLXPOBJS) $(DRIPOBJS) $(DRVPOBJS)
        DONES = $(GLXDONES) $(DRIDONES) $(DRVDONES)
 
-#if 0
-SubdirLibraryRule(highpc.o lowpc.o)
-NormalLintTarget(highpc.c lowpc.c)
-#endif
-
 #if LocalThreads
   THREADOBJS = $(THREADS_LIBS)
 #endif
@@ -290,10 +310,11 @@
 InstallSharedLibrary($(LIBNAME),$(SOREV),$(SHLIBDIR))
 #if LinkGLToUsrLib && AlternateUsrLibDir
 install::
+	MakeDir($(DESTDIR)$(SYSTEMUSRLIBDIR))
 	$(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so
-	$(LN) $(SHLIBDIR)/lib$(LIBNAME).so $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so
+	$(LN) $(SHLIBDIR)/lib$(LIBNAME).so $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so || true
 	$(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1
-	$(LN) $(SHLIBDIR)/lib$(LIBNAME).so.1 $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1
+	$(LN) $(SHLIBDIR)/lib$(LIBNAME).so.1 $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1 || true
 #endif
 #endif
 #if DebugLibGlx
Index: xc/lib/GL/highpc.c
diff -u xc/lib/GL/highpc.c:1.1 xc/lib/GL/highpc.c:1.3
--- xc/lib/GL/highpc.c:1.1	Fri Jun 16 20:02:47 2000
+++ xc/lib/GL/highpc.c	Tue Sep 26 11:56:45 2000
@@ -1,3 +1,5 @@
+/* $XFree86: xc/lib/GL/highpc.c,v 1.3 2000/09/26 15:56:45 tsi Exp $ */
+
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -32,16 +34,17 @@
    fprintf(stderr, "\n\n\nIn glx_init_prof\n\n\n");
 
    if (!s) return;
+   if (profile) return;
 
    profile = 1;
    monstartup( (char *)glx_lowpc, (char *)glx_highpc );
 
-   fprintf(stderr, "Starting profiling, %x %x\n", 
-	   (unsigned int)glx_lowpc, 
-	   (unsigned int)glx_highpc);
+   fprintf(stderr, "Starting profiling, %lx %lx\n", 
+	   (unsigned long)glx_lowpc, 
+	   (unsigned long)glx_highpc);
 
    if ((fp = fopen( "glx_lowpc", "w" )) != NULL) {
-      fprintf( fp, "0x%08x ", (unsigned int)glx_lowpc );
+      fprintf( fp, "0x%08lx ", (unsigned long)glx_lowpc );
       fclose( fp );
    }
 }
Index: xc/lib/GL/makeprofile.sh
diff -u xc/lib/GL/makeprofile.sh:1.1 xc/lib/GL/makeprofile.sh:1.3
--- xc/lib/GL/makeprofile.sh:1.1	Fri Jun 16 20:02:47 2000
+++ xc/lib/GL/makeprofile.sh	Sun Aug 27 22:43:11 2000
@@ -1,13 +1,23 @@
 #!/bin/sh
+# $XFree86: xc/lib/GL/makeprofile.sh,v 1.3 2000/08/28 02:43:11 tsi Exp $
 
-RUNDIR=$1
+libname=$1
 
-[ -f ${RUNDIR}/glx_lowpc ] || { echo "no file ${RUNDIR}/glx_lowpc" ; exit 1 } 
-[ -f ${RUNDIR}/gmon.out ] || { echo "no file ${RUNDIR}/gmon.out" ; exit 1 }
+if [ ! -f ${libname} ] ; then
+    echo "no file ${libname}" 
+    srcdir=${LIBGL_MODULES_DIR}
+    driver=$1
+    libname=${srcdir}/lib_${driver}_dri_p.a
+    echo "trying ${libname}" 
+fi
 
-rm -f glx_lowpc gmon.out glxsyms profile
-ln -s ${RUNDIR}/glx_lowpc . || exit 1
-ln -s ${RUNDIR}/gmon.out . || exit 1
+if [ ! -f ${libname} ] ; then 
+   echo "no file ${libname}"
+   echo "please specify full path to lib_(driver)_dri_p.a"
+   exit 1 
+fi
 
-ld -o glxsyms -noinhibit-exec --whole-archive -Ttext=`cat glx_lowpc` libGL.a 2> /dev/null && \
-gprof glxsyms < gmon.out > profile
+ld -o glxsyms -noinhibit-exec --whole-archive -Ttext=`cat glx_lowpc` ${libname} 2> /dev/null || { echo "couldn't build relocated object" ; exit 1 }
+
+gprof glxsyms < gmon.out > profile || { echo "gprof failed" ; exit 1 }
+
Index: xc/lib/GL/dri/XF86dri.c
diff -u xc/lib/GL/dri/XF86dri.c:1.7 xc/lib/GL/dri/XF86dri.c:1.11
--- xc/lib/GL/dri/XF86dri.c:1.7	Tue Jun 20 01:08:37 2000
+++ xc/lib/GL/dri/XF86dri.c	Thu Dec  7 15:26:02 2000
@@ -1,7 +1,8 @@
-/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.7 2000/06/20 05:08:37 dawes Exp $ */
+/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.11 2000/12/07 20:26:02 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,8 +29,9 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Jens Owen <jens@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Jens Owen <jens@valinux.com>
+ *   Rickard E. (Rik) Faith <faith@valinux.com>
  *
  */
 
@@ -83,17 +85,27 @@
  *                                                                           *
  *****************************************************************************/
 
+#if 0
+#define TRACE(msg)  printf("XF86DRI%s\n", msg);
+#else
+#define TRACE(msg)
+#endif
+
+
 Bool XF86DRIQueryExtension (dpy, event_basep, error_basep)
     Display *dpy;
     int *event_basep, *error_basep;
 {
     XExtDisplayInfo *info = find_display (dpy);
 
+    TRACE("QueryExtension...");
     if (XextHasExtension(info)) {
 	*event_basep = info->codes->first_event;
 	*error_basep = info->codes->first_error;
+        TRACE("QueryExtension... return True");
 	return True;
     } else {
+        TRACE("QueryExtension... return False");
 	return False;
     }
 }
@@ -108,6 +120,7 @@
     xXF86DRIQueryVersionReply rep;
     xXF86DRIQueryVersionReq *req;
 
+    TRACE("QueryVersion...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -117,6 +130,7 @@
     if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 	UnlockDisplay(dpy);
 	SyncHandle();
+        TRACE("QueryVersion... return False");
 	return False;
     }
     *majorVersion = rep.majorVersion;
@@ -124,6 +138,7 @@
     *patchVersion = rep.patchVersion;
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("QueryVersion... return True");
     return True;
 }
 
@@ -136,6 +151,7 @@
     xXF86DRIQueryDirectRenderingCapableReply rep;
     xXF86DRIQueryDirectRenderingCapableReq *req;
 
+    TRACE("QueryDirectRenderingCapable...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -146,11 +162,13 @@
     if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 	UnlockDisplay(dpy);
 	SyncHandle();
+        TRACE("QueryDirectRenderingCapable... return False");
 	return False;
     }
     *isCapable = rep.isCapable;
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("QueryDirectRenderingCapable... return True");
     return True;
 }
 
@@ -164,6 +182,7 @@
     xXF86DRIOpenConnectionReply rep;
     xXF86DRIOpenConnectionReq *req;
 
+    TRACE("OpenConnection...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -174,6 +193,7 @@
     if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 	UnlockDisplay(dpy);
 	SyncHandle();
+        TRACE("OpenConnection... return False");
 	return False;
     }
 
@@ -187,6 +207,7 @@
             _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
             UnlockDisplay(dpy);
             SyncHandle();
+            TRACE("OpenConnection... return False");
             return False;
         }
 	_XReadPad(dpy, *busIdString, rep.busIdStringLength);
@@ -195,6 +216,7 @@
     }
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("OpenConnection... return True");
     return True;
 }
 
@@ -207,6 +229,7 @@
     xXF86DRIAuthConnectionReq *req;
     xXF86DRIAuthConnectionReply rep;
 
+    TRACE("AuthConnection...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -219,10 +242,12 @@
     if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
 	UnlockDisplay(dpy);
 	SyncHandle();
+        TRACE("AuthConnection... return False");
 	return False;
     }
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("AuthConnection... return True");
     return True;
 }
 
@@ -233,6 +258,8 @@
     XExtDisplayInfo *info = find_display (dpy);
     xXF86DRICloseConnectionReq *req;
 
+    TRACE("CloseConnection...");
+
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -242,6 +269,7 @@
     req->screen = screen;
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("CloseConnection... return True");
     return True;
 }
 
@@ -258,6 +286,7 @@
     xXF86DRIGetClientDriverNameReply rep;
     xXF86DRIGetClientDriverNameReq *req;
 
+    TRACE("GetClientDriverName...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -268,6 +297,7 @@
     if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 	UnlockDisplay(dpy);
 	SyncHandle();
+        TRACE("GetClientDriverName... return False");
 	return False;
     }
 
@@ -278,6 +308,9 @@
     if (rep.length) {
         if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
             _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
+            UnlockDisplay(dpy);
+            SyncHandle();
+            TRACE("GetClientDriverName... return False");
             return False;
         }
 	_XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
@@ -286,6 +319,7 @@
     }
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("GetClientDriverName... return True");
     return True;
 }
 
@@ -300,6 +334,7 @@
     xXF86DRICreateContextReply rep;
     xXF86DRICreateContextReq *req;
 
+    TRACE("CreateContext...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -313,11 +348,13 @@
     if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 	UnlockDisplay(dpy);
 	SyncHandle();
+        TRACE("CreateContext... return False");
 	return False;
     }
     *hHWContext = rep.hHWContext;
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("CreateContext... return True");
     return True;
 }
 
@@ -329,6 +366,7 @@
     XExtDisplayInfo *info = find_display (dpy);
     xXF86DRIDestroyContextReq *req;
 
+    TRACE("DestroyContext...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -339,6 +377,7 @@
     req->context = context;
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("DestroyContext... return True");
     return True;
 }
 
@@ -352,6 +391,7 @@
     xXF86DRICreateDrawableReply rep;
     xXF86DRICreateDrawableReq *req;
 
+    TRACE("CreateDrawable...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -363,11 +403,13 @@
     if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 	UnlockDisplay(dpy);
 	SyncHandle();
+        TRACE("CreateDrawable... return False");
 	return False;
     }
     *hHWDrawable = rep.hHWDrawable;
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("CreateDrawable... return True");
     return True;
 }
 
@@ -379,6 +421,7 @@
     XExtDisplayInfo *info = find_display (dpy);
     xXF86DRIDestroyDrawableReq *req;
 
+    TRACE("DestroyDrawable...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -389,6 +432,7 @@
     req->drawable = drawable;
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("DestroyDrawable... return True");
     return True;
 }
 
@@ -419,6 +463,7 @@
     xXF86DRIGetDrawableInfoReq *req;
     int total_rects;
 
+    TRACE("GetDrawableInfo...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -432,6 +477,7 @@
     {
 	UnlockDisplay(dpy);
 	SyncHandle();
+        TRACE("GetDrawableInfo... return False");
 	return False;
     }
     *index = rep.drawableTableIndex;
@@ -448,20 +494,28 @@
     *numBackClipRects = rep.numBackClipRects;
     total_rects += *numBackClipRects;
 
-    if (rep.length != (SIZEOF(xXF86DRIGetDrawableInfoReply) - 
+#if 0
+    /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
+     * backwards compatibility (Because of the >> 2 shift) but the fix
+     * enables multi-threaded apps to work.
+     */
+    if (rep.length !=  ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - 
 		       SIZEOF(xGenericReply) + 
-		       total_rects * sizeof(XF86DRIClipRectRec))) {
-       _XEatData(dpy, rep.length);
-       return False;
+		       total_rects * sizeof(XF86DRIClipRectRec)) + 3) & ~3) >> 2)) {
+        _XEatData(dpy, rep.length);
+	UnlockDisplay(dpy);
+	SyncHandle();
+        TRACE("GetDrawableInfo... return False");
+        return False;
     }
-       
+#endif
 
     if (*numClipRects) {
        int len = sizeof(XF86DRIClipRectRec) * (*numClipRects);
 
        *pClipRects = (XF86DRIClipRectPtr)Xcalloc(len, 1);
        if (*pClipRects) 
-	  _XRead32(dpy, *pClipRects, len);
+	  _XRead(dpy, (char*)*pClipRects, len);
     } else {
         *pClipRects = NULL;
     }
@@ -471,13 +525,14 @@
 
        *pBackClipRects = (XF86DRIClipRectPtr)Xcalloc(len, 1);
        if (*pBackClipRects) 
-	  _XRead32(dpy, *pBackClipRects, len);
+	  _XRead(dpy, (char*)*pBackClipRects, len);
     } else {
         *pBackClipRects = NULL;
     }
 
     UnlockDisplay(dpy);
     SyncHandle();
+    TRACE("GetDrawableInfo... return True");
     return True;
 }
 
@@ -496,6 +551,7 @@
     xXF86DRIGetDeviceInfoReply rep;
     xXF86DRIGetDeviceInfoReq *req;
 
+    TRACE("GetDeviceInfo...");
     XF86DRICheckExtension (dpy, info, False);
 
     LockDisplay(dpy);
@@ -506,12 +562,13 @@
     if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
 	UnlockDisplay(dpy);
 	SyncHandle();
+        TRACE("GetDeviceInfo... return False");
 	return False;
     }
 
     *hFrameBuffer = rep.hFrameBufferLow;
 #ifdef LONG64
-    *hFrameBuffer = ((drmHandle)rep.hFrameBufferHigh) << 32;
+    *hFrameBuffer |= ((drmHandle)rep.hFrameBufferHigh) << 32;
 #endif
 
     *fbOrigin = rep.framebufferOrigin;
@@ -520,14 +577,79 @@
     *devPrivateSize = rep.devPrivateSize;
 
     if (rep.length) {
-        if (!(*pDevPrivate = (void *)Xcalloc(rep.length, 1))) {
-            _XEatData(dpy, ((rep.length+3) & ~3));
+        if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
+            _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
+            UnlockDisplay(dpy);
+            SyncHandle();
+            TRACE("GetDeviceInfo... return False");
             return False;
         }
-	_XRead32(dpy, *pDevPrivate, rep.length);
+	_XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
     } else {
         *pDevPrivate = NULL;
     }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    TRACE("GetDeviceInfo... return True");
+    return True;
+}
+
+Bool XF86DRIOpenFullScreen(dpy, screen, drawable)
+    Display* dpy;
+    int screen;
+    Drawable drawable;
+{
+    XExtDisplayInfo             *info = find_display (dpy);
+    xXF86DRIOpenFullScreenReply rep;
+    xXF86DRIOpenFullScreenReq   *req;
+
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRIOpenFullScreen, req);
+    req->reqType    = info->codes->major_opcode;
+    req->driReqType = X_XF86DRIOpenFullScreen;
+    req->screen     = screen;
+    req->drawable   = drawable;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+	UnlockDisplay(dpy);
+	SyncHandle();
+	return False;
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return rep.isFullScreen ? True : False;
+}
+
+Bool XF86DRICloseFullScreen(dpy, screen, drawable)
+    Display* dpy;
+    int screen;
+    Drawable drawable;
+{
+    XExtDisplayInfo              *info = find_display (dpy);
+    xXF86DRICloseFullScreenReply rep;
+    xXF86DRICloseFullScreenReq   *req;
+
+    XF86DRICheckExtension (dpy, info, False);
+
+    LockDisplay(dpy);
+    GetReq(XF86DRICloseFullScreen, req);
+    req->reqType    = info->codes->major_opcode;
+    req->driReqType = X_XF86DRICloseFullScreen;
+    req->screen     = screen;
+    req->drawable   = drawable;
+
+				/* The reply doesn't contain any data --
+                                   we just use it as a synchronization
+                                   point. */
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+	UnlockDisplay(dpy);
+	SyncHandle();
+	return False;
+    }
+
     UnlockDisplay(dpy);
     SyncHandle();
     return True;
Index: xc/lib/GL/dri/dri_glx.c
diff -u xc/lib/GL/dri/dri_glx.c:1.5 xc/lib/GL/dri/dri_glx.c:1.7
--- xc/lib/GL/dri/dri_glx.c:1.5	Fri Jun 16 20:02:48 2000
+++ xc/lib/GL/dri/dri_glx.c	Tue Sep 26 11:56:45 2000
@@ -24,6 +24,7 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
+/* $XFree86: xc/lib/GL/dri/dri_glx.c,v 1.7 2000/09/26 15:56:45 tsi Exp $ */
 
 /*
  * Authors:
@@ -300,6 +301,14 @@
     __DRIdisplayPrivate *pdpyp;
     int eventBase, errorBase;
     int major, minor, patch;
+
+    /* Initialize these fields to NULL in case we fail.
+     * If we don't do this we may later get segfaults trying to free random
+     * addresses when the display is closed.
+     */
+    pdisp->private = NULL;
+    pdisp->destroyDisplay = NULL;
+    pdisp->createScreen = NULL;
 
     if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) {
 	return NULL;
Index: xc/lib/GL/dri/xf86dri.h
diff -u xc/lib/GL/dri/xf86dri.h:1.6 xc/lib/GL/dri/xf86dri.h:1.7
--- xc/lib/GL/dri/xf86dri.h:1.6	Fri Jun 16 20:02:48 2000
+++ xc/lib/GL/dri/xf86dri.h	Thu Dec  7 15:26:02 2000
@@ -1,7 +1,8 @@
-/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.6 2000/06/17 00:02:48 martin Exp $ */
+/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.7 2000/12/07 20:26:02 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,9 +29,9 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Jens Owen <jens@precisioninsight.com>
- *   Rickard E. Faith <faith@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Jens Owen <jens@valinux.com>
+ *   Rickard E. (Rik) Faith <faith@valinux.com>
  *
  */
 
@@ -52,6 +53,8 @@
 #define X_XF86DRIGetDrawableInfo		9
 #define X_XF86DRIGetDeviceInfo			10
 #define X_XF86DRIAuthConnection                 11
+#define X_XF86DRIOpenFullScreen                 12
+#define X_XF86DRICloseFullScreen                13
 
 #define XF86DRINumberEvents		0
 
@@ -197,6 +200,22 @@
     int*		/* fbStride */,
     int*		/* devPrivateSize */,
     void**		/* pDevPrivate */
+#endif
+);
+
+Bool XF86DRIOpenFullScreen(
+#if NeedFunctionPrototypes
+    Display*		/* dpy */,
+    int                 /* screen */,
+    Drawable 		/* drawable */
+#endif
+);
+
+Bool XF86DRICloseFullScreen(
+#if NeedFunctionPrototypes
+    Display*		/* dpy */,
+    int                 /* screen */,
+    Drawable 		/* drawable */
 #endif
 );
 
Index: xc/lib/GL/dri/xf86dristr.h
diff -u xc/lib/GL/dri/xf86dristr.h:1.6 xc/lib/GL/dri/xf86dristr.h:1.7
--- xc/lib/GL/dri/xf86dristr.h:1.6	Fri Jun 16 20:02:48 2000
+++ xc/lib/GL/dri/xf86dristr.h	Thu Dec  7 15:26:02 2000
@@ -1,7 +1,8 @@
-/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.6 2000/06/17 00:02:48 martin Exp $ */
+/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.7 2000/12/07 20:26:02 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,8 +29,9 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Jens Owen <jens@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Jens Owen <jens@valinux.com>
+ *   Rickard E. (Rik) Fiath <faith@valinux.com>
  *
  */
 
@@ -282,5 +284,51 @@
 } xXF86DRIGetDeviceInfoReply;
 #define sz_xXF86DRIGetDeviceInfoReply	32
 
-#endif /* _XF86DRISTR_H_ */
+typedef struct _XF86DRIOpenFullScreen {
+    CARD8       reqType;	/* always DRIReqCode */
+    CARD8       driReqType;	/* always X_DRIOpenFullScreen */
+    CARD16      length B16;
+    CARD32      screen B32;
+    CARD32      drawable B32;
+} xXF86DRIOpenFullScreenReq;
+#define sz_xXF86DRIOpenFullScreenReq    12
+
+typedef struct {
+    BYTE        type;
+    BOOL        pad1;
+    CARD16      sequenceNumber B16;
+    CARD32      length B32;
+    CARD32      isFullScreen B32;
+    CARD32      pad2 B32;
+    CARD32      pad3 B32;
+    CARD32      pad4 B32;
+    CARD32      pad5 B32;
+    CARD32      pad6 B32;
+} xXF86DRIOpenFullScreenReply;
+#define sz_xXF86DRIOpenFullScreenReply  32
+
+typedef struct _XF86DRICloseFullScreen {
+    CARD8       reqType;	/* always DRIReqCode */
+    CARD8       driReqType;	/* always X_DRICloseFullScreen */
+    CARD16      length B16;
+    CARD32      screen B32;
+    CARD32      drawable B32;
+} xXF86DRICloseFullScreenReq;
+#define sz_xXF86DRICloseFullScreenReq   12
 
+typedef struct {
+    BYTE        type;
+    BOOL        pad1;
+    CARD16      sequenceNumber B16;
+    CARD32      length B32;
+    CARD32      pad2 B32;
+    CARD32      pad3 B32;
+    CARD32      pad4 B32;
+    CARD32      pad5 B32;
+    CARD32      pad6 B32;
+    CARD32      pad7 B32;
+} xXF86DRICloseFullScreenReply;
+#define sz_xXF86DRICloseFullScreenReply  32
+
+
+#endif /* _XF86DRISTR_H_ */
Index: xc/lib/GL/dri/drm/Imakefile
diff -u xc/lib/GL/dri/drm/Imakefile:1.6 xc/lib/GL/dri/drm/Imakefile:1.10
--- xc/lib/GL/dri/drm/Imakefile:1.6	Fri Jun 30 13:15:07 2000
+++ xc/lib/GL/dri/drm/Imakefile	Sun Sep 24 09:51:00 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/dri/drm/Imakefile,v 1.6 2000/06/30 17:15:07 dawes Exp $
+XCOMM $XFree86: xc/lib/GL/dri/drm/Imakefile,v 1.10 2000/09/24 13:51:00 alanh Exp $
 
 #define DoNormalLib NormalLibGlx
 #define DoSharedLib SharedLibGlx
@@ -11,7 +11,10 @@
 #endif
 
       DEFINES = $(ALLOC_DEFINES)
-     INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I.
+     INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I. \
+		-I$(XF86OSSRC)/$(OS_SUBDIR)/drm \
+		-I$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel \
+		-I$(XF86OSSRC)
          SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c \
 		xf86drmR128.c
          OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o \
@@ -19,22 +22,28 @@
 
 #if defined(LinuxArchitecture)
 OS_SUBDIR = linux
+OS_SUBDIR2 = linux
 #endif
 #if defined(FreeBSDArchitecture) || defined(BSDOSArchitecture)
 OS_SUBDIR = bsd
+OS_SUBDIR2 = linux
 #endif
+#if defined(cygwinArchitecture) && 0	/* XXX FIX ME */
+OS_SUBDIR = cygwin
+OS_SUBDIR2 = cygwin
+#endif
 
 LinkSourceFile(xf86drm.c,$(XF86OSSRC)/$(OS_SUBDIR)/drm)
-LinkSourceFile(xf86drmHash.c,$(XF86OSSRC)/$(OS_SUBDIR)/drm)
-LinkSourceFile(xf86drmRandom.c,$(XF86OSSRC)/$(OS_SUBDIR)/drm)
-LinkSourceFile(xf86drmSL.c,$(XF86OSSRC)/$(OS_SUBDIR)/drm)
-LinkSourceFile(xf86drm.h,$(XF86OSSRC))
-LinkSourceFile(drm.h,$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel)
-LinkSourceFile(mga_drm.h,$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel)
-LinkSourceFile(i810_drm.h,$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel)
-LinkSourceFile(xf86drmR128.c,$(XF86OSSRC)/$(OS_SUBDIR)/drm)
-LinkSourceFile(xf86drmR128.h,$(XF86OSSRC))
-LinkSourceFile(r128_drm.h,$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel)
+LinkSourceFile(xf86drmHash.c,$(XF86OSSRC)/$(OS_SUBDIR2)/drm)
+LinkSourceFile(xf86drmRandom.c,$(XF86OSSRC)/$(OS_SUBDIR2)/drm)
+LinkSourceFile(xf86drmSL.c,$(XF86OSSRC)/$(OS_SUBDIR2)/drm)
+LinkSourceFile(xf86drmR128.c,$(XF86OSSRC)/$(OS_SUBDIR2)/drm)
+
+LinkSourceFile(drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel)
+LinkSourceFile(i810_drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel)
+LinkSourceFile(mga_drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel)
+LinkSourceFile(r128_drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel)
+LinkSourceFile(sis_drm.h,$(XF86OSSRC)/$(OS_SUBDIR2)/drm/kernel)
 
 #include <Library.tmpl>
 
Index: xc/lib/GL/glx/Imakefile
diff -u xc/lib/GL/glx/Imakefile:1.10 xc/lib/GL/glx/Imakefile:1.11
--- xc/lib/GL/glx/Imakefile:1.10	Fri Jun 30 13:15:07 2000
+++ xc/lib/GL/glx/Imakefile	Tue Aug  1 16:28:38 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/glx/Imakefile,v 1.10 2000/06/30 17:15:07 dawes Exp $
+XCOMM $XFree86: xc/lib/GL/glx/Imakefile,v 1.11 2000/08/01 20:28:38 dawes Exp $
 XCOMM The contents of this file are subject to the GLX Public License Version 1.0
 XCOMM (the "License"). You may not use this file except in compliance with the
 XCOMM License. You may obtain a copy of the License at Silicon Graphics, Inc.,
@@ -31,18 +31,18 @@
 XCOMM 	glu \
 XCOMM 	glw
 
-LinkSourceFile(glapi.c, ../../../extras/Mesa/src)
-LinkSourceFile(glapi.h, ../../../extras/Mesa/src)
-LinkSourceFile(glapinoop.c, ../../../extras/Mesa/src)
-LinkSourceFile(glapinoop.h, ../../../extras/Mesa/src)
-LinkSourceFile(glapioffsets.h, ../../../extras/Mesa/src)
-LinkSourceFile(glapitable.h, ../../../extras/Mesa/src)
-LinkSourceFile(glapitemp.h, ../../../extras/Mesa/src)
-LinkSourceFile(glheader.h, ../../../extras/Mesa/src)
-LinkSourceFile(glthread.c, ../../../extras/Mesa/src)
-LinkSourceFile(glthread.h, ../../../extras/Mesa/src)
-LinkSourceFile(glapi_x86.S, ../../../extras/Mesa/src/X86)
-LinkSourceFile(assyntax.h, ../../../extras/Mesa/src/X86)
+LinkSourceFile(glapi.c, $(MESASRCDIR)/src)
+LinkSourceFile(glapi.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapinoop.c, $(MESASRCDIR)/src)
+LinkSourceFile(glapinoop.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapioffsets.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapitable.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapitemp.h, $(MESASRCDIR)/src)
+LinkSourceFile(glheader.h, $(MESASRCDIR)/src)
+LinkSourceFile(glthread.c, $(MESASRCDIR)/src)
+LinkSourceFile(glthread.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapi_x86.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(assyntax.h, $(MESASRCDIR)/src/X86)
 
      GLX_SRCS = \
 		clientattrib.c \
Index: xc/lib/GL/glx/glxclient.h
diff -u xc/lib/GL/glx/glxclient.h:1.7 xc/lib/GL/glx/glxclient.h:1.11
--- xc/lib/GL/glx/glxclient.h:1.7	Thu Mar  2 11:07:31 2000
+++ xc/lib/GL/glx/glxclient.h	Thu Dec  7 15:26:03 2000
@@ -1,5 +1,3 @@
-#ifndef _GLX_client_h_
-#define _GLX_client_h_
 
 /*
 ** The contents of this file are subject to the GLX Public License Version 1.0
@@ -20,6 +18,7 @@
 ** are Copyright (c) 1991-9 Silicon Graphics, Inc. All Rights Reserved.
 **
 */
+/* $XFree86: xc/lib/GL/glx/glxclient.h,v 1.11 2000/12/07 20:26:03 dawes Exp $ */
 
 /*
  * Direct rendering support added by Precision Insight, Inc.
@@ -29,6 +28,8 @@
  *
  */
 
+#ifndef _GLX_client_h_
+#define _GLX_client_h_
 #define NEED_REPLIES
 #define NEED_EVENTS
 #include <string.h>
@@ -43,6 +44,9 @@
 #ifdef NEED_GL_FUNCS_WRAPPED
 #include "indirect.h"
 #endif
+#ifdef XTHREADS
+#include "Xthreads.h"
+#endif
 
 
 #define GLX_MAJOR_VERSION	1	/* current version numbers */
@@ -122,7 +126,8 @@
     /*
     ** Method to return a pointer to the DRI drawable data.
     */
-    __DRIdrawable *(*getDrawable)(Display *dpy, GLXDrawable draw);
+    __DRIdrawable *(*getDrawable)(Display *dpy, GLXDrawable draw,
+				  void *private);
 
     /*
     ** Opaque pointer to private per screen direct rendering data.  NULL
@@ -152,7 +157,7 @@
     ** Method to unbind a DRI drawable to a DRI graphics context.
     */
     Bool (*unbindContext)(Display *dpy, int scrn, GLXDrawable draw,
-			  GLXContext gc);
+			  GLXContext gc, int will_rebind);
 
     /*
     ** Opaque pointer to private per context direct rendering data.
@@ -560,8 +565,15 @@
 ** Global lock for all threads in this address space using the GLX
 ** extension
 */
+#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
+extern xmutex_rec __glXmutex;
+extern xmutex_rec __glXSwapBuffersMutex;
+#define __glXLock()    xmutex_lock(&__glXmutex)
+#define __glXUnlock()  xmutex_unlock(&__glXmutex)
+#else
 #define __glXLock()
 #define __glXUnlock()
+#endif
 
 /*
 ** Setup for a command.  Initialize the extension for dpy if necessary.
Index: xc/lib/GL/glx/glxcmds.c
diff -u xc/lib/GL/glx/glxcmds.c:1.11 xc/lib/GL/glx/glxcmds.c:1.13
--- xc/lib/GL/glx/glxcmds.c:1.11	Sat Jul  1 11:23:10 2000
+++ xc/lib/GL/glx/glxcmds.c	Mon Nov 13 18:31:23 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/glx/glxcmds.c,v 1.11 2000/07/01 15:23:10 martin Exp $ */
+/* $XFree86: xc/lib/GL/glx/glxcmds.c,v 1.13 2000/11/13 23:31:23 dawes Exp $ */
 /*
 ** The contents of this file are subject to the GLX Public License Version 1.0
 ** (the "License"). You may not use this file except in compliance with the
@@ -68,8 +68,6 @@
     __GLXdisplayPrivate *priv;
 #endif
 
-    if (getenv("LIBGL_ALWAYS_INDIRECT"))
-	allowDirect = GL_FALSE;
     opcode = __glXSetupForCommand(dpy);
     if (!opcode) {
 	return NULL;
@@ -541,6 +539,10 @@
     __GLXdisplayPrivate *priv;
     __DRIdrawable *pdraw;
 
+#if defined(XTHREADS)
+    xmutex_lock(&__glXSwapBuffersMutex);
+#endif
+
     priv = __glXInitialize(dpy);
     if (priv->driDisplay.private) {
 	__GLXscreenConfigs *psc = &priv->screenConfigs[gc->screen];
@@ -549,9 +551,13 @@
 	    ** getDrawable returning NULL implies that the drawable is
 	    ** not bound to a direct rendering context.
 	    */
-	    pdraw = (*psc->driScreen.getDrawable)(dpy, drawable);
+	    pdraw = (*psc->driScreen.getDrawable)(dpy, drawable,
+						  psc->driScreen.private);
 	    if (pdraw) {
 		(*pdraw->swapBuffers)(dpy, pdraw->private);
+#if defined(XTHREADS)
+                xmutex_unlock(&__glXSwapBuffersMutex);
+#endif
 		return;
 	    }
 	}
@@ -560,6 +566,9 @@
 
     opcode = __glXSetupForCommand(dpy);
     if (!opcode) {
+#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
+        xmutex_unlock(&__glXSwapBuffersMutex);
+#endif
 	return;
     }
 
@@ -583,6 +592,9 @@
     UnlockDisplay(dpy);
     SyncHandle();
     XFlush(dpy);
+#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
+    xmutex_unlock(&__glXSwapBuffersMutex);
+#endif
 }
 
 /*
Index: xc/lib/GL/glx/glxext.c
diff -u xc/lib/GL/glx/glxext.c:1.6 xc/lib/GL/glx/glxext.c:1.9
--- xc/lib/GL/glx/glxext.c:1.6	Tue Feb 15 14:19:18 2000
+++ xc/lib/GL/glx/glxext.c	Thu Dec  7 15:26:03 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/glx/glxext.c,v 1.6 2000/02/15 19:19:18 dawes Exp $ */
+/* $XFree86: xc/lib/GL/glx/glxext.c,v 1.9 2000/12/07 20:26:03 dawes Exp $ */
 
 /*
 ** The contents of this file are subject to the GLX Public License Version 1.0
@@ -29,10 +29,10 @@
  */
 
 #include "packrender.h"
-#include <stdio.h>
 #include <Xext.h>
 #include <extutil.h>
 #include <assert.h>
+#include <stdio.h>
 #include "indirect_init.h"
 #include "glapi.h"
 #ifdef XTHREADS
@@ -72,7 +72,7 @@
 
 
 /*
- * Current context management
+ * Current context management and locking
  */
 
 #if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
@@ -107,6 +107,11 @@
    xthread_set_specific(ContextTSD, c);
 }
 
+
+/* Used by the __glXLock() and __glXUnlock() macros */
+xmutex_rec __glXmutex;
+xmutex_rec __glXSwapBuffersMutex;
+
 #else
 
 /* not thread safe */
@@ -179,8 +184,7 @@
     __glXErrorString,			/* error_string */
 };
 
-XExtDisplayInfo *__glXFindDisplay(Display *);
-
+static
 XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
 			   __glXExtensionName, &__glXExtensionHooks,
 			   __GLX_NUMBER_EVENTS, NULL)
@@ -451,6 +455,18 @@
     XEDataObject dataObj;
     int major, minor;
 
+#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
+    {
+        static int firstCall = 1;
+        if (firstCall) {
+            /* initialize the GLX mutexes */
+            xmutex_init(&__glXmutex);
+            xmutex_init(&__glXSwapBuffersMutex);
+            firstCall = 0;
+        }
+    }
+#endif
+
     /* The one and only long long lock */
     __glXLock();
 
@@ -510,8 +526,16 @@
     ** Note: This _must_ be done before calling any other DRI routines
     ** (e.g., those called in AllocAndFetchScreenConfigs).
     */
-    dpyPriv->driDisplay.private =
-	driCreateDisplay(dpy, &dpyPriv->driDisplay);
+    if (getenv("LIBGL_ALWAYS_INDIRECT")) {
+        /* Assinging zero here assures we'll never go direct */
+        dpyPriv->driDisplay.private = 0;
+        dpyPriv->driDisplay.destroyDisplay = 0;
+        dpyPriv->driDisplay.createScreen = 0;
+    }
+    else {
+        dpyPriv->driDisplay.private =
+            driCreateDisplay(dpy, &dpyPriv->driDisplay);
+    }
 #endif
 
     if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
@@ -533,7 +557,9 @@
     XAddToExtensionList(privList, private);
 
     if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) {
+#if 0
         __glXClientInfo(dpy, dpyPriv->majorOpcode);
+#endif
     }
     __glXUnlock();
 
@@ -792,10 +818,13 @@
     /* Unbind the old direct rendering context */
     if (oldGC->isDirect) {
 	if (oldGC->driContext.private) {
+	    int will_rebind = (gc && gc->isDirect
+			       && draw == oldGC->currentDrawable);
 	    if (!(*oldGC->driContext.unbindContext)(oldGC->currentDpy,
 						    oldGC->screen,
 						    oldGC->currentDrawable,
-						    oldGC)) {
+						    oldGC,
+						    will_rebind)) {
 		/* The make current failed.  Just return GL_FALSE. */
 		return GL_FALSE;
 	    }
@@ -811,6 +840,7 @@
 	}
     } else {
 #endif
+        _glapi_check_multithread();
 	/* Send a glXMakeCurrent request to bind the new context. */
 	LockDisplay(dpy);
 	GetReq(GLXMakeCurrent,req);
@@ -820,14 +850,15 @@
 	req->context = gc ? gc->xid : None;
 	req->oldContextTag = oldGC->currentContextTag;
 	bindReturnValue = _XReply(dpy, (xReply*) &reply, 0, False);
+        UnlockDisplay(dpy);
 #ifdef GLX_DIRECT_RENDERING
     }
 #endif
 
+
     if (!bindReturnValue) {
 	/* The make current failed. */
 	if (!gc->isDirect) {
-	    UnlockDisplay(dpy);
 	    SyncHandle();
 	}
 
@@ -884,6 +915,9 @@
 		** request, and cannot adhere to the "no-op" behavior.
 		*/
 	    }
+            else {
+		UnlockDisplay(dpy);
+            }
 	    oldGC->currentContextTag = reply.contextTag;
 	}
 	return GL_FALSE;
Index: xc/lib/GL/glx/packsingle.h
diff -u xc/lib/GL/glx/packsingle.h:1.3 xc/lib/GL/glx/packsingle.h:1.4
--- xc/lib/GL/glx/packsingle.h:1.3	Tue Feb  8 12:18:33 2000
+++ xc/lib/GL/glx/packsingle.h	Mon Aug 28 12:04:48 2000
@@ -1,7 +1,7 @@
 #ifndef __GLX_packsingle_h__
 #define __GLX_packsingle_h__
 
-/* $XFree86: xc/lib/GL/glx/packsingle.h,v 1.3 2000/02/08 17:18:33 dawes Exp $ */
+/* $XFree86: xc/lib/GL/glx/packsingle.h,v 1.4 2000/08/28 16:04:48 dawes Exp $ */
 /*
 ** The contents of this file are subject to the GLX Public License Version 1.0
 ** (the "License"). You may not use this file except in compliance with the
@@ -85,7 +85,7 @@
     *((FLOAT32 *) (pc + offset)) = a
 
 #else
-#define __GLX_SINGLE_PUT_SHORT(offset,a) \     
+#define __GLX_SINGLE_PUT_SHORT(offset,a) \
     { GLubyte *cp = (pc+offset); \
       int shift = (64-16) - ((int)(cp) >> (64-6)); \
       *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
Index: xc/lib/GL/mesa/dri/dri_mesa.c
diff -u xc/lib/GL/mesa/dri/dri_mesa.c:1.8 xc/lib/GL/mesa/dri/dri_mesa.c:1.13
--- xc/lib/GL/mesa/dri/dri_mesa.c:1.8	Mon Jun 26 01:41:29 2000
+++ xc/lib/GL/mesa/dri/dri_mesa.c	Thu Dec  7 15:26:04 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/dri/dri_mesa.c,v 1.8 2000/06/26 05:41:29 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/dri/dri_mesa.c,v 1.13 2000/12/07 20:26:04 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -51,12 +51,14 @@
 static Bool driMesaBindContext(Display *dpy, int scrn,
 			       GLXDrawable draw, GLXContext gc);
 static Bool driMesaUnbindContext(Display *dpy, int scrn,
-				 GLXDrawable draw, GLXContext gc);
+				 GLXDrawable draw, GLXContext gc,
+				 int will_rebind);
 
 /* Drawable methods */
 static void *driMesaCreateDrawable(Display *dpy, int scrn, GLXDrawable draw,
 				   VisualID vid, __DRIdrawable *pdraw);
-static __DRIdrawable *driMesaGetDrawable(Display *dpy, GLXDrawable draw);
+static __DRIdrawable *driMesaGetDrawable(Display *dpy, GLXDrawable draw,
+					 void *private);
 static void driMesaSwapBuffers(Display *dpy, void *private);
 static void driMesaDestroyDrawable(Display *dpy, void *private);
 
@@ -70,6 +72,21 @@
 				 int numConfigs, __GLXvisualConfig *config);
 static void driMesaDestroyScreen(Display *dpy, int scrn, void *private);
 
+static Bool driFeatureOn(const char *name)
+{
+    char *env = getenv(name);
+
+    if (!env) return GL_FALSE;
+    if (!strcasecmp(env, "enable")) return GL_TRUE;
+    if (!strcasecmp(env, "1"))      return GL_TRUE;
+    if (!strcasecmp(env, "on"))     return GL_TRUE;
+    if (!strcasecmp(env, "true"))   return GL_TRUE;
+    if (!strcasecmp(env, "t"))      return GL_TRUE;
+    if (!strcasecmp(env, "yes"))    return GL_TRUE;
+    if (!strcasecmp(env, "y"))      return GL_TRUE;
+
+    return GL_FALSE;
+}
 
 
 /*
@@ -87,30 +104,22 @@
 /*****************************************************************/
 
 /* Maintain a list of drawables */
-
-void *drawHash = NULL; /* Hash table to hold DRI drawables */
 
-static Bool __driMesaAddDrawable(__DRIdrawable *pdraw)
+static Bool __driMesaAddDrawable(void *drawHash, __DRIdrawable *pdraw)
 {
     __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
 
-    /* Create the hash table */
-    if (!drawHash) drawHash = drmHashCreate();
-
     if (drmHashInsert(drawHash, pdp->draw, pdraw))
 	return GL_FALSE;
 
     return GL_TRUE;
 }
 
-static __DRIdrawable *__driMesaFindDrawable(GLXDrawable draw)
+static __DRIdrawable *__driMesaFindDrawable(void *drawHash, GLXDrawable draw)
 {
     int retcode;
     __DRIdrawable *pdraw;
 
-    /* Create the hash table */
-    if (!drawHash) drawHash = drmHashCreate();
-
     retcode = drmHashLookup(drawHash, draw, (void **)&pdraw);
     if (retcode)
 	return NULL;
@@ -118,20 +127,61 @@
     return pdraw;
 }
 
-static void __driMesaRemoveDrawable(__DRIdrawable *pdraw)
+static void __driMesaRemoveDrawable(void *drawHash, __DRIdrawable *pdraw)
 {
     int retcode;
     __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
 
-    /* Create the hash table */
-    if (!drawHash) drawHash = drmHashCreate();
-
     retcode = drmHashLookup(drawHash, pdp->draw, (void **)&pdraw);
     if (!retcode) { /* Found */
 	drmHashDelete(drawHash, pdp->draw);
     }
 }
 
+static Bool __driMesaWindowExistsFlag;
+
+static int __driMesaWindowExistsErrorHandler(Display *dpy, XErrorEvent *xerr)
+{
+    if (xerr->error_code == BadWindow) {
+	__driMesaWindowExistsFlag = GL_FALSE;
+    }
+    return 0;
+}
+
+static Bool __driMesaWindowExists(Display *dpy, GLXDrawable draw)
+{
+    XWindowAttributes xwa;
+    int (*oldXErrorHandler)(Display *, XErrorEvent *);
+
+    __driMesaWindowExistsFlag = GL_TRUE;
+    oldXErrorHandler = XSetErrorHandler(__driMesaWindowExistsErrorHandler);
+    XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
+    XSetErrorHandler(oldXErrorHandler);
+    return __driMesaWindowExistsFlag;
+}
+
+static void __driMesaGarbageCollectDrawables(void *drawHash)
+{
+    GLXDrawable draw;
+    __DRIdrawable *pdraw;
+    Display *dpy;
+
+    if (drmHashFirst(drawHash, &draw, (void **)&pdraw)) {
+	do {
+	    __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+	    dpy = pdp->driScreenPriv->display;
+	    XSync(dpy, GL_FALSE);
+	    if (!__driMesaWindowExists(dpy, draw)) {
+		/* Destroy the local drawable data in the hash table, if the
+		   drawable no longer exists in the Xserver */
+		__driMesaRemoveDrawable(drawHash, pdraw);
+		(*pdraw->destroyDrawable)(dpy, pdraw->private);
+		Xfree(pdraw);
+	    }
+	} while (drmHashNext(drawHash, &draw, (void **)&pdraw));
+    }
+}
+
 /*****************************************************************/
 
 static void driMesaInitAPI(__MesaAPI *MesaAPI)
@@ -146,13 +196,17 @@
     MesaAPI->SwapBuffers = XMesaSwapBuffers;
     MesaAPI->MakeCurrent = XMesaMakeCurrent;
     MesaAPI->UnbindContext = XMesaUnbindContext;
+    MesaAPI->OpenFullScreen = XMesaOpenFullScreen;
+    MesaAPI->CloseFullScreen = XMesaCloseFullScreen;
 }
 
 /*****************************************************************/
 
 static Bool driMesaUnbindContext(Display *dpy, int scrn,
-				 GLXDrawable draw, GLXContext gc)
+				 GLXDrawable draw, GLXContext gc,
+				 int will_rebind)
 {
+    __DRIscreen *pDRIScreen;
     __DRIdrawable *pdraw;
     __DRIcontextPrivate *pcp;
     __DRIscreenPrivate *psp;
@@ -168,19 +222,32 @@
 	return GL_FALSE;
     }
 
-    pdraw = __driMesaFindDrawable(draw);
-    if (!pdraw) {
+    if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
+	/* ERROR!!! */
+	return GL_FALSE;
+    } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
 	/* ERROR!!! */
 	return GL_FALSE;
     }
 
     pcp = (__DRIcontextPrivate *)gc->driContext.private;
-    pdp = (__DRIdrawablePrivate *)pdraw->private;
-    psp = pdp->driScreenPriv;
-    if (!psp) {
+
+    pdraw = __driMesaFindDrawable(psp->drawHash, draw);
+    if (!pdraw) {
 	/* ERROR!!! */
 	return GL_FALSE;
     }
+    pdp = (__DRIdrawablePrivate *)pdraw->private;
+
+				/* Don't leave fullscreen mode if the
+                                   drawable will be rebound in the next
+                                   step -- this avoids a protocol
+                                   request. */
+    if (!will_rebind && psp->fullscreen) {
+	psp->MesaAPI.CloseFullScreen(pcp);
+	XF86DRICloseFullScreen(dpy, scrn, draw);
+	psp->fullscreen = NULL;
+    }
 
     /* Unbind Mesa's drawable from Mesa's context */
     (*psp->MesaAPI.UnbindContext)(pcp);
@@ -198,14 +265,20 @@
 	** context.  This also causes conflicts with caching of the
 	** drawable stamp.
 	**
+	** In addition, we don't destroy the drawable here since Mesa
+	** keeps private data internally (e.g., software accumulation
+	** buffers) that should not be destroyed unless the client
+	** explicitly requests that the window be destroyed.
+	**
 	** When GLX 1.3 is integrated, the create and destroy drawable
 	** functions will have user level counterparts and the memory
 	** will be able to be recovered.
+	** 
+	** Below is an example of what needs to go into the destroy
+	** drawable routine to support GLX 1.3.
 	*/
-
-	/* Delete drawable if no longer referenced by any contexts */
+	__driMesaRemoveDrawable(psp->drawHash, pdraw);
 	(*pdraw->destroyDrawable)(dpy, pdraw->private);
-	__driMesaRemoveDrawable(pdraw);
 	Xfree(pdraw);
 #endif
     }
@@ -220,10 +293,13 @@
 static Bool driMesaBindContext(Display *dpy, int scrn,
 			       GLXDrawable draw, GLXContext gc)
 {
+    __DRIscreen *pDRIScreen;
     __DRIdrawable *pdraw;
     __DRIdrawablePrivate *pdp;
     __DRIscreenPrivate *psp;
     __DRIcontextPrivate *pcp;
+    static Bool envchecked      = False;
+    static Bool checkfullscreen = False;
 
     /*
     ** Assume error checking is done properly in glXMakeCurrent before
@@ -234,8 +310,16 @@
 	/* ERROR!!! */
 	return GL_FALSE;
     }
+
+    if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
+	/* ERROR!!! */
+	return GL_FALSE;
+    } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+	/* ERROR!!! */
+	return GL_FALSE;
+    }
 
-    pdraw = __driMesaFindDrawable(draw);
+    pdraw = __driMesaFindDrawable(psp->drawHash, draw);
     if (!pdraw) {
 	/* Allocate a new drawable */
 	pdraw = (__DRIdrawable *)Xmalloc(sizeof(__DRIdrawable));
@@ -254,7 +338,7 @@
 	}
 
 	/* Add pdraw to drawable list */
-	if (!__driMesaAddDrawable(pdraw)) {
+	if (!__driMesaAddDrawable(psp->drawHash, pdraw)) {
 	    /* ERROR!!! */
 	    (*pdraw->destroyDrawable)(dpy, pdraw->private);
 	    Xfree(pdraw);
@@ -263,11 +347,6 @@
     }
 
     pdp = (__DRIdrawablePrivate *)pdraw->private;
-    psp = pdp->driScreenPriv;
-    if (!psp) {
-	/* ERROR!!! */
-	return GL_FALSE;
-    }
 
     /* Bind the drawable to the context */
     pcp = (__DRIcontextPrivate *)gc->driContext.private;
@@ -278,21 +357,98 @@
     /*
     ** Now that we have a context associated with this drawable, we can
     ** initialize the drawable information if has not been done before.
+    ** Also, since we need it when LIBGL_DRI_FULLSCREEN, pick up any changes
+    ** that are outstanding.
     */
-    if (!pdp->pStamp) {
+    if (!pdp->pStamp || *pdp->pStamp != pdp->lastStamp) {
 	DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
 	driMesaUpdateDrawableInfo(dpy, scrn, pdp);
 	DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
     }
 
-    /* Bind Mesa's drawable to Mesa's context */
+    /* Call device-specific MakeCurrent */
     (*psp->MesaAPI.MakeCurrent)(pcp, pdp, pdp);
 
+    /* Check for the potential to enter an automatic full-screen mode.
+       This may need to be moved up. */
+    if (!envchecked) {
+	checkfullscreen = driFeatureOn("LIBGL_DRI_AUTOFULLSCREEN");
+	envchecked = GL_TRUE;
+    }
+    if (checkfullscreen && pdp->numClipRects == 1) {
+	/* If there is valid information in the SAREA, we can use it to
+	avoid a protocol request.  The only time when the SAREA
+	information won't be valid will be initially, so in the worst
+	case, we'll make one protocol request that we could have
+	avoided. */
+	int try = 1;
+	int clw = pdp->pClipRects[0].x2 - pdp->pClipRects[0].x1;
+	int clh = pdp->pClipRects[0].y2 - pdp->pClipRects[0].y1;
+
+#if 0
+				/* Useful client-side debugging message */
+	fprintf(stderr,
+		"********************************************\n"
+		"********************************************\n"
+		"********************************************\n"
+		"%d @ %d,%d,%d,%d\n"
+		"frame %d,%d,%d,%d\n"
+		"win   %d,%d,%d,%d\n"
+		"fs = %p pdp = %p sarea = %d\n"
+		"********************************************\n"
+		"********************************************\n"
+		"********************************************\n",
+		pdp->numClipRects,
+		pdp->pClipRects[0].x1,
+		pdp->pClipRects[0].y1,
+		pdp->pClipRects[0].x2,
+		pdp->pClipRects[0].y2,
+		psp->pSAREA->frame.x,
+		psp->pSAREA->frame.y,
+		psp->pSAREA->frame.width,
+		psp->pSAREA->frame.height,
+		pdp->x, pdp->y, pdp->w, pdp->h,
+		psp->fullscreen, pdp, psp->pSAREA->frame.fullscreen);
+#endif
+
+
+	if (pdp->x != pdp->pClipRects[0].x1
+	    || pdp->y != pdp->pClipRects[0].y1
+	    || pdp->w != clw
+	    || pdp->h != clh) try = 0;
+
+	if (try && psp->pSAREA->frame.width && psp->pSAREA->frame.height) {
+	    if (pdp->x != psp->pSAREA->frame.x
+		|| pdp->y != psp->pSAREA->frame.y
+		|| pdp->w != psp->pSAREA->frame.width
+		|| pdp->h != psp->pSAREA->frame.height) try = 0;
+	}
+
+	if (try) {
+	    if (psp->fullscreen && !psp->pSAREA->frame.fullscreen) {
+				/* Server has closed fullscreen mode */
+		__driMesaMessage("server closed fullscreen mode\n");
+		psp->fullscreen = NULL;
+	    }
+	    if (XF86DRIOpenFullScreen(dpy, scrn, draw)) {
+		psp->fullscreen = pdp;
+		psp->MesaAPI.OpenFullScreen(pcp);
+	    }
+	}
+    }
+
     return GL_TRUE;
 }
 
 /*****************************************************************/
 
+/*
+ * This function basically updates the __DRIdrawablePrivate struct's
+ * cliprect information by calling XF86DRIGetDrawableInfo().
+ * This is usually called by a macro which compares the
+ * __DRIdrwablePrivate pStamp and lastStamp values.  If the values
+ * are different that means we have to update the clipping info.
+ */
 void driMesaUpdateDrawableInfo(Display *dpy, int scrn,
 			       __DRIdrawablePrivate *pdp)
 {
@@ -318,7 +474,6 @@
 	Xfree(pdp->pBackClipRects); 
     }
 
-
     DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
 
     if (!XF86DRIGetDrawableInfo(dpy, scrn, pdp->draw,
@@ -376,10 +531,17 @@
     pdp->numBackClipRects = 0;
     pdp->pClipRects = NULL;
     pdp->pBackClipRects = NULL;
-
-    pDRIScreen = __glXFindDRIScreen(dpy, scrn);
-    pdp->driScreenPriv = psp = (__DRIscreenPrivate *)pDRIScreen->private;
 
+    if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
+	(void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw);
+	Xfree(pdp);
+	return NULL;
+    } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+	(void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw);
+	Xfree(pdp);
+	return NULL;
+    }
+    pdp->driScreenPriv = psp;
     pdp->driContextPriv = &psp->dummyContextPriv;
 
     for (i = 0; i < psp->numVisuals; i++) {
@@ -408,13 +570,16 @@
     return (void *)pdp;
 }
 
-static __DRIdrawable *driMesaGetDrawable(Display *dpy, GLXDrawable draw)
+static __DRIdrawable *driMesaGetDrawable(Display *dpy, GLXDrawable draw,
+					 void *private)
 {
+    __DRIscreenPrivate *psp = (__DRIscreenPrivate *)private;
+
     /*
     ** Make sure this routine returns NULL if the drawable is not bound
     ** to a direct rendering context!
     */
-    return __driMesaFindDrawable(draw);
+    return __driMesaFindDrawable(psp->drawHash, draw);
 }
 
 static void driMesaSwapBuffers(Display *dpy, void *private)
@@ -433,7 +598,8 @@
 
     if (pdp) {
         gl_destroy_framebuffer(pdp->mesaBuffer);
-	(void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw);
+	if (__driMesaWindowExists(dpy, pdp->draw))
+	    (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw);
 	if (pdp->pClipRects)
 	    Xfree(pdp->pClipRects);
 	Xfree(pdp);
@@ -445,14 +611,19 @@
 static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared,
 				  __DRIcontext *pctx)
 {
+    __DRIscreen *pDRIScreen;
     __DRIcontextPrivate *pcp;
     __DRIcontextPrivate *pshare = (__DRIcontextPrivate *)shared;
     __DRIscreenPrivate *psp;
-    __DRIscreen *pDRIScreen;
     int i;
 
-    pDRIScreen = __glXFindDRIScreen(dpy, vis->screen);
-    psp = (__DRIscreenPrivate *)pDRIScreen->private;
+    if (!(pDRIScreen = __glXFindDRIScreen(dpy, vis->screen))) {
+	/* ERROR!!! */
+	return NULL;
+    } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+	/* ERROR!!! */
+	return NULL;
+    }
 
     if (!psp->dummyContextPriv.driScreenPriv) {
 	if (!XF86DRICreateContext(dpy, vis->screen, vis->visual,
@@ -466,6 +637,9 @@
 	/* No other fields should be used! */
     }
 
+    /* Create the hash table */
+    if (!psp->drawHash) psp->drawHash = drmHashCreate();
+
     pcp = (__DRIcontextPrivate *)Xmalloc(sizeof(__DRIcontextPrivate));
     if (!pcp) {
 	return NULL;
@@ -513,31 +687,27 @@
     pctx->bindContext    = driMesaBindContext;
     pctx->unbindContext  = driMesaUnbindContext;
 
+    __driMesaGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
+
     return pcp;
 }
 
 static void driMesaDestroyContext(Display *dpy, int scrn, void *private)
 {
     __DRIcontextPrivate  *pcp   = (__DRIcontextPrivate *)private;
+    __DRIscreenPrivate   *psp;
     __DRIdrawablePrivate *pdp;
-    __DRIdrawable        *pdraw;
 
     if (pcp) {
-	pdp = pcp->driDrawablePriv;
-	if (pdp) {
-	    /* Unbind Mesa's drawable from Mesa's context */
-	    (*pcp->driScreenPriv->MesaAPI.UnbindContext)(pcp);
-
-	    if (pdp->refcount == 1) {
-		/* If refcount is 1, then this is the last context to
-                   reference this drawable, so we can destroy the
-                   drawable and remove it from the hash table */
-		pdraw = __driMesaFindDrawable(pdp->draw);
-		(*pdraw->destroyDrawable)(dpy, pdraw->private);
-		__driMesaRemoveDrawable(pdraw);
-		Xfree(pdraw);
-	    }
+  	if ((pdp = pcp->driDrawablePriv)) {
+ 	    /* Shut down fullscreen mode */
+ 	    if ((psp = pdp->driScreenPriv) && psp->fullscreen) {
+ 		psp->MesaAPI.CloseFullScreen(pcp);
+ 		XF86DRICloseFullScreen(dpy, scrn, pdp->draw);
+ 		psp->fullscreen = NULL;
+ 	    }
 	}
+	__driMesaGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
 	(void)XF86DRIDestroyContext(dpy, scrn, pcp->contextID);
 	(*pcp->driScreenPriv->MesaAPI.DestroyContext)(pcp);
         gl_destroy_context(pcp->mesaContext);
@@ -740,6 +910,9 @@
     ** to NULL to let CreateContext routine that it needs to be inited.
     */
     psp->dummyContextPriv.driScreenPriv = NULL;
+
+    /* Initialize the drawHash when the first context is created */
+    psp->drawHash = NULL;
 
     psc->destroyScreen  = driMesaDestroyScreen;
     psc->createContext  = driMesaCreateContext;
Index: xc/lib/GL/mesa/dri/dri_mesaint.h
diff -u xc/lib/GL/mesa/dri/dri_mesaint.h:1.7 xc/lib/GL/mesa/dri/dri_mesaint.h:1.9
--- xc/lib/GL/mesa/dri/dri_mesaint.h:1.7	Fri Jun 16 20:02:51 2000
+++ xc/lib/GL/mesa/dri/dri_mesaint.h	Thu Dec  7 15:26:04 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/dri/dri_mesaint.h,v 1.7 2000/06/17 00:02:51 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/dri/dri_mesaint.h,v 1.9 2000/12/07 20:26:04 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -264,10 +264,19 @@
     __DRIcontextPrivate dummyContextPriv;
 
     /*
+    ** Hash table to hold the drawable information for this screen.
+    */
+    void *drawHash;
+
+    /*
     ** Device-dependent private information (not stored in the SAREA).
     ** This pointer is never touched by the DRI layer.
     */
     void *private;
+
+    /* If we're in full screen mode (via DRIOpenFullScreen), this points
+       to the drawable that was bound.  Otherwise, this is NULL. */
+    __DRIdrawablePrivate *fullscreen;
 };
 
 
Index: xc/lib/GL/mesa/dri/dri_xmesaapi.h
diff -u xc/lib/GL/mesa/dri/dri_xmesaapi.h:1.4 xc/lib/GL/mesa/dri/dri_xmesaapi.h:1.5
--- xc/lib/GL/mesa/dri/dri_xmesaapi.h:1.4	Fri Jun 16 20:02:51 2000
+++ xc/lib/GL/mesa/dri/dri_xmesaapi.h	Thu Dec  7 15:26:04 2000
@@ -1,7 +1,8 @@
-/* $XFree86: xc/lib/GL/mesa/dri/dri_xmesaapi.h,v 1.4 2000/06/17 00:02:51 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/dri/dri_xmesaapi.h,v 1.5 2000/12/07 20:26:04 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,8 +29,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Brian E. Paul <brian@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Brian E. Paul <brianp@valinux.com>
  */
 
 
@@ -84,10 +85,11 @@
 
 extern void XMesaSwapBuffers( __DRIdrawablePrivate *driDrawPriv );
 
+extern GLboolean XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv);
+extern GLboolean XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv);
 
 
 
-
 #define XMESA_VALIDATE_DRAWABLE_INFO(dpy, psp, pdp)                     \
 do {                                                                    \
     while (*(pdp->pStamp) != pdp->lastStamp) {                          \
@@ -131,6 +133,8 @@
                                 __DRIdrawablePrivate *driDrawPriv,
                                 __DRIdrawablePrivate *driReadPriv);
     GLboolean    (*UnbindContext)(__DRIcontextPrivate *driContextPriv);
+    GLboolean    (*OpenFullScreen)(__DRIcontextPrivate *driContextPriv);
+    GLboolean    (*CloseFullScreen)(__DRIcontextPrivate *driContextPriv);
 };
 
 
Index: xc/lib/GL/mesa/include/GL/Imakefile
diff -u xc/lib/GL/mesa/include/GL/Imakefile:1.5 xc/lib/GL/mesa/include/GL/Imakefile:1.6
--- xc/lib/GL/mesa/include/GL/Imakefile:1.5	Fri Jun 30 14:27:00 2000
+++ xc/lib/GL/mesa/include/GL/Imakefile	Tue Aug  1 16:28:38 2000
@@ -1,15 +1,15 @@
-XCOMM $XFree86: xc/lib/GL/mesa/include/GL/Imakefile,v 1.5 2000/06/30 18:27:00 dawes Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/include/GL/Imakefile,v 1.6 2000/08/01 20:28:38 dawes Exp $
 
 #define IHaveModules
 #include <Server.tmpl>
 
       DEFINES = $(GLX_DEFINES)
 
-LinkSourceFile(gl.h, ../../../../../extras/Mesa/include/GL)
-LinkSourceFile(glext.h, ../../../../../extras/Mesa/include/GL)
-LinkSourceFile(glx.h, ../../../../../include/GL)
-LinkSourceFile(glxtokens.h, ../../../../../include/GL)
-LinkSourceFile(xmesa.h, ../../../../../extras/Mesa/include/GL)
-LinkSourceFile(xmesa_x.h, ../../../../../extras/Mesa/include/GL)
-LinkSourceFile(xmesa_xf86.h, ../../../../../extras/Mesa/include/GL)
-LinkSourceFile(osmesa.h, ../../../../../extras/Mesa/include/GL)
+LinkSourceFile(gl.h, $(MESASRCDIR)/include/GL)
+LinkSourceFile(glext.h, $(MESASRCDIR)/include/GL)
+LinkSourceFile(glx.h, $(TOP)/include/GL)
+LinkSourceFile(glxtokens.h, $(TOP)/include/GL)
+LinkSourceFile(xmesa.h, $(MESASRCDIR)/include/GL)
+LinkSourceFile(xmesa_x.h, $(MESASRCDIR)/include/GL)
+LinkSourceFile(xmesa_xf86.h, $(MESASRCDIR)/include/GL)
+LinkSourceFile(osmesa.h, $(MESASRCDIR)/include/GL)
Index: xc/lib/GL/mesa/src/Imakefile
diff -u xc/lib/GL/mesa/src/Imakefile:1.15 xc/lib/GL/mesa/src/Imakefile:1.21
--- xc/lib/GL/mesa/src/Imakefile:1.15	Sat Jun 24 12:14:07 2000
+++ xc/lib/GL/mesa/src/Imakefile	Tue Dec 12 18:24:27 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/Imakefile,v 1.15 2000/06/24 16:14:07 dawes Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/Imakefile,v 1.21 2000/12/12 23:24:27 dawes Exp $
 
 #include <Threads.tmpl>
 
@@ -16,185 +16,185 @@
     TDFX_DEFS = -DFX
 #endif
 
-LinkSourceFile(aatriangle.c, ../../../../extras/Mesa/src)
-LinkSourceFile(aatriangle.h, ../../../../extras/Mesa/src)
-LinkSourceFile(aatritemp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(accum.c, ../../../../extras/Mesa/src)
-LinkSourceFile(accum.h, ../../../../extras/Mesa/src)
-LinkSourceFile(all.h, ../../../../extras/Mesa/src)
-LinkSourceFile(alpha.c, ../../../../extras/Mesa/src)
-LinkSourceFile(alpha.h, ../../../../extras/Mesa/src)
-LinkSourceFile(alphabuf.c, ../../../../extras/Mesa/src)
-LinkSourceFile(alphabuf.h, ../../../../extras/Mesa/src)
-LinkSourceFile(attrib.c, ../../../../extras/Mesa/src)
-LinkSourceFile(attrib.h, ../../../../extras/Mesa/src)
-LinkSourceFile(bbox.c, ../../../../extras/Mesa/src)
-LinkSourceFile(bbox.h, ../../../../extras/Mesa/src)
-LinkSourceFile(bitmap.c, ../../../../extras/Mesa/src)
-LinkSourceFile(bitmap.h, ../../../../extras/Mesa/src)
-LinkSourceFile(blend.c, ../../../../extras/Mesa/src)
-LinkSourceFile(blend.h, ../../../../extras/Mesa/src)
-LinkSourceFile(buffers.c, ../../../../extras/Mesa/src)
-LinkSourceFile(buffers.h, ../../../../extras/Mesa/src)
-LinkSourceFile(clip.c, ../../../../extras/Mesa/src)
-LinkSourceFile(clip.h, ../../../../extras/Mesa/src)
-LinkSourceFile(clip_funcs.h, ../../../../extras/Mesa/src)
-LinkSourceFile(clip_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(colortab.c, ../../../../extras/Mesa/src)
-LinkSourceFile(colortab.h, ../../../../extras/Mesa/src)
-LinkSourceFile(config.c, ../../../../extras/Mesa/src)
-LinkSourceFile(config.h, ../../../../extras/Mesa/src)
-LinkSourceFile(context.c, ../../../../extras/Mesa/src)
-LinkSourceFile(context.h, ../../../../extras/Mesa/src)
-LinkSourceFile(copy_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(copypix.c, ../../../../extras/Mesa/src)
-LinkSourceFile(copypix.h, ../../../../extras/Mesa/src)
-LinkSourceFile(cull_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(cva.c, ../../../../extras/Mesa/src)
-LinkSourceFile(cva.h, ../../../../extras/Mesa/src)
-LinkSourceFile(dd.h, ../../../../extras/Mesa/src)
-LinkSourceFile(debug_xform.c, ../../../../extras/Mesa/src)
-LinkSourceFile(debug_xform.h, ../../../../extras/Mesa/src)
-LinkSourceFile(depth.c, ../../../../extras/Mesa/src)
-LinkSourceFile(depth.h, ../../../../extras/Mesa/src)
-LinkSourceFile(dlist.c, ../../../../extras/Mesa/src)
-LinkSourceFile(dlist.h, ../../../../extras/Mesa/src)
-LinkSourceFile(dotprod_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(drawpix.c, ../../../../extras/Mesa/src)
-LinkSourceFile(drawpix.h, ../../../../extras/Mesa/src)
-LinkSourceFile(enable.c, ../../../../extras/Mesa/src)
-LinkSourceFile(enable.h, ../../../../extras/Mesa/src)
-LinkSourceFile(enums.c, ../../../../extras/Mesa/src)
-LinkSourceFile(enums.h, ../../../../extras/Mesa/src)
-LinkSourceFile(eval.c, ../../../../extras/Mesa/src)
-LinkSourceFile(eval.h, ../../../../extras/Mesa/src)
-LinkSourceFile(extensions.c, ../../../../extras/Mesa/src)
-LinkSourceFile(extensions.h, ../../../../extras/Mesa/src)
-LinkSourceFile(feedback.c, ../../../../extras/Mesa/src)
-LinkSourceFile(feedback.h, ../../../../extras/Mesa/src)
-LinkSourceFile(fixed.h, ../../../../extras/Mesa/src)
-LinkSourceFile(fog.c, ../../../../extras/Mesa/src)
-LinkSourceFile(fog.h, ../../../../extras/Mesa/src)
-LinkSourceFile(fog_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(general_clip.h, ../../../../extras/Mesa/src)
-LinkSourceFile(get.c, ../../../../extras/Mesa/src)
-LinkSourceFile(get.h, ../../../../extras/Mesa/src)
-LinkSourceFile(glapi.c, ../../../../extras/Mesa/src)
-LinkSourceFile(glapi.h, ../../../../extras/Mesa/src)
-LinkSourceFile(glapinoop.c, ../../../../extras/Mesa/src)
-LinkSourceFile(glapinoop.h, ../../../../extras/Mesa/src)
-LinkSourceFile(glapioffsets.h, ../../../../extras/Mesa/src)
-LinkSourceFile(glapitable.h, ../../../../extras/Mesa/src)
-LinkSourceFile(glapitemp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(glheader.h, ../../../../extras/Mesa/src)
-LinkSourceFile(glthread.c, ../../../../extras/Mesa/src)
-LinkSourceFile(glthread.h, ../../../../extras/Mesa/src)
-LinkSourceFile(hash.c, ../../../../extras/Mesa/src)
-LinkSourceFile(hash.h, ../../../../extras/Mesa/src)
-LinkSourceFile(hint.c, ../../../../extras/Mesa/src)
-LinkSourceFile(hint.h, ../../../../extras/Mesa/src)
-LinkSourceFile(image.c, ../../../../extras/Mesa/src)
-LinkSourceFile(image.h, ../../../../extras/Mesa/src)
-LinkSourceFile(imaging.c, ../../../../extras/Mesa/src)
-LinkSourceFile(imaging.h, ../../../../extras/Mesa/src)
-LinkSourceFile(indirect_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(interp_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(light.c, ../../../../extras/Mesa/src)
-LinkSourceFile(light.h, ../../../../extras/Mesa/src)
-LinkSourceFile(lines.c, ../../../../extras/Mesa/src)
-LinkSourceFile(lines.h, ../../../../extras/Mesa/src)
-LinkSourceFile(linetemp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(lnaatemp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(logic.c, ../../../../extras/Mesa/src)
-LinkSourceFile(logic.h, ../../../../extras/Mesa/src)
-LinkSourceFile(macros.h, ../../../../extras/Mesa/src)
-LinkSourceFile(masking.c, ../../../../extras/Mesa/src)
-LinkSourceFile(masking.h, ../../../../extras/Mesa/src)
-LinkSourceFile(matrix.c, ../../../../extras/Mesa/src)
-LinkSourceFile(matrix.h, ../../../../extras/Mesa/src)
-LinkSourceFile(mem.c, ../../../../extras/Mesa/src)
-LinkSourceFile(mem.h, ../../../../extras/Mesa/src)
-LinkSourceFile(mmath.c, ../../../../extras/Mesa/src)
-LinkSourceFile(mmath.h, ../../../../extras/Mesa/src)
-LinkSourceFile(norm_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(pb.c, ../../../../extras/Mesa/src)
-LinkSourceFile(pb.h, ../../../../extras/Mesa/src)
-LinkSourceFile(pipeline.c, ../../../../extras/Mesa/src)
-LinkSourceFile(pipeline.h, ../../../../extras/Mesa/src)
-LinkSourceFile(pixel.c, ../../../../extras/Mesa/src)
-LinkSourceFile(pixel.h, ../../../../extras/Mesa/src)
-LinkSourceFile(pixeltex.c, ../../../../extras/Mesa/src)
-LinkSourceFile(pixeltex.h, ../../../../extras/Mesa/src)
-LinkSourceFile(points.c, ../../../../extras/Mesa/src)
-LinkSourceFile(points.h, ../../../../extras/Mesa/src)
-LinkSourceFile(polygon.c, ../../../../extras/Mesa/src)
-LinkSourceFile(polygon.h, ../../../../extras/Mesa/src)
-LinkSourceFile(quads.c, ../../../../extras/Mesa/src)
-LinkSourceFile(quads.h, ../../../../extras/Mesa/src)
-LinkSourceFile(rastpos.c, ../../../../extras/Mesa/src)
-LinkSourceFile(rastpos.h, ../../../../extras/Mesa/src)
-LinkSourceFile(readpix.c, ../../../../extras/Mesa/src)
-LinkSourceFile(readpix.h, ../../../../extras/Mesa/src)
-LinkSourceFile(rect.c, ../../../../extras/Mesa/src)
-LinkSourceFile(rect.h, ../../../../extras/Mesa/src)
-LinkSourceFile(render_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(scissor.c, ../../../../extras/Mesa/src)
-LinkSourceFile(scissor.h, ../../../../extras/Mesa/src)
-LinkSourceFile(shade.c, ../../../../extras/Mesa/src)
-LinkSourceFile(shade.h, ../../../../extras/Mesa/src)
-LinkSourceFile(shade_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(simple_list.h, ../../../../extras/Mesa/src)
-LinkSourceFile(span.c, ../../../../extras/Mesa/src)
-LinkSourceFile(span.h, ../../../../extras/Mesa/src)
-LinkSourceFile(stages.c, ../../../../extras/Mesa/src)
-LinkSourceFile(stages.h, ../../../../extras/Mesa/src)
-LinkSourceFile(state.c, ../../../../extras/Mesa/src)
-LinkSourceFile(state.h, ../../../../extras/Mesa/src)
-LinkSourceFile(stencil.c, ../../../../extras/Mesa/src)
-LinkSourceFile(stencil.h, ../../../../extras/Mesa/src)
-LinkSourceFile(texgen_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(teximage.c, ../../../../extras/Mesa/src)
-LinkSourceFile(teximage.h, ../../../../extras/Mesa/src)
-LinkSourceFile(texobj.c, ../../../../extras/Mesa/src)
-LinkSourceFile(texobj.h, ../../../../extras/Mesa/src)
-LinkSourceFile(texstate.c, ../../../../extras/Mesa/src)
-LinkSourceFile(texstate.h, ../../../../extras/Mesa/src)
-LinkSourceFile(texture.c, ../../../../extras/Mesa/src)
-LinkSourceFile(texture.h, ../../../../extras/Mesa/src)
-LinkSourceFile(texutil.c, ../../../../extras/Mesa/src)
-LinkSourceFile(texutil.h, ../../../../extras/Mesa/src)
-LinkSourceFile(trans_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(translate.c, ../../../../extras/Mesa/src)
-LinkSourceFile(translate.h, ../../../../extras/Mesa/src)
-LinkSourceFile(triangle.c, ../../../../extras/Mesa/src)
-LinkSourceFile(triangle.h, ../../../../extras/Mesa/src)
-LinkSourceFile(tritemp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(types.h, ../../../../extras/Mesa/src)
-LinkSourceFile(varray.c, ../../../../extras/Mesa/src)
-LinkSourceFile(varray.h, ../../../../extras/Mesa/src)
-LinkSourceFile(vb.c, ../../../../extras/Mesa/src)
-LinkSourceFile(vb.h, ../../../../extras/Mesa/src)
-LinkSourceFile(vbcull.c, ../../../../extras/Mesa/src)
-LinkSourceFile(vbcull.h, ../../../../extras/Mesa/src)
-LinkSourceFile(vbfill.c, ../../../../extras/Mesa/src)
-LinkSourceFile(vbfill.h, ../../../../extras/Mesa/src)
-LinkSourceFile(vbindirect.c, ../../../../extras/Mesa/src)
-LinkSourceFile(vbindirect.h, ../../../../extras/Mesa/src)
-LinkSourceFile(vbrender.c, ../../../../extras/Mesa/src)
-LinkSourceFile(vbrender.h, ../../../../extras/Mesa/src)
-LinkSourceFile(vbxform.c, ../../../../extras/Mesa/src)
-LinkSourceFile(vbxform.h, ../../../../extras/Mesa/src)
-LinkSourceFile(vector.c, ../../../../extras/Mesa/src)
-LinkSourceFile(vector.h, ../../../../extras/Mesa/src)
-LinkSourceFile(vertices.c, ../../../../extras/Mesa/src)
-LinkSourceFile(vertices.h, ../../../../extras/Mesa/src)
-LinkSourceFile(winpos.c, ../../../../extras/Mesa/src)
-LinkSourceFile(winpos.h, ../../../../extras/Mesa/src)
-LinkSourceFile(xform.c, ../../../../extras/Mesa/src)
-LinkSourceFile(xform.h, ../../../../extras/Mesa/src)
-LinkSourceFile(xform_tmp.h, ../../../../extras/Mesa/src)
-LinkSourceFile(zoom.c, ../../../../extras/Mesa/src)
-LinkSourceFile(zoom.h, ../../../../extras/Mesa/src)
+LinkSourceFile(aatriangle.c, $(MESASRCDIR)/src)
+LinkSourceFile(aatriangle.h, $(MESASRCDIR)/src)
+LinkSourceFile(aatritemp.h, $(MESASRCDIR)/src)
+LinkSourceFile(accum.c, $(MESASRCDIR)/src)
+LinkSourceFile(accum.h, $(MESASRCDIR)/src)
+LinkSourceFile(all.h, $(MESASRCDIR)/src)
+LinkSourceFile(alpha.c, $(MESASRCDIR)/src)
+LinkSourceFile(alpha.h, $(MESASRCDIR)/src)
+LinkSourceFile(alphabuf.c, $(MESASRCDIR)/src)
+LinkSourceFile(alphabuf.h, $(MESASRCDIR)/src)
+LinkSourceFile(attrib.c, $(MESASRCDIR)/src)
+LinkSourceFile(attrib.h, $(MESASRCDIR)/src)
+LinkSourceFile(bbox.c, $(MESASRCDIR)/src)
+LinkSourceFile(bbox.h, $(MESASRCDIR)/src)
+LinkSourceFile(bitmap.c, $(MESASRCDIR)/src)
+LinkSourceFile(bitmap.h, $(MESASRCDIR)/src)
+LinkSourceFile(blend.c, $(MESASRCDIR)/src)
+LinkSourceFile(blend.h, $(MESASRCDIR)/src)
+LinkSourceFile(buffers.c, $(MESASRCDIR)/src)
+LinkSourceFile(buffers.h, $(MESASRCDIR)/src)
+LinkSourceFile(clip.c, $(MESASRCDIR)/src)
+LinkSourceFile(clip.h, $(MESASRCDIR)/src)
+LinkSourceFile(clip_funcs.h, $(MESASRCDIR)/src)
+LinkSourceFile(clip_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(colortab.c, $(MESASRCDIR)/src)
+LinkSourceFile(colortab.h, $(MESASRCDIR)/src)
+LinkSourceFile(config.c, $(MESASRCDIR)/src)
+LinkSourceFile(config.h, $(MESASRCDIR)/src)
+LinkSourceFile(context.c, $(MESASRCDIR)/src)
+LinkSourceFile(context.h, $(MESASRCDIR)/src)
+LinkSourceFile(copy_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(copypix.c, $(MESASRCDIR)/src)
+LinkSourceFile(copypix.h, $(MESASRCDIR)/src)
+LinkSourceFile(cull_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(cva.c, $(MESASRCDIR)/src)
+LinkSourceFile(cva.h, $(MESASRCDIR)/src)
+LinkSourceFile(dd.h, $(MESASRCDIR)/src)
+LinkSourceFile(debug_xform.c, $(MESASRCDIR)/src)
+LinkSourceFile(debug_xform.h, $(MESASRCDIR)/src)
+LinkSourceFile(depth.c, $(MESASRCDIR)/src)
+LinkSourceFile(depth.h, $(MESASRCDIR)/src)
+LinkSourceFile(dlist.c, $(MESASRCDIR)/src)
+LinkSourceFile(dlist.h, $(MESASRCDIR)/src)
+LinkSourceFile(dotprod_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(drawpix.c, $(MESASRCDIR)/src)
+LinkSourceFile(drawpix.h, $(MESASRCDIR)/src)
+LinkSourceFile(enable.c, $(MESASRCDIR)/src)
+LinkSourceFile(enable.h, $(MESASRCDIR)/src)
+LinkSourceFile(enums.c, $(MESASRCDIR)/src)
+LinkSourceFile(enums.h, $(MESASRCDIR)/src)
+LinkSourceFile(eval.c, $(MESASRCDIR)/src)
+LinkSourceFile(eval.h, $(MESASRCDIR)/src)
+LinkSourceFile(extensions.c, $(MESASRCDIR)/src)
+LinkSourceFile(extensions.h, $(MESASRCDIR)/src)
+LinkSourceFile(feedback.c, $(MESASRCDIR)/src)
+LinkSourceFile(feedback.h, $(MESASRCDIR)/src)
+LinkSourceFile(fixed.h, $(MESASRCDIR)/src)
+LinkSourceFile(fog.c, $(MESASRCDIR)/src)
+LinkSourceFile(fog.h, $(MESASRCDIR)/src)
+LinkSourceFile(fog_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(general_clip.h, $(MESASRCDIR)/src)
+LinkSourceFile(get.c, $(MESASRCDIR)/src)
+LinkSourceFile(get.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapi.c, $(MESASRCDIR)/src)
+LinkSourceFile(glapi.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapinoop.c, $(MESASRCDIR)/src)
+LinkSourceFile(glapinoop.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapioffsets.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapitable.h, $(MESASRCDIR)/src)
+LinkSourceFile(glapitemp.h, $(MESASRCDIR)/src)
+LinkSourceFile(glheader.h, $(MESASRCDIR)/src)
+LinkSourceFile(glthread.c, $(MESASRCDIR)/src)
+LinkSourceFile(glthread.h, $(MESASRCDIR)/src)
+LinkSourceFile(hash.c, $(MESASRCDIR)/src)
+LinkSourceFile(hash.h, $(MESASRCDIR)/src)
+LinkSourceFile(hint.c, $(MESASRCDIR)/src)
+LinkSourceFile(hint.h, $(MESASRCDIR)/src)
+LinkSourceFile(image.c, $(MESASRCDIR)/src)
+LinkSourceFile(image.h, $(MESASRCDIR)/src)
+LinkSourceFile(imaging.c, $(MESASRCDIR)/src)
+LinkSourceFile(imaging.h, $(MESASRCDIR)/src)
+LinkSourceFile(indirect_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(interp_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(light.c, $(MESASRCDIR)/src)
+LinkSourceFile(light.h, $(MESASRCDIR)/src)
+LinkSourceFile(lines.c, $(MESASRCDIR)/src)
+LinkSourceFile(lines.h, $(MESASRCDIR)/src)
+LinkSourceFile(linetemp.h, $(MESASRCDIR)/src)
+LinkSourceFile(lnaatemp.h, $(MESASRCDIR)/src)
+LinkSourceFile(logic.c, $(MESASRCDIR)/src)
+LinkSourceFile(logic.h, $(MESASRCDIR)/src)
+LinkSourceFile(macros.h, $(MESASRCDIR)/src)
+LinkSourceFile(masking.c, $(MESASRCDIR)/src)
+LinkSourceFile(masking.h, $(MESASRCDIR)/src)
+LinkSourceFile(matrix.c, $(MESASRCDIR)/src)
+LinkSourceFile(matrix.h, $(MESASRCDIR)/src)
+LinkSourceFile(mem.c, $(MESASRCDIR)/src)
+LinkSourceFile(mem.h, $(MESASRCDIR)/src)
+LinkSourceFile(mmath.c, $(MESASRCDIR)/src)
+LinkSourceFile(mmath.h, $(MESASRCDIR)/src)
+LinkSourceFile(norm_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(pb.c, $(MESASRCDIR)/src)
+LinkSourceFile(pb.h, $(MESASRCDIR)/src)
+LinkSourceFile(pipeline.c, $(MESASRCDIR)/src)
+LinkSourceFile(pipeline.h, $(MESASRCDIR)/src)
+LinkSourceFile(pixel.c, $(MESASRCDIR)/src)
+LinkSourceFile(pixel.h, $(MESASRCDIR)/src)
+LinkSourceFile(pixeltex.c, $(MESASRCDIR)/src)
+LinkSourceFile(pixeltex.h, $(MESASRCDIR)/src)
+LinkSourceFile(points.c, $(MESASRCDIR)/src)
+LinkSourceFile(points.h, $(MESASRCDIR)/src)
+LinkSourceFile(polygon.c, $(MESASRCDIR)/src)
+LinkSourceFile(polygon.h, $(MESASRCDIR)/src)
+LinkSourceFile(quads.c, $(MESASRCDIR)/src)
+LinkSourceFile(quads.h, $(MESASRCDIR)/src)
+LinkSourceFile(rastpos.c, $(MESASRCDIR)/src)
+LinkSourceFile(rastpos.h, $(MESASRCDIR)/src)
+LinkSourceFile(readpix.c, $(MESASRCDIR)/src)
+LinkSourceFile(readpix.h, $(MESASRCDIR)/src)
+LinkSourceFile(rect.c, $(MESASRCDIR)/src)
+LinkSourceFile(rect.h, $(MESASRCDIR)/src)
+LinkSourceFile(render_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(scissor.c, $(MESASRCDIR)/src)
+LinkSourceFile(scissor.h, $(MESASRCDIR)/src)
+LinkSourceFile(shade.c, $(MESASRCDIR)/src)
+LinkSourceFile(shade.h, $(MESASRCDIR)/src)
+LinkSourceFile(shade_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(simple_list.h, $(MESASRCDIR)/src)
+LinkSourceFile(span.c, $(MESASRCDIR)/src)
+LinkSourceFile(span.h, $(MESASRCDIR)/src)
+LinkSourceFile(stages.c, $(MESASRCDIR)/src)
+LinkSourceFile(stages.h, $(MESASRCDIR)/src)
+LinkSourceFile(state.c, $(MESASRCDIR)/src)
+LinkSourceFile(state.h, $(MESASRCDIR)/src)
+LinkSourceFile(stencil.c, $(MESASRCDIR)/src)
+LinkSourceFile(stencil.h, $(MESASRCDIR)/src)
+LinkSourceFile(texgen_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(teximage.c, $(MESASRCDIR)/src)
+LinkSourceFile(teximage.h, $(MESASRCDIR)/src)
+LinkSourceFile(texobj.c, $(MESASRCDIR)/src)
+LinkSourceFile(texobj.h, $(MESASRCDIR)/src)
+LinkSourceFile(texstate.c, $(MESASRCDIR)/src)
+LinkSourceFile(texstate.h, $(MESASRCDIR)/src)
+LinkSourceFile(texture.c, $(MESASRCDIR)/src)
+LinkSourceFile(texture.h, $(MESASRCDIR)/src)
+LinkSourceFile(texutil.c, $(MESASRCDIR)/src)
+LinkSourceFile(texutil.h, $(MESASRCDIR)/src)
+LinkSourceFile(trans_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(translate.c, $(MESASRCDIR)/src)
+LinkSourceFile(translate.h, $(MESASRCDIR)/src)
+LinkSourceFile(triangle.c, $(MESASRCDIR)/src)
+LinkSourceFile(triangle.h, $(MESASRCDIR)/src)
+LinkSourceFile(tritemp.h, $(MESASRCDIR)/src)
+LinkSourceFile(types.h, $(MESASRCDIR)/src)
+LinkSourceFile(varray.c, $(MESASRCDIR)/src)
+LinkSourceFile(varray.h, $(MESASRCDIR)/src)
+LinkSourceFile(vb.c, $(MESASRCDIR)/src)
+LinkSourceFile(vb.h, $(MESASRCDIR)/src)
+LinkSourceFile(vbcull.c, $(MESASRCDIR)/src)
+LinkSourceFile(vbcull.h, $(MESASRCDIR)/src)
+LinkSourceFile(vbfill.c, $(MESASRCDIR)/src)
+LinkSourceFile(vbfill.h, $(MESASRCDIR)/src)
+LinkSourceFile(vbindirect.c, $(MESASRCDIR)/src)
+LinkSourceFile(vbindirect.h, $(MESASRCDIR)/src)
+LinkSourceFile(vbrender.c, $(MESASRCDIR)/src)
+LinkSourceFile(vbrender.h, $(MESASRCDIR)/src)
+LinkSourceFile(vbxform.c, $(MESASRCDIR)/src)
+LinkSourceFile(vbxform.h, $(MESASRCDIR)/src)
+LinkSourceFile(vector.c, $(MESASRCDIR)/src)
+LinkSourceFile(vector.h, $(MESASRCDIR)/src)
+LinkSourceFile(vertices.c, $(MESASRCDIR)/src)
+LinkSourceFile(vertices.h, $(MESASRCDIR)/src)
+LinkSourceFile(winpos.c, $(MESASRCDIR)/src)
+LinkSourceFile(winpos.h, $(MESASRCDIR)/src)
+LinkSourceFile(xform.c, $(MESASRCDIR)/src)
+LinkSourceFile(xform.h, $(MESASRCDIR)/src)
+LinkSourceFile(xform_tmp.h, $(MESASRCDIR)/src)
+LinkSourceFile(zoom.c, $(MESASRCDIR)/src)
+LinkSourceFile(zoom.h, $(MESASRCDIR)/src)
 
     CORE_SRCS = aatriangle.c \
 		accum.c \
@@ -348,14 +348,23 @@
 #ifdef i386Architecture
      ASM_SRCS = 
      ASM_OBJS = 
-#ifdef MesaUse3DNow
-     ASM_DEFS = -DUSE_MMX_ASM -DUSE_X86_ASM -DUSE_3DNOW_ASM
-#else
-     ASM_DEFS = -DUSE_MMX_ASM -DUSE_X86_ASM
+#if MesaUseMMX
+     MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+   3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseKatmai
+  KATMAI_DEFS = -DUSE_KATMAI_ASM
 #endif
+     ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(KATMAI_DEFS)
 #endif
 
-      DEFINES = $(ALLOC_DEFINES) GlxDefines $(TDFX_DEFS) $(ASM_DEFS)
+#ifdef UseCompaqMathLibrary
+      MATHDEF = -DCCPML
+#endif
+
+      DEFINES = $(ALLOC_DEFINES) GlxDefines $(TDFX_DEFS) $(ASM_DEFS) $(MATHDEF)
      INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I../include -I../../dri -I. -I../../../../include
          SRCS = $(CORE_SRCS) $(ASM_SRCS)
          OBJS = $(CORE_OBJS) $(ASM_OBJS)
@@ -368,10 +377,6 @@
 #endif
 
 #if GlxBuiltInMesa || GlxDriverUsesMesa || !GlxUseBuiltInDRIDriver
-  MESASUBDIRS =
-#ifdef i386Architecture
-  ASMSUBDIRS = X86
-#endif
 
 #include <Library.tmpl>
 
@@ -379,18 +384,23 @@
 
 SubdirLibraryRule($(OBJS))
 NormalLintTarget($(SRCS))
-
-#else
-
-AllTarget($(OBJS))
 
-#endif
+#ifdef i386Architecture
 
 #define IHaveSubdirs
 #define PassCDebugFlags
 
-SUBDIRS = $(MESASUBDIRS) $(ASMSUBDIRS)
+SUBDIRS = X86
 
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
+
+#endif
+
+#else
+
+AllTarget($(OBJS))
+
+#endif
+
 DependTarget()
Index: xc/lib/GL/mesa/src/OSmesa/Imakefile
diff -u xc/lib/GL/mesa/src/OSmesa/Imakefile:1.3 xc/lib/GL/mesa/src/OSmesa/Imakefile:1.6
--- xc/lib/GL/mesa/src/OSmesa/Imakefile:1.3	Mon Jun 26 18:27:41 2000
+++ xc/lib/GL/mesa/src/OSmesa/Imakefile	Tue Dec 12 18:24:27 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/OSmesa/Imakefile,v 1.3 2000/06/26 22:27:41 tsi Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/OSmesa/Imakefile,v 1.6 2000/12/12 23:24:27 dawes Exp $
 
 #include <Threads.tmpl>
 
@@ -8,7 +8,7 @@
 #define DoDebugLib DebugLibGlx
 #define DoProfileLib ProfileLibGlx
 
-LinkSourceFile(osmesa.c, ../../../../../extras/Mesa/src/OSmesa)
+LinkSourceFile(osmesa.c, $(MESASRCDIR)/src/OSmesa)
 
 
 #if Malloc0ReturnsNull
@@ -171,26 +171,40 @@
 		osmesa.o
 
 #ifdef i386Architecture
-     X86_SRCS = ../X86/x86.c \
-		../X86/x86a.S \
-		../X86/common_x86.c \
-		../X86/common_x86asm.S \
-		../X86/vertex.S
-
-     X86_OBJS = ../X86/x86.o \
-		../X86/x86a.o \
-		../X86/common_x86.o \
-		../X86/common_x86asm.o \
-		../X86/vertex.o
+     X86_SRCS = ../X86/common_x86.c \
+		../X86/common_x86_asm.S \
+		../X86/x86.c \
+		../X86/x86_cliptest.S \
+		../X86/x86_vertex.S \
+		../X86/x86_xform_masked2.S \
+		../X86/x86_xform_masked3.S \
+		../X86/x86_xform_masked4.S \
+		../X86/x86_xform_raw2.S \
+		../X86/x86_xform_raw3.S \
+		../X86/x86_xform_raw4.S
+
+     X86_OBJS = ../X86/common_x86.o \
+		../X86/common_x86_asm.o \
+		../X86/x86.o \
+		../X86/x86_cliptest.o \
+		../X86/x86_vertex.o \
+		../X86/x86_xform_masked2.o \
+		../X86/x86_xform_masked3.o \
+		../X86/x86_xform_masked4.o \
+		../X86/x86_xform_raw2.o \
+		../X86/x86_xform_raw3.o \
+		../X86/x86_xform_raw4.o
 
+#if MesaUseMMX
      MMX_SRCS = ../X86/mmx_blend.S
 
      MMX_OBJS = ../X86/mmx_blend.o
+#endif
 
-XCOMM Disabling 3Dnow code for the time being.
-#if 0
+#if MesaUse3DNow
    3DNOW_SRCS = ../X86/3dnow.c \
 		../X86/3dnow_norm_raw.S \
+		../X86/3dnow_vertex.S \
 		../X86/3dnow_xform_masked1.S \
 		../X86/3dnow_xform_masked2.S \
 		../X86/3dnow_xform_masked3.S \
@@ -198,11 +212,11 @@
 		../X86/3dnow_xform_raw1.S \
 		../X86/3dnow_xform_raw2.S \
 		../X86/3dnow_xform_raw3.S \
-		../X86/3dnow_xform_raw4.S \
-		../X86/vertex_3dnow.S
+		../X86/3dnow_xform_raw4.S
 
    3DNOW_OBJS = ../X86/3dnow.o \
 		../X86/3dnow_norm_raw.o \
+		../X86/3dnow_vertex.o \
 		../X86/3dnow_xform_masked1.o \
 		../X86/3dnow_xform_masked2.o \
 		../X86/3dnow_xform_masked3.o \
@@ -210,14 +224,38 @@
 		../X86/3dnow_xform_raw1.o \
 		../X86/3dnow_xform_raw2.o \
 		../X86/3dnow_xform_raw3.o \
-		../X86/3dnow_xform_raw4.o \
-		../X86/vertex_3dnow.o
+		../X86/3dnow_xform_raw4.o
 #endif
 
+#if MesaUseKatmai
+  KATMAI_SRCS = ../X86/katmai.c \
+		../X86/katmai_norm_raw.S \
+		../X86/katmai_vertex.S \
+		../X86/katmai_xform_masked1.S \
+		../X86/katmai_xform_masked2.S \
+		../X86/katmai_xform_masked3.S \
+		../X86/katmai_xform_masked4.S \
+		../X86/katmai_xform_raw1.S \
+		../X86/katmai_xform_raw2.S \
+		../X86/katmai_xform_raw3.S \
+		../X86/katmai_xform_raw4.S
+
+  KATMAI_OBJS = ../X86/katmai.o \
+		../X86/katmai_norm_raw.o \
+		../X86/katmai_vertex.o \
+		../X86/katmai_xform_masked1.o \
+		../X86/katmai_xform_masked2.o \
+		../X86/katmai_xform_masked3.o \
+		../X86/katmai_xform_masked4.o \
+		../X86/katmai_xform_raw1.o \
+		../X86/katmai_xform_raw2.o \
+		../X86/katmai_xform_raw3.o \
+		../X86/katmai_xform_raw4.o
+#endif
 #endif
 
-      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
-      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS)
+      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS)
 
          SRCS = $(MESASRCS) $(ASMSRCS)
          OBJS = $(MESAOBJS) $(ASMOBJS)
Index: xc/lib/GL/mesa/src/OSmesa/OSmesa-def.cpp
diff -u /dev/null xc/lib/GL/mesa/src/OSmesa/OSmesa-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:23:28 2000
+++ xc/lib/GL/mesa/src/OSmesa/OSmesa-def.cpp	Wed Aug  9 19:40:12 2000
@@ -0,0 +1,25 @@
+LIBRARY libOSmesa
+VERSION LIBRARY_VERSION
+EXPORTS
+	OSMesaCreateContext
+	OSMesaDestroyContext
+	OSMesaGetColorBuffer
+	OSMesaGetCurrentContext
+	OSMesaGetDepthBuffer
+	OSMesaGetIntegerv
+	OSMesaMakeCurrent
+	OSMesaPixelStore
+	_glapi_Context 
+	_glapi_noop_enable_warnings
+	_glapi_add_entrypoint
+	_glapi_get_dispatch_table_size
+	_glapi_set_dispatch
+	_glapi_check_multithread
+	_glapi_set_context
+	glTexCoordPointer
+	glColorPointer
+	glNormalPointer
+	glVertexPointer
+	glDrawElements
+
+/* $XFree86: xc/lib/GL/mesa/src/OSmesa/OSmesa-def.cpp,v 1.1 2000/08/09 23:40:12 dawes Exp $ */
Index: xc/lib/GL/mesa/src/X/Imakefile
diff -u xc/lib/GL/mesa/src/X/Imakefile:1.5 xc/lib/GL/mesa/src/X/Imakefile:1.6
--- xc/lib/GL/mesa/src/X/Imakefile:1.5	Tue Feb 22 23:46:39 2000
+++ xc/lib/GL/mesa/src/X/Imakefile	Tue Aug  1 16:28:39 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.5 2000/02/23 04:46:39 martin Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.6 2000/08/01 20:28:39 dawes Exp $
 
 #define DoNormalLib NormalLibGlx
 #define DoSharedLib SharedLibGlx
@@ -6,12 +6,12 @@
 #define DoDebugLib DebugLibGlx
 #define DoProfileLib ProfileLibGlx
 
-LinkSourceFile(xmesa1.c, ../../../../../extras/Mesa/src/X)
-LinkSourceFile(xmesa2.c, ../../../../../extras/Mesa/src/X)
-LinkSourceFile(xmesa3.c, ../../../../../extras/Mesa/src/X)
-LinkSourceFile(xmesa4.c, ../../../../../extras/Mesa/src/X)
-LinkSourceFile(xmesaP.h, ../../../../../extras/Mesa/src/X)
-LinkSourceFile(glxheader.h, ../../../../../extras/Mesa/src/X)
+LinkSourceFile(xmesa1.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xmesa2.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xmesa3.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xmesa4.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xmesaP.h, $(MESASRCDIR)/src/X)
+LinkSourceFile(glxheader.h, $(MESASRCDIR)/src/X)
 
 
 #if Malloc0ReturnsNull
Index: xc/lib/GL/mesa/src/X86/Imakefile
diff -u xc/lib/GL/mesa/src/X86/Imakefile:1.9 xc/lib/GL/mesa/src/X86/Imakefile:1.14
--- xc/lib/GL/mesa/src/X86/Imakefile:1.9	Fri Jun 16 20:02:53 2000
+++ xc/lib/GL/mesa/src/X86/Imakefile	Tue Dec 12 18:24:27 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/X86/Imakefile,v 1.9 2000/06/17 00:02:53 martin Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/X86/Imakefile,v 1.14 2000/12/12 23:24:27 dawes Exp $
 
 #define DoNormalLib NormalLibGlx
 #define DoSharedLib SharedLibGlx
@@ -6,77 +6,162 @@
 #define DoDebugLib DebugLibGlx
 #define DoProfileLib ProfileLibGlx
 
-LinkSourceFile(assyntax.h, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(common_x86.c, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(common_x86asm.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(common_x86asm.h, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(glapi_x86.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(x86.c, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(x86.h, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(x86a.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(vertex.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(x86flatregs.m4, ../../../../../extras/Mesa/src/X86)
-
-LinkSourceFile(mmx.h, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(mmx_blend.S, ../../../../../extras/Mesa/src/X86)
-
-LinkSourceFile(3dnow.c, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow.h, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow_norm_raw.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow_xform_masked1.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow_xform_masked2.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow_xform_masked3.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow_xform_masked4.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow_xform_raw1.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow_xform_raw2.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow_xform_raw3.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(3dnow_xform_raw4.S, ../../../../../extras/Mesa/src/X86)
-LinkSourceFile(vertex_3dnow.S, ../../../../../extras/Mesa/src/X86)
+LinkSourceFile(assyntax.h, $(MESASRCDIR)/src/X86)
+LinkSourceFile(common_x86.c, $(MESASRCDIR)/src/X86)
+LinkSourceFile(common_x86_asm.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(common_x86_asm.h, $(MESASRCDIR)/src/X86)
+LinkSourceFile(common_x86_features.h, $(MESASRCDIR)/src/X86)
+LinkSourceFile(glapi_x86.S, $(MESASRCDIR)/src/X86)
+
+LinkSourceFile(xform_args.h, $(MESASRCDIR)/src/X86)
+LinkSourceFile(clip_args.h, $(MESASRCDIR)/src/X86)
+
+LinkSourceFile(x86.c, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86.h, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_cliptest.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_vertex.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_xform_masked2.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_xform_masked3.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_xform_masked4.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_xform_raw2.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_xform_raw3.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_xform_raw4.S, $(MESASRCDIR)/src/X86)
+
+LinkSourceFile(mmx.h, $(MESASRCDIR)/src/X86)
+LinkSourceFile(mmx_blend.S, $(MESASRCDIR)/src/X86)
+
+LinkSourceFile(3dnow.c, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow.h, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_norm_raw.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_vertex.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform_masked1.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform_masked2.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform_masked3.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform_masked4.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform_raw1.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform_raw2.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform_raw3.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform_raw4.S, $(MESASRCDIR)/src/X86)
+
+LinkSourceFile(katmai.c, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai.h, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_norm_raw.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_vertex.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_xform_masked1.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_xform_masked2.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_xform_masked3.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_xform_masked4.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_xform_raw1.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_xform_raw2.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_xform_raw3.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(katmai_xform_raw4.S, $(MESASRCDIR)/src/X86)
 
-LinkSourceFile(glapioffsets.h, ../../../../../extras/Mesa/src)
+LinkSourceFile(glapioffsets.h, $(MESASRCDIR)/src)
 
 #if Malloc0ReturnsNull
 ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
 #endif
 
 #ifdef i386Architecture
-XCOMM We'll learn at runtime whether 3dNow, MMX, etc are really present.
-      X86_SRCS = x86a.S common_x86.c common_x86asm.S glapi_x86.S x86.c vertex.S
+XCOMM Determine at runtime whether 3DNow!, Katmai, MMX, etc are really present.
+     X86_SRCS = common_x86.c \
+		common_x86_asm.S \
+		glapi_x86.S \
+		x86.c \
+		x86_cliptest.S \
+		x86_vertex.S \
+		x86_xform_masked2.S \
+		x86_xform_masked3.S \
+		x86_xform_masked4.S \
+		x86_xform_raw2.S \
+		x86_xform_raw3.S \
+		x86_xform_raw4.S
+
+     X86_OBJS = common_x86.o \
+		common_x86_asm.o \
+		x86.o \
+		x86_cliptest.o \
+		x86_vertex.o \
+		x86_xform_masked2.o \
+		x86_xform_masked3.o \
+		x86_xform_masked4.o \
+		x86_xform_raw2.o \
+		x86_xform_raw3.o \
+		x86_xform_raw4.o
+
+     X86_DEFS = -DUSE_X86_ASM
 
-      X86_OBJS = x86a.o common_x86.o common_x86asm.o x86.o vertex.o
 
-      X86_DEFS = -DUSE_X86_ASM
+#if MesaUseMMX
+     MMX_SRCS = mmx_blend.S
 
+     MMX_OBJS = mmx_blend.o
 
-      MMX_SRCS = mmx_blend.S
-
-      MMX_OBJS = mmx_blend.o
+     MMX_DEFS = -DUSE_MMX_ASM
+#endif
 
-      MMX_DEFS = -DUSE_MMX_ASM
+#if MesaUse3DNow
+   3DNOW_SRCS = 3dnow.c \
+		3dnow_norm_raw.S \
+		3dnow_vertex.S \
+		3dnow_xform_masked1.S \
+		3dnow_xform_masked2.S \
+		3dnow_xform_masked3.S \
+		3dnow_xform_masked4.S \
+		3dnow_xform_raw1.S \
+		3dnow_xform_raw2.S \
+		3dnow_xform_raw3.S \
+		3dnow_xform_raw4.S
+
+   3DNOW_OBJS = 3dnow.o \
+		3dnow_norm_raw.o \
+		3dnow_vertex.o \
+		3dnow_xform_masked1.o \
+		3dnow_xform_masked2.o \
+		3dnow_xform_masked3.o \
+		3dnow_xform_masked4.o \
+		3dnow_xform_raw1.o \
+		3dnow_xform_raw2.o \
+		3dnow_xform_raw3.o \
+		3dnow_xform_raw4.o
 
-#ifdef MesaUse3DNow
-    3DNOW_SRCS = 3dnow.c 3dnow_norm_raw.S 3dnow_xform_masked1.S \
-		 3dnow_xform_masked2.S 3dnow_xform_masked3.S \
-		 3dnow_xform_masked4.S 3dnow_xform_raw1.S \
-		 3dnow_xform_raw2.S 3dnow_xform_raw3.S 3dnow_xform_raw4.S \
-		 vertex_3dnow.S
+   3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
 
-    3DNOW_OBJS = 3dnow.o 3dnow_norm_raw.o 3dnow_xform_masked1.o \
-		 3dnow_xform_masked2.o 3dnow_xform_masked3.o \
-		 3dnow_xform_masked4.o 3dnow_xform_raw1.o \
-		 3dnow_xform_raw2.o 3dnow_xform_raw3.o 3dnow_xform_raw4.o \
-		 vertex_3dnow.o
+#if MesaUseKatmai
+  KATMAI_SRCS = katmai.c \
+		katmai_norm_raw.S \
+		katmai_vertex.S \
+		katmai_xform_masked1.S \
+		katmai_xform_masked2.S \
+		katmai_xform_masked3.S \
+		katmai_xform_masked4.S \
+		katmai_xform_raw1.S \
+		katmai_xform_raw2.S \
+		katmai_xform_raw3.S \
+		katmai_xform_raw4.S
+
+  KATMAI_OBJS = katmai.o \
+		katmai_norm_raw.o \
+		katmai_vertex.o \
+		katmai_xform_masked1.o \
+		katmai_xform_masked2.o \
+		katmai_xform_masked3.o \
+		katmai_xform_masked4.o \
+		katmai_xform_raw1.o \
+		katmai_xform_raw2.o \
+		katmai_xform_raw3.o \
+		katmai_xform_raw4.o
 
-    3DNOW_DEFS = -DUSE_3DNOW_ASM
+  KATMAI_DEFS = -DUSE_KATMAI_ASM
 #endif
 
-
 #endif
 
-      DEFINES = $(ALLOC_DEFINES) GlxDefines -DFX $(X86_DEFS) $(MMX_DEFS) $(3DNOW_DEFS)
+      DEFINES = $(ALLOC_DEFINES) GlxDefines -DFX $(X86_DEFS) $(MMX_DEFS) $(3DNOW_DEFS) $(KATMAI_DEFS)
      INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I../include -I../../include -I../../dri -I..
-         SRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
-         OBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+         SRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS)
+         OBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS)
 
 #if !GlxUseBuiltInDRIDriver
 #undef DoNormalLib NormalLibGlx
@@ -94,8 +179,24 @@
 SubdirLibraryRule($(OBJS))
 NormalLintTarget($(SRCS))
 
-#ifdef MesaUse3DNow
+ObjectFromAsmSource(common_x86_asm, NullParameter)
+
+ObjectFromAsmSource(x86_cliptest, NullParameter)
+ObjectFromAsmSource(x86_vertex, NullParameter)
+ObjectFromAsmSource(x86_xform_masked2, NullParameter)
+ObjectFromAsmSource(x86_xform_masked3, NullParameter)
+ObjectFromAsmSource(x86_xform_masked4, NullParameter)
+ObjectFromAsmSource(x86_xform_raw2, NullParameter)
+ObjectFromAsmSource(x86_xform_raw3, NullParameter)
+ObjectFromAsmSource(x86_xform_raw4, NullParameter)
+
+#if MesaUseMMX
+ObjectFromAsmSource(mmx_blend, NullParameter)
+#endif
+
+#if MesaUse3DNow
 ObjectFromAsmSource(3dnow_norm_raw, NullParameter)
+ObjectFromAsmSource(3dnow_vertex, NullParameter)
 ObjectFromAsmSource(3dnow_xform_masked1, NullParameter)
 ObjectFromAsmSource(3dnow_xform_masked2, NullParameter)
 ObjectFromAsmSource(3dnow_xform_masked3, NullParameter)
@@ -104,14 +205,19 @@
 ObjectFromAsmSource(3dnow_xform_raw2, NullParameter)
 ObjectFromAsmSource(3dnow_xform_raw3, NullParameter)
 ObjectFromAsmSource(3dnow_xform_raw4, NullParameter)
-ObjectFromAsmSource(vertex_3dnow, NullParameter)
 #endif
-
-ObjectFromAsmSource(mmx_blend, NullParameter)
 
-ObjectFromAsmSource(common_x86asm, NullParameter)
-ObjectFromAsmSource(vertex, NullParameter)
-ObjectFromAsmSource(x86a, NullParameter)
+#if MesaUseKatmai
+ObjectFromAsmSource(katmai_norm_raw, NullParameter)
+ObjectFromAsmSource(katmai_vertex, NullParameter)
+ObjectFromAsmSource(katmai_xform_masked1, NullParameter)
+ObjectFromAsmSource(katmai_xform_masked2, NullParameter)
+ObjectFromAsmSource(katmai_xform_masked3, NullParameter)
+ObjectFromAsmSource(katmai_xform_masked4, NullParameter)
+ObjectFromAsmSource(katmai_xform_raw1, NullParameter)
+ObjectFromAsmSource(katmai_xform_raw2, NullParameter)
+ObjectFromAsmSource(katmai_xform_raw3, NullParameter)
+ObjectFromAsmSource(katmai_xform_raw4, NullParameter)
+#endif
 
 DependTarget()
-
Index: xc/lib/GL/mesa/src/drv/Imakefile
diff -u xc/lib/GL/mesa/src/drv/Imakefile:1.13 xc/lib/GL/mesa/src/drv/Imakefile:1.16
--- xc/lib/GL/mesa/src/drv/Imakefile:1.13	Fri Jun 30 15:30:17 2000
+++ xc/lib/GL/mesa/src/drv/Imakefile	Mon Dec  4 13:54:13 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/drv/Imakefile,v 1.13 2000/06/30 19:30:17 dawes Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/Imakefile,v 1.16 2000/12/04 18:54:13 dawes Exp $
 
 #define DoNormalLib NormalLibGlx
 #define DoSharedLib SharedLibGlx
@@ -33,31 +33,42 @@
 #endif
 
 SUBDIRS = $(DRIVER)
-#else
-#if defined(i386Architecture) 
-SUBDIRS += gamma
-#if HasGlide3
-SUBDIRS += tdfx
-#endif
+
+#else /* GlxUseBuiltInDRIDriver */
+
+#if defined(i386Architecture) || defined(ia64Architecture)
+
 SUBDIRS += common
+SUBDIRS += gamma
 SUBDIRS += mga
 SUBDIRS += i810
 SUBDIRS += r128
-#if 0
 SUBDIRS += sis
-#endif
-#elif defined(AlphaArchitecture) 
-SUBDIRS += gamma
 #if HasGlide3
 SUBDIRS += tdfx
 #endif
+
+#elif defined(AlphaArchitecture) 
+
 SUBDIRS += common
+SUBDIRS += gamma
 SUBDIRS += mga
 SUBDIRS += r128
+#if HasGlide3
+SUBDIRS += tdfx
+#endif
+
 #elif defined(SparcArchitecture)
+
 SUBDIRS += ffb
-#endif
-#endif
+
+#else
+
+SUBDIRS = 
+
+#endif /* architecture */
+
+#endif /* GlxUseBuiltInDRIDriver */
 
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
Index: xc/lib/GL/mesa/src/drv/common/depthtmp.h
diff -u xc/lib/GL/mesa/src/drv/common/depthtmp.h:1.1 xc/lib/GL/mesa/src/drv/common/depthtmp.h:1.4
--- xc/lib/GL/mesa/src/drv/common/depthtmp.h:1.1	Fri Jun 16 20:02:54 2000
+++ xc/lib/GL/mesa/src/drv/common/depthtmp.h	Mon Dec  4 17:43:20 2000
@@ -1,12 +1,20 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/common/depthtmp.h,v 1.4 2000/12/04 22:43:20 dawes Exp $ */
+
 #ifndef DBG
 #define DBG 0
 #endif
 
+#ifndef HAVE_HW_DEPTH_SPANS
+#define HAVE_HW_DEPTH_SPANS 0
+#endif
+#ifndef HAVE_HW_DEPTH_PIXELS
+#define HAVE_HW_DEPTH_PIXELS 0
+#endif
 
 
 static void TAG(WriteDepthSpan)( GLcontext *ctx,
 				 GLuint n, GLint x, GLint y,
-				 const GLdepth *depth, 
+				 const GLdepth *depth,
 				 const GLubyte mask[] )
 {
    HW_LOCK()
@@ -15,95 +23,110 @@
 	 GLint n1;
 	 LOCAL_DEPTH_VARS;
 
-	 y = Y_FLIP(y);
+	 y = Y_FLIP( y );
 
-	 HW_CLIPLOOP() 
+#if HAVE_HW_DEPTH_SPANS
+	 (void) x1; (void) n1;
+
+	 if ( DBG ) fprintf( stderr, "WriteDepthSpan 0..%d (x1 %d)\n",
+			     (int)n, (int)x );
+
+	 WRITE_DEPTH_SPAN();
+#else
+	 HW_CLIPLOOP()
 	    {
 	       GLint i = 0;
-	       CLIPSPAN(x,y,n,x1,n1,i);
+	       CLIPSPAN( x, y, n, x1, n1, i );
 
-	       if (DBG) fprintf(stderr, "WriteDepthSpan %d..%d (x1 %d)\n",
-				(int)i, (int)n1, (int)x1);
+	       if ( DBG ) fprintf( stderr, "WriteDepthSpan %d..%d (x1 %d)\n",
+				   (int)i, (int)n1, (int)x1 );
 
-	       if (mask)
-	       {
-		  for (;i<n1;i++,x1++)
-		     if (mask[i])
-			WRITE_DEPTH( x1, y, depth[i] );
-	       }
-	       else
-	       {
-		  for (;i<n1;i++,x1++)
+	       if ( mask ) {
+		  for ( ; i < n1 ; i++, x1++ ) {
+		     if ( mask[i] ) WRITE_DEPTH( x1, y, depth[i] );
+		  }
+	       } else {
+		  for ( ; i < n1 ; i++, x1++ ) {
 		     WRITE_DEPTH( x1, y, depth[i] );
+		  }
 	       }
 	    }
 	 HW_ENDCLIPLOOP();
+#endif
       }
    HW_UNLOCK();
 }
 
-
 static void TAG(WriteDepthPixels)( GLcontext *ctx,
-				   GLuint n, 
-				   const GLint x[], 
+				   GLuint n,
+				   const GLint x[],
 				   const GLint y[],
-				   const GLdepth depth[], 
+				   const GLdepth depth[],
 				   const GLubyte mask[] )
 {
    HW_LOCK()
       {
 	 GLint i;
 	 LOCAL_DEPTH_VARS;
+
+	 if ( DBG ) fprintf( stderr, "WriteDepthPixels\n" );
 
-	 if (DBG) fprintf(stderr, "WriteDepthPixels\n");
+#if HAVE_HW_DEPTH_PIXELS
+	 (void) i;
 
+	 WRITE_DEPTH_PIXELS();
+#else
 	 HW_CLIPLOOP()
 	    {
-	       for (i=0;i<n;i++)
-	       {
-		  if (mask[i]) {
-		     const int fy = Y_FLIP(y[i]);
-		     if (CLIPPIXEL(x[i],fy))
+	       for ( i = 0 ; i < n ; i++ ) {
+		  if ( mask[i] ) {
+		     const int fy = Y_FLIP( y[i] );
+		     if ( CLIPPIXEL( x[i], fy ) )
 			WRITE_DEPTH( x[i], fy, depth[i] );
 		  }
 	       }
 	    }
 	 HW_ENDCLIPLOOP();
+#endif
       }
    HW_UNLOCK();
 }
 
 
-
-
 /* Read depth spans and pixels
  */
 static void TAG(ReadDepthSpan)( GLcontext *ctx,
 				GLuint n, GLint x, GLint y,
-				GLdepth depth[])
+				GLdepth depth[] )
 {
    HW_LOCK()
       {
-	 GLint x1,n1;
+	 GLint x1, n1;
 	 LOCAL_DEPTH_VARS;
 
-	 y = Y_FLIP(y);
+	 y = Y_FLIP( y );
 
-	 if (DBG) fprintf(stderr, "ReadDepthSpan\n");
+	 if ( DBG ) fprintf( stderr, "ReadDepthSpan\n" );
 
-	 HW_CLIPLOOP() 
+#if HAVE_HW_DEPTH_SPANS
+	 (void) x1; (void) n1;
+
+	 READ_DEPTH_SPAN();
+#else
+	 HW_CLIPLOOP()
 	    {
 	       GLint i = 0;
-	       CLIPSPAN(x,y,n,x1,n1,i);
-	       for (;i<n1;i++)
+	       CLIPSPAN( x, y, n, x1, n1, i );
+	       for ( ; i < n1 ; i++ )
 		  READ_DEPTH( depth[i], (x1+i), y );
 	    }
 	 HW_ENDCLIPLOOP();
+#endif
       }
    HW_UNLOCK();
 }
 
-static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n, 
+static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
 				  const GLint x[], const GLint y[],
 				  GLdepth depth[] )
 {
@@ -112,22 +135,34 @@
 	 GLint i;
 	 LOCAL_DEPTH_VARS;
 
-	 if (DBG) fprintf(stderr, "ReadDepthPixels\n");
- 
+	 if ( DBG ) fprintf( stderr, "ReadDepthPixels\n" );
+
+#if HAVE_HW_DEPTH_PIXELS
+	 (void) i;
+
+	 READ_DEPTH_PIXELS();
+#else
 	 HW_CLIPLOOP()
 	    {
-	       for (i=0;i<n;i++) {
+	       for ( i = 0 ; i < n ;i++ ) {
 		  int fy = Y_FLIP( y[i] );
-		  if (CLIPPIXEL( x[i], fy ))
+		  if ( CLIPPIXEL( x[i], fy ) )
 		     READ_DEPTH( depth[i], x[i], fy );
 	       }
 	    }
 	 HW_ENDCLIPLOOP();
+#endif
       }
    HW_UNLOCK();
 }
 
-
+#if HAVE_HW_DEPTH_SPANS
+#undef WRITE_DEPTH_SPAN
+#undef WRITE_DEPTH_PIXELS
+#undef READ_DEPTH_SPAN
+#undef READ_DEPTH_PIXELS
+#else
 #undef WRITE_DEPTH
 #undef READ_DEPTH
+#endif
 #undef TAG
Index: xc/lib/GL/mesa/src/drv/common/hwlog.h
diff -u xc/lib/GL/mesa/src/drv/common/hwlog.h:1.2 xc/lib/GL/mesa/src/drv/common/hwlog.h:1.3
--- xc/lib/GL/mesa/src/drv/common/hwlog.h:1.2	Thu Jun 22 12:59:23 2000
+++ xc/lib/GL/mesa/src/drv/common/hwlog.h	Sat Nov 18 14:37:05 2000
@@ -24,7 +24,7 @@
  *
  *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/common/hwlog.h,v 1.2 2000/06/22 16:59:23 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/common/hwlog.h,v 1.3 2000/11/18 19:37:05 tsi Exp $ */
  
 /* Usage:
  * - use mgaError for error messages. Always write to X error and log file.
@@ -85,8 +85,8 @@
 static __inline__ int hwIsLogReady( void ) { return 0; }
 static __inline__ int hwGetLogLevel( void ) { return -1; }
 static __inline__ int hwLogLevel(int level) { return 0; }
-static __inline__ void hwLog(int level, const char *format, ...) {}
-static __inline__ void hwMsg(int level, const char *format, ...) {}
+static void hwLog(int level, const char *format, ...) {}
+static void hwMsg(int level, const char *format, ...) {}
 
 #define hwCloseLog()
 #define hwSetLogLevel(x)
Index: xc/lib/GL/mesa/src/drv/common/stenciltmp.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/common/stenciltmp.h:1.2
--- /dev/null	Mon Dec 18 14:23:29 2000
+++ xc/lib/GL/mesa/src/drv/common/stenciltmp.h	Tue Sep 26 11:56:46 2000
@@ -0,0 +1,134 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/common/stenciltmp.h,v 1.2 2000/09/26 15:56:46 tsi Exp $ */
+
+#ifndef DBG
+#define DBG 0
+#endif
+
+
+static void TAG(WriteStencilSpan)( GLcontext *ctx,
+				   GLuint n, GLint x, GLint y,
+				   const GLstencil *stencil, 
+				   const GLubyte mask[] )
+{
+   HW_LOCK()
+      {
+	 GLint x1;
+	 GLint n1;
+	 LOCAL_STENCIL_VARS;
+
+	 y = Y_FLIP(y);
+
+	 HW_CLIPLOOP() 
+	    {
+	       GLint i = 0;
+	       CLIPSPAN(x,y,n,x1,n1,i);
+
+	       if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n",
+				(int)i, (int)n1, (int)x1);
+
+	       if (mask)
+	       {
+		  for (;i<n1;i++,x1++)
+		     if (mask[i])
+			WRITE_STENCIL( x1, y, stencil[i] );
+	       }
+	       else
+	       {
+		  for (;i<n1;i++,x1++)
+		     WRITE_STENCIL( x1, y, stencil[i] );
+	       }
+	    }
+	 HW_ENDCLIPLOOP();
+      }
+   HW_UNLOCK();
+}
+
+
+static void TAG(WriteStencilPixels)( GLcontext *ctx,
+				     GLuint n, 
+				     const GLint x[], 
+				     const GLint y[],
+				     const GLstencil stencil[], 
+				     const GLubyte mask[] )
+{
+   HW_LOCK()
+      {
+	 GLint i;
+	 LOCAL_STENCIL_VARS;
+
+	 if (DBG) fprintf(stderr, "WriteStencilPixels\n");
+
+	 HW_CLIPLOOP()
+	    {
+	       for (i=0;i<n;i++)
+	       {
+		  if (mask[i]) {
+		     const int fy = Y_FLIP(y[i]);
+		     if (CLIPPIXEL(x[i],fy))
+			WRITE_STENCIL( x[i], fy, stencil[i] );
+		  }
+	       }
+	    }
+	 HW_ENDCLIPLOOP();
+      }
+   HW_UNLOCK();
+}
+
+
+/* Read stencil spans and pixels
+ */
+static void TAG(ReadStencilSpan)( GLcontext *ctx,
+				  GLuint n, GLint x, GLint y,
+				  GLstencil stencil[])
+{
+   HW_LOCK()
+      {
+	 GLint x1,n1;
+	 LOCAL_STENCIL_VARS;
+
+	 y = Y_FLIP(y);
+
+	 if (DBG) fprintf(stderr, "ReadStencilSpan\n");
+
+	 HW_CLIPLOOP() 
+	    {
+	       GLint i = 0;
+	       CLIPSPAN(x,y,n,x1,n1,i);
+	       for (;i<n1;i++)
+		  READ_STENCIL( stencil[i], (x1+i), y );
+	    }
+	 HW_ENDCLIPLOOP();
+      }
+   HW_UNLOCK();
+}
+
+static void TAG(ReadStencilPixels)( GLcontext *ctx, GLuint n, 
+				    const GLint x[], const GLint y[],
+				    GLstencil stencil[] )
+{
+   HW_LOCK()
+      {
+	 GLint i;
+	 LOCAL_STENCIL_VARS;
+
+	 if (DBG) fprintf(stderr, "ReadStencilPixels\n");
+ 
+	 HW_CLIPLOOP()
+	    {
+	       for (i=0;i<n;i++) {
+		  int fy = Y_FLIP( y[i] );
+		  if (CLIPPIXEL( x[i], fy ))
+		     READ_STENCIL( stencil[i], x[i], fy );
+	       }
+	    }
+	 HW_ENDCLIPLOOP();
+      }
+   HW_UNLOCK();
+}
+
+
+
+
+#undef WRITE_STENCIL
+#undef READ_STENCIL
+#undef TAG
Index: xc/lib/GL/mesa/src/drv/ffb/Imakefile
diff -u xc/lib/GL/mesa/src/drv/ffb/Imakefile:1.3 xc/lib/GL/mesa/src/drv/ffb/Imakefile:1.6
--- xc/lib/GL/mesa/src/drv/ffb/Imakefile:1.3	Sun Jun 25 10:44:26 2000
+++ xc/lib/GL/mesa/src/drv/ffb/Imakefile	Fri Oct 20 08:57:22 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/drv/ffb/Imakefile,v 1.3 2000/06/25 14:44:26 alanh Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/ffb/Imakefile,v 1.6 2000/10/20 12:57:22 alanh Exp $
 
 #include <Threads.tmpl>
 
@@ -19,11 +19,11 @@
 		-I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
 		-I$(XF86DRIVERSRC)/sunffb \
 		-I../../../include -I../.. -I../../X -I../common \
-		-I../../../dri \
-	        -I$(XF86OSSRC)/linux/drm/kernel
+		-I../../../dri
 #endif
 
-MESA_INCLUDES = -I. -I.. -I../../include
+MESA_INCLUDES = -I. -I.. -I../../include \
+		-I../../../../dri/drm
 
 
       DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
@@ -204,7 +204,7 @@
 	 SRCS = $(FFBSRCS) $(DRISRCS) $(DRMSRCS) $(MESASRCS)
 	 OBJS = $(FFBOBJS) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS)
 
-REQUIREDLIBS += -lm
+REQUIREDLIBS += MathLibrary
 #if !GlxBuiltInFfb
 REQUIREDLIBS += -L../../../.. -lGL
 #endif
Index: xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h
diff -u xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h:1.1 xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h:1.2
--- xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h:1.1	Tue Jun 20 01:08:39 2000
+++ xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h	Tue Dec  5 16:18:33 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h,v 1.2 2000/12/05 21:18:33 dawes Exp $ */
 
 static void TAG(ffb_points)(GLcontext *ctx, GLuint first, GLuint last)
 {
@@ -18,7 +18,7 @@
 #endif
 	int i;
 
-	for (i = first; i <= last; i++) {
+	for (i = first; i < last; i++) {
 		if (VB->ClipMask[i] == 0) {
 			ffb_vertex *tmp = &ffbVB[i];
 #if !(IND & FFB_POINT_BIG_BIT)
Index: xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c
diff -u xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c:1.1 xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c:1.2
--- xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c:1.1	Tue Jun 20 01:08:40 2000
+++ xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c	Sun Sep 24 09:51:03 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c,v 1.1 2000/06/20 05:08:40 dawes Exp $
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c,v 1.2 2000/09/24 13:51:03 alanh Exp $
  *
  * GLX Hardware Device Driver for Sun Creator/Creator3D
  * Copyright (C) 2000 David S. Miller
@@ -28,7 +28,7 @@
 #include "ffb_xmesa.h"
 #include "ffb_context.h"
 #include "ffb_vb.h"
-
+#include "mem.h"
 #include "stages.h"
 
 #define COL {							\
@@ -242,8 +242,8 @@
 		exit(1);
 	}
 
-	free(VB->ClipMask);
-	VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
+	ALIGN_FREE(VB->ClipMask);
+	VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4);
 	if (!VB->ClipMask) {
 		fprintf(stderr, "ffb-glx: out of memory !\n");
 		exit(1);
@@ -283,8 +283,8 @@
 		exit(1);
 	}
 
-	free(VB->ClipMask);
-	VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
+	ALIGN_FREE(VB->ClipMask);
+	VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4);
 	if (!VB->ClipMask) {
 		fprintf(stderr, "ffb-glx: out of memory !\n");
 		exit(1);
Index: xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c
diff -u xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c:1.1 xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c:1.2
--- xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c:1.1	Tue Jun 20 01:08:40 2000
+++ xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c	Thu Dec  7 15:26:05 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c,v 1.1 2000/06/20 05:08:40 dawes Exp $
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c,v 1.2 2000/12/07 20:26:05 dawes Exp $
  *
  * GLX Hardware Device Driver for Sun Creator/Creator3D
  * Copyright (C) 2000 David S. Miller
@@ -515,6 +515,18 @@
 GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv)
 {
 	return GL_TRUE;
+}
+
+GLboolean
+XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
+}
+
+GLboolean
+XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
 }
 
 void ffbXMesaUpdateState(ffbContextPtr fmesa)
Index: xc/lib/GL/mesa/src/drv/gamma/Imakefile
diff -u xc/lib/GL/mesa/src/drv/gamma/Imakefile:1.11 xc/lib/GL/mesa/src/drv/gamma/Imakefile:1.16
--- xc/lib/GL/mesa/src/drv/gamma/Imakefile:1.11	Sun Jun 25 10:44:26 2000
+++ xc/lib/GL/mesa/src/drv/gamma/Imakefile	Tue Dec 12 18:24:27 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/drv/gamma/Imakefile,v 1.11 2000/06/25 14:44:26 alanh Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/gamma/Imakefile,v 1.16 2000/12/12 23:24:27 dawes Exp $
 
 #include <Threads.tmpl>
 
@@ -12,6 +12,19 @@
 ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
 #endif
 
+#ifdef i386Architecture
+#if MesaUseMMX
+     MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+   3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseKatmai
+  KATMAI_DEFS = -DUSE_KATMAI_ASM
+#endif
+  ASM_DEFINES = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(KATMAI_DEFS)
+#endif
+
 #if BuildXF86DRI
   DRI_DEFINES = GlxDefines -DDRIVERTS
  DRI_INCLUDES = -I../../../../dri -I../../../../glx \
@@ -19,25 +32,16 @@
 		-I$(TOP)/include -I$(TOP)/include/GL \
 		-I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
 		-I$(XF86DRIVERSRC)/glint \
-		-I../../../include -I../.. -I../../X -I../common \
-	        -I$(XF86OSSRC)/linux/drm/kernel
+		-I../../../include -I../.. -I../../X -I../common
 #endif
-
-MESA_INCLUDES = -I. -I.. -I../../include
 
+MESA_INCLUDES = -I. -I.. -I../../include \
+		-I../../../../dri/drm
 
 
-      DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
+      DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFINES)
      INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) 
 
-#if 0
-	LOSRC = ../../../../lowpc.c
-	LOOBJ = ../../../../lowpc.o
-
-	HISRC = ../../../../highpc.c
-	HIOBJ = ../../../../highpc.o
-#endif
-
       DRISRCS = ../../../dri/dri_mesa.c \
 		../../../../dri/dri_tmm.c
 
@@ -53,12 +57,22 @@
 		../../../../dri/drm/xf86drmHash.o \
 		../../../../dri/drm/xf86drmRandom.o \
 		../../../../dri/drm/xf86drmSL.o
-
-    GAMMASRCS = gamma_gl.c gamma_xmesa.c gamma_init.c gamma_matrix.c \
-                gamma_inithw.c gamma_texture.c /* gamma_dlist.c */
 
-    GAMMAOBJS = gamma_gl.o gamma_xmesa.o gamma_init.o gamma_matrix.o \
-                gamma_inithw.o gamma_texture.o /* gamma_dlist.o */
+    GAMMASRCS = gamma_gl.c \
+		gamma_xmesa.c \
+		gamma_init.c \
+		gamma_matrix.c \
+		gamma_inithw.c \
+		gamma_texture.c \
+		/* gamma_dlist.c */
+
+    GAMMAOBJS = gamma_gl.o \
+		gamma_xmesa.o \
+		gamma_init.o \
+		gamma_matrix.o \
+		gamma_inithw.o \
+		gamma_texture.o \
+		/* gamma_dlist.o */
 
      MESASRCS = ../../aatriangle.c \
 		../../accum.c \
@@ -209,26 +223,40 @@
 		../../zoom.o
 
 #ifdef i386Architecture
-     X86_SRCS = ../../X86/x86.c \
-		../../X86/x86a.S \
-		../../X86/common_x86.c \
-		../../X86/common_x86asm.S \
-		../../X86/vertex.S
-
-     X86_OBJS = ../../X86/x86.o \
-		../../X86/x86a.o \
-		../../X86/common_x86.o \
-		../../X86/common_x86asm.o \
-		../../X86/vertex.o
+     X86_SRCS = ../../X86/common_x86.c \
+		../../X86/common_x86_asm.S \
+		../../X86/x86.c \
+		../../X86/x86_cliptest.S \
+		../../X86/x86_vertex.S \
+		../../X86/x86_xform_masked2.S \
+		../../X86/x86_xform_masked3.S \
+		../../X86/x86_xform_masked4.S \
+		../../X86/x86_xform_raw2.S \
+		../../X86/x86_xform_raw3.S \
+		../../X86/x86_xform_raw4.S
+
+     X86_OBJS = ../../X86/common_x86.o \
+		../../X86/common_x86_asm.o \
+		../../X86/x86.o \
+		../../X86/x86_cliptest.o \
+		../../X86/x86_vertex.o \
+		../../X86/x86_xform_masked2.o \
+		../../X86/x86_xform_masked3.o \
+		../../X86/x86_xform_masked4.o \
+		../../X86/x86_xform_raw2.o \
+		../../X86/x86_xform_raw3.o \
+		../../X86/x86_xform_raw4.o
 
+#if MesaUseMMX
      MMX_SRCS = ../../X86/mmx_blend.S
 
      MMX_OBJS = ../../X86/mmx_blend.o
+#endif
 
-XCOMM Disabling 3Dnow code for the time being.
-#if 0
+#if MesaUse3DNow
    3DNOW_SRCS = ../../X86/3dnow.c \
 		../../X86/3dnow_norm_raw.S \
+		../../X86/3dnow_vertex.S \
 		../../X86/3dnow_xform_masked1.S \
 		../../X86/3dnow_xform_masked2.S \
 		../../X86/3dnow_xform_masked3.S \
@@ -236,11 +264,11 @@
 		../../X86/3dnow_xform_raw1.S \
 		../../X86/3dnow_xform_raw2.S \
 		../../X86/3dnow_xform_raw3.S \
-		../../X86/3dnow_xform_raw4.S \
-		../../X86/vertex_3dnow.S
+		../../X86/3dnow_xform_raw4.S
 
    3DNOW_OBJS = ../../X86/3dnow.o \
 		../../X86/3dnow_norm_raw.o \
+		../../X86/3dnow_vertex.o \
 		../../X86/3dnow_xform_masked1.o \
 		../../X86/3dnow_xform_masked2.o \
 		../../X86/3dnow_xform_masked3.o \
@@ -248,19 +276,53 @@
 		../../X86/3dnow_xform_raw1.o \
 		../../X86/3dnow_xform_raw2.o \
 		../../X86/3dnow_xform_raw3.o \
-		../../X86/3dnow_xform_raw4.o \
-		../../X86/vertex_3dnow.o
+		../../X86/3dnow_xform_raw4.o
 #endif
 
+#if MesaUseKatmai
+  KATMAI_SRCS = ../../X86/katmai.c \
+		../../X86/katmai_norm_raw.S \
+		../../X86/katmai_vertex.S \
+		../../X86/katmai_xform_masked1.S \
+		../../X86/katmai_xform_masked2.S \
+		../../X86/katmai_xform_masked3.S \
+		../../X86/katmai_xform_masked4.S \
+		../../X86/katmai_xform_raw1.S \
+		../../X86/katmai_xform_raw2.S \
+		../../X86/katmai_xform_raw3.S \
+		../../X86/katmai_xform_raw4.S
+
+  KATMAI_OBJS = ../../X86/katmai.o \
+		../../X86/katmai_norm_raw.o \
+		../../X86/katmai_vertex.o \
+		../../X86/katmai_xform_masked1.o \
+		../../X86/katmai_xform_masked2.o \
+		../../X86/katmai_xform_masked3.o \
+		../../X86/katmai_xform_masked4.o \
+		../../X86/katmai_xform_raw1.o \
+		../../X86/katmai_xform_raw2.o \
+		../../X86/katmai_xform_raw3.o \
+		../../X86/katmai_xform_raw4.o
 #endif
+#endif
 
-      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
-      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+#ifdef GlxSoProf
+       LOSRCS = ../../../../lowpc.c
+       HISRCS = ../../../../highpc.c
 
-         SRCS = $(LOWSRC) $(DRISRCS) $(DRMSRCS) $(MESASRCS) $(ASMSRCS) $(GAMMASRCS) $(HISRC)
-         OBJS = $(LOWOBJ) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) $(GAMMAOBJS) $(HIOBJ)
+       LOOBJS = ../../../../lowpc.o
+       HIOBJS = ../../../../highpc.o
+#endif
 
-REQUIREDLIBS += -lm
+      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS)
+      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS)
+
+         SRCS = $(LOWSRCS) $(DRISRCS) $(DRMSRCS) $(MESASRCS) \
+		$(ASMSRCS) $(GAMMASRCS) $(HISRCS)
+         OBJS = $(LOWOBJS) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) \
+		$(ASMOBJS) $(GAMMAOBJS) $(HIOBJS)
+
+REQUIREDLIBS += MathLibrary
 #if !GlxBuiltInGamma
 REQUIREDLIBS += -L../../../.. -lGL
 #endif
@@ -286,6 +348,12 @@
 ALL_DEPS = DONE
 SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
 InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _gamma_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
 #endif
 
 DependTarget()
Index: xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c
diff -u xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c:1.6 xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c:1.7
--- xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c:1.6	Fri Jun 16 20:02:55 2000
+++ xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c	Mon Nov 27 05:59:36 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c,v 1.6 2000/06/17 00:02:55 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c,v 1.7 2000/11/27 10:59:36 alanh Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -30,7 +30,7 @@
  * Authors:
  *   Kevin E. Martin <kevin@precisioninsight.com>
  *   Brian Paul <brian@precisioninsight.com>
- *   Alan Hourihane <Alan.Hourihane@btinternet.com>
+ *   Alan Hourihane <alanh@fairlite.demon.co.uk>
  */
 
 #ifdef GLX_DIRECT_RENDERING
Index: xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c
diff -u xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c:1.5 xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c:1.6
--- xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c:1.5	Fri Jun 16 20:02:56 2000
+++ xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c	Mon Nov 27 05:59:37 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c,v 1.5 2000/06/17 00:02:56 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c,v 1.6 2000/11/27 10:59:37 alanh Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -29,7 +29,7 @@
 /*
  * Authors:
  *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Alan Hourihane <Alan.Hourihane@btinternet.com>
+ *   Alan Hourihane <alanh@fairlite.demon.co.uk>
  *
  */
 
Index: xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c
diff -u xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c:1.6 xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c:1.8
--- xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c:1.6	Fri Jun 16 20:02:56 2000
+++ xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c	Thu Dec  7 15:26:05 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c,v 1.6 2000/06/17 00:02:56 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c,v 1.8 2000/12/07 20:26:05 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -30,7 +30,7 @@
  * Authors:
  *   Kevin E. Martin <kevin@precisioninsight.com>
  *   Brian Paul <brian@precisioninsight.com>
- *   Alan Hourihane <Alan.Hourihane@btinternet.com>
+ *   Alan Hourihane <alanh@fairlite.demon.co.uk>
  */
 
 #ifdef GLX_DIRECT_RENDERING
@@ -526,6 +526,18 @@
 {
    /* XXX not 100% sure what's supposed to be done here */
    return GL_TRUE;
+}
+
+GLboolean
+XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
+}
+
+GLboolean
+XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
 }
 
 
Index: xc/lib/GL/mesa/src/drv/i810/Imakefile
diff -u xc/lib/GL/mesa/src/drv/i810/Imakefile:1.6 xc/lib/GL/mesa/src/drv/i810/Imakefile:1.13
--- xc/lib/GL/mesa/src/drv/i810/Imakefile:1.6	Fri Jun 30 13:15:08 2000
+++ xc/lib/GL/mesa/src/drv/i810/Imakefile	Tue Dec 12 18:24:27 2000
@@ -1,3 +1,4 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/i810/Imakefile,v 1.13 2000/12/12 23:24:27 dawes Exp $
 
 #include <Threads.tmpl>
 
@@ -11,12 +12,18 @@
 ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
 #endif
 
-#if defined(LinuxArchitecture)
-OS_SUBDIR = linux
+#ifdef i386Architecture
+#if MesaUseMMX
+     MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+   3DNOW_DEFS = -DUSE_3DNOW_ASM
 #endif
-#if defined(FreeBSDArchitecture) || defined(BSDOSArchitecture)
-OS_SUBDIR = bsd
+#if MesaUseKatmai
+  KATMAI_DEFS = -DUSE_KATMAI_ASM
 #endif
+  ASM_DEFINES = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(KATMAI_DEFS)
+#endif
 
 #if BuildXF86DRI
   DRI_DEFINES = GlxDefines -DDRIVERTS
@@ -25,15 +32,13 @@
 		-I$(TOP)/include -I$(TOP)/include/GL \
 		-I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
 		-I$(XF86DRIVERSRC)/i810  \
-		-I../../../include -I../.. -I../common -I../../X \
-	        -I$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel
+		-I../../../include -I../.. -I../common -I../../X
 #endif
-
-MESA_INCLUDES = -I. -I.. -I../../include
 
+MESA_INCLUDES = -I. -I.. -I../../include \
+		-I../../../../dri/drm
 
-
-      DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
+      DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFINES)
      INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) 
 
       DRISRCS = ../../../dri/dri_mesa.c \
@@ -51,17 +56,28 @@
 		../../../../dri/drm/xf86drmHash.o \
 		../../../../dri/drm/xf86drmRandom.o \
 		../../../../dri/drm/xf86drmSL.o
-
 
-     I810SRCS = i810_xmesa.c	\
-		i810dd.c  	\
-		i810pipeline.c i810span.c i810state.c	\
-		i810tex.c i810tris.c i810vb.c i810fastpath.c i810ioctl.c
+     I810SRCS = i810_xmesa.c \
+		i810dd.c \
+		i810pipeline.c \
+		i810span.c \
+		i810state.c \
+		i810tex.c \
+		i810tris.c \
+		i810vb.c \
+		i810fastpath.c \
+		i810ioctl.c
 
      I810OBJS = i810_xmesa.o \
-		i810dd.o  		\
-		i810pipeline.o i810span.o i810state.o	\
-		i810tex.o i810tris.o i810vb.o i810fastpath.o i810ioctl.o
+		i810dd.o \
+		i810pipeline.o \
+		i810span.o \
+		i810state.o \
+		i810tex.o \
+		i810tris.o \
+		i810vb.o \
+		i810fastpath.o \
+		i810ioctl.o
 
      MESASRCS = ../../aatriangle.c \
 		../../accum.c \
@@ -212,26 +228,40 @@
 		../../zoom.o
 
 #ifdef i386Architecture
-     X86_SRCS = ../../X86/x86.c \
-		../../X86/x86a.S \
-		../../X86/common_x86.c \
-		../../X86/common_x86asm.S \
-		../../X86/vertex.S
-
-     X86_OBJS = ../../X86/x86.o \
-		../../X86/x86a.o \
-		../../X86/common_x86.o \
-		../../X86/common_x86asm.o \
-		../../X86/vertex.o
+     X86_SRCS = ../../X86/common_x86.c \
+		../../X86/common_x86_asm.S \
+		../../X86/x86.c \
+		../../X86/x86_cliptest.S \
+		../../X86/x86_vertex.S \
+		../../X86/x86_xform_masked2.S \
+		../../X86/x86_xform_masked3.S \
+		../../X86/x86_xform_masked4.S \
+		../../X86/x86_xform_raw2.S \
+		../../X86/x86_xform_raw3.S \
+		../../X86/x86_xform_raw4.S
+
+     X86_OBJS = ../../X86/common_x86.o \
+		../../X86/common_x86_asm.o \
+		../../X86/x86.o \
+		../../X86/x86_cliptest.o \
+		../../X86/x86_vertex.o \
+		../../X86/x86_xform_masked2.o \
+		../../X86/x86_xform_masked3.o \
+		../../X86/x86_xform_masked4.o \
+		../../X86/x86_xform_raw2.o \
+		../../X86/x86_xform_raw3.o \
+		../../X86/x86_xform_raw4.o
 
+#if MesaUseMMX
      MMX_SRCS = ../../X86/mmx_blend.S
 
      MMX_OBJS = ../../X86/mmx_blend.o
+#endif
 
-XCOMM Disabling 3Dnow code for the time being.
-#if 0
+#if MesaUse3DNow
    3DNOW_SRCS = ../../X86/3dnow.c \
 		../../X86/3dnow_norm_raw.S \
+		../../X86/3dnow_vertex.S \
 		../../X86/3dnow_xform_masked1.S \
 		../../X86/3dnow_xform_masked2.S \
 		../../X86/3dnow_xform_masked3.S \
@@ -239,11 +269,11 @@
 		../../X86/3dnow_xform_raw1.S \
 		../../X86/3dnow_xform_raw2.S \
 		../../X86/3dnow_xform_raw3.S \
-		../../X86/3dnow_xform_raw4.S \
-		../../X86/vertex_3dnow.S
+		../../X86/3dnow_xform_raw4.S
 
    3DNOW_OBJS = ../../X86/3dnow.o \
 		../../X86/3dnow_norm_raw.o \
+		../../X86/3dnow_vertex.o \
 		../../X86/3dnow_xform_masked1.o \
 		../../X86/3dnow_xform_masked2.o \
 		../../X86/3dnow_xform_masked3.o \
@@ -251,22 +281,56 @@
 		../../X86/3dnow_xform_raw1.o \
 		../../X86/3dnow_xform_raw2.o \
 		../../X86/3dnow_xform_raw3.o \
-		../../X86/3dnow_xform_raw4.o \
-		../../X86/vertex_3dnow.o
+		../../X86/3dnow_xform_raw4.o
 #endif
 
+#if MesaUseKatmai
+  KATMAI_SRCS = ../../X86/katmai.c \
+		../../X86/katmai_norm_raw.S \
+		../../X86/katmai_vertex.S \
+		../../X86/katmai_xform_masked1.S \
+		../../X86/katmai_xform_masked2.S \
+		../../X86/katmai_xform_masked3.S \
+		../../X86/katmai_xform_masked4.S \
+		../../X86/katmai_xform_raw1.S \
+		../../X86/katmai_xform_raw2.S \
+		../../X86/katmai_xform_raw3.S \
+		../../X86/katmai_xform_raw4.S
+
+  KATMAI_OBJS = ../../X86/katmai.o \
+		../../X86/katmai_norm_raw.o \
+		../../X86/katmai_vertex.o \
+		../../X86/katmai_xform_masked1.o \
+		../../X86/katmai_xform_masked2.o \
+		../../X86/katmai_xform_masked3.o \
+		../../X86/katmai_xform_masked4.o \
+		../../X86/katmai_xform_raw1.o \
+		../../X86/katmai_xform_raw2.o \
+		../../X86/katmai_xform_raw3.o \
+		../../X86/katmai_xform_raw4.o
 #endif
+#endif
+
+#ifdef GlxSoProf
+       LOSRCS = ../../../../lowpc.c
+       HISRCS = ../../../../highpc.c
+
+       LOOBJS = ../../../../lowpc.o
+       HIOBJS = ../../../../highpc.o
+#endif
 
-      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
-      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS)
+      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS)
 
-      COMMONSRCS = ../common/mm.c ../common/hwlog.c
-      COMMONOBJS = ../common/mm.o ../common/hwlog.o
+   COMMONSRCS = ../common/mm.c ../common/hwlog.c
+   COMMONOBJS = ../common/mm.o ../common/hwlog.o
 
-         SRCS = $(DRISRCS) $(DRMSRCS) $(MESASRCS) $(ASMSRCS) $(COMMONSRCS) $(I810SRCS) 
-         OBJS = $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) $(COMMONOBJS) $(I810OBJS)
+         SRCS = $(LOSRCS) $(DRISRCS) $(DRMSRCS) $(MESASRCS) \
+		$(ASMSRCS) $(COMMONSRCS) $(I810SRCS) $(HISRCS)
+         OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) \
+		$(ASMOBJS) $(COMMONOBJS) $(I810OBJS) $(HIOBJS)
 
-REQUIREDLIBS += -lm
+REQUIREDLIBS += MathLibrary
 #if !GlxBuiltInI810
 REQUIREDLIBS += -L../../../.. -lGL
 #endif
@@ -292,6 +356,12 @@
 ALL_DEPS = DONE
 SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
 InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _i810_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
 #endif
 
 DependTarget()
Index: xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h
diff -u xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h:1.3 xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h:1.5
--- xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h:1.3	Tue Jun 20 01:08:40 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h	Sun Aug 27 22:43:11 2000
@@ -1,5 +1,5 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h,v 1.5 2000/08/28 02:43:11 tsi Exp $ */
 
-
 #ifndef I810_3D_REG_H
 #define I810_3D_REG_H
 
@@ -110,6 +110,8 @@
 #define LCS_LINEWIDTH_SHIFT           12
 #define LCS_LINEWIDTH_0_5       (0x1<<12)
 #define LCS_LINEWIDTH_1_0       (0x2<<12)
+#define LCS_LINEWIDTH_2_0       (0x4<<12)
+#define LCS_LINEWIDTH_3_0       (0x6<<12)
 #define LCS_UPDATE_ALPHA_INTERP (0x1<<11)
 #define LCS_ALPHA_FLAT          (0x0<<10)
 #define LCS_ALPHA_INTERP        (0x1<<10)
@@ -652,5 +654,19 @@
 
 #define I810PACKCOLOR565(r,g,b) \
   ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+
+#define I810_VFMT_T0 (GFX_OP_VERTEX_FMT |	\
+		      VF_TEXCOORD_COUNT_1 |	\
+		      VF_SPEC_FOG_ENABLE |	\
+		      VF_RGBA_ENABLE |		\
+		      VF_XYZW)
+
+#define I810_VFMT_T0T1 (GFX_OP_VERTEX_FMT |	\
+		        VF_TEXCOORD_COUNT_2 |	\
+		        VF_SPEC_FOG_ENABLE |	\
+		        VF_RGBA_ENABLE |	\
+		        VF_XYZW)
+
 
 #endif
Index: xc/lib/GL/mesa/src/drv/i810/i810_init.h
diff -u xc/lib/GL/mesa/src/drv/i810/i810_init.h:1.3 xc/lib/GL/mesa/src/drv/i810/i810_init.h:1.4
--- xc/lib/GL/mesa/src/drv/i810/i810_init.h:1.3	Fri Jun 16 20:02:58 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810_init.h	Wed Aug  2 22:30:19 2000
@@ -78,7 +78,7 @@
 
    __DRIscreenPrivate *driScrnPriv;
    drmBufMapPtr  bufs;
-
+   int use_copy_buf;
 } i810ScreenPrivate;
 
 
Index: xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c
diff -u xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c:1.4 xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c:1.9
--- xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c:1.4	Thu Jun 22 12:59:24 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c	Thu Dec  7 15:26:06 2000
@@ -24,7 +24,7 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c,v 1.4 2000/06/22 16:59:24 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c,v 1.9 2000/12/07 20:26:06 dawes Exp $ */
 
 /*
  * Authors:
@@ -92,6 +92,21 @@
  */
 
 
+static int i810_malloc_proxy_buf(drmBufMapPtr buffers)
+{
+   char *buffer;
+   drmBufPtr buf;
+   int i;
+   
+   buffer = Xmalloc(I810_DMA_BUF_SZ);
+   if(buffer == NULL) return -1;
+   for(i = 0; i < I810_DMA_BUF_NR; i++) {
+      buf = &(buffers->list[i]);
+      buf->address = (drmAddress)buffer;
+   }
+   return 0;
+}
+
 static drmBufMapPtr i810_create_empty_buffers(void)
 {
    drmBufMapPtr retval;
@@ -141,7 +156,7 @@
 
    /* Check that the DRM driver version is compatible */
    if (sPriv->drmMajor != 1 ||
-       sPriv->drmMinor != 0 ||
+       sPriv->drmMinor != 1 ||
        sPriv->drmPatch < 0) {
       char msg[1000];
       sprintf(msg, "i810 DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
@@ -188,6 +203,17 @@
       Xfree(i810Screen);
       return GL_FALSE;
    }
+   
+   /* Check if you need to create a fake buffer */
+   if(i810_check_copy(sPriv->fd) == 1)
+   {
+      i810_malloc_proxy_buf(i810Screen->bufs);
+      i810Screen->use_copy_buf = 1;
+   }
+   else
+   {
+      i810Screen->use_copy_buf = 0;
+   }
     
    i810Screen->back.handle = gDRIPriv->backbuffer;
    i810Screen->back.size = gDRIPriv->backbufferSize;
@@ -313,6 +339,12 @@
       ctx->Const.MaxTextureSize = 1<<10;
    }      
 
+   ctx->Const.MinLineWidth = 1.0;
+   ctx->Const.MinLineWidthAA = 1.0;
+   ctx->Const.MaxLineWidth = 3.0;
+   ctx->Const.MaxLineWidthAA = 3.0;
+   ctx->Const.LineWidthGranularity = 1.0;
+
 
    /* Dri stuff
     */
@@ -362,9 +394,6 @@
     */
    ctx->TriangleCaps |= DD_CLIP_FOG_COORD;
 
-   ctx->Shared->DefaultD[2][0].DriverData = 0;
-   ctx->Shared->DefaultD[2][1].DriverData = 0;
-
    if (ctx->VB) 
       i810DDRegisterVB( ctx->VB );
 
@@ -454,7 +483,6 @@
    imesa->drawX = dPriv->x;
    imesa->drawY = dPriv->y;
 
-   imesa->drawMap = (char *)imesa->driScreen->pFB;
    i810EmitDrawingRectangle( imesa );
 }
 
@@ -485,7 +513,6 @@
       imesa->drawY = dPriv->backY;
    }
 
-   imesa->drawMap = imesa->i810Screen->back.map;
    i810EmitDrawingRectangle( imesa );
    imesa->dirty |= I810_UPLOAD_CLIPRECTS;
 
@@ -526,6 +553,18 @@
       i810->dirty = ~0;
 
    return GL_TRUE;
+}
+
+GLboolean
+XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
+}
+
+GLboolean
+XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
 }
 
 
Index: xc/lib/GL/mesa/src/drv/i810/i810context.h
diff -u xc/lib/GL/mesa/src/drv/i810/i810context.h:1.3 xc/lib/GL/mesa/src/drv/i810/i810context.h:1.5
--- xc/lib/GL/mesa/src/drv/i810/i810context.h:1.3	Tue Jun 20 01:08:40 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810context.h	Sun Aug 27 22:43:11 2000
@@ -21,8 +21,8 @@
  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810context.h,v 1.5 2000/08/28 02:43:11 tsi Exp $ */
 
-
 #ifndef I810CONTEXT_INC
 #define I810CONTEXT_INC
 
@@ -54,6 +54,7 @@
 #define I810_FALLBACK_COLORMASK      0x8  
 #define I810_FALLBACK_STIPPLE        0x10  
 #define I810_FALLBACK_SPECULAR       0x20 
+#define I810_FALLBACK_LOGICOP        0x40
 
 
 
@@ -96,6 +97,7 @@
     */
    GLuint Setup[I810_CTX_SETUP_SIZE];
    GLuint BufferSetup[I810_DEST_SETUP_SIZE];
+   int vertsize;
    
 
    /* Support for CVA and the fast paths.
Index: xc/lib/GL/mesa/src/drv/i810/i810dd.c
diff -u xc/lib/GL/mesa/src/drv/i810/i810dd.c:1.3 xc/lib/GL/mesa/src/drv/i810/i810dd.c:1.4
--- xc/lib/GL/mesa/src/drv/i810/i810dd.c:1.3	Thu Jun 22 12:59:24 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810dd.c	Sun Sep 24 09:51:04 2000
@@ -21,7 +21,7 @@
  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810dd.c,v 1.3 2000/06/22 16:59:24 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810dd.c,v 1.4 2000/09/24 13:51:04 alanh Exp $ */
 
 #include "types.h"
 #include "vbrender.h"
@@ -77,8 +77,15 @@
 static void i810BufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
 {
    i810ContextPtr imesa = I810_CONTEXT(ctx);  
+
+   /* Need to lock to make sure the driDrawable is uptodate.  This
+    * information is used to resize Mesa's software buffers, so it has
+    * to be correct.
+    */
+   LOCK_HARDWARE(imesa);
    *width = imesa->driDrawable->w;
    *height = imesa->driDrawable->h;
+   UNLOCK_HARDWARE(imesa);
 }
 
 
@@ -97,17 +104,19 @@
    /* The imaging subset of 1.2 isn't supported by any mesa driver.
     */
    gl_extensions_disable( ctx, "ARB_imaging" );
+   gl_extensions_disable( ctx, "GL_ARB_texture_compression" );   
+   gl_extensions_disable( ctx, "GL_ARB_texture_cube_map" );   
    gl_extensions_disable( ctx, "GL_EXT_blend_color" );
-   gl_extensions_disable( ctx, "GL_EXT_blend_minmax" );
    gl_extensions_disable( ctx, "GL_EXT_blend_logic_op" );
+   gl_extensions_disable( ctx, "GL_EXT_blend_minmax" );
    gl_extensions_disable( ctx, "GL_EXT_blend_subtract" );
-   gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );
+   gl_extensions_disable( ctx, "GL_EXT_convolution" );   
    gl_extensions_disable( ctx, "GL_EXT_texture_lod_bias" );   
+   gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );
    gl_extensions_disable( ctx, "GL_MESA_resize_buffers" );   
-
-
-   if (0) gl_extensions_disable( ctx, "GL_ARB_multitexture" );
-
+   gl_extensions_disable( ctx, "GL_SGIX_pixel_texture" );   
+   gl_extensions_disable( ctx, "GL_SGI_color_matrix" );   
+   gl_extensions_disable( ctx, "GL_SGI_color_table" );   
 
    /* We do support tex_env_add, however
     */
Index: xc/lib/GL/mesa/src/drv/i810/i810fastpath.c
diff -u xc/lib/GL/mesa/src/drv/i810/i810fastpath.c:1.2 xc/lib/GL/mesa/src/drv/i810/i810fastpath.c:1.5
--- xc/lib/GL/mesa/src/drv/i810/i810fastpath.c:1.2	Fri Jun 16 20:02:59 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810fastpath.c	Mon Nov 13 18:31:27 2000
@@ -21,6 +21,7 @@
  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810fastpath.c,v 1.5 2000/11/13 23:31:27 dawes Exp $ */
 
 #include <stdio.h>
 
@@ -50,9 +51,9 @@
 
 
 
-#define POINT(x) i810_draw_point(imesa, &ivert[x].v, psize)
-#define LINE(x,y) i810_draw_line(imesa, &ivert[x].v, &ivert[y].v, lwidth)
-#define TRI(x,y,z) i810_draw_triangle(imesa, &ivert[x].v, &ivert[y].v, &ivert[z].v)
+#define POINT(x) i810_draw_point(imesa, &ivert[x], psize)
+#define LINE(x,y) i810_draw_line(imesa, &ivert[x], &ivert[y] )
+#define TRI(x,y,z) i810_draw_triangle(imesa, &ivert[x], &ivert[y], &ivert[z])
 
 
 
@@ -63,7 +64,7 @@
 #define RENDER_POINTS( start, count )		\
 do {						\
    GLuint e;					\
-   for(e=start;e<=count;e++)			\
+   for(e=start;e<count;e++)			\
      POINT(elt[e]);				\
 } while (0)
 
@@ -94,9 +95,8 @@
    const GLuint *elt = VB->EltPtr->data;		\
    GLcontext *ctx = VB->ctx;				\
    i810ContextPtr imesa = I810_CONTEXT(ctx);	\
-   const GLfloat lwidth = ctx->Line.Width;		\
    const GLfloat psize = ctx->Point.Size;		\
-   (void) lwidth; (void)psize; (void) ivert;
+   (void)psize; (void) ivert;
 
 
 #define TAG(x) x##_i810_smooth_indirect
Index: xc/lib/GL/mesa/src/drv/i810/i810ioctl.c
diff -u xc/lib/GL/mesa/src/drv/i810/i810ioctl.c:1.1 xc/lib/GL/mesa/src/drv/i810/i810ioctl.c:1.4
--- xc/lib/GL/mesa/src/drv/i810/i810ioctl.c:1.1	Fri Jun 16 20:02:59 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810ioctl.c	Sun Aug 27 22:43:11 2000
@@ -1,7 +1,8 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810ioctl.c,v 1.4 2000/08/28 02:43:11 tsi Exp $ */
+
 #include <stdio.h>
 #include <unistd.h>
 
-
 #include "types.h"
 #include "pb.h"
 #include "dd.h"
@@ -14,7 +15,7 @@
 #include "drm.h"
 #include <sys/ioctl.h>
 
-static drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa )
+drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa )
 {
    drm_i810_dma_t dma;
    drmBufPtr buf;
@@ -43,9 +44,11 @@
 
    buf = &(imesa->i810Screen->bufs->list[dma.request_idx]);
    buf->idx = dma.request_idx;
-   buf->used = 0;
+   buf->used = 4;		/* leave room for instruction header */
    buf->total = dma.request_size;
-   buf->address = (drmAddress)dma.virtual;
+
+   if(imesa->i810Screen->use_copy_buf != 1) 
+       buf->address = (drmAddress)dma.virtual;
    return buf;
 }
 
@@ -340,7 +343,17 @@
 
    if (nbox > I810_NR_SAREA_CLIPRECTS)
       imesa->dirty |= I810_UPLOAD_CLIPRECTS;
+   
+   if(imesa->i810Screen->use_copy_buf == 1 && vertex.used) {
+      drm_i810_copy_t copy;
+      
+      copy.idx = buffer->idx;
+      copy.used = buffer->used;
+      copy.address = buffer->address;
+      ioctl(imesa->driFd, DRM_IOCTL_I810_COPY, &copy);
+   }
 
+
    imesa->sarea->vertex_prim = imesa->vertex_prim;
 
    if (!nbox || !(imesa->dirty & I810_UPLOAD_CLIPRECTS)) 
@@ -416,46 +429,35 @@
 }
 
 
-GLuint *i810AllocDwords( i810ContextPtr imesa, int dwords, GLuint prim )
+GLuint *i810AllocDwords( i810ContextPtr imesa, int dwords )
 {
    GLuint *start;
 
    if (!imesa->vertex_dma_buffer) 
    {
-      if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
-	 fprintf(stderr, "i810AllocPrimitiveVerts -- get buf\n");
       LOCK_HARDWARE(imesa);
       imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
-      imesa->vertex_dma_buffer->used = 4;
-      imesa->vertex_prim = prim;
       UNLOCK_HARDWARE(imesa);
    } 
-   else if (imesa->vertex_prim != prim ||
-	    imesa->vertex_dma_buffer->used + dwords * 4 > 
+   else if (imesa->vertex_dma_buffer->used + dwords * 4 > 
 	    imesa->vertex_dma_buffer->total) 
    {
-      if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
-	 fprintf(stderr, "i810AllocPrimitiveVerts -- flush\n");
-      i810FlushVertices( imesa );
       LOCK_HARDWARE(imesa);
+      i810FlushVerticesLocked( imesa );
       imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
-      imesa->vertex_dma_buffer->used = 4;
-      imesa->vertex_prim = prim;
       UNLOCK_HARDWARE(imesa);
    }
 
-
-   if (0)
-      fprintf(stderr, "i810AllocPrimitiveVerts %d, buf %d, used %d\n",
-	      dwords, imesa->vertex_dma_buffer->idx,
-	      imesa->vertex_dma_buffer->used);
-      
    start = (GLuint *)((char *)imesa->vertex_dma_buffer->address + 
 		      imesa->vertex_dma_buffer->used);
 
    imesa->vertex_dma_buffer->used += dwords * 4;
-
    return start;
+}
+
+int i810_check_copy(int fd)
+{
+   return(ioctl(fd, DRM_IOCTL_I810_DOCOPY));
 }
 
 static void i810DDFlush( GLcontext *ctx )
Index: xc/lib/GL/mesa/src/drv/i810/i810ioctl.h
diff -u xc/lib/GL/mesa/src/drv/i810/i810ioctl.h:1.1 xc/lib/GL/mesa/src/drv/i810/i810ioctl.h:1.5
--- xc/lib/GL/mesa/src/drv/i810/i810ioctl.h:1.1	Fri Jun 16 20:02:59 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810ioctl.h	Tue Oct 24 18:45:01 2000
@@ -1,10 +1,12 @@
-#ifndef MGA_IOCTL_H
-#define MGA_IOCTL_H
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810ioctl.h,v 1.5 2000/10/24 22:45:01 dawes Exp $ */
 
+#ifndef I810_IOCTL_H
+#define I810_IOCTL_H
+
 #include "i810context.h"
 
 
-GLuint *i810AllocDwords( i810ContextPtr imesa, int dwords, GLuint prim );
+GLuint *i810AllocDwords( i810ContextPtr imesa, int dwords );
 
 void i810GetGeneralDmaBufferLocked( i810ContextPtr mmesa ); 
 
@@ -23,6 +25,8 @@
 
 void i810SwapBuffers( i810ContextPtr imesa );
 
+int i810_check_copy(int fd);
+
 GLbitfield i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
 		      GLint cx, GLint cy, GLint cw, GLint ch );
 
@@ -32,5 +36,34 @@
 	if (imesa->vertex_dma_buffer) i810FlushVertices(imesa);		\
 } while (0)
 
+extern drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa );
+
+static __inline
+GLuint *i810AllocDwordsInline( i810ContextPtr imesa, int dwords )
+{
+   int bytes = dwords * 4;
+   GLuint *start;
+
+   if (!imesa->vertex_dma_buffer) 
+   {
+      LOCK_HARDWARE(imesa);
+      imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
+      UNLOCK_HARDWARE(imesa);
+   } 
+   else if (imesa->vertex_dma_buffer->used + bytes > 
+	    imesa->vertex_dma_buffer->total) 
+   {
+      LOCK_HARDWARE(imesa);
+      i810FlushVerticesLocked( imesa );
+      imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
+      UNLOCK_HARDWARE(imesa);
+   }
+
+   start = (GLuint *)((char *)imesa->vertex_dma_buffer->address + 
+		      imesa->vertex_dma_buffer->used);
+
+   imesa->vertex_dma_buffer->used += bytes;
+   return start;
+}
 
 #endif
Index: xc/lib/GL/mesa/src/drv/i810/i810state.c
diff -u xc/lib/GL/mesa/src/drv/i810/i810state.c:1.4 xc/lib/GL/mesa/src/drv/i810/i810state.c:1.5
--- xc/lib/GL/mesa/src/drv/i810/i810state.c:1.4	Thu Jun 22 12:59:24 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810state.c	Fri Aug 25 09:42:21 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810state.c,v 1.4 2000/06/22 16:59:24 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810state.c,v 1.5 2000/08/25 13:42:21 dawes Exp $ */
 
 #include <stdio.h>
 
@@ -65,8 +65,8 @@
 {
    if (mode != GL_FUNC_ADD_EXT) {
       ctx->Color.BlendEquation = GL_FUNC_ADD_EXT;
-      i810Error("Unsupported blend equation");
-      exit(1);
+      if (0) fprintf(stderr, "Unsupported blend equation: %s\n", 
+		     gl_lookup_enum_by_nr(mode));
    }
 }
 
@@ -242,7 +242,21 @@
 {
 }
 
+static void i810DDLogicOp( GLcontext *ctx, GLenum opcode )
+{
+   if (ctx->Color.ColorLogicOpEnabled) 
+   {
+      i810ContextPtr imesa = I810_CONTEXT(ctx);
 
+      FLUSH_BATCH( imesa );
+   
+      if (opcode == GL_COPY)
+	 imesa->Fallback &= ~I810_FALLBACK_LOGICOP;
+      else
+	 imesa->Fallback |= I810_FALLBACK_LOGICOP;
+   }
+}
+
 static GLboolean i810DDSetDrawBuffer(GLcontext *ctx, GLenum mode )
 {
    i810ContextPtr imesa = I810_CONTEXT(ctx);
@@ -254,6 +268,7 @@
    if (mode == GL_FRONT_LEFT) 
    {
       imesa->drawMap = (char *)imesa->driScreen->pFB;
+      imesa->readMap = (char *)imesa->driScreen->pFB;
       imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->fbOffset | 
 					      imesa->i810Screen->backPitchBits);
       imesa->dirty |= I810_UPLOAD_BUFFERS;
@@ -263,6 +278,7 @@
    else if (mode == GL_BACK_LEFT) 
    {
       imesa->drawMap = imesa->i810Screen->back.map;
+      imesa->readMap = imesa->i810Screen->back.map;
       imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->backOffset | 
 					      imesa->i810Screen->backPitchBits);
       imesa->dirty |= I810_UPLOAD_BUFFERS;
@@ -352,6 +368,7 @@
    imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
    imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
    imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
+   imesa->vertex_prim = PR_TRIANGLES;
 
    switch (ctx->PB->primitive) {
    case GL_POLYGON:
@@ -366,12 +383,10 @@
 	 imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
       break;
    case GL_LINES:
-      imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_0_5;
-      if (ctx->Line.SmoothFlag) {
+      if (ctx->Line.SmoothFlag) 
 	 imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;  
-	 imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_0_5;
-      } 
       imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
+      imesa->vertex_prim = PR_LINES;
       break;
    case GL_POINTS:
       if (ctx->Point.SmoothFlag)
@@ -385,7 +400,22 @@
 }
 
 
+static void i810DDLineWidth( GLcontext *ctx, GLfloat widthf )
+{
+   i810ContextPtr imesa = I810_CONTEXT( ctx );
+   int width = (int)widthf;
+
+   if (width > 3) width = 3;
+   if (width < 1) width = 1;
+   
+   imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_3_0;
+
+   if (width & 1) imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_1_0;
+   if (width & 2) imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_2_0;
 
+   imesa->dirty |= I810_UPLOAD_CTX;
+}
+
 /* =============================================================
  * Color masks
  */
@@ -590,6 +620,13 @@
 	    imesa->Setup[I810_CTXREG_MT] |= MT_TEXEL1_ENABLE;
       }
       break;
+   case GL_COLOR_LOGIC_OP:
+   case GL_INDEX_LOGIC_OP:
+      FLUSH_BATCH( imesa );
+      imesa->Fallback &= ~I810_FALLBACK_LOGICOP;
+      if (state && ctx->Color.LogicOp != GL_COPY)
+	 imesa->Fallback |= I810_FALLBACK_LOGICOP;
+      break;
    default:
       ; 
    }    
@@ -713,11 +750,7 @@
 
    memset(imesa->Setup, 0, sizeof(imesa->Setup));
 
-   imesa->Setup[I810_CTXREG_VF] = (GFX_OP_VERTEX_FMT |
-				   VF_TEXCOORD_COUNT_2 |
-				   VF_SPEC_FOG_ENABLE |
-				   VF_RGBA_ENABLE |
-				   VF_XYZW);
+   imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0;
 
    imesa->Setup[I810_CTXREG_MT] = (GFX_OP_MAP_TEXELS |
 				   MT_UPDATE_TEXEL1_STATE |
@@ -925,20 +958,16 @@
 
    if (imesa->glCtx->Color.DriverDrawBuffer == GL_BACK_LEFT) {
       imesa->drawMap = i810Screen->back.map;
+      imesa->readMap = i810Screen->back.map;
       imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->backOffset | 
 					      i810Screen->backPitchBits);
    } else {
       imesa->drawMap = (char *)imesa->driScreen->pFB;
+      imesa->readMap = (char *)imesa->driScreen->pFB;
       imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->fbOffset | 
 					      i810Screen->backPitchBits);
    }
 
-   if (imesa->glCtx->Color.DriverDrawBuffer == GL_BACK_LEFT) {
-      imesa->readMap = i810Screen->back.map;
-   } else {
-      imesa->readMap = (char *)imesa->driScreen->pFB;
-   }
-
    imesa->BufferSetup[I810_DESTREG_DV0] = GFX_OP_DESTBUFFER_VARS;
    imesa->BufferSetup[I810_DESTREG_DV1] = (DV_HORG_BIAS_OGL |
 					   DV_VORG_BIAS_OGL |
@@ -1006,6 +1035,8 @@
    ctx->Driver.RenderFinish = 0; 
    ctx->Driver.PolygonStipple = i810DDPolygonStipple;
    ctx->Driver.LineStipple = 0;
+   ctx->Driver.LineWidth = i810DDLineWidth;
+   ctx->Driver.LogicOpcode = i810DDLogicOp;
    ctx->Driver.SetReadBuffer = i810DDSetReadBuffer;
    ctx->Driver.SetDrawBuffer = i810DDSetDrawBuffer;
    ctx->Driver.Color = i810DDSetColor;
Index: xc/lib/GL/mesa/src/drv/i810/i810tex.c
diff -u xc/lib/GL/mesa/src/drv/i810/i810tex.c:1.3 xc/lib/GL/mesa/src/drv/i810/i810tex.c:1.4
--- xc/lib/GL/mesa/src/drv/i810/i810tex.c:1.3	Tue Jun 20 01:08:40 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810tex.c	Wed Nov  8 00:02:43 2000
@@ -734,7 +734,7 @@
 				     MA_OP_ARG1 );
     
 
-   if (!(ctx->Texture.Enabled & 0xf) || !tObj || !tObj->Complete) {
+   if (!(ctx->Texture.ReallyEnabled & 0xf) || !tObj || !tObj->Complete) {
       return;
    }
 
@@ -977,7 +977,7 @@
 				     MA_UPDATE_OP |
 				     MA_OP_ARG1 );
 
-   if (!(ctx->Texture.Enabled & 0xf0) || !tObj || !tObj->Complete) {
+   if (!(ctx->Texture.ReallyEnabled & 0xf0) || !tObj || !tObj->Complete) {
       return;
    }
 
Index: xc/lib/GL/mesa/src/drv/i810/i810tris.c
diff -u xc/lib/GL/mesa/src/drv/i810/i810tris.c:1.2 xc/lib/GL/mesa/src/drv/i810/i810tris.c:1.5
--- xc/lib/GL/mesa/src/drv/i810/i810tris.c:1.2	Fri Jun 16 20:03:00 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810tris.c	Sun Sep 24 09:51:04 2000
@@ -22,6 +22,7 @@
  *
  *
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tris.c,v 1.5 2000/09/24 13:51:04 alanh Exp $ */
 
 #include <stdio.h>
 #include <math.h>
@@ -44,14 +45,11 @@
   (to)[3] = (from)[3];				\
 }
 
+static triangle_func tri_tab[0x10];   
+static quad_func     quad_tab[0x10];  
+static line_func     line_tab[0x10];  
+static points_func   points_tab[0x10];
 
-
-static triangle_func tri_tab[0x20];   
-static quad_func     quad_tab[0x20];  
-static line_func     line_tab[0x20];  
-static points_func   points_tab[0x20];
-
-
 #define IND (0)
 #define TAG(x) x
 #include "i810tritmp.h"
@@ -60,30 +58,32 @@
 #define TAG(x) x##_flat
 #include "i810tritmp.h"
 
-#define IND (I810_OFFSET_BIT)	/* wide */
+#define IND (I810_OFFSET_BIT)	
 #define TAG(x) x##_offset
 #include "i810tritmp.h"
 
-#define IND (I810_OFFSET_BIT|I810_FLAT_BIT) /* wide|flat */
+#define IND (I810_OFFSET_BIT|I810_FLAT_BIT) 
 #define TAG(x) x##_offset_flat
 #include "i810tritmp.h"
 
-#define IND (I810_TWOSIDE_BIT)	/* stipple */
+#define IND (I810_TWOSIDE_BIT)	
 #define TAG(x) x##_twoside
 #include "i810tritmp.h"
 
-#define IND (I810_TWOSIDE_BIT|I810_FLAT_BIT) /* stipple|flat */
+#define IND (I810_TWOSIDE_BIT|I810_FLAT_BIT) 
 #define TAG(x) x##_twoside_flat
 #include "i810tritmp.h"
 
-#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT) /* stipple|wide */
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT) 
 #define TAG(x) x##_twoside_offset
 #include "i810tritmp.h"
 
-#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_FLAT_BIT) /* stip|wide|flat*/
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_FLAT_BIT) 
 #define TAG(x) x##_twoside_offset_flat
 #include "i810tritmp.h"
 
+
+
 void i810DDTrifuncInit()
 {
    init();
@@ -98,62 +98,68 @@
 
 
 
+#define ALL_FALLBACK (DD_MULTIDRAW | DD_SELECT | DD_FEEDBACK | DD_STENCIL)
+#define POINT_FALLBACK (ALL_FALLBACK)
+#define LINE_FALLBACK (ALL_FALLBACK | DD_LINE_STIPPLE)
+#define TRI_FALLBACK (ALL_FALLBACK | DD_TRI_UNFILLED)
+#define ANY_FALLBACK (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|DD_TRI_STIPPLE)
+#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET)
 
-void i810DDChooseRenderState( GLcontext *ctx )
+void i810DDChooseRenderState(GLcontext *ctx)
 {
-   i810ContextPtr imesa = I810_CONTEXT( ctx );
-   GLuint flags = ctx->TriangleCaps;
-
-   imesa->IndirectTriangles = 0;
-
-   if (flags) {
-      GLuint ind = 0;
-      GLuint shared = 0;
-
-      if (flags & DD_FLATSHADE)                    shared |= I810_FLAT_BIT;
-      if (flags & DD_MULTIDRAW)                    shared |= I810_FALLBACK_BIT;
-      if (flags & DD_SELECT)                       shared |= I810_FALLBACK_BIT;
-      if (flags & DD_FEEDBACK)                     shared |= I810_FALLBACK_BIT;
-      if (flags & DD_STENCIL)                      shared |= I810_FALLBACK_BIT;
-
-      imesa->renderindex = shared;
-      imesa->PointsFunc = points_tab[shared]; 
-
-      ind = shared;
-      if (flags & DD_LINE_WIDTH)                    ind |= I810_WIDE_LINE_BIT;
-      if (flags & DD_LINE_STIPPLE)                  ind |= I810_FALLBACK_BIT;
-
-      imesa->renderindex |= ind;
-      imesa->LineFunc = line_tab[ind];
-      if (ind & I810_FALLBACK_BIT) 
-	 imesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
-
-      ind = shared;
-      if (flags & DD_TRI_OFFSET)                    ind |= I810_OFFSET_BIT;
-      if (flags & DD_TRI_LIGHT_TWOSIDE)             ind |= I810_TWOSIDE_BIT;
-      if (flags & DD_TRI_UNFILLED)                  ind |= I810_FALLBACK_BIT;
-      if ((flags & DD_TRI_STIPPLE) &&
-	  (ctx->IndirectTriangles & DD_TRI_STIPPLE)) ind |= I810_FALLBACK_BIT;	
-
-      imesa->renderindex |= ind;
-      imesa->TriangleFunc = tri_tab[ind];
-      imesa->QuadFunc = quad_tab[ind];
-      if (ind & I810_FALLBACK_BIT)
-	 imesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE);
-   } 
-   else if (imesa->renderindex)
-   {
-      imesa->renderindex  = 0;
-      imesa->PointsFunc   = points_tab[0]; 
-      imesa->LineFunc     = line_tab[0];
-      imesa->TriangleFunc = tri_tab[0];
-      imesa->QuadFunc     = quad_tab[0];
-   }
-
-
-   if (I810_DEBUG&DEBUG_VERBOSE_API) {
-      gl_print_tri_caps("tricaps", ctx->TriangleCaps);
-   }
+    i810ContextPtr imesa = I810_CONTEXT(ctx);
+    GLuint         flags   = ctx->TriangleCaps;
+    CARD32 index    = 0;
+
+    if (imesa->Fallback) {
+	imesa->renderindex = I810_FALLBACK_BIT;
+	return;
+    }
+    
+    if (flags & ANY_RASTER_FLAGS) {
+	if (flags & DD_FLATSHADE)               index |= I810_FLAT_BIT;
+	if (flags & DD_TRI_LIGHT_TWOSIDE)       index |= I810_TWOSIDE_BIT;
+	if (flags & DD_TRI_OFFSET)              index |= I810_OFFSET_BIT; 
+    }
+	
+    imesa->PointsFunc = points_tab[index];
+    imesa->LineFunc = line_tab[index];
+    imesa->TriangleFunc = tri_tab[index];
+    imesa->QuadFunc = quad_tab[index];
+    imesa->renderindex = index;
+    imesa->IndirectTriangles = 0;
+
+    if (flags & ANY_FALLBACK) {
+	if (flags & POINT_FALLBACK) {
+	    imesa->renderindex |= I810_FALLBACK_BIT;
+	    imesa->PointsFunc = 0;
+	    imesa->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
+	}
+	    
+	if (flags & LINE_FALLBACK) {
+	    imesa->renderindex |= I810_FALLBACK_BIT;
+	    imesa->LineFunc = 0;
+	    imesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
+	}
+
+	if (flags & TRI_FALLBACK) {
+	    imesa->renderindex |= I810_FALLBACK_BIT;
+	    imesa->TriangleFunc = 0;
+	    imesa->QuadFunc = 0;
+	    imesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
+					 DD_QUAD_SW_RASTERIZE);
+	}
+	/* Special cases:
+	 */
+	if ((flags & DD_TRI_STIPPLE) &&
+	    (ctx->IndirectTriangles & DD_TRI_STIPPLE)) {
+	    imesa->renderindex |= I810_FALLBACK_BIT;
+	    imesa->TriangleFunc = 0;
+	    imesa->QuadFunc = 0;
+	    imesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
+					 DD_QUAD_SW_RASTERIZE);
+	}
+    }
 }
 
 
Index: xc/lib/GL/mesa/src/drv/i810/i810tris.h
diff -u xc/lib/GL/mesa/src/drv/i810/i810tris.h:1.2 xc/lib/GL/mesa/src/drv/i810/i810tris.h:1.8
--- xc/lib/GL/mesa/src/drv/i810/i810tris.h:1.2	Fri Jun 16 20:03:00 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810tris.h	Mon Dec  4 14:21:43 2000
@@ -15,165 +15,143 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  *
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tris.h,v 1.8 2000/12/04 19:21:43 dawes Exp $ */
 
 #ifndef I810TRIS_INC
 #define I810TRIS_INC
 
 #include "types.h"
 #include "i810ioctl.h"
+#include "i810vb.h"
 
 extern void i810PrintRenderState( const char *msg, GLuint state );
 extern void i810DDChooseRenderState(GLcontext *ctx);
 extern void i810DDTrifuncInit( void );
 
 
-/* shared */
 #define I810_FLAT_BIT 	     0x1
-
-/* triangle */
-#define I810_OFFSET_BIT	     0x2	
+#define I810_OFFSET_BIT	     0x2
 #define I810_TWOSIDE_BIT     0x4
+#define I810_FALLBACK_BIT    0x8
 
-/* line */
-#define I810_WIDE_LINE_BIT    0x2 
-#define I810_STIPPLE_LINE_BIT 0x4 
-
-/* shared */
-#define I810_FALLBACK_BIT    0x8 
-
-
-
-
-
-static i810_vertex __inline__ *i810AllocTriangles( i810ContextPtr imesa, int nr)
-{
-   GLuint *start = i810AllocDwords( imesa, 30*nr, PR_TRIANGLES );
-   return (i810_vertex *)start;
-}
-
-static i810_vertex __inline__ *i810AllocLine( i810ContextPtr imesa ) 
-{
-   GLuint *start = i810AllocDwords( imesa, 20, PR_LINES );
-   return (i810_vertex *)start;
-}
-
-static i810_vertex __inline__ *i810AllocRect( i810ContextPtr imesa ) 
-{
-   GLuint *start = i810AllocDwords( imesa, 30, PR_RECTS );
-   return (i810_vertex *)start;
-}
 
 
 
 static void __inline__ i810_draw_triangle( i810ContextPtr imesa,
-					   i810_vertex *v0, 
-					   i810_vertex *v1, 
-					   i810_vertex *v2 )
-{
-   i810_vertex *wv = i810AllocTriangles( imesa, 1 );
-   wv[0] = *v0;
-   wv[1] = *v1;
-   wv[2] = *v2;
+					   i810VertexPtr v0,
+					   i810VertexPtr v1,
+					   i810VertexPtr v2 )
+{
+   GLuint vertsize = imesa->vertsize;
+   GLuint *vb = i810AllocDwordsInline( imesa, 3 * vertsize );
+   int j;
+
+#if defined(USE_X86_ASM)
+    __asm__ __volatile__( "rep ; movsl"
+			  : "=%c" (j)
+			  : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
+			  : "memory" );
+    __asm__ __volatile__( "rep ; movsl"
+			  : "=%c" (j)
+			  : "0" (vertsize), "S" ((long)v1)
+			  : "memory" );
+    __asm__ __volatile__( "rep ; movsl"
+			  : "=%c" (j)
+			  : "0" (vertsize), "S" ((long)v2)
+			  : "memory" );
+#else
+   for (j = 0 ; j < vertsize ; j++)
+      vb[j] = v0->ui[j];
+
+   vb += vertsize;
+   for (j = 0 ; j < vertsize ; j++)
+      vb[j] = v1->ui[j];
+
+   vb += vertsize;
+   for (j = 0 ; j < vertsize ; j++)
+      vb[j] = v2->ui[j];
+#endif
 }
 
 
 static __inline__ void i810_draw_point( i810ContextPtr imesa,
-					i810_vertex *tmp, float sz )
-{
-   i810_vertex *wv = i810AllocTriangles( imesa, 2 );
-
-   wv[0] = *tmp;
-   wv[0].x = tmp->x - sz;
-   wv[0].y = tmp->y - sz;
-
-   wv[1] = *tmp;
-   wv[1].x = tmp->x + sz;
-   wv[1].y = tmp->y - sz;
-
-   wv[2] = *tmp;
-   wv[2].x = tmp->x + sz;
-   wv[2].y = tmp->y + sz;
-
-   wv[3] = *tmp;
-   wv[3].x = tmp->x + sz;
-   wv[3].y = tmp->y + sz;
-
-   wv[4] = *tmp;
-   wv[4].x = tmp->x - sz;
-   wv[4].y = tmp->y + sz;
-
-   wv[5] = *tmp;
-   wv[5].x = tmp->x - sz;
-   wv[5].y = tmp->y - sz;
-
-}
-
-
-static __inline__ void i810_draw_line_line( i810ContextPtr imesa, 
-					    i810_vertex *tmp0, 
-					    i810_vertex *tmp1 )
-{
-   i810_vertex *wv = i810AllocLine( imesa );
-   wv[0] = *tmp0;
-   wv[1] = *tmp1;
-}
-
-static __inline__ void i810_draw_tri_line( i810ContextPtr imesa, 
-					   i810_vertex *tmp0, 
-					   i810_vertex *tmp1,
-					   float width )
+					i810VertexPtr tmp,
+					float sz )
 {
-   i810_vertex *wv = i810AllocTriangles( imesa, 2 );
-      
-   float dx, dy, ix, iy;
-
-   dx = tmp0->x - tmp1->x;
-   dy = tmp0->y - tmp1->y;
-
-   ix = width * .5; iy = 0;
-   if (dx * dx > dy * dy) {
-      iy = ix; ix = 0;
-   }
-
-   wv[0] = *tmp0;
-   wv[0].x = tmp0->x - ix;
-   wv[0].y = tmp0->y - iy;
-
-   wv[1] = *tmp1;
-   wv[1].x = tmp1->x + ix;
-   wv[1].y = tmp1->y + iy;
-
-   wv[2] = *tmp0;
-   wv[2].x = tmp0->x + ix;
-   wv[2].y = tmp0->y + iy;
-	 
-   wv[3] = *tmp0;
-   wv[3].x = tmp0->x - ix;
-   wv[3].y = tmp0->y - iy;
-
-   wv[4] = *tmp1;
-   wv[4].x = tmp1->x - ix;
-   wv[4].y = tmp1->y - iy;
-
-   wv[5] = *tmp1;
-   wv[5].x = tmp1->x + ix;
-   wv[5].y = tmp1->y + iy;
+   int vertsize = imesa->vertsize;
+   GLuint *vb = i810AllocDwordsInline( imesa, 6 * vertsize );
+   int j;
+
+   *(float *)&vb[0] = tmp->v.x - sz;
+   *(float *)&vb[1] = tmp->v.y - sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x + sz;
+   *(float *)&vb[1] = tmp->v.y - sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x + sz;
+   *(float *)&vb[1] = tmp->v.y + sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x + sz;
+   *(float *)&vb[1] = tmp->v.y + sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x - sz;
+   *(float *)&vb[1] = tmp->v.y + sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x - sz;
+   *(float *)&vb[1] = tmp->v.y - sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+}
+
+
+static __inline__ void i810_draw_line( i810ContextPtr imesa,
+				       i810VertexPtr v0,
+				       i810VertexPtr v1 )
+{
+   GLuint vertsize = imesa->vertsize;
+   GLuint *vb = i810AllocDwordsInline( imesa, 2 * vertsize );
+   int j;
+
+#if defined(USE_X86_ASM)
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
+			 : "memory" );
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "S" ((long)v1)
+			 : "memory" );
+#else
+   for (j = 0 ; j < vertsize ; j++)
+      vb[j] = v0->ui[j];
+
+   vb += vertsize;
+   for (j = 0 ; j < vertsize ; j++)
+      vb[j] = v1->ui[j];
+#endif
 }
 
-
-static __inline__ void i810_draw_line( i810ContextPtr imesa, 
-				       i810_vertex *tmp0, 
-				       i810_vertex *tmp1,
-				       float width )
-{
-   i810_draw_line_line( imesa, tmp0, tmp1 );
-}
 
 #endif
Index: xc/lib/GL/mesa/src/drv/i810/i810tritmp.h
diff -u xc/lib/GL/mesa/src/drv/i810/i810tritmp.h:1.2 xc/lib/GL/mesa/src/drv/i810/i810tritmp.h:1.5
--- xc/lib/GL/mesa/src/drv/i810/i810tritmp.h:1.2	Fri Jun 16 20:03:00 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810tritmp.h	Tue Dec  5 16:18:33 2000
@@ -1,96 +1,104 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tritmp.h,v 1.5 2000/12/05 21:18:33 dawes Exp $ */
 
-static __inline__ void TAG(triangle)( GLcontext *ctx, GLuint e0,
-				      GLuint e1, GLuint e2, GLuint pv )
+static __inline void TAG(triangle)(GLcontext *ctx,
+				   GLuint e0, GLuint e1, GLuint e2,
+				   GLuint pv)
 {
-   i810ContextPtr imesa = I810_CONTEXT(ctx);
-   struct vertex_buffer *VB = ctx->VB;
-   i810VertexPtr i810VB = I810_DRIVER_DATA(VB)->verts;
-   const i810_vertex *v0 = &i810VB[e0].v;  
-   const i810_vertex *v1 = &i810VB[e1].v;  
-   const i810_vertex *v2 = &i810VB[e2].v;  
+   i810ContextPtr        i810ctx   = I810_CONTEXT(ctx);
+   struct vertex_buffer *VB        = ctx->VB;
+   i810VertexPtr         i810verts = I810_DRIVER_DATA(VB)->verts;
+   i810Vertex     *v[3];
 
 #if (IND & I810_OFFSET_BIT)
-   GLfloat offset = ctx->Polygon.OffsetUnits * 1.0/0x10000;
+   GLfloat offset;
+   GLfloat z[3];
 #endif
 
-#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
-   int c0 = *(int *)&i810VB[pv].v.color; 
-   int c1 = c0;
-   int c2 = c0;
+#if (IND & (I810_TWOSIDE_BIT | I810_FLAT_BIT))
+   GLuint c[3];
 #endif
 
+   v[0] = &i810verts[e0];
+   v[1] = &i810verts[e1];
+   v[2] = &i810verts[e2];
+
+#if (IND & (I810_TWOSIDE_BIT | I810_FLAT_BIT))
+   c[0] = v[0]->ui[4];
+   c[1] = v[1]->ui[4];
+   c[2] = v[2]->ui[4];
+#endif
 
-#if (IND & (I810_TWOSIDE_BIT|I810_OFFSET_BIT)) 
+
+#if (IND & (I810_TWOSIDE_BIT | I810_OFFSET_BIT))
    {
-      GLfloat ex = v0->x - v2->x;
-      GLfloat ey = v0->y - v2->y;
-      GLfloat fx = v1->x - v2->x;
-      GLfloat fy = v1->y - v2->y;
-      GLfloat c = ex*fy-ey*fx;
-	 
-#if (IND & I810_TWOSIDE_BIT) 
+      GLfloat ex = v[0]->v.x - v[2]->v.x;
+      GLfloat ey = v[0]->v.y - v[2]->v.y;
+      GLfloat fx = v[1]->v.x - v[2]->v.x;
+      GLfloat fy = v[1]->v.y - v[2]->v.y;
+      GLfloat cc  = ex*fy - ey*fx;
+
+#if (IND & I810_TWOSIDE_BIT)
       {
-	 GLuint facing = (c>0.0) ^ ctx->Polygon.FrontBit;
+	 GLuint  facing        = (cc > 0.0) ^ ctx->Polygon.FrontBit;
 	 GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
 	 if (IND & I810_FLAT_BIT) {
-	    I810_COLOR((char *)&c0,vbcolor[pv]);
-	    c2 = c1 = c0;
+	    I810_COLOR((char *)&v[0]->ui[4], vbcolor[pv]);
+	    v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
 	 } else {
-	    I810_COLOR((char *)&c0,vbcolor[e0]);
-	    I810_COLOR((char *)&c1,vbcolor[e1]);
-	    I810_COLOR((char *)&c2,vbcolor[e2]);
+	    I810_COLOR((char *)&v[0]->ui[4], vbcolor[e0]);
+	    I810_COLOR((char *)&v[1]->ui[4], vbcolor[e1]);
+	    I810_COLOR((char *)&v[2]->ui[4], vbcolor[e2]);
 	 }
       }
 #endif
-      
-#if (IND & I810_OFFSET_BIT) 
+
+#if (IND & I810_OFFSET_BIT)
       {
-	 if (c * c > 1e-16) {
-	    GLfloat factor = ctx->Polygon.OffsetFactor;
-	    GLfloat ez = v0->z - v2->z;
-	    GLfloat fz = v1->z - v2->z;
-	    GLfloat a = ey*fz-ez*fy;
-	    GLfloat b = ez*fx-ex*fz;
-	    GLfloat ic = 1.0 / c;
-	    GLfloat ac = a * ic;
-	    GLfloat bc = b * ic;
-	    if (ac<0.0F)  ac = -ac;
-	    if (bc<0.0F)  bc = -bc;
-	    offset += MAX2( ac, bc ) * factor;
+	 offset = ctx->Polygon.OffsetUnits * 1.0/0x10000;
+	 z[0] = v[0]->v.z;
+	 z[1] = v[1]->v.z;
+	 z[2] = v[2]->v.z;
+	 if (cc * cc > 1e-16) {
+	    GLfloat ez     = z[0] - z[2];
+	    GLfloat fz     = z[1] - z[2];
+	    GLfloat a      = ey*fz - ez*fy;
+	    GLfloat b      = ez*fx - ex*fz;
+	    GLfloat ic     = 1.0 / cc;
+	    GLfloat ac     = a * ic;
+	    GLfloat bc     = b * ic;
+	    if (ac < 0.0f) ac = -ac;
+	    if (bc < 0.0f) bc = -bc;
+	    offset += MAX2(ac, bc) * ctx->Polygon.OffsetFactor;
 	 }
+	 v[0]->v.z += offset;
+	 v[1]->v.z += offset;
+	 v[2]->v.z += offset;
       }
 #endif
    }
-#endif  
-
-   
+#elif (IND & I810_FLAT_BIT)
    {
-      i810_vertex *wv = i810AllocTriangles( imesa, 1 );
-      wv[0] = *v0;
-#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
-      *((int *)(&wv[0].color)) = c0;
-#endif
-#if (IND & I810_OFFSET_BIT)
-      wv[0].z = v0->z + offset;
+      GLuint color = i810verts[pv].ui[4];
+      v[0]->ui[4] = color;
+      v[1]->ui[4] = color;
+      v[2]->ui[4] = color;
+   }
 #endif
 
+   i810_draw_triangle( i810ctx, v[0], v[1], v[2] );
 
-      wv[1] = *v1;
-#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
-      *((int *)(&wv[1].color)) = c1;
-#endif
 #if (IND & I810_OFFSET_BIT)
-      wv[1].z = v1->z + offset;
+   v[0]->v.z = z[0];
+   v[1]->v.z = z[1];
+   v[2]->v.z = z[2];
 #endif
 
-      wv[2] = *v2;
-#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
-      *((int *)(&wv[2].color)) = c2;
-#endif
-#if (IND & I810_OFFSET_BIT)
-      wv[2].z = v2->z + offset;
+#if (IND & (I810_FLAT_BIT | I810_TWOSIDE_BIT))
+   v[0]->ui[4] = c[0];
+   v[1]->ui[4] = c[1];
+   v[2]->ui[4] = c[2];    
 #endif
-   }
+
 }
 
 
@@ -106,31 +114,39 @@
 {
    i810ContextPtr imesa = I810_CONTEXT( ctx );
    i810VertexPtr i810VB = I810_DRIVER_DATA(ctx->VB)->verts;
-   int tmp0, tmp1;
-   (void) tmp0; (void) tmp1;
 
+#if (IND & (I810_TWOSIDE_BIT|I810_FLAT_BIT|I810_OFFSET_BIT)) 
+   i810Vertex tmp0 = i810VB[v0];
+   i810Vertex tmp1 = i810VB[v1];
+
+   if (IND & I810_TWOSIDE_BIT) {
+      GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
+
+      if (IND & I810_FLAT_BIT) {
+	 I810_COLOR((char *)&tmp0.v.color,vbcolor[pv]);
+	 *(int *)&tmp1.v.color = *(int *)&tmp0.v.color;
+      } else {
+	 I810_COLOR((char *)&tmp0.v.color,vbcolor[v0]);
+	 I810_COLOR((char *)&tmp1.v.color,vbcolor[v1]);
+      }
 
-   if (IND & I810_FLAT_BIT) {
-      tmp0 = *(int *)&i810VB[v0].v.color;
-      tmp1 = *(int *)&i810VB[v1].v.color;
-      i810VB[v0].v.color = i810VB[pv].v.color;
-      i810VB[v1].v.color = i810VB[pv].v.color;
-   }      
+   } else if (IND & I810_FLAT_BIT) {
+      *(int *)&tmp0.v.color = *(int *)&i810VB[pv].v.color;
+      *(int *)&tmp1.v.color = *(int *)&i810VB[pv].v.color;
+   }
 
-   if (IND & I810_WIDE_LINE_BIT)
-   {
-      i810_draw_tri_line( imesa, &i810VB[v0].v, &i810VB[v1].v, 
-			  ctx->Line.Width );
-   } 
-   else 
-   {
-      i810_draw_line_line( imesa, &i810VB[v0].v, &i810VB[v1].v );
-   }      
+   /* Relies on precomputed LineZoffset from vbrender.c
+    */
+   if (IND & I810_OFFSET_BIT) {
+      GLfloat offset = ctx->LineZoffset * (1.0 / 0x10000); 
+      tmp0.v.z += offset;
+      tmp1.v.z += offset;
+   }
 
-   if (IND & I810_FLAT_BIT) {
-      *(int *)&i810VB[v0].v.color = tmp0;
-      *(int *)&i810VB[v1].v.color = tmp1;
-   }      
+   i810_draw_line( imesa, &tmp0, &tmp1 );
+#else
+   i810_draw_line( imesa, &i810VB[v0], &i810VB[v1] );
+#endif
 }
 
 
@@ -146,10 +162,21 @@
     * ctx->Driver.ReducedPrimitiveChange() callback.  
     */
    
-   for(i=first;i<=last;i++) {
+   for(i=first;i<last;i++) {
       if(VB->ClipMask[i]==0) {
-	 i810_vertex *tmp = &i810VB[i].v;
-	 i810_draw_point( imesa, tmp, sz );
+	 if (IND & I810_TWOSIDE_BIT) {	
+	    i810Vertex tmp0 = i810VB[i];
+	    if (IND & I810_TWOSIDE_BIT) {
+	       GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
+	       I810_COLOR((char *)&tmp0.v.color, vbcolor[i]);
+	    }
+	    if (IND & I810_OFFSET_BIT) {
+	       GLfloat offset = ctx->PointZoffset * (1.0 / 0x10000);
+	       tmp0.v.z += offset;
+	    }
+	    i810_draw_point( imesa, &tmp0, sz );
+	 } else
+	    i810_draw_point( imesa, &i810VB[i], sz );
       }
    }
 }
Index: xc/lib/GL/mesa/src/drv/i810/i810vb.c
diff -u xc/lib/GL/mesa/src/drv/i810/i810vb.c:1.3 xc/lib/GL/mesa/src/drv/i810/i810vb.c:1.7
--- xc/lib/GL/mesa/src/drv/i810/i810vb.c:1.3	Tue Jun 20 01:08:40 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810vb.c	Wed Nov  8 00:02:43 2000
@@ -22,15 +22,16 @@
  *
  *
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810vb.c,v 1.7 2000/11/08 05:02:43 dawes Exp $ */
  
+#include <stdio.h>
+#include <stdlib.h>
 #include "i810context.h"
 #include "i810vb.h"
 #include "i810log.h"
-
+#include "mem.h"
 #include "stages.h"
 
-#include <stdio.h>
-#include <stdlib.h>
 
 
 #define TEX0 {					\
@@ -261,16 +262,17 @@
   i810ContextPtr imesa = I810_CONTEXT( ctx );
   int funcindex = (I810_WIN_BIT | I810_RGBA_BIT);
 
-  if (ctx->Texture.Enabled & 0xf) {
-      /* This doesn't work for non-RGBA textures
-      if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
-	 funcindex &= ~I810_RGBA_BIT;
-      */
-     funcindex |= I810_TEX0_BIT;
-  }
+  imesa->vertsize = 8;
+  imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0;
 
-  if (ctx->Texture.Enabled & 0xf0)
+  if (ctx->Texture.ReallyEnabled & 0xf) 
+     funcindex |= I810_TEX0_BIT;
+  
+  if (ctx->Texture.ReallyEnabled & 0xf0) {
      funcindex |= I810_TEX1_BIT;
+     imesa->vertsize = 10;
+     imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0T1;
+  }
 
   if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
      funcindex |= I810_SPEC_BIT;
@@ -385,8 +387,8 @@
       exit(1);
    }
 
-   free( VB->ClipMask );
-   VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
+   ALIGN_FREE( VB->ClipMask );
+   VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4);
    if (!VB->ClipMask) {
       fprintf(stderr, "i810-glx: out of memory !\n");
       exit(1);
@@ -427,8 +429,8 @@
       exit(1);
    }
       
-   free( VB->ClipMask );
-   VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
+   ALIGN_FREE( VB->ClipMask );
+   VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4);
    if (!VB->ClipMask) {
       fprintf(stderr, "i810-glx: out of memory !\n");
       exit(1);
Index: xc/lib/GL/mesa/src/drv/i810/i810vb.h
diff -u xc/lib/GL/mesa/src/drv/i810/i810vb.h:1.1 xc/lib/GL/mesa/src/drv/i810/i810vb.h:1.3
--- xc/lib/GL/mesa/src/drv/i810/i810vb.h:1.1	Fri Feb 11 12:25:34 2000
+++ xc/lib/GL/mesa/src/drv/i810/i810vb.h	Sun Aug 27 22:43:12 2000
@@ -22,6 +22,7 @@
  *
  *
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810vb.h,v 1.3 2000/08/28 02:43:12 tsi Exp $ */
 
 #ifndef I810VB_INC
 #define I810VB_INC
@@ -60,6 +61,7 @@
 union i810_vertex_t {
    i810_vertex v;
    float f[16];
+   GLuint ui[16];
 };
 
 typedef union i810_vertex_t i810Vertex;
Index: xc/lib/GL/mesa/src/drv/mga/Imakefile
diff -u xc/lib/GL/mesa/src/drv/mga/Imakefile:1.6 xc/lib/GL/mesa/src/drv/mga/Imakefile:1.13
--- xc/lib/GL/mesa/src/drv/mga/Imakefile:1.6	Fri Jun 30 13:15:08 2000
+++ xc/lib/GL/mesa/src/drv/mga/Imakefile	Tue Dec 12 18:24:28 2000
@@ -1,3 +1,4 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/mga/Imakefile,v 1.13 2000/12/12 23:24:28 dawes Exp $
 
 #include <Threads.tmpl>
 
@@ -11,22 +12,19 @@
 ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
 #endif
 
-#if defined(LinuxArchitecture)
-OS_SUBDIR = linux
+#ifdef i386Architecture
+#if MesaUseMMX
+     MMX_DEFS = -DUSE_MMX_ASM
 #endif
-#if defined(FreeBSDArchitecture) || defined(BSDOSArchitecture)
-OS_SUBDIR = bsd
+#if MesaUse3DNow
+   3DNOW_DEFS = -DUSE_3DNOW_ASM
 #endif
-
-#ifdef i386Architecture
-#ifdef MesaUse3DNow
-     ASM_DEFS = -DUSE_MMX_ASM -DUSE_X86_ASM -DUSE_3DNOW_ASM
-#else
-     ASM_DEFS = -DUSE_MMX_ASM -DUSE_X86_ASM
+#if MesaUseKatmai
+  KATMAI_DEFS = -DUSE_KATMAI_ASM
 #endif
+  ASM_DEFINES = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(KATMAI_DEFS)
 #endif
 
-
 #if BuildXF86DRI
   DRI_DEFINES = GlxDefines -DDRIVERTS
  DRI_INCLUDES = -I../../../../dri -I../../../../glx \
@@ -34,24 +32,14 @@
 		-I$(TOP)/include -I$(TOP)/include/GL \
 		-I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
 		-I$(XF86DRIVERSRC)/mga \
-		-I../../../include -I../.. -I../../X -I../common \
-	        -I$(XF86OSSRC)/$(OS_SUBDIR)/drm/kernel
+		-I../../../include -I../.. -I../../X -I../common
 #endif
-
-MESA_INCLUDES = -I. -I.. -I../../include
-
-
-
-      DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS)
-     INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) 
 
-#if 0
-	LOSRC = ../../../../lowpc.c
-	LOOBJ = ../../../../lowpc.o
+MESA_INCLUDES = -I. -I.. -I../../include \
+		-I../../../../dri/drm
 
-	HISRC = ../../../../highpc.c
-	HIOBJ = ../../../../highpc.o
-#endif
+      DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFINES)
+     INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
 
       DRISRCS = ../../../dri/dri_mesa.c \
 		../../../../dri/dri_tmm.c
@@ -68,19 +56,36 @@
 		../../../../dri/drm/xf86drmHash.o \
 		../../../../dri/drm/xf86drmRandom.o \
 		../../../../dri/drm/xf86drmSL.o
-
 
-      MGASRCS = mgaclear.c mgacnvtex.c mgadd.c \
-		mgafastpath.c mgaeltpath.c \
-		mgapipeline.c	\
-		mgaspan.c mgastate.c mgatex.c		\
-		mgatris.c mgavb.c mgaioctl.c mga_xmesa.c mgabuffers.c
-
-      MGAOBJS = mgaclear.o mgacnvtex.o mgadd.o \
-		mgafastpath.o mgaeltpath.o \
-		mgapipeline.o	\
-		mgaspan.o mgastate.o mgatex.o		\
-		mgatris.o mgavb.o mgaioctl.o mga_xmesa.o mgabuffers.o
+      MGASRCS = mgabuffers.c \
+		mgadd.c \
+		mgaeltpath.c \
+		mgafastpath.c \
+		mgaioctl.c \
+		mgapipeline.c \
+		mgaspan.c \
+		mgastate.c \
+		mgatex.c \
+		mgatexcnv.c \
+		mgatexmem.c \
+		mgatris.c \
+		mgavb.c \
+		mga_xmesa.c \
+
+      MGAOBJS = mgabuffers.o \
+		mgadd.o \
+		mgaeltpath.o \
+		mgafastpath.o \
+		mgaioctl.o \
+		mgapipeline.o \
+		mgaspan.o \
+		mgastate.o \
+		mgatex.o \
+		mgatexcnv.o \
+		mgatexmem.o \
+		mgatris.o \
+		mgavb.o \
+		mga_xmesa.o
 
      MESASRCS = ../../aatriangle.c \
 		../../accum.c \
@@ -231,25 +236,40 @@
 		../../zoom.o
 
 #ifdef i386Architecture
-     X86_SRCS = ../../X86/x86.c \
-		../../X86/x86a.S \
-		../../X86/common_x86.c \
-		../../X86/common_x86asm.S \
-		../../X86/vertex.S
-
-     X86_OBJS = ../../X86/x86.o \
-		../../X86/x86a.o \
-		../../X86/common_x86.o \
-		../../X86/common_x86asm.o \
-		../../X86/vertex.o
+     X86_SRCS = ../../X86/common_x86.c \
+		../../X86/common_x86_asm.S \
+		../../X86/x86.c \
+		../../X86/x86_cliptest.S \
+		../../X86/x86_vertex.S \
+		../../X86/x86_xform_masked2.S \
+		../../X86/x86_xform_masked3.S \
+		../../X86/x86_xform_masked4.S \
+		../../X86/x86_xform_raw2.S \
+		../../X86/x86_xform_raw3.S \
+		../../X86/x86_xform_raw4.S
+
+     X86_OBJS = ../../X86/common_x86.o \
+		../../X86/common_x86_asm.o \
+		../../X86/x86.o \
+		../../X86/x86_cliptest.o \
+		../../X86/x86_vertex.o \
+		../../X86/x86_xform_masked2.o \
+		../../X86/x86_xform_masked3.o \
+		../../X86/x86_xform_masked4.o \
+		../../X86/x86_xform_raw2.o \
+		../../X86/x86_xform_raw3.o \
+		../../X86/x86_xform_raw4.o
 
+#if MesaUseMMX
      MMX_SRCS = ../../X86/mmx_blend.S
 
      MMX_OBJS = ../../X86/mmx_blend.o
+#endif
 
-#ifdef MesaUse3DNow
+#if MesaUse3DNow
    3DNOW_SRCS = ../../X86/3dnow.c \
 		../../X86/3dnow_norm_raw.S \
+		../../X86/3dnow_vertex.S \
 		../../X86/3dnow_xform_masked1.S \
 		../../X86/3dnow_xform_masked2.S \
 		../../X86/3dnow_xform_masked3.S \
@@ -257,11 +277,11 @@
 		../../X86/3dnow_xform_raw1.S \
 		../../X86/3dnow_xform_raw2.S \
 		../../X86/3dnow_xform_raw3.S \
-		../../X86/3dnow_xform_raw4.S \
-		../../X86/vertex_3dnow.S
+		../../X86/3dnow_xform_raw4.S
 
    3DNOW_OBJS = ../../X86/3dnow.o \
 		../../X86/3dnow_norm_raw.o \
+		../../X86/3dnow_vertex.o \
 		../../X86/3dnow_xform_masked1.o \
 		../../X86/3dnow_xform_masked2.o \
 		../../X86/3dnow_xform_masked3.o \
@@ -269,22 +289,56 @@
 		../../X86/3dnow_xform_raw1.o \
 		../../X86/3dnow_xform_raw2.o \
 		../../X86/3dnow_xform_raw3.o \
-		../../X86/3dnow_xform_raw4.o \
-		../../X86/vertex_3dnow.o
+		../../X86/3dnow_xform_raw4.o
+#endif
 
+#if MesaUseKatmai
+  KATMAI_SRCS = ../../X86/katmai.c \
+		../../X86/katmai_norm_raw.S \
+		../../X86/katmai_vertex.S \
+		../../X86/katmai_xform_masked1.S \
+		../../X86/katmai_xform_masked2.S \
+		../../X86/katmai_xform_masked3.S \
+		../../X86/katmai_xform_masked4.S \
+		../../X86/katmai_xform_raw1.S \
+		../../X86/katmai_xform_raw2.S \
+		../../X86/katmai_xform_raw3.S \
+		../../X86/katmai_xform_raw4.S
+
+  KATMAI_OBJS = ../../X86/katmai.o \
+		../../X86/katmai_norm_raw.o \
+		../../X86/katmai_vertex.o \
+		../../X86/katmai_xform_masked1.o \
+		../../X86/katmai_xform_masked2.o \
+		../../X86/katmai_xform_masked3.o \
+		../../X86/katmai_xform_masked4.o \
+		../../X86/katmai_xform_raw1.o \
+		../../X86/katmai_xform_raw2.o \
+		../../X86/katmai_xform_raw3.o \
+		../../X86/katmai_xform_raw4.o
 #endif
 #endif
 
-      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
-      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+#ifdef GlxSoProf
+       LOSRCS = ../../../../lowpc.c
+       HISRCS = ../../../../highpc.c
+
+       LOOBJS = ../../../../lowpc.o
+       HIOBJS = ../../../../highpc.o
+#endif
+
+      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS)
+      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS)
+
+   COMMONSRCS = ../common/mm.c ../common/hwlog.c
+   COMMONOBJS = ../common/mm.o ../common/hwlog.o
+
+         SRCS = $(LOSRCS) $(DRISRCS) $(DRMSRCS) $(MESASRCS) \
+		$(ASMSRCS) $(COMMONSRCS) $(MGASRCS) $(HISRCS)
+         OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) \
+		$(ASMOBJS) $(COMMONOBJS) $(MGAOBJS) $(HIOBJS)
 
-      COMMONSRCS = ../common/mm.c ../common/hwlog.c
-      COMMONOBJS = ../common/mm.o ../common/hwlog.o
-
-         SRCS = $(LOWSRC) $(DRISRCS) $(DRMSRCS) $(MESASRCS) $(ASMSRCS) $(COMMONSRCS) $(MGASRCS) $(HISRC)
-         OBJS = $(LOWOBJ) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) $(COMMONOBJS) $(MGAOBJS) $(HIOBJ)
-
-REQUIREDLIBS += -lm
+REQUIREDLIBS += MathLibrary 
 #if !GlxBuiltInMga
 REQUIREDLIBS += -L../../../.. -lGL -L../../../../../X11 -lX11
 #endif
@@ -310,6 +364,12 @@
 ALL_DEPS = DONE
 SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
 InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _mga_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
 #endif
 
 DependTarget()
Index: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
diff -u xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c:1.4 xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c:1.8
--- xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c:1.4	Thu Jun 22 12:59:24 2000
+++ xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c	Thu Dec  7 15:26:06 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c,v 1.8 2000/12/07 20:26:06 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -24,7 +25,6 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c,v 1.4 2000/06/22 16:59:24 tsi Exp $ */
 
 /*
  * Authors:
@@ -44,12 +44,12 @@
 #include "matrix.h"
 #include "mmath.h"
 #include "simple_list.h"
+#include "mem.h"
 
 #include "mgadd.h"
 #include "mgastate.h"
 #include "mgatex.h"
 #include "mgaspan.h"
-#include "mgadepth.h"
 #include "mgatris.h"
 #include "mgapipeline.h"
 #include "mgabuffers.h"
@@ -77,7 +77,6 @@
 
 static mgaContextPtr      mgaCtx = 0;
 
-mgaGlx_t	mgaglx;
 
 /* These functions are accessed externally to the driver:
  *
@@ -100,6 +99,9 @@
    mgaScreenPrivate *mgaScreen;
    MGADRIPtr         serverInfo = (MGADRIPtr)sPriv->pDevPriv;
 
+   if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+      fprintf(stderr, "XMesaInitDriver\n");
+
    /* Check the DRI version */
    {
       int major, minor, patch;
@@ -124,27 +126,23 @@
    }
 
    /* Check that the DRM driver version is compatible */
-   if (sPriv->drmMajor != 1 ||
+   if (sPriv->drmMajor != 2 ||
        sPriv->drmMinor != 0 ||
        sPriv->drmPatch < 0) {
       char msg[1000];
-      sprintf(msg, "MGA DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
+      sprintf(msg, "MGA DRI driver expected DRM driver version 2.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
       __driMesaMessage(msg);
       return GL_FALSE;
    }
 
    /* Allocate the private area */
-   mgaScreen = (mgaScreenPrivate *)Xmalloc(sizeof(mgaScreenPrivate));
+   mgaScreen = (mgaScreenPrivate *)MALLOC(sizeof(mgaScreenPrivate));
    if (!mgaScreen)
       return GL_FALSE;
 
    mgaScreen->sPriv = sPriv;
    sPriv->private = (void *)mgaScreen;
 
-   /*
-   fprintf(stderr, "serverInfo->chipset: %d\n", serverInfo->chipset);
-   */
-
    if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
        serverInfo->chipset != MGA_CARD_TYPE_G400) {
       XFree(mgaScreen);
@@ -183,12 +181,6 @@
    mgaScreen->textureOffset[MGA_AGP_HEAP] = (serverInfo->agpTextureOffset |
 					     PDEA_pagpxfer_enable | 1);
 
-   /*
-   fprintf(stderr, "CARD texture size %x, granul %d --> %x\n", 
-	   serverInfo->textureSize, serverInfo->logTextureGranularity,
-	   1<<serverInfo->logTextureGranularity);
-   */
-
    mgaScreen->textureSize[MGA_CARD_HEAP] = serverInfo->textureSize;
    mgaScreen->textureSize[MGA_AGP_HEAP] = serverInfo->agpTextureSize;
 
@@ -209,13 +201,6 @@
     */
    mgaScreen->dmaOffset = serverInfo->agpBufferOffset;   
    
-   /*
-   fprintf(stderr, "\n\n\nbackOffset: %x pitch %x\n", 
-	   mgaScreen->backOffset,
-	   mgaScreen->backPitch);
-   */
-
-   mgaScreen->Attrib = MGA_PF_565;
    mgaScreen->bufs = drmMapBufs(sPriv->fd);
    if (!mgaScreen->bufs) {
       /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/
@@ -224,10 +209,6 @@
       return GL_FALSE;
    }
 
-   /* Other mgaglx stuff, too??
-    */
-   memset(&mgaglx, 0, sizeof(mgaglx));
-
    mgaDDFastPathInit();
    mgaDDEltPathInit();
    mgaDDTrifuncInit();
@@ -242,6 +223,10 @@
 void XMesaResetDriver(__DRIscreenPrivate *sPriv)
 {
    mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private;
+
+   if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+      fprintf(stderr, "XMesaResetDriver\n");
+
    /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/
    Xfree(mgaScreen);
    sPriv->private = NULL;
@@ -253,6 +238,9 @@
                             const XVisualInfo *visinfo,
                             const __GLXvisualConfig *config)
 {
+   if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+      fprintf(stderr, "XMesaCreateVisual\n");
+
    /* Drivers may change the args to _mesa_create_visual() in order to
     * setup special visuals.
     */
@@ -284,9 +272,11 @@
    mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private;
    drm_mga_sarea_t *saPriv=(drm_mga_sarea_t*)(((char*)sPriv->pSAREA)+
 					      sizeof(XF86DRISAREARec));
-   /*fprintf(stderr, "XMesaCreateContext\n");*/
+
+   if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+      fprintf(stderr, "XMesaCreateContext\n");
 
-   mmesa = (mgaContextPtr)Xcalloc(sizeof(mgaContext), 1);
+   mmesa = (mgaContextPtr)CALLOC(sizeof(mgaContext));
    if (!mmesa) {
       return GL_FALSE;
    }
@@ -312,6 +302,61 @@
       make_empty_list(&mmesa->TexObjList[i]);
    }
 
+   /* Set the maximum texture size small enough that we can guarentee
+    * that both texture units can bind a maximal texture and have them
+    * on the card at once.
+    */
+   { 
+      int nr = 2;
+
+      if (mgaScreen->chipset == MGA_CARD_TYPE_G200) 
+	 nr = 1;
+
+      if (mgaScreen->textureSize[0] < nr*1024*1024) {
+	 ctx->Const.MaxTextureLevels = 9;
+	 ctx->Const.MaxTextureSize = 1<<8;
+      } else if (mgaScreen->textureSize[0] < nr*4*1024*1024) {
+	 ctx->Const.MaxTextureLevels = 10;
+	 ctx->Const.MaxTextureSize = 1<<9;
+      } else {
+	 ctx->Const.MaxTextureLevels = 11;
+	 ctx->Const.MaxTextureSize = 1<<10;
+      }      
+   }
+
+   mmesa->hw_stencil = mesaVis->StencilBits && mesaVis->DepthBits == 24;
+
+/*     fprintf(stderr,  */
+/*  	   "mesaVis->DepthBits: %d " */
+/*  	   "mmesa->glCtx->Visual->DepthBits: %d " */
+/*  	   "mmesa->glCtx->Visual->DepthMax: %x\n",  */
+/*  	   mesaVis->DepthBits, */
+/*  	   ctx->Visual->DepthBits,  */
+/*  	   ctx->Visual->DepthMax); */
+
+   switch (mesaVis->DepthBits) {
+   case 16: 
+      mmesa->depth_scale = 1.0/(GLdouble)0xffff; 
+      mmesa->depth_clear_mask = ~0;
+      mmesa->ClearDepth = 0xffff;
+      break;
+   case 24: 
+      mmesa->depth_scale = 1.0/(GLdouble)0xffffff; 
+      if (mmesa->hw_stencil) {
+	 mmesa->depth_clear_mask = 0xffffff00;
+	 mmesa->stencil_clear_mask = 0x000000ff;
+      } else
+	 mmesa->depth_clear_mask = ~0;
+      mmesa->ClearDepth = 0xffffff00;
+      break; 
+   case 32: 
+      mmesa->depth_scale = 1.0/(GLdouble)0xffffffff; 
+      mmesa->depth_clear_mask = ~0;
+      mmesa->ClearDepth = 0xffffffff;
+      break;
+   };
+
+
    mmesa->renderindex = -1;		/* impossible value */
    mmesa->new_state = ~0;
    mmesa->dirty = ~0;
@@ -343,9 +388,6 @@
     */
    ctx->TriangleCaps |= DD_CLIP_FOG_COORD;
 
-   ctx->Shared->DefaultD[2][0].DriverData = 0;
-   ctx->Shared->DefaultD[2][1].DriverData = 0;
-
    if (ctx->VB) 
       mgaDDRegisterVB( ctx->VB );
 
@@ -365,18 +407,12 @@
 void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
 {
    mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
-
-   if (mmesa) {
-/*        mgaTextureObjectPtr next_t, t; */
-
-/*        foreach_s (t, next_t, &(mmesa->TexObjList)) */
-/*  	 mgaDestroyTexObj(mmesa, t); */
 
-/*        foreach_s (t, next_t, &(mmesa->SwappedOut)) */
-/*  	 mgaDestroyTexObj(mmesa, t); */
+   if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+      fprintf(stderr, "XMesaDestroyContext\n");
 
+   if (mmesa) {
       Xfree(mmesa);
-
       driContextPriv->driverPrivate = NULL;
    }
 }
@@ -387,6 +423,9 @@
                                         __DRIdrawablePrivate *driDrawPriv,
                                         GLvisual *mesaVis)
 {
+   if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+      fprintf(stderr, "XMesaCreateWindowBuffer\n");
+
    return gl_create_framebuffer(mesaVis,
                                 GL_FALSE,  /* software depth buffer? */
                                 mesaVis->StencilBits > 0,
@@ -435,7 +474,19 @@
    return GL_TRUE;
 }
 
+GLboolean
+XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
+}
+
+GLboolean
+XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
+}
 
+
 /* This looks buggy to me - the 'b' variable isn't used anywhere...
  * Hmm - It seems that the drawable is already hooked in to
  * driDrawablePriv.  
@@ -451,9 +502,11 @@
 
       gl_make_current2(mgaCtx->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer);
 
-      mgaCtx->driDrawable = driDrawPriv;
-      mgaCtx->dirty = ~0;
-      mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK);
+      if (mgaCtx->driDrawable != driDrawPriv) {
+	 mgaCtx->driDrawable = driDrawPriv;
+	 mgaCtx->dirty = ~0; 
+	 mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK); 
+      }
 
       if (!mgaCtx->glCtx->Viewport.Width)
 	 gl_Viewport(mgaCtx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h);
@@ -499,6 +552,7 @@
 
    sarea->last_quiescent = -1;	/* just kill it for now */
 }
+
 
 
 
Index: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
diff -u xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h:1.3 xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h:1.6
--- xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h:1.3	Fri Jun 16 20:03:01 2000
+++ xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h	Sun Sep 24 09:51:05 2000
@@ -24,6 +24,7 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h,v 1.6 2000/09/24 13:51:05 alanh Exp $ */
 
 /*
  * Authors:
@@ -49,7 +50,7 @@
    char *map;
 } mgaRegion, *mgaRegionPtr;
 
-typedef struct {
+typedef struct mga_screen_private_s {
 
    int chipset;
    int width;
@@ -58,7 +59,6 @@
 
    int cpp;			/* for front and back buffers */
 
-   int Attrib;
    unsigned int mAccess;
 
    unsigned int frontOffset;
@@ -88,7 +88,7 @@
 } mgaScreenPrivate;
 
 
-#include "mgalib.h"
+#include "mgacontext.h"
 
 extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags );
 extern void mgaEmitHwStateLocked( mgaContextPtr mmesa );
Index: xc/lib/GL/mesa/src/drv/mga/mgabuffers.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgabuffers.c:1.2 xc/lib/GL/mesa/src/drv/mga/mgabuffers.c:1.4
--- xc/lib/GL/mesa/src/drv/mga/mgabuffers.c:1.2	Thu Jun 22 12:59:24 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgabuffers.c	Sun Sep 24 09:51:05 2000
@@ -24,7 +24,7 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgabuffers.c,v 1.2 2000/06/22 16:59:24 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgabuffers.c,v 1.4 2000/09/24 13:51:05 alanh Exp $ */
 
 /*
  * Authors:
@@ -34,9 +34,10 @@
  */
 
 #include <stdio.h>
-#include "mgalib.h"
+#include "mgacontext.h"
 #include "mgabuffers.h"
 #include "mgastate.h"
+#include "mgaioctl.h"
 
 static void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa )
 {
@@ -47,7 +48,6 @@
    mmesa->drawX = driDrawable->x;
    mmesa->drawY = driDrawable->y;
 
-   mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
    mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->drawOffset;
    mmesa->dirty |= MGA_UPLOAD_CTX;
    mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
@@ -71,7 +71,6 @@
       mmesa->drawY = driDrawable->backY;
    }
 
-   mmesa->drawOffset = mmesa->mgaScreen->backOffset;
    mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->drawOffset;
 
    mmesa->dirty |= MGA_UPLOAD_CTX;
@@ -89,37 +88,29 @@
 
 
    if (sarea->exported_buffers & MGA_BACK) {
-      XF86DRIClipRectPtr boxes = 
-	 (XF86DRIClipRectPtr)malloc( sarea->exported_nback * sizeof(*boxes) );
 
-      if (driDrawable->pBackClipRects)
-	 free(driDrawable->pBackClipRects);
-
       driDrawable->numBackClipRects = sarea->exported_nback;
-      driDrawable->pBackClipRects = boxes;
+      driDrawable->pBackClipRects = mmesa->tmp_boxes[0];
 
       top = sarea->exported_nback;
       for (i = 0 ; i < top ; i++)
-	 boxes[i] = *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
+	 driDrawable->pBackClipRects[i] = 
+	    *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
    }
 
 
    if (sarea->exported_buffers & MGA_FRONT) 
    {
       int start = top;
-      XF86DRIClipRectPtr boxes = 
-	 (XF86DRIClipRectPtr)malloc( sarea->exported_nfront * sizeof(*boxes) );
-
-      if (driDrawable->pClipRects)
-	 free(driDrawable->pClipRects);
 
       driDrawable->numClipRects = sarea->exported_nfront;
-      driDrawable->pClipRects = boxes;
+      driDrawable->pClipRects = mmesa->tmp_boxes[1];
 
       top += sarea->exported_nfront;
       for ( ; i < top ; i++)
-	 boxes[i-start] = *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
-
+	 driDrawable->pClipRects[i-start] = 
+	    *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]);
+      
    } 
 
 
@@ -224,7 +215,8 @@
     */
    if (0) printSareaRects(mmesa);
 
-   if (sarea->exported_drawable == driDrawable->draw && 
+   if (0 && 
+       sarea->exported_drawable == driDrawable->draw && 
        (sarea->exported_buffers & buffers) == buffers)
    {
       mgaUpdateRectsFromSarea( mmesa );
@@ -271,6 +263,7 @@
    if (mode == GL_FRONT_LEFT) 
    {
       mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
+      mmesa->readOffset = mmesa->mgaScreen->frontOffset;
       mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->mgaScreen->frontOffset;
       mmesa->dirty |= MGA_UPLOAD_CTX;
       mmesa->draw_buffer = MGA_FRONT;
@@ -280,6 +273,7 @@
    else if (mode == GL_BACK_LEFT) 
    {
       mmesa->drawOffset = mmesa->mgaScreen->backOffset;
+      mmesa->readOffset = mmesa->mgaScreen->backOffset;
       mmesa->Setup[MGA_CTXREG_DSTORG] = mmesa->mgaScreen->backOffset;
       mmesa->draw_buffer = MGA_BACK;
       mmesa->dirty |= MGA_UPLOAD_CTX;
@@ -293,25 +287,19 @@
    }
 }
 
-/* XXX I don't know whether this is correct, but it at least compiles properly now */
-void mgaDDSetReadBuffer(GLcontext *ctx, GLframebuffer *colorBuffer, GLenum mode)
+void mgaDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer,
+			GLenum mode )
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
 
-   mmesa->Fallback &= ~MGA_FALLBACK_BUFFER;
-
    if (mode == GL_FRONT_LEFT) 
    {
       mmesa->readOffset = mmesa->mgaScreen->frontOffset;
       mmesa->read_buffer = MGA_FRONT;
    } 
-   else if (mode == GL_BACK_LEFT) 
+   else 
    {
       mmesa->readOffset = mmesa->mgaScreen->backOffset;
       mmesa->read_buffer = MGA_BACK;
-   }
-   else 
-   {
-      mmesa->Fallback |= MGA_FALLBACK_BUFFER;
    }
 }
Index: xc/lib/GL/mesa/src/drv/mga/mgabuffers.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgabuffers.h:1.2 xc/lib/GL/mesa/src/drv/mga/mgabuffers.h:1.3
--- xc/lib/GL/mesa/src/drv/mga/mgabuffers.h:1.2	Thu Jun 22 12:59:24 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgabuffers.h	Fri Aug 25 09:42:23 2000
@@ -1,10 +1,11 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgabuffers.h,v 1.2 2000/06/22 16:59:24 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgabuffers.h,v 1.3 2000/08/25 13:42:23 dawes Exp $ */
 
 #ifndef MGA_BUFFERS_H
 #define MGA_BUFFERS_H
 
-void mgaDDSetReadBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
-                             GLenum mode );
+void mgaDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer,
+			GLenum mode );
+
 GLboolean mgaDDSetDrawBuffer(GLcontext *ctx, GLenum mode );
 
 void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers );
Index: xc/lib/GL/mesa/src/drv/mga/mgaclear.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgaclear.c:1.1 xc/lib/GL/mesa/src/drv/mga/mgaclear.c:removed
--- xc/lib/GL/mesa/src/drv/mga/mgaclear.c:1.1	Fri Feb 11 12:25:35 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgaclear.c	Mon Dec 18 14:23:32 2000
@@ -1,10 +0,0 @@
-#include "types.h"
-#include "vbrender.h"
-
-#include <stdio.h>
-
-#include "mm.h"
-#include "mgalib.h"
-#include "mgadd.h"
-#include "mgaclear.h"
-#include "mgastate.h"
Index: xc/lib/GL/mesa/src/drv/mga/mgaclear.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgaclear.h:1.1 xc/lib/GL/mesa/src/drv/mga/mgaclear.h:removed
--- xc/lib/GL/mesa/src/drv/mga/mgaclear.h:1.1	Fri Feb 11 12:25:35 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgaclear.h	Mon Dec 18 14:23:32 2000
@@ -1,7 +0,0 @@
-#ifndef _MGA_CLEAR_H
-#define _MGA_CLEAR_H
-
-extern GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
-			    GLint x, GLint y, GLint width, GLint height );
-
-#endif
Index: xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c:1.2 xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c:removed
--- xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c:1.2	Fri Jun 16 20:03:01 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgacnvtex.c	Mon Dec 18 14:23:32 2000
@@ -1,251 +0,0 @@
-/* -*- mode: C; c-basic-offset:8 -*- */
-/*
- * GLX Hardware Device Driver for Matrox Millenium G200
- * Copyright (C) 1999 Wittawat Yamwong
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- *    original by Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
- *	9/20/99 rewrite by John Carmack <johnc@idsoftware.com>
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <GL/gl.h>
-
-#include "mm.h"
-#include "mgalib.h"
-#include "mgatex.h"
-
-
-/*
- * mgaConvertTexture
- * Converts a mesa format texture to the apropriate hardware format
- * Note that sometimes width may be larger than the texture, like 64x1
- * for an 8x8 texture.  This happens when we have to crutch the pitch
- * limits of the mga by uploading a block of texels as a single line.
- */
-void mgaConvertTexture( mgaUI32 *destPtr, int texelBytes, 
-			struct gl_texture_image *image,
-			int x, int y, int width, int height ) 
-{
-	register int		i, j;
-	mgaUI8		*src;
-	int stride;
-	
-	/* FIXME: g400 luminance_alpha internal format */
-	switch (texelBytes) {
-	case 1:
-		switch (image->Format) {
-		case GL_COLOR_INDEX:
-		case GL_INTENSITY:
-		case GL_LUMINANCE:
-		case GL_ALPHA:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x );
-			stride = (image->Width - width);
-			for ( i = height ; i ; i-- ) {
-				for ( j = width >> 2  ; j ; j-- ) {
-			
-					*destPtr++ = src[0] | ( src[1] << 8 ) | ( src[2] << 16 ) | ( src[3] << 24 );
-					src += 4;
-				}
-				src += stride;
-			}
-			break;
-		default:
-			goto format_error;
-		}
-		break;
-	case 2:
-		switch (image->Format) {
-		case GL_RGB:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 3;
-			stride = (image->Width - width) * 3;
-			for ( i = height ; i ; i-- ) {
-				for ( j = width >> 1  ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR565(src[0],src[1],src[2]) |  
-						( MGAPACKCOLOR565(src[3],src[4],src[5]) << 16 );
-					src += 6;
-				}
-				src += stride;
-			}
-			break;
-		case GL_RGBA:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 4;
-			stride = (image->Width - width) * 4;
-			for ( i = height ; i ; i-- ) {
-				for ( j = width >> 1  ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR4444(src[0],src[1],src[2],src[3]) |  
-						( MGAPACKCOLOR4444(src[4],src[5],src[6],src[7]) << 16 );
-					src += 8;
-				}
-				src += stride;
-			}
-			break;
-		case GL_LUMINANCE:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x );
-			stride = (image->Width - width);
-			for ( i = height ; i ; i-- ) {
-				for ( j = width >> 1  ; j ; j-- ) {
-					/* FIXME: should probably use 555 texture to get true grey */
-					*destPtr++ = MGAPACKCOLOR565(src[0],src[0],src[0]) |  
-						( MGAPACKCOLOR565(src[1],src[1],src[1]) << 16 );
-					src += 2;
-				}
-				src += stride;
-			}
-			break;
-		case GL_INTENSITY:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x );
-			stride = (image->Width - width);
-			for ( i = height ; i ; i-- ) {
-				for ( j = width >> 1  ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[0]) |  
-						( MGAPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16 );
-					src += 2;
-				}
-				src += stride;
-			}
-			break;
-		case GL_ALPHA:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x );
-			stride = (image->Width - width);
-			for ( i = height ; i ; i-- ) {
-				for ( j = width >> 1  ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR4444(255,255,255,src[0]) |  
-						( MGAPACKCOLOR4444(255,255,255,src[1]) << 16 );
-					src += 2;
-				}
-				src += stride;
-			}
-			break;
-		case GL_LUMINANCE_ALPHA:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 2;
-			stride = (image->Width - width) * 2;
-			for ( i = height ; i ; i-- ) {
-				for ( j = width >> 1  ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[1]) |  
-						( MGAPACKCOLOR4444(src[2],src[2],src[2],src[3]) << 16 );
-					src += 4;
-				}
-				src += stride;
-			}
-			break;
-		default:
-			goto format_error;
-		}
-		break;
-	case 4:
-		switch (image->Format) {
-		case GL_RGB:
-			src = (mgaUI8 *)image->Data + (  y * image->Width + x ) * 3;
-			stride = (image->Width - width) * 3;
-			for ( i = height ; i ; i-- ) {
-				for ( j = width ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2], 255);
-					src += 3;
-				}
-				src += stride;
-			}
-			break;
-		case GL_RGBA:
-			src = (mgaUI8 *)image->Data + (  y * image->Width + x ) * 4;
-			stride = (image->Width - width) * 4;
-			for ( i = height ; i ; i-- ) {
-				for ( j = width  ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2],src[3]);
-					src += 4;
-				}
-				src += stride;
-			}
-			break;
-		case GL_LUMINANCE:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x );
-			stride = (image->Width - width);
-			for ( i = height ; i ; i-- ) {
-				for ( j = width ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0], 255);
-					src += 1;
-				}
-				src += stride;
-			}
-			break;
-		case GL_INTENSITY:
-			src = (mgaUI8 *)image->Data + (  y * image->Width + x );
-			stride = (image->Width - width);
-			for ( i = height ; i ; i-- ) {
-				for ( j = width ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0],src[0]);
-					src += 1;
-				}
-				src += stride;
-			}
-			break;
-		case GL_ALPHA:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x );
-			stride = (image->Width - width);
-			for ( i = height ; i ; i-- ) {
-				for ( j = width ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR8888(255,255,255,src[0]);
-					src += 1;
-				}
-				src += stride;
-			}
-			break;
-		case GL_LUMINANCE_ALPHA:
-			src = (mgaUI8 *)image->Data + ( y * image->Width + x ) * 2;
-			stride = (image->Width - width) * 2;
-			for ( i = height ; i ; i-- ) {
-				for ( j = width ; j ; j-- ) {
-			
-					*destPtr++ = MGAPACKCOLOR8888(src[0],src[0],
-								      src[0],src[1]);
-					src += 2;
-				}
-				src += stride;
-			}
-			break;
-		default:
-			goto format_error;
-		}
-		break;
-	default:
-		goto format_error;
-	}
-
-	return;
-
- format_error:
-
-	mgaError( "Unsupported texelBytes %i, image->Format %i\n", 
-		  (int)texelBytes, (int)image->Format );
-}
Index: xc/lib/GL/mesa/src/drv/mga/mgacommon.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgacommon.h:1.1 xc/lib/GL/mesa/src/drv/mga/mgacommon.h:removed
--- xc/lib/GL/mesa/src/drv/mga/mgacommon.h:1.1	Fri Feb 11 12:25:35 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgacommon.h	Mon Dec 18 14:23:32 2000
@@ -1,44 +0,0 @@
-/*
- * GLX Hardware Device Driver for Matrox Millenium G200
- * Copyright (C) 1999 Wittawat Yamwong
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
- */
-
-
-#ifndef MGACOMMON_INC
-#define MGACOMMON_INC
-
-typedef unsigned int mgaUI32;
-typedef unsigned short mgaUI16;
-typedef unsigned char mgaUI8;
-typedef int mgaI32;
-typedef short mgaI16;
-typedef char mgaI8;
-
-typedef mgaUI8 mgaColor[4];
-
-struct mga_context_t;
-typedef struct mga_context_t mgaContext;
-typedef struct mga_context_t *mgaContextPtr;
-
-#endif
Index: xc/lib/GL/mesa/src/drv/mga/mgacontext.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/mga/mgacontext.h:1.1
--- /dev/null	Mon Dec 18 14:23:32 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgacontext.h	Sun Sep 24 09:51:06 2000
@@ -0,0 +1,316 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgacontext.h,v 1.1 2000/09/24 13:51:06 alanh Exp $*/
+/*
+ * GLX Hardware Device Driver for Matrox Millenium G200
+ * Copyright (C) 1999 Wittawat Yamwong
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
+ */
+
+
+#ifndef MGALIB_INC
+#define MGALIB_INC
+
+#include <X11/Xlibint.h>
+#include "dri_tmm.h"
+#include "dri_mesaint.h"
+#include "dri_mesa.h"
+
+#include "types.h"
+
+#include "drm.h"
+#include "mm.h"
+#include "mgavb.h"
+#include "mem.h"
+
+
+#define MGA_SET_FIELD(reg,mask,val)  reg = ((reg) & (mask)) | ((val) & ~(mask))
+#define MGA_FIELD(field,val) (((val) << (field ## _SHIFT)) & ~(field ## _MASK))
+#define MGA_GET_FIELD(field, val) ((val & ~(field ## _MASK)) >> (field ## _SHIFT))
+
+#define MGA_IS_G200(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G200)
+#define MGA_IS_G400(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G400)
+
+
+/* SoftwareFallback 
+ *    - texture env GL_BLEND -- can be fixed 
+ *    - 1D and 3D textures
+ *    - incomplete textures
+ */
+#define MGA_FALLBACK_TEXTURE   0x1
+#define MGA_FALLBACK_BUFFER    0x2
+#define MGA_FALLBACK_LOGICOP   0x4
+#define MGA_FALLBACK_STENCIL   0x8
+
+
+/* For mgaCtx->new_state.
+ */
+#define MGA_NEW_DEPTH   0x1
+#define MGA_NEW_ALPHA   0x2
+#define MGA_NEW_FOG     0x4
+#define MGA_NEW_CLIP    0x8
+#define MGA_NEW_MASK    0x10
+#define MGA_NEW_TEXTURE 0x20
+#define MGA_NEW_CULL    0x40
+#define MGA_NEW_WARP    0x80
+#define MGA_NEW_STENCIL 0x100
+#define MGA_NEW_CONTEXT 0x200
+
+
+typedef void (*mga_interp_func)( GLfloat t, 
+				 GLfloat *result,
+				 const GLfloat *in,
+				 const GLfloat *out );
+				 
+
+
+
+
+
+/* Reasons why the GL_BLEND fallback mightn't work:
+ */
+#define MGA_BLEND_ENV_COLOR 0x1
+#define MGA_BLEND_MULTITEX  0x2
+
+struct mga_elt_tab;
+struct mga_texture_object_s;
+struct mga_screen_private_s;
+
+#define MGA_TEX_MAXLEVELS 5
+
+typedef struct mga_texture_object_s 
+{
+	struct mga_texture_object_s *next;	
+	struct mga_texture_object_s *prev;	
+	struct gl_texture_object *tObj;
+        struct mga_context_t *ctx;
+	PMemBlock	MemBlock;               
+	GLuint		offsets[MGA_TEX_MAXLEVELS];
+        int             lastLevel;
+        GLuint         dirty_images;
+	GLuint		totalSize;		
+	int		texelBytes;
+	GLuint 	age;
+        int             bound;
+        int             heap;	/* agp or card */
+        int             Setup[MGA_TEX_SETUP_SIZE];
+} mgaTextureObject_t;
+
+struct mga_context_t {
+
+   GLcontext *glCtx;
+
+
+   /* Bookkeeping for texturing 
+    */
+   int lastTexHeap;
+   struct mga_texture_object_s TexObjList[MGA_NR_TEX_HEAPS];
+   struct mga_texture_object_s SwappedOut;
+   struct mga_texture_object_s *CurrentTexObj[2];
+   memHeap_t *texHeap[MGA_NR_TEX_HEAPS];
+   int c_texupload;
+   int c_texusage;
+   int tex_thrash;
+
+
+   /* Map GL texture units onto hardware.
+    */
+   GLuint multitex;
+   GLuint tmu_source[2];
+   GLuint tex_dest[2];
+   
+   GLboolean default32BitTextures;
+
+   /* Manage fallbacks 
+    */
+   GLuint IndirectTriangles;
+   int Fallback;  
+
+
+   /* Support for CVA and the fastpath 
+    */
+   unsigned int setupdone;
+   unsigned int setupindex;
+   unsigned int renderindex;
+   unsigned int using_fast_path;
+   mga_interp_func interp;
+
+
+   /* Support for limited GL_BLEND fallback
+    */
+   unsigned int blend_flags;
+   unsigned int envcolor;
+
+
+   /* Shortcircuit some state changes 
+    */
+   points_func   PointsFunc;
+   line_func     LineFunc;
+   triangle_func TriangleFunc;
+   quad_func     QuadFunc;
+
+
+   /* Manage driver and hardware state 
+    */
+   GLuint        new_state; 
+   GLuint        dirty;
+   GLuint        Setup[MGA_CTX_SETUP_SIZE];
+   GLuint        warp_pipe;
+   GLuint        vertsize;
+   GLushort      MonoColor;
+   GLushort      ClearColor;
+   GLuint        ClearDepth;
+   GLuint        poly_stipple;
+   GLfloat       depth_scale;
+   
+   GLuint        depth_clear_mask;
+   GLuint        stencil_clear_mask;
+   GLuint        hw_stencil;
+
+   /* Dma buffers
+    */
+   drmBufPtr  vertex_dma_buffer;
+   drmBufPtr  iload_buffer;
+
+   
+   /* Drawable, cliprect and scissor information
+    */
+   int dirty_cliprects;		/* which sets of cliprects are uptodate? */
+   int draw_buffer;		/* which buffer are we rendering to */
+   unsigned int drawOffset;		/* draw buffer address in  space */
+   int read_buffer;	
+   int readOffset;	
+   int drawX, drawY;		/* origin of drawable in draw buffer */
+   int lastX, lastY;		/* detect DSTORG bug */
+   GLuint numClipRects;		/* cliprects for the draw buffer */
+   XF86DRIClipRectPtr pClipRects;
+   XF86DRIClipRectRec draw_rect;
+   drm_clip_rect_t scissor_rect;
+   int scissor;
+   
+   XF86DRIClipRectRec tmp_boxes[2][MGA_NR_SAREA_CLIPRECTS];
+
+
+   /* Texture aging and DMA based aging.
+    */
+   unsigned int texAge[MGA_NR_TEX_HEAPS];/* texture LRU age  */
+   unsigned int dirtyAge;		/* buffer age for synchronization */
+   unsigned int lastSwap;		/* throttling runaway apps */
+
+
+
+   /* Mirrors of some DRI state.
+    */
+   GLframebuffer *glBuffer;
+   drmContext hHWContext;
+   drmLock *driHwLock;
+   int driFd;
+   Display *display;
+   __DRIdrawablePrivate *driDrawable;
+   __DRIscreenPrivate *driScreen;
+   struct mga_screen_private_s *mgaScreen; 
+   drm_mga_sarea_t *sarea;
+
+
+   /* New setupdma path
+    */
+   drmBufPtr elt_buf, retained_buf;
+   GLuint *first_elt, *next_elt;
+   GLfloat *next_vert;
+   GLuint next_vert_phys;
+   GLuint first_vert_phys;
+   struct mga_elt_tab *elt_tab;
+   GLfloat device_matrix[16];
+};
+
+
+
+#define MGAPACKCOLOR555(r,g,b,a) \
+  ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+    ((a) ? 0x8000 : 0))
+
+#define MGAPACKCOLOR565(r,g,b) \
+  ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define MGAPACKCOLOR888(r,g,b) \
+  (((r) << 16) | ((g) << 8) | (b))
+
+#define MGAPACKCOLOR8888(r,g,b,a) \
+  (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+#define MGAPACKCOLOR4444(r,g,b,a) \
+  ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+
+#define MGA_DEBUG 0   
+#ifndef MGA_DEBUG
+extern int MGA_DEBUG;
+#endif
+
+#define DEBUG_ALWAYS_SYNC    0x1
+#define DEBUG_VERBOSE_MSG    0x2
+#define DEBUG_VERBOSE_LRU    0x4
+#define DEBUG_VERBOSE_DRI    0x8
+#define DEBUG_VERBOSE_IOCTL  0x10
+#define DEBUG_VERBOSE_2D     0x20
+
+static __inline__ GLuint mgaPackColor(GLuint cpp,
+				      GLubyte r, GLubyte g, 
+				      GLubyte b, GLubyte a)
+{
+  switch (cpp) {
+  case 2:
+    return MGAPACKCOLOR565(r,g,b);
+  case 4:
+    return MGAPACKCOLOR8888(r,g,b,a);
+  default:
+    return 0;
+  }
+}
+
+
+/*
+ * Subpixel offsets for window coordinates:
+ */
+#define SUBPIXEL_X (-0.5F)
+#define SUBPIXEL_Y (-0.5F + 0.125)
+
+
+typedef struct mga_context_t mgaContext;
+typedef struct mga_context_t *mgaContextPtr;
+
+struct mga_elt_tab {
+   void (*emit_unclipped_verts)( struct vertex_buffer *VB );
+
+   void (*build_tri_verts)( mgaContextPtr mmesa, 
+			    struct vertex_buffer *VB, 
+			    GLfloat *O, GLuint *elt );
+
+   void (*interp)( GLfloat t, GLfloat *O, 
+		   const GLfloat *I, const GLfloat *J );
+
+   void (*project_and_emit_verts)( mgaContextPtr mmesa,
+				   const GLfloat *verts,
+				   GLuint *elts,
+				   int nr );
+};
+
+#endif
Index: xc/lib/GL/mesa/src/drv/mga/mgadd.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgadd.c:1.3 xc/lib/GL/mesa/src/drv/mga/mgadd.c:1.6
--- xc/lib/GL/mesa/src/drv/mga/mgadd.c:1.3	Thu Jun 22 12:59:24 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgadd.c	Wed Nov  8 00:02:45 2000
@@ -23,9 +23,10 @@
  *
  *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgadd.c,v 1.3 2000/06/22 16:59:24 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgadd.c,v 1.6 2000/11/08 05:02:45 dawes Exp $ */
 
 
+
 #include "types.h"
 #include "vbrender.h"
 
@@ -34,11 +35,8 @@
 #include <stdlib.h>
 
 #include "mm.h"
-#include "mgalib.h"
-#include "mgaclear.h"
+#include "mgacontext.h"
 #include "mgadd.h"
-#include "mgadepth.h"
-#include "mgalog.h"
 #include "mgastate.h"
 #include "mgaspan.h"
 #include "mgatex.h"
@@ -61,11 +59,11 @@
    mgaContextPtr mmesa = MGA_CONTEXT( ctx );
    switch (name) {
    case GL_VENDOR:
-      return (GLubyte *)"Precision Insight, Inc.";
+      return (GLubyte *) "Precision Insight, Inc.";
    case GL_RENDERER:
-      if (MGA_IS_G200(mmesa)) return (GLubyte *)"Mesa DRI G200 20000510";
-      if (MGA_IS_G400(mmesa)) return (GLubyte *)"Mesa DRI G400 20000510";
-      return (GLubyte *)"Mesa DRI MGA 20000510";
+      if (MGA_IS_G200(mmesa)) return (GLubyte *) "Mesa DRI G200 20000510";
+      if (MGA_IS_G400(mmesa)) return (GLubyte *) "Mesa DRI G400 20000510";
+      return (GLubyte *) "Mesa DRI MGA 20000510";
    default:
       return 0;
    }
@@ -74,24 +72,28 @@
 
 static GLint mgaGetParameteri(const GLcontext *ctx, GLint param)
 {
-  switch (param) {
-  case DD_HAVE_HARDWARE_FOG:  
-    return 1; 
-  default:
-    mgaError("mgaGetParameteri(): unknown parameter!\n");
-    return 0;
-  }
+   switch (param) {
+   case DD_HAVE_HARDWARE_FOG:  
+      return 1; 
+   default:
+      fprintf(stderr, "mgaGetParameteri(): unknown parameter!\n");
+      return 0;
+   }
 }
 
 
 static void mgaBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);  
-   
-/*     LOCK_HARDWARE( mmesa ); */
+
+   /* Need to lock to make sure the driDrawable is uptodate.  This
+    * information is used to resize Mesa's software buffers, so it has
+    * to be correct.
+    */
+   LOCK_HARDWARE( mmesa ); 
    *width = mmesa->driDrawable->w;
    *height = mmesa->driDrawable->h;
-/*     UNLOCK_HARDWARE( mmesa ); */
+   UNLOCK_HARDWARE( mmesa ); 
 }
 
 void mgaDDExtensionsInit( GLcontext *ctx )
@@ -102,10 +104,8 @@
 
    /* Support multitexture only on the g400.
     */
-   if (1 /*!MGA_IS_G400(MGA_CONTEXT(ctx))*/) 
+   if (!MGA_IS_G400(MGA_CONTEXT(ctx))) 
    {
-      gl_extensions_disable( ctx, "GL_EXT_multitexture" );
-      gl_extensions_disable( ctx, "GL_SGIS_multitexture" );
       gl_extensions_disable( ctx, "GL_ARB_multitexture" );
    }
 
@@ -130,11 +130,14 @@
    gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );   
    gl_extensions_disable( ctx, "GL_EXT_texture_lod_bias" );   
    gl_extensions_disable( ctx, "GL_MESA_resize_buffers" );   
-}
-
-
 
-
+   gl_extensions_disable( ctx, "GL_SGI_color_matrix" );   
+   gl_extensions_disable( ctx, "GL_SGI_color_table" );   
+   gl_extensions_disable( ctx, "GL_SGIX_pixel_texture" );   
+   gl_extensions_disable( ctx, "GL_ARB_texture_cube_map" );   
+   gl_extensions_disable( ctx, "GL_ARB_texture_compression" );   
+   gl_extensions_disable( ctx, "GL_EXT_convolution" );   
+}
 
 
 
Index: xc/lib/GL/mesa/src/drv/mga/mgadepth.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgadepth.c:1.2 xc/lib/GL/mesa/src/drv/mga/mgadepth.c:removed
--- xc/lib/GL/mesa/src/drv/mga/mgadepth.c:1.2	Fri Jun 16 20:03:01 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgadepth.c	Mon Dec 18 14:23:32 2000
@@ -1,648 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  3.1
- * 
- * Copyright (C) 1999  Brian Paul   All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * This file has been modified by Wittawat Yamwong for GLX module.
- */
-
-/*
- * Depth buffer functions
- */
-
-
-#ifdef PC_HEADER
-#include "all.h"
-#else
-#include <stdlib.h>
-#include <string.h>
-#include "context.h"
-#include "mgadepth.h"
-#include "types.h"
-#include "mm.h"
-#include "mgalib.h"
-#endif
-
-#define DEPTH_SCALE 65535.0F
-
-/*
- * Return the address of the Z-buffer value for window coordinate (x,y):
- */
-#define Z_SETUP						\
-   __DRIscreenPrivate *sPriv = mmesa->driScreen;	\
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;	\
-   GLuint height = dPriv->h;				\
-   mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;	\
-   GLint zbpitch = mgaScreen->depthPitch;		\
-   char *zbstart = (char *)(sPriv->pFB + 		\
-			       mgaScreen->depthOffset +	\
-			       dPriv->x * 2 +		\
-			       dPriv->y * zbpitch)
-
-#define Z_ADDRESS( X, Y )  \
-  (GLdepth *)(zbstart + zbpitch * (height - (Y)) + (X) * 2)
-
-
-/**********************************************************************/
-/*****                   Depth Testing Functions                  *****/
-/**********************************************************************/
-
-
-/*
- * Depth test horizontal spans of fragments.  These functions are called
- * via ctx->Driver.depth_test_span only.
- *
- * Input:  n - number of pixels in the span
- *         x, y - location of leftmost pixel in span in window coords
- *         z - array [n] of integer depth values
- * In/Out:  mask - array [n] of flags (1=draw pixel, 0=don't draw) 
- * Return:  number of pixels which passed depth test
- */
-
-
-/*
- * glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ).
- */
-static GLuint mga_depth_test_span_generic( GLcontext* ctx,
-					   GLuint n, GLint x, GLint y,
-					   const GLdepth z[],
-					   GLubyte mask[] )
-{
-   mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-   GLubyte *m = mask;
-   GLuint i;
-   GLuint passed = 0;
-
-   LOCK_HARDWARE_QUIESCENT(mmesa);
-   {
-      Z_SETUP;
-      GLdepth *zptr = Z_ADDRESS( x, y );
-
-      /* switch cases ordered from most frequent to less frequent */
-      switch (ctx->Depth.Func) {
-      case GL_LESS:
-         if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0; i<n; i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] < *zptr) {
-		     /* pass */
-		     *zptr = z[i];
-		     passed++;
-		  }
-		  else {
-		     /* fail */
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0; i<n; i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] < *zptr) {
-		     /* pass */
-		     passed++;
-		  }
-		  else {
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_LEQUAL:
-	 if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] <= *zptr) {
-		     *zptr = z[i];
-		     passed++;
-		  }
-		  else {
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] <= *zptr) {
-		     /* pass */
-		     passed++;
-		  }
-		  else {
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_GEQUAL:
-	 if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] >= *zptr) {
-		     *zptr = z[i];
-		     passed++;
-		  }
-		  else {
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] >= *zptr) {
-		     /* pass */
-		     passed++;
-		  }
-		  else {
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_GREATER:
-	 if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] > *zptr) {
-		     *zptr = z[i];
-		     passed++;
-		  }
-		  else {
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] > *zptr) {
-		     /* pass */
-		     passed++;
-		  }
-		  else {
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_NOTEQUAL:
-	 if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] != *zptr) {
-		     *zptr = z[i];
-		     passed++;
-		  }
-		  else {
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] != *zptr) {
-		     /* pass */
-		     passed++;
-		  }
-		  else {
-		     *m = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_EQUAL:
-	 if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] == *zptr) {
-		     *zptr = z[i];
-		     passed++;
-		  }
-		  else {
-		     *m =0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  if (z[i] == *zptr) {
-		     /* pass */
-		     passed++;
-		  }
-		  else {
-		     *m =0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_ALWAYS:
-	 if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0;i<n;i++,zptr++,m++) {
-	       if (*m) {
-		  *zptr = z[i];
-		  passed++;
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer or mask */
-	    passed = n;
-	 }
-	 break;
-      case GL_NEVER:
-	 for (i=0;i<n;i++) {
-	    mask[i] = 0;
-	 }
-	 break;
-      default:
-      }
-   }
-   UNLOCK_HARDWARE(mmesa);
-
-   return passed;
-}
-
-
-
-
-
-/*
- * Depth test an array of randomly positioned fragments.
- */
-
-/*
- * glDepthFunc( any ) and glDepthMask( GL_TRUE or GL_FALSE ).
- */
-static void mga_depth_test_pixels_generic( GLcontext* ctx,
-					   GLuint n, 
-					   const GLint x[], const GLint y[],
-					   const GLdepth z[], GLubyte mask[] )
-{
-   mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-   LOCK_HARDWARE_QUIESCENT(mmesa);
-   {
-      Z_SETUP;
-      register GLdepth *zptr;
-      register GLuint i;
-
-
-      /* switch cases ordered from most frequent to less frequent */
-      switch (ctx->Depth.Func) {
-      case GL_LESS:
-         if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] < *zptr) {
-		     /* pass */
-		     *zptr = z[i];
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] < *zptr) {
-		     /* pass */
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_LEQUAL:
-         if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] <= *zptr) {
-		     /* pass */
-		     *zptr = z[i];
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] <= *zptr) {
-		     /* pass */
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_GEQUAL:
-         if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] >= *zptr) {
-		     /* pass */
-		     *zptr = z[i];
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] >= *zptr) {
-		     /* pass */
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_GREATER:
-         if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] > *zptr) {
-		     /* pass */
-		     *zptr = z[i];
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] > *zptr) {
-		     /* pass */
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_NOTEQUAL:
-         if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] != *zptr) {
-		     /* pass */
-		     *zptr = z[i];
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] != *zptr) {
-		     /* pass */
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_EQUAL:
-         if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] == *zptr) {
-		     /* pass */
-		     *zptr = z[i];
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  if (z[i] == *zptr) {
-		     /* pass */
-		  }
-		  else {
-		     /* fail */
-		     mask[i] = 0;
-		  }
-	       }
-	    }
-	 }
-	 break;
-      case GL_ALWAYS:
-	 if (ctx->Depth.Mask) {
-	    /* Update Z buffer */
-	    for (i=0; i<n; i++) {
-	       if (mask[i]) {
-		  zptr = Z_ADDRESS(x[i],y[i]);
-		  *zptr = z[i];
-	       }
-	    }
-	 }
-	 else {
-	    /* Don't update Z buffer or mask */
-	 }
-	 break;
-      case GL_NEVER:
-	 /* depth test never passes */
-	 for (i=0;i<n;i++) {
-	    mask[i] = 0;
-	 }
-	 break;
-      default:
-      } 
-   }
-   UNLOCK_HARDWARE(mmesa);
-}
-
-
-
-/**********************************************************************/
-/*****                      Read Depth Buffer                     *****/
-/**********************************************************************/
-
-
-/*
- * Return a span of depth values from the depth buffer as floats in [0,1].
- * This function is only called through Driver.read_depth_span_float()
- * Input:  n - how many pixels
- *         x,y - location of first pixel
- * Output:  depth - the array of depth values
- */
-static void mga_read_depth_span_float( GLcontext* ctx,
-				       GLuint n, GLint x, GLint y, 
-				       GLfloat depth[] )
-{
-   mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-   LOCK_HARDWARE_QUIESCENT(mmesa);
-   {
-
-      Z_SETUP;
-      GLdepth *zptr;
-      GLfloat scale;
-      GLuint i;
-
-      scale = 1.0F / DEPTH_SCALE;
-
-      if (ctx->ReadBuffer->Depth) {
-	 zptr = Z_ADDRESS( x, y );
-	 for (i=0;i<n;i++) {
-	    depth[i] = (GLfloat) zptr[i] * scale;
-	 }
-      }
-      else {
-	 for (i=0;i<n;i++) {
-	    depth[i] = 0.0F;
-	 }
-      }
-   }
-   UNLOCK_HARDWARE(mmesa);
-}
-
-
-/*
- * Return a span of depth values from the depth buffer as integers in
- * [0,MAX_DEPTH].
- * This function is only called through Driver.read_depth_span_int()
- * Input:  n - how many pixels
- *         x,y - location of first pixel
- * Output:  depth - the array of depth values
- */
-static void mga_read_depth_span_int( GLcontext* ctx,
-				     GLuint n, GLint x, GLint y, 
-				     GLdepth depth[] )
-{
-   mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-   LOCK_HARDWARE_QUIESCENT(mmesa);
-   {
-      Z_SETUP;
-   
-      
-      if (ctx->ReadBuffer->Depth) {
-	 GLdepth *zptr = Z_ADDRESS( x, y );
-	 MEMCPY( depth, zptr, n * sizeof(GLdepth) );
-      }
-      else {
-	 GLuint i;
-	 for (i=0;i<n;i++) {
-	    depth[i] = 0;
-	 }
-      }
-   }
-   UNLOCK_HARDWARE(mmesa);
-}
-
-
-void mgaDDInitDepthFuncs( GLcontext *ctx )
-{
-   ctx->Driver.ReadDepthSpan = mga_read_depth_span_float;
-   ctx->Driver.WriteDepthSpan = mga_read_depth_span_float;
-   ctx->Driver.ReadDepthPixels mga_read_depth_span_float;
-   ctx->Driver.WriteDepthPixels = mga_read_depth_span_float;
-}
-
Index: xc/lib/GL/mesa/src/drv/mga/mgadepth.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgadepth.h:1.1 xc/lib/GL/mesa/src/drv/mga/mgadepth.h:removed
--- xc/lib/GL/mesa/src/drv/mga/mgadepth.h:1.1	Fri Feb 11 12:25:36 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgadepth.h	Mon Dec 18 14:23:32 2000
@@ -1,37 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version:  3.1
- * 
- * Copyright (C) 1999  Brian Paul   All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/*
- * This file has been modified by Wittawat Yamwong for GLX module.
- */
-
-
-#ifndef MGADEPTH_INC
-#define MGADEPTH_INC
-
-
-#include "types.h"
-void mgaDDInitDepthFuncs( GLcontext *ctx );
-
-#endif
Index: xc/lib/GL/mesa/src/drv/mga/mgadma.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgadma.c:1.1 xc/lib/GL/mesa/src/drv/mga/mgadma.c:removed
--- xc/lib/GL/mesa/src/drv/mga/mgadma.c:1.1	Fri Feb 11 12:25:36 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgadma.c	Mon Dec 18 14:23:32 2000
@@ -1,59 +0,0 @@
-/* -*- mode: C; c-basic-offset:8 -*- */
-/*
- * GLX Hardware Device Driver for Matrox G200/G400
- * Copyright (C) 1999 Jeff Hartmann
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * original by Jeff Hartmann <slicer@ionet.net>
- * 6/16/99: rewrite by John Carmack <johnc@idsoftware.com>
- * 1/13/00: rewrite for DRI by Keith Whitwell <keithw@precisioninsight.com>
- */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-
-#include "mm.h"
-#include "mgabuf.h"
-#include "mgadd.h"
-#include "mgalib.h"
-#include "mgalog.h"
-#include "mgastate.h"
-#include "mgaglx.h"
-
-#include "pb.h"
-
-
-
-
-
-
-
-
-
-
Index: xc/lib/GL/mesa/src/drv/mga/mgadma.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgadma.h:1.1 xc/lib/GL/mesa/src/drv/mga/mgadma.h:removed
--- xc/lib/GL/mesa/src/drv/mga/mgadma.h:1.1	Fri Feb 11 12:25:36 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgadma.h	Mon Dec 18 14:23:32 2000
@@ -1,41 +0,0 @@
-/*
-  GLX Hardware Device Driver for Matrox Millenium G200
-  Copyright (C) 1999  Stephen Crowley (crow@debian.org)
-  
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  any later version.
-  
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-  
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-  
- original by Jeff Hartmann <slicer@ionet.net>
-  6/16/99: rewrite by John Carmack <johnc@idsoftware.com>
-*/
-
-#ifndef MGADMA_H
-#define MGADMA_H
-
-#include "mgacommon.h"
-#include "mm.h"
-#include <stdio.h>
-
-
-
-
-
-
-
-
-
-
-
-
-#endif
Index: xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c:1.1 xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c:1.5
--- xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c:1.1	Fri Jun 16 20:03:01 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c	Tue Sep 26 11:56:47 2000
@@ -21,6 +21,7 @@
  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c,v 1.5 2000/09/26 15:56:47 tsi Exp $ */
 
 #include <stdio.h>
 
@@ -31,7 +32,7 @@
 #include "mmath.h"
 #include "xform.h"
 
-#include "mgalib.h"
+#include "mgacontext.h"
 #include "mgapipeline.h"
 #include "mgatris.h"
 #include "mgastate.h"
@@ -57,10 +58,10 @@
 
       if (mmesa->first_elt != mmesa->next_elt) {
 	 mgaFireEltsLocked( mmesa, 
-			    ((GLuint)mmesa->first_elt - 
-			     (GLuint)mmesa->elt_buf->address),
-			    ((GLuint)mmesa->next_elt - 
-			     (GLuint)mmesa->elt_buf->address),
+			    ((char *)mmesa->first_elt - 
+			     (char *)mmesa->elt_buf->address),
+			    ((char *)mmesa->next_elt - 
+			     (char *)mmesa->elt_buf->address),
 			    !retain );
       } else if (!retain) 
 	 mgaReleaseBufLocked( mmesa, mmesa->elt_buf );
@@ -76,7 +77,7 @@
       
    UNLOCK_HARDWARE( mmesa );
 
-   mmesa->next_vert = (GLfloat *)((GLuint)mmesa->elt_buf->address + 
+   mmesa->next_vert = (GLfloat *)((char *)mmesa->elt_buf->address + 
 				  mmesa->elt_buf->total - 
 				  BUFFER_STRIDE * sizeof(GLfloat));
 
@@ -98,10 +99,10 @@
       LOCK_HARDWARE( mmesa );
       if (mmesa->first_elt != mmesa->next_elt) {
 	 mgaFireEltsLocked( mmesa, 
-			    ((GLuint)mmesa->first_elt - 
-			     (GLuint)mmesa->elt_buf->address),
-			    ((GLuint)mmesa->next_elt - 
-			     (GLuint)mmesa->elt_buf->address),
+			    ((char *)mmesa->first_elt - 
+			     (char *)mmesa->elt_buf->address),
+			    ((char *)mmesa->next_elt - 
+			     (char *)mmesa->elt_buf->address),
 			    0 );
 
 	 mmesa->first_elt = mmesa->next_elt;
@@ -204,7 +205,7 @@
 
    {
       GLuint *out = inlist[in];
-      GLuint space = (GLuint)mmesa->next_vert -	(GLuint)mmesa->next_elt;
+      GLuint space = (char *)mmesa->next_vert - (char *)mmesa->next_elt;
 
       if (space < n * (BUFFER_STRIDE + 3) * sizeof(GLuint))
          fire_elts(mmesa); 
@@ -241,15 +242,15 @@
 
 #define UNCLIPPED_VERT(x) (mmesa->first_vert_phys - x * BUFFER_STRIDE * 4)
 
-#define TRIANGLE( e2, e1, e0 )			\
-do {						\
-   if ((GLuint)mmesa->next_vert - 		\
-       (GLuint)mmesa->next_elt < TRI_THRESHOLD)	\
-      fire_elts(mmesa);			\
-   mmesa->next_elt[0] = UNCLIPPED_VERT(e2);	\
-   mmesa->next_elt[1] = UNCLIPPED_VERT(e1);	\
-   mmesa->next_elt[2] = UNCLIPPED_VERT(e0);	\
-   mmesa->next_elt+=3;				\
+#define TRIANGLE( e2, e1, e0 )				\
+do {							\
+   if (((char *)mmesa->next_vert -			\
+        (char *)mmesa->next_elt) < TRI_THRESHOLD)	\
+      fire_elts(mmesa);					\
+   mmesa->next_elt[0] = UNCLIPPED_VERT(e2);		\
+   mmesa->next_elt[1] = UNCLIPPED_VERT(e1);		\
+   mmesa->next_elt[2] = UNCLIPPED_VERT(e0);		\
+   mmesa->next_elt+=3;					\
 } while (0)
 
 #define CLIP_TRIANGLE( e2, e1, e0 )				\
@@ -328,8 +329,8 @@
    m[MAT_TX] =   mat->m[MAT_TX] + mmesa->drawX + .5;
    m[MAT_SY] = (- mat->m[MAT_SY]);
    m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY - .5;
-   m[MAT_SZ] =   mat->m[MAT_SZ] * (1.0 / 0x10000);
-   m[MAT_TZ] =   mat->m[MAT_TZ] * (1.0 / 0x10000);
+   m[MAT_SZ] =   mat->m[MAT_SZ] * mmesa->depth_scale;
+   m[MAT_TZ] =   mat->m[MAT_TZ] * mmesa->depth_scale;
 }
 
 #define CLIP_UBYTE_B 0   
@@ -427,7 +428,7 @@
    /* Allocate a single buffer to hold unclipped vertices.  All
     * unclipped vertices must be contiguous.  
     */
-   if ((GLuint)mmesa->next_vert - (GLuint)mmesa->next_elt <  
+   if ((char *)mmesa->next_vert - (char *)mmesa->next_elt <  
        VB->Count * BUFFER_STRIDE * sizeof(GLuint))	
       fire_elts( mmesa );
 
Index: xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h:1.1 xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h:1.3
--- xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h:1.1	Fri Jun 16 20:03:01 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h	Sun Aug 27 22:43:12 2000
@@ -21,6 +21,7 @@
  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h,v 1.3 2000/08/28 02:43:12 tsi Exp $ */
 
 /* Buffers fill from high addresses down with vertices and from low
  * addresses up with elements.  
@@ -83,8 +84,6 @@
 	 }
 
 	 if (TYPE & MGA_TEX0_BIT) {
-/*  	    fprintf(stderr, "i %d tex0 %f, %f\n", i,  */
-/*  		    tex0_data[0], tex0_data[1]); */
 	    *(int*)&f[6] = *(int*)&tex0_data[0];
 	    *(int*)&f[7] = *(int*)&tex0_data[1];
 	 }
@@ -126,20 +125,25 @@
       O[3] = clip[3];
 
       if (TYPE & MGA_RGBA_BIT) {
-	 GLubyte *col = VEC_ELT(VB->ColorPtr, GLubyte, elt[i]);
+	 GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, elt[i]);
+#if defined(USE_X86_ASM)
+	 __asm__ (
+	    "movl (%%edx),%%eax   \n"
+	    "bswap %%eax          \n"
+	    "rorl $8,%%eax        \n"
+	    "movl %%eax,16(%%edi) \n"
+	    :
+	    : "d" (color), "D" (O)
+	    : "%eax" );
+#else
 	 GLubyte *b = (GLubyte *)&O[4];
-	 b[CLIP_UBYTE_R] = col[0];
-	 b[CLIP_UBYTE_G] = col[1];
-	 b[CLIP_UBYTE_B] = col[2];
-	 b[CLIP_UBYTE_A] = col[3];
+	 b[CLIP_UBYTE_B] = color[2];
+	 b[CLIP_UBYTE_G] = color[1];
+	 b[CLIP_UBYTE_R] = color[0];
+	 b[CLIP_UBYTE_A] = color[3];
+#endif
       }
 
-      if (0)
-	 fprintf(stderr, 
-	      "build_tri_vert elt[%d]: %d phys: %x (first_phys %x elt_buf %x\n",
-	      i, elt[i], UNCLIPPED_VERT(elt[i]), 
-	      mmesa->first_vert_phys, (GLuint)mmesa->elt_buf);
-
       *(GLuint *)&O[5] = UNCLIPPED_VERT(elt[i]);
 
       if (TYPE & MGA_TEX0_BIT) {
@@ -176,8 +180,6 @@
 		  ((GLubyte *)&(J[4])));
    }
 
-   if (0) fprintf(stderr, "setting 0x%x to ~0\n", (GLuint)&O[5]);
-
    *(GLuint *)&O[5] = ~0;	/* note that this is a new vertex */
  
    if (TYPE & MGA_TEX0_BIT) {
@@ -215,10 +217,6 @@
       const GLfloat *I = &verts[elt[i] * CLIP_STRIDE];
       GLuint tmp = *(GLuint *)&I[5];
 
-      if (0) fprintf(stderr, "elt[%d] (tmp 0x%x %d) %d --> ", i, (GLuint)&I[5],
-	      tmp, elt[i]);
-
-
       if ((elt[i] = tmp) == ~0) 
       {      
 	 GLfloat oow = 1.0/I[3];
@@ -247,7 +245,6 @@
 
 	 O -= BUFFER_STRIDE;
       }
-      if (0) fprintf(stderr, "0x%x\n", elt[i]);
    }
 
    mmesa->next_vert = O;
Index: xc/lib/GL/mesa/src/drv/mga/mgafastpath.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgafastpath.c:1.2 xc/lib/GL/mesa/src/drv/mga/mgafastpath.c:1.6
--- xc/lib/GL/mesa/src/drv/mga/mgafastpath.c:1.2	Fri Jun 16 20:03:01 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgafastpath.c	Mon Nov 13 18:31:28 2000
@@ -21,6 +21,7 @@
  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgafastpath.c,v 1.6 2000/11/13 23:31:28 dawes Exp $ */
 
 #include <stdio.h>
 
@@ -30,7 +31,7 @@
 #include "vertices.h"
 #include "mmath.h"
 
-#include "mgalib.h"
+#include "mgacontext.h"
 #include "mgapipeline.h"
 #include "mgatris.h"
 #include "mgastate.h"
@@ -62,7 +63,7 @@
 #define RENDER_POINTS( start, count )		\
 do {						\
    GLuint e;					\
-   for(e=start;e<=count;e++)			\
+   for(e=start;e<count;e++)			\
      POINT(elt[e]);				\
 } while (0)
 
@@ -386,8 +387,8 @@
    m[MAT_TX] =   mat->m[MAT_TX] + mmesa->drawX + SUBPIXEL_X;
    m[MAT_SY] = (- mat->m[MAT_SY]);
    m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY + SUBPIXEL_Y;
-   m[MAT_SZ] =   mat->m[MAT_SZ] * (1.0 / 0x10000);
-   m[MAT_TZ] =   mat->m[MAT_TZ] * (1.0 / 0x10000);
+   m[MAT_SZ] =   mat->m[MAT_SZ] * mmesa->depth_scale;
+   m[MAT_TZ] =   mat->m[MAT_TZ] * mmesa->depth_scale;
 
    gl_project_v16( mgaVB->verts[VB->CopyStart].f,
 		   mgaVB->verts[mgaVB->last_vert].f,
@@ -409,8 +410,8 @@
    m[MAT_TX] =   mat->m[MAT_TX] + mmesa->drawX + SUBPIXEL_X;
    m[MAT_SY] = (- mat->m[MAT_SY]);
    m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY - SUBPIXEL_Y;
-   m[MAT_SZ] =   mat->m[MAT_SZ] * (1.0 / 0x10000);
-   m[MAT_TZ] =   mat->m[MAT_TZ] * (1.0 / 0x10000);
+   m[MAT_SZ] =   mat->m[MAT_SZ] * mmesa->depth_scale;
+   m[MAT_TZ] =   mat->m[MAT_TZ] * mmesa->depth_scale;
 
    gl_project_clipped_v16( mgaVB->verts[VB->CopyStart].f,
 			   mgaVB->verts[mgaVB->last_vert].f,
@@ -486,8 +487,10 @@
    struct mga_fast_tab *tab = &mgaFastTab[mmesa->setupindex & VALID_SETUP];
    GLuint do_cliptest = 1;
 
+
    gl_prepare_arrays_cva( VB );	                 /* still need this */
 
+#if 1
    if (gl_reduce_prim[prim] == GL_TRIANGLES && 
        VB->Count < (MGA_DMA_BUF_SZ / 48) &&
        (ctx->ModelProjectMatrix.flags & (MAT_FLAG_GENERAL|
@@ -497,6 +500,7 @@
       mgaDDEltPath( VB );
       return;
    }
+#endif
 
    /* Reserve enough space for the pathological case.
     */
Index: xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgaioctl.c:1.3 xc/lib/GL/mesa/src/drv/mga/mgaioctl.c:1.8
--- xc/lib/GL/mesa/src/drv/mga/mgaioctl.c:1.3	Fri Jun 30 13:15:08 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgaioctl.c	Wed Nov  8 00:02:45 2000
@@ -1,17 +1,16 @@
-#include <stdio.h>
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaioctl.c,v 1.8 2000/11/08 05:02:45 dawes Exp $ */
 
+#include <stdio.h>
 
 #include "types.h"
 #include "pb.h"
 #include "dd.h"
 
 #include "mm.h"
-#include "mgalib.h"
+#include "mgacontext.h"
 #include "mgadd.h"
 #include "mgastate.h"
-#include "mgadepth.h"
 #include "mgatex.h"
-#include "mgalog.h"
 #include "mgavb.h"
 #include "mgatris.h"
 #include "mgabuffers.h"
@@ -20,7 +19,8 @@
 #include "drm.h"
 #include <sys/ioctl.h>
 
-#define DEPTH_SCALE 65535.0F
+#define DEPTH_SCALE_16 ((GLfloat)0xffff)
+#define DEPTH_SCALE_32 ((GLfloat)0xffffffff) 
 
 static void mga_iload_dma_ioctl(mgaContextPtr mmesa,
 				unsigned long dest, 
@@ -54,6 +54,7 @@
 int mgaUpdateLock( mgaContextPtr mmesa, drmLockFlags flags )
 {
    drm_lock_t lock;
+   int retcode;
    
    lock.flags = 0;
 
@@ -66,13 +67,15 @@
    
    if (flags & DRM_LOCK_FLUSH)      lock.flags |= _DRM_LOCK_FLUSH;
    if (flags & DRM_LOCK_FLUSH_ALL)  lock.flags |= _DRM_LOCK_FLUSH_ALL;
- 
+
    if (!lock.flags)
       return 0;
 
-   if(ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH, &lock)) {
+   retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH, &lock);
+   if(retcode != 0) {
       fprintf(stderr, "Lockupdate failed\n");
-      return -1;
+      if(retcode == EACCES) exit(1);
+      else return -1;
    }
    
    if(flags & DRM_LOCK_QUIESCENT)
@@ -81,7 +84,7 @@
    return 0;
 }
 
-static drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
+drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
 {
    int idx = 0;
    int size = 0;
@@ -135,10 +138,10 @@
    if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
       fprintf(stderr, 
 	   "drmDMA (get) returns size[0] 0x%x idx[0] %d\n"
-	   "dma_buffer now: buf idx: %d size: %d used: %d\n",
+	   "dma_buffer now: buf idx: %d size: %d used: %d addr %p\n",
 	   dma.request_sizes[0], dma.request_list[0],
 	   buf->idx, buf->total,
-	   buf->used);
+	   buf->used, buf->address);
 
    if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
       fprintf(stderr, "finished getbuffer\n");
@@ -154,7 +157,6 @@
 {
    mgaContextPtr mmesa = MGA_CONTEXT( ctx );
    __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
-   const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
    drm_mga_clear_t clear;
    int retcode;
    int i;
@@ -164,25 +166,39 @@
 
    clear.flags = 0;
    clear.clear_color = mmesa->ClearColor;
-   clear.clear_depth = (mgaUI32) (ctx->Depth.Clear * DEPTH_SCALE);
+   clear.clear_depth = 0;
+   clear.clear_depth_mask = 0;
 
    FLUSH_BATCH( mmesa );
 	
-   if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) {
+   if (mask & DD_FRONT_LEFT_BIT) {
       clear.flags |= MGA_FRONT;
+      clear.clear_color_mask = mmesa->Setup[MGA_CTXREG_PLNWT];
       mask &= ~DD_FRONT_LEFT_BIT;
    }
 
-   if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0) {
+   if (mask & DD_BACK_LEFT_BIT) {
       clear.flags |= MGA_BACK;
+      clear.clear_color_mask = mmesa->Setup[MGA_CTXREG_PLNWT];
       mask &= ~DD_BACK_LEFT_BIT;
    }
 
    if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) {
       clear.flags |= MGA_DEPTH;
+      clear.clear_depth_mask |= mmesa->depth_clear_mask;
+      clear.clear_depth = (mmesa->ClearDepth &
+			   mmesa->depth_clear_mask);
       mask &= ~DD_DEPTH_BIT;
    }
 
+   if ((mask & DD_STENCIL_BIT) && mmesa->hw_stencil) {
+      clear.flags |= MGA_DEPTH;
+      clear.clear_depth_mask |= mmesa->stencil_clear_mask;
+      clear.clear_depth |= (ctx->Stencil.Clear &
+			    mmesa->stencil_clear_mask);
+      mask &= ~DD_STENCIL_BIT;
+   }
+
    if (!clear.flags)
       return mask;
 
@@ -261,6 +277,8 @@
 }
 
 
+int nrswaps;
+
 
 
 /*
@@ -272,7 +290,6 @@
    XF86DRIClipRectPtr pbox;
    int nbox;
    drm_mga_swap_t swap;
-   static int nrswaps;
    int retcode;
    int i;
    int tmp;
@@ -306,12 +323,16 @@
       if (0)
 	 fprintf(stderr, "DRM_IOCTL_MGA_SWAP\n"); 
 
+#if 1
       if((retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_SWAP, &swap))) {
 	 printf("send swap retcode = %d\n", retcode);
 	 exit(1);
       }
+#else
+      mgaUpdateLock( mmesa, DRM_LOCK_FLUSH );
+#endif
 
-      if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+      if (0)
 	 fprintf(stderr, "finished swap %d\n", ++nrswaps);
    }
 
@@ -502,10 +523,10 @@
 {
    if (mmesa->first_elt != mmesa->next_elt) {
       mgaFireEltsLocked( mmesa, 
-			 ((GLuint)mmesa->first_elt - 
-			  (GLuint)mmesa->elt_buf->address),
-			 ((GLuint)mmesa->next_elt - 
-			  (GLuint)mmesa->elt_buf->address),
+			 ((char *)mmesa->first_elt - 
+			  (char *)mmesa->elt_buf->address),
+			 ((char *)mmesa->next_elt - 
+			  (char *)mmesa->elt_buf->address),
 			 0 );
       mmesa->first_elt = mmesa->next_elt;
    }
@@ -519,10 +540,10 @@
 }
 
 
-mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords )
+GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords )
 {
    int bytes = dwords * 4;
-   mgaUI32 *head;
+   GLuint *head;
 
    if (!mmesa->vertex_dma_buffer) {
       LOCK_HARDWARE( mmesa );
@@ -540,7 +561,7 @@
       UNLOCK_HARDWARE( mmesa );
    }
 
-   head = (mgaUI32 *)((char *)mmesa->vertex_dma_buffer->address + 
+   head = (GLuint *)((char *)mmesa->vertex_dma_buffer->address + 
 		      mmesa->vertex_dma_buffer->used);
 
    mmesa->vertex_dma_buffer->used += bytes;
@@ -559,7 +580,10 @@
    if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
       fprintf(stderr, "mgaFireILoad idx %d ofs 0x%x length %d\n",
 	      mmesa->iload_buffer->idx, (int)offset, (int)length );
-
+   
+   /* HACK 
+    */
+   mgaUpdateLock( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH);
    mga_iload_dma_ioctl( mmesa, offset, length );
 }
 
@@ -573,7 +597,7 @@
 }
 
 
- void mgaDDFlush( GLcontext *ctx )
+void mgaDDFlush( GLcontext *ctx )
 {
    mgaContextPtr mmesa = MGA_CONTEXT( ctx );
 
@@ -583,10 +607,7 @@
    /* This may be called redundantly - dispatch_age may trail what
     * has actually been sent and processed by the hardware.
     */
-#if 0
-   if (GET_DISPATCH_AGE( mmesa ) < mmesa->sarea->last_enqueue)
-#endif
-   {
+   if (1 || GET_DISPATCH_AGE( mmesa ) < mmesa->sarea->last_enqueue) {
       LOCK_HARDWARE( mmesa );
       if (0) fprintf(stderr, "mgaDDFlush %d %d\n", GET_DISPATCH_AGE( mmesa ),  mmesa->sarea->last_enqueue);
       mgaUpdateLock( mmesa, DRM_LOCK_FLUSH );
Index: xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgaioctl.h:1.2 xc/lib/GL/mesa/src/drv/mga/mgaioctl.h:1.5
--- xc/lib/GL/mesa/src/drv/mga/mgaioctl.h:1.2	Fri Jun 16 20:03:01 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgaioctl.h	Sun Sep 24 09:51:07 2000
@@ -1,7 +1,10 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaioctl.h,v 1.5 2000/09/24 13:51:07 alanh Exp $ */
+
 #ifndef MGA_IOCTL_H
 #define MGA_IOCTL_H
 
-#include "mgalib.h"
+#include "mgacontext.h"
+#include "mga_xmesa.h"
 
 GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
 		     GLint cx, GLint cy, GLint cw, GLint ch ); 
@@ -11,7 +14,7 @@
 
 
 
-mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
+GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
 
 
 void mgaGetILoadBufferLocked( mgaContextPtr mmesa );
@@ -43,6 +46,7 @@
 /* upload texture
  */
 
+void mgaDDFlush( GLcontext *ctx );
 void mgaDDFinish( GLcontext *ctx );
 
 void mgaDDInitIoctlFuncs( GLcontext *ctx );
@@ -54,5 +58,35 @@
 	else if (mmesa->next_elt != mmesa->first_elt) mgaFlushElts(mmesa);	        	\
 } while (0)
 
+extern drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa );
+
+static __inline
+GLuint *mgaAllocVertexDwordsInline( mgaContextPtr mmesa, int dwords )
+{
+   int bytes = dwords * 4;
+   GLuint *head;
+
+   if (!mmesa->vertex_dma_buffer) {
+      LOCK_HARDWARE( mmesa );
+
+      if (mmesa->first_elt != mmesa->next_elt) 
+	 mgaFlushEltsLocked(mmesa);
+
+      mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
+      UNLOCK_HARDWARE( mmesa );
+   } else if (mmesa->vertex_dma_buffer->used + bytes > 
+	      mmesa->vertex_dma_buffer->total) {
+      LOCK_HARDWARE( mmesa );
+      mgaFlushVerticesLocked( mmesa );
+      mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
+      UNLOCK_HARDWARE( mmesa );
+   }
+
+   head = (GLuint *)((char *)mmesa->vertex_dma_buffer->address + 
+		      mmesa->vertex_dma_buffer->used);
+
+   mmesa->vertex_dma_buffer->used += bytes;
+   return head;
+}
 
 #endif
Index: xc/lib/GL/mesa/src/drv/mga/mgalib.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgalib.h:1.2 xc/lib/GL/mesa/src/drv/mga/mgalib.h:removed
--- xc/lib/GL/mesa/src/drv/mga/mgalib.h:1.2	Fri Jun 16 20:03:01 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgalib.h	Mon Dec 18 14:23:33 2000
@@ -1,324 +0,0 @@
-/*
- * GLX Hardware Device Driver for Matrox Millenium G200
- * Copyright (C) 1999 Wittawat Yamwong
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
- */
-
-
-#ifndef MGALIB_INC
-#define MGALIB_INC
-
-#include <X11/Xlibint.h>
-#include "dri_tmm.h"
-#include "dri_mesaint.h"
-#include "dri_mesa.h"
-
-#include "types.h"
-
-#include "drm.h"
-#include "mgacommon.h"
-#include "mm.h"
-#include "mgalog.h"
-#include "mgaioctl.h"
-#include "mgatex.h"
-#include "mgavb.h"
-
-#include "mga_xmesa.h"
-
-
-#define MGA_SET_FIELD(reg,mask,val)  reg = ((reg) & (mask)) | ((val) & ~(mask))
-#define MGA_FIELD(field,val) (((val) << (field ## _SHIFT)) & ~(field ## _MASK))
-#define MGA_GET_FIELD(field, val) ((val & ~(field ## _MASK)) >> (field ## _SHIFT))
-
-#define MGA_IS_G200(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G200)
-#define MGA_IS_G400(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G400)
-
-
-/* SoftwareFallback 
- *    - texture env GL_BLEND -- can be fixed 
- *    - 1D and 3D textures
- *    - incomplete textures
- */
-#define MGA_FALLBACK_TEXTURE   0x1
-#define MGA_FALLBACK_BUFFER    0x2
-#define MGA_FALLBACK_STIPPLE   0x3
-
-
-/* For mgaCtx->new_state.
- */
-#define MGA_NEW_DEPTH   0x1
-#define MGA_NEW_ALPHA   0x2
-#define MGA_NEW_FOG     0x4
-#define MGA_NEW_CLIP    0x8
-#define MGA_NEW_MASK    0x10
-#define MGA_NEW_TEXTURE 0x20
-#define MGA_NEW_CULL    0x40
-#define MGA_NEW_WARP    0x80
-#define MGA_NEW_CONTEXT 0x100
-
-
-typedef void (*mga_interp_func)( GLfloat t, 
-				 GLfloat *result,
-				 const GLfloat *in,
-				 const GLfloat *out );
-				 
-
-
-
-/* if type == MGA_COLORBUFFER */
-#define MGA_PF_MASK  0xf0
-#define MGA_PF_INDEX 0
-#define MGA_PF_565   (1 << 4)
-#define MGA_PF_555   (9 << 4)
-#define MGA_PF_888   (3 << 4)
-#define MGA_PF_8888  (10 << 4)
-#define MGA_PF_HASALPHA (8 << 4)
-
-
-
-/* Reasons why the GL_BLEND fallback mightn't work:
- */
-#define MGA_BLEND_ENV_COLOR 0x1
-#define MGA_BLEND_MULTITEX  0x2
-
-struct mga_elt_tab {
-   void (*emit_unclipped_verts)( struct vertex_buffer *VB );
-
-   void (*build_tri_verts)( mgaContextPtr mmesa, 
-			    struct vertex_buffer *VB, 
-			    GLfloat *O, GLuint *elt );
-
-   void (*interp)( GLfloat t, GLfloat *O, 
-		   const GLfloat *I, const GLfloat *J );
-
-   void (*project_and_emit_verts)( mgaContextPtr mmesa,
-				   const GLfloat *verts,
-				   GLuint *elts,
-				   int nr );
-};
-
-struct mga_context_t {
-
-   GLcontext *glCtx;
-
-
-   /* Bookkeeping for texturing 
-    */
-   int lastTexHeap;
-   struct mga_texture_object_s TexObjList[MGA_NR_TEX_HEAPS];
-   struct mga_texture_object_s SwappedOut;
-   struct mga_texture_object_s *CurrentTexObj[2];
-   memHeap_t *texHeap[MGA_NR_TEX_HEAPS];
-   int c_texupload;
-   int c_texusage;
-   int tex_thrash;
-
-
-   /* Map GL texture units onto hardware.
-    */
-   mgaUI32 multitex;
-   mgaUI32 tmu_source[2];
-   mgaUI32 tex_dest[2];
-
-
-   /* Manage fallbacks 
-    */
-   mgaUI32 IndirectTriangles;
-   int Fallback;  
-
-
-   /* Support for CVA and the fastpath 
-    */
-   unsigned int setupdone;
-   unsigned int setupindex;
-   unsigned int renderindex;
-   unsigned int using_fast_path;
-   mga_interp_func interp;
-
-
-   /* Support for limited GL_BLEND fallback
-    */
-   unsigned int blend_flags;
-   unsigned int envcolor;
-
-
-   /* Shortcircuit some state changes 
-    */
-   points_func   PointsFunc;
-   line_func     LineFunc;
-   triangle_func TriangleFunc;
-   quad_func     QuadFunc;
-
-
-   /* Manage driver and hardware state 
-    */
-   GLuint        new_state; 
-   GLuint        dirty;
-   GLuint        Setup[MGA_CTX_SETUP_SIZE];
-   GLuint        warp_pipe;
-   GLuint        vertsize;
-   GLushort      MonoColor;
-   GLushort      ClearColor;
-   GLuint        poly_stipple;
-
-   
-   /* Dma buffers
-    */
-   drmBufPtr  vertex_dma_buffer;
-   drmBufPtr  iload_buffer;
-
-   
-   /* Drawable, cliprect and scissor information
-    */
-   int dirty_cliprects;		/* which sets of cliprects are uptodate? */
-   int draw_buffer;		/* which buffer are we rendering to */
-   unsigned int drawOffset;		/* draw buffer address in  space */
-   int read_buffer;	
-   int readOffset;	
-   int drawX, drawY;		/* origin of drawable in draw buffer */
-   int lastX, lastY;		/* detect DSTORG bug */
-   GLuint numClipRects;		/* cliprects for the draw buffer */
-   XF86DRIClipRectPtr pClipRects;
-   XF86DRIClipRectRec draw_rect;
-   drm_clip_rect_t scissor_rect;
-   int scissor;
-
-
-   /* Texture aging and DMA based aging.
-    */
-   unsigned int texAge[MGA_NR_TEX_HEAPS];/* texture LRU age  */
-   unsigned int dirtyAge;		/* buffer age for synchronization */
-   unsigned int lastSwap;		/* throttling runaway apps */
-
-
-
-   /* Mirrors of some DRI state.
-    */
-   GLframebuffer *glBuffer;
-   drmContext hHWContext;
-   drmLock *driHwLock;
-   int driFd;
-   Display *display;
-   __DRIdrawablePrivate *driDrawable;
-   __DRIscreenPrivate *driScreen;
-   mgaScreenPrivate *mgaScreen; 
-   drm_mga_sarea_t *sarea;
-
-
-   /* New setupdma path
-    */
-   drmBufPtr elt_buf, retained_buf;
-   GLuint *first_elt, *next_elt;
-   GLfloat *next_vert;
-   GLuint next_vert_phys;
-   GLuint first_vert_phys;
-   struct mga_elt_tab *elt_tab;
-   GLfloat device_matrix[16];
-};
-
-
-
-
-typedef struct {
-
-	/* dma stuff */
-        mgaUI32         systemTexture;
-
-        mgaUI32         default32BitTextures;
-        
-	/* options */
-	mgaUI32		nullprims;  /* skip all primitive generation */
-        mgaUI32         noFallback;
- 	
-	/* performance counters */	
-	mgaUI32		c_textureUtilization;
-	mgaUI32		c_textureSwaps;
-	mgaUI32		c_setupPointers;
-	mgaUI32		c_triangles;
-	mgaUI32		c_points;
-	mgaUI32		c_lines;
-	mgaUI32		c_drawWaits;
-	mgaUI32		c_dmaFlush;
-	mgaUI32		c_overflows;
-
-} mgaGlx_t;
-
-extern mgaGlx_t	mgaglx;
-
-
-#define MGAPACKCOLOR555(r,g,b,a) \
-  ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
-    ((a) ? 0x8000 : 0))
-
-#define MGAPACKCOLOR565(r,g,b) \
-  ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
-
-#define MGAPACKCOLOR888(r,g,b) \
-  (((r) << 16) | ((g) << 8) | (b))
-
-#define MGAPACKCOLOR8888(r,g,b,a) \
-  (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
-
-#define MGAPACKCOLOR4444(r,g,b,a) \
-  ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-
-
-#define MGA_DEBUG 0   
-#ifndef MGA_DEBUG
-extern int MGA_DEBUG;
-#endif
-
-#define DEBUG_ALWAYS_SYNC    0x1
-#define DEBUG_VERBOSE_MSG    0x2
-#define DEBUG_VERBOSE_LRU    0x4
-#define DEBUG_VERBOSE_DRI    0x8
-#define DEBUG_VERBOSE_IOCTL  0x10
-#define DEBUG_VERBOSE_2D     0x20
-
-static __inline__ mgaUI32 mgaPackColor(mgaUI32 format,
-				       mgaUI8 r, mgaUI8 g, 
-				       mgaUI8 b, mgaUI8 a)
-{
-  switch (format & MGA_PF_MASK) {
-  case MGA_PF_555:
-    return MGAPACKCOLOR555(r,g,b,a);
-  case MGA_PF_565:
-    return MGAPACKCOLOR565(r,g,b);
-  case MGA_PF_888:
-    return MGAPACKCOLOR888(r,g,b);
-  case MGA_PF_8888:
-    return MGAPACKCOLOR8888(r,g,b,a);
-  default:
-    return 0;
-  }
-}
-
-
-/*
- * Subpixel offsets for window coordinates:
- */
-#define SUBPIXEL_X (-0.5F)
-#define SUBPIXEL_Y (-0.5F + 0.125)
-
-
-#endif
Index: xc/lib/GL/mesa/src/drv/mga/mgalog.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgalog.h:1.1 xc/lib/GL/mesa/src/drv/mga/mgalog.h:removed
--- xc/lib/GL/mesa/src/drv/mga/mgalog.h:1.1	Fri Feb 11 12:25:38 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgalog.h	Mon Dec 18 14:23:33 2000
@@ -1,47 +0,0 @@
-/*
- * GLX Hardware Device Driver for Matrox Millenium G200
- * Copyright (C) 1999 Wittawat Yamwong
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
- */
- 
-/* Usage:
- * - use mgaError for error messages. Always write to X error and log file.
- * - use mgaMsg for debugging. Can be disabled by undefining MGA_LOG_ENABLED.
- */
- 
-#ifndef MGALOG_INC
-#define MGALOG_INC
-#include "hwlog.h"
-
-/* Mapping between old function names and new common code: */
-/* (Feel free to replace all mgaMsg with hwMsg etc. in all *.c
- * files, I was to lazy to do this...) */
-#define mgaOpenLog(f) 	hwOpenLog(f,"[mga] ")
-#define mgaCloseLog 	hwCloseLog
-#define mgaIsLogReady 	hwIsLogReady
-#define mgaSetLogLevel  hwSetLogLevel
-#define mgaGetLogLevel  hwGetLogLevel
-#define mgaMsg		hwMsg
-#define mgaError	hwError
-
-#endif
Index: xc/lib/GL/mesa/src/drv/mga/mgapipeline.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgapipeline.c:1.1 xc/lib/GL/mesa/src/drv/mga/mgapipeline.c:1.3
--- xc/lib/GL/mesa/src/drv/mga/mgapipeline.c:1.1	Fri Feb 11 12:25:38 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgapipeline.c	Tue Sep 26 11:56:47 2000
@@ -1,9 +1,9 @@
-/*  #include "mgapipeline.h" */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgapipeline.c,v 1.3 2000/09/26 15:56:47 tsi Exp $ */
 
 #include <stdio.h>
 #include "mgavb.h"
 #include "mgadd.h"
-#include "mgalib.h"
+#include "mgacontext.h"
 #include "mgatris.h"
 #include "mgapipeline.h"
 #include "fog.h"
Index: xc/lib/GL/mesa/src/drv/mga/mgaspan.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgaspan.c:1.2 xc/lib/GL/mesa/src/drv/mga/mgaspan.c:1.5
--- xc/lib/GL/mesa/src/drv/mga/mgaspan.c:1.2	Fri Jun 16 20:03:02 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgaspan.c	Sun Sep 24 09:51:07 2000
@@ -1,9 +1,10 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaspan.c,v 1.5 2000/09/24 13:51:07 alanh Exp $ */
+
 #include "types.h"
 #include "mgadd.h"
-#include "mgalib.h"
-#include "mgadma.h"
-#include "mgalog.h"
+#include "mgacontext.h"
 #include "mgaspan.h"
+#include "mgaioctl.h"
 
 #define DBG 0
 
@@ -16,13 +17,13 @@
    GLuint height = dPriv->h;				\
    char *read_buf = (char *)(sPriv->pFB +		\
 			mmesa->readOffset +		\
-			dPriv->x * 2 +			\
-			dPriv->y * pitch);              \
+			dPriv->x * mgaScreen->cpp +	\
+			dPriv->y * pitch);		\
    char *buf = (char *)(sPriv->pFB +			\
 			mmesa->drawOffset +		\
-			dPriv->x * 2 +			\
-			dPriv->y * pitch);              \
-   GLushort p = MGA_CONTEXT( ctx )->MonoColor;          \
+			dPriv->x * mgaScreen->cpp +	\
+			dPriv->y * pitch);		\
+   GLushort p = MGA_CONTEXT( ctx )->MonoColor;		\
    (void) read_buf; (void) buf; (void) p
    
 
@@ -38,6 +39,8 @@
 			dPriv->x * 2 +			\
 			dPriv->y * pitch)
 
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS 
+
 #define INIT_MONO_PIXEL(p) 
 
 #define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
@@ -107,29 +110,33 @@
 
 
 
-/* 15 bit, 555 rgb color spanline and pixel functions
- */
-#define WRITE_RGBA( _x, _y, r, g, b, a )			\
-   *(GLushort *)(buf + _x*2 + _y*pitch)  = (((r & 0xf8) << 7) |	\
-		                            ((g & 0xf8) << 3) |	\
-                         		    ((b & 0xf8) >> 3))
-#define WRITE_PIXEL( _x, _y, p )  \
-   *(GLushort *)(buf + _x*2 + _y*pitch)  = p
 
-#define READ_RGBA( rgba, _x, _y )				\
-do {								\
-   GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch);	\
-   rgba[0] = (p >> 7) & 0xf8;					\
-   rgba[1] = (p >> 3) & 0xf8;					\
-   rgba[2] = (p << 3) & 0xf8;					\
-   rgba[3] = 255;						\
-} while(0)
+/* 32 bit, 8888 argb color spanline and pixel functions
+ */
+#define WRITE_RGBA(_x, _y, r, g, b, a)			\
+    *(GLuint *)(buf + _x*4 + _y*pitch) = ((r << 16) |	\
+					  (g << 8)  |	\
+					  (b << 0)  |	\
+					  (a << 24) )
+
+#define WRITE_PIXEL(_x, _y, p)			\
+    *(GLuint *)(buf + _x*4 + _y*pitch) = p
+
+#define READ_RGBA(rgba, _x, _y)					\
+    do {							\
+	GLuint p = *(GLuint *)(read_buf + _x*4 + _y*pitch);	\
+	rgba[0] = (p >> 16) & 0xff;				\
+	rgba[1] = (p >> 8)  & 0xff;				\
+	rgba[2] = (p >> 0)  & 0xff;				\
+	rgba[3] = (p >> 24) & 0xff;				\
+    } while (0)
 
-#define TAG(x) mga##x##_555
+#define TAG(x) mga##x##_8888
 #include "spantmp.h"
 
 
 
+
 /* 16 bit depthbuffer functions.
  */
 #define WRITE_DEPTH( _x, _y, d )	\
@@ -144,9 +151,57 @@
 
 
 
+/* 32 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH( _x, _y, d )	\
+   *(GLuint *)(buf + _x*4 + _y*pitch) = d;
+
+#define READ_DEPTH( d, _x, _y )		\
+   d = *(GLuint *)(buf + _x*4 + _y*pitch);	
+
+#define TAG(x) mga##x##_32
+#include "depthtmp.h"
+
+
+
+/* 24/8 bit interleaved depth/stencil functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) {			\
+   GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch);	\
+   tmp &= 0xff;						\
+   tmp |= (d) & 0xffffff00;				\
+   *(GLuint *)(buf + _x*4 + _y*pitch) = tmp;		\
+}
+
+#define READ_DEPTH( d, _x, _y )		\
+   d = *(GLuint *)(buf + _x*4 + _y*pitch) >> 8;	
+
+
+#define TAG(x) mga##x##_24_8
+#include "depthtmp.h"
+
+#define WRITE_STENCIL( _x, _y, d ) {			\
+   GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch);	\
+   tmp &= 0xffffff00;					\
+   tmp |= d & 0xff;					\
+   *(GLuint *)(buf + _x*4 + _y*pitch) = tmp;		\
+}
+
+#define READ_STENCIL( d, _x, _y )		\
+   d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff;	
+
+#define TAG(x) mga##x##_24_8
+#include "stenciltmp.h"
+
+
+
+
 void mgaDDInitSpanFuncs( GLcontext *ctx )
 {
-   if (1) {
+   mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+   switch (mmesa->mgaScreen->cpp) {
+   case 2:
       ctx->Driver.WriteRGBASpan = mgaWriteRGBASpan_565;
       ctx->Driver.WriteRGBSpan = mgaWriteRGBSpan_565;
       ctx->Driver.WriteMonoRGBASpan = mgaWriteMonoRGBASpan_565;
@@ -154,26 +209,47 @@
       ctx->Driver.WriteMonoRGBAPixels = mgaWriteMonoRGBAPixels_565;
       ctx->Driver.ReadRGBASpan = mgaReadRGBASpan_565;
       ctx->Driver.ReadRGBAPixels = mgaReadRGBAPixels_565;
-   } else {
-      ctx->Driver.WriteRGBASpan = mgaWriteRGBASpan_555;
-      ctx->Driver.WriteRGBSpan = mgaWriteRGBSpan_555;
-      ctx->Driver.WriteMonoRGBASpan = mgaWriteMonoRGBASpan_555;
-      ctx->Driver.WriteRGBAPixels = mgaWriteRGBAPixels_555;
-      ctx->Driver.WriteMonoRGBAPixels = mgaWriteMonoRGBAPixels_555;
-      ctx->Driver.ReadRGBASpan = mgaReadRGBASpan_555;
-      ctx->Driver.ReadRGBAPixels = mgaReadRGBAPixels_555;
+
+      ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_16;
+      ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_16;
+      ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_16;
+      ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_16;
+      break;
+
+   case 4:
+      ctx->Driver.WriteRGBASpan = mgaWriteRGBASpan_8888;
+      ctx->Driver.WriteRGBSpan = mgaWriteRGBSpan_8888;
+      ctx->Driver.WriteMonoRGBASpan = mgaWriteMonoRGBASpan_8888;
+      ctx->Driver.WriteRGBAPixels = mgaWriteRGBAPixels_8888;
+      ctx->Driver.WriteMonoRGBAPixels = mgaWriteMonoRGBAPixels_8888;
+      ctx->Driver.ReadRGBASpan = mgaReadRGBASpan_8888;
+      ctx->Driver.ReadRGBAPixels = mgaReadRGBAPixels_8888;
+      
+      if (mmesa->hw_stencil) {
+	 ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_32;
+	 ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_32;
+	 ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_32;
+	 ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_32;
+      } else {
+	 ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_24_8;
+	 ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_24_8;
+	 ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_24_8;
+	 ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_24_8;
+
+	 ctx->Driver.ReadStencilSpan = mgaReadStencilSpan_24_8;
+	 ctx->Driver.WriteStencilSpan = mgaWriteStencilSpan_24_8;
+	 ctx->Driver.ReadStencilPixels = mgaReadStencilPixels_24_8;
+	 ctx->Driver.WriteStencilPixels = mgaWriteStencilPixels_24_8;
+      }
+      break;
    }
+
 
-   ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_16;
-   ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_16;
-   ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_16;
-   ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_16;
-
-   ctx->Driver.WriteCI8Span        =NULL;
-   ctx->Driver.WriteCI32Span       =NULL;
-   ctx->Driver.WriteMonoCISpan     =NULL;
-   ctx->Driver.WriteCI32Pixels     =NULL;
-   ctx->Driver.WriteMonoCIPixels   =NULL;
-   ctx->Driver.ReadCI32Span        =NULL;
-   ctx->Driver.ReadCI32Pixels      =NULL;
+   ctx->Driver.WriteCI8Span = 0;
+   ctx->Driver.WriteCI32Span = 0;
+   ctx->Driver.WriteMonoCISpan = 0;
+   ctx->Driver.WriteCI32Pixels = 0;
+   ctx->Driver.WriteMonoCIPixels = 0;
+   ctx->Driver.ReadCI32Span = 0;
+   ctx->Driver.ReadCI32Pixels = 0;
 }
Index: xc/lib/GL/mesa/src/drv/mga/mgastate.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgastate.c:1.3 xc/lib/GL/mesa/src/drv/mga/mgastate.c:1.6
--- xc/lib/GL/mesa/src/drv/mga/mgastate.c:1.3	Wed Jun 21 08:10:59 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgastate.c	Wed Nov  8 00:02:46 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgastate.c,v 1.3 2000/06/21 12:10:59 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgastate.c,v 1.6 2000/11/08 05:02:46 dawes Exp $ */
 
 #include <stdio.h>
 
@@ -7,17 +7,181 @@
 #include "dd.h"
 
 #include "mm.h"
-#include "mgalib.h"
+#include "mgacontext.h"
 #include "mgadd.h"
 #include "mgastate.h"
-#include "mgadepth.h"
 #include "mgatex.h"
-#include "mgalog.h"
 #include "mgavb.h"
 #include "mgatris.h"
 #include "mgaregs.h"
 #include "mgabuffers.h"
 
+/* Some outstanding problems with accelerating logic ops...
+ */
+#if defined(ACCEL_ROP)
+static GLuint mgarop_NoBLK[16] = {
+   DC_atype_rpl  | 0x00000000, DC_atype_rstr | 0x00080000, 
+   DC_atype_rstr | 0x00040000, DC_atype_rpl  | 0x000c0000,
+   DC_atype_rstr | 0x00020000, DC_atype_rstr | 0x000a0000, 
+   DC_atype_rstr | 0x00060000, DC_atype_rstr | 0x000e0000,
+   DC_atype_rstr | 0x00010000, DC_atype_rstr | 0x00090000, 
+   DC_atype_rstr | 0x00050000, DC_atype_rstr | 0x000d0000,
+   DC_atype_rpl  | 0x00030000, DC_atype_rstr | 0x000b0000, 
+   DC_atype_rstr | 0x00070000, DC_atype_rpl  | 0x000f0000
+};
+#endif
+
+
+static void mgaUpdateStencil(const GLcontext *ctx)
+{
+   mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+   GLuint stencil = 0, stencilctl = 0;
+
+   if (ctx->Stencil.Enabled)
+   {
+      stencil = ctx->Stencil.Ref | 
+	 ( ctx->Stencil.ValueMask << 8 ) |
+	 ( ctx->Stencil.WriteMask << 16 );
+     		
+      switch (ctx->Stencil.Function)
+      {
+      case GL_NEVER:
+	 MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_snever);
+	 break;
+      case GL_LESS:
+	 MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_slt);
+	 break;
+      case GL_LEQUAL:
+	 MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_slte);
+	 break;
+      case GL_GREATER:
+	 MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_sgt);
+	 break;
+      case GL_GEQUAL:
+	 MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_sgte);
+	 break;
+      case GL_NOTEQUAL:
+	 MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_sne);
+	 break;
+      case GL_EQUAL:
+	 MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_se);
+	 break;
+      case GL_ALWAYS:
+	 MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_salways);
+      default:
+	 break;
+      }
+       
+      switch (ctx->Stencil.FailFunc)
+      {     
+      case GL_KEEP:
+	 MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_keep);
+	 break;
+      case GL_ZERO:
+	 MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_zero);
+	 break;
+      case GL_REPLACE:
+	 MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_replace);
+	 break;
+      case GL_INCR:
+	 MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_incrsat);
+	 break;
+      case GL_DECR:
+	 MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_decrsat);
+	 break;
+      case GL_INVERT:
+	 MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_invert);
+	 break;
+      default:
+	 break;
+      }
+       
+      switch (ctx->Stencil.ZFailFunc)
+      {     
+      case GL_KEEP:
+	 MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_keep);
+	 break;
+      case GL_ZERO:
+	 MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_zero);
+	 break;
+      case GL_REPLACE:
+	 MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_replace);
+	 break;
+      case GL_INCR:
+	 MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_incrsat);
+	 break;
+      case GL_DECR:
+	 MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_decrsat);
+	 break;
+      case GL_INVERT:
+	 MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_invert);
+	 break;
+      default:
+	 break;
+      }
+       
+      switch (ctx->Stencil.ZPassFunc)
+      {     
+      case GL_KEEP:
+	 MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_keep);
+	 break;
+      case GL_ZERO:
+	 MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_zero);
+	 break;
+      case GL_REPLACE:
+	 MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_replace);
+	 break;
+      case GL_INCR:
+	 MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_incrsat);
+	 break;
+      case GL_DECR:
+	 MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_decrsat);
+	 break;
+      case GL_INVERT:
+	 MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_invert);
+	 break;
+      default:
+	 break;
+      }
+   }
+
+   mmesa->Setup[MGA_CTXREG_STENCIL] = stencil;
+   mmesa->Setup[MGA_CTXREG_STENCILCTL] = stencilctl;
+   mmesa->dirty |= MGA_UPLOAD_CTX;
+}
+
+static void mgaDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, 
+			     GLuint mask) 
+{
+   FLUSH_BATCH( MGA_CONTEXT(ctx) );
+   MGA_CONTEXT(ctx)->new_state |= MGA_NEW_STENCIL;
+}
+
+static void mgaDDStencilMask(GLcontext *ctx, GLuint mask) 
+{
+   FLUSH_BATCH( MGA_CONTEXT(ctx) );
+   MGA_CONTEXT(ctx)->new_state |= MGA_NEW_STENCIL;
+}
+
+static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail, 
+			   GLenum zpass) 
+{
+   FLUSH_BATCH( MGA_CONTEXT(ctx) );
+   MGA_CONTEXT(ctx)->new_state |= MGA_NEW_STENCIL;
+}
+
+static void mgaDDClearDepth(GLcontext *ctx, GLclampd d)
+{
+    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+    switch (mmesa->Setup[MGA_CTXREG_MACCESS] & MA_zwidth_MASK) {
+    case MA_zwidth_16: mmesa->ClearDepth = d * 0x0000ffff; break;
+    case MA_zwidth_24: mmesa->ClearDepth = d * 0xffffff00; break;
+    case MA_zwidth_32: mmesa->ClearDepth = d * 0xffffffff; break;
+    default: return;
+    }
+}
+
 static void mgaUpdateZMode(const GLcontext *ctx)
 {
    mgaContextPtr mmesa = MGA_CONTEXT( ctx );
@@ -51,8 +215,16 @@
    } else {
       zmode |= DC_zmode_nozcmp | DC_atype_i;
    }
+
+#if defined(ACCEL_ROP)
+   mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_bop_MASK;
+   if (ctx->Color.ColorLogicOpEnabled) 
+      zmode |= mgarop_NoBLK[(ctx->Color.LogicOp)&0xf];
+   else 
+      zmode |= mgarop_NoBLK[GL_COPY & 0xf];
+#endif
 
-   mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_zmode_MASK & DC_atype_MASK;
+   mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_zmode_MASK & DC_atype_MASK; 
    mmesa->Setup[MGA_CTXREG_DWGCTL] |= zmode;
    mmesa->dirty |= MGA_UPLOAD_CTX;
 }
@@ -99,11 +271,8 @@
 
 static void mgaDDShadeModel(GLcontext *ctx, GLenum mode)
 {
-   if (1) {
-      FLUSH_BATCH( MGA_CONTEXT(ctx) );
-      MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; 
-      mgaMsg(8, "mgaDDShadeModel: %x\n", mode);
-   }
+   FLUSH_BATCH( MGA_CONTEXT(ctx) );
+   MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; 
 }
 
 
@@ -118,17 +287,35 @@
    FLUSH_BATCH( MGA_CONTEXT(ctx) );
    MGA_CONTEXT(ctx)->new_state |= MGA_NEW_DEPTH;
 }
-
 
+#if defined(ACCEL_ROP)
+static void mgaDDLogicOp( GLcontext *ctx, GLenum opcode )
+{
+   FLUSH_BATCH( MGA_CONTEXT(ctx) );
+   MGA_CONTEXT(ctx)->new_state |= MGA_NEW_DEPTH;
+}
+#else
+static void mgaDDLogicOp( GLcontext *ctx, GLenum opcode )
+{
+   if (ctx->Color.ColorLogicOpEnabled) {
+      FLUSH_BATCH( MGA_CONTEXT(ctx) );
+   
+      if (opcode == GL_COPY)
+	 MGA_CONTEXT(ctx)->Fallback &= ~MGA_FALLBACK_LOGICOP;
+      else
+	 MGA_CONTEXT(ctx)->Fallback |= MGA_FALLBACK_LOGICOP;
+   }
+}
+#endif
 
 
 static void mgaUpdateFogAttrib( GLcontext *ctx )
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
 
-   mgaUI32 color = MGAPACKCOLOR888((mgaUI8)(ctx->Fog.Color[0]*255.0F), 
-				   (mgaUI8)(ctx->Fog.Color[1]*255.0F), 
-				   (mgaUI8)(ctx->Fog.Color[2]*255.0F));
+   GLuint color = MGAPACKCOLOR888((GLubyte)(ctx->Fog.Color[0]*255.0F), 
+				   (GLubyte)(ctx->Fog.Color[1]*255.0F), 
+				   (GLubyte)(ctx->Fog.Color[2]*255.0F));
 
    if (color != mmesa->Setup[MGA_CTXREG_FOGCOLOR]) 
       mmesa->Setup[MGA_CTXREG_FOGCOLOR] = color;
@@ -161,7 +348,7 @@
    int a = 0;
 
    /* determine source of alpha for blending and testing */
-   if ( !ctx->Texture.Enabled ) 
+   if ( !ctx->Texture.ReallyEnabled ) 
       a |= AC_alphasel_diffused;
    else {
       switch (ctx->Texture.Unit[0].EnvMode) {
@@ -231,13 +418,13 @@
       case GL_ONE_MINUS_SRC_ALPHA:
 	 a |= AC_src_om_src_alpha; break;
       case GL_DST_ALPHA:
-	 if (mgaScreen->Attrib & MGA_PF_HASALPHA)
+	 if (mgaScreen->cpp == 4)
 	    a |= AC_src_dst_alpha;
 	 else
 	    a |= AC_src_one;
 	 break;
       case GL_ONE_MINUS_DST_ALPHA:
-	 if (mgaScreen->Attrib & MGA_PF_HASALPHA)
+	 if (mgaScreen->cpp == 4)
 	    a |= AC_src_om_dst_alpha; 
 	 else 
 	    a |= AC_src_zero;
@@ -263,13 +450,13 @@
       case GL_ONE_MINUS_SRC_COLOR:
 	 a |= AC_dst_om_src_color; break;
       case GL_DST_ALPHA:
-	 if (mgaScreen->Attrib & MGA_PF_HASALPHA)
+	 if (mgaScreen->cpp == 4)
 	    a |= AC_dst_dst_alpha;
 	 else
 	    a |= AC_dst_one;
 	 break;
       case GL_ONE_MINUS_DST_ALPHA:
-	 if (mgaScreen->Attrib & MGA_PF_HASALPHA)
+	 if (mgaScreen->cpp == 4)
 	    a |= AC_dst_om_dst_alpha;
 	 else
 	    a |= AC_dst_zero;
@@ -355,8 +542,7 @@
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
 
-   mmesa->MonoColor = mgaPackColor( mmesa->mgaScreen->Attrib,
-				      r, g, b, a );
+   mmesa->MonoColor = mgaPackColor( mmesa->mgaScreen->cpp, r, g, b, a );
 }
 
 
@@ -366,8 +552,7 @@
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
 
-   mmesa->ClearColor = mgaPackColor( mmesa->mgaScreen->Attrib,
-				      r, g, b, a );
+   mmesa->ClearColor = mgaPackColor( mmesa->mgaScreen->cpp, r, g, b, a );
 }
 
 
@@ -394,7 +579,7 @@
 	 mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE);
       if (ctx->Polygon.FrontFace != GL_CCW)
 	 mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE);
-      if (mmesa->multitex)
+      if (mmesa->warp_pipe & MGA_TEX1_BIT) 
 	 mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); /* why??? */
    }
 
@@ -426,19 +611,14 @@
    mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;	
 
 
-   GLuint mask = mgaPackColor(mgaScreen->Attrib,
+   GLuint mask = mgaPackColor(mgaScreen->cpp,
 			      ctx->Color.ColorMask[RCOMP],
 			      ctx->Color.ColorMask[GCOMP],
 			      ctx->Color.ColorMask[BCOMP],
 			      ctx->Color.ColorMask[ACOMP]);
   
-   switch (mgaScreen->Attrib & MGA_PF_MASK)
-   {
-   case MGA_PF_555:
-   case MGA_PF_565:
+   if (mgaScreen->cpp == 2)
       mask = mask | (mask << 16);
-      break;
-   }
 
    if (mmesa->Setup[MGA_CTXREG_PLNWT] != mask) {
       FLUSH_BATCH( MGA_CONTEXT(ctx) );
@@ -530,9 +710,6 @@
 /* =============================================================
  */
 
-
-
-
 static void mgaDDPrintDirty( const char *msg, GLuint state )
 {
    fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s\n",
@@ -548,11 +725,80 @@
 	   );
 }
 
+/*  static int tex0[11] = { */
+/*     0x2050003, */
+/*     0x90,	 */
+/*     0x82100000, */
+/*     0x0, */
+/*     0xc6d000, */
+/*     0xc7d000, */
+/*     0xc81000, */
+/*     0xc82000, */
+/*     0xc82400, */
+/*     0x3fc7413, */
+/*     0x1fc7612 */
+/*  }; */
+
+/*  static int tex1[11] = { */
+/*     0x2040003, */
+/*     0x90, */
+/*     0x82100000, */
+/*     0x0, */
+/*     0xc82500, */
+/*     0xc8a500, */
+/*     0xc8c500, */
+/*     0xc8cd00, */
+/*     0xc8cf00, */
+/*     0x1fc7612, */
+/*     0x1fc7612 */
+/*  }; */
+
+/*  static int tex0_single[11] = { */
+/*     0x2040003, */
+/*     0x10, */
+/*     0x82100000, */
+/*     0x0, */
+/*     0x196d000, */
+/*     0x1975000, */
+/*     0x1977000, */
+/*     0x1977800, */
+/*     0x1977a00, */
+/*     0x1fc7612, */
+/*     0x1fc7612, */
+/*  }; */
+
+/*  static int ctx_single[] = { */
+/*     0x727000, */
+/*     0x1, */
+/*     0xffffffff, */
+/*     0xc4436, */
+/*     0x101, */
+/*     0x7fff7f, */
+/*     0x0, */
+/*     0x0, */
+/*     0x0, */
+/*     0x0 */
+/*  }; */
+
+/*  static int ctx_multi[] = { */
+/*     0x727000, */
+/*     0x1, */
+/*     0xffffffff, */
+/*     0xc4076, */
+/*     0x2000101, */
+/*     0x0, */
+/*     0x0, */
+/*     0xc0600000, */
+/*     0xc3600013, */
+/*     0x0 */
+/*  }; */
 
 /* Push the state into the sarea and/or texture memory.
  */
 void mgaEmitHwStateLocked( mgaContextPtr mmesa )
 {
+   drm_mga_sarea_t *sarea = mmesa->sarea;
+
    if (MGA_DEBUG & DEBUG_VERBOSE_MSG)
       mgaDDPrintDirty( "mgaEmitHwStateLocked", mmesa->dirty );
 
@@ -562,31 +808,40 @@
    if ((mmesa->dirty & MGA_UPLOAD_TEX1IMAGE) && mmesa->CurrentTexObj[1])
       mgaUploadTexImages(mmesa, mmesa->CurrentTexObj[1]);
   
-   if (mmesa->dirty & MGA_UPLOAD_CTX) 
-      memcpy( mmesa->sarea->ContextState, 
-	      mmesa->Setup,
-	      sizeof(mmesa->Setup));
-
-   if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0])
-	 memcpy(mmesa->sarea->TexState[0],
-		mmesa->CurrentTexObj[0]->Setup,
-		sizeof(mmesa->sarea->TexState[0]));
-
-   if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1])
-	 memcpy(mmesa->sarea->TexState[1],
-		mmesa->CurrentTexObj[1]->Setup,
-		sizeof(mmesa->sarea->TexState[1]));
+   if (mmesa->dirty & MGA_UPLOAD_CTX) {
+      memcpy( sarea->ContextState, mmesa->Setup, sizeof(mmesa->Setup));
+   }
+
+   if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0]) {
+      memcpy(sarea->TexState[0],
+	     mmesa->CurrentTexObj[0]->Setup,
+	     sizeof(sarea->TexState[0]));
+   }
 
-   mmesa->sarea->WarpPipe = ((mmesa->setupindex & MGA_WARP_T2GZSAF) | 
-			     MGA_ALPHA_BIT | MGA_SPEC_BIT | MGA_FOG_BIT);
+   if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1]) {
+      memcpy(sarea->TexState[1],
+	     mmesa->CurrentTexObj[1]->Setup,
+	     sizeof(sarea->TexState[1]));
+   }
 
+   if (sarea->TexState[0][MGA_TEXREG_CTL2] !=
+       sarea->TexState[1][MGA_TEXREG_CTL2]) {
+      memcpy(sarea->TexState[1],
+	     sarea->TexState[0],
+	     sizeof(sarea->TexState[0]));      
+      mmesa->dirty |= MGA_UPLOAD_TEX1|MGA_UPLOAD_TEX0;
+   }
 
+   mmesa->sarea->WarpPipe = mmesa->warp_pipe;
+   mmesa->sarea->vertexsize = mmesa->vertsize;
+/*     mmesa->sarea->vertexsize = 10; */
    mmesa->sarea->dirty |= mmesa->dirty;
 
 #if 0
-   mgaPrintSetupFlags("warp pipe", mmesa->sarea->WarpPipe);
-   fprintf(stderr, "in mgaEmitHwStateLocked: dirty now %x\n",
-	   mmesa->sarea->dirty);
+   if (mmesa->dirty & MGA_UPLOAD_PIPE) 
+      mgaPrintSetupFlags("warp pipe", mmesa->sarea->WarpPipe);
+/*     fprintf(stderr, "in mgaEmitHwStateLocked: dirty now %x\n", */
+/*  	   mmesa->sarea->dirty); */
 #endif
 
    mmesa->dirty &= (MGA_UPLOAD_CLIPRECTS|MGA_WAIT_AGE);
@@ -631,7 +886,7 @@
    case GL_TEXTURE_2D:
    case GL_TEXTURE_3D:
       FLUSH_BATCH( mmesa );
-      mmesa->new_state |= MGA_NEW_TEXTURE;
+      mmesa->new_state |= (MGA_NEW_TEXTURE|MGA_NEW_ALPHA);
       break;
    case GL_POLYGON_STIPPLE:
       if ((ctx->Driver.TriangleCaps & DD_TRI_STIPPLE) &&
@@ -644,8 +899,27 @@
 	    mmesa->Setup[MGA_CTXREG_DWGCTL] |= mmesa->poly_stipple;
       }
       break;
-   default:
+   case GL_COLOR_LOGIC_OP:
+   case GL_INDEX_LOGIC_OP:
+      FLUSH_BATCH( mmesa );
+#if !defined(ACCEL_ROP)
+      mmesa->Fallback &= ~MGA_FALLBACK_LOGICOP;
+      if (state && ctx->Color.LogicOp != GL_COPY)
+	 mmesa->Fallback |= MGA_FALLBACK_LOGICOP;
+#else
+      mmesa->new_state |= MGA_NEW_DEPTH;
+#endif
       break;
+   case GL_STENCIL_TEST:
+      FLUSH_BATCH( mmesa );
+      if (mmesa->hw_stencil) 
+	 mmesa->new_state |= MGA_NEW_STENCIL;
+      else if (state)
+	 mmesa->Fallback |= MGA_FALLBACK_STENCIL;
+      else
+	 mmesa->Fallback &= ~MGA_FALLBACK_STENCIL;
+   default:
+      break; 
    }    
 }
 
@@ -662,10 +936,15 @@
    int index = mmesa->setupindex;
  
    index &= ~(MGA_WIN_BIT|MGA_TEX0_BIT|MGA_RGBA_BIT);
-   index |= MGA_ALPHA_BIT;
+   index |= (MGA_ALPHA_BIT | 
+	     MGA_SPEC_BIT | 
+	     MGA_FOG_BIT | 
+/*  	     MGA_TEX1_BIT | */
+	     0);
 
    if (index != mmesa->warp_pipe)
    {
+      FLUSH_BATCH(mmesa);      
       mmesa->warp_pipe = index;
       mmesa->new_state |= MGA_NEW_WARP;
       mmesa->dirty |= MGA_UPLOAD_PIPE;
@@ -679,7 +958,7 @@
 
 static void mgaDDPrintState( const char *msg, GLuint state )
 {
-   mgaMsg(1, "%s (0x%x): %s%s%s%s%s%s%s%s\n",
+   fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s%s\n",
 	   msg,
 	   state,
 	   (state & MGA_NEW_DEPTH)   ? "depth, " : "",
@@ -718,6 +997,9 @@
       if (new_state & MGA_NEW_CLIP)
 	 mgaUpdateClipping(ctx);
 
+      if (new_state & MGA_NEW_STENCIL) 
+	mgaUpdateStencil(ctx);
+
       if (new_state & (MGA_NEW_WARP|MGA_NEW_CULL))
 	 mgaUpdateCull(ctx);
 
@@ -741,6 +1023,7 @@
 
    if (ctx->Polygon.StippleFlag && (ctx->Driver.TriangleCaps & DD_TRI_STIPPLE))
    {
+      mmesa->dirty |= MGA_UPLOAD_CTX;
       mmesa->Setup[MGA_CTXREG_DWGCTL] &= ~(0xf<<20);
       if (ctx->PB->primitive == GL_POLYGON)
 	 mmesa->Setup[MGA_CTXREG_DWGCTL] |= mmesa->poly_stipple;
@@ -756,7 +1039,6 @@
 void mgaDDUpdateState( GLcontext *ctx )
 {
    mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-   mgaglx.c_setupPointers++;
    
    if (ctx->NewState & INTERESTED) {
       mgaDDChooseRenderState(ctx);  
@@ -804,16 +1086,50 @@
       mmesa->Setup[MGA_CTXREG_DSTORG] = mgaScreen->frontOffset;
    }
 
-/*     mmesa->Setup[MGA_CTXREG_MACCESS] = mgaScreen->mAccess; */
-/*     mmesa->Setup[MGA_CTXREG_DWGCTL] = ( DC_clipdis_disable |  */
-/*  				       (0xC << DC_bop_SHIFT) | */
-/*  				       DC_shftzero_enable |  */
-/*  				       DC_zmode_nozcmp |  */
-/*  				       DC_atype_zi ); */
-
+   switch (mmesa->glCtx->Visual->DepthBits) {
+   case 16:
+      mmesa->Setup[MGA_CTXREG_MACCESS] = (MA_pwidth_16 |
+					  MA_zwidth_16 | /* 1bit stencil? */
+					  MA_memreset_disable |
+					  MA_fogen_disable |
+					  MA_tlutload_disable |
+					  MA_nodither_disable |
+					  MA_dit555_disable);
+      break;
+   case 24:
+      mmesa->Setup[MGA_CTXREG_MACCESS] = (MA_pwidth_32 |
+					  MA_zwidth_24 | 
+					  MA_memreset_disable |
+					  MA_fogen_disable |
+					  MA_tlutload_disable |
+					  MA_nodither_enable |
+					  MA_dit555_disable);
+      break;
+   case 32:
+      mmesa->Setup[MGA_CTXREG_MACCESS] = (MA_pwidth_32 |
+					  MA_zwidth_32 | 
+					  MA_memreset_disable |
+					  MA_fogen_disable |
+					  MA_tlutload_disable |
+					  MA_nodither_enable |
+					  MA_dit555_disable);
+      break;
+   }
 
-   mmesa->Setup[MGA_CTXREG_MACCESS] = 0x1;
-   mmesa->Setup[MGA_CTXREG_DWGCTL] = 0xc4074;
+   mmesa->Setup[MGA_CTXREG_DWGCTL] = (DC_opcod_trap |
+				      DC_atype_i |
+				      DC_linear_xy |
+				      DC_zmode_nozcmp |
+				      DC_solid_disable |
+				      DC_arzero_disable |
+				      DC_sgnzero_disable |
+				      DC_shftzero_enable |
+				      (0xC << DC_bop_SHIFT) |
+				      (0x0 << DC_trans_SHIFT) |
+				      DC_bltmod_bmonolef |
+				      DC_pattern_disable |
+				      DC_transc_disable |
+				      DC_clipdis_disable);
 
 
    mmesa->Setup[MGA_CTXREG_PLNWT] = ~0;
@@ -863,13 +1179,18 @@
    ctx->Driver.SetReadBuffer = mgaDDSetReadBuffer;
    ctx->Driver.Color = mgaDDSetColor;
    ctx->Driver.ClearColor = mgaDDClearColor;
+   ctx->Driver.ClearDepth = mgaDDClearDepth;
    ctx->Driver.Dither = mgaDDDither;
+   ctx->Driver.LogicOpcode = mgaDDLogicOp;
 
    ctx->Driver.PolygonStipple = mgaDDPolygonStipple;
 
+   ctx->Driver.StencilFunc = mgaDDStencilFunc;
+   ctx->Driver.StencilMask = mgaDDStencilMask;
+   ctx->Driver.StencilOp = mgaDDStencilOp;
+
    ctx->Driver.Index = 0;
    ctx->Driver.ClearIndex = 0;
    ctx->Driver.IndexMask = 0;
-
 }
 
Index: xc/lib/GL/mesa/src/drv/mga/mgatex.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgatex.c:1.4 xc/lib/GL/mesa/src/drv/mga/mgatex.c:1.7
--- xc/lib/GL/mesa/src/drv/mga/mgatex.c:1.4	Thu Jun 22 12:59:24 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgatex.c	Wed Nov  8 00:02:46 2000
@@ -1,4 +1,3 @@
-/* -*- mode: C; c-basic-offset:8 -*- */
 /*
  * GLX Hardware Device Driver for Matrox Millenium G200
  * Copyright (C) 1999 Wittawat Yamwong
@@ -26,376 +25,122 @@
  *	9/20/99 rewrite by John Carmack <johnc@idsoftware.com>
  *      13/1/00 port to DRI by Keith Whitwell <keithw@precisioninsight.com>
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatex.c,v 1.4 2000/06/22 16:59:24 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatex.c,v 1.7 2000/11/08 05:02:46 dawes Exp $ */
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <GL/gl.h>
 
 #include "mm.h"
-#include "mgalib.h"
-#include "mgadma.h"
+#include "mgacontext.h"
 #include "mgatex.h"
-#include "mgalog.h"
 #include "mgaregs.h"
+#include "mgaioctl.h"
 
+#include "enums.h"
 #include "simple_list.h"
+#include "mem.h"
 
+#define TEX_0 1
+#define TEX_1 2
 
 /*
  * mgaDestroyTexObj
  * Free all memory associated with a texture and NULL any pointers
  * to it.
  */
-static void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ) {
-
- 	if ( !t ) return;
+void 
+mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ) 
+{
+   if ( !t ) return;
   	  	
-	/* free the texture memory */
-	if (t->MemBlock) {
-		mmFreeMem( t->MemBlock );
-		t->MemBlock = 0;
-
-		if (t->age > mmesa->dirtyAge)
-			mmesa->dirtyAge = t->age;
-	}
+   /* free the texture memory */
+   if (t->MemBlock) {
+      mmFreeMem( t->MemBlock );
+      t->MemBlock = 0;
+
+      if (t->age > mmesa->dirtyAge)
+	 mmesa->dirtyAge = t->age;
+   }
  
- 	/* free mesa's link */   
-	if (t->tObj) 
-		t->tObj->DriverData = NULL;
-
-	/* see if it was the driver's current object */
-	if (t->bound)
-		mmesa->CurrentTexObj[t->bound - 1] = 0; 
+   /* free mesa's link */   
+   if (t->tObj) 
+      t->tObj->DriverData = NULL;
+
+   /* see if it was the driver's current object */
+   if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0; 
+   if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0; 
 	
-	remove_from_list(t);
-	free( t );
-}
-
-static void mgaSwapOutTexObj(mgaContextPtr mmesa, mgaTextureObjectPtr t)
-{
-	if (t->MemBlock) {
-		mmFreeMem(t->MemBlock);
-		t->MemBlock = 0;      
-
-		if (t->age > mmesa->dirtyAge)
-			mmesa->dirtyAge = t->age;
-	}
-
-	t->dirty_images = ~0;
-	move_to_tail(&(mmesa->SwappedOut), t);
+   remove_from_list(t);
+   FREE( t );
 }
 
-
-static void mgaPrintLocalLRU( mgaContextPtr mmesa, int heap ) 
-{
-   mgaTextureObjectPtr t;
-   int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]);
-
-   fprintf(stderr, "\nLocal LRU, heap %d:\n", heap);
-
-   foreach( t, &(mmesa->TexObjList[heap]) ) {
-      if (!t->tObj)
-	 fprintf(stderr, "Placeholder %d at %x sz %x\n", 
-		 t->MemBlock->ofs / sz,
-		 t->MemBlock->ofs,
-		 t->MemBlock->size);      
-      else
-	 fprintf(stderr, "Texture (bound %d) at %x sz %x\n", 
-		 t->bound,
-		 t->MemBlock->ofs,
-		 t->MemBlock->size);      
 
-   }
-
-   fprintf(stderr, "\n\n");
-}
-
-static void mgaPrintGlobalLRU( mgaContextPtr mmesa, int heap )
+/*
+ * mgaSetTexWrappings
+ */
+static void mgaSetTexWrapping( mgaTextureObjectPtr t,
+			       GLenum sWrap, 
+			       GLenum tWrap ) 
 {
-   int i, j;
-   drm_mga_tex_region_t *list = mmesa->sarea->texList[heap];
-
-   fprintf(stderr, "\nGlobal LRU, heap %d list %p:\n", heap, list);
+   GLuint val = 0;
 
-   for (i = 0, j = MGA_NR_TEX_REGIONS ; i < MGA_NR_TEX_REGIONS ; i++) {
-      fprintf(stderr, "list[%d] age %d next %d prev %d\n",
-	      j, list[j].age, list[j].next, list[j].prev);
-      j = list[j].next;
-      if (j == MGA_NR_TEX_REGIONS) break;
-   }
-   
-   if (j != MGA_NR_TEX_REGIONS) {
-      fprintf(stderr, "Loop detected in global LRU\n\n\n");
-      for (i = 0 ; i < MGA_NR_TEX_REGIONS ; i++) {
-	      fprintf(stderr, "list[%d] age %d next %d prev %d\n",
-		      i, list[i].age, list[i].next, list[i].prev);
-      }
-   }
+   if (sWrap != GL_REPEAT) 
+      val |= TMC_clampu_enable;
    
-   fprintf(stderr, "\n\n");
-}
-
-
-static void mgaResetGlobalLRU( mgaContextPtr mmesa, GLuint heap )
-{
-   drm_mga_tex_region_t *list = mmesa->sarea->texList[heap];
-   int sz = 1 << mmesa->mgaScreen->logTextureGranularity[heap];
-   int i;
-
-   mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap];
-
-   if (0) fprintf(stderr, "mgaResetGlobalLRU %d\n", (int)heap);
-
-   /* (Re)initialize the global circular LRU list.  The last element
-    * in the array (MGA_NR_TEX_REGIONS) is the sentinal.  Keeping it
-    * at the end of the array allows it to be addressed rationally
-    * when looking up objects at a particular location in texture
-    * memory.  
-    */
-   for (i = 0 ; (i+1) * sz <= mmesa->mgaScreen->textureSize[heap] ; i++) {
-      list[i].prev = i-1;
-      list[i].next = i+1;
-      list[i].age = mmesa->sarea->texAge[heap];   
-   }
-
-   i--;
-   list[0].prev = MGA_NR_TEX_REGIONS;
-   list[i].prev = i-1;
-   list[i].next = MGA_NR_TEX_REGIONS;
-   list[MGA_NR_TEX_REGIONS].prev = i;
-   list[MGA_NR_TEX_REGIONS].next = 0;
+   if (tWrap != GL_REPEAT) 
+      val |= TMC_clampv_enable;
 
+   t->Setup[MGA_TEXREG_CTL] &= ~(TMC_clampu_enable|TMC_clampv_enable);
+   t->Setup[MGA_TEXREG_CTL] |= val;
 }
 
-
-static void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t ) 
-{
-   int i;
-   int heap = t->heap;
-   int logsz = mmesa->mgaScreen->logTextureGranularity[heap];
-   int start = t->MemBlock->ofs >> logsz;
-   int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
-   drm_mga_tex_region_t *list = mmesa->sarea->texList[heap];
-   
-   mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap];
-
-   if (!t->MemBlock) {
-	   fprintf(stderr, "no memblock\n\n");
-	   return;
-   }
-
-   /* Update our local LRU
-    */
-   move_to_head( &(mmesa->TexObjList[heap]), t );
-
-
-   if (0)
-	   fprintf(stderr, "mgaUpdateTexLRU heap %d list %p\n", heap, list);
-
-
-   /* Update the global LRU
-    */
-   for (i = start ; i <= end ; i++) {
-
-      list[i].in_use = 1;
-      list[i].age = mmesa->texAge[heap];
-
-      /* remove_from_list(i)
-       */
-      list[(unsigned)list[i].next].prev = list[i].prev;
-      list[(unsigned)list[i].prev].next = list[i].next;
-      
-      /* insert_at_head(list, i)
-       */
-      list[i].prev = MGA_NR_TEX_REGIONS;
-      list[i].next = list[MGA_NR_TEX_REGIONS].next;
-      list[(unsigned)list[MGA_NR_TEX_REGIONS].next].prev = i;
-      list[MGA_NR_TEX_REGIONS].next = i;
-   }
-
-   if (0) {
-	   mgaPrintGlobalLRU(mmesa, t->heap);
-	   mgaPrintLocalLRU(mmesa, t->heap);
-   }
-}
 
-/* Called for every shared texture region which has increased in age
- * since we last held the lock.
- *
- * Figures out which of our textures have been ejected by other clients,
- * and pushes a placeholder texture onto the LRU list to represent 
- * the other client's textures.  
+/*
+ * mgaSetTexFilter
  */
-static void mgaTexturesGone( mgaContextPtr mmesa,
-			     GLuint heap,
-			     GLuint offset, 
-			     GLuint size,
-			     GLuint in_use ) 
+static void mgaSetTexFilter(mgaTextureObjectPtr t, GLenum minf, GLenum magf) 
 {
-   mgaTextureObjectPtr t, tmp;
-
-
+   GLuint val = 0;
 
-   foreach_s ( t, tmp, &(mmesa->TexObjList[heap]) ) {
-
-      if (t->MemBlock->ofs >= offset + size ||
-	  t->MemBlock->ofs + t->MemBlock->size <= offset)
-	 continue;
-
-
-
-
-      /* It overlaps - kick it off.  Need to hold onto the currently bound
-       * objects, however.
-       */
-      if (t->bound) 
-	 mgaSwapOutTexObj( mmesa, t );
-      else
-	 mgaDestroyTexObj( mmesa, t );
+   switch (minf) {
+   case GL_NEAREST: val = TF_minfilter_nrst; break;
+   case GL_LINEAR: val = TF_minfilter_bilin; break;
+   case GL_NEAREST_MIPMAP_NEAREST: val = TF_minfilter_mm1s; break;
+   case GL_LINEAR_MIPMAP_NEAREST: val = TF_minfilter_mm4s; break;
+   case GL_NEAREST_MIPMAP_LINEAR: val = TF_minfilter_mm2s; break;
+   case GL_LINEAR_MIPMAP_LINEAR: val = TF_minfilter_mm8s; break;
+   default: val = TF_minfilter_nrst; break;
    }
 
-   
-   if (in_use) {
-      t = (mgaTextureObjectPtr) calloc(1,sizeof(*t));
-      if (!t) return;
-
-      t->heap = heap;
-      t->MemBlock = mmAllocMem( mmesa->texHeap[heap], size, 0, offset);      
-      if (!t->MemBlock) {
-	      fprintf(stderr, "Couldn't alloc placeholder sz %x ofs %x\n",
-		      (int)size, (int)offset);
-	      mmDumpMemInfo( mmesa->texHeap[heap]);
-	      return;
-      }
-      insert_at_head( &(mmesa->TexObjList[heap]), t );
+   switch (magf) {
+   case GL_NEAREST: val |= TF_magfilter_nrst; break;
+   case GL_LINEAR: val |= TF_magfilter_bilin; break;
+   default: val |= TF_magfilter_nrst; break;
    }
-}
-
-
-void mgaAgeTextures( mgaContextPtr mmesa, int heap )
-{
-	drm_mga_sarea_t *sarea = mmesa->sarea;
-	int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]);
-	int idx, nr = 0;
-
-	/* Have to go right round from the back to ensure stuff ends up
-	 * LRU in our local list...  Fix with a cursor pointer.
-	 */
-	for (idx = sarea->texList[heap][MGA_NR_TEX_REGIONS].prev ; 
-	     idx != MGA_NR_TEX_REGIONS && nr < MGA_NR_TEX_REGIONS ; 
-	     idx = sarea->texList[heap][idx].prev, nr++)
-	{
-		if (sarea->texList[heap][idx].age > mmesa->texAge[heap]) {
-			mgaTexturesGone(mmesa, heap, idx * sz, sz, 1);
-		}
-	}
-
-	if (nr == MGA_NR_TEX_REGIONS) {
-		mgaTexturesGone(mmesa, heap, 0,
-				mmesa->mgaScreen->textureSize[heap], 0);
-		mgaResetGlobalLRU( mmesa, heap );
-	}
-
-	
-	if (0) {
-		mgaPrintGlobalLRU( mmesa, heap );
-		mgaPrintLocalLRU( mmesa, heap );
-	}
-
-	mmesa->texAge[heap] = sarea->texAge[heap];
-	mmesa->dirty |= MGA_UPLOAD_TEX0IMAGE | MGA_UPLOAD_TEX1IMAGE;
-}
-
-
-/*
- * mgaSetTexWrappings
- */
-static void mgaSetTexWrapping( mgaTextureObjectPtr t,
-			       GLenum sWrap, GLenum tWrap ) {
-	if (sWrap == GL_REPEAT) {
-		t->Setup[MGA_TEXREG_CTL] &= ~TMC_clampu_enable;
-	} else {
-		t->Setup[MGA_TEXREG_CTL] |= TMC_clampu_enable;
-	}
-	if (tWrap == GL_REPEAT) {
-		t->Setup[MGA_TEXREG_CTL] &= ~TMC_clampv_enable;
-	} else {
-		t->Setup[MGA_TEXREG_CTL] |= TMC_clampv_enable;
-	}
-}
-
-/*
- * mgaSetTexFilter
- */
-static void mgaSetTexFilter(mgaTextureObjectPtr t, GLenum minf, GLenum magf) {
-	switch (minf) {
-	case GL_NEAREST:
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],
-		  TF_minfilter_MASK, TF_minfilter_nrst);
-		break;
-	case GL_LINEAR:
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],
-		  TF_minfilter_MASK, TF_minfilter_bilin);
-		break;
-	case GL_NEAREST_MIPMAP_NEAREST:
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],
-		  TF_minfilter_MASK, TF_minfilter_mm1s);
-		break;
-	case GL_LINEAR_MIPMAP_NEAREST:
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],
-		  TF_minfilter_MASK, TF_minfilter_mm4s);
-		break;
-	case GL_NEAREST_MIPMAP_LINEAR:
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],
-		  TF_minfilter_MASK, TF_minfilter_mm2s);
-		break;
-	case GL_LINEAR_MIPMAP_LINEAR:
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],
-		  TF_minfilter_MASK, TF_minfilter_mm8s);
-		break;
-	default:
-		mgaError("mgaSetTexFilter(): not supported min. filter %d\n",
-			 (int)minf);
-		break;
-	}
-
-	switch (magf) {
-	case GL_NEAREST:
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],
-		  TF_magfilter_MASK,TF_magfilter_nrst);
-		break;
-	case GL_LINEAR:
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],
-		  TF_magfilter_MASK,TF_magfilter_bilin);
-		break;
-	default:
-		mgaError("mgaSetTexFilter(): not supported mag. filter %d\n",
-			 (int)magf);
-		break;
-	}
   
-	/* See OpenGL 1.2 specification */
-	if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST || 
-                            minf == GL_NEAREST_MIPMAP_LINEAR)) {
-		/* c = 0.5 */
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],TF_fthres_MASK,
-		  0x20 << TF_fthres_SHIFT);
-	} else {
-		/* c = 0 */
-		MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],TF_fthres_MASK,
-		  0x10 << TF_fthres_SHIFT);
-	}
+   /* See OpenGL 1.2 specification */
+   if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST || 
+			     minf == GL_NEAREST_MIPMAP_LINEAR)) {
+      val |= (0x20 << TF_fthres_SHIFT); /* c = 0.5 */
+   } else {
+      val |= (0x10 << TF_fthres_SHIFT); /* c = 0 */
+   }
+
 
+   t->Setup[MGA_TEXREG_FILTER] &= (TF_minfilter_MASK |
+				   TF_magfilter_MASK |
+				   TF_fthres_MASK);   
+   t->Setup[MGA_TEXREG_FILTER] |= val;
 }
 
 /*
  * mgaSetTexBorderColor
  */
-static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]) {
-	t->Setup[MGA_TEXREG_BORDERCOL] = 
-		MGAPACKCOLOR8888(color[0],color[1],color[2],color[3]);
-
+static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]) 
+{
+   t->Setup[MGA_TEXREG_BORDERCOL] = MGAPACKCOLOR8888(color[0],color[1],
+						     color[2],color[3]);
 }
 
 
@@ -404,152 +149,6 @@
 
 
 
-/*
- * mgaUploadSubImageLocked
- *
- * Perform an iload based update of a resident buffer.  This is used for
- * both initial loading of the entire image, and texSubImage updates.
- *
- * Performed with the hardware lock held.
- */
-static void mgaUploadSubImageLocked( mgaContextPtr mmesa,
-				     mgaTextureObjectPtr t,
-				     int level,	     
-				     int x, int y, int width, int height ) {
-	int		x2;
-	int		dwords;
-        int		offset;
-	struct gl_texture_image *image;
-	int		texelBytes, texelsPerDword, texelMaccess, length;
-
-	if ( level < 0 || level >= MGA_TEX_MAXLEVELS ) {
-		mgaMsg( 1, "mgaUploadSubImage: bad level: %i\n", level );
- 	 	return;
-	}
-
-	image = t->tObj->Image[level];
-	if ( !image ) {
-		mgaError( "mgaUploadSubImage: NULL image\n" );
-		return;
-	}
-	
-	/* find the proper destination offset for this level */
-   	offset = (t->MemBlock->ofs + 
-		  t->offsets[level]);
-
-	texelBytes = t->texelBytes;	
-	switch( texelBytes ) {
-	case 1:
-		texelsPerDword = 4;
-		texelMaccess = 0;
-		break;
-	case 2:
-		texelsPerDword = 2;
-		texelMaccess = 1;
-		break;
-	case 4:
-		texelsPerDword = 1;
-		texelMaccess = 2;
-		break;
-	default:
-		return;
-	}
-			
-		
-	/* We can't do a subimage update if pitch is < 32 texels due
-	 * to hardware XY addressing limits, so we will need to
-	 * linearly upload all modified rows.
-	 */
-	if ( image->Width < 32 ) {
-		x = 0;
-		width = image->Width * height;
-		height = 1;
-
-		/* Assume that 1x1 textures aren't going to cause a
-		 * bus error if we read up to four texels from that
-		 * location: 
-		 */
-		if ( width < texelsPerDword ) {
-			width = texelsPerDword;
-		}
-	} else {
-		/* pad the size out to dwords.  The image is a pointer
-		   to the entire image, so we can safely reference
-		   outside the x,y,width,height bounds if we need to */
-		x2 = x + width;
-		x2 = (x2 + (texelsPerDword-1)) & ~(texelsPerDword-1);	
-		x = (x + (texelsPerDword-1)) & ~(texelsPerDword-1);
-		width = x2 - x;
-	}
-
-	/* we may not be able to upload the entire texture in one
-	   batch due to register limits or dma buffer limits.
-	   Recursively split it up. */
-	while ( 1 ) {
-		dwords = height * width / texelsPerDword;
-		if ( dwords * 4 <= MGA_DMA_BUF_SZ ) {
-			break;
-		}
-		mgaMsg(10, "mgaUploadSubImage: recursively subdividing\n" );
-
-		mgaUploadSubImageLocked( mmesa, t, level, x, y, 
-					 width, height >> 1 );
-		y += ( height >> 1 );
-		height -= ( height >> 1 );
-	}
-	
-	mgaMsg(10, "mgaUploadSubImage: %i,%i of %i,%i at %i,%i\n", 
-	       width, height, image->Width, image->Height, x, y );
-
-	/* bump the performance counter */
-	mgaglx.c_textureSwaps += ( dwords << 2 );
-	
-   	length = dwords * 4;
-
-	/* Fill in the secondary buffer with properly converted texels
-	 * from the mesa buffer. */
-   	if(t->heap == MGA_CARD_HEAP) {
-	   mgaGetILoadBufferLocked( mmesa );
-	   mgaConvertTexture( (mgaUI32 *)mmesa->iload_buffer->address, 
-			     texelBytes, image, x, y, width, height ); 
-	   if(length < 64) length = 64;
-	   mgaMsg(10, "TexelBytes : %d, offset: %d, length : %d\n",
-		  texelBytes,
-		  mmesa->mgaScreen->textureOffset[t->heap] +
-		  offset + 
-		  y * width * 4/texelsPerDword,
-		  length);
-	   
-	   mgaFireILoadLocked( mmesa, 
-			      mmesa->mgaScreen->textureOffset[t->heap] +
-			      offset + 
-			      y * width * 4/texelsPerDword,
-			      length);
-	} else {
- 	/* This works, is slower for uploads to card space and needs
-	 * additional synchronization with the dma stream.
-	 */
-	   mgaConvertTexture( (mgaUI32 *)
-			      (mmesa->mgaScreen->texVirtual[t->heap] + 
-					  offset + 
-					  y * width * 4/texelsPerDword), 
-			     texelBytes, image, x, y, width, height ); 
-	}
-}
-
-
-static void mgaUploadTexLevel( mgaContextPtr mmesa, 
-				     mgaTextureObjectPtr t,
-				     int l )
-{
-	mgaUploadSubImageLocked( mmesa,
-				 t,
-				 l,
-				 0, 0,
-				 t->tObj->Image[l]->Width,
-				 t->tObj->Image[l]->Height);
-}
-
 
 
 /*
@@ -558,490 +157,337 @@
  * This will happen before drawing with a new texture, or drawing with a
  * texture after it was swapped out or teximaged again.
  */
-static void mgaCreateTexObj(mgaContextPtr mmesa, struct gl_texture_object *tObj) 
+static void mgaCreateTexObj(mgaContextPtr mmesa, 
+			    struct gl_texture_object *tObj) 
 {
-	mgaTextureObjectPtr		t;
-	int					i, ofs, size;
-	struct gl_texture_image *image;
-	int					LastLevel;
-	int					s, s2;
-	int					textureFormat;
+   const struct gl_texture_image *image = tObj->Image[ 0 ];   
+   mgaTextureObjectPtr t;
+   int i, ofs;
+   int LastLevel;
+   int s, s2;
+   int textureFormat;
 	
-	mgaMsg( 10,"mgaCreateTexObj( %p )\n", tObj );
 
-	t = malloc( sizeof( *t ) );
-	if ( !t ) {
-		mgaError( "mgaCreateTexObj: Failed to malloc mgaTextureObject\n" );
-		return;
-	}
-	memset( t, 0, sizeof( *t ) );
-	
-	image = tObj->Image[ 0 ];
-	if ( !image ) {
-		return;
-	}
+   if (!image) return;
 
-	if ( 0 ) {
-		/* G400 texture format options */
 
-	} else {
-		/* G200 texture format options */
-		
-		switch( image->Format ) {
-		case GL_RGB:
-	 	case GL_LUMINANCE:
-	 		if ( image->IntFormat != GL_RGB5 &&
-			     ( image->IntFormat == GL_RGB8 ||
-			       mgaglx.default32BitTextures ) ) {
-	 			t->texelBytes = 4;
-	 			textureFormat = TMC_tformat_tw32;
-	 		} else {
-				t->texelBytes = 2;
-				textureFormat = TMC_tformat_tw16;
-			}
-			break;
-		case GL_ALPHA:
-	 	case GL_LUMINANCE_ALPHA:
-		case GL_INTENSITY:
-		case GL_RGBA:
-	 		if ( image->IntFormat != GL_RGBA4 &&
-			     ( image->IntFormat == GL_RGBA8 ||
-			       mgaglx.default32BitTextures ) ) {
-	 			t->texelBytes = 4;
-	 			textureFormat = TMC_tformat_tw32;
-	 		} else {
-				t->texelBytes = 2;
-				textureFormat = TMC_tformat_tw12;
-			}
-			break;
-		case GL_COLOR_INDEX:
-			textureFormat = TMC_tformat_tw8;
-			t->texelBytes = 1;
-			break;
-		default:
-			mgaError( "mgaCreateTexObj: bad image->Format\n" );
-			free( t );
-			return;	
-		}
-	}
-		
-	/* we are going to upload all levels that are present, even if
-	   later levels wouldn't be used by the current filtering mode.  This
-	   allows the filtering mode to change without forcing another upload
-	   of the images */
-	LastLevel = MGA_TEX_MAXLEVELS-1;
-
-	ofs = 0;
-	for ( i = 0 ; i <= LastLevel ; i++ ) {
-		int levelWidth, levelHeight;
+   tObj->DriverData = t = CALLOC( sizeof( *t ) );
+   if (!t) {
+      fprintf(stderr, "mgaCreateTexObj: Failed to malloc mgaTextureObject\n" );
+      return;
+   }
+
+   switch( image->Format ) {
+   case GL_RGB:
+   case GL_LUMINANCE:
+      if ( image->IntFormat != GL_RGB5 && ( image->IntFormat == GL_RGB8 ||
+					    mmesa->default32BitTextures ) ) {
+	 t->texelBytes = 4;
+	 textureFormat = TMC_tformat_tw32;
+      } else {
+	 t->texelBytes = 2;
+	 textureFormat = TMC_tformat_tw16;
+      }
+      break;
+   case GL_ALPHA:
+   case GL_LUMINANCE_ALPHA:
+   case GL_INTENSITY:
+   case GL_RGBA:
+      if ( image->IntFormat != GL_RGBA4 && ( image->IntFormat == GL_RGBA8 ||
+					     mmesa->default32BitTextures ) ) {
+	 t->texelBytes = 4;
+	 textureFormat = TMC_tformat_tw32;
+      } else {
+	 t->texelBytes = 2;
+	 textureFormat = TMC_tformat_tw12;
+      }
+      break;
+   case GL_COLOR_INDEX:
+      textureFormat = TMC_tformat_tw8;
+      t->texelBytes = 1;
+      break;
+   default:
+      fprintf(stderr, "mgaCreateTexObj: bad image->Format %x/%s\n",
+	      image->Format,
+	      gl_lookup_enum_by_nr(image->Format));
+      FREE( t );
+      tObj->DriverData = 0;
+      return;	
+   }
 		
-		t->offsets[i] = ofs;
-		image = tObj->Image[ i ];
-		if ( !image ) {
-			LastLevel = i - 1;
-			mgaMsg( 10, "  missing images after LastLevel: %i\n",
-				LastLevel );
-			break;
-		}
-		/* the G400 doesn't work with textures less than 8
-                   units in size */
-		levelWidth = image->Width;
-		levelHeight = image->Height;
-		if ( levelWidth < 8 ) {
-			levelWidth = 8;
-		}
-		if ( levelHeight < 8 ) {
-			levelHeight = 8;
-		}
-		size = levelWidth * levelHeight * t->texelBytes;
-		size = ( size + 31 ) & ~31;	/* 32 byte aligned */
-		ofs += size;
-		t->dirty_images |= (1<<i);
-	}
-	t->totalSize = ofs;
-	t->lastLevel = LastLevel;
-	
+   /* We are going to upload all levels that are present, even if
+    * later levels wouldn't be used by the current filtering mode.  This
+    * allows the filtering mode to change without forcing another upload
+    * of the images.
+    */
+   LastLevel = MGA_TEX_MAXLEVELS-1;
 
-	/* fill in our mga texture object */
-	t->tObj = tObj;
-	t->ctx = mmesa;
-	t->age = 0;
-	t->bound = 0;
+   ofs = 0;
+   for ( i = 0 ; i <= LastLevel ; i++ ) {		
+      if ( !tObj->Image[i] ) {
+	 LastLevel = i - 1;
+	 break;
+      }
 
-	
-	insert_at_tail(&(mmesa->SwappedOut), t);
-	
-	t->MemBlock = 0;
+      t->offsets[i] = ofs;
+      t->dirty_images |= (1<<i);
 
-	/* base image */	  
-	image = tObj->Image[ 0 ];
+      ofs += ((MAX2( tObj->Image[i]->Width, 8 ) * 
+	       MAX2( tObj->Image[i]->Height, 8 ) * 
+	       t->texelBytes) + 31) & ~31;
+   }
 
-	/* setup hardware register values */		
-	t->Setup[MGA_TEXREG_CTL] = (TMC_takey_1 | 
-				       TMC_tamask_0 | 
-				       textureFormat );
-
-	if (image->WidthLog2 >= 3) {
-		t->Setup[MGA_TEXREG_CTL] |= ((image->WidthLog2 - 3) << 
-						TMC_tpitch_SHIFT);
-	} else {
-		t->Setup[MGA_TEXREG_CTL] |= (TMC_tpitchlin_enable | 
-						(image->Width << 
-						 TMC_tpitchext_SHIFT));
-	}
-
-
-	t->Setup[MGA_TEXREG_CTL2] = TMC_ckstransdis_enable;
-
-	if ( mmesa->glCtx->Light.Model.ColorControl == 
-	     GL_SEPARATE_SPECULAR_COLOR ) 
-	{
-		t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable;
-	}
-	
-	t->Setup[MGA_TEXREG_FILTER] = (TF_minfilter_nrst | 
-					  TF_magfilter_nrst |
-					  TF_filteralpha_enable | 
-					  (0x10 << TF_fthres_SHIFT) | 
-					  (LastLevel << TF_mapnb_SHIFT));
-	
-	/* warp texture registers */
-	if (MGA_IS_G200(mmesa)) {
-		ofs = 28;
-	} else {
-   		ofs = 11;
-   	}
-
-	s = image->Width;
-	s2 = image->WidthLog2;
-	t->Setup[MGA_TEXREG_WIDTH] = 
-		MGA_FIELD(TW_twmask, s - 1) |
-		MGA_FIELD(TW_rfw,    (10 - s2 - 8) & 63 ) |
-		MGA_FIELD(TW_tw,     (s2 + ofs ) | 0x40 );
+   t->totalSize = ofs;
+   t->lastLevel = LastLevel;
+   t->tObj = tObj;
+   t->ctx = mmesa;
+   t->age = 0;
+   t->bound = 0;
+   t->MemBlock = 0;
 
+   insert_at_tail(&(mmesa->SwappedOut), t);
 	
-	s = image->Height;
-	s2 = image->HeightLog2;
-	t->Setup[MGA_TEXREG_HEIGHT] = 
-		MGA_FIELD(TH_thmask, s - 1) |
-		MGA_FIELD(TH_rfh,    (10 - s2 - 8) & 63 ) | 
-		MGA_FIELD(TH_th,     (s2 + ofs ) | 0x40 );
 
+   /* setup hardware register values */		
+   t->Setup[MGA_TEXREG_CTL] = (TMC_takey_1 | 
+			       TMC_tamask_0 | 
+			       textureFormat );
 
-	/* set all the register values for filtering, border, etc */	
-	mgaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
-	mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
-	mgaSetTexBorderColor( t, tObj->BorderColor );
+   if (image->WidthLog2 >= 3) 
+      t->Setup[MGA_TEXREG_CTL] |= ((image->WidthLog2 - 3) << TMC_tpitch_SHIFT);
+   else 
+      t->Setup[MGA_TEXREG_CTL] |= (TMC_tpitchlin_enable | 
+				   (image->Width << TMC_tpitchext_SHIFT));
 
-  	tObj->DriverData = t;
-}
 
-static void mgaMigrateTexture( mgaContextPtr mmesa, mgaTextureObjectPtr t )
-{
-	/* NOT DONE */
-}
-
-
-static int mgaChooseTexHeap( mgaContextPtr mmesa, mgaTextureObjectPtr t )
-{
-	return 0;
-}
+   t->Setup[MGA_TEXREG_CTL2] = TMC_ckstransdis_enable;
 
+   if ( mmesa->glCtx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ) 
+      t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable;
 
-int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t )
-{
-	int heap;
-	int i;
-	int ofs;
-	mgaglx.c_textureSwaps++;
-
-	heap = t->heap = mgaChooseTexHeap( mmesa, t );
-
-	/* Do we need to eject LRU texture objects?
-	 */
-	if (!t->MemBlock) {
-		while (1)
-		{
-			mgaTextureObjectPtr tmp = mmesa->TexObjList[heap].prev;
-
-			t->MemBlock = mmAllocMem( mmesa->texHeap[heap], 
-						  t->totalSize,
-						  6, 0 ); 
-			if (t->MemBlock)
-				break;
-
-			if (mmesa->TexObjList[heap].prev->bound) {
-				fprintf(stderr, 
-					"Hit bound texture in upload\n"); 
-				return -1;
-			}
-
-			if (mmesa->TexObjList[heap].prev == 
-			    &(mmesa->TexObjList[heap])) 
-			{
-				fprintf(stderr, "Failed to upload texture, "
-					"sz %d\n", t->totalSize);
-				mmDumpMemInfo( mmesa->texHeap[heap] );
-				return -1;
-			}
-	 
-			mgaDestroyTexObj( mmesa, tmp );
-		}
- 
-		ofs = t->MemBlock->ofs 
-			+ mmesa->mgaScreen->textureOffset[heap]
-			;
-
-		t->Setup[MGA_TEXREG_ORG]  = ofs;
-		t->Setup[MGA_TEXREG_ORG1] = ofs + t->offsets[1];
-		t->Setup[MGA_TEXREG_ORG2] = ofs + t->offsets[2];
-		t->Setup[MGA_TEXREG_ORG3] = ofs + t->offsets[3];
-		t->Setup[MGA_TEXREG_ORG4] = ofs + t->offsets[4];
-
-		mmesa->dirty |= MGA_UPLOAD_CTX;
-	}
-
-	/* Let the world know we've used this memory recently.
-	 */
-	mgaUpdateTexLRU( mmesa, t );
-
 	
-	if (MGA_DEBUG&DEBUG_VERBOSE_LRU)
-		fprintf(stderr, "dispatch age: %d age freed memory: %d\n",
-			GET_DISPATCH_AGE(mmesa), mmesa->dirtyAge);
-
-	if (mmesa->dirtyAge >= GET_DISPATCH_AGE(mmesa)) 
-		mgaWaitAgeLocked( mmesa, mmesa->dirtyAge );
-
-	if (t->dirty_images) {
-  		if (MGA_DEBUG&DEBUG_VERBOSE_LRU)
-			fprintf(stderr, "*");
+   t->Setup[MGA_TEXREG_FILTER] = (TF_minfilter_nrst | 
+				  TF_magfilter_nrst |
+				  TF_filteralpha_enable | 
+				  (0x10 << TF_fthres_SHIFT) | 
+				  (LastLevel << TF_mapnb_SHIFT));
+	
+   /* warp texture registers */
+   ofs = MGA_IS_G200(mmesa) ? 28 : 11;
+   s = image->Width;
+   s2 = image->WidthLog2;
+   t->Setup[MGA_TEXREG_WIDTH] = (MGA_FIELD(TW_twmask, s - 1) |
+				 MGA_FIELD(TW_rfw, (10 - s2 - 8) & 63 ) |
+				 MGA_FIELD(TW_tw, (s2 + ofs ) | 0x40 ));
 
-		for (i = 0 ; i <= t->lastLevel ; i++)
-			if (t->dirty_images & (1<<i)) 
-				mgaUploadTexLevel( mmesa, t, i );
-	}
+	
+   s = image->Height;
+   s2 = image->HeightLog2;
+   t->Setup[MGA_TEXREG_HEIGHT] = (MGA_FIELD(TH_thmask, s - 1) |
+				  MGA_FIELD(TH_rfh, (10 - s2 - 8) & 63 ) | 
+				  MGA_FIELD(TH_th, (s2 + ofs ) | 0x40 ));
 
 
-	t->dirty_images = 0;
-	return 0;
+   /* set all the register values for filtering, border, etc */	
+   mgaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+   mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+   mgaSetTexBorderColor( t, tObj->BorderColor );
 }
 
-/*
-============================================================================
 
-PUBLIC MGA FUNCTIONS
 
-============================================================================
-*/
 
-
-
 static void mgaUpdateTextureEnvG200( GLcontext *ctx )
 {
-	struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current;
-	mgaTextureObjectPtr t;
+   struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current;
+   mgaTextureObjectPtr t;
 
-	if (!tObj || !tObj->DriverData)
-		return;
+   if (!tObj || !tObj->DriverData)
+      return;
 
-	t = (mgaTextureObjectPtr)tObj->DriverData;
+   t = (mgaTextureObjectPtr)tObj->DriverData;
 
-	switch (ctx->Texture.Unit[0].EnvMode) {
-	case GL_REPLACE:
-		t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable;
-		t->Setup[MGA_TEXREG_CTL2] &= ~TMC_decaldis_enable;
-		break;
-	case GL_MODULATE:
-		t->Setup[MGA_TEXREG_CTL] |= TMC_tmodulate_enable;
-		t->Setup[MGA_TEXREG_CTL2] &= ~TMC_decaldis_enable;
-		break;
-	case GL_DECAL:
-		t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable;
-		t->Setup[MGA_TEXREG_CTL2] &= ~TMC_decaldis_enable;
-		break;
-	case GL_BLEND:
-		t->ctx->Fallback |= MGA_FALLBACK_TEXTURE;
-		break;
-	default:
-		break;
-	}
+   switch (ctx->Texture.Unit[0].EnvMode) {
+   case GL_REPLACE:
+      t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable;
+      break;
+   case GL_MODULATE:
+      t->Setup[MGA_TEXREG_CTL] |= TMC_tmodulate_enable;
+      break;
+   case GL_DECAL:
+      t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable;
+      break;
+   case GL_BLEND:
+      t->ctx->Fallback |= MGA_FALLBACK_TEXTURE;
+      break;
+   default:
+      break;
+   }
 }
 
-static void mgaUpdateTextureStage( GLcontext *ctx, int unit )
+static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit )
 {
-	mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-	GLuint *reg = &mmesa->Setup[MGA_CTXREG_TDUAL0 + unit];
-	GLuint source = mmesa->tmu_source[unit];
-	struct gl_texture_object *tObj = ctx->Texture.Unit[source].Current;
-
-	*reg = 0;
-	if (unit == 1)
-		*reg = mmesa->Setup[MGA_CTXREG_TDUAL0];
-	
-	if ( tObj != ctx->Texture.Unit[source].CurrentD[2] ) 
-		return;
-	
-	if ( ((ctx->Enabled>>(source*4))&TEXTURE0_ANY) != TEXTURE0_2D ) 
-		return;
-	
-	if (!tObj || !tObj->Complete) 
-		return;
-
-	switch (ctx->Texture.Unit[source].EnvMode) {
-	case GL_REPLACE:
-		*reg = (TD0_color_sel_arg1 |
-			TD0_alpha_sel_arg1 );
-		break;
-
-	case GL_MODULATE:
-		if (unit == 0)
-			*reg = ( TD0_color_arg2_diffuse |
-				 TD0_color_sel_mul | 
-				 TD0_alpha_arg2_diffuse |
-				 TD0_alpha_sel_mul);
-		else
-			*reg = ( TD0_color_arg2_prevstage |
-				 TD0_color_alpha_prevstage |
-				 TD0_color_sel_mul | 
-				 TD0_alpha_arg2_prevstage |
-				 TD0_alpha_sel_mul);
-		break;
-	case GL_DECAL:
-		*reg = (TD0_color_arg2_fcol | 
-			TD0_color_alpha_currtex |
-			TD0_color_alpha2inv_enable |
-			TD0_color_arg2mul_alpha2 |
-			TD0_color_arg1mul_alpha1 |
-			TD0_color_add_add |
-			TD0_color_sel_add |
-			TD0_alpha_arg2_fcol |
-			TD0_alpha_sel_arg2 );
-		break;
-
-	case GL_ADD:
-		if (unit == 0)
-			*reg = ( TD0_color_arg2_diffuse |
-				 TD0_color_add_add |
-				 TD0_color_sel_add | 
-				 TD0_alpha_arg2_diffuse |
-				 TD0_alpha_sel_add);
-		else
-			*reg = ( TD0_color_arg2_prevstage |
-				 TD0_color_alpha_prevstage |
-				 TD0_color_add_add |
-				 TD0_color_sel_add | 
-				 TD0_alpha_arg2_prevstage |
-				 TD0_alpha_sel_add);
-		break;
-
-	case GL_BLEND:
-		if (0)
-			fprintf(stderr, "GL_BLEND unit %d flags %x\n", unit,
-				mmesa->blend_flags);
-
-		if (mmesa->blend_flags) 
-			mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
-			return;
-
-		/* Do singletexture GL_BLEND with 'all ones' env-color
-		 * by using both texture units.  Multitexture gl_blend
-		 * is a fallback.  
-		 */
-		if (unit == 0) {
-			/* Part 1: R1 = Rf ( 1 - Rt )
-			 *         A1 = Af At
-			 */
-			*reg = ( TD0_color_arg2_diffuse |
-				 TD0_color_arg1_inv_enable |
-				 TD0_color_sel_mul | 
-				 TD0_alpha_arg2_diffuse |
-				 TD0_alpha_sel_arg1);
-		} else {
-			/* Part 2: R2 = R1 + Rt
-			 *         A2 = A1
-			 */
-			*reg = ( TD0_color_arg2_prevstage |
-				 TD0_color_add_add | 
-				 TD0_color_sel_add | 
-				 TD0_alpha_arg2_prevstage |
-				 TD0_alpha_sel_arg2);		
-		}	
-
-		break;
-	default:
-		break;
-	}
+   mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+   GLuint *reg = &mmesa->Setup[MGA_CTXREG_TDUAL0 + unit];
+   GLuint source = mmesa->tmu_source[unit];
+   struct gl_texture_object *tObj = ctx->Texture.Unit[source].Current;
+
+   if ( tObj != ctx->Texture.Unit[source].CurrentD[2] || 
+	!tObj || 
+	!tObj->Complete || 
+	((ctx->Enabled>>(source*4))&TEXTURE0_ANY) != TEXTURE0_2D ) 
+      return;
+	
+
+   switch (ctx->Texture.Unit[source].EnvMode) {
+   case GL_REPLACE:
+      *reg = (TD0_color_sel_arg1 |
+	      TD0_alpha_sel_arg1 );
+      break;
+
+   case GL_MODULATE:
+      if (unit == 0)
+	 *reg = ( TD0_color_arg2_diffuse |
+		  TD0_color_sel_mul | 
+		  TD0_alpha_arg2_diffuse |
+		  TD0_alpha_sel_mul);
+      else
+	 *reg = ( TD0_color_arg2_prevstage |
+		  TD0_color_alpha_prevstage |
+		  TD0_color_sel_mul | 
+		  TD0_alpha_arg2_prevstage |
+		  TD0_alpha_sel_mul);
+      break;
+   case GL_DECAL:
+      if (tObj->Image[0]->Format == GL_RGB) 
+	 *reg = (TD0_color_sel_arg1 |
+		 TD0_alpha_sel_arg1 );
+      else if (unit == 0) 
+	 *reg = (TD0_color_arg2_diffuse | 
+		 TD0_color_alpha_currtex |
+		 TD0_color_alpha2inv_enable |
+		 TD0_color_arg2mul_alpha2 |
+		 TD0_color_arg1mul_alpha1 |
+		 TD0_color_add_add |
+		 TD0_color_sel_add |
+		 TD0_alpha_arg2_diffuse |
+		 TD0_alpha_sel_arg2 );
+      else
+	 *reg = (TD0_color_arg2_prevstage | 
+		 TD0_color_alpha_currtex |
+		 TD0_color_alpha2inv_enable |
+		 TD0_color_arg2mul_alpha2 |
+		 TD0_color_arg1mul_alpha1 |
+		 TD0_color_add_add |
+		 TD0_color_sel_add |
+		 TD0_alpha_arg2_prevstage |
+		 TD0_alpha_sel_arg2 );
+
+      break;
+
+   case GL_ADD:
+      if (unit == 0)
+	 *reg = ( TD0_color_arg2_diffuse |
+		  TD0_color_add_add |
+		  TD0_color_sel_add | 
+		  TD0_alpha_arg2_diffuse |
+		  TD0_alpha_sel_add);
+      else
+	 *reg = ( TD0_color_arg2_prevstage |
+		  TD0_color_alpha_prevstage |
+		  TD0_color_add_add |
+		  TD0_color_sel_add | 
+		  TD0_alpha_arg2_prevstage |
+		  TD0_alpha_sel_add);
+      break;
+
+   case GL_BLEND:
+      if (mmesa->blend_flags) 
+	 mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
+
+      /* Do singletexture GL_BLEND with 'all ones' env-color
+       * by using both texture units.  Multitexture gl_blend
+       * is a fallback.  
+       */
+      if (unit == 0) {
+	 /* Part 1: R1 = Rf ( 1 - Rt )
+	  *         A1 = Af At
+	  */
+	 *reg = ( TD0_color_arg2_diffuse |
+		  TD0_color_arg1_inv_enable |
+		  TD0_color_sel_mul | 
+		  TD0_alpha_arg2_diffuse |
+		  TD0_alpha_sel_arg1);
+      } else {
+	 /* Part 2: R2 = R1 + Rt
+	  *         A2 = A1
+	  */
+	 *reg = ( TD0_color_arg2_prevstage |
+		  TD0_color_add_add | 
+		  TD0_color_sel_add | 
+		  TD0_alpha_arg2_prevstage |
+		  TD0_alpha_sel_arg2);		
+      }	
+      break;
+   default:
+      break;
+   }
 }
 
 
 
-static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) {
-	mgaTextureObjectPtr t;
-	struct gl_texture_object	*tObj;
-	GLuint enabled;
-	mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-	GLuint source = mmesa->tmu_source[unit];
-
-	mgaMsg(15,"mgaUpdateTextureState %d\n", unit);
-	
-	/* disable texturing until it is known to be good */
-	mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK;
-	mmesa->Setup[MGA_CTXREG_DWGCTL] |= DC_opcod_trap;
-
-	enabled = (ctx->Texture.Enabled>>(source*4))&TEXTURE0_ANY;
-	if (enabled != TEXTURE0_2D) {
-		if (enabled)
-			mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
-		return;
-	}
-
-	tObj = ctx->Texture.Unit[source].Current;
-
-	if ( !tObj || tObj != ctx->Texture.Unit[source].CurrentD[2] ) 
-		return;
+static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) 
+{
+   mgaTextureObjectPtr t;
+   struct gl_texture_object	*tObj;
+   GLuint enabled;
+   mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+   GLuint source = mmesa->tmu_source[unit];
 
-/*  	fprintf(stderr, "unit %d: %d\n", unit, tObj->Name); */
-	
-	/* if the texture object doesn't exist at all (never used or
-	   swapped out), create it now, uploading all texture images */
 
-	if ( !tObj->DriverData ) {
-		/* clear the current pointer so that texture object can be
-		   swapped out if necessary to make room */
-		mgaCreateTexObj( mmesa, tObj );
+   enabled = (ctx->Texture.ReallyEnabled>>(source*4))&TEXTURE0_ANY;
+   tObj = ctx->Texture.Unit[source].Current;
+
+   if (enabled != TEXTURE0_2D) {
+      if (enabled)
+	 mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
+      return;
+   }
 
-		if ( !tObj->DriverData ) {
-			mgaMsg( 5, "mgaUpdateTextureState: create failed\n" );
-			mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
-			return;		/* can't create a texture object */
-		}
-	}
+   if ( !tObj || tObj != ctx->Texture.Unit[source].CurrentD[2] ) {
+      mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
+      return;
+   }
 
-	/* we definately have a valid texture now */
-	mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK;
-	mmesa->Setup[MGA_CTXREG_DWGCTL] |= DC_opcod_texture_trap;
+/*     if (!tObj) tObj = ctx->Texture.Unit[0].Current; */
+/*     if (!tObj) return; */
 
-	t = (mgaTextureObjectPtr)tObj->DriverData;
+   if ( !tObj->DriverData ) {
+      mgaCreateTexObj( mmesa, tObj );
+      if ( !tObj->DriverData ) {
+	 mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
+	 return;		
+      }
+   }
 
-	if (t->dirty_images) 
-		mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << unit);
+   t = (mgaTextureObjectPtr)tObj->DriverData;
 
-	mmesa->CurrentTexObj[unit] = t;
-	t->bound = unit+1;
+   if (t->dirty_images) 
+      mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << unit);
 
-	if (t->MemBlock)
-		mgaUpdateTexLRU( mmesa, t );
+   mmesa->CurrentTexObj[unit] = t;
+   t->bound |= unit+1;
 
+/*     if (t->MemBlock) */
+/*        mgaUpdateTexLRU( mmesa, t ); */
 
-	t->Setup[MGA_TEXREG_CTL2] &= ~TMC_dualtex_enable;
-	if (ctx->Texture.Enabled == (TEXTURE0_2D|TEXTURE1_2D))
-		t->Setup[MGA_TEXREG_CTL2] |= TMC_dualtex_enable;
+   t->Setup[MGA_TEXREG_CTL2] &= ~TMC_dualtex_enable; 
+   if (mmesa->multitex)  
+      t->Setup[MGA_TEXREG_CTL2] |= TMC_dualtex_enable; 
 
-	t->Setup[MGA_TEXREG_CTL2] &= ~TMC_specen_enable;
-	if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
-		t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable;
-       
+   t->Setup[MGA_TEXREG_CTL2] &= ~TMC_specen_enable;
+   if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+      t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable;
 }
 
 
@@ -1053,279 +499,259 @@
  */
 void mgaUpdateTextureState( GLcontext *ctx )
 {
-	mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-	mmesa->Fallback &= ~MGA_FALLBACK_TEXTURE;
+   mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+   mmesa->Fallback &= ~MGA_FALLBACK_TEXTURE;
 
-	if (mmesa->CurrentTexObj[0]) mmesa->CurrentTexObj[0]->bound = 0;
-	if (mmesa->CurrentTexObj[1]) mmesa->CurrentTexObj[1]->bound = 0;
-	mmesa->CurrentTexObj[0] = 0;
-	mmesa->CurrentTexObj[1] = 0;   
-
-	if (MGA_IS_G400(mmesa)) {
-		mgaUpdateTextureObject( ctx, 0 );		
-		mgaUpdateTextureStage( ctx, 0 );
-
-		mmesa->Setup[MGA_CTXREG_TDUAL1] = 
-			mmesa->Setup[MGA_CTXREG_TDUAL0];
-
-		if (mmesa->multitex) {
-			mgaUpdateTextureObject( ctx, 1 );	
-			mgaUpdateTextureStage( ctx, 1 );
-		}
-		
-		mmesa->dirty |= MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1;
-	} else {
-		mgaUpdateTextureObject( ctx, 0 );
-		mgaUpdateTextureEnvG200( ctx );		
-	}
+   if (mmesa->CurrentTexObj[0]) {
+      mmesa->CurrentTexObj[0]->bound = 0;
+      mmesa->CurrentTexObj[0] = 0;
+   }
 
-	/* schedule the register writes */
-	mmesa->dirty |= MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0;
-}
+   if (mmesa->CurrentTexObj[1]) {
+      mmesa->CurrentTexObj[1]->bound = 0;
+      mmesa->CurrentTexObj[1] = 0;   
+   }
 
+   if (MGA_IS_G400(mmesa)) {
+      mgaUpdateTextureObject( ctx, 0 );		
+      mgaUpdateTextureEnvG400( ctx, 0 );
+
+      mmesa->Setup[MGA_CTXREG_TDUAL1] = mmesa->Setup[MGA_CTXREG_TDUAL0];
+
+      if (mmesa->multitex || 1) {
+	 mgaUpdateTextureObject( ctx, 1 );	
+	 mgaUpdateTextureEnvG400( ctx, 1 );
+      } 
+/*  else  */
+/*  	 mmesa->Setup[MGA_CTXREG_TDUAL1] = ( TD0_color_arg2_prevstage | */
+/*  					     TD0_color_sel_arg2 |  */
+/*  					     TD0_alpha_arg2_prevstage | */
+/*  					     TD0_alpha_sel_arg2); */
+
+      		
+      mmesa->dirty |= MGA_UPLOAD_TEX1;
+   } else {
+      mgaUpdateTextureObject( ctx, 0 );
+      mgaUpdateTextureEnvG200( ctx );		
+   }
 
+   mmesa->dirty |= MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0;
 
-/*
-============================================================================
+   mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK;
+   mmesa->Setup[MGA_CTXREG_DWGCTL] |= (ctx->Texture.ReallyEnabled 
+				       ? DC_opcod_texture_trap 
+				       : DC_opcod_trap);
+}
 
-Driver functions called directly from mesa
 
-============================================================================
-*/
 
-/*
- * mgaTexEnv
- */      
-void mgaTexEnv( GLcontext *ctx, GLenum target, GLenum pname,
-                const GLfloat *param ) 
-{
-	mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-	mgaMsg( 10, "mgaTexEnv( %i )\n", pname );
 
+static void mgaDDTexEnv( GLcontext *ctx, GLenum target, 
+			 GLenum pname, const GLfloat *param ) 
+{
+   mgaContextPtr mmesa = MGA_CONTEXT(ctx);
 
-	if (pname == GL_TEXTURE_ENV_MODE) {
-		/* force the texture state to be updated */
-		FLUSH_BATCH( MGA_CONTEXT(ctx) );
-		MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
-	}
-	else if (pname == GL_TEXTURE_ENV_COLOR)
-	{
-		struct gl_texture_unit *texUnit = 
-			&ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-		GLfloat *fc = texUnit->EnvColor;
-		GLubyte c[4];
-		GLuint col;
 
+   if (pname == GL_TEXTURE_ENV_MODE) {
+      /* force the texture state to be updated */
+      FLUSH_BATCH( MGA_CONTEXT(ctx) );
+      MGA_CONTEXT(ctx)->new_state |= (MGA_NEW_TEXTURE | 
+				      MGA_NEW_ALPHA);
+   }
+   else if (pname == GL_TEXTURE_ENV_COLOR)
+   {
+      struct gl_texture_unit *texUnit = 
+	 &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+      GLfloat *fc = texUnit->EnvColor;
+      GLubyte c[4];
+      GLuint col;
 		
-		c[0] = fc[0];
-		c[1] = fc[1];
-		c[2] = fc[2];
-		c[3] = fc[3];
-
-		/* No alpha at 16bpp?
-		 */
-		col = mgaPackColor( mmesa->mgaScreen->Attrib,
-				    c[0], c[1], c[2], c[3] );
-
-  		mmesa->envcolor = (c[3]<<24) | (c[0]<<16) | (c[1]<<8) | (c[2]); 
+      COPY_4V(c, fc);
+      col = mgaPackColor( mmesa->mgaScreen->cpp, c[0], c[1], c[2], c[3] );
+      mmesa->envcolor = (c[3]<<24) | (c[0]<<16) | (c[1]<<8) | (c[2]); 
     
-		if (mmesa->Setup[MGA_CTXREG_FCOL] != col) {
-			FLUSH_BATCH(mmesa);	
-			mmesa->Setup[MGA_CTXREG_FCOL] = col;      
-			mmesa->dirty |= MGA_UPLOAD_CTX;
-
-			mmesa->blend_flags &= ~MGA_BLEND_ENV_COLOR;
-
-			/* Actually just require all four components to be
-			 * equal.  This permits a single-pass GL_BLEND.
-			 * 
-			 * More complex multitexture/multipass fallbacks
-			 * for blend can be done later.
-			 */
-			if (mmesa->envcolor != 0x0 &&
-			    mmesa->envcolor != 0xffffffff)
-				mmesa->blend_flags |= MGA_BLEND_ENV_COLOR;
-		}
-	}
-
+      if (mmesa->Setup[MGA_CTXREG_FCOL] != col) {
+	 FLUSH_BATCH(mmesa);	
+	 mmesa->Setup[MGA_CTXREG_FCOL] = col;      
+	 mmesa->dirty |= MGA_UPLOAD_CTX;
+
+	 mmesa->blend_flags &= ~MGA_BLEND_ENV_COLOR;
+
+	 /* Actually just require all four components to be
+	  * equal.  This permits a single-pass GL_BLEND.
+	  * 
+	  * More complex multitexture/multipass fallbacks
+	  * for blend can be done later.
+	  */
+	 if (mmesa->envcolor != 0x0 && mmesa->envcolor != 0xffffffff)
+	    mmesa->blend_flags |= MGA_BLEND_ENV_COLOR;
+      }
+   }
 }
 
-/*
- * mgaTexImage
- */ 
-void mgaTexImage( GLcontext *ctx, GLenum target,
-		  struct gl_texture_object *tObj, GLint level,
-		  GLint internalFormat,
-		  const struct gl_texture_image *image ) 
+
+static void mgaDDTexImage( GLcontext *ctx, GLenum target,
+			   struct gl_texture_object *tObj, GLint level,
+			   GLint internalFormat,
+			   const struct gl_texture_image *image ) 
 {
-	mgaContextPtr mmesa = MGA_CONTEXT( ctx );	
-	mgaTextureObjectPtr t;
+   mgaContextPtr mmesa = MGA_CONTEXT( ctx );	
+   mgaTextureObjectPtr t;
 
-	mgaMsg( 10,"mgaTexImage( %p, level %i )\n", tObj, level );
-  
- 	/* just free the mga texture if it exists, it will be recreated at
-	mgaUpdateTextureState time. */  
-	t = (mgaTextureObjectPtr) tObj->DriverData;
-	if ( t ) {
-		if (t->bound) FLUSH_BATCH(mmesa);
-		/* if this is the current object, it will force an update */
- 	 	mgaDestroyTexObj( mmesa, t );
-		mmesa->new_state |= MGA_NEW_TEXTURE;
-	}
+   /* just free the mga texture if it exists, it will be recreated at
+      mgaUpdateTextureState time. */  
+   t = (mgaTextureObjectPtr) tObj->DriverData;
+   if ( t ) {
+      if (t->bound) FLUSH_BATCH(mmesa);
+      /* if this is the current object, it will force an update */
+      mgaDestroyTexObj( mmesa, t );
+      mmesa->new_state |= MGA_NEW_TEXTURE;
+   }
+
+   if (0)
+      fprintf(stderr, "mgaDDTexImage tObj %p, level %d, image %p\n",
+	      tObj, level, image);
+   
 }
 
-/*
- * mgaTexSubImage
- */      
-void mgaTexSubImage( GLcontext *ctx, GLenum target,
-		     struct gl_texture_object *tObj, GLint level,
-		     GLint xoffset, GLint yoffset,
-		     GLsizei width, GLsizei height,
-		     GLint internalFormat,
-		     const struct gl_texture_image *image ) 
+static void mgaDDTexSubImage( GLcontext *ctx, GLenum target,
+			      struct gl_texture_object *tObj, GLint level,
+			      GLint xoffset, GLint yoffset,
+			      GLsizei width, GLsizei height,
+			      GLint internalFormat,
+			      const struct gl_texture_image *image ) 
 {
-	mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-	mgaTextureObjectPtr t;
-
-	mgaMsg(10,"mgaTexSubImage() Size: %d,%d of %d,%d; Level %d\n",
-		width, height, image->Width,image->Height, level);
+   mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+   mgaTextureObjectPtr t;
 
-	t = (mgaTextureObjectPtr) tObj->DriverData;
+   t = (mgaTextureObjectPtr) tObj->DriverData;
 
 
- 	/* just free the mga texture if it exists, it will be recreated at
-	mgaUpdateTextureState time. */  
-	t = (mgaTextureObjectPtr) tObj->DriverData;
-	if ( t ) {
-		if (t->bound) FLUSH_BATCH(mmesa);
-		/* if this is the current object, it will force an update */
- 	 	mgaDestroyTexObj( mmesa, t );
-		mmesa->new_state |= MGA_NEW_TEXTURE;
-	}
+   /* just free the mga texture if it exists, it will be recreated at
+      mgaUpdateTextureState time. */  
+   t = (mgaTextureObjectPtr) tObj->DriverData;
+   if ( t ) {
+      if (t->bound) FLUSH_BATCH(mmesa);
+      /* if this is the current object, it will force an update */
+      mgaDestroyTexObj( mmesa, t );
+      mmesa->new_state |= MGA_NEW_TEXTURE;
+   }
 
 
 
 #if 0
-	/* the texture currently exists, so directly update it */
-	mgaUploadSubImage( t, level, xoffset, yoffset, width, height );
+   /* the texture currently exists, so directly update it */
+   mgaUploadSubImage( t, level, xoffset, yoffset, width, height );
 #endif
 }
 
+
+
 /*
  * mgaTexParameter
  * This just changes variables and flags for a state update, which
  * will happen at the next mgaUpdateTextureState
  */
-void mgaTexParameter( GLcontext *ctx, GLenum target,
-		      struct gl_texture_object *tObj,
-		      GLenum pname, const GLfloat *params )
+static void 
+mgaDDTexParameter( GLcontext *ctx, GLenum target,
+		   struct gl_texture_object *tObj,
+		   GLenum pname, const GLfloat *params )
 {
-	mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-	mgaTextureObjectPtr t;
+   mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+   mgaTextureObjectPtr t;
 
-	mgaMsg( 10, "mgaTexParameter( %p, %i )\n", tObj, pname );
+   t = (mgaTextureObjectPtr) tObj->DriverData;
 
-	t = (mgaTextureObjectPtr) tObj->DriverData;
+   /* if we don't have a hardware texture, it will be automatically
+      created with current state before it is used, so we don't have
+      to do anything now */
+   if ( !t || !t->bound || target != GL_TEXTURE_2D ) {
+      return;
+   }
 
-	/* if we don't have a hardware texture, it will be automatically
-	created with current state before it is used, so we don't have
-	to do anything now */
-	if ( !t || target != GL_TEXTURE_2D ) {
-		return;
-	}
-
-	switch (pname) {
-	case GL_TEXTURE_MIN_FILTER:
-	case GL_TEXTURE_MAG_FILTER:
-		if (t->bound) FLUSH_BATCH(mmesa);
-		mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
-		break;
-
-	case GL_TEXTURE_WRAP_S:
-	case GL_TEXTURE_WRAP_T:
-		if (t->bound) FLUSH_BATCH(mmesa);
-		mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT);
-		break;
+   switch (pname) {
+   case GL_TEXTURE_MIN_FILTER:
+   case GL_TEXTURE_MAG_FILTER:
+      FLUSH_BATCH(mmesa);
+      mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+      break;
+
+   case GL_TEXTURE_WRAP_S:
+   case GL_TEXTURE_WRAP_T:
+      FLUSH_BATCH(mmesa);
+      mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT);
+      break;
   
-	case GL_TEXTURE_BORDER_COLOR:
-		if (t->bound) FLUSH_BATCH(mmesa);
-		mgaSetTexBorderColor(t,tObj->BorderColor);
-		break;
-
-	default:
-		return;
-	}
+   case GL_TEXTURE_BORDER_COLOR:
+      FLUSH_BATCH(mmesa);
+      mgaSetTexBorderColor(t,tObj->BorderColor);
+      break;
+
+   default:
+      return;
+   }
 
-	mmesa->new_state |= MGA_NEW_TEXTURE;
+   mmesa->new_state |= MGA_NEW_TEXTURE;
 }
 
-/*
- * mgaBindTexture
- */      
-void mgaBindTexture( GLcontext *ctx, GLenum target,
-		     struct gl_texture_object *tObj ) 
-{
-	mgaContextPtr mmesa = MGA_CONTEXT( ctx );
 
-	mgaMsg( 10, "mgaBindTexture( %p )\n", tObj );
+static void 
+mgaDDBindTexture( GLcontext *ctx, GLenum target,
+		  struct gl_texture_object *tObj ) 
+{
+   mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+   int unit = ctx->Texture.CurrentUnit;
 
-	FLUSH_BATCH(mmesa);
+   FLUSH_BATCH(mmesa);
 
-	if (mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]) {
-		mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0;
-		mmesa->CurrentTexObj[ctx->Texture.CurrentUnit] = 0;  
-	}
+   if (mmesa->CurrentTexObj[unit]) {
+      mmesa->CurrentTexObj[unit]->bound &= ~(unit+1);
+      mmesa->CurrentTexObj[unit] = 0;  
+   }
 
-	/* force the texture state to be updated 
-	 */
-	MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
+   /* force the texture state to be updated 
+    */
+   MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE;
 }
 
-/*
- * mgaDeleteTexture
- */      
-void mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) 
+
+static void 
+mgaDDDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) 
 {
-	mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-	mgaTextureObjectPtr t = (mgaTextureObjectPtr)tObj->DriverData;
+   mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+   mgaTextureObjectPtr t = (mgaTextureObjectPtr)tObj->DriverData;
 
-	mgaMsg( 10, "mgaDeleteTexture( %p )\n", tObj );
-	
-	if ( t ) {
-		if (t->bound) {
-			FLUSH_BATCH(mmesa);
-			mmesa->CurrentTexObj[t->bound-1] = 0;
-			mmesa->new_state |= MGA_NEW_TEXTURE;
-		}
-
-		mgaDestroyTexObj( mmesa, t );
-		mmesa->new_state |= MGA_NEW_TEXTURE;
-	}
+   if ( t ) {
+      if (t->bound) {
+	 FLUSH_BATCH(mmesa);
+	 if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0;
+	 if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0;
+	 mmesa->new_state |= MGA_NEW_TEXTURE;
+      }
+
+      mgaDestroyTexObj( mmesa, t );
+      mmesa->new_state |= MGA_NEW_TEXTURE;
+   }
 }
 
 
-/* Have to grab the lock to find out if anyone has kicked out our
- * textures.
- */
-GLboolean mgaIsTextureResident( GLcontext *ctx, struct gl_texture_object *t ) 
+static GLboolean 
+mgaDDIsTextureResident( GLcontext *ctx, struct gl_texture_object *t ) 
 {
-	mgaTextureObjectPtr mt;
-
-/*  	LOCK_HARDWARE; */
-	mt = (mgaTextureObjectPtr)t->DriverData;
-/*  	UNLOCK_HARDWARE; */
-
-	return mt && mt->MemBlock;
+   mgaTextureObjectPtr mt = (mgaTextureObjectPtr)t->DriverData;
+   return mt && mt->MemBlock;
 }
+
 
-void mgaDDInitTextureFuncs( GLcontext *ctx )
+void 
+mgaDDInitTextureFuncs( GLcontext *ctx )
 {
-   ctx->Driver.TexEnv = mgaTexEnv;
-   ctx->Driver.TexImage = mgaTexImage;
-   ctx->Driver.TexSubImage = mgaTexSubImage;
-   ctx->Driver.BindTexture = mgaBindTexture;
-   ctx->Driver.DeleteTexture = mgaDeleteTexture;
-   ctx->Driver.TexParameter = mgaTexParameter;
+   ctx->Driver.TexEnv = mgaDDTexEnv;
+   ctx->Driver.TexImage = mgaDDTexImage;
+   ctx->Driver.TexSubImage = mgaDDTexSubImage;
+   ctx->Driver.BindTexture = mgaDDBindTexture;
+   ctx->Driver.DeleteTexture = mgaDDDeleteTexture;
+   ctx->Driver.TexParameter = mgaDDTexParameter;
    ctx->Driver.UpdateTexturePalette = 0;
-   ctx->Driver.IsTextureResident = mgaIsTextureResident;
+   ctx->Driver.IsTextureResident = mgaDDIsTextureResident;
 }
Index: xc/lib/GL/mesa/src/drv/mga/mgatex.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgatex.h:1.3 xc/lib/GL/mesa/src/drv/mga/mgatex.h:1.4
--- xc/lib/GL/mesa/src/drv/mga/mgatex.h:1.3	Thu Jun 22 12:59:24 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgatex.h	Sun Sep 24 09:51:07 2000
@@ -24,44 +24,16 @@
  *    John Carmack <johnc@idsoftware.com>
  *    Keith Whitwell <keithw@precisioninsight.com>
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatex.h,v 1.3 2000/06/22 16:59:24 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatex.h,v 1.4 2000/09/24 13:51:07 alanh Exp $ */
 
 #ifndef MGATEX_INC
 #define MGATEX_INC
 
-#include "types.h"
-#include "mgacommon.h"
-#include "mm.h"
-
-
-#define MGA_TEX_MAXLEVELS 5
-
-
-typedef struct mga_texture_object_s {
-	struct mga_texture_object_s *next;	
-	struct mga_texture_object_s *prev;	
-	struct gl_texture_object *tObj;
-	mgaContextPtr ctx;
-	PMemBlock	MemBlock;               
-	mgaUI32		offsets[MGA_TEX_MAXLEVELS];
-        int             lastLevel;
-        mgaUI32         dirty_images;
-	mgaUI32		totalSize;		
-	int		texelBytes;
-	mgaUI32 	age;
-        int             bound;
-        int             heap;	/* agp or card */
-        mgaUI32         Setup[MGA_TEX_SETUP_SIZE];
-} mgaTextureObject_t;
+#include "mgacontext.h"
 
-typedef mgaTextureObject_t *mgaTextureObjectPtr;
+typedef struct mga_texture_object_s *mgaTextureObjectPtr;
 
-/* called to check for environment variable options */
-void mgaInitTextureSystem( void );
 
-/* called when a context is being destroyed */
-void mgaDestroyContextTextures( mgaContextPtr ctx );
-
 /* Called before a primitive is rendered to make sure the texture
  * state is properly setup.  Texture residence is checked later
  * when we grab the lock.
@@ -70,51 +42,20 @@
 
 
 /* Driver functions which are called directly from mesa */
-
-void mgaTexEnv( GLcontext *ctx, GLenum target, GLenum pname,
-                const GLfloat *param );
-
-void mgaTexImage( GLcontext *ctx, GLenum target,
-		  struct gl_texture_object *tObj, GLint level,
-		  GLint internalFormat,
-		  const struct gl_texture_image *image );
-
-void mgaTexSubImage( GLcontext *ctx, GLenum target,
-		  struct gl_texture_object *tObj, GLint level,
-		  GLint xoffset, GLint yoffset,
-		  GLsizei width, GLsizei height,
-		  GLint internalFormat,
-		  const struct gl_texture_image *image );
-
-void mgaTexParameter( GLcontext *ctx, GLenum target,
-		      struct gl_texture_object *tObj,
-		      GLenum pname, const GLfloat *params );
-
-void mgaBindTexture( GLcontext *ctx, GLenum target,
-		     struct gl_texture_object *tObj );
-
-void mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj );
 
-void mgaUpdateTexturePalette( GLcontext *ctx, struct gl_texture_object *tObj );
-
-GLboolean mgaIsTextureResident( GLcontext *ctx, struct gl_texture_object *t );
-
-void mgaConvertTexture( mgaUI32 *dest, int texelBytes,
+void mgaConvertTexture( GLuint *dest, int texelBytes,
 			struct gl_texture_image *image,
 			int x, int y, int width, int height );
 
 
 
 int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t );
-
 
+void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t );
 
-
 void mgaAgeTextures( mgaContextPtr mmesa, int heap );
 
 void mgaDDInitTextureFuncs( GLcontext *ctx );
-
-
 
 
 #endif
Index: xc/lib/GL/mesa/src/drv/mga/mgatexcnv.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/mga/mgatexcnv.c:1.1
--- /dev/null	Mon Dec 18 14:23:33 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgatexcnv.c	Sun Sep 24 09:51:08 2000
@@ -0,0 +1,257 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatexcnv.c,v 1.1 2000/09/24 13:51:08 alanh Exp $ */
+/*
+ * GLX Hardware Device Driver for Matrox Millenium G200
+ * Copyright (C) 1999 Wittawat Yamwong
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ *    original by Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
+ *	9/20/99 rewrite by John Carmack <johnc@idsoftware.com>
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <GL/gl.h>
+
+#include "mm.h"
+#include "mgacontext.h"
+#include "mgatex.h"
+
+
+/*
+ * mgaConvertTexture
+ * Converts a mesa format texture to the apropriate hardware format
+ * Note that sometimes width may be larger than the texture, like 64x1
+ * for an 8x8 texture.  This happens when we have to crutch the pitch
+ * limits of the mga by uploading a block of texels as a single line.
+ */
+void mgaConvertTexture( GLuint *destPtr, int texelBytes, 
+			struct gl_texture_image *image,
+			int x, int y, int width, int height ) 
+{
+   register int		i, j;
+   GLubyte		*src;
+   int stride;
+	
+   if (0)
+      fprintf(stderr, "texture image %p\n", image->Data);
+		
+   if (image->Data == 0) 
+      return;
+
+   /* FIXME: g400 luminance_alpha internal format */
+   switch (texelBytes) {
+   case 1:
+      switch (image->Format) {
+      case GL_COLOR_INDEX:
+      case GL_INTENSITY:
+      case GL_LUMINANCE:
+      case GL_ALPHA:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x );
+	 stride = (image->Width - width);
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width >> 2  ; j ; j-- ) {
+			
+	       *destPtr++ = src[0] | ( src[1] << 8 ) | ( src[2] << 16 ) | ( src[3] << 24 );
+	       src += 4;
+	    }
+	    src += stride;
+	 }
+	 break;
+      default:
+	 goto format_error;
+      }
+      break;
+   case 2:
+      switch (image->Format) {
+      case GL_RGB:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x ) * 3;
+	 stride = (image->Width - width) * 3;
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width >> 1  ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR565(src[0],src[1],src[2]) |  
+		  ( MGAPACKCOLOR565(src[3],src[4],src[5]) << 16 );
+	       src += 6;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_RGBA:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x ) * 4;
+	 stride = (image->Width - width) * 4;
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width >> 1  ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR4444(src[0],src[1],src[2],src[3]) |  
+		  ( MGAPACKCOLOR4444(src[4],src[5],src[6],src[7]) << 16 );
+	       src += 8;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_LUMINANCE:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x );
+	 stride = (image->Width - width);
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width >> 1  ; j ; j-- ) {
+	       /* FIXME: should probably use 555 texture to get true grey */
+	       *destPtr++ = MGAPACKCOLOR565(src[0],src[0],src[0]) |  
+		  ( MGAPACKCOLOR565(src[1],src[1],src[1]) << 16 );
+	       src += 2;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_INTENSITY:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x );
+	 stride = (image->Width - width);
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width >> 1  ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[0]) |  
+		  ( MGAPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16 );
+	       src += 2;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_ALPHA:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x );
+	 stride = (image->Width - width);
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width >> 1  ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR4444(255,255,255,src[0]) |  
+		  ( MGAPACKCOLOR4444(255,255,255,src[1]) << 16 );
+	       src += 2;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_LUMINANCE_ALPHA:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x ) * 2;
+	 stride = (image->Width - width) * 2;
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width >> 1  ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR4444(src[0],src[0],src[0],src[1]) |  
+		  ( MGAPACKCOLOR4444(src[2],src[2],src[2],src[3]) << 16 );
+	       src += 4;
+	    }
+	    src += stride;
+	 }
+	 break;
+      default:
+	 goto format_error;
+      }
+      break;
+   case 4:
+      switch (image->Format) {
+      case GL_RGB:
+	 src = (GLubyte *)image->Data + (  y * image->Width + x ) * 3;
+	 stride = (image->Width - width) * 3;
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2], 255);
+	       src += 3;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_RGBA:
+	 src = (GLubyte *)image->Data + (  y * image->Width + x ) * 4;
+	 stride = (image->Width - width) * 4;
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width  ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR8888(src[0],src[1],src[2],src[3]);
+	       src += 4;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_LUMINANCE:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x );
+	 stride = (image->Width - width);
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0], 255);
+	       src += 1;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_INTENSITY:
+	 src = (GLubyte *)image->Data + (  y * image->Width + x );
+	 stride = (image->Width - width);
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],src[0],src[0]);
+	       src += 1;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_ALPHA:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x );
+	 stride = (image->Width - width);
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR8888(255,255,255,src[0]);
+	       src += 1;
+	    }
+	    src += stride;
+	 }
+	 break;
+      case GL_LUMINANCE_ALPHA:
+	 src = (GLubyte *)image->Data + ( y * image->Width + x ) * 2;
+	 stride = (image->Width - width) * 2;
+	 for ( i = height ; i ; i-- ) {
+	    for ( j = width ; j ; j-- ) {
+			
+	       *destPtr++ = MGAPACKCOLOR8888(src[0],src[0],
+					     src[0],src[1]);
+	       src += 2;
+	    }
+	    src += stride;
+	 }
+	 break;
+      default:
+	 goto format_error;
+      }
+      break;
+   default:
+      goto format_error;
+   }
+
+   return;
+
+ format_error:
+
+   fprintf(stderr, "Unsupported texelBytes %i, image->Format %i\n", 
+	   (int)texelBytes, (int)image->Format );
+}
Index: xc/lib/GL/mesa/src/drv/mga/mgatexmem.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/mga/mgatexmem.c:1.1
--- /dev/null	Mon Dec 18 14:23:33 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgatexmem.c	Sun Sep 24 09:51:08 2000
@@ -0,0 +1,492 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatexmem.c,v 1.1 2000/09/24 13:51:08 alanh Exp $ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <GL/gl.h>
+
+#include "mm.h"
+#include "mgacontext.h"
+#include "mgatex.h"
+#include "mgaregs.h"
+#include "mgaioctl.h"
+
+#include "mem.h"
+#include "simple_list.h"
+
+static void 
+mgaSwapOutTexObj(mgaContextPtr mmesa, mgaTextureObjectPtr t)
+{
+   if (t->MemBlock) {
+      mmFreeMem(t->MemBlock);
+      t->MemBlock = 0;      
+
+      if (t->age > mmesa->dirtyAge)
+	 mmesa->dirtyAge = t->age;
+   }
+
+   t->dirty_images = ~0;
+   move_to_tail(&(mmesa->SwappedOut), t);
+}
+
+static void 
+mgaPrintLocalLRU( mgaContextPtr mmesa, int heap ) 
+{
+   mgaTextureObjectPtr t;
+   int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]);
+
+   fprintf(stderr, "\nLocal LRU, heap %d:\n", heap);
+
+   foreach( t, &(mmesa->TexObjList[heap]) ) {
+      if (!t->tObj)
+	 fprintf(stderr, "Placeholder %d at %x sz %x\n", 
+		 t->MemBlock->ofs / sz,
+		 t->MemBlock->ofs,
+		 t->MemBlock->size);      
+      else
+	 fprintf(stderr, "Texture (bound %d) at %x sz %x\n", 
+		 t->bound,
+		 t->MemBlock->ofs,
+		 t->MemBlock->size);
+   }
+
+   fprintf(stderr, "\n\n");
+}
+
+static void 
+mgaPrintGlobalLRU( mgaContextPtr mmesa, int heap )
+{
+   int i, j;
+   drm_mga_tex_region_t *list = mmesa->sarea->texList[heap];
+
+   fprintf(stderr, "\nGlobal LRU, heap %d list %p:\n", heap, list);
+
+   for (i = 0, j = MGA_NR_TEX_REGIONS ; i < MGA_NR_TEX_REGIONS ; i++) {
+      fprintf(stderr, "list[%d] age %d next %d prev %d\n",
+	      j, list[j].age, list[j].next, list[j].prev);
+      j = list[j].next;
+      if (j == MGA_NR_TEX_REGIONS) break;
+   }
+   
+   if (j != MGA_NR_TEX_REGIONS) {
+      fprintf(stderr, "Loop detected in global LRU\n\n\n");
+      for (i = 0 ; i < MGA_NR_TEX_REGIONS ; i++) {
+	 fprintf(stderr, "list[%d] age %d next %d prev %d\n",
+		 i, list[i].age, list[i].next, list[i].prev);
+      }
+   }
+   
+   fprintf(stderr, "\n\n");
+}
+
+
+static void mgaResetGlobalLRU( mgaContextPtr mmesa, GLuint heap )
+{
+   drm_mga_tex_region_t *list = mmesa->sarea->texList[heap];
+   int sz = 1 << mmesa->mgaScreen->logTextureGranularity[heap];
+   int i;
+
+   mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap];
+
+   if (0) fprintf(stderr, "mgaResetGlobalLRU %d\n", (int)heap);
+
+   /* (Re)initialize the global circular LRU list.  The last element
+    * in the array (MGA_NR_TEX_REGIONS) is the sentinal.  Keeping it
+    * at the end of the array allows it to be addressed rationally
+    * when looking up objects at a particular location in texture
+    * memory.  
+    */
+   for (i = 0 ; (i+1) * sz <= mmesa->mgaScreen->textureSize[heap] ; i++) {
+      list[i].prev = i-1;
+      list[i].next = i+1;
+      list[i].age = mmesa->sarea->texAge[heap];   
+   }
+
+   i--;
+   list[0].prev = MGA_NR_TEX_REGIONS;
+   list[i].prev = i-1;
+   list[i].next = MGA_NR_TEX_REGIONS;
+   list[MGA_NR_TEX_REGIONS].prev = i;
+   list[MGA_NR_TEX_REGIONS].next = 0;
+
+}
+
+
+static void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t ) 
+{
+   int i;
+   int heap = t->heap;
+   int logsz = mmesa->mgaScreen->logTextureGranularity[heap];
+   int start = t->MemBlock->ofs >> logsz;
+   int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
+   drm_mga_tex_region_t *list = mmesa->sarea->texList[heap];
+   
+   mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap];
+
+   if (!t->MemBlock) {
+      fprintf(stderr, "no memblock\n\n");
+      return;
+   }
+
+   /* Update our local LRU
+    */
+   move_to_head( &(mmesa->TexObjList[heap]), t );
+
+
+   if (0)
+      fprintf(stderr, "mgaUpdateTexLRU heap %d list %p\n", heap, list);
+
+
+   /* Update the global LRU
+    */
+   for (i = start ; i <= end ; i++) {
+
+      list[i].in_use = 1;
+      list[i].age = mmesa->texAge[heap];
+
+      /* remove_from_list(i)
+       */
+      list[(unsigned)list[i].next].prev = list[i].prev;
+      list[(unsigned)list[i].prev].next = list[i].next;
+      
+      /* insert_at_head(list, i)
+       */
+      list[i].prev = MGA_NR_TEX_REGIONS;
+      list[i].next = list[MGA_NR_TEX_REGIONS].next;
+      list[(unsigned)list[MGA_NR_TEX_REGIONS].next].prev = i;
+      list[MGA_NR_TEX_REGIONS].next = i;
+   }
+
+   if (0) {
+      mgaPrintGlobalLRU(mmesa, t->heap);
+      mgaPrintLocalLRU(mmesa, t->heap);
+   }
+}
+
+/* Called for every shared texture region which has increased in age
+ * since we last held the lock.
+ *
+ * Figures out which of our textures have been ejected by other clients,
+ * and pushes a placeholder texture onto the LRU list to represent 
+ * the other client's textures.  
+ */
+static void mgaTexturesGone( mgaContextPtr mmesa,
+			     GLuint heap,
+			     GLuint offset, 
+			     GLuint size,
+			     GLuint in_use ) 
+{
+   mgaTextureObjectPtr t, tmp;
+
+
+
+   foreach_s ( t, tmp, &(mmesa->TexObjList[heap]) ) {
+
+      if (t->MemBlock->ofs >= offset + size ||
+	  t->MemBlock->ofs + t->MemBlock->size <= offset)
+	 continue;
+
+
+
+
+      /* It overlaps - kick it off.  Need to hold onto the currently bound
+       * objects, however.
+       */
+      if (t->bound) 
+	 mgaSwapOutTexObj( mmesa, t );
+      else
+	 mgaDestroyTexObj( mmesa, t );
+   }
+
+   
+   if (in_use) {
+      t = (mgaTextureObjectPtr) CALLOC(sizeof(*t));
+      if (!t) return;
+
+      t->heap = heap;
+      t->MemBlock = mmAllocMem( mmesa->texHeap[heap], size, 0, offset);      
+      if (!t->MemBlock) {
+	 fprintf(stderr, "Couldn't alloc placeholder sz %x ofs %x\n",
+		 (int)size, (int)offset);
+	 mmDumpMemInfo( mmesa->texHeap[heap]);
+	 return;
+      }
+      insert_at_head( &(mmesa->TexObjList[heap]), t );
+   }
+}
+
+
+void mgaAgeTextures( mgaContextPtr mmesa, int heap )
+{
+   drm_mga_sarea_t *sarea = mmesa->sarea;
+   int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]);
+   int idx, nr = 0;
+
+   /* Have to go right round from the back to ensure stuff ends up
+    * LRU in our local list...  Fix with a cursor pointer.
+    */
+   for (idx = sarea->texList[heap][MGA_NR_TEX_REGIONS].prev ; 
+	idx != MGA_NR_TEX_REGIONS && nr < MGA_NR_TEX_REGIONS ; 
+	idx = sarea->texList[heap][idx].prev, nr++)
+   {
+      if (sarea->texList[heap][idx].age > mmesa->texAge[heap]) {
+	 mgaTexturesGone(mmesa, heap, idx * sz, sz, 1);
+      }
+   }
+
+   if (nr == MGA_NR_TEX_REGIONS) {
+      mgaTexturesGone(mmesa, heap, 0,
+		      mmesa->mgaScreen->textureSize[heap], 0);
+      mgaResetGlobalLRU( mmesa, heap );
+   }
+
+	
+   if (0) {
+      mgaPrintGlobalLRU( mmesa, heap );
+      mgaPrintLocalLRU( mmesa, heap );
+   }
+
+   mmesa->texAge[heap] = sarea->texAge[heap];
+   mmesa->dirty |= MGA_UPLOAD_TEX0IMAGE | MGA_UPLOAD_TEX1IMAGE;
+}
+
+/*
+ * mgaUploadSubImageLocked
+ *
+ * Perform an iload based update of a resident buffer.  This is used for
+ * both initial loading of the entire image, and texSubImage updates.
+ *
+ * Performed with the hardware lock held.
+ */
+static void mgaUploadSubImageLocked( mgaContextPtr mmesa,
+				     mgaTextureObjectPtr t,
+				     int level,	     
+				     int x, int y, int width, int height ) 
+{
+   int		x2;
+   int		dwords;
+   int		offset;
+   struct gl_texture_image *image;
+   int		texelBytes, texelsPerDword, texelMaccess, length;
+
+   if ( level < 0 || level >= MGA_TEX_MAXLEVELS ) 
+      return;
+
+   image = t->tObj->Image[level];
+   if ( !image ) return;
+
+
+   if (image->Data == 0) {
+      fprintf(stderr, "null texture image data tObj %p level %d\n",
+	      t->tObj, level);
+      return;
+   }
+		
+	
+   /* find the proper destination offset for this level */
+   offset = (t->MemBlock->ofs + 
+	     t->offsets[level]);
+
+
+   texelBytes = t->texelBytes;	
+   switch( texelBytes ) {
+   case 1:
+      texelsPerDword = 4;
+      texelMaccess = 0;
+      break;
+   case 2:
+      texelsPerDword = 2;
+      texelMaccess = 1;
+      break;
+   case 4:
+      texelsPerDword = 1;
+      texelMaccess = 2;
+      break;
+   default:
+      return;
+   }
+			
+		
+   /* We can't do a subimage update if pitch is < 32 texels due
+    * to hardware XY addressing limits, so we will need to
+    * linearly upload all modified rows.
+    */
+   if ( image->Width < 32 ) {
+      x = 0;
+      width = image->Width * height;
+      height = 1;
+
+      /* Assume that 1x1 textures aren't going to cause a
+       * bus error if we read up to four texels from that
+       * location: 
+       */
+/*        if ( width < texelsPerDword ) { */
+/*  	 width = texelsPerDword; */
+/*        } */
+   } else {
+      /* pad the size out to dwords.  The image is a pointer
+	 to the entire image, so we can safely reference
+	 outside the x,y,width,height bounds if we need to */
+      x2 = x + width;
+      x2 = (x2 + (texelsPerDword-1)) & ~(texelsPerDword-1);	
+      x = (x + (texelsPerDword-1)) & ~(texelsPerDword-1);
+      width = x2 - x;
+   }
+
+   /* we may not be able to upload the entire texture in one
+      batch due to register limits or dma buffer limits.
+      Recursively split it up. */
+   while ( 1 ) {
+      dwords = height * width / texelsPerDword;
+      if ( dwords * 4 <= MGA_DMA_BUF_SZ ) {
+	 break;
+      }
+
+      mgaUploadSubImageLocked( mmesa, t, level, x, y, 
+			       width, height >> 1 );
+      y += ( height >> 1 );
+      height -= ( height >> 1 );
+   }
+	
+   length = dwords * 4;
+
+   /* Fill in the secondary buffer with properly converted texels
+    * from the mesa buffer. */
+   if(t->heap == MGA_CARD_HEAP) {
+      mgaGetILoadBufferLocked( mmesa );
+      mgaConvertTexture( (GLuint *)mmesa->iload_buffer->address, 
+			 texelBytes, image, x, y, width, height ); 
+      if(length < 64) length = 64;
+
+      if (0)
+	 fprintf(stderr, "TexelBytes : %d, offset: %d, length : %d\n",
+		 texelBytes,
+		 mmesa->mgaScreen->textureOffset[t->heap] +
+		 offset + 
+		 y * width * 4/texelsPerDword,
+		 length);
+	   
+      mgaFireILoadLocked( mmesa, 
+			  mmesa->mgaScreen->textureOffset[t->heap] +
+			  offset + 
+			  y * width * 4/texelsPerDword,
+			  length);
+   } else {
+      /* This works, is slower for uploads to card space and needs
+       * additional synchronization with the dma stream.
+       */
+      mgaConvertTexture( (GLuint *)
+			 (mmesa->mgaScreen->texVirtual[t->heap] + 
+			  offset + 
+			  y * width * 4/texelsPerDword), 
+			 texelBytes, image, x, y, width, height ); 
+   }
+}
+
+
+static void mgaUploadTexLevel( mgaContextPtr mmesa, 
+			       mgaTextureObjectPtr t,
+			       int l )
+{
+/*     return; */
+	mgaUploadSubImageLocked( mmesa,
+				 t,
+				 l,
+				 0, 0,
+				 t->tObj->Image[l]->Width,
+				 t->tObj->Image[l]->Height);
+}
+
+
+
+
+#if 0
+static void mgaMigrateTexture( mgaContextPtr mmesa, mgaTextureObjectPtr t )
+{
+	/* NOT DONE */
+}
+#endif
+
+
+static int mgaChooseTexHeap( mgaContextPtr mmesa, mgaTextureObjectPtr t )
+{
+	return 0;
+}
+
+
+int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t )
+{
+   int heap;
+   int i;
+   int ofs;
+
+   heap = t->heap = mgaChooseTexHeap( mmesa, t );
+
+   /* Do we need to eject LRU texture objects?
+    */
+   if (!t->MemBlock) {
+      while (1)
+      {
+	 mgaTextureObjectPtr tmp = mmesa->TexObjList[heap].prev;
+
+	 t->MemBlock = mmAllocMem( mmesa->texHeap[heap], 
+				   t->totalSize,
+				   6, 0 ); 
+	 if (t->MemBlock)
+	    break;
+
+	 if (mmesa->TexObjList[heap].prev->bound) {
+	    fprintf(stderr, 
+		    "Hit bound texture in upload\n"); 
+	    return -1;
+	 }
+
+	 if (mmesa->TexObjList[heap].prev == 
+	     &(mmesa->TexObjList[heap])) 
+	 {
+	    fprintf(stderr, "Failed to upload texture, "
+		    "sz %d\n", t->totalSize);
+	    mmDumpMemInfo( mmesa->texHeap[heap] );
+	    return -1;
+	 }
+	 
+	 mgaDestroyTexObj( mmesa, tmp );
+      }
+ 
+      ofs = t->MemBlock->ofs 
+	 + mmesa->mgaScreen->textureOffset[heap]
+	 ;
+
+      t->Setup[MGA_TEXREG_ORG]  = ofs;
+      t->Setup[MGA_TEXREG_ORG1] = ofs + t->offsets[1];
+      t->Setup[MGA_TEXREG_ORG2] = ofs + t->offsets[2];
+      t->Setup[MGA_TEXREG_ORG3] = ofs + t->offsets[3];
+      t->Setup[MGA_TEXREG_ORG4] = ofs + t->offsets[4];
+
+      mmesa->dirty |= MGA_UPLOAD_CTX;
+   }
+
+   /* Let the world know we've used this memory recently.
+    */
+   mgaUpdateTexLRU( mmesa, t );
+
+	
+   if (MGA_DEBUG&DEBUG_VERBOSE_LRU)
+      fprintf(stderr, "dispatch age: %d age freed memory: %d\n",
+	      GET_DISPATCH_AGE(mmesa), mmesa->dirtyAge);
+
+   if (mmesa->dirtyAge >= GET_DISPATCH_AGE(mmesa)) 
+      mgaWaitAgeLocked( mmesa, mmesa->dirtyAge );
+
+   if (t->dirty_images) {
+      if (MGA_DEBUG&DEBUG_VERBOSE_LRU)
+	 fprintf(stderr, "*");
+
+      for (i = 0 ; i <= t->lastLevel ; i++)
+	 if (t->dirty_images & (1<<i)) 
+	    mgaUploadTexLevel( mmesa, t, i );
+   }
+
+
+   t->dirty_images = 0;
+   return 0;
+}
Index: xc/lib/GL/mesa/src/drv/mga/mgatris.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgatris.c:1.2 xc/lib/GL/mesa/src/drv/mga/mgatris.c:1.5
--- xc/lib/GL/mesa/src/drv/mga/mgatris.c:1.2	Fri Jun 16 20:03:02 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgatris.c	Sun Sep 24 09:51:08 2000
@@ -23,6 +23,7 @@
  *
  *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatris.c,v 1.5 2000/09/24 13:51:08 alanh Exp $ */
 
 #include <stdio.h>
 #include <math.h>
@@ -32,22 +33,27 @@
 #include "pipeline.h"
 
 #include "mm.h"
-#include "mgalib.h"
+#include "mgacontext.h"
 #include "mgatris.h"
 #include "mgavb.h"
-#include "mgalog.h"
 
 
 static void mga_null_quad( GLcontext *ctx, GLuint v0,
-			   GLuint v1, GLuint v2, GLuint v3, GLuint pv ) {
+			   GLuint v1, GLuint v2, GLuint v3, GLuint pv ) 
+{
 }     
+
 static void mga_null_triangle( GLcontext *ctx, GLuint v0,
-			       GLuint v1, GLuint v2, GLuint pv ) {
+			       GLuint v1, GLuint v2, GLuint pv ) 
+{
 }     
-static void mga_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) {
+
+static void mga_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) 
+{
 }
 
-static void mga_null_points( GLcontext *ctx, GLuint first, GLuint last ) {
+static void mga_null_points( GLcontext *ctx, GLuint first, GLuint last ) 
+{
 }
 
 
@@ -60,22 +66,10 @@
 
 
 
-static triangle_func tri_tab[0x20];   
-static quad_func     quad_tab[0x20];  
-static line_func     line_tab[0x20];  
-static points_func   points_tab[0x20];
-
-static void mgaPrintRenderState( const char *msg, GLuint state )
-{
-   mgaMsg(1, "%s: (%x) %s%s%s%s%s%s\n",
-	   msg, state,
-	   (state & MGA_FLAT_BIT)       ? "flat, "       : "",
-	   (state & MGA_OFFSET_BIT)     ? "offset, "     : "",
-	   (state & MGA_TWOSIDE_BIT)    ? "twoside, "    : "",
-	   (state & MGA_ANTIALIAS_BIT)  ? "antialias, "  : "",
-	   (state & MGA_NODRAW_BIT)     ? "no-draw, "    : "",
-	   (state & MGA_FALLBACK_BIT)   ? "fallback"     : "");
-}
+static triangle_func tri_tab[0x10];   
+static quad_func     quad_tab[0x10];  
+static line_func     line_tab[0x10];  
+static points_func   points_tab[0x10];
 
 #define IND (0)
 #define TAG(x) x
@@ -109,6 +103,7 @@
 #define TAG(x) x##_twoside_offset_flat
 #include "mgatritmp.h"
 
+
 void mgaDDTrifuncInit()
 {
    int i;
@@ -124,8 +119,7 @@
    init_twoside_offset_flat();
 
    for (i = 0 ; i < 0x20 ; i++) 
-      if ((i & (MGA_NODRAW_BIT|MGA_FALLBACK_BIT)) == MGA_NODRAW_BIT)
-      {
+      if (i & MGA_NODRAW_BIT) {
 	 quad_tab[i] = mga_null_quad; 
 	 tri_tab[i] = mga_null_triangle; 
 	 line_tab[i] = mga_null_line;
@@ -135,84 +129,71 @@
 
 
 
-
-
-
-void mgaDDChooseRenderState( GLcontext *ctx )
+#define ALL_FALLBACK (DD_MULTIDRAW | DD_SELECT | DD_FEEDBACK)
+#define POINT_FALLBACK (ALL_FALLBACK | DD_POINT_SMOOTH)
+#define LINE_FALLBACK (ALL_FALLBACK | DD_LINE_SMOOTH | DD_LINE_STIPPLE)
+#define TRI_FALLBACK (ALL_FALLBACK | DD_TRI_SMOOTH | DD_TRI_UNFILLED)
+#define ANY_FALLBACK (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|DD_TRI_STIPPLE)
+#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_Z_NEVER)
+
+/* Setup the Point, Line, Triangle and Quad functions based on the
+   current rendering state.  Wherever possible, use the hardware to
+   render the primitive.  Otherwise, fallback to software rendering. */
+void mgaDDChooseRenderState(GLcontext *ctx)
 {
-   mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-   GLuint flags = ctx->TriangleCaps;
-
-   if (mmesa->Fallback)
-      return;
-
-   mmesa->IndirectTriangles = 0;
-
-   if (flags) {
-      GLuint ind = 0;
-      GLuint shared = 0;
-
-      if (flags & DD_Z_NEVER)                      shared |= MGA_NODRAW_BIT;
-      if (flags & DD_FLATSHADE)                    shared |= MGA_FLAT_BIT;
-      if (flags & (DD_MULTIDRAW|
-		   DD_SELECT|
-		   DD_FEEDBACK))                   shared |= MGA_FALLBACK_BIT;
-      if (flags & DD_STENCIL)                      shared |= MGA_FALLBACK_BIT;
-
-      ind = shared;
-#if 0
-      if (flags & DD_POINT_SMOOTH)                 ind |= MGA_ANTIALIAS_BIT;
-#else
-      if (flags & DD_POINT_SMOOTH)                 ind |= MGA_FALLBACK_BIT;
-#endif
-
-      mmesa->renderindex = ind;
-      mmesa->PointsFunc = points_tab[ind];
-      if (ind & MGA_FALLBACK_BIT) 
-	 mmesa->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
-
-      ind = shared;
-#if 0
-      if (flags & DD_LINE_SMOOTH)                   ind |= MGA_ANTIALIAS_BIT;
-#else
-      if (flags & DD_LINE_SMOOTH)                   ind |= MGA_FALLBACK_BIT;
-#endif
-      if (flags & DD_LINE_STIPPLE)                  ind |= MGA_FALLBACK_BIT;
-
-      mmesa->renderindex |= ind;
-      mmesa->LineFunc = line_tab[ind];
-      if (ind & MGA_FALLBACK_BIT) 
-	 mmesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
-
-      ind = shared;
-      if (flags & DD_TRI_SMOOTH)                    ind |= MGA_ANTIALIAS_BIT;
-      if (flags & DD_TRI_OFFSET)                    ind |= MGA_OFFSET_BIT;
-      if (flags & DD_TRI_LIGHT_TWOSIDE)             ind |= MGA_TWOSIDE_BIT;
-      if (flags & DD_TRI_UNFILLED)                  ind |= MGA_FALLBACK_BIT;
-      if ((flags & DD_TRI_STIPPLE) &&
-	  (ctx->IndirectTriangles & DD_TRI_STIPPLE)) ind |= MGA_FALLBACK_BIT;	
-
-      mmesa->renderindex |= ind;
-      mmesa->TriangleFunc = tri_tab[ind];
-      mmesa->QuadFunc = quad_tab[ind];
-      if (ind & MGA_FALLBACK_BIT)
-	 mmesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE | 
-				      DD_QUAD_SW_RASTERIZE);
-   } 
-   else if (mmesa->renderindex)
-   {
-      mmesa->renderindex  = 0;
-      mmesa->PointsFunc   = points_tab[0];
-      mmesa->LineFunc     = line_tab[0];
-      mmesa->TriangleFunc = tri_tab[0];
-      mmesa->QuadFunc     = quad_tab[0];
-   }
-
-   if (0) {
-      gl_print_tri_caps("tricaps", ctx->TriangleCaps);
-      mgaPrintRenderState("mga: Render state", mmesa->renderindex);
-   }
+    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+    GLuint flags = ctx->TriangleCaps;
+    GLuint index = 0;
+
+    if (mmesa->Fallback) {
+	mmesa->renderindex = MGA_FALLBACK_BIT;
+	return;
+    }
+
+    if (flags & ANY_RASTER_FLAGS) {
+	if (flags & DD_FLATSHADE)               index |= MGA_FLAT_BIT;
+	if (flags & DD_TRI_LIGHT_TWOSIDE)       index |= MGA_TWOSIDE_BIT;
+	if (flags & DD_TRI_OFFSET)              index |= MGA_OFFSET_BIT; 
+	if (flags & DD_Z_NEVER)                 index |= MGA_NODRAW_BIT; 
+    }
+	
+    mmesa->PointsFunc = points_tab[index];
+    mmesa->LineFunc = line_tab[index];
+    mmesa->TriangleFunc = tri_tab[index];
+    mmesa->QuadFunc = quad_tab[index];
+
+    mmesa->renderindex = index;
+    mmesa->IndirectTriangles = 0;
+
+    if (flags & ANY_FALLBACK) {
+	if (flags & POINT_FALLBACK) {
+	    mmesa->renderindex |= MGA_FALLBACK_BIT;
+	    mmesa->PointsFunc = 0;
+	    mmesa->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
+	}
+	    
+	if (flags & LINE_FALLBACK) {
+	    mmesa->renderindex |= MGA_FALLBACK_BIT;
+	    mmesa->LineFunc = 0;
+	    mmesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
+	}
+
+	if (flags & TRI_FALLBACK) {
+	    mmesa->renderindex |= MGA_FALLBACK_BIT;
+	    mmesa->TriangleFunc = 0;
+	    mmesa->QuadFunc = 0;
+	    mmesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
+					 DD_QUAD_SW_RASTERIZE);
+	}
+	/* Special cases:
+	 */
+	if ((flags & DD_TRI_STIPPLE) &&
+	    (ctx->IndirectTriangles & DD_TRI_STIPPLE)) {
+	    mmesa->renderindex |= MGA_FALLBACK_BIT;
+	    mmesa->TriangleFunc = 0;
+	    mmesa->QuadFunc = 0;
+	    mmesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
+					 DD_QUAD_SW_RASTERIZE);
+	}
+    }
 }
-
-
-
Index: xc/lib/GL/mesa/src/drv/mga/mgatris.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgatris.h:1.2 xc/lib/GL/mesa/src/drv/mga/mgatris.h:1.5
--- xc/lib/GL/mesa/src/drv/mga/mgatris.h:1.2	Fri Jun 16 20:03:02 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgatris.h	Sun Sep 24 09:51:08 2000
@@ -23,92 +23,184 @@
  *
  *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatris.h,v 1.5 2000/09/24 13:51:08 alanh Exp $ */
 
 #ifndef MGATIS_INC
 #define MGATIS_INC
 
 #include "types.h"
+#include "mgaioctl.h"
 
 extern void mgaDDChooseRenderState(GLcontext *ctx);
 extern void mgaDDTrifuncInit( void );
 
 
-/* Todo: 
- *    - Antialiasing (?)
- *    - line and polygon stipple
- *    - stencil 
- */
-#define MGA_ANTIALIAS_BIT   0       /* ignored for now, no fallback */
 #define MGA_FLAT_BIT	    0x1
 #define MGA_OFFSET_BIT	    0x2	
 #define MGA_TWOSIDE_BIT	    0x4	
 #define MGA_NODRAW_BIT	    0x8
 #define MGA_FALLBACK_BIT    0x10
 
+extern int nrswaps;
 
 
+#define VERTSIZE vertsize
 
+/*  static float _v0[] = { */
+/*     242.202515, */
+/*     250.469604, */
+/*     0.961081, */
+/*     0.013503, */
+/*     0, */
+/*     0.000000, */
+/*     2.600000, */
+/*     0.000000, */
+/*     1.000000, */
+/*     0.600000 */
+/*  }; */
+
+/*  static float _v1[] = { */
+/*     246.448914, */
+/*     54.697876, */
+/*     0.953817, */
+/*     0.014156, */
+/*     0, */
+/*     0.000000, */
+/*     2.600000, */
+/*     2.000000, */
+/*     1.000000, */
+/*     1.600000 */
+/*  }; */
+
+/*  static float _v2[] = { */
+/*     55.999474, */
+/*     85.196106, */
+/*     0.942609, */
+/*     0.015165, */
+/*     0, */
+/*     0.000000, */
+/*     0.600000, */
+/*     2.000000, */
+/*     0.000000, */
+/*     1.600000, */
+/*  }; */
+
 static __inline void mga_draw_triangle( mgaContextPtr mmesa,
 				      mgaVertex *v0, 
 				      mgaVertex *v1, 
 				      mgaVertex *v2 )
 {
-   mgaUI32 vertsize = mmesa->vertsize;
-   mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 3 * vertsize );
+   GLuint vertsize = mmesa->vertsize;
+   GLuint *wv = mgaAllocVertexDwordsInline( mmesa, 3 * VERTSIZE );
    int j;
+
+   (void) vertsize;
 
-   for (j = 0 ; j < vertsize ; j++) 
-      wv[j] = v0->ui[j];
+/*     for (j = 0 ; j < vertsize ; j++)  */
+/*        fprintf(stderr, "v0 %d: %f 0x%x\n", j, v0->f[j], v0->ui[j]); */
 
-   wv += vertsize;
-   for (j = 0 ; j < vertsize ; j++) 
-      wv[j] = v1->ui[j];
-
-   wv += vertsize;
-   for (j = 0 ; j < vertsize ; j++) 
-      wv[j] = v2->ui[j];
+/*     for (j = 0 ; j < vertsize ; j++)  */
+/*        fprintf(stderr, "v1 %d: %f 0x%x\n", j, v1->f[j], v1->ui[j]); */
+
+/*     for (j = 0 ; j < vertsize ; j++)  */
+/*        fprintf(stderr, "v2 %d: %f 0x%x\n", j, v2->f[j], v2->ui[j]); */
+
+/*     v0 = (mgaVertex *)_v0; */
+/*     v1 = (mgaVertex *)_v1; */
+/*     v2 = (mgaVertex *)_v2; */
+
+
+/*     if (v0->v.x < 0 || v0->v.x > 1920 || */
+/*         v0->v.y < 0 || v0->v.y > 1440 || */
+/*         v0->v.z < 0 || v0->v.z > 1)  */
+/*        fprintf(stderr, "v0 %f %f %f %f\n", v0->v.x, v0->v.y, v0->v.z, v0->v.rhw); */
+
+
+/*     if (v1->v.x < 0 || v1->v.x > 1920 || */
+/*         v1->v.y < 0 || v1->v.y > 1440 || */
+/*         v1->v.z < 0 || v1->v.z > 1)  */
+/*        fprintf(stderr, "v1 %f %f %f %f\n", v1->v.x, v1->v.y, v1->v.z, v1->v.rhw); */
+
+/*     if (v2->v.x < 0 || v2->v.x > 1920 || */
+/*         v2->v.y < 0 || v2->v.y > 1440 || */
+/*         v2->v.z < 0 || v2->v.z > 1)  */
+/*        fprintf(stderr, "v2 %f %f %f %f\n", v2->v.x, v2->v.y, v2->v.z, v2->v.rhw); */
+      
+
+#if defined (USE_X86_ASM)
+   /* GTH: We can safely assume the vertex stride is some number of
+    * dwords, and thus a "rep movsd" is okay.  The vb pointer is
+    * automagically updated with this instruction, so we don't have
+    * to manually take care of incrementing it.
+    */
+      __asm__ __volatile__( "rep ; movsl"
+			    : "=%c" (j)
+			    : "0" (VERTSIZE), "D" ((long)wv), "S" ((long)v0)
+			    : "memory" );
+      __asm__ __volatile__( "rep ; movsl"
+			    : "=%c" (j)
+			    : "0" (VERTSIZE), "S" ((long)v1)
+			    : "memory" );
+      __asm__ __volatile__( "rep ; movsl"
+			    : "=%c" (j)
+			    : "0" (VERTSIZE), "S" ((long)v2)
+			    : "memory" );
+#else
+   {
+      for (j = 0 ; j < vertsize ; j++) 
+	 wv[j] = v0->ui[j];
+
+      wv += VERTSIZE;
+      for (j = 0 ; j < vertsize ; j++) 
+	 wv[j] = v1->ui[j];
+
+      wv += VERTSIZE;
+      for (j = 0 ; j < vertsize ; j++) 
+	 wv[j] = v2->ui[j];
+   }
+#endif
 }
 
 
 static __inline void mga_draw_point( mgaContextPtr mmesa,
 				   mgaVertex *tmp, float sz )
 {
-   mgaUI32 vertsize = mmesa->vertsize;
-   mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 6*vertsize);
+   GLuint vertsize = mmesa->vertsize;
+   GLuint *wv = mgaAllocVertexDwords( mmesa, 6*VERTSIZE);
    int j;
 
-   *(float *)&wv[0] = tmp->warp1.x - sz;
-   *(float *)&wv[1] = tmp->warp1.y - sz;
+   *(float *)&wv[0] = tmp->v.x - sz;
+   *(float *)&wv[1] = tmp->v.y - sz;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 
-   *(float *)&wv[0] = tmp->warp1.x + sz;
-   *(float *)&wv[1] = tmp->warp1.y - sz;
+   *(float *)&wv[0] = tmp->v.x + sz;
+   *(float *)&wv[1] = tmp->v.y - sz;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 
-   *(float *)&wv[0] = tmp->warp1.x + sz;
-   *(float *)&wv[1] = tmp->warp1.y + sz;
+   *(float *)&wv[0] = tmp->v.x + sz;
+   *(float *)&wv[1] = tmp->v.y + sz;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 
-   *(float *)&wv[0] = tmp->warp1.x + sz;
-   *(float *)&wv[1] = tmp->warp1.y + sz;
+   *(float *)&wv[0] = tmp->v.x + sz;
+   *(float *)&wv[1] = tmp->v.y + sz;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 
-   *(float *)&wv[0] = tmp->warp1.x - sz;
-   *(float *)&wv[1] = tmp->warp1.y + sz;
+   *(float *)&wv[0] = tmp->v.x - sz;
+   *(float *)&wv[1] = tmp->v.y + sz;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 
-   *(float *)&wv[0] = tmp->warp1.x - sz;
-   *(float *)&wv[1] = tmp->warp1.y - sz;
+   *(float *)&wv[0] = tmp->v.x - sz;
+   *(float *)&wv[1] = tmp->v.y - sz;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp->ui[j];
 }
@@ -119,13 +211,13 @@
 				  const mgaVertex *tmp1,
 				  float width )
 {
-   mgaUI32 vertsize = mmesa->vertsize;
-   mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 6 * vertsize );
+   GLuint vertsize = mmesa->vertsize;
+   GLuint *wv = mgaAllocVertexDwords( mmesa, 6 * VERTSIZE );
    float dx, dy, ix, iy;
    int j;
 
-   dx = tmp0->warp1.x - tmp1->warp1.x;
-   dy = tmp0->warp1.y - tmp1->warp1.y;
+   dx = tmp0->v.x - tmp1->v.x;
+   dy = tmp0->v.y - tmp1->v.y;
 
    ix = width * .5; iy = 0;
   
@@ -136,41 +228,41 @@
       iy = ix; ix = 0;
    }
   
-   *(float *)&wv[0] = tmp0->warp1.x - ix;
-   *(float *)&wv[1] = tmp0->warp1.y - iy;
+   *(float *)&wv[0] = tmp0->v.x - ix;
+   *(float *)&wv[1] = tmp0->v.y - iy;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp0->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 
-   *(float *)&wv[0] = tmp1->warp1.x + ix;
-   *(float *)&wv[1] = tmp1->warp1.y + iy;
+   *(float *)&wv[0] = tmp1->v.x + ix;
+   *(float *)&wv[1] = tmp1->v.y + iy;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp1->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 
-   *(float *)&wv[0] = tmp0->warp1.x + ix;
-   *(float *)&wv[1] = tmp0->warp1.y + iy;
+   *(float *)&wv[0] = tmp0->v.x + ix;
+   *(float *)&wv[1] = tmp0->v.y + iy;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp0->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 	 
-   *(float *)&wv[0] = tmp0->warp1.x - ix;
-   *(float *)&wv[1] = tmp0->warp1.y - iy;
+   *(float *)&wv[0] = tmp0->v.x - ix;
+   *(float *)&wv[1] = tmp0->v.y - iy;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp0->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 
-   *(float *)&wv[0] = tmp1->warp1.x - ix;
-   *(float *)&wv[1] = tmp1->warp1.y - iy;
+   *(float *)&wv[0] = tmp1->v.x - ix;
+   *(float *)&wv[1] = tmp1->v.y - iy;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp1->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 
-   *(float *)&wv[0] = tmp1->warp1.x + ix;
-   *(float *)&wv[1] = tmp1->warp1.y + iy;
+   *(float *)&wv[0] = tmp1->v.x + ix;
+   *(float *)&wv[1] = tmp1->v.y + iy;
    for (j = 2 ; j < vertsize ; j++) 
       wv[j] = tmp1->ui[j];
-   wv += vertsize;
+   wv += VERTSIZE;
 }
 
 
Index: xc/lib/GL/mesa/src/drv/mga/mgatritmp.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgatritmp.h:1.2 xc/lib/GL/mesa/src/drv/mga/mgatritmp.h:1.5
--- xc/lib/GL/mesa/src/drv/mga/mgatritmp.h:1.2	Fri Jun 16 20:03:02 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgatritmp.h	Tue Dec  5 16:18:34 2000
@@ -1,94 +1,109 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatritmp.h,v 1.5 2000/12/05 21:18:34 dawes Exp $ */
 
-static __inline void TAG(triangle)( GLcontext *ctx, GLuint e0,
-				  GLuint e1, GLuint e2, GLuint pv )
+static __inline void TAG(triangle)(GLcontext *ctx,
+				   GLuint e0, GLuint e1, GLuint e2,
+				   GLuint pv)
 {
-   mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-   GLuint vertsize = mmesa->vertsize;
-   mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 3 * vertsize);
+   mgaContextPtr        mmesa   = MGA_CONTEXT(ctx);
+   struct vertex_buffer *VB        = ctx->VB;
+   mgaVertexPtr         mgaverts = MGA_DRIVER_DATA(VB)->verts;
+   mgaVertex     *v[3];
 
-   struct vertex_buffer *VB = ctx->VB;
-   mgaVertexPtr mgaVB = MGA_DRIVER_DATA(VB)->verts;
-   const mgaVertex *v[3];
-   int i, j;
-
 #if (IND & MGA_OFFSET_BIT)
-   GLfloat offset = ctx->Polygon.OffsetUnits * 1.0/0x10000;
+   GLfloat offset;
+   GLfloat z[3];
 #endif
-
-#if (IND & (MGA_FLAT_BIT|MGA_TWOSIDE_BIT))
-   mgaUI32 c[3];
 
-   c[2] = c[1] = c[0] = *(mgaUI32 *)&mgaVB[pv].warp2.color; 
+#if (IND & (MGA_TWOSIDE_BIT | MGA_FLAT_BIT))
+   GLuint c[3];
 #endif
 
-   (void) VB;
+   v[0] = &mgaverts[e0];
+   v[1] = &mgaverts[e1];
+   v[2] = &mgaverts[e2];
 
-   v[0] = &mgaVB[e0];  
-   v[1] = &mgaVB[e1];  
-   v[2] = &mgaVB[e2];  
+#if (IND & (MGA_TWOSIDE_BIT | MGA_FLAT_BIT))
+   c[0] = v[0]->ui[4];
+   c[1] = v[1]->ui[4];
+   c[2] = v[2]->ui[4];
+#endif
 
 
-#if (IND & (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT)) 
+#if (IND & (MGA_TWOSIDE_BIT | MGA_OFFSET_BIT))
    {
-      GLfloat ex = v[0]->warp1.x - v[2]->warp1.x;
-      GLfloat ey = v[0]->warp1.y - v[2]->warp1.y;
-      GLfloat fx = v[1]->warp1.x - v[2]->warp1.x;
-      GLfloat fy = v[1]->warp1.y - v[2]->warp1.y;
-      GLfloat cc = ex*fy-ey*fx;
-	 
-#if (IND & MGA_TWOSIDE_BIT) 
+      GLfloat ex = v[0]->v.x - v[2]->v.x;
+      GLfloat ey = v[0]->v.y - v[2]->v.y;
+      GLfloat fx = v[1]->v.x - v[2]->v.x;
+      GLfloat fy = v[1]->v.y - v[2]->v.y;
+      GLfloat cc  = ex*fy - ey*fx;
+
+#if (IND & MGA_TWOSIDE_BIT)
       {
-	 GLuint facing = (cc>0.0) ^ ctx->Polygon.FrontBit;
+	 GLuint  facing        = (cc > 0.0) ^ ctx->Polygon.FrontBit;
 	 GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
 	 if (IND & MGA_FLAT_BIT) {
-	    MGA_COLOR((char *)&c[0],vbcolor[pv]);
-	    c[2] = c[1] = c[0];
+	    MGA_COLOR((char *)&v[0]->ui[4], vbcolor[pv]);
+	    v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
 	 } else {
-	    MGA_COLOR((char *)&c[0],vbcolor[e0]);
-	    MGA_COLOR((char *)&c[1],vbcolor[e1]);
-	    MGA_COLOR((char *)&c[2],vbcolor[e2]);
+	    MGA_COLOR((char *)&v[0]->ui[4], vbcolor[e0]);
+	    MGA_COLOR((char *)&v[1]->ui[4], vbcolor[e1]);
+	    MGA_COLOR((char *)&v[2]->ui[4], vbcolor[e2]);
 	 }
       }
 #endif
-      
-#if (IND & MGA_OFFSET_BIT) 
+
+#if (IND & MGA_OFFSET_BIT)
       {
+	 offset = ctx->Polygon.OffsetUnits * mmesa->depth_scale;
+	 z[0] = v[0]->v.z;
+	 z[1] = v[1]->v.z;
+	 z[2] = v[2]->v.z;
 	 if (cc * cc > 1e-16) {
-	    GLfloat factor = ctx->Polygon.OffsetFactor;
-	    GLfloat ez = v[0]->warp1.z - v[2]->warp1.z;
-	    GLfloat fz = v[1]->warp1.z - v[2]->warp1.z;
-	    GLfloat a = ey*fz-ez*fy;
-	    GLfloat b = ez*fx-ex*fz;
-	    GLfloat ic = 1.0 / cc;
-	    GLfloat ac = a * ic;
-	    GLfloat bc = b * ic;
-	    if (ac<0.0F)  ac = -ac;
-	    if (bc<0.0F)  bc = -bc;
-	    offset += MAX2( ac, bc ) * factor;
+	    GLfloat ez     = z[0] - z[2];
+	    GLfloat fz     = z[1] - z[2];
+	    GLfloat a      = ey*fz - ez*fy;
+	    GLfloat b      = ez*fx - ex*fz;
+	    GLfloat ic     = 1.0 / cc;
+	    GLfloat ac     = a * ic;
+	    GLfloat bc     = b * ic;
+	    if (ac < 0.0f) ac = -ac;
+	    if (bc < 0.0f) bc = -bc;
+	    offset += MAX2(ac, bc) * ctx->Polygon.OffsetFactor;
 	 }
+	 v[0]->v.z += offset;
+	 v[1]->v.z += offset;
+	 v[2]->v.z += offset;
       }
 #endif
    }
-#endif  
-
-   mgaglx.c_triangles++;
-
-   for (j = 0 ; j < 3 ; j++, wv += vertsize) {
+#elif (IND & MGA_FLAT_BIT)
+   {
+      GLuint color = mgaverts[pv].ui[4];
+      v[0]->ui[4] = color;
+      v[1]->ui[4] = color;
+      v[2]->ui[4] = color;
+   }
+#endif
 
-      for (i = 0 ; i < vertsize ; i++)
-	 wv[i] = v[j]->ui[i];
+   mga_draw_triangle( mmesa, v[0], v[1], v[2] );
 
-#if (IND & (MGA_FLAT_BIT|MGA_TWOSIDE_BIT))
-      wv[4] = c[j];		/* color is the fifth element... */
-#endif
 #if (IND & MGA_OFFSET_BIT)
-      *(float *)&wv[2] = v[j]->warp1.z + offset;
+   v[0]->v.z = z[0];
+   v[1]->v.z = z[1];
+   v[2]->v.z = z[2];
 #endif
-   }
+
+#if (IND & (MGA_FLAT_BIT | MGA_TWOSIDE_BIT))
+   v[0]->ui[4] = c[0];
+   v[1]->ui[4] = c[1];
+   v[2]->ui[4] = c[2];    
+#endif
+
 }
 
 
 
+
 static void TAG(quad)( GLcontext *ctx, GLuint v0,
 		       GLuint v1, GLuint v2, GLuint v3, 
 		       GLuint pv )
@@ -103,30 +118,48 @@
    mgaContextPtr mmesa = MGA_CONTEXT( ctx );
    mgaVertexPtr mgaVB = MGA_DRIVER_DATA(ctx->VB)->verts;
    float width = ctx->Line.Width;
+   GLfloat z0, z1;
+   GLuint c0, c1;
+   mgaVertex *vert0 = &mgaVB[v0];
+   mgaVertex *vert1 = &mgaVB[v1];
 
-   if (IND & (MGA_TWOSIDE_BIT|MGA_FLAT_BIT)) {
-      mgaVertex tmp0 = mgaVB[v0];
-      mgaVertex tmp1 = mgaVB[v1];
 
-      if (IND & MGA_TWOSIDE_BIT) {
-	 GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
-
-	 if (IND & MGA_FLAT_BIT) {
- 	    MGA_COLOR((char *)&tmp0.warp1.color,vbcolor[pv]);
-	    *(int *)&tmp1.warp1.color = *(int *)&tmp0.warp1.color;
-	 } else {
-	    MGA_COLOR((char *)&tmp0.warp1.color,vbcolor[v0]);
-	    MGA_COLOR((char *)&tmp1.warp1.color,vbcolor[v1]);
-	 }
-
+   if (IND & MGA_TWOSIDE_BIT) {
+      GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
+
+      if (IND & MGA_FLAT_BIT) {
+	 MGA_COLOR((char *)&vert0->v.color,vbcolor[pv]);
+	 *(int *)&vert1->v.color = *(int *)&vert0->v.color;
       } else {
-	 *(int *)&tmp0.warp1.color = *(int *)&mgaVB[pv].warp1.color;
-	 *(int *)&tmp1.warp1.color = *(int *)&mgaVB[pv].warp1.color;
+	 MGA_COLOR((char *)&vert0->v.color,vbcolor[v0]);
+	 MGA_COLOR((char *)&vert1->v.color,vbcolor[v1]);
       }
-      mga_draw_line( mmesa, &tmp0, &tmp1, width );
+   } else if (IND & MGA_FLAT_BIT) {
+      c0 = *(GLuint *) &(vert0->v.color);
+      c1 = *(GLuint *) &(vert1->v.color);
+      *(int *)&vert0->v.color = 
+	 *(int *)&vert1->v.color = *(int *)&mgaVB[pv].v.color;
    }
-   else
-      mga_draw_line( mmesa, &mgaVB[v0], &mgaVB[v1], width );
+
+   if (IND & MGA_OFFSET_BIT) {
+      GLfloat offset = ctx->LineZoffset * mmesa->depth_scale; 
+      z0 = vert0->v.z;
+      z1 = vert1->v.z;
+      vert0->v.z += offset;
+      vert1->v.z += offset;
+   }
+
+   mga_draw_line( mmesa, &mgaVB[v0], &mgaVB[v1], width );
+
+   if (IND & MGA_OFFSET_BIT) {
+      vert0->v.z = z0;
+      vert1->v.z = z1;
+   }
+   
+   if ((IND & MGA_FLAT_BIT) && !(IND & MGA_TWOSIDE_BIT)) {
+      *(GLuint *) &(vert0->v.color) = c0;
+      *(GLuint *) &(vert1->v.color) = c1;
+   }
 }
 
 
@@ -138,12 +171,18 @@
    GLfloat sz = ctx->Point.Size * .5;
    int i;
    
-   for(i=first;i<=last;i++) 
+   for(i=first;i<last;i++) 
       if(VB->ClipMask[i]==0) {
-	 if (IND & MGA_TWOSIDE_BIT) {	
-	    GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
+	 if (IND & (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT)) {	
 	    mgaVertex tmp0 = mgaVB[i];
-	    MGA_COLOR((char *)&tmp0.warp1.color, vbcolor[i]);
+	    if (IND & MGA_TWOSIDE_BIT) {
+	       GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
+	       MGA_COLOR((char *)&tmp0.v.color, vbcolor[i]);
+	    }
+	    if (IND & MGA_OFFSET_BIT) {
+	       GLfloat offset = ctx->PointZoffset * mmesa->depth_scale;
+	       tmp0.v.z += offset;
+	    }
 	    mga_draw_point( mmesa, &tmp0, sz );
 	 } else
 	    mga_draw_point( mmesa, &mgaVB[i], sz );
@@ -157,10 +196,8 @@
 {
    tri_tab[IND] = TAG(triangle);
    quad_tab[IND] = TAG(quad);
-
    line_tab[IND] = TAG(line);
    points_tab[IND] = TAG(points);
-
 }
 
 
Index: xc/lib/GL/mesa/src/drv/mga/mgavb.c
diff -u xc/lib/GL/mesa/src/drv/mga/mgavb.c:1.3 xc/lib/GL/mesa/src/drv/mga/mgavb.c:1.7
--- xc/lib/GL/mesa/src/drv/mga/mgavb.c:1.3	Tue Jun 20 01:08:41 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgavb.c	Wed Nov  8 00:02:46 2000
@@ -23,46 +23,49 @@
  *
  *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgavb.c,v 1.7 2000/11/08 05:02:46 dawes Exp $ */
  
-#include "mgalib.h"
+#include "mgacontext.h"
 #include "mgavb.h"
-#include "mgalog.h"
+#include "mga_xmesa.h"
+
 #include "stages.h"
+#include "mem.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 
 #define TEX0 {					\
-  v->warp2.tu0 = tc0[i][0];			\
-  v->warp2.tv0 = tc0[i][1];			\
+  v->v.tu0 = tc0[i][0];			\
+  v->v.tv0 = tc0[i][1];			\
 }
 
 #define TEX1 {					\
-  v->warp2.tu1 = tc1[i][0];			\
-  v->warp2.tv1 = tc1[i][1];			\
+  v->v.tu1 = tc1[i][0];			\
+  v->v.tv1 = tc1[i][1];			\
 }
 
 #define SPC {					\
   GLubyte *spec = &(VB->Spec[0][i][0]);		\
-  v->warp2.specular.red = spec[0];		\
-  v->warp2.specular.green = spec[1];		\
-  v->warp2.specular.blue = spec[2];		\
+  v->v.specular.red = spec[0];		\
+  v->v.specular.green = spec[1];		\
+  v->v.specular.blue = spec[2];		\
 }
 
 #define FOG {					\
   GLubyte *spec = &(VB->Spec[0][i][0]);		\
-  v->warp2.specular.alpha = spec[3];		\
+  v->v.specular.alpha = spec[3];		\
 }
 
 #define COL {					\
   GLubyte *col = &(VB->Color[0]->data[i][0]);	\
-  v->warp2.color.blue  = col[2];		\
-  v->warp2.color.green = col[1];		\
-  v->warp2.color.red   = col[0];		\
-  v->warp2.color.alpha = col[3];		\
+  v->v.color.blue  = col[2];		\
+  v->v.color.green = col[1];		\
+  v->v.color.red   = col[0];		\
+  v->v.color.alpha = col[3];		\
 }
 
-/* The warp2 code we have doesn't seem to support projective texturing
+/* The v code we have doesn't seem to support projective texturing
  * in the multitexture case.  (Would require another 1/w value for the
  * second set of texcoords).  This may be a problem for the g400.  
  */
@@ -74,19 +77,20 @@
      mmesa->setupdone &= ~MGA_WIN_BIT;			\
      for (i=start; i < end; i++, v++)	{		\
         float oow = 1.0 / tc[i][3];			\
-	v->warp2.rhw *= tc[i][3];			\
-	v->warp2.tu0 *= oow;				\
-	v->warp2.tv0 *= oow;				\
+	v->v.rhw *= tc[i][3];			\
+	v->v.tu0 *= oow;				\
+	v->v.tv0 *= oow;				\
      }							\
   }
 
+
+#define COORD						\
+      GLfloat *win = VB->Win.data[i];			\
+      v->v.rhw =               win[3];			\
+      v->v.z = depth_scale * win[2];			\
+      v->v.x =                 win[0] + xoffset;	\
+      v->v.y =          -      win[1] + yoffset;  
 
-#define COORD							\
-      GLfloat *win = VB->Win.data[i];				\
-      v->warp2.rhw =               win[3];			\
-      v->warp2.z = (1.0/0x10000) * win[2];			\
-      v->warp2.x =                 win[0] + xoffset;		\
-      v->warp2.y =          -      win[1] + yoffset; 
 
 #define NOP
 
@@ -100,11 +104,12 @@
    mgaVertexPtr v;							\
    GLfloat (*tc0)[4];							\
    GLfloat (*tc1)[4];							\
-   GLfloat xoffset = mmesa->drawX + SUBPIXEL_X;				\
-   GLfloat yoffset = mmesa->driDrawable->h + mmesa->drawY + SUBPIXEL_Y;	\
+   const GLfloat depth_scale = mmesa->depth_scale;			\
+   const GLfloat xoffset = mmesa->drawX + SUBPIXEL_X;			\
+   const GLfloat yoffset = mmesa->driDrawable->h + mmesa->drawY + \
+                           SUBPIXEL_Y;	\
    int i;								\
-   (void) xoffset; (void) yoffset;					\
-   if (0) fprintf(stderr, "V");						\
+   (void) xoffset; (void) yoffset; (void) depth_scale;			\
    gl_import_client_data( VB, VB->ctx->RenderFlags,			\
 			  (VB->ClipOrMask				\
 			   ? VEC_WRITABLE|VEC_GOOD_STRIDE		\
@@ -178,7 +183,7 @@
 
 static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end)
 {
-  mgaError("mgaRasterSetup(): invalid combination\n");
+   fprintf(stderr, "mgaRasterSetup(): invalid combination\n");
 }
 
 typedef void (*setupFunc)(struct vertex_buffer *,GLuint,GLuint);
@@ -253,6 +258,7 @@
 {
    mgaContextPtr mmesa = MGA_CONTEXT( ctx );
    int funcindex = (MGA_WIN_BIT | MGA_RGBA_BIT);
+   int multi = mmesa->multitex;
 
    mmesa->vertsize = 8;
    mmesa->tmu_source[0] = 0;
@@ -262,7 +268,7 @@
    mmesa->multitex = 0;
    mmesa->blend_flags &= ~MGA_BLEND_MULTITEX;
 
-   if (ctx->Texture.Enabled & 0xf) {
+   if (ctx->Texture.ReallyEnabled & 0xf) {
       /* This doesn't work for non-RGBA textures
       if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
 	 funcindex &= ~MGA_RGBA_BIT;
@@ -279,8 +285,8 @@
       funcindex |= MGA_TEX0_BIT;
    }
 
-   if (ctx->Texture.Enabled & 0xf0) {     
-      if (ctx->Texture.Enabled & 0xf) {
+   if (ctx->Texture.ReallyEnabled & 0xf0) {     
+      if (ctx->Texture.ReallyEnabled & 0xf) {
 	 mmesa->multitex = 1;
 	 mmesa->vertsize = 10;
 	 mmesa->blend_flags |= MGA_BLEND_MULTITEX;
@@ -309,6 +315,19 @@
       }
    }
 
+/*       if (mmesa->multitex == 0) {  */
+/*          mmesa->tmu_source[1] = mmesa->tmu_source[0];  */
+/*          mmesa->tex_dest[1] = mmesa->tex_dest[0];  */
+/*          mmesa->vertsize = 10;  */
+/*          mmesa->multitex = 1;  */
+/*          funcindex |= MGA_TEX0_BIT|MGA_TEX1_BIT;  */
+/*       }  */
+
+/*     mmesa->vertsize = 10; */
+   if (multi != mmesa->multitex)
+        mmesa->new_state |= MGA_NEW_WARP; 
+
+
    /* Not really a good place to do this - need to make the mga state
     * management code more event-driven so this can be calculated for
     * free.
@@ -420,7 +439,6 @@
 }
 
 
-
 void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size )
 {
    mgaVertexBufferPtr mvb = MGA_DRIVER_DATA(VB);
@@ -428,8 +446,8 @@
    while (mvb->size < size)
       mvb->size *= 2;
 
-   free( mvb->vert_store );
-   mvb->vert_store = malloc( sizeof(mgaVertex) * mvb->size + 31);
+   FREE( mvb->vert_store );
+   mvb->vert_store = MALLOC( sizeof(mgaVertex) * mvb->size + 31);
    if (!mvb->vert_store) 
       FatalError("mga-glx: out of memory !\n");
 
@@ -440,16 +458,16 @@
    if (!mvb->clipped_elements.start) 
       FatalError("mga-glx: out of memory !\n");
 
-   free( VB->ClipMask );
-   VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
+   ALIGN_FREE( VB->ClipMask );
+   VB->ClipMask = (GLubyte *)ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 32);
    if (!VB->ClipMask) 
       FatalError("mga-glx: out of memory !\n");
 
    if (VB->Type == VB_IMMEDIATE) {
-      free( mvb->primitive );
-      free( mvb->next_primitive );
-      mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
-      mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
+      FREE( mvb->primitive );
+      FREE( mvb->next_primitive );
+      mvb->primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size );
+      mvb->next_primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size );
       if (!mvb->primitive || !mvb->next_primitive)
 	 FatalError("mga-glx: out of memory!");
    }
@@ -460,14 +478,14 @@
 {
    mgaVertexBufferPtr mvb;
 
-   mvb = (mgaVertexBufferPtr)calloc( 1, sizeof(*mvb) );
+   mvb = (mgaVertexBufferPtr)MALLOC( sizeof(*mvb) );
 
    /* This looks like it allocates a lot of memory, but it basically
     * just sets an upper limit on how much can be used - nothing like
     * this amount will ever be turned into 'real' memory.
     */
    mvb->size = VB->Size * 5;
-   mvb->vert_store = malloc( sizeof(mgaVertex) * mvb->size + 31);
+   mvb->vert_store = MALLOC( sizeof(mgaVertex) * mvb->size + 31);
    if (!mvb->vert_store) 
       FatalError("mga-glx: out of memory !\n");
    
@@ -477,13 +495,13 @@
    if (!mvb->clipped_elements.start) 
       FatalError("mga-glx: out of memory !\n");
 
-   free( VB->ClipMask );
-   VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size);
+   ALIGN_FREE( VB->ClipMask );
+   VB->ClipMask = (GLubyte *)ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 32);
    if (!VB->ClipMask) 
       FatalError("mga-glx: out of memory !\n");
 
-   mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
-   mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
+   mvb->primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size );
+   mvb->next_primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size );
    if (!mvb->primitive || !mvb->next_primitive)
       FatalError("mga-glx: out of memory!");
    
@@ -496,11 +514,11 @@
    mgaVertexBufferPtr mvb = MGA_DRIVER_DATA(VB);
    
    if (mvb) {
-      if (mvb->vert_store) free(mvb->vert_store);
-      if (mvb->primitive) free(mvb->primitive);
-      if (mvb->next_primitive) free(mvb->next_primitive);
+      if (mvb->vert_store) FREE(mvb->vert_store);
+      if (mvb->primitive) FREE(mvb->primitive);
+      if (mvb->next_primitive) FREE(mvb->next_primitive);
       gl_vector1ui_free( &mvb->clipped_elements );
-      free(mvb);
+      FREE(mvb);
       VB->driver_data = 0;
    }      
 }
Index: xc/lib/GL/mesa/src/drv/mga/mgavb.h
diff -u xc/lib/GL/mesa/src/drv/mga/mgavb.h:1.2 xc/lib/GL/mesa/src/drv/mga/mgavb.h:1.5
--- xc/lib/GL/mesa/src/drv/mga/mgavb.h:1.2	Fri Jun 16 20:03:02 2000
+++ xc/lib/GL/mesa/src/drv/mga/mgavb.h	Sun Sep 24 09:51:09 2000
@@ -23,13 +23,13 @@
  *
  *    Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
  */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgavb.h,v 1.5 2000/09/24 13:51:09 alanh Exp $ */
 
 #ifndef MGAVB_INC
 #define MGAVB_INC
 
 #include "types.h"
 #include "vb.h"
-#include "mgacommon.h"
 
 
 /* common datatypes for the mga warp engines */
@@ -46,37 +46,27 @@
 } mga_warp_color;
 
 
-/* 
- *  vertex type used for the single-warp g200
- */
-typedef struct mga_warp_vertex_t {
-  GLfloat		x,y,z;	        /* coordinates in screen space*/
-  GLfloat 		rhw;	        /* reciprocal homogeneous w */
-  mga_warp_color	color;		/* vertex color */
-  mga_warp_color	specular;	/* specular color, alpha is fog */
-  GLfloat		tu0,tv0;	/* texture coordinates */
-} mga_warp_vertex1;
 
 /*
- *  vertex type used for the dual-warp g400
+ * The vertex structure.  The final tu1/tv1 values only used in multitexture
+ * modes.
  */
-typedef struct mga_warp_vertex2_t {
+typedef struct mga_warp_vertex_t {
   GLfloat		x,y,z;	        /* coordinates in screen space*/
   GLfloat 		rhw;	        /* reciprocal homogeneous w */
   mga_warp_color	color;		/* vertex color */
   mga_warp_color	specular;	/* specular color, alpha is fog */
   GLfloat		tu0,tv0;	/* texture coordinates */
   GLfloat		tu1,tv1;	/* same for second stage */
-} mga_warp_vertex2;
+} mga_warp_vertex;
 
 
 /* The fastpath code still expects a 16-float stride vertex.
  */
 union mga_vertex_t {
-   mga_warp_vertex1 warp1;	
-   mga_warp_vertex2 warp2;
+   mga_warp_vertex v;	
    float f[16];
-   mgaUI32 ui[16];
+   GLuint ui[16];
 };
 
 typedef union mga_vertex_t mgaVertex;
@@ -91,9 +81,9 @@
    void *vert_store;
    GLuint size;
 
-   mgaUI32 *vert_buf;
-   mgaUI32 *elt_buf;
-   mgaUI32 vert_phys_start;
+   GLuint *vert_buf;
+   GLuint *elt_buf;
+   GLuint vert_phys_start;
 };
    
 typedef struct mga_vertex_buffer_t *mgaVertexBufferPtr;
Index: xc/lib/GL/mesa/src/drv/r128/Imakefile
diff -u xc/lib/GL/mesa/src/drv/r128/Imakefile:1.4 xc/lib/GL/mesa/src/drv/r128/Imakefile:1.11
--- xc/lib/GL/mesa/src/drv/r128/Imakefile:1.4	Mon Jun 26 01:41:29 2000
+++ xc/lib/GL/mesa/src/drv/r128/Imakefile	Tue Dec 12 18:24:28 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/drv/r128/Imakefile,v 1.4 2000/06/26 05:41:29 martin Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/r128/Imakefile,v 1.11 2000/12/12 23:24:28 dawes Exp $
 
 #include <Threads.tmpl>
 
@@ -13,12 +13,17 @@
 #endif
 
 #ifdef i386Architecture
-#ifdef MesaUse3DNow
-  ASM_DEFINES = -DUSE_MMX_ASM -DUSE_X86_ASM -DUSE_3DNOW_ASM
-#else
-  ASM_DEFINES = -DUSE_MMX_ASM -DUSE_X86_ASM
+#if MesaUseMMX
+     MMX_DEFS = -DUSE_MMX_ASM
 #endif
+#if MesaUse3DNow
+   3DNOW_DEFS = -DUSE_3DNOW_ASM
 #endif
+#if MesaUseKatmai
+  KATMAI_DEFS = -DUSE_KATMAI_ASM
+#endif
+  ASM_DEFINES = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(KATMAI_DEFS)
+#endif
 
 #if BuildXF86DRI
   DRI_DEFINES = GlxDefines -DDRIVERTS
@@ -30,48 +35,44 @@
 		-I$(XF86OSSRC) \
 		-I$(XF86COMSRC) \
 		-I$(SERVERSRC)/GL/dri \
-		-I$(XF86DRIVERSRC)/r128 \
+		-I$(XF86DRIVERSRC)/ati \
 		-I../../../include \
 		-I../.. \
 		-I../../X \
 		-I../common
 #endif
-
-LinkSourceFile(mm.c, ../common)
-LinkSourceFile(mm.h, ../common)
-LinkSourceFile(hwlog.c, ../common)
-LinkSourceFile(hwlog.h, ../common)
 
-MESA_INCLUDES = -I. -I.. -I../../include
+MESA_INCLUDES = -I. -I.. -I../../include \
+		-I../../../../dri/drm
 
       DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFINES)
      INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
 
-     R128SRCS = r128_cce.c \
-		r128_clear.c \
-		r128_context.c \
+     R128SRCS = r128_context.c \
 		r128_dd.c \
 		r128_fastpath.c \
+		r128_eltpath.c \
+		r128_ioctl.c \
+		r128_lock.c \
 		r128_pipeline.c \
                 r128_screen.c \
 		r128_span.c \
 		r128_state.c \
-		r128_swap.c \
 		r128_tex.c \
 		r128_tris.c \
 		r128_vb.c \
 		r128_xmesa.c
 
-     R128OBJS = r128_cce.o \
-		r128_clear.o \
-		r128_context.o \
+     R128OBJS = r128_context.o \
 		r128_dd.o \
 		r128_fastpath.o \
+		r128_eltpath.o \
+		r128_ioctl.o \
+		r128_lock.o \
 		r128_pipeline.o \
                 r128_screen.o \
 		r128_span.o \
 		r128_state.o \
-		r128_swap.o \
 		r128_tex.o \
 		r128_tris.o \
 		r128_vb.o \
@@ -245,26 +246,40 @@
 		../../zoom.o
 
 #ifdef i386Architecture
-     X86_SRCS = ../../X86/x86.c \
-		../../X86/x86a.S \
-		../../X86/common_x86.c \
-		../../X86/common_x86asm.S \
-		../../X86/vertex.S
-
-     X86_OBJS = ../../X86/x86.o \
-		../../X86/x86a.o \
-		../../X86/common_x86.o \
-		../../X86/common_x86asm.o \
-		../../X86/vertex.o
+     X86_SRCS = ../../X86/common_x86.c \
+		../../X86/common_x86_asm.S \
+		../../X86/x86.c \
+		../../X86/x86_cliptest.S \
+		../../X86/x86_vertex.S \
+		../../X86/x86_xform_masked2.S \
+		../../X86/x86_xform_masked3.S \
+		../../X86/x86_xform_masked4.S \
+		../../X86/x86_xform_raw2.S \
+		../../X86/x86_xform_raw3.S \
+		../../X86/x86_xform_raw4.S
+
+     X86_OBJS = ../../X86/common_x86.o \
+		../../X86/common_x86_asm.o \
+		../../X86/x86.o \
+		../../X86/x86_cliptest.o \
+		../../X86/x86_vertex.o \
+		../../X86/x86_xform_masked2.o \
+		../../X86/x86_xform_masked3.o \
+		../../X86/x86_xform_masked4.o \
+		../../X86/x86_xform_raw2.o \
+		../../X86/x86_xform_raw3.o \
+		../../X86/x86_xform_raw4.o
 
+#if MesaUseMMX
      MMX_SRCS = ../../X86/mmx_blend.S
 
      MMX_OBJS = ../../X86/mmx_blend.o
+#endif
 
-XCOMM Disabling 3Dnow code for the time being.
-#if 0
+#if MesaUse3DNow
    3DNOW_SRCS = ../../X86/3dnow.c \
 		../../X86/3dnow_norm_raw.S \
+		../../X86/3dnow_vertex.S \
 		../../X86/3dnow_xform_masked1.S \
 		../../X86/3dnow_xform_masked2.S \
 		../../X86/3dnow_xform_masked3.S \
@@ -272,11 +287,11 @@
 		../../X86/3dnow_xform_raw1.S \
 		../../X86/3dnow_xform_raw2.S \
 		../../X86/3dnow_xform_raw3.S \
-		../../X86/3dnow_xform_raw4.S \
-		../../X86/vertex_3dnow.S
+		../../X86/3dnow_xform_raw4.S
 
    3DNOW_OBJS = ../../X86/3dnow.o \
 		../../X86/3dnow_norm_raw.o \
+		../../X86/3dnow_vertex.o \
 		../../X86/3dnow_xform_masked1.o \
 		../../X86/3dnow_xform_masked2.o \
 		../../X86/3dnow_xform_masked3.o \
@@ -284,29 +299,62 @@
 		../../X86/3dnow_xform_raw1.o \
 		../../X86/3dnow_xform_raw2.o \
 		../../X86/3dnow_xform_raw3.o \
-		../../X86/3dnow_xform_raw4.o \
-		../../X86/vertex_3dnow.o
+		../../X86/3dnow_xform_raw4.o
 #endif
 
+#if MesaUseKatmai
+  KATMAI_SRCS = ../../X86/katmai.c \
+		../../X86/katmai_norm_raw.S \
+		../../X86/katmai_vertex.S \
+		../../X86/katmai_xform_masked1.S \
+		../../X86/katmai_xform_masked2.S \
+		../../X86/katmai_xform_masked3.S \
+		../../X86/katmai_xform_masked4.S \
+		../../X86/katmai_xform_raw1.S \
+		../../X86/katmai_xform_raw2.S \
+		../../X86/katmai_xform_raw3.S \
+		../../X86/katmai_xform_raw4.S
+
+  KATMAI_OBJS = ../../X86/katmai.o \
+		../../X86/katmai_norm_raw.o \
+		../../X86/katmai_vertex.o \
+		../../X86/katmai_xform_masked1.o \
+		../../X86/katmai_xform_masked2.o \
+		../../X86/katmai_xform_masked3.o \
+		../../X86/katmai_xform_masked4.o \
+		../../X86/katmai_xform_raw1.o \
+		../../X86/katmai_xform_raw2.o \
+		../../X86/katmai_xform_raw3.o \
+		../../X86/katmai_xform_raw4.o
+#endif
 #endif
 #endif
 
-      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
-      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+#ifdef GlxSoProf
+       LOSRCS = ../../../../lowpc.c
+       HISRCS = ../../../../highpc.c
 
-   COMMONSRCS = mm.c hwlog.c
-   COMMONOBJS = mm.o hwlog.o
+       LOOBJS = ../../../../lowpc.o
+       HIOBJS = ../../../../highpc.o
+#endif
 
-         SRCS = $(DRISRCS) $(DRMSRCS) $(MESASRCS) $(ASMSRCS) \
-		$(COMMONSRCS) $(R128SRCS)
-         OBJS = $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) \
-		$(COMMONOBJS) $(R128OBJS)
+      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS)
+      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS)
 
-REQUIREDLIBS += -lm
-#if !GlxBuiltInMga
+   COMMONSRCS = ../common/mm.c ../common/hwlog.c
+   COMMONOBJS = ../common/mm.o ../common/hwlog.o
+
+         SRCS = $(LOSRCS) $(DRISRCS) $(DRMSRCS) $(MESASRCS) \
+		$(ASMSRCS) $(COMMONSRCS) $(R128SRCS) $(HISRCS)
+         OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) \
+		$(ASMOBJS) $(COMMONOBJS) $(R128OBJS) $(HIOBJS)
+
+REQUIREDLIBS += MathLibrary
+#if !GlxBuiltInR128
 REQUIREDLIBS += -L../../../.. -lGL
 #endif
 
+
 #if !GlxUseBuiltInDRIDriver
 #undef DoNormalLib NormalLibGlx
 #undef DoExtraLib SharedLibGlx
@@ -327,6 +375,12 @@
 ALL_DEPS = DONE
 SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
 InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _r128_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
 #endif
 
 DependTarget()
Index: xc/lib/GL/mesa/src/drv/r128/r128_cce.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_cce.c:1.2 xc/lib/GL/mesa/src/drv/r128/r128_cce.c:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_cce.c:1.2	Mon Jun 26 01:41:29 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_cce.c	Mon Dec 18 14:23:35 2000
@@ -1,330 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_cce.c,v 1.2 2000/06/26 05:41:29 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Gareth Hughes <gareth@precisioninsight.com>
- *
- */
-
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
-#include "r128_context.h"
-#include "r128_lock.h"
-#include "r128_state.h"
-#include "r128_reg.h"
-#include "r128_cce.h"
-
-#define R128_TIMEOUT        2000000
-
-r128_get_buffer_func		r128GetBufferLocked;
-r128_fire_vertices_func		r128FireVerticesLocked;
-
-
-static void r128RingStatus( r128ContextPtr r128ctx )
-{
-   r128ScreenPtr r128scrn = r128ctx->r128Screen;
-   unsigned char *R128MMIO = r128scrn->mmio;
-
-   fprintf( stderr, "GUI_STAT           = 0x%08x\n",
-	    (unsigned int) INREG( R128_GUI_STAT ) );
-   fprintf( stderr, "PM4_STAT           = 0x%08x\n",
-	    (unsigned int) INREG( R128_PM4_STAT ) );
-   fprintf( stderr, "PM4_BUFFER_DL_WPTR = 0x%08x\n",
-	    (unsigned int) INREG( R128_PM4_BUFFER_DL_WPTR ) );
-   fprintf( stderr, "PM4_BUFFER_DL_RPTR = 0x%08x\n",
-	    (unsigned int) INREG( R128_PM4_BUFFER_DL_RPTR ) );
-   fprintf( stderr, "ringWrite          = 0x%08x\n",
-	    r128scrn->SAREA->ringWrite );
-   fprintf( stderr, "*ringReadPtr       = 0x%08x\n",
-	    *r128scrn->ringReadPtr );
-}
-
-
-/* Get a new VB from the pool of vertex buffers in AGP space.
- */
-static drmBufPtr r128_get_buffer_locked( r128ContextPtr r128ctx )
-{
-   int fd = r128ctx->r128Screen->driScreen->fd;
-   int num = 0;
-   int index = 0;
-   int size = 0;
-   int to = 0;
-   drmBufPtr buf = NULL;
-
-   while ( !buf && ( to++ < r128ctx->CCEtimeout ) ) {
-      num = drmR128GetVertexBuffers( fd, 1, &index, &size );
-
-      if ( num > 0 ) {
-	 buf = &r128ctx->r128Screen->vbBufs->list[index];
-	 buf->used = 0;
-#if ENABLE_PERF_BOXES
-	 /* Bump the performance counter */
-	 r128ctx->c_vertexBuffers++;
-#endif
-	 return buf;
-      }
-   }
-
-   if ( !buf ) {
-      drmR128EngineReset( fd );
-      fprintf( stderr, "Error: Could not get new VB... exiting\n" );
-      exit( -1 );
-   }
-
-   return buf;
-}
-
-static void r128_fire_vertices_locked( r128ContextPtr r128ctx )
-{
-   int vertsize = r128ctx->vertsize;
-   int format = r128ctx->vc_format;
-   int index = r128ctx->vert_buf->idx;
-   int offset = r128ctx->r128Screen->vbOffset +
-      index * r128ctx->r128Screen->vbBufSize;
-   int size = r128ctx->vert_buf->used / (vertsize * sizeof(GLuint));
-   int fd = r128ctx->r128Screen->driScreen->fd;
-   int to = 0;
-   int ret;
-   CARD32 prim;
-
-   prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST;
-
-   /* Send the vertex buffer to the hardware */
-   BEGIN_CLIP_LOOP( r128ctx );
-   {
-      R128CCE3( R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3 );
-      R128CCE( offset );
-      R128CCE( size );
-      R128CCE( format );
-      R128CCE( prim | R128_CCE_VC_CNTL_PRIM_WALK_LIST |
-	       (size << R128_CCE_VC_CNTL_NUM_SHIFT) );
-
-      R128CCE_SUBMIT_PACKET();
-   }
-   END_CLIP_LOOP( r128ctx );
-
-   /* Tell the kernel to release the vertex buffer */
-   do {
-      ret = drmR128FlushVertexBuffers( fd, 1, &index, &size, 0 );
-   } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) );
-
-   if ( ret < 0 ) {
-      drmR128EngineReset( fd );
-      fprintf( stderr, "Error: Could not flush VB... exiting\n" );
-      exit( -1 );
-   }
-
-   r128ctx->vert_buf = NULL;
-}
-
-static drmBufPtr r128_get_ring_locked( r128ContextPtr r128ctx )
-{
-   r128ScreenPtr r128scrn = r128ctx->r128Screen;
-   drmBufPtr buf = NULL;
-
-   buf = (drmBufPtr) malloc( sizeof(*buf) );
-
-   buf->idx = -666;
-   buf->total = r128scrn->vbBufSize;
-   buf->used = 0;
-   buf->address = (drmAddress *) malloc( r128scrn->vbBufSize );
-
-#if ENABLE_PERF_BOXES
-   /* Bump the performance counter */
-   r128ctx->c_vertexBuffers++;
-#endif
-
-   return buf;
-}
-
-static void r128_fire_ring_locked( r128ContextPtr r128ctx )
-{
-   int vertsize = r128ctx->vertsize;
-   int format = r128ctx->vc_format;
-   int size = r128ctx->vert_buf->used / (vertsize * sizeof(GLuint));
-   drmBufPtr buf = r128ctx->vert_buf;
-   int dwords = buf->used >> 2;
-   CARD32 prim;
-
-   prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST;
-
-   /* Send the vertex buffer to the hardware */
-   BEGIN_CLIP_LOOP( r128ctx );
-   {
-      R128CCE3( R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, dwords + 1 );
-      R128CCE( format );
-      R128CCE( prim | R128_CCE_VC_CNTL_PRIM_WALK_RING |
-	       (size << R128_CCE_VC_CNTL_NUM_SHIFT) );
-
-      memcpy( &r128ctx->CCEbuf[r128ctx->CCEcount], buf->address, buf->used );
-      r128ctx->CCEcount += dwords;
-
-      R128CCE_SUBMIT_PACKET();
-   }
-   END_CLIP_LOOP( r128ctx );
-
-   free( buf->address );
-   free( buf );
-
-   r128ctx->vert_buf = NULL;
-}
-
-/* Allocate some space in the current vertex buffer.  If the current
- * buffer is full, flush it and grab another one.
- */
-CARD32 *r128AllocVertexDwords( r128ContextPtr r128ctx, int dwords )
-{
-	return r128AllocVertexDwordsInlined( r128ctx, dwords );
-}
-
-
-/* ================================================================ */
-
-
-void r128GetEltBufLocked( r128ContextPtr r128ctx )
-{
-#if 0
-   r128ctx->elt_buf = r128GetBufferLocked( r128ctx );
-#endif
-}
-
-void r128FireEltsLocked( r128ContextPtr r128ctx,
-			 GLuint num_elts, GLuint discard )
-{
-#if 0
-   r128ScreenPtr r128scrn = r128ctx->r128Screen;
-   int vertsize = r128ctx->vertsize;
-   int format = r128ctx->vc_format;
-
-   int index = r128ctx->elt_buf->idx;
-   int offset = r128scrn->vbOffset;
-   int total = r128scrn->vbRgn.size / (vertsize * sizeof(GLuint));
-   int size = r128ctx->elt_buf->used / (vertsize * sizeof(GLuint));
-
-   int fd = r128scrn->driScreen->fd;
-   int to = 0;
-   int ret;
-   CARD32 prim;
-
-   fprintf( stderr, "%s: ofs=0x%x sz=0x%x tot=%d elts=%d discard=%d\n",
-	    __FUNCTION__, offset, size, total, num_elts, discard );
-
-   prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST;
-
-   /* Send the vertex buffer to the hardware */
-   BEGIN_CLIP_LOOP( r128ctx );
-   {
-      R128CCE3( R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3 );
-      R128CCE( offset );
-      R128CCE( size );
-      R128CCE( format );
-      R128CCE( prim | R128_CCE_VC_CNTL_PRIM_WALK_IND |
-	       (num_elts << R128_CCE_VC_CNTL_NUM_SHIFT) );
-
-      /* GTH: We really need indirect buffers for this... */
-
-      R128CCE_SUBMIT_PACKET();
-   }
-   END_CLIP_LOOP( r128ctx );
-
-   if ( discard ) {
-      /* Tell the kernel to release the vertex buffer */
-      do {
-	 ret = drmR128FlushVertexBuffers( fd, 1, &index, &size, 0 );
-      } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) );
-
-      if ( ret < 0 ) {
-	 drmR128EngineReset( fd );
-	 fprintf( stderr, "Error: Could not flush VB... exiting\n" );
-	 exit( -1 );
-      }
-   }
-
-   r128ctx->vert_buf = NULL;
-#endif
-}
-
-void r128FlushEltsLocked( r128ContextPtr r128ctx )
-{
-#if 0
-   if ( r128ctx->first_elt != r128ctx->next_elt ) {
-      r128FireEltsLocked( r128ctx,
-			  (GLuint)r128ctx->next_elt -
-			  (GLuint)r128ctx->first_elt,
-			  0 );
-      r128ctx->first_elt = r128ctx->next_elt;
-   }
-#endif
-}
-
-void r128ReleaseBufLocked( r128ContextPtr r128ctx, drmBufPtr buffer )
-{
-#if 0
-   int index;
-   int size;
-   int fd = r128ctx->r128Screen->driScreen->fd;
-   int to = 0;
-   int ret;
-
-   if ( !buffer ) return;
-
-   index = buffer->idx;
-   size = buffer->used = 0;
-
-   /* Tell the kernel to release the vertex buffer */
-   do {
-      ret = drmR128FlushVertexBuffers( fd, 1, &index, &size, 0 );
-   } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) );
-
-   if ( ret < 0 ) {
-      drmR128EngineReset( fd );
-      fprintf( stderr, "Error: Could not release VB... exiting\n" );
-      exit( -1 );
-   }
-#endif
-}
-
-
-void r128InitVertexBuffers( r128ScreenPtr r128scrn )
-{
-   if ( !r128scrn->IsPCI ) {
-      r128GetBufferLocked = r128_get_buffer_locked;
-      r128FireVerticesLocked = r128_fire_vertices_locked;
-   } else {
-      r128GetBufferLocked = r128_get_ring_locked;
-      r128FireVerticesLocked = r128_fire_ring_locked;
-   }
-
-   /* Provide a fallback for Rage 128 Pro cards until we fix the lockups */
-   if (getenv("LIBGL_USE_RING_VB")) {
-      r128GetBufferLocked = r128_get_ring_locked;
-      r128FireVerticesLocked = r128_fire_ring_locked;
-   }
-}
Index: xc/lib/GL/mesa/src/drv/r128/r128_cce.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_cce.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_cce.h:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_cce.h:1.1	Fri Jun 16 20:03:04 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_cce.h	Mon Dec 18 14:23:35 2000
@@ -1,203 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_cce.h,v 1.1 2000/06/17 00:03:04 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Gareth Hughes <gareth@precisioninsight.com>
- *
- */
-
-#ifndef _R128_CCE_H_
-#define _R128_CCE_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include "r128_dri.h"
-#include "r128_reg.h"
-#include "r128_lock.h"
-#include "r128_xmesa.h"
-
-#include "xf86drmR128.h"
-
-#define R128_DEFAULT_TOTAL_CCE_TIMEOUT 1000000 /* usecs */
-
-typedef union {
-    float f;
-    int   i;
-} floatTOint;
-
-/* Insert an integer value into the CCE ring buffer. */
-#define R128CCE(v)				\
-do {						\
-   r128ctx->CCEbuf[r128ctx->CCEcount] = (v);	\
-   r128ctx->CCEcount++;				\
-} while (0)
-
-/* Insert an floating point value into the CCE ring buffer. */
-#define R128CCEF(v)				\
-do {						\
-   floatTOint fTi;				\
-   fTi.f = (v);					\
-   r128ctx->CCEbuf[r128ctx->CCEcount] = fTi.i;	\
-   r128ctx->CCEcount++;				\
-} while (0)
-
-/* Insert a type-[0123] packet header into the ring buffer */
-#define R128CCE0(p,r,n)   R128CCE((p) | ((n) << 16) | ((r) >> 2))
-#define R128CCE1(p,r1,r2) R128CCE((p) | (((r2) >> 2) << 11) | ((r1) >> 2))
-#define R128CCE2(p)       R128CCE((p))
-#define R128CCE3(p,n)     R128CCE((p) | ((n) << 16))
-
-#define R128CCE_SUBMIT_PACKET()						  \
-do {									  \
-   r128SubmitPacketLocked( r128ctx, r128ctx->CCEbuf, r128ctx->CCEcount ); \
-   r128ctx->CCEcount = 0;						  \
-} while (0)
-
-static __inline void r128SubmitPacketLocked( r128ContextPtr r128ctx,
-					     CARD32 *buf, GLuint count )
-{
-   CARD32 *b;
-   int c = count;
-   int fd = r128ctx->r128Screen->driScreen->fd;
-   int to = 0;
-   int ret;
-
-   do {
-      b = buf + (count - c);
-      ret = drmR128SubmitPacket( fd, b, &c, 0 );
-   } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) );
-
-   if ( ret < 0 ) {
-      drmR128EngineReset( fd );
-      fprintf( stderr, "Error: Could not submit packet... exiting\n" );
-      exit( -1 );
-   }
-}
-
-static __inline void r128WaitForIdleLocked( r128ContextPtr r128ctx )
-{
-    int fd = r128ctx->r128Screen->driScreen->fd;
-    int to = 0;
-    int ret;
-
-    drmR128EngineFlush( fd );
-
-    do {
-	ret = drmR128WaitForIdle( fd );
-    } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) );
-
-    if ( ret < 0 ) {
-	drmR128EngineReset( fd );
-	fprintf( stderr, "Error: Rage 128 timed out... exiting\n" );
-	exit( -1 );
-    }
-}
-
-/* Vertex buffer handling functions:
- */
-extern void r128InitVertexBuffers( r128ScreenPtr r128scrn );
-
-typedef drmBufPtr (*r128_get_buffer_func)( r128ContextPtr r128ctx );
-typedef void (*r128_fire_vertices_func)( r128ContextPtr r128ctx );
-
-extern r128_get_buffer_func		r128GetBufferLocked;
-extern r128_fire_vertices_func		r128FireVerticesLocked;
-
-extern CARD32 *r128AllocVertexDwords( r128ContextPtr r128ctx, int dwords );
-
-extern void r128GetEltBufLocked( r128ContextPtr r128ctx );
-extern void r128FlushEltsLocked( r128ContextPtr r128ctx );
-extern void r128FireEltsLocked( r128ContextPtr r128ctx,
-				GLuint num_elts, GLuint discard );
-extern void r128ReleaseBufLocked( r128ContextPtr r128ctx, drmBufPtr buffer );
-
-
-static __inline void r128FlushVerticesLocked( r128ContextPtr r128ctx )
-{
-    if ( r128ctx->vert_buf && r128ctx->vert_buf->used ) {
-       r128FireVerticesLocked( r128ctx );
-    }
-}
-
-static __inline CARD32 *r128AllocVertexDwordsInlined( r128ContextPtr r128ctx,
-						      int dwords )
-{
-    int bytes = dwords * 4;
-    CARD32 *head;
-
-    if ( !r128ctx->vert_buf ) {
-	LOCK_HARDWARE( r128ctx );
-#if 0
-	if ( r128ctx->first_elt != r128ctx->next_elt ) {
-	    r128FlushEltsLocked( r128ctx );
-	}
-#endif
-	r128ctx->vert_buf = r128GetBufferLocked( r128ctx );
-
-	UNLOCK_HARDWARE( r128ctx );
-    } else if ( r128ctx->vert_buf->used + bytes > r128ctx->vert_buf->total ) {
-	LOCK_HARDWARE( r128ctx );
-
-	r128FlushVerticesLocked( r128ctx );
-	r128ctx->vert_buf = r128GetBufferLocked( r128ctx );
-
-	UNLOCK_HARDWARE( r128ctx );
-    }
-
-    head = (CARD32 *)((char *)r128ctx->vert_buf->address +
-		      r128ctx->vert_buf->used);
-
-    r128ctx->vert_buf->used += bytes;
-    return head;
-}
-
-#define r128WaitForIdle( r128ctx )		\
-do {						\
-   LOCK_HARDWARE( r128ctx );			\
-   r128WaitForIdleLocked( r128ctx );		\
-   UNLOCK_HARDWARE( r128ctx );			\
-} while (0)
-
-#define r128FlushVertices( r128ctx )		\
-do {						\
-   LOCK_HARDWARE( r128ctx );			\
-   r128FlushVerticesLocked( r128ctx );		\
-   UNLOCK_HARDWARE( r128ctx );			\
-} while (0)
-
-#define r128FlushElts( r128ctx )		\
-do {						\
-   LOCK_HARDWARE( r128ctx );			\
-   r128FlushEltsLocked( r128ctx );		\
-   UNLOCK_HARDWARE( r128ctx );			\
-} while (0)
-
-#endif
-#endif /* _R128_CCE_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_clear.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_clear.c:1.2 xc/lib/GL/mesa/src/drv/r128/r128_clear.c:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_clear.c:1.2	Mon Jun 26 01:41:29 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_clear.c	Mon Dec 18 14:23:35 2000
@@ -1,223 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_clear.c,v 1.2 2000/06/26 05:41:29 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *
- */
-
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
-#include "r128_context.h"
-#include "r128_lock.h"
-#include "r128_reg.h"
-#include "r128_cce.h"
-#include "r128_state.h"
-#include "r128_vb.h"
-#include "r128_clear.h"
-
-/* Clear the depth buffer */
-void r128ClearDepthBuffer(r128ContextPtr r128ctx, GLboolean all,
-			  GLint cx, GLint cy, GLint cw, GLint ch)
-{
-    __DRIdrawablePrivate *dPriv    = r128ctx->driDrawable;
-    int                   nc;
-    XF86DRIClipRectPtr    c;
-    int                   dst_bpp;
-    CARD32                write_mask;
-
-    if (!(r128ctx->regs.tex_cntl_c & R128_Z_WRITE_ENABLE)) return;
-
-    switch (r128ctx->regs.z_sten_cntl_c & R128_Z_PIX_WIDTH_MASK) {
-    case R128_Z_PIX_WIDTH_16:
-	write_mask = 0x0000ffff;
-	dst_bpp    = R128_GMC_DST_16BPP;
-	break;
-    case R128_Z_PIX_WIDTH_24:
-	write_mask = 0x00ffffff;
-	dst_bpp    = R128_GMC_DST_32BPP;
-	break;
-    case R128_Z_PIX_WIDTH_32:
-	write_mask = 0xffffffff;
-	dst_bpp    = R128_GMC_DST_32BPP;
-	break;
-    default: return;
-    }
-
-#if ENABLE_PERF_BOXES
-    /* Bump the performance counter */
-    r128ctx->c_clears++;
-#endif
-
-    cx += dPriv->x;
-    cy  = dPriv->y + dPriv->h - cy - ch;
-
-    LOCK_HARDWARE(r128ctx);
-
-    /* Flush any outstanding vertex buffers */
-    r128FlushVerticesLocked(r128ctx);
-
-    /* Init the clip rects here in case they changed during the
-       LOCK_HARDWARE macro */
-    c  = dPriv->pClipRects;
-    nc = dPriv->numClipRects;
-
-    /* Set the write mask so that we _only_ clear the Z buffer */
-    R128CCE0(R128_CCE_PACKET0, R128_DP_WRITE_MASK, 0);
-    R128CCE(write_mask);
-
-    /* Cycle through the clip rects */
-    while (nc--) {
-	int x = c[nc].x1;
-	int y = c[nc].y1;
-	int w = c[nc].x2 - x;
-	int h = c[nc].y2 - y;
-
-	if (!all) {
-	    if (x < cx) w -= cx - x, x = cx;
-	    if (y < cy) h -= cy - y, y = cy;
-
-	    if (x + w > cx + cw) w = cx + cw - x;
-	    if (y + h > cy + ch) h = cy + ch - y;
-
-	    if (w <= 0 || h <= 0) continue;
-	}
-
-	x += r128ctx->r128Screen->depthX;
-	y += r128ctx->r128Screen->depthY;
-
-	R128CCE3(R128_CCE_PACKET3_CNTL_PAINT_MULTI, 3);
-	R128CCE(R128_GMC_BRUSH_SOLID_COLOR
-		| dst_bpp
-		| R128_GMC_SRC_DATATYPE_COLOR
-		| R128_ROP3_P
-		| R128_GMC_CLR_CMP_CNTL_DIS
-		| R128_GMC_AUX_CLIP_DIS);
-	R128CCE(r128ctx->ClearDepth);
-	R128CCE((x << 16) | y);
-	R128CCE((w << 16) | h);
-    }
-
-    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-    r128ctx->dirty_context |= (R128_CTX_MISC        |
-			       R128_CTX_ENGINESTATE |
-			       R128_CTX_ALPHASTATE);
-
-    R128CCE_SUBMIT_PACKET();
-
-    UNLOCK_HARDWARE(r128ctx);
-}
-
-/* Clear a color buffer */
-void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all,
-			  GLint cx, GLint cy, GLint cw, GLint ch,
-			  GLint drawX, GLint drawY)
-{
-    __DRIdrawablePrivate *dPriv    = r128ctx->driDrawable;
-    int                   nc;
-    XF86DRIClipRectPtr    c;
-    int                   dst_bpp;
-
-    switch (r128ctx->r128Screen->bpp) {
-    case 8:
-	dst_bpp = R128_GMC_DST_8BPP_CI;
-	break;
-    case 16:
-	if (r128ctx->r128Screen->depth == 15) dst_bpp = R128_GMC_DST_15BPP;
-	else                                  dst_bpp = R128_GMC_DST_16BPP;
-	break;
-    case 24:
-	dst_bpp = R128_GMC_DST_24BPP;
-	break;
-    case 32:
-    default:
-	dst_bpp = R128_GMC_DST_32BPP;
-	break;
-    }
-
-#if ENABLE_PERF_BOXES
-    /* Bump the performance counter */
-    r128ctx->c_clears++;
-#endif
-
-    cx += dPriv->x;
-    cy  = dPriv->y + dPriv->h - cy - ch;
-
-    LOCK_HARDWARE(r128ctx);
-
-    /* Flush any outstanding vertex buffers */
-    r128FlushVerticesLocked(r128ctx);
-
-    /* Init the clip rects here in case they changed during the
-       LOCK_HARDWARE macro */
-    c  = dPriv->pClipRects;
-    nc = dPriv->numClipRects;
-
-    /* Cycle through the clip rects */
-    while (nc--) {
-	int x = c[nc].x1;
-	int y = c[nc].y1;
-	int w = c[nc].x2 - x;
-	int h = c[nc].y2 - y;
-
-	if (!all) {
-	    if (x < cx) w -= cx - x, x = cx;
-	    if (y < cy) h -= cy - y, y = cy;
-
-	    if (x + w > cx + cw) w = cx + cw - x;
-	    if (y + h > cy + ch) h = cy + ch - h;
-
-	    if (w <= 0 || h <= 0) continue;
-	}
-
-	x += drawX;
-	y += drawY;
-
-	R128CCE3(R128_CCE_PACKET3_CNTL_PAINT_MULTI, 3);
-	R128CCE(R128_GMC_BRUSH_SOLID_COLOR
-		| dst_bpp
-		| R128_GMC_SRC_DATATYPE_COLOR
-		| R128_ROP3_P
-		| R128_GMC_CLR_CMP_CNTL_DIS
-		| R128_GMC_AUX_CLIP_DIS);
-	R128CCE(r128ctx->ClearColor);
-	R128CCE((x << 16) | y);
-	R128CCE((w << 16) | h);
-    }
-
-    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-    r128ctx->dirty_context |= (R128_CTX_MISC        |
-			       R128_CTX_ENGINESTATE |
-			       R128_CTX_ALPHASTATE);
-
-    R128CCE_SUBMIT_PACKET();
-
-    UNLOCK_HARDWARE(r128ctx);
-}
Index: xc/lib/GL/mesa/src/drv/r128/r128_clear.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_clear.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_clear.h:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_clear.h:1.1	Fri Jun 16 20:03:04 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_clear.h	Mon Dec 18 14:23:35 2000
@@ -1,47 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_clear.h,v 1.1 2000/06/17 00:03:04 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas. 
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *
- */
-
-#ifndef _R128_CLEAR_H_
-#define _R128_CLEAR_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-extern void r128ClearDepthBuffer(r128ContextPtr r128ctx, GLboolean all,
-				 GLint x, GLint y, GLint width, GLint height);
-extern void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all,
-				 GLint x, GLint y, GLint width, GLint height,
-				 GLint drawX, GLint drawY);
-
-#endif
-#endif /* _R128_CLEAR_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_context.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_context.c:1.1 xc/lib/GL/mesa/src/drv/r128/r128_context.c:1.4
--- xc/lib/GL/mesa/src/drv/r128/r128_context.c:1.1	Fri Jun 16 20:03:04 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_context.c	Tue Dec 12 12:17:06 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_context.c,v 1.1 2000/06/17 00:03:04 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_context.c,v 1.4 2000/12/12 17:17:06 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,17 +28,15 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
 #include <stdlib.h>
 
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
 #include "r128_context.h"
-#include "r128_cce.h"
+#include "r128_ioctl.h"
 #include "r128_dd.h"
 #include "r128_state.h"
 #include "r128_span.h"
@@ -48,29 +46,51 @@
 
 #include "context.h"
 #include "simple_list.h"
+#include "mem.h"
 
+#ifndef R128_DEBUG
+int R128_DEBUG = (0
+/*		  | DEBUG_ALWAYS_SYNC */
+/*		  | DEBUG_VERBOSE_API */
+/*		  | DEBUG_VERBOSE_MSG */
+/*		  | DEBUG_VERBOSE_LRU */
+/*		  | DEBUG_VERBOSE_DRI */
+/*		  | DEBUG_VERBOSE_IOCTL */
+/*		  | DEBUG_VERBOSE_2D */
+   );
+#endif
+
 /* Create the device specific context */
 GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual,
 			    __DRIcontextPrivate *driContextPriv)
 {
     r128ContextPtr  r128ctx;
     r128ScreenPtr   r128scrn;
-    GLcontext      *glCtx    = driContextPriv->mesaContext;
+    GLcontext      *ctx    = driContextPriv->mesaContext;
     int             i;
     char           *v;
+    __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
 
-    r128ctx = (r128ContextPtr)Xmalloc(sizeof(*r128ctx));
+    r128ctx = (r128ContextPtr)Xcalloc(1, sizeof(*r128ctx));
     if (!r128ctx) return GL_FALSE;
 
     /* Initialize r128Context */
-    r128ctx->glCtx         = glCtx;
-    r128ctx->display       = dpy;
-    r128ctx->driContext    = driContextPriv;
-    r128ctx->driDrawable   = NULL; /* Set by XMesaMakeCurrent */
+    r128ctx->glCtx       = ctx;
+    r128ctx->display     = dpy;
+
+    r128ctx->driContext  = driContextPriv;
+    r128ctx->driScreen   = sPriv;
+    r128ctx->driDrawable = NULL; /* Set by XMesaMakeCurrent */
+
+    r128ctx->hHWContext  = driContextPriv->hHWContext;
+    r128ctx->driFd       = sPriv->fd;
+    r128ctx->driHwLock   = &sPriv->pSAREA->lock;
 
-    r128scrn = r128ctx->r128Screen =
-	(r128ScreenPtr)(driContextPriv->driScreenPriv->private);
+    r128scrn = r128ctx->r128Screen = (r128ScreenPtr)(sPriv->private);
 
+    r128ctx->sarea = (R128SAREAPriv *)((char *)sPriv->pSAREA +
+				       sizeof(XF86DRISAREARec));
+
     r128ctx->CurrentTexObj[0] = NULL;
     r128ctx->CurrentTexObj[1] = NULL;
     make_empty_list(&r128ctx->SwappedOut);
@@ -79,16 +99,26 @@
 	r128ctx->texHeap[i] = mmInit(0, r128scrn->texSize[i]);
 	r128ctx->lastTexAge[i] = -1;
     }
+    r128ctx->lastTexHeap = r128scrn->NRTexHeaps;
+
+    r128ctx->DepthSize   = glVisual->DepthBits;
+    r128ctx->StencilSize = glVisual->StencilBits;
 
-    r128ctx->lastSwapAge      = 0;
+    r128ctx->useFastPath = GL_FALSE;
+    r128ctx->lod_bias = 0x3f;
 
-    r128ctx->useFastPath      = GL_FALSE;
+    r128ctx->num_verts = 0;
+    r128ctx->vert_buf = NULL;
 
-    r128ctx->vert_buf         = NULL;
+    r128ctx->elt_buf = NULL;
+    r128ctx->retained_buf = NULL;
+    r128ctx->vert_heap = r128ctx->r128Screen->buffers->list->address;
 
-    r128ctx->CCEbuf           = (CARD32 *)malloc(sizeof(*r128ctx->CCEbuf) *
-						 r128scrn->ringEntries);
-    r128ctx->CCEcount         = 0;
+#if 0
+    r128ctx->CCEbuf= (CARD32 *)MALLOC(sizeof(*r128ctx->CCEbuf) *
+				      r128scrn->ringEntries);
+    r128ctx->CCEcount = 0;
+#endif
 
     if ((v = getenv("LIBGL_CCE_TIMEOUT")))
 	r128ctx->CCEtimeout   = strtoul(v, NULL, 10);
@@ -98,41 +128,27 @@
     if (r128ctx->CCEtimeout <= 0) r128ctx->CCEtimeout = 1;
 
     /* Initialize GLcontext */
-    glCtx->DriverCtx = (void *)r128ctx;
+    ctx->DriverCtx = (void *)r128ctx;
 
-    r128DDInitExtensions(glCtx);
+    r128DDInitExtensions(ctx);
 
-    r128DDInitDriverFuncs(glCtx);
-    r128DDInitStateFuncs(glCtx);
-    r128DDInitSpanFuncs(glCtx);
-    r128DDInitTextureFuncs(glCtx);
+    r128DDInitDriverFuncs(ctx);
+    r128DDInitIoctlFuncs(ctx);
+    r128DDInitStateFuncs(ctx);
+    r128DDInitSpanFuncs(ctx);
+    r128DDInitTextureFuncs(ctx);
 
-    /* Do this after initialization of r128ctx->Fallback in InitState().
-     */
-    if (getenv("LIBGL_SOFTWARE_RENDERING"))
-	r128ctx->Fallback  |= R128_FALLBACK_SWONLY;
+    ctx->Driver.TriangleCaps = (DD_TRI_CULL
+				| DD_TRI_LIGHT_TWOSIDE
+				| DD_TRI_OFFSET);
 
-    /* KW: No vertex buffer code for PCI cards -- for now fallback to
-     * software always.
-     * GTH: There is support there, but I'm seeing strange behaviour
-     * with it enabled.  I'll leave the software fallbacks in place
-     * for now.
+    /* Ask Mesa to clip fog coordinates for us
      */
-    if (r128scrn->IsPCI)
-	r128ctx->Fallback  |= R128_FALLBACK_SWONLY;
+    ctx->TriangleCaps |= DD_CLIP_FOG_COORD;
 
-    if (getenv("LIBGL_NO_SOFTWARE_FALLBACKS"))
-	r128ctx->SWfallbackDisable = GL_TRUE;
-    else
-	r128ctx->SWfallbackDisable = GL_FALSE;
-
-    glCtx->Driver.TriangleCaps = (DD_TRI_CULL
-				  | DD_TRI_LIGHT_TWOSIDE
-				  | DD_TRI_OFFSET);
-
     /* Reset Mesa's current 2D texture pointers to the driver's textures */
-    glCtx->Shared->DefaultD[2][0].DriverData = NULL;
-    glCtx->Shared->DefaultD[2][1].DriverData = NULL;
+    ctx->Shared->DefaultD[2][0].DriverData = NULL;
+    ctx->Shared->DefaultD[2][1].DriverData = NULL;
 
     /* KW: Set the maximum texture size small enough that we can
      * guarentee that both texture units can bind a maximal texture
@@ -140,17 +156,17 @@
      * Gareth: Please check these numbers are OK)
      */
     if (r128scrn->texSize[0] < 2*1024*1024) {
-       glCtx->Const.MaxTextureLevels = 9;
-       glCtx->Const.MaxTextureSize = 1<<8;
+       ctx->Const.MaxTextureLevels = 9;
+       ctx->Const.MaxTextureSize = 1<<8;
     } else if (r128scrn->texSize[0] < 8*1024*1024) {
-       glCtx->Const.MaxTextureLevels = 10;
-       glCtx->Const.MaxTextureSize = 1<<9;
+       ctx->Const.MaxTextureLevels = 10;
+       ctx->Const.MaxTextureSize = 1<<9;
     } else {
-       glCtx->Const.MaxTextureLevels = 11;
-       glCtx->Const.MaxTextureSize = 1<<10;
+       ctx->Const.MaxTextureLevels = 11;
+       ctx->Const.MaxTextureSize = 1<<10;
     }
 
-    glCtx->Const.MaxTextureUnits = 2;
+    ctx->Const.MaxTextureUnits = 2;
 
 #if ENABLE_PERF_BOXES
     if (getenv("LIBGL_PERFORMANCE_BOXES"))
@@ -161,14 +177,14 @@
 
     /* If Mesa has current a vertex buffer, make sure the driver's VB
        data is up to date */
-    if (glCtx->VB) r128DDRegisterVB(glCtx->VB);
+    if (ctx->VB) r128DDRegisterVB(ctx->VB);
 
     /* Register the fast path */
-    if (glCtx->NrPipelineStages)
-	glCtx->NrPipelineStages =
-	    r128RegisterPipelineStages(glCtx->PipelineStage,
-				       glCtx->PipelineStage,
-				       glCtx->NrPipelineStages);
+    if (ctx->NrPipelineStages)
+	ctx->NrPipelineStages =
+	    r128DDRegisterPipelineStages(ctx->PipelineStage,
+					 ctx->PipelineStage,
+					 ctx->NrPipelineStages);
 
     r128DDInitState(r128ctx);
 
@@ -184,7 +200,9 @@
 	r128TexObjPtr t, next_t;
 	int           i;
 
-	free(r128ctx->CCEbuf);
+#if 0
+	FREE( r128ctx->CCEbuf );
+#endif
 
 	for (i = 0; i < r128ctx->r128Screen->NRTexHeaps; i++) {
 	    foreach_s (t, next_t, &r128ctx->TexObjList[i])
@@ -196,6 +214,10 @@
 
 	Xfree(r128ctx);
     }
+
+#if 0
+    glx_fini_prof();
+#endif
 }
 
 /* Load the device specific context into the hardware.  The actual
@@ -206,16 +228,17 @@
 {
     if (oldCtx) {
 	if (!R128CCE_USE_RING_BUFFER(newCtx->r128Screen->CCEMode))
-	    newCtx->dirty         |= R128_REQUIRE_QUIESCENCE;
+	    newCtx->dirty |= R128_REQUIRE_QUIESCENCE;
 	if (oldCtx != newCtx) {
-	    newCtx->dirty         |= R128_UPDATE_CONTEXT;
-	    newCtx->dirty_context |= R128_CTX_ALL_DIRTY;
+	    newCtx->new_state |= R128_NEW_CONTEXT;
+	    newCtx->dirty = R128_UPLOAD_ALL;
+	}
+	if (oldCtx->driDrawable != dPriv) {
+	    newCtx->new_state |= R128_NEW_WINDOW;
 	}
-	if (oldCtx->driDrawable != dPriv)
-	    newCtx->dirty         |= R128_UPDATE_WINPOS;
     } else {
-	newCtx->dirty             |= R128_UPDATE_CONTEXT;
-	newCtx->dirty_context     |= R128_CTX_ALL_DIRTY;
+	newCtx->new_state |= R128_NEW_CONTEXT;
+	newCtx->dirty = R128_UPLOAD_ALL;
     }
 
     newCtx->driDrawable = dPriv;
Index: xc/lib/GL/mesa/src/drv/r128/r128_context.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_context.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_context.h:1.4
--- xc/lib/GL/mesa/src/drv/r128/r128_context.h:1.1	Fri Jun 16 20:03:05 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_context.h	Tue Dec 12 12:17:06 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_context.h,v 1.1 2000/06/17 00:03:05 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_context.h,v 1.4 2000/12/12 17:17:06 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,7 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
@@ -37,204 +38,217 @@
 
 #ifdef GLX_DIRECT_RENDERING
 
+#include <X11/Xlibint.h>
+
+#include "dri_mesaint.h"
+#include "dri_tmm.h"
+
+#include "xf86drm.h"
+#include "xf86drmR128.h"
+
+#include "types.h"
+
+#include "r128_sarea.h"
+#include "r128_reg.h"
+
 struct r128_context;
 typedef struct r128_context r128ContextRec;
 typedef struct r128_context *r128ContextPtr;
 
+#include "r128_lock.h"
 #include "r128_texobj.h"
-#include "r128_fastpath.h"
+#include "r128_screen.h"
+
+/* Flags for what context state needs to be updated:
+ */
+#define R128_NEW_ALPHA		0x0001
+#define R128_NEW_DEPTH		0x0002
+#define R128_NEW_FOG		0x0004
+#define R128_NEW_CLIP		0x0008
+#define R128_NEW_CULL		0x0010
+#define R128_NEW_MASKS		0x0020
+#define R128_NEW_RENDER		0x0040
+#define R128_NEW_WINDOW		0x0080
+#define R128_NEW_TEXTURE	0x0100
+#define R128_NEW_CONTEXT	0x0200
+#define R128_NEW_ALL		0x03ff
 
-/* Flags for what needs to be updated before a new primitive is rendered */
-#define R128_CLEAN                  0x0000
-#define R128_REQUIRE_QUIESCENCE     0x0001
-#define R128_UPDATE_CONTEXT         0x0002
-#define R128_UPDATE_WINPOS          0x0004
-#define R128_UPDATE_TEX0IMAGES      0x0008
-#define R128_UPDATE_TEX1IMAGES      0x0010
-#define R128_UPDATE_TEXSTATE        0x0020
-#define R128_ALL_DIRTY              0xffff
-
-/* Flags for what context state needs to be updated */
-#define R128_CTX_CLEAN              0x0000
-#define R128_CTX_MISC               0x0001
-#define R128_CTX_ENGINESTATE        0x0002
-#define R128_CTX_TEX0STATE          0x0004
-#define R128_CTX_TEX1STATE          0x0008
-#define R128_CTX_TEXENVSTATE        0x0010
-#define R128_CTX_FOGSTATE           0x0020
-#define R128_CTX_FOGTABLE           0x0040
-#define R128_CTX_ZSTENSTATE         0x0080
-#define R128_CTX_SCISSORS           0x0100
-#define R128_CTX_ALPHASTATE         0x0200
-#define R128_CTX_SETUPSTATE         0x0400
-#define R128_CTX_WIN_Z_POS          0x0800
-#define R128_CTX_FLUSH_PIX_CACHE    0x1000
-#define R128_CTX_ALL_DIRTY          0xffff
-
-/* Flags for software fallback cases */
-#define R128_FALLBACK_TEXTURE       0x0001
-#define R128_FALLBACK_DRAW_BUFFER   0x0002
-#define R128_FALLBACK_READ_BUFFER   0x0004
-#define R128_FALLBACK_COLORMASK     0x0008
-#define R128_FALLBACK_STIPPLE       0x0010
-#define R128_FALLBACK_SWONLY        0x0020
-#define R128_FALLBACK_RENDER_MODE   0x0040
-#define R128_FALLBACK_MULTIDRAW     0x0080
-
-/* NOTE: The groups below need to be kept together so that a single
-   memcpy can be used to transfer data to the ring buffer */
-typedef struct {
-    CARD32  scale_3d_cntl;                        /* 0x1a00 */
-
-    CARD32  aux_sc_cntl;                          /* 0x1660 */
-    CARD32  aux1_sc_left;
-    CARD32  aux1_sc_right;
-    CARD32  aux1_sc_top;
-    CARD32  aux1_sc_bottom;
-    CARD32  aux2_sc_left;
-    CARD32  aux2_sc_right;
-    CARD32  aux2_sc_top;
-    CARD32  aux2_sc_bottom;
-    CARD32  aux3_sc_left;
-    CARD32  aux3_sc_right;
-    CARD32  aux3_sc_top;
-    CARD32  aux3_sc_bottom;                       /* 0x1690 */
-
-    CARD32  dst_pitch_offset_c;                   /* 0x1c80 */
-    CARD32  dp_gui_master_cntl;
-    CARD32  sc_top_left_c;
-    CARD32  sc_bottom_right_c;
-    CARD32  z_offset_c;
-    CARD32  z_pitch_c;
-    CARD32  z_sten_cntl_c;
-    CARD32  tex_cntl_c;
-    CARD32  misc_3d_state_cntl_reg;
-    CARD32  texture_clr_cmp_clr_c;
-    CARD32  texture_clr_cmp_msk_c;
-    CARD32  fog_color_c;
-    CARD32  prim_tex_cntl_c;
-    CARD32  prim_texture_combine_cntl_c;
-    CARD32  tex_size_pitch_c;
-    CARD32  prim_tex_offset[R128_TEX_MAXLEVELS];  /* 0x1ce4 */
-
-    CARD32  sec_tex_cntl_c;                       /* 0x1d00 */
-    CARD32  sec_tex_combine_cntl_c;
-    CARD32  sec_tex_offset[R128_TEX_MAXLEVELS];
-    CARD32  constant_color_c;
-    CARD32  prim_texture_border_color_c;
-    CARD32  sec_texture_border_color_c;
-    CARD32  sten_ref_mask_c;
-    CARD32  plane_3d_mask_c;                      /* 0x1d44 */
-
-    CARD32  setup_cntl;                           /* 0x1bc4 */
-
-    CARD32  pm4_vc_fpu_setup;                     /* 0x071c */
-
-    CARD32  fog_3d_table_start;                   /* 0x1810 */
-    CARD32  fog_3d_table_end;
-    CARD32  fog_3d_table_density;                 /* 0x181c */
+/* Flags for software fallback cases:
+ */
+#define R128_FALLBACK_TEXTURE		0x0001
+#define R128_FALLBACK_DRAW_BUFFER	0x0002
+#define R128_FALLBACK_READ_BUFFER	0x0004
+#define R128_FALLBACK_STENCIL		0x0008
+#define R128_FALLBACK_RENDER_MODE	0x0010
+#define R128_FALLBACK_MULTIDRAW		0x0020
+#define R128_FALLBACK_LOGICOP		0x0040
 
-    CARD32  window_xy_offset;                     /* 0x1bcc */
+/* Reasons why the GL_BLEND fallback mightn't work:
+ */
+#define R128_BLEND_ENV_COLOR	0x1
+#define R128_BLEND_MULTITEX	0x2
 
-    CARD32  dp_write_mask;                        /* 0x16cc */
+/* Subpixel offsets for window coordinates:
+ */
+#define SUBPIXEL_X		(-0.125F)
+#define SUBPIXEL_Y		( 0.375F)
 
-    CARD32  pc_gui_ctlstat;                       /* 0x1748 */
-} r128ContextRegs;
+typedef void (*r128_interp_func)( GLfloat t,
+				  GLfloat *result,
+				  const GLfloat *in,
+				  const GLfloat *out );
+
+struct r128_elt_tab {
+   void (*emit_unclipped_verts)( struct vertex_buffer *VB );
+
+   void (*build_tri_verts)( r128ContextPtr r128ctx,
+			    struct vertex_buffer *VB,
+			    GLfloat *O, GLuint *elt );
+
+   void (*interp)( GLfloat t, GLfloat *O,
+		   const GLfloat *I, const GLfloat *J );
+
+   void (*project_and_emit_verts)( r128ContextPtr r128ctx,
+				   const GLfloat *verts,
+				   GLuint *elts,
+				   int nr );
+};
 
 struct r128_context {
-    GLcontext            *glCtx;	/* Mesa context */
-    int                   dirty;	/* Hardware state to be updated */
-    int                   dirty_context; /* Context state to be updated */
-
-    int                   vertsize;	/* Size of current vertices */
-    CARD32                vc_format;	/* Format of current vertices */
-    int                   multitex;
-    GLfloat               depth_scale;
-
-    int                   SWfallbackDisable; /* Disable software fallbacks */
-
-    r128TexObjPtr         CurrentTexObj[2]; /* Ptr to current texture
-					       object associated with
-					       each texture unit */
-					/* List of tex swapped in per heap*/
-    r128TexObj            TexObjList[R128_NR_TEX_HEAPS];
-    r128TexObj            SwappedOut;	/* List of textures swapped out */
-    memHeap_t            *texHeap[R128_NR_TEX_HEAPS]; /* Global tex heaps */
-					/* Last known global tex heap ages */
-    int                   lastTexAge[R128_NR_TEX_HEAPS];
-
-    CARD32                lastSwapAge;  /* Last known swap age */
-
-    GLenum                FogMode;      /* Current fog equation */
-
-    int                   Scissor;
-    XF86DRIClipRectRec    ScissorRect;  /* Current software scissor */
-
-    int                   useFastPath;	/* Currently using Fast Path code */
-    int                   SetupIndex;	/* Raster setup function index */
-    int                   SetupDone;	/* Partial raster setup done? */
-    int                   RenderIndex;	/* Render state function index */
-    r128InterpFunc        interp;	/* Current vert interp function */
+   GLcontext		*glCtx;		/* Mesa context */
 
-    drmBufPtr             vert_buf;	/* VB currently being filled */
+   /* Driver and hardware state management
+    */
+   GLuint		new_state;
+   GLuint		dirty;		/* Hardware state to be updated */
+   r128_context_regs_t	setup;
+
+   GLuint		vertsize;
+   CARD32		vc_format;
+   GLfloat		depth_scale;
+
+   CARD32		Color;		/* Current draw color */
+   CARD32		ClearColor;	/* Color used to clear color buffer */
+   CARD32		ClearDepth;	/* Value used to clear depth buffer */
+   CARD32		ClearStencil;	/* Value used to clear stencil */
+
+   /* Map GL texture units onto hardware
+    */
+   GLint		multitex;
+   GLint		tmu_source[2];
+   GLint		tex_dest[2];
+   GLuint		blend_flags;
+   CARD32		env_color;
+   GLint		lod_bias;
+
+   /* Texture object bookkeeping
+    */
+   r128TexObjPtr	CurrentTexObj[2];
+   r128TexObj		TexObjList[R128_NR_TEX_HEAPS];
+   r128TexObj		SwappedOut;
+   memHeap_t		*texHeap[R128_NR_TEX_HEAPS];
+   GLint		lastTexAge[R128_NR_TEX_HEAPS];
+   GLint		lastTexHeap;
+
+   /* Current rendering state, fallbacks
+    */
+   points_func		PointsFunc;
+   line_func		LineFunc;
+   triangle_func	TriangleFunc;
+   quad_func		QuadFunc;
+
+   CARD32		IndirectTriangles;
+   CARD32		Fallback;
+
+   /* Fast path
+    */
+   GLuint		useFastPath;
+   GLuint		SetupIndex;
+   GLuint		SetupDone;
+   GLuint		RenderIndex;
+   r128_interp_func	interp;
+
+   /* Vertex buffers
+    */
+   drmBufPtr		vert_buf;
+   GLuint		num_verts;
+
+   /* Elt path
+    */
+   drmBufPtr		elt_buf, retained_buf;
+   GLushort		*first_elt, *next_elt;
+   GLfloat		*next_vert, *vert_heap;
+   GLushort		next_vert_index;
+   GLushort		first_vert_index;
+   GLuint		elt_vertsize;
+   struct r128_elt_tab	*elt_tab;
+   GLfloat		device_matrix[16];
 
+   /* CCE command packets
+    */
 #if 0
-    drmBufPtr		  elt_buf, retained_buf, index_buf;
-    GLushort		 *first_elt, *next_elt, *last_elt;
-    GLfloat		 *next_vert, *last_vert;
-    CARD32		  next_vert_index;
-    CARD32		  first_vert_index;
-    struct r128_elt_tab	 *elt_tab;
-    GLfloat		  device_matrix[16];
+   CARD32		*CCEbuf;	/* buffer to submit to CCE */
+   GLuint		CCEcount;	/* number of dwords in CCEbuf */
 #endif
-
-    points_func           PointsFunc;	/* Current Points, Line, Triangle */
-    line_func             LineFunc;	/* and Quad rendering functions */
-    triangle_func         TriangleFunc;
-    quad_func             QuadFunc;
-
-    CARD32                IndirectTriangles; /* Flags for point, line,
-						tri and quad software
-						fallbacks */
-    CARD32                Fallback;     /* Need software fallback */
-
-    r128ContextRegs       regs;		/* Hardware state */
-    CARD32                Color;	/* Current draw color */
-    CARD32                ClearColor;	/* Color used to clear color buffer */
-    CARD32                ClearDepth;	/* Value used to clear depth buffer */
-
-    int                   drawX;	/* x-offset to current draw buffer */
-    int                   drawY;	/* y-offset to current draw buffer */
-
-    int                   readX;	/* x-offset to current read buffer */
-    int                   readY;	/* y-offset to current read buffer */
-
-    CARD32               *CCEbuf;	/* buffer to submit to CCE */
-    int                   CCEcount;	/* number of dwords in CCEbuf */
-
-    int                   CCEtimeout;   /* number of times to loop
+   GLint		CCEtimeout;	/* number of times to loop
 					   before exiting */
 
-    Display              *display;	/* X server display */
-
-    __DRIcontextPrivate  *driContext;	/* DRI context */
-    __DRIdrawablePrivate *driDrawable;	/* DRI drawable bound to this ctx */
+   /* Visual, drawable, cliprect and scissor information
+    */
+   GLint		DepthSize;	/* Bits in depth buffer */
+   GLint		StencilSize;	/* Bits in stencil buffer */
+
+   GLenum		DrawBuffer;	/* Optimize draw buffer update */
+   GLint		drawOffset, drawPitch;
+   GLint		drawX, drawY;
+   GLint		readOffset, readPitch;
+   GLint		readX, readY;
+
+   GLuint		numClipRects;	/* Cliprects for the draw buffer */
+   XF86DRIClipRectPtr	pClipRects;
+
+   GLuint		scissor;
+   XF86DRIClipRectRec	ScissorRect;	/* Current software scissor */
+
+   /* Mirrors of some DRI state
+    */
+   Display		*display;	/* X server display */
+
+   __DRIcontextPrivate	*driContext;	/* DRI context */
+   __DRIscreenPrivate	*driScreen;	/* DRI screen */
+   __DRIdrawablePrivate	*driDrawable;	/* DRI drawable bound to this ctx */
+
+   drmContext		hHWContext;
+   drmLock		*driHwLock;
+   int			driFd;
+
+   r128ScreenPtr	r128Screen;	/* Screen private DRI data */
+   R128SAREAPriv	*sarea;		/* Private SAREA data */
+
+   /* Performance counters
+     */
+   GLuint		boxes;		/* Draw performance boxes */
+   GLuint		hardwareWentIdle;
+   GLuint		c_clears;
+   GLuint		c_drawWaits;
+   GLuint		c_textureSwaps;
+   GLuint		c_textureBytes;
+   GLuint		c_vertexBuffers;
+};
 
-    r128ScreenPtr         r128Screen;	/* Screen private DRI data */
+#define R128_CONTEXT(ctx)		((r128ContextPtr)(ctx->DriverCtx))
 
-    /* Performance counters: */
-    int                   boxes;	/* Draw performance boxes */
-    int			  hardwareWentIdle;
-    int			  c_clears;
-    int			  c_drawWaits;
-    int			  c_textureSwaps;
-    int			  c_textureBytes;
-    int			  c_vertexBuffers;
-};
+#define R128_MESACTX(r128ctx)		((r128ctx)->glCtx)
+#define R128_DRIDRAWABLE(r128ctx)	((r128ctx)->driDrawable)
+#define R128_DRISCREEN(r128ctx)		((r128ctx)->r128Screen->driScreen)
+
+#define R128_IS_PLAIN( r128ctx ) \
+		(r128ctx->r128Screen->chipset == R128_CARD_TYPE_R128)
+#define R128_IS_PRO( r128ctx ) \
+		(r128ctx->r128Screen->chipset == R128_CARD_TYPE_R128_PRO)
+#define R128_IS_MOBILITY( r128ctx ) \
+		(r128ctx->r128Screen->chipset == R128_CARD_TYPE_R128_MOBILITY)
 
-#define R128_MESACTX(r128ctx)     ((r128ctx)->glCtx)
-#define R128_DRIDRAWABLE(r128ctx) ((r128ctx)->driDrawable)
-#define R128_DRISCREEN(r128ctx)   ((r128ctx)->r128Screen->driScreen)
 
 extern GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual,
 				   __DRIcontextPrivate *driContextPriv);
@@ -242,6 +256,28 @@
 extern r128ContextPtr r128MakeCurrent(r128ContextPtr oldCtx,
 				      r128ContextPtr newCtx,
 				      __DRIdrawablePrivate *dPriv);
+
+
+/* ================================================================
+ * Debugging:
+ */
+#define DEBUG			0
+#define DEBUG_LOCKING		0
+#define ENABLE_PERF_BOXES	0
+
+#if DEBUG
+extern int R128_DEBUG;
+#else
+#define R128_DEBUG		0
+#endif
+
+#define DEBUG_ALWAYS_SYNC	0x01
+#define DEBUG_VERBOSE_API	0x02
+#define DEBUG_VERBOSE_MSG	0x04
+#define DEBUG_VERBOSE_LRU	0x08
+#define DEBUG_VERBOSE_DRI	0x10
+#define DEBUG_VERBOSE_IOCTL	0x20
+#define DEBUG_VERBOSE_2D	0x40
 
 #endif
 #endif /* _R128_CONTEXT_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_dd.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_dd.c:1.1 xc/lib/GL/mesa/src/drv/r128/r128_dd.c:1.6
--- xc/lib/GL/mesa/src/drv/r128/r128_dd.c:1.1	Fri Jun 16 20:03:05 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_dd.c	Fri Dec 15 17:48:38 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_dd.c,v 1.1 2000/06/17 00:03:05 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_dd.c,v 1.6 2000/12/15 22:48:38 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,166 +28,184 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
 #include "r128_context.h"
-#include "r128_lock.h"
-#include "r128_cce.h"
-#include "r128_clear.h"
+#include "r128_ioctl.h"
 #include "r128_state.h"
-#include "r128_swap.h"
 #include "r128_vb.h"
 #include "r128_pipeline.h"
 #include "r128_dd.h"
 
-/* Driver entry point for clearing color and ancillary buffers */
-static GLbitfield r128DDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
-			      GLint x, GLint y, GLint width, GLint height)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-
-    if (mask & DD_FRONT_LEFT_BIT) {
-	r128ClearColorBuffer(r128ctx, all, x, y, width, height,
-			     r128ctx->r128Screen->fbX,
-			     r128ctx->r128Screen->fbY);
-	mask &= ~DD_FRONT_LEFT_BIT;
-    }
-
-    if (mask & DD_BACK_LEFT_BIT) {
-	r128ClearColorBuffer(r128ctx, all, x, y, width, height,
-			     r128ctx->r128Screen->backX,
-			     r128ctx->r128Screen->backY);
-	mask &= ~DD_BACK_LEFT_BIT;
-    }
-
-    if (mask & DD_DEPTH_BIT) {
-	r128ClearDepthBuffer(r128ctx, all, x, y, width, height);
-	mask &= ~DD_DEPTH_BIT;
-    }
-
-#if 0
-    /* FIXME: Add stencil support */
-    if (mask & DD_STENCIL_BIT) {
-	r128ClearStencilBuffer(r128ctx, all, x, y, width, height);
-	mask &= ~DD_STENCIL_BIT;
-    }
+#include "extensions.h"
+#if defined(USE_X86_ASM) || defined(USE_3DNOW_ASM) || defined(USE_KATMAI_ASM)
+#include "X86/common_x86_asm.h"
 #endif
 
-    return mask;
-}
+#define R128_DATE	"20001215"
 
 /* Return the current color buffer size */
-static void r128DDGetBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
+static void r128DDGetBufferSize( GLcontext *ctx,
+				 GLuint *width, GLuint *height )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
 
-    *width  = r128ctx->driDrawable->w;
-    *height = r128ctx->driDrawable->h;
+   *width  = r128ctx->driDrawable->w;
+   *height = r128ctx->driDrawable->h;
 }
 
 /* Return various strings for glGetString() */
-static const GLubyte *r128DDGetString(GLcontext *ctx, GLenum name)
+static const GLubyte *r128DDGetString( GLcontext *ctx, GLenum name )
 {
-    switch (name) {
-    case GL_VENDOR:
-	return (GLubyte *)"Precision Insight, Inc.";
-    case GL_RENDERER:
-	return (GLubyte *)"Mesa DRI Rage128 20000613";
-    default:
-	return NULL;
-    }
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   static GLubyte buffer[128];
+
+   switch ( name ) {
+   case GL_VENDOR:
+      return (const GLubyte *)"VA Linux Systems, Inc.";
+
+   case GL_RENDERER:
+      sprintf((void *)buffer, "Mesa DRI Rage128 " R128_DATE );
+
+      /* Append any chipset-specific information.
+       */
+      if ( R128_IS_PRO( r128ctx ) ) {
+	 strncat( buffer, " Pro", 4 );
+      }
+      if ( R128_IS_MOBILITY( r128ctx ) ) {
+	 strncat( buffer, " M3", 3 );
+      }
+
+      /* Append any AGP-specific information.
+       */
+      switch ( r128ctx->r128Screen->AGPMode ) {
+      case 1:
+	 strncat( buffer, " AGP 1x", 7 );
+	 break;
+      case 2:
+	 strncat( buffer, " AGP 2x", 7 );
+	 break;
+      case 4:
+	 strncat( buffer, " AGP 4x", 7 );
+	 break;
+      }
+
+      /* Append any CPU-specific information.
+       */
+#ifdef USE_X86_ASM
+      if ( gl_x86_cpu_features ) {
+	 strncat( buffer, " x86", 4 );
+      }
+#endif
+#ifdef USE_3DNOW_ASM
+      if ( cpu_has_3dnow ) {
+	 strncat( buffer, "/3DNow!", 7 );
+      }
+#endif
+#ifdef USE_KATMAI_ASM
+      if ( cpu_has_xmm ) {
+	 strncat( buffer, "/SSE", 4 );
+      }
+#endif
+      return buffer;
+
+   default:
+      return NULL;
+   }
 }
 
 /* Send all commands to the hardware.  If vertex buffers or indirect
-   buffers are in use, then we need to make sure they are sent to the
-   hardware.  All commands that are normally sent to the ring are
-   already considered `flushed'. */
-static void r128DDFlush(GLcontext *ctx)
+ * buffers are in use, then we need to make sure they are sent to the
+ * hardware.  All commands that are normally sent to the ring are
+ * already considered `flushed'.
+ */
+static void r128DDFlush( GLcontext *ctx )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
 
-    r128FlushVertices(r128ctx);
+   FLUSH_BATCH( r128ctx );
 
 #if ENABLE_PERF_BOXES
-    if (r128ctx->boxes) {
-	LOCK_HARDWARE(r128ctx);
-	r128PerformanceBoxesLocked(r128ctx);
-	UNLOCK_HARDWARE(r128ctx);
-    }
+   if ( r128ctx->boxes ) {
+      LOCK_HARDWARE( r128ctx );
+      r128PerformanceBoxesLocked( r128ctx );
+      UNLOCK_HARDWARE( r128ctx );
+   }
 
-    /* Log the performance counters if necessary */
-    r128PerformanceCounters(r128ctx);
+   /* Log the performance counters if necessary */
+   r128PerformanceCounters( r128ctx );
 #endif
 }
 
 /* Make sure all commands have been sent to the hardware and have
-   completed processing. */
-static void r128DDFinish(GLcontext *ctx)
+ * completed processing.
+ */
+static void r128DDFinish( GLcontext *ctx )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
 
 #if ENABLE_PERF_BOXES
-    /* Bump the performance counter */
-    r128ctx->c_drawWaits++;
+   /* Bump the performance counter */
+   r128ctx->c_drawWaits++;
 #endif
 
-    r128DDFlush(ctx);
-    r128WaitForIdle(r128ctx);
+   r128DDFlush( ctx );
+   r128WaitForIdle( r128ctx );
 }
 
 /* Return various parameters requested by Mesa (this is deprecated) */
-static GLint r128DDGetParameteri(const GLcontext *ctx, GLint param)
+static GLint r128DDGetParameteri( const GLcontext *ctx, GLint param )
 {
-    switch (param) {
-       /* Hardware fog isn't working yet -- however returning zero
-	* here means that it looks like fog is working in some cases.
-	* It is less confusing to simply have it never work until it
-	* is actually fixed.
-	*/
-    case DD_HAVE_HARDWARE_FOG: return 1;
-    default:                   return 0;
-    }
+   switch (param) {
+   case DD_HAVE_HARDWARE_FOG:
+      return 1;
+   default:
+      return 0;
+   }
 }
 
 /* Initialize the extensions supported by this driver */
-void r128DDInitExtensions(GLcontext *ctx)
+void r128DDInitExtensions( GLcontext *ctx )
 {
-    /* FIXME: Are there other extensions to enable/disable??? */
-    gl_extensions_disable(ctx, "GL_EXT_shared_texture_palette");
-    gl_extensions_disable(ctx, "GL_EXT_paletted_texture");
-    gl_extensions_disable(ctx, "GL_EXT_point_parameters");
-    gl_extensions_disable(ctx, "ARB_imaging");
-    gl_extensions_disable(ctx, "GL_EXT_blend_minmax");
-    gl_extensions_disable(ctx, "GL_EXT_blend_logic_op");
-    gl_extensions_disable(ctx, "GL_EXT_blend_subtract");
-    gl_extensions_disable(ctx, "GL_INGR_blend_func_separate");
-
-    if (getenv("LIBGL_NO_MULTITEXTURE"))
-	gl_extensions_disable(ctx, "GL_ARB_multitexture");
+   /* FIXME: Are there other extensions to enable/disable??? */
+   gl_extensions_disable( ctx, "GL_EXT_shared_texture_palette" );
+   gl_extensions_disable( ctx, "GL_EXT_paletted_texture" );
+   gl_extensions_disable( ctx, "GL_EXT_point_parameters" );
+   gl_extensions_disable( ctx, "ARB_imaging" );
+   gl_extensions_disable( ctx, "GL_EXT_blend_minmax" );
+   gl_extensions_disable( ctx, "GL_EXT_blend_logic_op" );
+   gl_extensions_disable( ctx, "GL_EXT_blend_subtract" );
+   gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );
+
+   if ( getenv( "LIBGL_NO_MULTITEXTURE" ) )
+      gl_extensions_disable( ctx, "GL_ARB_multitexture" );
+
+   gl_extensions_disable( ctx, "GL_SGI_color_matrix" );
+   gl_extensions_disable( ctx, "GL_SGI_color_table" );
+   gl_extensions_disable( ctx, "GL_SGIX_pixel_texture" );
+   gl_extensions_disable( ctx, "GL_ARB_texture_cube_map" );
+   gl_extensions_disable( ctx, "GL_ARB_texture_compression" );
+   gl_extensions_disable( ctx, "GL_EXT_convolution" );
 }
 
 /* Initialize the driver's misc functions */
-void r128DDInitDriverFuncs(GLcontext *ctx)
+void r128DDInitDriverFuncs( GLcontext *ctx )
 {
-    ctx->Driver.Clear                = r128DDClear;
-
-    ctx->Driver.GetBufferSize        = r128DDGetBufferSize;
-    ctx->Driver.GetString            = r128DDGetString;
-    ctx->Driver.Finish               = r128DDFinish;
-    ctx->Driver.Flush                = r128DDFlush;
-
-    ctx->Driver.Error                = NULL;
-    ctx->Driver.GetParameteri        = r128DDGetParameteri;
-
-    ctx->Driver.DrawPixels           = NULL;
-    ctx->Driver.Bitmap               = NULL;
-
-    ctx->Driver.RegisterVB           = r128DDRegisterVB;
-    ctx->Driver.UnregisterVB         = r128DDUnregisterVB;
-    ctx->Driver.BuildPrecalcPipeline = r128DDBuildPrecalcPipeline;
+    ctx->Driver.GetBufferSize		= r128DDGetBufferSize;
+    ctx->Driver.GetString		= r128DDGetString;
+    ctx->Driver.Finish			= r128DDFinish;
+    ctx->Driver.Flush			= r128DDFlush;
+
+    ctx->Driver.Error			= NULL;
+    ctx->Driver.GetParameteri		= r128DDGetParameteri;
+
+    ctx->Driver.DrawPixels		= NULL;
+    ctx->Driver.Bitmap			= NULL;
+
+    ctx->Driver.RegisterVB		= r128DDRegisterVB;
+    ctx->Driver.UnregisterVB		= r128DDUnregisterVB;
+    ctx->Driver.BuildPrecalcPipeline	= r128DDBuildPrecalcPipeline;
 }
Index: xc/lib/GL/mesa/src/drv/r128/r128_dd.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_dd.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_dd.h:1.2
--- xc/lib/GL/mesa/src/drv/r128/r128_dd.h:1.1	Fri Jun 16 20:03:05 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_dd.h	Mon Dec  4 14:21:45 2000
@@ -1,8 +1,8 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_dd.h,v 1.1 2000/06/17 00:03:05 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_dd.h,v 1.2 2000/12/04 19:21:45 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas. 
+                                               Cedar Park, Texas.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,7 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
Index: xc/lib/GL/mesa/src/drv/r128/r128_eltpath.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/r128/r128_eltpath.c:1.2
--- /dev/null	Mon Dec 18 14:23:36 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_eltpath.c	Thu Dec  7 15:26:08 2000
@@ -0,0 +1,567 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_eltpath.c,v 1.2 2000/12/07 20:26:08 dawes Exp $ */
+/*
+ * GLX Hardware Device Driver for Matrox G400
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <stdio.h>
+
+#include "r128_context.h"
+#include "r128_pipeline.h"
+#include "r128_ioctl.h"
+#include "r128_tris.h"
+#include "r128_state.h"
+#include "r128_vb.h"
+
+#include "types.h"
+#include "enums.h"
+#include "cva.h"
+#include "vertices.h"
+#include "mmath.h"
+#include "xform.h"
+
+#define DEBUG_ELTPATH	0
+
+/* Always use a full-sized stride for vertices. [FIXME]
+ * Stride in the buffers must be a quadword multiple.
+ */
+#define CLIP_STRIDE	10
+
+static void fire_elts( r128ContextPtr r128ctx )
+{
+   int vertsize = r128ctx->vertsize;
+
+   LOCK_HARDWARE( r128ctx );
+
+   if ( DEBUG_ELTPATH )
+      fprintf( stderr, "\n%s: elt=%p ret=%p vs=%d\n",
+	       __FUNCTION__, r128ctx->elt_buf,
+	       r128ctx->retained_buf, vertsize );
+
+   /* Fire queued elements and discard that buffer if its contents
+    * won't be referenced by future elements.
+    */
+   if ( r128ctx->elt_buf )
+   {
+      GLuint retain = (r128ctx->elt_buf == r128ctx->retained_buf);
+
+      if ( r128ctx->first_elt != r128ctx->next_elt ) {
+	 r128FireEltsLocked( r128ctx,
+			     ((GLuint)r128ctx->first_elt -
+			      (GLuint)r128ctx->elt_buf->address),
+			     ((GLuint)r128ctx->next_elt -
+			      (GLuint)r128ctx->elt_buf->address),
+			     !retain );
+      } else if ( !retain ) {
+	 r128ReleaseBufLocked( r128ctx, r128ctx->elt_buf );
+      }
+
+      r128ctx->elt_buf = 0;
+   }
+   else if ( r128ctx->vert_buf )
+   {
+      r128FlushVerticesLocked( r128ctx );
+   }
+
+   r128GetEltBufLocked( r128ctx );
+
+   UNLOCK_HARDWARE( r128ctx );
+
+   /* Give the compiler a chance to optimize the divisions.
+    */
+   switch ( vertsize ) {
+   case 8:
+      r128ctx->next_vert_index = (GLushort)
+	 (((r128ctx->elt_buf->idx + 1) *
+	   R128_BUFFER_SIZE / (8 * sizeof(GLuint))) - 1);
+      r128ctx->next_vert = (GLfloat *)
+	 ((GLuint)r128ctx->vert_heap +
+	  r128ctx->next_vert_index * 8 * sizeof(GLfloat));
+      break;
+
+   case 10:
+      r128ctx->next_vert_index = (GLushort)
+	 (((r128ctx->elt_buf->idx + 1) *
+	   R128_BUFFER_SIZE / (10 * sizeof(GLuint))) - 1);
+      r128ctx->next_vert = (GLfloat *)
+	 ((GLuint)r128ctx->vert_heap +
+	  r128ctx->next_vert_index * 10 * sizeof(GLfloat));
+      break;
+   }
+
+   r128ctx->first_elt = r128ctx->next_elt = (GLushort *)
+      ((GLubyte *)r128ctx->elt_buf->address + R128_INDEX_PRIM_OFFSET);
+
+   r128ctx->elt_vertsize = vertsize;
+
+   if ( DEBUG_ELTPATH )
+      fprintf( stderr, "new elt=%p idx=%d tot=%d next=%p idx=%d\n\n",
+	       r128ctx->elt_buf, r128ctx->elt_buf->idx,
+	       r128ctx->elt_buf->total,
+	       r128ctx->next_vert, r128ctx->next_vert_index );
+
+   {
+      GLint space = (GLint)((GLuint)r128ctx->next_vert -
+			    (GLuint)r128ctx->next_elt);
+      if ( DEBUG_ELTPATH )
+	 fprintf( stderr, "   new nv=%p ne=%p space=%d\n",
+		  r128ctx->next_vert, r128ctx->next_elt, space );
+   }
+}
+
+
+static void release_bufs( r128ContextPtr r128ctx )
+{
+   if ( DEBUG_ELTPATH )
+      fprintf( stderr, "%s: %d idx=%d\n",
+	       __FUNCTION__,
+	       r128ctx->retained_buf &&
+	       r128ctx->retained_buf != r128ctx->elt_buf,
+	       r128ctx->retained_buf ? r128ctx->retained_buf->idx : -1 );
+
+   if ( r128ctx->retained_buf && r128ctx->retained_buf != r128ctx->elt_buf )
+   {
+      LOCK_HARDWARE( r128ctx );
+      if ( r128ctx->first_elt != r128ctx->next_elt ) {
+	 r128FireEltsLocked( r128ctx,
+			     ((GLuint)r128ctx->first_elt -
+			      (GLuint)r128ctx->elt_buf->address),
+			     ((GLuint)r128ctx->next_elt -
+			      (GLuint)r128ctx->elt_buf->address),
+			     0 );
+
+	 ALIGN_NEXT_ELT( r128ctx );
+	 r128ctx->first_elt = r128ctx->next_elt;
+      }
+
+      r128ReleaseBufLocked( r128ctx, r128ctx->retained_buf );
+      UNLOCK_HARDWARE( r128ctx );
+   }
+
+   r128ctx->retained_buf = 0;
+}
+
+
+
+
+#define NEGATIVE(f)          (f < 0)
+#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
+#define LINTERP( T, A, B )   ( (A) + (T) * ( (B) - (A) ) )
+
+
+#define INTERP_RGBA(t, out, a, b) {			\
+   int i;						\
+   for (i = 0; i < 4; i++) {				\
+      GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]);	\
+      GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]);	\
+      GLfloat fo = LINTERP(t, fa, fb);			\
+      FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo);		\
+   }							\
+}
+
+
+#define CLIP(SGN,V,PLANE)			\
+if (mask & PLANE) {				\
+   GLuint *indata = inlist[in];			\
+   GLuint *outdata = inlist[in ^= 1];		\
+   GLuint nr = n;				\
+   GLfloat *J = verts[indata[nr-1]];		\
+   GLfloat dpJ = (SGN J[V]) + J[3];		\
+						\
+   for (i = n = 0 ; i < nr ; i++) {		\
+      GLuint elt_i = indata[i];			\
+      GLfloat *I = verts[elt_i];		\
+      GLfloat dpI = (SGN I[V]) + I[3];		\
+						\
+      if (DIFFERENT_SIGNS(dpI, dpJ)) {		\
+	 GLfloat *O = verts[next_vert];	\
+	 outdata[n++] = next_vert++;		\
+						\
+	 if (NEGATIVE(dpI)) {			\
+	    GLfloat t = dpI / (dpI - dpJ);	\
+	    interp(t, O, I, J);			\
+	 }					\
+         else					\
+	 {					\
+	    GLfloat t = dpJ / (dpJ - dpI);	\
+	    interp(t, O, J, I);			\
+	 }					\
+      }						\
+						\
+      if (!NEGATIVE(dpI))			\
+	 outdata[n++] = elt_i;			\
+						\
+      J = I;					\
+      dpJ = dpI;				\
+   }						\
+						\
+   if (n < 3) return;				\
+}
+
+
+static void r128_tri_clip( r128ContextPtr r128ctx,
+			   struct vertex_buffer *VB,
+			   GLuint *elt,
+			   GLubyte mask )
+{
+   struct r128_elt_tab *tab = r128ctx->elt_tab;
+   r128_interp_func interp = tab->interp;
+   GLint vertsize = r128ctx->vertsize;
+   GLuint inlist[2][VB_MAX_CLIPPED_VERTS];
+   GLuint in = 0;
+   GLuint n = 3, next_vert = 3;
+   GLuint i;
+   GLfloat verts[VB_MAX_CLIPPED_VERTS][CLIP_STRIDE];
+
+   /* Build temporary vertices in clipspace.  This is the potential
+    * downside to this path.
+    */
+   tab->build_tri_verts( r128ctx, VB, (GLfloat *)verts, elt );
+
+   inlist[0][0] = 0;
+   inlist[0][1] = 1;
+   inlist[0][2] = 2;
+
+   CLIP(-,0,CLIP_RIGHT_BIT);
+   CLIP(+,0,CLIP_LEFT_BIT);
+   CLIP(-,1,CLIP_TOP_BIT);
+   CLIP(+,1,CLIP_BOTTOM_BIT);
+   CLIP(-,2,CLIP_FAR_BIT);
+   CLIP(+,2,CLIP_NEAR_BIT);
+
+
+   {
+      GLuint *out = inlist[in];
+      GLint space = (GLint)((GLuint)r128ctx->next_vert -
+			    (GLuint)r128ctx->next_elt);
+
+      if ( DEBUG_ELTPATH )
+	 fprintf( stderr, "  clip nv=%p ne=%p space=%d thresh=%d %d\n",
+		  r128ctx->next_vert, r128ctx->next_elt,
+		  space, (GLint)n * (vertsize + 2) * (GLint)sizeof(GLuint),
+		  space < (GLint)n * (vertsize + 2) * (GLint)sizeof(GLuint) );
+
+      /* GH: Why the hell do we explicitly have to test the sign of the
+       * available space here?
+       */
+      if ( space < (GLint)n * (vertsize + 2) * (GLint)sizeof(GLuint) ) {
+	 fire_elts( r128ctx );
+      }
+
+      /* Project the new vertices and emit to dma buffers.  Translate
+       * out values to physical addresses for setup dma.
+       */
+      tab->project_and_emit_verts( r128ctx, (GLfloat *)verts, out, n );
+
+      /* Convert the planar polygon to a list of triangles and emit to
+       * elt buffers.
+       */
+      for (i = 2 ; i < n ; i++) {
+	 r128ctx->next_elt[0] = (GLushort) out[0];
+	 r128ctx->next_elt[1] = (GLushort) out[i-1];
+	 r128ctx->next_elt[2] = (GLushort) out[i];
+	 r128ctx->next_elt += 3;
+      }
+   }
+   if ( DEBUG_ELTPATH )
+      fflush( stderr );
+}
+
+
+
+
+/* Build a table of functions to clip each primitive type.  These
+ * produce a list of elements in the appropriate 'reduced' primitive,
+ * ie (points, lines, triangles) containing all the clipped and
+ * unclipped primitives from the original list.
+ */
+
+#define INIT(x)
+
+#define TRI_THRESHOLD		(GLint)(2 * sizeof(GLuint))
+
+#define UNCLIPPED_VERT(x)	(GLushort)(r128ctx->first_vert_index - x)
+
+#define TRIANGLE( e2, e1, e0 )						\
+do {									\
+   if ( DEBUG_ELTPATH )							\
+      fprintf( stderr, "   tri nv=%p ne=%p space=%d thresh=%d %d\n",	\
+	       r128ctx->next_vert, r128ctx->next_elt,			\
+	       (GLint)((GLuint)r128ctx->next_vert -			\
+		       (GLuint)r128ctx->next_elt), TRI_THRESHOLD,	\
+	       ( (GLint)((GLuint)r128ctx->next_vert -			\
+			 (GLuint)r128ctx->next_elt) < TRI_THRESHOLD ) );\
+   if ( (GLint)((GLuint)r128ctx->next_vert -				\
+		(GLuint)r128ctx->next_elt) < TRI_THRESHOLD ) {		\
+      if ( DEBUG_ELTPATH )						\
+	 fprintf( stderr, "      firing elts...\n" );			\
+      fire_elts( r128ctx );						\
+   }									\
+   r128ctx->next_elt[0] = UNCLIPPED_VERT( e2 );				\
+   r128ctx->next_elt[1] = UNCLIPPED_VERT( e1 );				\
+   r128ctx->next_elt[2] = UNCLIPPED_VERT( e0 );				\
+   if ( 0 )								\
+      fprintf( stderr, "    tri %d,%d,%d -> %hd,%hd,%hd\n",		\
+	       e2, e1, e0, r128ctx->next_elt[0],			\
+	       r128ctx->next_elt[1], r128ctx->next_elt[2]);		\
+   r128ctx->next_elt += 3;						\
+   if ( DEBUG_ELTPATH )							\
+      fflush( stderr );							\
+} while (0)
+
+#define CLIP_TRIANGLE( e2, e1, e0 )					\
+do {									\
+   GLubyte ormask = mask[e2] | mask[e1] | mask[e0];			\
+   if ( ormask == 0 ) {							\
+      TRIANGLE( e2, e1, e0 );						\
+   } else if ( (mask[e2] & mask[e1] & mask[e0]) == 0 ) {		\
+      out[0] = e2;							\
+      out[1] = e1;							\
+      out[2] = e0;							\
+      r128_tri_clip( r128ctx, VB, out, ormask );			\
+   }									\
+} while (0)
+
+#define LOCAL_VARS							\
+   r128ContextPtr r128ctx = R128_CONTEXT( VB->ctx );			\
+   GLuint *elt = VB->EltPtr->data;					\
+   GLuint out[VB_MAX_CLIPPED_VERTS];					\
+   GLubyte *mask = VB->ClipMask; 					\
+   (void) mask; (void) out; (void) elt; (void) r128ctx;
+
+
+
+#define RENDER_POINTS( start, count )
+#define RENDER_LINE( i1, i0 )
+#define RENDER_TRI( i2, i1, i0, pv, parity )				\
+do {									\
+   GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0];			\
+   if (parity) e2 = elt[i1], e1 = elt[i2];				\
+   CLIP_TRIANGLE( e2, e1, e0 );						\
+} while (0)
+
+#define RENDER_QUAD( i3, i2, i1, i0, pv )				\
+  CLIP_TRIANGLE( elt[i3], elt[i2], elt[i0] );     			\
+  CLIP_TRIANGLE( elt[i2], elt[i1], elt[i0] )
+
+#define TAG(x) r128_##x##_elt
+#include "render_tmp.h"
+
+
+
+#define LOCAL_VARS							\
+   r128ContextPtr r128ctx = R128_CONTEXT( VB->ctx );			\
+   GLuint *elt = VB->EltPtr->data;					\
+   (void) elt; (void) r128ctx;
+
+#define RENDER_POINTS( start, count )
+#define RENDER_LINE( i1, i0 )
+#define RENDER_TRI( i2, i1, i0, pv, parity )				\
+do {									\
+   GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0];			\
+   if (parity) e2 = elt[i1], e1 = elt[i2];				\
+   TRIANGLE( e2, e1, e0 );						\
+} while (0)
+
+#define RENDER_QUAD(i3, i2, i1, i0, pv )				\
+  TRIANGLE( elt[i3], elt[i2], elt[i0] );				\
+  TRIANGLE( elt[i2], elt[i1], elt[i0] )
+
+#define TAG(x) r128_##x##_elt_unclipped
+#include "render_tmp.h"
+
+
+
+
+static void refresh_projection_matrix( GLcontext *ctx )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   GLmatrix *mat = &ctx->Viewport.WindowMap;
+   GLfloat *m = r128ctx->device_matrix;
+
+   m[MAT_SX] =  mat->m[MAT_SX];
+   m[MAT_TX] =  mat->m[MAT_TX];
+   m[MAT_SY] = -mat->m[MAT_SY];
+   m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h;
+   m[MAT_SZ] =  mat->m[MAT_SZ] * r128ctx->depth_scale;
+   m[MAT_TZ] =  mat->m[MAT_TZ] * r128ctx->depth_scale;
+}
+
+#define CLIP_UBYTE_B 0
+#define CLIP_UBYTE_G 1
+#define CLIP_UBYTE_R 2
+#define CLIP_UBYTE_A 3
+
+
+#define TYPE (0)
+#define TAG(x) x
+#include "r128_elttmp.h"
+
+#define TYPE (R128_RGBA_BIT)
+#define TAG(x) x##_RGBA
+#include "r128_elttmp.h"
+
+#define TYPE (R128_TEX0_BIT)
+#define TAG(x) x##_TEX0
+#include "r128_elttmp.h"
+
+#define TYPE (R128_RGBA_BIT|R128_TEX0_BIT)
+#define TAG(x) x##_RGBA_TEX0
+#include "r128_elttmp.h"
+
+#define TYPE (R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT)
+#define TAG(x) x##_RGBA_TEX0_TEX1
+#include "r128_elttmp.h"
+
+#define TYPE (R128_TEX0_BIT|R128_TEX1_BIT)
+#define TAG(x) x##_TEX0_TEX1
+#include "r128_elttmp.h"
+
+
+/* Very sparsely popluated array - fix the indices.
+ */
+static struct r128_elt_tab r128EltTab[0x80];
+
+void r128DDEltPathInit( void )
+{
+   r128_render_init_elt();
+   r128_render_init_elt_unclipped();
+
+   r128_init_eltpath( &r128EltTab[0] );
+   r128_init_eltpath_RGBA( &r128EltTab[R128_RGBA_BIT] );
+   r128_init_eltpath_TEX0( &r128EltTab[R128_TEX0_BIT] );
+   r128_init_eltpath_RGBA_TEX0( &r128EltTab[R128_RGBA_BIT|R128_TEX0_BIT] );
+   r128_init_eltpath_TEX0_TEX1( &r128EltTab[R128_TEX0_BIT|R128_TEX1_BIT] );
+   r128_init_eltpath_RGBA_TEX0_TEX1( &r128EltTab[R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] );
+}
+
+#define VALID_SETUP (R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT)
+
+
+
+/* Use a temporary array for device coordinates, so that we can easily
+ * tap into existing mesa assembly.  Otherwise consider emitting
+ * device coordinates to dma buffers directly from the project/cliptest
+ * routine.  (requires output stride, potential loss of writecombining
+ * efficiency?)
+ *
+ * This path is a lot closer to the standard vertex path in the
+ * initial stages than the original fastpath.  A slightly more optimal
+ * path could be constructed, but would require us to write new
+ * assembly.
+ */
+void r128DDEltPath( struct vertex_buffer *VB )
+{
+   GLcontext *ctx = VB->ctx;
+   GLenum prim = ctx->CVA.elt_mode;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   struct r128_elt_tab *tab = &r128EltTab[r128ctx->SetupIndex & VALID_SETUP];
+   GLint vertsize = r128ctx->vertsize;
+   GLint space;
+
+   if ( DEBUG_ELTPATH )
+      fprintf( stderr, "\n\n\n%s: count=%d space=%d\n",
+	       __FUNCTION__, VB->Count,
+	       (GLint)((GLuint)r128ctx->next_vert -
+		       (GLuint)r128ctx->next_elt) );
+
+   VB->ClipPtr = TransformRaw( &VB->Clip,
+			       &ctx->ModelProjectMatrix,
+			       VB->ObjPtr );
+
+   refresh_projection_matrix( ctx );
+
+   VB->ClipAndMask = ~0;
+   VB->ClipOrMask = 0;
+   VB->Projected = gl_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
+						   &VB->Win,
+						   VB->ClipMask,
+						   &VB->ClipOrMask,
+						   &VB->ClipAndMask );
+
+   if ( VB->ClipAndMask ) {
+      if ( DEBUG_ELTPATH )
+	 fprintf( stderr, "    clipped, returning...\n" );
+      return;
+   }
+   if ( r128ctx->vert_buf ) {
+      r128FlushVertices( r128ctx );
+   }
+   if ( r128ctx->new_state ) {
+      r128DDUpdateHWState( ctx );
+   }
+
+   space = (GLint)((GLuint)r128ctx->next_vert -
+		   (GLuint)r128ctx->next_elt);
+
+   /* Allocate a single buffer to hold unclipped vertices.  All
+    * unclipped vertices must be contiguous.
+    */
+   if ( DEBUG_ELTPATH )
+      fprintf( stderr, "   top nv=%p ne=%p space=%d reqd=%d count=%d   clip=0x%x\n\n",
+	       r128ctx->next_vert, r128ctx->next_elt, space,
+	       (GLint)VB->Count * vertsize * sizeof(GLuint),
+	       VB->Count, VB->ClipOrMask );
+
+   /* Because we need to adjust the next_elt pointer to accomodate the
+    * CCE packet header, we can sometimes go past the next_vert pointer
+    * and thus have negative space.
+    */
+   if ( space < (GLint)VB->Count * vertsize * (GLint)sizeof(GLuint) ||
+	r128ctx->vertsize != r128ctx->elt_vertsize ) {
+      fire_elts( r128ctx );
+   }
+
+   r128ctx->retained_buf = r128ctx->elt_buf;
+
+   /* Emit unclipped vertices to the buffer.
+    */
+   tab->emit_unclipped_verts( VB );
+
+   /* Emit indices and clipped vertices to one or more buffers.
+    */
+   if ( VB->ClipOrMask ) {
+      r128ctx->elt_tab = tab;
+      r128_render_tab_elt[prim]( VB, 0, VB->EltPtr->count, 0 );
+   } else {
+      r128_render_tab_elt_unclipped[prim]( VB, 0, VB->EltPtr->count, 0 );
+   }
+
+   /* Send to hardware and release the elt buffer.
+    */
+   release_bufs( r128ctx );
+
+   /* This indicates that there is no cached data to reuse.
+    */
+   VB->pipeline->data_valid = 0;
+   VB->pipeline->new_state = 0;
+
+   if ( DEBUG_ELTPATH ) {
+      FLUSH_BATCH( r128ctx );
+
+      LOCK_HARDWARE( r128ctx );
+      drmR128WaitForIdleCCE( r128ctx->driFd );
+      UNLOCK_HARDWARE( r128ctx );
+
+      __asm__ __volatile__ ( "int $3" );
+   }
+}
Index: xc/lib/GL/mesa/src/drv/r128/r128_elttmp.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/r128/r128_elttmp.h:1.1
--- /dev/null	Mon Dec 18 14:23:36 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_elttmp.h	Mon Dec  4 14:21:46 2000
@@ -0,0 +1,274 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_elttmp.h,v 1.1 2000/12/04 19:21:46 dawes Exp $ */
+/*
+ * DRI Hardware Device Driver for G200/G400
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/* Buffers fill from high addresses down with vertices and from low
+ * addresses up with elements.
+ */
+
+
+/* Emit the bulk of the vertices to the first dma buffer.  Leave
+ * empty slots for clipped vertices so that we can still address
+ * vertices by index.
+ */
+static void TAG(emit_unclipped_verts)( struct vertex_buffer *VB )
+{
+   GLuint i;
+   r128ContextPtr r128ctx = R128_CONTEXT(VB->ctx);
+   GLfloat *dev = VB->Projected->start;
+   GLubyte *color = VB->ColorPtr->start;
+   GLfloat *tex0_data = VB->TexCoordPtr[0]->start;
+   GLfloat *tex1_data = VB->TexCoordPtr[1]->start;
+   GLuint color_stride = VB->ColorPtr->stride;
+   GLuint tex0_stride = VB->TexCoordPtr[0]->stride;
+   GLuint tex1_stride = VB->TexCoordPtr[1]->stride;
+   GLuint buffer_stride = r128ctx->vertsize;
+
+   GLfloat *f = r128ctx->next_vert;
+   GLuint count = VB->Count;
+   GLubyte *clipmask = VB->ClipMask;
+
+   const GLfloat *m = r128ctx->device_matrix;
+   const GLfloat sx = m[0], sy = m[5], sz = m[10];
+   const GLfloat tx = m[12], ty = m[13], tz = m[14];
+
+   if ( 0 )
+      fprintf( stderr, "%s: stride=%d\n", __FUNCTION__, buffer_stride );
+
+   r128ctx->retained_buf = r128ctx->elt_buf;
+   r128ctx->first_vert_index = r128ctx->next_vert_index;
+
+   for ( i = 0 ; i < count ; f -= buffer_stride, i++ )
+   {
+      if ( !clipmask[i] )
+      {
+	 if ( 0 )
+	    fprintf( stderr, "vert=%d addr=%p space=0x%x\n",
+		     i, f, (GLuint)f - (GLuint)r128ctx->elt_buf->address );
+
+	 f[0] = sx * dev[0] + tx;
+	 f[1] = sy * dev[1] + ty;
+	 f[2] = sz * dev[2] + tz;
+	 f[3] = dev[3];
+
+	 if (TYPE & R128_RGBA_BIT) {
+#if 0 /*defined(USE_X86_ASM)*/
+	    __asm__ (
+	       "movl (%%edx),%%eax   \n"
+	       "bswap %%eax          \n"
+	       "rorl $8,%%eax        \n"
+	       "movl %%eax,16(%%edi) \n"
+	       :
+	       : "d" (color), "D" (f)
+	       : "%eax" );
+#else
+	    GLubyte *b = (GLubyte *)&f[4];
+	    b[CLIP_UBYTE_B] = color[2];
+	    b[CLIP_UBYTE_G] = color[1];
+	    b[CLIP_UBYTE_R] = color[0];
+	    b[CLIP_UBYTE_A] = color[3];
+#endif
+	 }
+
+	 if (TYPE & R128_TEX0_BIT) {
+	    *(int*)&f[6] = *(int*)&tex0_data[0];
+	    *(int*)&f[7] = *(int*)&tex0_data[1];
+	 }
+
+	 if (TYPE & R128_TEX1_BIT) {
+	    *(int*)&f[8] = *(int*)&tex1_data[0];
+	    *(int*)&f[9] = *(int*)&tex1_data[1];
+	 }
+      }
+
+      STRIDE_F(dev, 16);
+      if (TYPE & R128_RGBA_BIT) color += color_stride;
+      if (TYPE & R128_TEX0_BIT) STRIDE_F(tex0_data, tex0_stride);
+      if (TYPE & R128_TEX1_BIT) STRIDE_F(tex1_data, tex1_stride);
+   }
+
+   r128ctx->next_vert = f;
+   r128ctx->next_vert_index -= count;
+}
+
+
+/* Build three temporary clipspace vertex for clipping a triangle.
+ * Recreate from the VB data rather than trying to read back from
+ * uncached memory.
+ */
+static void TAG(build_tri_verts)( r128ContextPtr r128ctx,
+				  struct vertex_buffer *VB,
+				  GLfloat *O,
+				  GLuint *elt )
+{
+   int i;
+
+   for ( i = 0 ; i < 3 ; i++, O += CLIP_STRIDE ) {
+      GLfloat *clip = VB->Clip.start + elt[i]*4;
+
+      O[0] = clip[0];
+      O[1] = clip[1];
+      O[2] = clip[2];
+      O[3] = clip[3];
+
+      if (TYPE & R128_RGBA_BIT) {
+	 GLubyte *col = VEC_ELT(VB->ColorPtr, GLubyte, elt[i]);
+	 GLubyte *b = (GLubyte *)&O[4];
+	 b[CLIP_UBYTE_R] = col[0];
+	 b[CLIP_UBYTE_G] = col[1];
+	 b[CLIP_UBYTE_B] = col[2];
+	 b[CLIP_UBYTE_A] = col[3];
+      }
+
+      if ( 0 )
+	 fprintf(stderr,
+		 "build_tri_vert elt[%d]=%d index=0x%x (first_index=0x%x)\n",
+		 i, elt[i], (GLuint)UNCLIPPED_VERT(elt[i]),
+		 (GLuint)r128ctx->first_vert_index);
+
+      *(GLuint *)&O[5] = UNCLIPPED_VERT(elt[i]);
+
+      if (TYPE & R128_TEX0_BIT) {
+	 GLfloat *tex0_data = VEC_ELT(VB->TexCoordPtr[0], GLfloat, elt[i]);
+	 *(int*)&O[6] = *(int*)&tex0_data[0];
+	 *(int*)&O[7] = *(int*)&tex0_data[1];
+      }
+
+      if (TYPE & R128_TEX1_BIT) {
+	 GLfloat *tex1_data = VEC_ELT(VB->TexCoordPtr[1], GLfloat, elt[i]);
+	 *(int*)&O[8] = *(int*)&tex1_data[0];
+	 *(int*)&O[9] = *(int*)&tex1_data[1];
+      }
+   }
+}
+
+
+/* Interpolate between two of the vertices constructed above.
+ */
+static void TAG(interp)( GLfloat t,
+			 GLfloat *O,
+			 const GLfloat *I,
+			 const GLfloat *J )
+{
+   O[0] = LINTERP(t, I[0], J[0]);
+   O[1] = LINTERP(t, I[1], J[1]);
+   O[2] = LINTERP(t, I[2], J[2]);
+   O[3] = LINTERP(t, I[3], J[3]);
+
+   if (TYPE & R128_RGBA_BIT) {
+      INTERP_RGBA(t,
+		  ((GLubyte *)&(O[4])),
+		  ((GLubyte *)&(I[4])),
+		  ((GLubyte *)&(J[4])));
+   }
+
+   if (0) fprintf(stderr, "setting 0x%x to ~0\n", (GLuint)&O[5]);
+
+   *(GLuint *)&O[5] = ~0;	/* note that this is a new vertex */
+
+   if (TYPE & R128_TEX0_BIT) {
+      O[6] = LINTERP(t, I[6], J[6]);
+      O[7] = LINTERP(t, I[7], J[7]);
+   }
+
+   if (TYPE & R128_TEX1_BIT) {
+      O[8] = LINTERP(t, I[8], J[8]);
+      O[9] = LINTERP(t, I[9], J[9]);
+   }
+}
+
+
+
+/* When clipping is complete, scan the final vertex list and emit any
+ * new ones to dma buffers.  Update the element list to a format
+ * suitable for sending to hardware.
+ */
+static void TAG(project_and_emit_verts)( r128ContextPtr r128ctx,
+					 const GLfloat *verts,
+					 GLuint *elt,
+					 int nr)
+{
+   GLfloat *O = r128ctx->next_vert;
+   GLushort index = r128ctx->next_vert_index;
+   GLuint buffer_stride = r128ctx->vertsize;
+
+   const GLfloat *m = r128ctx->device_matrix;
+   const GLfloat sx = m[0], sy = m[5], sz = m[10];
+   const GLfloat tx = m[12], ty = m[13], tz = m[14];
+   GLuint i;
+
+   for (i = 0 ; i < nr ; i++) {
+      const GLfloat *I = &verts[elt[i] * CLIP_STRIDE];
+      GLuint tmp = *(GLuint *)&I[5];
+
+      if (0) fprintf(stderr, "elt[%d] (tmp 0x%x %d) %d --> ",
+		     i, (GLuint)&I[5], tmp, elt[i]);
+
+      if ((elt[i] = tmp) == ~0)
+      {
+	 GLfloat oow = 1.0/I[3];
+
+	 elt[i] = index--;
+
+	 O[0] = sx * I[0] * oow + tx;
+	 O[1] = sy * I[1] * oow + ty;
+	 O[2] = sz * I[2] * oow + tz;
+	 O[3] = oow;
+
+	 if (TYPE & R128_RGBA_BIT) {
+	    *(int*)&O[4] = *(int*)&I[4];
+	 }
+
+	 if (TYPE & R128_TEX0_BIT) {
+	    *(int*)&O[6] = *(int*)&I[6];
+	    *(int*)&O[7] = *(int*)&I[7];
+	 }
+
+	 if (TYPE & R128_TEX1_BIT) {
+	    *(int*)&O[8] = *(int*)&I[8];
+	    *(int*)&O[9] = *(int*)&I[9];
+	 }
+
+	 O -= buffer_stride;
+      }
+      if (0) fprintf(stderr, "0x%x\n", elt[i]);
+   }
+
+   r128ctx->next_vert = O;
+   r128ctx->next_vert_index = index;
+}
+
+
+
+static void TAG(r128_init_eltpath)( struct r128_elt_tab *tab )
+{
+   tab->emit_unclipped_verts = TAG(emit_unclipped_verts);
+   tab->build_tri_verts = TAG(build_tri_verts);
+   tab->interp = TAG(interp);
+   tab->project_and_emit_verts = TAG(project_and_emit_verts);
+}
+
+#undef TYPE
+#undef TAG
+#undef STRIDE
Index: xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c:1.1 xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c:1.4
--- xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c:1.1	Fri Jun 16 20:03:05 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c	Mon Dec  4 14:21:46 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c,v 1.1 2000/06/17 00:03:05 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c,v 1.4 2000/12/04 19:21:46 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,22 +28,25 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Keith Whitwell <keithw@valinux.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
-#include "r128_init.h"
-#include "r128_mesa.h"
 #include "r128_state.h"
 #include "r128_vb.h"
-#include "r128_cce.h"
+#include "r128_pipeline.h"
+#include "r128_ioctl.h"
 #include "r128_tris.h"
-#include "r128_fastpath.h"
 
 #include "mmath.h"
 #include "cva.h"
 #include "vertices.h"
 
+/* HACK: Declare this global for now */
+static GLfloat m[16] __attribute__ ((aligned (16)));
+
 /* FIXME: These routines were copied from the i810 driver, and were only
    slightly modified for the Rage 128.  They still need to be optmizied
    and cleaned up.  Also, support for USE_RHW2 needs to be added.
@@ -51,57 +54,58 @@
    KW: The fastpath never does projective texturing, so RHW2 support
    isn't necesary here.
 */
+
+struct r128_fast_tab {
+   void (*build_vertices)( struct vertex_buffer *VB, GLuint do_cliptest );
+   void (*interp)( GLfloat t, GLfloat *O, const GLfloat *I, const GLfloat *J );
+};
+
+#define POINT(x)   r128_draw_point( r128ctx, &vert[x], psize )
+#define LINE(x,y)  r128_draw_line( r128ctx, &vert[x], &vert[y], lwidth )
+#define TRI(x,y,z) r128_draw_triangle( r128ctx, &vert[x], &vert[y], &vert[z] )
 
-typedef struct r128_fast_table {
-    r128BuildVerticesFunc build_vertices;
-    r128InterpFunc        interp;
-} r128FastPathTable;
-
-#define POINT(x)   r128DrawPointVB(r128ctx, &vert[x], psize)
-#define LINE(x,y)  r128DrawLineVB(r128ctx, &vert[x], &vert[y], lwidth)
-#define TRI(x,y,z) r128DrawTriangleVB(r128ctx, &vert[x], &vert[y], &vert[z])
 
 /* Direct, and no clipping required.  The clip funcs have not been
   written yet, so this is only useful for the fast path. */
-#define RENDER_POINTS(start, count)                                       \
-do {                                                                      \
-    GLuint e;                                                             \
-    for (e = start; e <= count; e++)                                      \
-	POINT(elt[e]);                                                    \
-} while (0)
-
-#define RENDER_LINE(i1, i)                                                \
-do {                                                                      \
-    GLuint e1 = elt[i1], e = elt[i];                                      \
-    LINE(e1, e);                                                          \
-} while (0)
-
-#define RENDER_TRI(i2, i1, i, pv, parity)                                 \
-do {                                                                      \
-    GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];                        \
-    if (parity) {                                                         \
-	GLuint tmp = e2;                                                  \
-	e2 = e1;                                                          \
-	e1 = tmp;                                                         \
-    }                                                                     \
-    TRI(e2, e1, e);                                                       \
-} while (0)
-
-#define RENDER_QUAD(i3, i2, i1, i, pv)                                    \
-do {                                                                      \
-    GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];          \
-    TRI(e3, e2, e);                                                       \
-    TRI(e2, e1, e);                                                       \
-} while (0)
-
-#define LOCAL_VARS                                                        \
-    r128VertexPtr   vert    = R128_DRIVER_DATA(VB)->verts;                \
-    const GLuint   *elt     = VB->EltPtr->data;                           \
-    GLcontext      *ctx     = VB->ctx;                                    \
-    r128ContextPtr  r128ctx = R128_CONTEXT(ctx);                          \
-    const GLfloat   lwidth  = ctx->Line.Width;                            \
-    const GLfloat   psize   = ctx->Point.Size;                            \
-    (void) lwidth; (void)psize; (void) vert;
+#define RENDER_POINTS(start, count)					\
+do {									\
+   GLuint e;								\
+   for (e = start; e < count; e++)					\
+      POINT(elt[e]);							\
+} while (0)
+
+#define RENDER_LINE(i1, i)						\
+do {									\
+   GLuint e1 = elt[i1], e = elt[i];					\
+   LINE(e1, e);								\
+} while (0)
+
+#define RENDER_TRI(i2, i1, i, pv, parity)				\
+do {									\
+   GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];			\
+   if (parity) {							\
+      GLuint tmp = e2;							\
+      e2 = e1;								\
+      e1 = tmp;								\
+   }									\
+   TRI(e2, e1, e);							\
+} while (0)
+
+#define RENDER_QUAD(i3, i2, i1, i, pv)					\
+do {									\
+   GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];		\
+   TRI(e3, e2, e);							\
+   TRI(e2, e1, e);							\
+} while (0)
+
+#define LOCAL_VARS							\
+   r128VertexPtr	vert = R128_DRIVER_DATA(VB)->verts;		\
+   const GLuint		*elt = VB->EltPtr->data;			\
+   GLcontext		*ctx = VB->ctx;					\
+   r128ContextPtr	r128ctx = R128_CONTEXT(ctx);			\
+   const GLfloat	lwidth = ctx->Line.Width;			\
+   const GLfloat	psize = ctx->Point.Size;			\
+   (void) lwidth; (void) psize; (void) vert;
 
 #define TAG(x) r128_##x##_smooth_indirect
 #include "render_tmp.h"
@@ -113,196 +117,196 @@
 #define LINTERP(T, A, B)     ((A) + (T) * ((B) - (A)))
 
 
-#define INTERP_RGBA(t, out, a, b)                                         \
-do {                                                                      \
-    int i;                                                                \
-    for (i = 0; i < 4; i++) {                                             \
-	GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]);                    \
-	GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]);                    \
-	GLfloat fo = LINTERP(t, fa, fb);                                  \
-	FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo);                           \
-   }                                                                      \
-} while (0)
-
-
-#define CLIP(SGN, V, PLANE)                                               \
-do {                                                                      \
-    if (mask & PLANE) {                                                   \
-	GLuint   *indata  = inlist[in];                                   \
-	GLuint   *outdata = inlist[in ^= 1];                              \
-	GLuint   nr       = n;                                            \
-	GLfloat *J        = verts[indata[nr-1]].f;                        \
-	GLfloat  dpJ      = (SGN J[V]) + J[3];                            \
-                                                                          \
-	inlist[0] = vlist1;                                               \
-	for (i = n = 0 ; i < nr ; i++) {                                  \
-	    GLuint   elt_i = indata[i];                                   \
-	    GLfloat *I     = verts[elt_i].f;                              \
-	    GLfloat  dpI   = (SGN I[V]) + I[3];                           \
-                                                                          \
-	    if (DIFFERENT_SIGNS(dpI, dpJ)) {                              \
-		GLfloat *O = verts[next_vert].f;                          \
-		GLfloat t, *in, *out;                                     \
-                                                                          \
-		if (NEGATIVE(dpI)) {                                      \
-		    t = dpI / (dpI - dpJ);                                \
-		    in = I;                                               \
-		    out = J;                                              \
-		} else {                                                  \
-		    t = dpJ / (dpJ - dpI);                                \
-		    in = J;                                               \
-		    out = I;                                              \
-		}                                                         \
-                                                                          \
-		interp(t, O, in, out);                                    \
-                                                                          \
-		clipmask[next_vert] = 0;                                  \
-		outdata[n++] = next_vert++;                               \
-	    }                                                             \
-                                                                          \
-	    clipmask[elt_i] |= PLANE;      /* don't set up */             \
-                                                                          \
-	    if (!NEGATIVE(dpI)) {                                         \
-		outdata[n++] = elt_i;                                     \
-		clipmask[elt_i] &= ~PLANE; /* set up after all */         \
-	    }                                                             \
-                                                                          \
-	    J = I;                                                        \
-	    dpJ = dpI;                                                    \
-	}                                                                 \
-                                                                          \
-	if (n < 3) return;                                                \
-    }                                                                     \
-} while (0)
-
-#define LINE_CLIP(x,y,z,w,PLANE)                                          \
-do {                                                                      \
-    if (mask & PLANE) {                                                   \
-	GLfloat dpI = DOT4V(I,x,y,z,w);                                   \
-	GLfloat dpJ = DOT4V(J,x,y,z,w);                                   \
-                                                                          \
-	if (DIFFERENT_SIGNS(dpI, dpJ)) {                                  \
-	    GLfloat *O = verts[next_vert].f;                              \
-	    GLfloat  t = dpI / (dpI - dpJ);                               \
-                                                                          \
-	    interp(t, O, I, J);                                           \
-                                                                          \
-	    clipmask[next_vert] = 0;                                      \
-                                                                          \
-	    if (NEGATIVE(dpI)) {                                          \
-		clipmask[elts[0]] |= PLANE;                               \
-		I = O;                                                    \
-		elts[0] = next_vert++;                                    \
-	    } else {                                                      \
-		clipmask[elts[1]] |= PLANE;                               \
-		J = O;                                                    \
-		elts[1] = next_vert++;                                    \
-	    }                                                             \
-	} else if (NEGATIVE(dpI)) return;                                 \
-    }                                                                     \
-} while (0)
-
-
-static void r128TriClip(GLuint **p_elts,
-			r128Vertex *verts,
-			GLubyte *clipmask,
-			GLuint *p_next_vert,
-			GLubyte mask,
-			r128InterpFunc interp)
+#define INTERP_RGBA(t, out, a, b)					\
+do {									\
+   int i;								\
+   for (i = 0; i < 4; i++) {						\
+      GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]);			\
+      GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]);			\
+      GLfloat fo = LINTERP(t, fa, fb);					\
+      FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo);				\
+   }									\
+} while (0)
+
+
+#define CLIP(SGN, V, PLANE)						\
+do {									\
+   if (mask & PLANE) {							\
+      GLuint *indata = inlist[in];					\
+      GLuint *outdata = inlist[in ^= 1];				\
+      GLuint nr = n;							\
+      GLfloat *J = verts[indata[nr-1]].f;				\
+      GLfloat dpJ = (SGN J[V]) + J[3];					\
+									\
+      inlist[0] = vlist1;						\
+      for (i = n = 0 ; i < nr ; i++) {					\
+	 GLuint elt_i = indata[i];					\
+	 GLfloat *I = verts[elt_i].f;					\
+	 GLfloat dpI = (SGN I[V]) + I[3];				\
+									\
+	 if (DIFFERENT_SIGNS(dpI, dpJ)) {				\
+	    GLfloat *O = verts[next_vert].f;				\
+	    GLfloat t, *in, *out;					\
+									\
+	    if (NEGATIVE(dpI)) {					\
+	       t = dpI / (dpI - dpJ);					\
+	       in = I;							\
+	       out = J;							\
+	    } else {							\
+	       t = dpJ / (dpJ - dpI);					\
+	       in = J;							\
+	       out = I;							\
+	    }								\
+									\
+	    interp(t, O, in, out);					\
+									\
+	    clipmask[next_vert] = 0;					\
+	    outdata[n++] = next_vert++;					\
+	 }								\
+									\
+	 clipmask[elt_i] |= PLANE;      /* don't set up */		\
+									\
+	 if (!NEGATIVE(dpI)) {						\
+	    outdata[n++] = elt_i;					\
+	    clipmask[elt_i] &= ~PLANE; /* set up after all */		\
+	 }								\
+									\
+	 J = I;								\
+	 dpJ = dpI;							\
+      }									\
+									\
+      if (n < 3) return;						\
+   }									\
+} while (0)
+
+#define LINE_CLIP(x,y,z,w,PLANE)					\
+do {									\
+   if (mask & PLANE) {							\
+      GLfloat dpI = DOT4V(I,x,y,z,w);					\
+      GLfloat dpJ = DOT4V(J,x,y,z,w);					\
+									\
+      if (DIFFERENT_SIGNS(dpI, dpJ)) {					\
+	 GLfloat *O = verts[next_vert].f;				\
+	 GLfloat t = dpI / (dpI - dpJ);					\
+									\
+	 interp(t, O, I, J);						\
+									\
+	 clipmask[next_vert] = 0;					\
+									\
+	 if (NEGATIVE(dpI)) {						\
+	    clipmask[elts[0]] |= PLANE;					\
+	    I = O;							\
+	    elts[0] = next_vert++;					\
+	 } else {							\
+	    clipmask[elts[1]] |= PLANE;					\
+	    J = O;							\
+	    elts[1] = next_vert++;					\
+	 }								\
+      } else if (NEGATIVE(dpI)) return;					\
+   }									\
+} while (0)
+
+
+static __inline void r128_tri_clip( GLuint **p_elts,
+				    r128Vertex *verts,
+				    GLubyte *clipmask,
+				    GLuint *p_next_vert,
+				    GLubyte mask,
+				    r128_interp_func interp )
 {
-    GLuint *elts      = *p_elts;
-    GLuint  next_vert = *p_next_vert;
-    GLuint  in        = 0;
-    GLuint  n         = 3;
-    GLuint  vlist1[VB_MAX_CLIPPED_VERTS];
-    GLuint  vlist2[VB_MAX_CLIPPED_VERTS];
-    GLuint *inlist[2];
-    GLuint *out;
-    GLuint  i;
-
-    inlist[0] = elts;
-    inlist[1] = vlist2;
-
-    CLIP(-,0,CLIP_RIGHT_BIT);
-    CLIP(+,0,CLIP_LEFT_BIT);
-    CLIP(-,1,CLIP_TOP_BIT);
-    CLIP(+,1,CLIP_BOTTOM_BIT);
-    CLIP(-,2,CLIP_FAR_BIT);
-    CLIP(+,2,CLIP_NEAR_BIT);
-
-    /* Convert the planar polygon to a list of triangles */
-    out = inlist[in];
-
-    for (i = 2 ; i < n ; i++) {
-	elts[0] = out[0];
-	elts[1] = out[i-1];
-	elts[2] = out[i];
-	elts += 3;
-    }
+   GLuint *elts = *p_elts;
+   GLuint next_vert = *p_next_vert;
+   GLuint in = 0;
+   GLuint n = 3;
+   GLuint vlist1[VB_MAX_CLIPPED_VERTS];
+   GLuint vlist2[VB_MAX_CLIPPED_VERTS];
+   GLuint *inlist[2];
+   GLuint *out;
+   GLuint i;
+
+   inlist[0] = elts;
+   inlist[1] = vlist2;
+
+   CLIP( -, 0, CLIP_RIGHT_BIT );
+   CLIP( +, 0, CLIP_LEFT_BIT );
+   CLIP( -, 1, CLIP_TOP_BIT );
+   CLIP( +, 1, CLIP_BOTTOM_BIT );
+   CLIP( -, 2, CLIP_FAR_BIT );
+   CLIP( +, 2, CLIP_NEAR_BIT );
+
+   /* Convert the planar polygon to a list of triangles */
+   out = inlist[in];
+
+   for (i = 2 ; i < n ; i++) {
+      elts[0] = out[0];
+      elts[1] = out[i-1];
+      elts[2] = out[i];
+      elts += 3;
+   }
 
-    *p_next_vert = next_vert;
-    *p_elts      = elts;
+   *p_next_vert = next_vert;
+   *p_elts = elts;
 }
 
 
-static void r128LineClip(GLuint **p_elts,
-			 r128Vertex *verts,
-			 GLubyte *clipmask,
-			 GLuint *p_next_vert,
-			 GLubyte mask,
-			 r128InterpFunc interp)
+static __inline void r128_line_clip( GLuint **p_elts,
+				     r128Vertex *verts,
+				     GLubyte *clipmask,
+				     GLuint *p_next_vert,
+				     GLubyte mask,
+				     r128_interp_func interp )
 {
-    GLuint  *elts      = *p_elts;
-    GLfloat *I         = verts[elts[0]].f;
-    GLfloat *J         = verts[elts[1]].f;
-    GLuint   next_vert = *p_next_vert;
-
-    LINE_CLIP(1,0,0,-1,CLIP_LEFT_BIT);
-    LINE_CLIP(-1,0,0,1,CLIP_RIGHT_BIT);
-    LINE_CLIP(0,1,0,-1,CLIP_TOP_BIT);
-    LINE_CLIP(0,-1,0,1,CLIP_BOTTOM_BIT);
-    LINE_CLIP(0,0,1,-1,CLIP_FAR_BIT);
-    LINE_CLIP(0,0,-1,1,CLIP_NEAR_BIT);
+   GLuint *elts = *p_elts;
+   GLfloat *I = verts[elts[0]].f;
+   GLfloat *J = verts[elts[1]].f;
+   GLuint next_vert = *p_next_vert;
+
+   LINE_CLIP( 1, 0, 0, -1, CLIP_LEFT_BIT );
+   LINE_CLIP( -1, 0, 0, 1, CLIP_RIGHT_BIT );
+   LINE_CLIP( 0, 1, 0, -1, CLIP_TOP_BIT );
+   LINE_CLIP( 0, -1, 0, 1, CLIP_BOTTOM_BIT );
+   LINE_CLIP( 0, 0, 1, -1, CLIP_FAR_BIT );
+   LINE_CLIP( 0, 0, -1, 1, CLIP_NEAR_BIT );
 
-    *p_next_vert  = next_vert;
-    *p_elts      += 2;
+   *p_next_vert = next_vert;
+   *p_elts += 2;
 }
 
 
 
-#define CLIP_POINT(e)                                                     \
-do {                                                                      \
-   if (mask[e]) *out++ = e;                                               \
-} while (0)
-
-#define CLIP_LINE(e1, e0)                                                 \
-do {                                                                      \
-    GLubyte ormask = mask[e0] | mask[e1];                                 \
-    out[0] = e1;                                                          \
-    out[1] = e0;                                                          \
-    out += 2;                                                             \
-    if (ormask) {                                                         \
-	out-=2;                                                           \
-	if (!(mask[e0] & mask[e1])) {                                     \
-	    r128LineClip(&out, verts, mask, &next_vert, ormask, interp);  \
-	}                                                                 \
-    }                                                                     \
-} while (0)
-
-#define CLIP_TRIANGLE(e2, e1, e0)                                         \
-do {                                                                      \
-    GLubyte ormask;                                                       \
-    out[0] = e2;                                                          \
-    out[1] = e1;                                                          \
-    out[2] = e0;                                                          \
-    out += 3;                                                             \
-    ormask = mask[e2] | mask[e1] | mask[e0];                              \
-    if (ormask) {                                                         \
-	out -= 3;                                                         \
-	if (!(mask[e2] & mask[e1] & mask[e0])) {                          \
-	    r128TriClip(&out, verts, mask, &next_vert, ormask, interp);   \
-	}                                                                 \
-    }                                                                     \
+#define CLIP_POINT(e)							\
+do {									\
+   if (mask[e]) *out++ = e;						\
+} while (0)
+
+#define CLIP_LINE(e1, e0)						\
+do {									\
+   GLubyte ormask = mask[e0] | mask[e1];				\
+   out[0] = e1;								\
+   out[1] = e0;								\
+   out += 2;								\
+   if (ormask) {							\
+      out-=2;								\
+      if (!(mask[e0] & mask[e1])) {					\
+	 r128_line_clip(&out, verts, mask, &next_vert, ormask, interp);	\
+      }									\
+   }									\
+} while (0)
+
+#define CLIP_TRIANGLE(e2, e1, e0)					\
+do {									\
+   GLubyte ormask;							\
+   out[0] = e2;								\
+   out[1] = e1;								\
+   out[2] = e0;								\
+   out += 3;								\
+   ormask = mask[e2] | mask[e1] | mask[e0];				\
+   if (ormask) {							\
+      out -= 3;								\
+      if (!(mask[e2] & mask[e1] & mask[e0])) {				\
+	 r128_tri_clip(&out, verts, mask, &next_vert, ormask, interp);	\
+      }									\
+   }									\
 } while (0)
 
 
@@ -312,64 +316,65 @@
  * ie (points, lines, triangles) containing all the clipped and
  * unclipped primitives from the original list.
  */
-#define LOCAL_VARS                                                        \
-    r128ContextPtr       r128ctx   = R128_CONTEXT(VB->ctx);               \
-    r128VertexBufferPtr  r128VB    = R128_DRIVER_DATA(VB);                \
-    GLuint              *elt       = VB->EltPtr->data;                    \
-    r128Vertex          *verts     = r128VB->verts;                       \
-    GLuint               next_vert = r128VB->last_vert;                   \
-    GLuint              *out       = r128VB->clipped_elements.data;       \
-    GLubyte             *mask      = VB->ClipMask;                        \
-    r128InterpFunc       interp    = r128ctx->interp;                     \
-    (void) interp; (void) verts;
-
-#define POSTFIX                                                           \
-    r128VB->clipped_elements.count = out - r128VB->clipped_elements.data; \
-    r128VB->last_vert = next_vert;
+#define LOCAL_VARS							 \
+   r128ContextPtr	r128ctx = R128_CONTEXT(VB->ctx);		 \
+   r128VertexBufferPtr	r128VB = R128_DRIVER_DATA(VB);			 \
+   GLuint		*elt = VB->EltPtr->data;			 \
+   r128Vertex		*verts = r128VB->verts;				 \
+   GLuint		next_vert = r128VB->last_vert;			 \
+   GLuint		*out = r128VB->clipped_elements.data;		 \
+   GLubyte		*mask = VB->ClipMask;				 \
+   r128_interp_func	interp = r128ctx->interp;			 \
+   (void) interp; (void) verts;
+
+#define POSTFIX								 \
+   r128VB->clipped_elements.count = out - r128VB->clipped_elements.data; \
+   r128VB->last_vert = next_vert;
 
 
 #define INIT(x)
 
-#define RENDER_POINTS(start, count)                                       \
-do {                                                                      \
-    GLuint i;                                                             \
-    for (i = start; i < count; i++)                                       \
-	CLIP_POINT(elt[i]);                                               \
+#define RENDER_POINTS(start, count)					 \
+do {									 \
+   GLuint i;								 \
+   for (i = start; i < count; i++)					 \
+      CLIP_POINT(elt[i]);						 \
 } while (0)
 
-#define RENDER_LINE(i1, i0)                                               \
-do {                                                                      \
-    CLIP_LINE(elt[i1], elt[i0]);                                          \
+#define RENDER_LINE(i1, i0)						 \
+do {									 \
+   CLIP_LINE(elt[i1], elt[i0]);						 \
 } while (0)
 
-#define RENDER_TRI(i2, i1, i0, pv, parity)                                \
-do {                                                                      \
-    GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0];                      \
-    if (parity) e2 = elt[i1], e1 = elt[i2];                               \
-    CLIP_TRIANGLE(e2, e1, e0);                                            \
+#define RENDER_TRI(i2, i1, i0, pv, parity)				 \
+do {									 \
+   GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0];			 \
+   if (parity) e2 = elt[i1], e1 = elt[i2];				 \
+   CLIP_TRIANGLE(e2, e1, e0);						 \
 } while (0)
 
-#define RENDER_QUAD(i3, i2, i1, i0, pv)                                   \
-do {                                                                      \
-  CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]);                               \
-  CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0]);                               \
+#define RENDER_QUAD(i3, i2, i1, i0, pv)					 \
+do {									 \
+   CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]);				 \
+   CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0]);				 \
 } while (0)
 
 #define TAG(x) r128_##x##_clip_elt
 #include "render_tmp.h"
 
 
+
 /* Pack rgba and/or texture into the remaining half of a 32 byte vertex.
  */
-#define CLIP_UBYTE_COLOR  4
-#define CLIP_UBYTE_B 0
-#define CLIP_UBYTE_G 1
-#define CLIP_UBYTE_R 2
-#define CLIP_UBYTE_A 3
-#define CLIP_S0 6
-#define CLIP_T0 7
-#define CLIP_S1 8
-#define CLIP_T1 9
+#define CLIP_UBYTE_COLOR	4
+#define CLIP_UBYTE_B		0
+#define CLIP_UBYTE_G		1
+#define CLIP_UBYTE_R		2
+#define CLIP_UBYTE_A		3
+#define CLIP_S0			6
+#define CLIP_T0			7
+#define CLIP_S1			8
+#define CLIP_T1			9
 
 #define TYPE (0)
 #define TAG(x) x
@@ -402,135 +407,136 @@
 
 
 /* Render elements directly from original list of vertices. */
-static void r128RenderElementsDirect(struct vertex_buffer *VB)
+static void r128_render_elements_direct( struct vertex_buffer *VB )
 {
-    GLcontext           *ctx     = VB->ctx;
-    r128ContextPtr       r128ctx = R128_CONTEXT(ctx);
-    GLenum               prim    = ctx->CVA.elt_mode;
-    GLuint               nr      = VB->EltPtr->count;
-    render_func          func    = r128_render_tab_smooth_indirect[prim];
-    GLuint               p       = 0;
-
-    if (r128ctx->dirty) r128UpdateHWState(r128ctx);
-
-    do {
-	func(VB, 0, nr, 0);
-    } while (ctx->Driver.MultipassFunc &&
-	     ctx->Driver.MultipassFunc(VB, ++p));
+   GLcontext		*ctx = VB->ctx;
+   r128ContextPtr	r128ctx = R128_CONTEXT(ctx);
+   GLenum		prim = ctx->CVA.elt_mode;
+   GLuint		nr = VB->EltPtr->count;
+   render_func		func = r128_render_tab_smooth_indirect[prim];
+   GLuint		p = 0;
+
+   if ( r128ctx->new_state )
+      r128DDUpdateHWState( ctx );
+
+   do {
+      func( VB, 0, nr, 0 );
+   } while ( ctx->Driver.MultipassFunc &&
+	     ctx->Driver.MultipassFunc( VB, ++p ) );
 }
 
 /* Project vertices from clip to device space */
-static void r128ProjectVertices(struct vertex_buffer *VB)
+static void r128_project_vertices( struct vertex_buffer *VB )
 {
-    GLcontext           *ctx     = VB->ctx;
-    GLmatrix            *mat     = &ctx->Viewport.WindowMap;
-    r128ContextPtr       r128ctx = R128_CONTEXT(ctx);
-    r128VertexBufferPtr  r128VB  = R128_DRIVER_DATA(VB);
-    GLfloat              m[16];
-
-    m[MAT_SX] =  mat->m[MAT_SX];
-    m[MAT_TX] =  mat->m[MAT_TX];
-    m[MAT_SY] = -mat->m[MAT_SY];
-    m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h;
-    m[MAT_SZ] =  mat->m[MAT_SZ] * r128ctx->depth_scale;
-    m[MAT_TZ] =  mat->m[MAT_TZ] * r128ctx->depth_scale;
+   GLcontext           *ctx     = VB->ctx;
+   GLmatrix            *mat     = &ctx->Viewport.WindowMap;
+   r128ContextPtr       r128ctx = R128_CONTEXT(ctx);
+   r128VertexBufferPtr  r128VB  = R128_DRIVER_DATA(VB);
+
+   m[MAT_SX] =  mat->m[MAT_SX];
+   m[MAT_TX] =  mat->m[MAT_TX];
+   m[MAT_SY] = -mat->m[MAT_SY];
+   m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h;
+   m[MAT_SZ] =  mat->m[MAT_SZ] * r128ctx->depth_scale;
+   m[MAT_TZ] =  mat->m[MAT_TZ] * r128ctx->depth_scale;
 
-    gl_project_v16(r128VB->verts[VB->CopyStart].f,
+   gl_project_v16( r128VB->verts[VB->CopyStart].f,
 		   r128VB->verts[r128VB->last_vert].f,
 		   m,
-		   16 * 4);
+		   16 * 4 );
 }
 
 /* Project clipped vertices from clip to device space */
-static void r128ProjectClippedVertices(struct vertex_buffer *VB)
+static void r128_project_clipped_vertices( struct vertex_buffer *VB )
 {
-    GLcontext           *ctx     = VB->ctx;
-    GLmatrix            *mat     = &ctx->Viewport.WindowMap;
-    r128ContextPtr       r128ctx = R128_CONTEXT(ctx);
-    r128VertexBufferPtr  r128VB  = R128_DRIVER_DATA(VB);
-    GLfloat              m[16];
-
-    m[MAT_SX] =  mat->m[MAT_SX];
-    m[MAT_TX] =  mat->m[MAT_TX];
-    m[MAT_SY] = -mat->m[MAT_SY];
-    m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h;
-    m[MAT_SZ] =  mat->m[MAT_SZ] * r128ctx->depth_scale;
-    m[MAT_TZ] =  mat->m[MAT_TZ] * r128ctx->depth_scale;
+   GLcontext           *ctx     = VB->ctx;
+   GLmatrix            *mat     = &ctx->Viewport.WindowMap;
+   r128ContextPtr       r128ctx = R128_CONTEXT(ctx);
+   r128VertexBufferPtr  r128VB  = R128_DRIVER_DATA(VB);
+
+   m[MAT_SX] =  mat->m[MAT_SX];
+   m[MAT_TX] =  mat->m[MAT_TX];
+   m[MAT_SY] = -mat->m[MAT_SY];
+   m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h;
+   m[MAT_SZ] =  mat->m[MAT_SZ] * r128ctx->depth_scale;
+   m[MAT_TZ] =  mat->m[MAT_TZ] * r128ctx->depth_scale;
 
-    gl_project_clipped_v16(r128VB->verts[VB->CopyStart].f,
+   gl_project_clipped_v16( r128VB->verts[VB->CopyStart].f,
 			   r128VB->verts[r128VB->last_vert].f,
 			   m,
 			   16 * 4,
-			   VB->ClipMask + VB->CopyStart);
+			   VB->ClipMask + VB->CopyStart );
 }
 
-static r128FastPathTable r128FastTab[0x80];
+static struct r128_fast_tab r128FastTab[0x80];
 
 /* Initialize the table of fast path support functions */
-void r128FastPathInit(void)
+void r128DDFastPathInit( void )
 {
    r128_render_init_clip_elt();
    r128_render_init_smooth_indirect();
 
-   r128_init_fastpath(&r128FastTab[0]);
-   r128_init_fastpath_RGBA(&r128FastTab[R128_RGBA_BIT]);
-   r128_init_fastpath_TEX0(&r128FastTab[R128_TEX0_BIT]);
-   r128_init_fastpath_RGBA_TEX0(&r128FastTab[R128_RGBA_BIT|R128_TEX0_BIT]);
-   r128_init_fastpath_TEX0_TEX1(&r128FastTab[R128_TEX0_BIT|R128_TEX1_BIT]);
-   r128_init_fastpath_RGBA_TEX0_TEX1(&r128FastTab[R128_RGBA_BIT|R128_TEX0_BIT|
-						  R128_TEX1_BIT]);
+   r128_init_fastpath( &r128FastTab[0] );
+   r128_init_fastpath_RGBA( &r128FastTab[R128_RGBA_BIT] );
+   r128_init_fastpath_TEX0( &r128FastTab[R128_TEX0_BIT] );
+   r128_init_fastpath_RGBA_TEX0( &r128FastTab[R128_RGBA_BIT|R128_TEX0_BIT] );
+   r128_init_fastpath_TEX0_TEX1( &r128FastTab[R128_TEX0_BIT|R128_TEX1_BIT] );
+   r128_init_fastpath_RGBA_TEX0_TEX1( &r128FastTab[R128_RGBA_BIT|R128_TEX0_BIT|
+						   R128_TEX1_BIT] );
 }
 
 #define VALID_SETUP (R128_RGBA_BIT | R128_TEX0_BIT | R128_TEX1_BIT)
 
-void r128FastPath(struct vertex_buffer *VB)
+void r128DDFastPath( struct vertex_buffer *VB )
 {
-    GLcontext         *ctx  = VB->ctx;
-    GLenum             prim = ctx->CVA.elt_mode;
-    r128ContextPtr     r128ctx = R128_CONTEXT(ctx);
-    r128FastPathTable *tab  = &r128FastTab[r128ctx->SetupIndex & VALID_SETUP];
-    GLuint             do_cliptest = 1;
-
-    gl_prepare_arrays_cva(VB);   /* still need this */
-
-#if 0
-    if ((gl_reduce_prim[prim] == GL_TRIANGLES) &&
-	(VB->Count < (r128ctx->r128Screen->vbBufSize / 48)) &&
-	(ctx->ModelProjectMatrix.flags & (MAT_FLAG_GENERAL|
-					  MAT_FLAG_PERSPECTIVE)))
-    {
-	r128EltPath( VB );
-	return;
-    }
-#endif
-
-    /* Reserve enough space for the pathological case */
-    if (VB->EltPtr->count * 12 > R128_DRIVER_DATA(VB)->size) {
-	r128ResizeVB(VB, VB->EltPtr->count * 12);
-	do_cliptest = 1;
-    }
-
-    tab->build_vertices(VB, do_cliptest);         /* object->clip space */
-
-    if (r128ctx->dirty) r128UpdateHWState(r128ctx);
-
-    if (VB->ClipOrMask) {
-	if (!VB->ClipAndMask) {
-	    render_func *clip = r128_render_tab_clip_elt;
-
-	    r128ctx->interp = tab->interp;
-	    clip[prim](VB, 0, VB->EltPtr->count, 0); /* build new elts */
-	    ctx->CVA.elt_mode = gl_reduce_prim[prim];
-	    VB->EltPtr = &(R128_DRIVER_DATA(VB)->clipped_elements);
-	    r128ProjectClippedVertices(VB);    /* clip->device space */
-	    r128RenderElementsDirect(VB);      /* render using new list */
-	}
-    } else {
-	r128ProjectVertices(VB);               /* clip->device space  */
-	r128RenderElementsDirect(VB);          /* render using orig list */
-    }
-
-    /* This indicates that there is no cached data to reuse */
-    VB->pipeline->data_valid = 0;
-    VB->pipeline->new_state = 0;
+   GLcontext *ctx  = VB->ctx;
+   GLenum prim = ctx->CVA.elt_mode;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   struct r128_fast_tab *tab = &r128FastTab[r128ctx->SetupIndex & VALID_SETUP];
+   GLuint do_cliptest = 1;
+
+   gl_prepare_arrays_cva( VB );   /* still need this */
+
+   if ( ( gl_reduce_prim[prim] == GL_TRIANGLES ) &&
+	( VB->Count < (R128_BUFFER_SIZE / (10 * sizeof(GLuint))) ) &&
+	( ctx->ModelProjectMatrix.flags & (MAT_FLAG_GENERAL|
+					   MAT_FLAG_PERSPECTIVE) ) )
+   {
+      r128DDEltPath( VB );
+      return;
+   }
+
+   /* Reserve enough space for the pathological case */
+   if ( VB->EltPtr->count * 12 > R128_DRIVER_DATA(VB)->size ) {
+      r128DDResizeVB( VB, VB->EltPtr->count * 12 );
+      do_cliptest = 1;
+   }
+
+   tab->build_vertices( VB, do_cliptest );	/* object->clip space */
+
+   if ( r128ctx->new_state )
+      r128DDUpdateHWState( ctx );
+
+   if ( VB->ClipOrMask ) {
+      if ( !VB->ClipAndMask ) {
+	 render_func *clip = r128_render_tab_clip_elt;
+
+	 r128ctx->interp = tab->interp;
+
+	 clip[prim]( VB, 0, VB->EltPtr->count, 0 ); /* build new elts */
+
+	 ctx->CVA.elt_mode = gl_reduce_prim[prim];
+	 VB->EltPtr = &(R128_DRIVER_DATA(VB)->clipped_elements);
+
+	 r128_project_clipped_vertices( VB );	/* clip->device space */
+	 r128_render_elements_direct( VB );	/* render using new list */
+      }
+   } else {
+      r128_project_vertices( VB );		/* clip->device space  */
+      r128_render_elements_direct( VB );	/* render using orig list */
+   }
+
+   /* This indicates that there is no cached data to reuse */
+   VB->pipeline->data_valid = 0;
+   VB->pipeline->new_state = 0;
 }
Index: xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h:1.1	Fri Jun 16 20:03:05 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h	Mon Dec 18 14:23:36 2000
@@ -1,48 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_fastpath.h,v 1.1 2000/06/17 00:03:05 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas. 
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *
- */
-
-#ifndef _R128_FASTPATH_H_
-#define _R128_FASTPATH_H_
-
-typedef void (*r128BuildVerticesFunc)(struct vertex_buffer *VB,
-				      GLuint do_cliptest);
-typedef void (*r128InterpFunc)(GLfloat t,
-			       GLfloat *result,
-			       const GLfloat *in,
-			       const GLfloat *out);
-
-extern void r128FastPathInit(void);
-extern void r128FastPath(struct vertex_buffer *VB);
-
-#endif /* _R128_FASTPATH_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h:1.2
--- xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h:1.1	Fri Jun 16 20:03:05 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h	Mon Dec  4 14:21:46 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h,v 1.1 2000/06/17 00:03:05 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h,v 1.2 2000/12/04 19:21:46 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,7 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Keith Whitwell <keithw@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
@@ -181,7 +182,7 @@
 }
 
 
-static void TAG(r128_init_fastpath)(r128FastPathTable *tab)
+static void TAG(r128_init_fastpath)(struct r128_fast_tab *tab)
 {
    tab->build_vertices = TAG(r128_setup_full);
    tab->interp         = TAG(r128_interp_vert);
Index: xc/lib/GL/mesa/src/drv/r128/r128_init.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_init.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_init.h:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_init.h:1.1	Fri Jun 16 20:03:05 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_init.h	Mon Dec 18 14:23:36 2000
@@ -1,86 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_init.h,v 1.1 2000/06/17 00:03:05 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *
- */
-
-#ifndef _R128_INIT_H_
-#define _R128_INIT_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include <X11/Xlibint.h>
-
-#include "types.h"
-#include "xf86drm.h"
-#include "dri_tmm.h"
-#include "dri_mesaint.h"
-
-#include "r128_screen.h"
-#include "r128_context.h"
-
-#define DEBUG			1
-#define DEBUG_LOCKING		1
-#define ENABLE_PERF_BOXES	0
-
-
-#if DEBUG
-
-#include <stdio.h>
-#define R128_DEBUG(p)                                                       \
-    do {                                                                    \
-	printf p ;                                                          \
-	fflush(stdout);                                                     \
-    } while (0)
-
-extern int R128_DEBUG_FLAGS;
-
-#else
-
-#define R128_DEBUG_FLAGS            0
-
-#endif
-
-#define DEBUG_VERBOSE_2D            0x0001
-#define DEBUG_VERBOSE_CCE           0x0008
-#define DEBUG_VERBOSE_OUTREG        0x0010
-#define DEBUG_ALWAYS_SYNC           0x0040
-#define DEBUG_VERBOSE_MSG           0x0080
-#define DEBUG_NO_OUTRING            0x0100
-#define DEBUG_NO_OUTREG             0x0200
-#define DEBUG_VERBOSE_API           0x0400
-#define DEBUG_VALIDATE_RING         0x0800
-#define DEBUG_VERBOSE_LRU           0x1000
-#define DEBUG_VERBOSE_DRI           0x2000
-#define DEBUG_VERBOSE_IOCTL         0x4000
-
-#endif
-#endif /* _R128_INIT_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c:1.2
--- /dev/null	Mon Dec 18 14:23:36 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c	Tue Dec 12 12:17:07 2000
@@ -0,0 +1,766 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c,v 1.2 2000/12/12 17:17:07 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+                                               Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+on the rights to use, copy, modify, merge, publish, distribute, sub
+license, and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#include "r128_context.h"
+#include "r128_state.h"
+#include "r128_ioctl.h"
+
+#include "mem.h"
+
+#define R128_TIMEOUT        2000000
+
+
+/* =============================================================
+ * Hardware vertex buffer handling
+ */
+
+/* Get a new VB from the pool of vertex buffers in AGP space.
+ */
+drmBufPtr r128GetBufferLocked( r128ContextPtr r128ctx )
+{
+   int fd = r128ctx->r128Screen->driScreen->fd;
+   int index = 0;
+   int size = 0;
+   drmDMAReq dma;
+   drmBufPtr buf = NULL;
+   int to = 0;
+   int ret;
+
+   dma.context = r128ctx->hHWContext;
+   dma.send_count = 0;
+   dma.send_list = NULL;
+   dma.send_sizes = NULL;
+   dma.flags = 0;
+   dma.request_count = 1;
+   dma.request_size = R128_BUFFER_SIZE;
+   dma.request_list = &index;
+   dma.request_sizes = &size;
+   dma.granted_count = 0;
+
+   while ( !buf && ( to++ < r128ctx->CCEtimeout ) ) {
+      ret = drmDMA( fd, &dma );
+
+      if ( ret == 0 ) {
+	 buf = &r128ctx->r128Screen->buffers->list[index];
+	 buf->used = 0;
+#if ENABLE_PERF_BOXES
+	 /* Bump the performance counter */
+	 r128ctx->c_vertexBuffers++;
+#endif
+	 return buf;
+      }
+   }
+
+   if ( !buf ) {
+      drmR128EngineReset( fd );
+      fprintf( stderr, "Error: Could not get new VB... exiting\n" );
+      exit( -1 );
+   }
+
+   return buf;
+}
+
+void r128FlushVerticesLocked( r128ContextPtr r128ctx )
+{
+   XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+   int nbox = r128ctx->numClipRects;
+   drmBufPtr buffer = r128ctx->vert_buf;
+   int count = r128ctx->num_verts;
+   int prim = R128_TRIANGLES;
+   int fd = r128ctx->driScreen->fd;
+   int i;
+
+   if ( 0 )
+	fprintf( stderr, "%s: buf=%d count=%d\n",
+		 __FUNCTION__, buffer ? buffer->idx : -1, count );
+
+   r128ctx->num_verts = 0;
+   r128ctx->vert_buf = NULL;
+
+   if ( !buffer ) {
+      return;
+   }
+
+   if ( r128ctx->dirty & ~R128_UPLOAD_CLIPRECTS ) {
+      r128EmitHwStateLocked( r128ctx );
+   }
+
+   if ( !nbox ) {
+      count = 0;
+   }
+   if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+      r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+   }
+
+   if ( !count || !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+   {
+      if ( nbox < 3 ) {
+	 r128ctx->sarea->nbox = 0;
+      } else {
+	 r128ctx->sarea->nbox = nbox;
+      }
+
+      drmR128FlushVertexBuffer( fd, prim, buffer->idx, count, 1 );
+   }
+   else
+   {
+      for (i = 0 ; i < nbox ; ) {
+	 int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+	 XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+	 int discard = 0;
+
+	 r128ctx->sarea->nbox = nr - i;
+	 for ( ; i < nr ; i++) {
+	    *b++ = pbox[i];
+	 }
+
+	 /* Finished with the buffer?
+	  */
+	 if ( nr == nbox ) {
+	    discard = 1;
+	 }
+
+	 r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+	 drmR128FlushVertexBuffer( fd, prim, buffer->idx, count, discard );
+      }
+   }
+
+   r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+
+
+/* ================================================================
+ * Indexed vertex buffer handling
+ */
+
+void r128GetEltBufLocked( r128ContextPtr r128ctx )
+{
+   r128ctx->elt_buf = r128GetBufferLocked( r128ctx );
+}
+
+void r128FireEltsLocked( r128ContextPtr r128ctx,
+			 GLuint start, GLuint end,
+			 GLuint discard )
+{
+   XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+   int nbox = r128ctx->numClipRects;
+   drmBufPtr buffer = r128ctx->elt_buf;
+   int prim = R128_TRIANGLES;
+   int fd = r128ctx->driScreen->fd;
+   int i;
+
+   if ( 0 )
+	fprintf( stderr, "%s: start=%d end=%d discard=%d\n",
+		 __FUNCTION__, start, end, discard );
+
+   if ( !buffer ) {
+      return;
+   }
+
+   if ( r128ctx->dirty & ~R128_UPLOAD_CLIPRECTS ) {
+      r128EmitHwStateLocked( r128ctx );
+   }
+
+   if ( !nbox ) {
+      end = start;
+   }
+   if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+      r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+   }
+
+   if ( start == end || !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+   {
+      if ( nbox < 3 ) {
+	 r128ctx->sarea->nbox = 0;
+      } else {
+	 r128ctx->sarea->nbox = nbox;
+      }
+
+      drmR128FlushIndices( fd, prim, buffer->idx, start, end, discard );
+   }
+   else
+   {
+      for (i = 0 ; i < nbox ; ) {
+	 int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+	 XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+	 int d = 0;
+
+	 r128ctx->sarea->nbox = nr - i;
+	 for ( ; i < nr ; i++) {
+	    *b++ = pbox[i];
+	 }
+
+	 /* Finished with the buffer?
+	  */
+	 if ( nr == nbox ) {
+	    d = discard;
+	 }
+
+	 r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+	 drmR128FlushIndices( fd, prim, buffer->idx, start, end, discard );
+      }
+   }
+
+   if ( R128_DEBUG & DEBUG_ALWAYS_SYNC ) {
+      drmR128WaitForIdleCCE( r128ctx->driFd );
+   }
+
+   r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128FlushEltsLocked( r128ContextPtr r128ctx )
+{
+   if ( r128ctx->first_elt != r128ctx->next_elt ) {
+      r128FireEltsLocked( r128ctx,
+			  ((GLuint)r128ctx->first_elt -
+			   (GLuint)r128ctx->elt_buf->address),
+			  ((GLuint)r128ctx->next_elt -
+			   (GLuint)r128ctx->elt_buf->address),
+			  0 );
+
+      ALIGN_NEXT_ELT( r128ctx );
+      r128ctx->first_elt = r128ctx->next_elt;
+   }
+}
+
+void r128ReleaseBufLocked( r128ContextPtr r128ctx, drmBufPtr buffer )
+{
+   int fd = r128ctx->driScreen->fd;
+
+   if ( 0 )
+	fprintf( stderr, "%s: buffer=%p\n",
+		 __FUNCTION__, buffer );
+
+   if ( !buffer ) {
+      return;
+   }
+   drmR128FlushVertexBuffer( fd, R128_TRIANGLES, buffer->idx, 0, 1 );
+}
+
+
+/* Allocate some space in the current vertex buffer.  If the current
+ * buffer is full, flush it and grab another one.
+ */
+CARD32 *r128AllocVertices( r128ContextPtr r128ctx, int count )
+{
+   return r128AllocVerticesInline( r128ctx, count );
+}
+
+
+
+/* ================================================================
+ * Texture uploads
+ */
+
+void r128FireBlitLocked( r128ContextPtr r128ctx, drmBufPtr buffer,
+			 GLint offset, GLint pitch, GLint format,
+			 GLint x, GLint y, GLint width, GLint height )
+{
+   GLint ret;
+
+   ret = drmR128TextureBlit( r128ctx->driFd, buffer->idx,
+			     offset, pitch, format,
+			     x, y, width, height );
+
+   if ( ret ) {
+      fprintf( stderr, "drmR128TextureBlit: return = %d\n", ret );
+      exit( 1 );
+   }
+}
+
+
+/* ================================================================
+ * SwapBuffers with client-side throttling
+ */
+
+static void delay( void ) {
+/* Prevent an optimizing compiler from removing a spin loop */
+}
+
+#define R128_MAX_OUTSTANDING	2
+
+/* Throttle the frame rate -- only allow one pending swap buffers
+ * request at a time.
+ * GH: We probably don't want a timeout here, as we can wait as
+ * long as we want for a frame to complete.  If it never does, then
+ * the card has locked.
+ */
+static int r128WaitForFrameCompletion( r128ContextPtr r128ctx )
+{
+   unsigned char *R128MMIO = r128ctx->r128Screen->mmio;
+   CARD32 frame;
+   int i;
+   int wait = 0;
+
+   while ( 1 ) {
+      frame = INREG( R128_LAST_FRAME_REG );
+      if ( r128ctx->sarea->last_frame - frame <= R128_MAX_OUTSTANDING ) {
+	 break;
+      }
+
+      /* Spin in place a bit so we aren't hammering the register */
+      wait++;
+      for ( i = 0 ; i < 1024 ; i++ ) {
+	 delay();
+      }
+   }
+
+   return wait;
+}
+
+/* Copy the back color buffer to the front color buffer */
+void r128SwapBuffers( r128ContextPtr r128ctx )
+{
+   GLint nbox = r128ctx->numClipRects;
+   GLint i;
+   GLint ret;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "\n********************************\n" );
+      fprintf( stderr, "\n%s( %p )\n\n",
+	       __FUNCTION__, r128ctx->glCtx );
+      fflush( stderr );
+   }
+
+   /* Flush any outstanding vertex buffers */
+   FLUSH_BATCH( r128ctx );
+
+   LOCK_HARDWARE( r128ctx );
+
+   /* Throttle the frame rate -- only allow one pending swap buffers
+    * request at a time.
+    */
+   if ( !r128WaitForFrameCompletion( r128ctx ) ) {
+      r128ctx->hardwareWentIdle = 1;
+   } else {
+      r128ctx->hardwareWentIdle = 0;
+   }
+
+   for ( i = 0 ; i < nbox ; ) {
+      GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , nbox );
+      XF86DRIClipRectPtr box = r128ctx->pClipRects;
+      XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+      GLint n = 0;
+
+      for ( ; i < nr ; i++ ) {
+	 *b++ = *(XF86DRIClipRectRec *)&box[i];
+	 n++;
+      }
+      r128ctx->sarea->nbox = n;
+
+      ret = drmR128SwapBuffers( r128ctx->driFd );
+
+      if ( ret ) {
+	 fprintf( stderr, "drmR128SwapBuffers: return = %d\n", ret );
+	 exit( 1 );
+      }
+   }
+
+   if ( R128_DEBUG & DEBUG_ALWAYS_SYNC ) {
+      drmR128WaitForIdleCCE( r128ctx->driFd );
+   }
+
+   UNLOCK_HARDWARE( r128ctx );
+
+   r128ctx->new_state |= R128_NEW_CONTEXT;
+   r128ctx->dirty |= (R128_UPLOAD_CONTEXT |
+		      R128_UPLOAD_MASKS |
+		      R128_UPLOAD_CLIPRECTS);
+
+#if ENABLE_PERF_BOXES
+   /* Log the performance counters if necessary */
+   r128PerformanceCounters( r128ctx );
+#endif
+}
+
+
+/* ================================================================
+ * Buffer clear
+ */
+
+static GLbitfield r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+			       GLint cx, GLint cy, GLint cw, GLint ch )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;
+   GLuint flags = 0;
+   GLint i;
+   GLint ret;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s:\n", __FUNCTION__ );
+   }
+
+   FLUSH_BATCH( r128ctx );
+
+   /* Update and emit any new state.  We need to do this here to catch
+    * changes to the masks.
+    * FIXME: Just update the masks?
+    */
+   if ( r128ctx->new_state )
+      r128DDUpdateHWState( ctx );
+
+   if ( mask & DD_FRONT_LEFT_BIT ) {
+      flags |= DRM_R128_FRONT;
+      mask &= ~DD_FRONT_LEFT_BIT;
+   }
+
+   if ( mask & DD_BACK_LEFT_BIT ) {
+      flags |= DRM_R128_BACK;
+      mask &= ~DD_BACK_LEFT_BIT;
+   }
+
+   if ( ( mask & DD_DEPTH_BIT ) && ctx->Depth.Mask ) {
+      flags |= DRM_R128_DEPTH;
+      mask &= ~DD_DEPTH_BIT;
+   }
+#if 0
+   /* FIXME: Add stencil support */
+   if ( mask & DD_STENCIL_BIT ) {
+      flags |= DRM_R128_DEPTH;
+      mask &= ~DD_STENCIL_BIT;
+   }
+#endif
+
+   if ( !flags ) {
+      return mask;
+   }
+
+   /* Flip top to bottom */
+   cx += dPriv->x;
+   cy  = dPriv->y + dPriv->h - cy - ch;
+
+   LOCK_HARDWARE( r128ctx );
+
+   if ( r128ctx->dirty & ~R128_UPLOAD_CLIPRECTS ) {
+      r128EmitHwStateLocked( r128ctx );
+   }
+
+   for ( i = 0 ; i < r128ctx->numClipRects ; ) {
+      GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , r128ctx->numClipRects );
+      XF86DRIClipRectPtr box = r128ctx->pClipRects;
+      XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+      GLint n = 0;
+
+      if ( !all ) {
+	 for ( ; i < nr ; i++ ) {
+	    GLint x = box[i].x1;
+	    GLint y = box[i].y1;
+	    GLint w = box[i].x2 - x;
+	    GLint h = box[i].y2 - y;
+
+	    if ( x < cx ) w -= cx - x, x = cx;
+	    if ( y < cy ) h -= cy - y, y = cy;
+	    if ( x + w > cx + cw ) w = cx + cw - x;
+	    if ( y + h > cy + ch ) h = cy + ch - y;
+	    if ( w <= 0 ) continue;
+	    if ( h <= 0 ) continue;
+
+	    b->x1 = x;
+	    b->y1 = y;
+	    b->x2 = x + w;
+	    b->y2 = y + h;
+	    b++;
+	    n++;
+	 }
+      } else {
+	 for ( ; i < nr ; i++ ) {
+	    *b++ = *(XF86DRIClipRectRec *)&box[i];
+	    n++;
+	 }
+      }
+
+      r128ctx->sarea->nbox = n;
+
+      if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) {
+	 fprintf( stderr,
+		  "drmR128Clear: flag 0x%x color %x depth %x nbox %d\n",
+		  flags,
+		  (GLuint)r128ctx->ClearColor,
+		  (GLuint)r128ctx->ClearDepth,
+		  r128ctx->sarea->nbox );
+      }
+
+      ret = drmR128Clear( r128ctx->driFd, flags,
+			  cx, cy, cw, ch,
+			  r128ctx->ClearColor, r128ctx->ClearDepth );
+
+      if ( ret ) {
+	 fprintf( stderr, "drmR128Clear: return = %d\n", ret );
+	 exit( 1 );
+      }
+   }
+
+   UNLOCK_HARDWARE( r128ctx );
+
+   r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+
+   return mask;
+}
+
+
+/* ================================================================
+ * Depth spans, pixels
+ */
+
+void r128WriteDepthSpanLocked( r128ContextPtr r128ctx,
+			       GLuint n, GLint x, GLint y,
+			       const GLdepth depth[],
+			       const GLubyte mask[] )
+{
+   XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+   int nbox = r128ctx->numClipRects;
+   int fd = r128ctx->driScreen->fd;
+   int i;
+
+   if ( !nbox || !n ) {
+      return;
+   }
+   if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+      r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+   }
+
+   if ( !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+   {
+      if ( nbox < 3 ) {
+	 r128ctx->sarea->nbox = 0;
+      } else {
+	 r128ctx->sarea->nbox = nbox;
+      }
+
+      drmR128WriteDepthSpan( fd, n, x, y, depth, mask );
+   }
+   else
+   {
+      for (i = 0 ; i < nbox ; ) {
+	 int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+	 XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+
+	 r128ctx->sarea->nbox = nr - i;
+	 for ( ; i < nr ; i++) {
+	    *b++ = pbox[i];
+	 }
+
+	 r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+	 drmR128WriteDepthSpan( fd, n, x, y, depth, mask );
+      }
+   }
+
+   r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128WriteDepthPixelsLocked( r128ContextPtr r128ctx, GLuint n,
+				 const GLint x[], const GLint y[],
+				 const GLdepth depth[],
+				 const GLubyte mask[] )
+{
+   XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+   int nbox = r128ctx->numClipRects;
+   int fd = r128ctx->driScreen->fd;
+   int i;
+
+   if ( !nbox || !n ) {
+      return;
+   }
+   if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+      r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+   }
+
+   if ( !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+   {
+      if ( nbox < 3 ) {
+	 r128ctx->sarea->nbox = 0;
+      } else {
+	 r128ctx->sarea->nbox = nbox;
+      }
+
+      drmR128WriteDepthPixels( fd, n, x, y, depth, mask );
+   }
+   else
+   {
+      for (i = 0 ; i < nbox ; ) {
+	 int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+	 XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+
+	 r128ctx->sarea->nbox = nr - i;
+	 for ( ; i < nr ; i++) {
+	    *b++ = pbox[i];
+	 }
+
+	 r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+	 drmR128WriteDepthPixels( fd, n, x, y, depth, mask );
+      }
+   }
+
+   r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128ReadDepthSpanLocked( r128ContextPtr r128ctx,
+			      GLuint n, GLint x, GLint y )
+{
+   XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+   int nbox = r128ctx->numClipRects;
+   int fd = r128ctx->driScreen->fd;
+   int i;
+
+   if ( !nbox || !n ) {
+      return;
+   }
+   if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+      r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+   }
+
+   if ( !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+   {
+      if ( nbox < 3 ) {
+	 r128ctx->sarea->nbox = 0;
+      } else {
+	 r128ctx->sarea->nbox = nbox;
+      }
+
+      drmR128ReadDepthSpan( fd, n, x, y );
+   }
+   else
+   {
+      for (i = 0 ; i < nbox ; ) {
+	 int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+	 XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+
+	 r128ctx->sarea->nbox = nr - i;
+	 for ( ; i < nr ; i++) {
+	    *b++ = pbox[i];
+	 }
+
+	 r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+	 drmR128ReadDepthSpan( fd, n, x, y );
+      }
+   }
+
+   r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128ReadDepthPixelsLocked( r128ContextPtr r128ctx, GLuint n,
+				const GLint x[], const GLint y[] )
+{
+   XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+   int nbox = r128ctx->numClipRects;
+   int fd = r128ctx->driScreen->fd;
+   int i;
+
+   if ( !nbox || !n ) {
+      return;
+   }
+   if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+      r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+   }
+
+   if ( !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+   {
+      if ( nbox < 3 ) {
+	 r128ctx->sarea->nbox = 0;
+      } else {
+	 r128ctx->sarea->nbox = nbox;
+      }
+
+      drmR128ReadDepthPixels( fd, n, x, y );
+   }
+   else
+   {
+      for (i = 0 ; i < nbox ; ) {
+	 int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+	 XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+
+	 r128ctx->sarea->nbox = nr - i;
+	 for ( ; i < nr ; i++) {
+	    *b++ = pbox[i];
+	 }
+
+	 r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+	 drmR128ReadDepthPixels( fd, n, x, y );
+      }
+   }
+
+   r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+
+/* ================================================================
+ * Deprecated function...
+ */
+void r128SubmitPacketLocked( r128ContextPtr r128ctx,
+			     CARD32 *buf, GLuint count )
+{
+   CARD32 *b;
+   int c = count;
+   int fd = r128ctx->r128Screen->driScreen->fd;
+   int to = 0;
+   int ret;
+
+   do {
+      b = buf + (count - c);
+      ret = drmR128SubmitPacket( fd, b, &c, 0 );
+   } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) );
+
+   if ( ret < 0 ) {
+      drmR128EngineReset( fd );
+      fprintf( stderr, "Error: Could not submit packet... exiting\n" );
+      exit( -1 );
+   }
+}
+
+
+
+void r128WaitForIdleLocked( r128ContextPtr r128ctx )
+{
+    int fd = r128ctx->r128Screen->driScreen->fd;
+    int to = 0;
+    int ret;
+
+    do {
+	ret = drmR128WaitForIdleCCE( fd );
+    } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) );
+
+    if ( ret < 0 ) {
+	drmR128EngineReset( fd );
+	fprintf( stderr, "Error: Rage 128 timed out... exiting\n" );
+	exit( -1 );
+    }
+}
+
+
+void r128DDInitIoctlFuncs( GLcontext *ctx )
+{
+    ctx->Driver.Clear	= r128DDClear;
+}
Index: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h:1.1
--- /dev/null	Mon Dec 18 14:23:36 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h	Mon Dec  4 14:21:46 2000
@@ -0,0 +1,217 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h,v 1.1 2000/12/04 19:21:46 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+                                               Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+on the rights to use, copy, modify, merge, publish, distribute, sub
+license, and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __R128_IOCTL_H__
+#define __R128_IOCTL_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "r128_dri.h"
+#include "r128_reg.h"
+#include "r128_lock.h"
+
+#include "xf86drm.h"
+#include "xf86drmR128.h"
+
+#define R128_DEFAULT_TOTAL_CCE_TIMEOUT 1000000 /* usecs */
+
+#define R128_BUFFER_MAX_DWORDS	(R128_BUFFER_SIZE / sizeof(CARD32))
+
+
+#define FLUSH_BATCH( r128ctx )						\
+do {									\
+   if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL )				\
+      fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ );		\
+   if ( r128ctx->vert_buf ) {						\
+      r128FlushVertices( r128ctx );					\
+   } else if ( r128ctx->next_elt != r128ctx->first_elt ) {		\
+      r128FlushElts( r128ctx );						\
+   }									\
+} while (0)
+
+#define r128FlushVertices( r128ctx )		\
+do {						\
+   LOCK_HARDWARE( r128ctx );			\
+   r128FlushVerticesLocked( r128ctx );		\
+   UNLOCK_HARDWARE( r128ctx );			\
+} while (0)
+
+
+extern drmBufPtr r128GetBufferLocked( r128ContextPtr r128ctx );
+extern void r128FlushVerticesLocked( r128ContextPtr r128ctx );
+
+
+#define r128FlushElts( r128ctx )		\
+do {						\
+   LOCK_HARDWARE( r128ctx );			\
+   r128FlushEltsLocked( r128ctx );		\
+   UNLOCK_HARDWARE( r128ctx );			\
+} while (0)
+
+extern void r128GetEltBufLocked( r128ContextPtr r128ctx );
+extern void r128FlushEltsLocked( r128ContextPtr r128ctx );
+extern void r128FireEltsLocked( r128ContextPtr r128ctx,
+				GLuint start, GLuint end,
+				GLuint discard );
+extern void r128ReleaseBufLocked( r128ContextPtr r128ctx, drmBufPtr buffer );
+
+
+/* 64-bit align the next element address, and then make room for the
+ * next indexed prim packet header.
+ */
+#define ALIGN_NEXT_ELT( r128ctx )					\
+do {									\
+   r128ctx->next_elt = (GLushort *)					\
+      (((GLuint)r128ctx->next_elt + 7) & ~0x7);				\
+   r128ctx->next_elt = (GLushort *)					\
+      ((GLubyte *)r128ctx->next_elt + R128_INDEX_PRIM_OFFSET);		\
+} while (0)
+
+
+/* Make this available as both a regular and an inline function.
+ */
+extern CARD32 *r128AllocVertices( r128ContextPtr r128ctx, int count );
+
+static __inline CARD32 *r128AllocVerticesInline( r128ContextPtr r128ctx,
+						 int count )
+{
+    int bytes = count * r128ctx->vertsize * sizeof(CARD32);
+    CARD32 *head;
+
+    if ( !r128ctx->vert_buf ) {
+	LOCK_HARDWARE( r128ctx );
+
+	if ( r128ctx->first_elt != r128ctx->next_elt ) {
+	    r128FlushEltsLocked( r128ctx );
+	}
+
+	r128ctx->vert_buf = r128GetBufferLocked( r128ctx );
+
+	UNLOCK_HARDWARE( r128ctx );
+    } else if ( r128ctx->vert_buf->used + bytes > r128ctx->vert_buf->total ) {
+	LOCK_HARDWARE( r128ctx );
+
+	r128FlushVerticesLocked( r128ctx );
+	r128ctx->vert_buf = r128GetBufferLocked( r128ctx );
+
+	UNLOCK_HARDWARE( r128ctx );
+    }
+
+    head = (CARD32 *)((char *)r128ctx->vert_buf->address +
+		      r128ctx->vert_buf->used);
+
+    r128ctx->num_verts += count;
+    r128ctx->vert_buf->used += bytes;
+    return head;
+}
+
+
+extern void r128FireBlitLocked( r128ContextPtr r128ctx, drmBufPtr buffer,
+				GLint offset, GLint pitch, GLint format,
+				GLint x, GLint y, GLint width, GLint height );
+
+
+extern void r128WriteDepthSpanLocked( r128ContextPtr r128ctx,
+				      GLuint n, GLint x, GLint y,
+				      const GLdepth depth[],
+				      const GLubyte mask[] );
+extern void r128WriteDepthPixelsLocked( r128ContextPtr r128ctx, GLuint n,
+					const GLint x[], const GLint y[],
+					const GLdepth depth[],
+					const GLubyte mask[] );
+extern void r128ReadDepthSpanLocked( r128ContextPtr r128ctx,
+				     GLuint n, GLint x, GLint y );
+extern void r128ReadDepthPixelsLocked( r128ContextPtr r128ctx, GLuint n,
+				       const GLint x[], const GLint y[] );
+
+
+extern void r128SwapBuffers( r128ContextPtr r128ctx );
+
+
+#define r128WaitForIdle( r128ctx )		\
+do {						\
+   LOCK_HARDWARE( r128ctx );			\
+   r128WaitForIdleLocked( r128ctx );		\
+   UNLOCK_HARDWARE( r128ctx );			\
+} while (0)
+
+extern void r128WaitForIdleLocked( r128ContextPtr r128ctx );
+
+
+extern void r128DDInitIoctlFuncs( GLcontext *ctx );
+
+
+
+/* ================================================================
+ * Deprecated functions:
+ */
+
+typedef union {
+    float f;
+    int   i;
+} floatTOint;
+
+/* Insert an integer value into the CCE ring buffer. */
+#define R128CCE(v)				\
+do {						\
+   r128ctx->CCEbuf[r128ctx->CCEcount] = (v);	\
+   r128ctx->CCEcount++;				\
+} while (0)
+
+/* Insert an floating point value into the CCE ring buffer. */
+#define R128CCEF(v)				\
+do {						\
+   floatTOint fTi;				\
+   fTi.f = (v);					\
+   r128ctx->CCEbuf[r128ctx->CCEcount] = fTi.i;	\
+   r128ctx->CCEcount++;				\
+} while (0)
+
+/* Insert a type-[0123] packet header into the ring buffer */
+#define R128CCE0(p,r,n)   R128CCE((p) | ((n) << 16) | ((r) >> 2))
+#define R128CCE1(p,r1,r2) R128CCE((p) | (((r2) >> 2) << 11) | ((r1) >> 2))
+#define R128CCE2(p)       R128CCE((p))
+#define R128CCE3(p,n)     R128CCE((p) | ((n) << 16))
+
+#define R128CCE_SUBMIT_PACKET()						  \
+do {									  \
+   r128SubmitPacketLocked( r128ctx, r128ctx->CCEbuf, r128ctx->CCEcount ); \
+   r128ctx->CCEcount = 0;						  \
+} while (0)
+
+extern void r128SubmitPacketLocked( r128ContextPtr r128ctx,
+				    CARD32 *buf, GLuint count );
+
+#endif
+#endif /* __R128_IOCTL_H__ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_lock.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/r128/r128_lock.c:1.1
--- /dev/null	Mon Dec 18 14:23:36 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_lock.c	Mon Dec  4 14:21:46 2000
@@ -0,0 +1,93 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_lock.c,v 1.1 2000/12/04 19:21:46 dawes Exp $ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+                                               Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+on the rights to use, copy, modify, merge, publish, distribute, sub
+license, and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#include "r128_context.h"
+#include "r128_lock.h"
+#include "r128_tex.h"
+
+#if DEBUG_LOCKING
+char *prevLockFile = NULL;
+int   prevLockLine = 0;
+#endif
+
+
+/* Update the hardware state.  This is called if another context has
+ * grabbed the hardware lock, which includes the X server.  This
+ * function also updates the driver's window state after the X server
+ * moves, resizes or restacks a window -- the change will be reflected
+ * in the drawable position and clip rects.  Since the X server grabs
+ * the hardware lock when it changes the window state, this routine will
+ * automatically be called after such a change.
+ */
+void r128GetLock( r128ContextPtr r128ctx, GLuint flags )
+{
+   __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;
+   __DRIscreenPrivate *sPriv = r128ctx->driScreen;
+   R128SAREAPriv *sarea = r128ctx->sarea;
+   int stamp = dPriv->lastStamp;
+   int i;
+
+   drmGetLock( r128ctx->driFd, r128ctx->hHWContext, flags );
+
+   /* The window might have moved, so we might need to get new clip
+    * rects.
+    *
+    * NOTE: This releases and regrabs the hw lock to allow the X server
+    * to respond to the DRI protocol request for new drawable info.
+    * Since the hardware state depends on having the latest drawable
+    * clip rects, all state checking must be done _after_ this call.
+    */
+   XMESA_VALIDATE_DRAWABLE_INFO( r128ctx->display, sPriv, dPriv );
+
+   if ( stamp != dPriv->lastStamp ) {
+      r128ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
+      r128ctx->SetupDone = 0;
+   }
+
+   r128ctx->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_CLIPRECTS;
+
+   r128ctx->numClipRects = dPriv->numClipRects;
+   r128ctx->pClipRects = dPriv->pClipRects;
+
+   if ( sarea->ctxOwner != r128ctx->hHWContext ) {
+      sarea->ctxOwner = r128ctx->hHWContext;
+      r128ctx->dirty = R128_UPLOAD_ALL;
+   }
+
+   for ( i = 0 ; i < r128ctx->lastTexHeap ; i++ ) {
+      if ( sarea->texAge[i] != r128ctx->lastTexAge[i] ) {
+	 r128AgeTextures( r128ctx, i );
+      }
+   }
+}
Index: xc/lib/GL/mesa/src/drv/r128/r128_lock.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_lock.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_lock.h:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_lock.h:1.1	Fri Jun 16 20:03:06 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_lock.h	Thu Dec  7 10:43:37 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_lock.h,v 1.1 2000/06/17 00:03:06 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_lock.h,v 1.3 2000/12/07 15:43:37 tsi Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,7 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
@@ -37,8 +38,11 @@
 
 #ifdef GLX_DIRECT_RENDERING
 
+extern void r128GetLock( r128ContextPtr r128ctx, GLuint flags );
+
+
 /* Turn DEBUG_LOCKING on to find locking conflicts (see r128_init.h) */
-#if DEBUG_LOCKING
+#ifdef DEBUG_LOCKING
 extern char *prevLockFile;
 extern int   prevLockLine;
 
@@ -78,57 +82,28 @@
  * do not do any drawing !!!
  */
 
-/* Lock the hardware using the current context */
-#define LOCK_HARDWARE(CC)                                               \
-    do {                                                                \
-	char                  __ret = 0;                                \
-	__DRIcontextPrivate  *cPriv = CC->driContext;                   \
-	__DRIscreenPrivate   *sPriv = CC->r128Screen->driScreen;        \
-                                                                        \
-	DEBUG_CHECK_LOCK();                                             \
-	DRM_CAS(&sPriv->pSAREA->lock, cPriv->hHWContext,                \
-		DRM_LOCK_HELD|cPriv->hHWContext, __ret);                \
-	if (__ret) {                                                    \
-	    /* We lost the context, so we need to request the lock from \
-               the kernel and update our state. */                      \
-	    drmGetLock(sPriv->fd, cPriv->hHWContext, 0);                \
-	    XMesaUpdateState(cPriv);                                    \
-	}                                                               \
-	DEBUG_LOCK();                                                   \
-    } while (0)
-
-/* Unlock the hardware using the current context */
-#define UNLOCK_HARDWARE(CC)                                             \
-    do {                                                                \
-	__DRIcontextPrivate  *cPriv = CC->driContext;                   \
-	__DRIscreenPrivate   *sPriv = CC->r128Screen->driScreen;        \
-                                                                        \
-	DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, cPriv->hHWContext); \
-	DEBUG_RESET();                                                  \
-    } while (0)
+/* Lock the hardware and validate our state.
+ */
+#define LOCK_HARDWARE( r128ctx )					\
+   do {									\
+      char __ret = 0;							\
+      DEBUG_CHECK_LOCK();						\
+      DRM_CAS( r128ctx->driHwLock, r128ctx->hHWContext,			\
+	       (DRM_LOCK_HELD | r128ctx->hHWContext), __ret );		\
+      if ( __ret )							\
+	 r128GetLock( r128ctx, 0 );					\
+      DEBUG_LOCK();							\
+   } while (0)
 
-/*
- * This pair of macros makes a loop over the drawing operations, so it
- * is not self contained and does not have the nice single statement
- * semantics of most macros.
+/* Unlock the hardware.
  */
-#define BEGIN_CLIP_LOOP(CC)                                             \
-    do {                                                                \
-	__DRIdrawablePrivate *_dPriv = CC->driDrawable;                 \
-	XF86DRIClipRectPtr    _pc = _dPriv->pClipRects;                 \
-	int                   _nc, _sc;                                 \
-                                                                        \
-	for (_nc = _dPriv->numClipRects; _nc > 0; _nc -= 3, _pc += 3) { \
-	    _sc = (_nc <= 3) ? _nc : 3;                                 \
-	    r128SetClipRects(CC, _pc, _sc)
-
-/* FIXME: This should be a function call to turn off aux clipping */
-#define END_CLIP_LOOP(CC)                                               \
-	    R128CCE0(R128_CCE_PACKET0, R128_AUX_SC_CNTL, 0);            \
-	    R128CCE(0x00000000);                                        \
-	    R128CCE_SUBMIT_PACKET();                                    \
-	}                                                               \
-    } while (0)
+#define UNLOCK_HARDWARE( r128ctx )					\
+   do {									\
+      DRM_UNLOCK( r128ctx->driFd,					\
+		  r128ctx->driHwLock,					\
+		  r128ctx->hHWContext );				\
+      DEBUG_RESET();							\
+   } while (0)
 
 #endif
 #endif /* _R128_LOCK_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_mesa.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_mesa.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_mesa.h:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_mesa.h:1.1	Fri Jun 16 20:03:06 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_mesa.h	Mon Dec 18 14:23:36 2000
@@ -1,43 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_mesa.h,v 1.1 2000/06/17 00:03:06 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas. 
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *
- */
-
-#ifndef _R128_MESA_H_
-#define _R128_MESA_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-#define R128_CONTEXT(ctx) ((r128ContextPtr)(ctx->DriverCtx))
-
-#endif
-#endif /* _R128_MESA_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c:1.1 xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c:1.1	Fri Jun 16 20:03:06 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c	Mon Dec  4 14:21:46 2000
@@ -1,8 +1,8 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c,v 1.1 2000/06/17 00:03:06 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c,v 1.3 2000/12/04 19:21:46 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas. 
+                                               Cedar Park, Texas.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,96 +28,141 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
-#include "r128_init.h"
-#include "r128_mesa.h"
+#include "r128_context.h"
 #include "r128_vb.h"
-#include "r128_fastpath.h"
 #include "r128_pipeline.h"
 
 #include "types.h"
+#include "fog.h"
 
-static struct gl_pipeline_stage r128FastStage = {
-    "R128 Fast Path",
-    (PIPE_OP_VERT_XFORM   |
-     PIPE_OP_RAST_SETUP_0 |
-     PIPE_OP_RAST_SETUP_1 |
-     PIPE_OP_RENDER),
-    PIPE_PRECALC,
-    0, 0, 0, 0, 0, 0, 0, 0, 0,   
-    r128FastPath
+static struct gl_pipeline_stage r128_fast_stage = {
+   "R128 Fast Path",
+   (PIPE_OP_VERT_XFORM |
+    PIPE_OP_RAST_SETUP_0 |
+    PIPE_OP_RAST_SETUP_1 |
+    PIPE_OP_RENDER),
+   PIPE_PRECALC,
+   0, 0, 0, 0, 0, 0, 0, 0, 0,
+   r128DDFastPath
 };
 
+#define ILLEGAL_ENABLES (TEXTURE0_3D |		\
+			 TEXTURE1_3D |		\
+			 ENABLE_TEXMAT0 |	\
+			 ENABLE_TEXMAT1 |	\
+			 ENABLE_TEXGEN0 |	\
+			 ENABLE_TEXGEN1 |	\
+			 ENABLE_USERCLIP |	\
+			 ENABLE_LIGHT |		\
+			 ENABLE_FOG)
+
 /* Build the PRECALC pipeline with our stage, if possible.  Otherwise,
-   return GL_FALSE */
-GLboolean r128DDBuildPrecalcPipeline(GLcontext *ctx)
+ * return GL_FALSE.
+ */
+GLboolean r128DDBuildPrecalcPipeline( GLcontext *ctx )
 {
-    r128ContextPtr      r128ctx = R128_CONTEXT(ctx);
-    struct gl_pipeline *pipe    = &ctx->CVA.pre;
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   struct gl_pipeline *pipe = &ctx->CVA.pre;
 
-    if (r128ctx->RenderIndex == 0 &&
-	!(ctx->Enabled & (TEXTURE0_3D     |
-			  TEXTURE1_3D     |
-			  ENABLE_TEXMAT0  |
-			  ENABLE_TEXMAT1  |
-			  ENABLE_TEXGEN0  |
-			  ENABLE_TEXGEN1  |
-			  ENABLE_USERCLIP |
-			  ENABLE_LIGHT    |
-			  ENABLE_FOG)) &&
+   if ( r128ctx->RenderIndex == 0 &&
+	(ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
 	(ctx->Array.Flags & (VERT_OBJ_234 |
 			     VERT_TEX0_4  |
 			     VERT_TEX1_4  |
-			     VERT_ELT)) == (VERT_OBJ_23 |
-					    VERT_ELT)) {
-	pipe->stages[0]  = &r128FastStage;
-	pipe->stages[1]  = 0;
-	pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
-	pipe->ops        = pipe->stages[0]->ops;
-
-	r128ctx->useFastPath = GL_TRUE;
-	return GL_TRUE;
-    }
-
-    if (r128ctx->useFastPath) {
-	r128ctx->useFastPath = GL_FALSE;
-
-	ctx->CVA.VB->ClipOrMask   = 0;
-	ctx->CVA.VB->ClipAndMask  = CLIP_ALL_BITS;
-	ctx->Array.NewArrayState |= ctx->Array.Summary;
-    }
+			     VERT_ELT)) == (VERT_OBJ_23 | VERT_ELT) )
+   {
+      pipe->stages[0]  = &r128_fast_stage;
+      pipe->stages[1]  = 0;
+      pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
+      pipe->ops        = pipe->stages[0]->ops;
+
+      r128ctx->useFastPath = GL_TRUE;
+      return GL_TRUE;
+   }
+
+   if ( r128ctx->useFastPath ) {
+      r128ctx->useFastPath = GL_FALSE;
+
+      ctx->CVA.VB->ClipOrMask   = 0;
+      ctx->CVA.VB->ClipAndMask  = CLIP_ALL_BITS;
+      ctx->Array.NewArrayState |= ctx->Array.Summary;
+   }
+
+   return GL_FALSE;
+}
+
+
+/* Still do the normal fixup and copy-to-current, so this isn't so
+ * bad.
+ */
+#define ILLEGAL_INPUTS_IMM (VERT_OBJ_4 |	\
+                            VERT_TEX0_4 |	\
+			    VERT_TEX1_4 |	\
+			    VERT_MATERIAL)
+
+static void r128DDCheckRasterSetup( GLcontext *ctx,
+				    struct gl_pipeline_stage *d )
+{
+   d->type = PIPE_IMMEDIATE | PIPE_PRECALC;
+   d->inputs = ctx->RenderFlags;
+
+   /* r128 requires an extra input:
+    */
+   if ( ctx->FogMode == FOG_FRAGMENT )
+      d->inputs |= VERT_FOG_COORD;
+
+   d->outputs = VERT_SETUP_FULL;
 
-    return GL_FALSE;
+   if ( ctx->IndirectTriangles & DD_SW_SETUP )
+      d->type = PIPE_IMMEDIATE;
 }
 
 
 /* Register the pipeline with our stages included */
-GLuint r128RegisterPipelineStages(struct gl_pipeline_stage *out,
-				  const struct gl_pipeline_stage *in,
-				  GLuint nr)
+GLuint r128DDRegisterPipelineStages( struct gl_pipeline_stage *out,
+				     const struct gl_pipeline_stage *in,
+				     GLuint nr )
 {
-    int i;
+   int i, o;
 
-    for (i = 0; i < nr; i++) {
-	out[i] = in[i];
-	switch (in[i].ops) {
-	case PIPE_OP_RAST_SETUP_0:
-	    out[i].cva_state_change = (NEW_LIGHTING  |
-				       NEW_TEXTURING |
-				       NEW_RASTER_OPS);
-	    out[i].state_change     = ~0;
-	    out[i].check            = r128CheckPartialRasterSetup;
-	    out[i].run              = r128PartialRasterSetup;
-	    break;
-
-	case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1:
-	    out[i].run              = r128DoRasterSetup;
-	    break;
-	}
-    }
+   for ( i = o = 0 ; i < nr ; i++ ) {
+      switch ( in[i].ops ) {
+	 /* Completely replace Mesa's fog processing to generate fog
+	  * coordinates instead of messing with colors.
+	  */
+      case PIPE_OP_FOG:
+	 out[o] = gl_fog_coord_stage;
+	 o++;
+	 break;
+
+      case PIPE_OP_RAST_SETUP_0:
+	 out[o] = in[i];
+	 out[o].cva_state_change = (NEW_LIGHTING |
+				    NEW_TEXTURING |
+				    NEW_RASTER_OPS);
+	 out[o].state_change = ~0;
+	 out[o].check = r128DDCheckPartialRasterSetup;
+	 out[o].run = r128DDPartialRasterSetup;
+	 o++;
+	 break;
+
+      case PIPE_OP_RAST_SETUP_0 | PIPE_OP_RAST_SETUP_1:
+	 out[o] = in[i];
+	 out[o].check = r128DDCheckRasterSetup;
+	 out[o].run = r128DDDoRasterSetup;
+	 o++;
+	 break;
+
+      default:
+	 out[o++] = in[i];
+	 break;
+      }
+   }
 
-    return nr;
+   return o;
 }
Index: xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h:1.1	Fri Jun 16 20:03:06 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h	Mon Dec  4 14:21:46 2000
@@ -1,8 +1,8 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h,v 1.1 2000/06/17 00:03:06 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h,v 1.3 2000/12/04 19:21:46 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas. 
+                                               Cedar Park, Texas.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,16 +28,23 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
 #ifndef _R128_PIPELINE_H_
 #define _R128_PIPELINE_H_
 
-extern GLboolean r128DDBuildPrecalcPipeline(GLcontext *ctx);
-extern GLuint    r128RegisterPipelineStages(struct gl_pipeline_stage *out,
+extern GLboolean r128DDBuildPrecalcPipeline( GLcontext *ctx );
+extern GLuint r128DDRegisterPipelineStages( struct gl_pipeline_stage *out,
 					    const struct gl_pipeline_stage *in,
-					    GLuint nr);
+					    GLuint nr );
+
+extern void r128DDFastPathInit( void );
+extern void r128DDFastPath( struct vertex_buffer *VB );
+
+extern void r128DDEltPathInit( void );
+extern void r128DDEltPath( struct vertex_buffer *VB );
 
 #endif /* _R128_PIPELINE_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_screen.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_screen.c:1.1 xc/lib/GL/mesa/src/drv/r128/r128_screen.c:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_screen.c:1.1	Fri Jun 16 20:03:06 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_screen.c	Mon Dec  4 14:21:46 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.c,v 1.1 2000/06/17 00:03:06 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.c,v 1.3 2000/12/04 19:21:46 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,28 +28,41 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
 #include "r128_dri.h"
-#include "r128_reg.h"
 
-#include "r128_init.h"
 #include "r128_context.h"
-#include "r128_xmesa.h"
-#include "r128_cce.h"
+#include "r128_ioctl.h"
 #include "r128_tris.h"
 #include "r128_vb.h"
-#include "r128_fastpath.h"
+#include "r128_pipeline.h"
 
 #include <sys/mman.h>
 
+#if 1
+/* Including xf86PciInfo.h introduces a bunch of errors...
+ */
+#define PCI_CHIP_RAGE128LE	0x4C45
+#define PCI_CHIP_RAGE128LF	0x4C46
+#define PCI_CHIP_RAGE128PF	0x5046
+#define PCI_CHIP_RAGE128PR	0x5052
+#define PCI_CHIP_RAGE128RE	0x5245
+#define PCI_CHIP_RAGE128RF	0x5246
+#define PCI_CHIP_RAGE128RK	0x524B
+#define PCI_CHIP_RAGE128RL	0x524C
+#endif
+
+
 /* Create the device specific screen private data struct */
 r128ScreenPtr r128CreateScreen(__DRIscreenPrivate *sPriv)
 {
     r128ScreenPtr    r128Screen;
     R128DRIPtr       r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv;
+    int cpp;
 
     /* Allocate the private area */
     r128Screen = (r128ScreenPtr)Xmalloc(sizeof(*r128Screen));
@@ -93,13 +106,12 @@
 	    return NULL;
 	}
 
-	r128Screen->vbRgn.handle = r128DRIPriv->vbHandle;
-	r128Screen->vbRgn.size   = r128DRIPriv->vbMapSize;
-	r128Screen->vbOffset     = r128DRIPriv->vbOffset;
+	r128Screen->bufRgn.handle = r128DRIPriv->bufHandle;
+	r128Screen->bufRgn.size   = r128DRIPriv->bufMapSize;
 	if (drmMap(sPriv->fd,
-		   r128Screen->vbRgn.handle,
-		   r128Screen->vbRgn.size,
-		   (drmAddressPtr)&r128Screen->vb)) {
+		   r128Screen->bufRgn.handle,
+		   r128Screen->bufRgn.size,
+		   (drmAddressPtr)&r128Screen->buf)) {
 	    drmUnmap((drmAddress)r128Screen->ringReadPtr,
 		     r128Screen->ringReadRgn.size);
 	    drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
@@ -107,32 +119,15 @@
 	    Xfree(r128Screen);
 	    return NULL;
 	}
-	r128Screen->vbOffset     = r128DRIPriv->vbOffset;
-	r128Screen->vbBufSize    = r128DRIPriv->vbBufSize;
+	r128Screen->bufOffset     = r128DRIPriv->bufOffset;
 
-	r128Screen->indRgn.handle = r128DRIPriv->indHandle;
-	r128Screen->indRgn.size   = r128DRIPriv->indMapSize;
-	if (drmMap(sPriv->fd,
-		   r128Screen->indRgn.handle,
-		   r128Screen->indRgn.size,
-		   (drmAddressPtr)&r128Screen->ind)) {
-	    drmUnmap((drmAddress)r128Screen->vb, r128Screen->vbRgn.size);
-	    drmUnmap((drmAddress)r128Screen->ringReadPtr,
-		     r128Screen->ringReadRgn.size);
-	    drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
-	    drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size);
-	    Xfree(r128Screen);
-	    return NULL;
-	}
-
 	r128Screen->agpTexRgn.handle = r128DRIPriv->agpTexHandle;
 	r128Screen->agpTexRgn.size   = r128DRIPriv->agpTexMapSize;
 	if (drmMap(sPriv->fd,
 		   r128Screen->agpTexRgn.handle,
 		   r128Screen->agpTexRgn.size,
 		   (drmAddressPtr)&r128Screen->agpTex)) {
-	    drmUnmap((drmAddress)r128Screen->ind,  r128Screen->indRgn.size);
-	    drmUnmap((drmAddress)r128Screen->vb,   r128Screen->vbRgn.size);
+	    drmUnmap((drmAddress)r128Screen->buf,   r128Screen->bufRgn.size);
 	    drmUnmap((drmAddress)r128Screen->ringReadPtr,
 		     r128Screen->ringReadRgn.size);
 	    drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
@@ -142,11 +137,10 @@
 	}
 	r128Screen->agpTexOffset   = r128DRIPriv->agpTexOffset;
 
-	if (!(r128Screen->vbBufs = drmMapBufs(sPriv->fd))) {
+	if (!(r128Screen->buffers = drmMapBufs(sPriv->fd))) {
 	    drmUnmap((drmAddress)r128Screen->agpTex,
 		     r128Screen->agpTexRgn.size);
-	    drmUnmap((drmAddress)r128Screen->ind,  r128Screen->indRgn.size);
-	    drmUnmap((drmAddress)r128Screen->vb,   r128Screen->vbRgn.size);
+	    drmUnmap((drmAddress)r128Screen->buf,   r128Screen->bufRgn.size);
 	    drmUnmap((drmAddress)r128Screen->ringReadPtr,
 		     r128Screen->ringReadRgn.size);
 	    drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size);
@@ -156,34 +150,38 @@
 	}
     }
 
+    /* Allow both AGP and PCI cards to use vertex buffers.  PCI cards use
+     * the ring walker method, ie. the vertex buffer data is actually part
+     * of the command stream.
+     */
+    r128Screen->bufMapSize        = r128DRIPriv->bufMapSize;
+
     r128Screen->deviceID         = r128DRIPriv->deviceID;
 
-    r128Screen->width            = r128DRIPriv->width;
-    r128Screen->height           = r128DRIPriv->height;
     r128Screen->depth            = r128DRIPriv->depth;
     r128Screen->bpp              = r128DRIPriv->bpp;
     r128Screen->pixel_code       = (r128Screen->bpp != 16 ?
 				    r128Screen->bpp :
 				    r128Screen->depth);
 
+    cpp                          = r128Screen->bpp / 8;
+
     r128Screen->fb               = sPriv->pFB;
     r128Screen->fbOffset         = sPriv->fbOrigin;
     r128Screen->fbStride         = sPriv->fbStride;
     r128Screen->fbSize           = sPriv->fbSize;
 
-    r128Screen->fbX              = r128DRIPriv->fbX;
-    r128Screen->fbY              = r128DRIPriv->fbY;
-    r128Screen->backX            = r128DRIPriv->backX;
-    r128Screen->backY            = r128DRIPriv->backY;
-    r128Screen->depthX           = r128DRIPriv->depthX;
-    r128Screen->depthY           = r128DRIPriv->depthY;
-
-    r128Screen->texOffset[R128_LOCAL_TEX_HEAP]     = (r128DRIPriv->textureY *
-						      r128Screen->fbStride +
-						      r128DRIPriv->textureX *
-						      (r128Screen->bpp/8));
-    r128Screen->texSize[R128_LOCAL_TEX_HEAP]       = r128DRIPriv->textureSize;
-    r128Screen->log2TexGran[R128_LOCAL_TEX_HEAP]   = r128DRIPriv->log2TexGran;
+    r128Screen->frontOffset      = r128DRIPriv->frontOffset;
+    r128Screen->frontPitch       = r128DRIPriv->frontPitch;
+    r128Screen->backOffset       = r128DRIPriv->backOffset;
+    r128Screen->backPitch        = r128DRIPriv->backPitch;
+    r128Screen->depthOffset      = r128DRIPriv->depthOffset;
+    r128Screen->depthPitch       = r128DRIPriv->depthPitch;
+    r128Screen->spanOffset       = r128DRIPriv->spanOffset;
+
+    r128Screen->texOffset[R128_LOCAL_TEX_HEAP]   = r128DRIPriv->textureOffset;
+    r128Screen->texSize[R128_LOCAL_TEX_HEAP]     = r128DRIPriv->textureSize;
+    r128Screen->log2TexGran[R128_LOCAL_TEX_HEAP] = r128DRIPriv->log2TexGran;
 
     if (r128Screen->IsPCI) {
 	r128Screen->texOffset[R128_AGP_TEX_HEAP]   = 0;
@@ -199,15 +197,7 @@
 	r128Screen->NRTexHeaps                     = R128_NR_TEX_HEAPS;
     }
 
-#if 1
-    /* FIXME: For testing only */
-    if (getenv("LIBGL_SHOW_BUFFERS")) {
-	r128Screen->backX        = 0;
-	r128Screen->backY        = r128DRIPriv->height/2;
-	r128Screen->depthX       = r128DRIPriv->width/2;
-	r128Screen->depthY       = r128DRIPriv->height/2;
-    }
-#endif
+    r128Screen->AGPMode          = r128DRIPriv->AGPMode;
 
     r128Screen->CCEMode          = r128DRIPriv->CCEMode;
     r128Screen->CCEFifoSize      = r128DRIPriv->CCEFifoSize;
@@ -224,16 +214,31 @@
 
     r128Screen->CCEFifoAddr      = R128_PM4_FIFO_DATA_EVEN;
 
-    r128Screen->SAREA            = (R128SAREAPrivPtr)((char *)sPriv->pSAREA +
-						      sizeof(XF86DRISAREARec));
-
     r128Screen->driScreen        = sPriv;
 
-    r128InitVertexBuffers(r128Screen);
+    switch ( r128DRIPriv->deviceID ) {
+    case PCI_CHIP_RAGE128RE:
+    case PCI_CHIP_RAGE128RF:
+    case PCI_CHIP_RAGE128RK:
+    case PCI_CHIP_RAGE128RL:
+	r128Screen->chipset = R128_CARD_TYPE_R128;
+	break;
+    case PCI_CHIP_RAGE128PF:
+	r128Screen->chipset = R128_CARD_TYPE_R128_PRO;
+	break;
+    case PCI_CHIP_RAGE128LE:
+    case PCI_CHIP_RAGE128LF:
+	r128Screen->chipset = R128_CARD_TYPE_R128_MOBILITY;
+	break;
+    default:
+	r128Screen->chipset = R128_CARD_TYPE_R128;
+	break;
+    }
 
-    r128FastPathInit();
-    r128TriangleFuncsInit();
-    r128SetupInit();
+    r128DDFastPathInit();
+    r128DDEltPathInit();
+    r128DDTriangleFuncsInit();
+    r128DDSetupInit();
 
     return r128Screen;
 }
@@ -244,11 +249,10 @@
     r128ScreenPtr r128Screen = (r128ScreenPtr)sPriv->private;
 
     if (!r128Screen->IsPCI) {
-	drmUnmapBufs(r128Screen->vbBufs);
+	drmUnmapBufs(r128Screen->buffers);
 
 	drmUnmap((drmAddress)r128Screen->agpTex, r128Screen->agpTexRgn.size);
-	drmUnmap((drmAddress)r128Screen->ind,    r128Screen->indRgn.size);
-	drmUnmap((drmAddress)r128Screen->vb,     r128Screen->vbRgn.size);
+	drmUnmap((drmAddress)r128Screen->buf,    r128Screen->bufRgn.size);
 	drmUnmap((drmAddress)r128Screen->ringReadPtr,
 		 r128Screen->ringReadRgn.size);
 	drmUnmap((drmAddress)r128Screen->ring,   r128Screen->ringRgn.size);
Index: xc/lib/GL/mesa/src/drv/r128/r128_screen.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_screen.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_screen.h:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_screen.h:1.1	Fri Jun 16 20:03:06 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_screen.h	Mon Dec  4 14:21:47 2000
@@ -1,8 +1,8 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.h,v 1.1 2000/06/17 00:03:06 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.h,v 1.3 2000/12/04 19:21:47 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas. 
+                                               Cedar Park, Texas.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,7 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
@@ -56,16 +57,12 @@
     /* CCE ring read pointer data */
     r128RegionRec       ringReadRgn;
 
-    /* CCE vertex buffer data */
-    r128RegionRec       vbRgn;
-    unsigned char      *vb;
-    int                 vbOffset;
-    int                 vbBufSize;
-    drmBufMapPtr        vbBufs;
-
-    /* CCE indirect buffer data */
-    r128RegionRec       indRgn;
-    unsigned char      *ind;
+    /* CCE vertex/indirect buffer data */
+    r128RegionRec       bufRgn;
+    unsigned char      *buf;
+    int                 bufOffset;
+    int                 bufMapSize;
+    drmBufMapPtr        buffers;
 
     /* CCE AGP Texture data */
     r128RegionRec       agpTexRgn;
@@ -78,7 +75,17 @@
     int                 fbStride;
     int                 fbSize;
 
+    unsigned int	frontX, frontY;	/* Start of front buffer */
+    unsigned int	frontOffset, frontPitch;
+    unsigned int	backX, backY;	/* Start of shared back buffer */
+    unsigned int	backOffset, backPitch;
+    unsigned int	depthX, depthY;	/* Start of shared depth buffer */
+    unsigned int	depthOffset, depthPitch;
+    unsigned int	spanOffset;
+
+    int			chipset;
     int                 IsPCI;		/* Current card is a PCI card */
+    int                 AGPMode;
 
     int                 CCEMode;	/* CCE mode that server/clients use */
     int                 CCEFifoSize;	/* Size of the CCE command FIFO */
@@ -92,19 +99,10 @@
 
     /* DRI screen private data */
     int                 deviceID;	/* PCI device ID */
-    int                 width;		/* Width in pixels of display */
-    int                 height;		/* Height in scanlines of display */
     int                 depth;		/* Depth of display (8, 15, 16, 24) */
     int                 bpp;		/* Bit depth of disp (8, 16, 24, 32) */
     int                 pixel_code;	/* 8, 15, 16, 24, 32 */
 
-    int                 fbX;		/* Start of frame buffer */
-    int                 fbY;
-    int                 backX;		/* Start of shared back buffer */
-    int                 backY;
-    int                 depthX;		/* Start of shared depth buffer */
-    int                 depthY;
-
     /* Shared texture data */
     int                 NRTexHeaps;
     int                 texOffset[R128_NR_TEX_HEAPS];
@@ -117,8 +115,6 @@
     int                 CCEFifoAddr;    /* MMIO offset to write next CCE
 					   value (only used when CCE is
 					   in PIO mode). */
-    R128SAREAPrivPtr    SAREA;		/* Pointer to SAREA private data */
-
     __DRIscreenPrivate *driScreen;
 } r128ScreenRec, *r128ScreenPtr;
 
Index: xc/lib/GL/mesa/src/drv/r128/r128_span.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_span.c:1.1 xc/lib/GL/mesa/src/drv/r128/r128_span.c:1.4
--- xc/lib/GL/mesa/src/drv/r128/r128_span.c:1.1	Fri Jun 16 20:03:07 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_span.c	Tue Dec 12 12:17:07 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_span.c,v 1.1 2000/06/17 00:03:07 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_span.c,v 1.4 2000/12/12 17:17:07 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,302 +28,373 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Keith Whitwell <keith@precisioninsight.com>
- *   Gareth Hughes <gareth@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Keith Whitwell <keithw@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
 #include "r128_context.h"
-#include "r128_lock.h"
+#include "r128_ioctl.h"
 #include "r128_state.h"
-#include "r128_reg.h"
-#include "r128_cce.h"
 #include "r128_span.h"
 
+#include "pb.h"
+
 #define DBG 0
 
-#define LOCAL_VARS                                                            \
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);                               \
-    r128ScreenPtr r128scrn = r128ctx->r128Screen;                             \
-    __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;                       \
-    GLuint pitch = r128scrn->fbStride;                                        \
-    GLuint height = dPriv->h;                                                 \
-    char *buf = (char *)(r128scrn->fb +                                       \
-			 (r128ctx->drawX + dPriv->x) * (r128scrn->bpp/8) +    \
-			 (r128ctx->drawY + dPriv->y) * pitch);                \
-    char *read_buf = (char *)(r128scrn->fb +                                  \
-			      (r128ctx->readX + dPriv->x) * (r128scrn->bpp/8)+\
-			      (r128ctx->readY + dPriv->y) * pitch);           \
-    GLushort p;                                                               \
-    (void) read_buf; (void) buf; (void) p
-
-#define LOCAL_DEPTH_VARS                                                      \
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);                               \
-    r128ScreenPtr r128scrn = r128ctx->r128Screen;                             \
-    __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;                       \
-    GLuint pitch = r128scrn->fbStride;                                        \
-    GLuint height = dPriv->h;                                                 \
-    char *buf = (char *)(r128scrn->fb +                                       \
-			 (r128scrn->depthX + dPriv->x) * (r128scrn->bpp/8) +  \
-			 (r128scrn->depthY + dPriv->y) * pitch);              \
-    (void) buf
-
-#define INIT_MONO_PIXEL(p)                                                    \
-    p = R128_CONTEXT(ctx)->Color
-
-#define CLIPPIXEL(_x, _y)                                                     \
-    ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
-
-
-#define CLIPSPAN(_x, _y, _n, _x1, _n1, _i)                                    \
-    if (( _y < miny) || (_y >= maxy)) {                                       \
-	_n1 = 0, _x1 = x;                                                     \
-    } else {                                                                  \
-	_n1 = _n;                                                             \
-	_x1 = _x;                                                             \
-	if (_x1 < minx) _i += (minx - _x1), _x1 = minx;                       \
-	if (_x1 + _n1 >= maxx) n1 -= (_x1 + n1 - maxx) + 1;                   \
-    }
-
-#define Y_FLIP(_y) (height - _y - 1)
-
-
-#define HW_LOCK()                                                             \
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);                               \
-    LOCK_HARDWARE(r128ctx);                                                   \
-    r128WaitForIdleLocked(r128ctx);
-
-#define HW_CLIPLOOP()                                                         \
-    do {                                                                      \
-	__DRIdrawablePrivate *dPriv = r128ctx->driDrawable;                   \
-	int _nc = dPriv->numClipRects;                                        \
-                                                                              \
-	while (_nc--) {                                                       \
-	    int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;                  \
-	    int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;                  \
-	    int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;                  \
-	    int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
+#define HAVE_HW_DEPTH_SPANS	1
+#define HAVE_HW_DEPTH_PIXELS	1
 
-#define HW_ENDCLIPLOOP()                                                      \
-	}                                                                     \
-    } while (0)
+#define LOCAL_VARS							\
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);				\
+   r128ScreenPtr r128scrn = r128ctx->r128Screen;			\
+   __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;			\
+   GLuint pitch = r128scrn->fbStride;					\
+   GLuint height = dPriv->h;						\
+   char *buf = (char *)(r128scrn->fb +					\
+			r128ctx->drawOffset +				\
+			(dPriv->x * r128scrn->bpp/8) +			\
+			(dPriv->y * pitch));				\
+   char *read_buf = (char *)(r128scrn->fb +				\
+			     r128ctx->readOffset +			\
+			     (dPriv->x * r128scrn->bpp/8) +		\
+			     (dPriv->y * pitch));			\
+   GLushort p;								\
+   (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS						\
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);				\
+   __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;			\
+   GLuint height = dPriv->h;						\
+   (void) height
+
+#define LOCAL_STENCIL_VARS	LOCAL_DEPTH_VARS
+
+#define INIT_MONO_PIXEL( p )						\
+   p = r128ctx->Color
+
+#define CLIPPIXEL( _x, _y )						\
+   ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
+
+
+#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i )				\
+   if (( _y < miny) || (_y >= maxy)) {					\
+      _n1 = 0, _x1 = x;							\
+   } else {								\
+      _n1 = _n;								\
+      _x1 = _x;								\
+      if (_x1 < minx) _i += (minx - _x1), _x1 = minx;			\
+      if (_x1 + _n1 >= maxx) n1 -= (_x1 + n1 - maxx) + 1;		\
+   }
+
+#define Y_FLIP( _y )	(height - _y - 1)
+
+
+#define HW_LOCK()							\
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);				\
+   FLUSH_BATCH( r128ctx );						\
+   LOCK_HARDWARE( r128ctx );						\
+   r128WaitForIdleLocked( r128ctx );
+
+#define HW_CLIPLOOP()							\
+   do {									\
+      __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;		\
+      int _nc = dPriv->numClipRects;					\
+									\
+      while ( _nc-- ) {							\
+	 int minx = dPriv->pClipRects[_nc].x1 - dPriv->x;		\
+	 int miny = dPriv->pClipRects[_nc].y1 - dPriv->y;		\
+	 int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x;		\
+	 int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
+
+#define HW_ENDCLIPLOOP()						\
+      }									\
+   } while (0)
 
-#define HW_UNLOCK()                                                           \
-    UNLOCK_HARDWARE(r128ctx)
+#define HW_UNLOCK()							\
+   UNLOCK_HARDWARE( r128ctx )						\
 
 
 
-/* 16 bit, RGB565 color spanline and pixel functions */
-#define WRITE_RGBA(_x, _y, r, g, b, a)                                        \
-    *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) |          \
-					    (((int)g & 0xfc) << 3) |          \
-					    (((int)b & 0xf8) >> 3) )
+/* ================================================================
+ * Color buffer
+ */
 
-#define WRITE_PIXEL(_x, _y, p)                                                \
+/* 16 bit, RGB565 color spanline and pixel functions
+ */			\
+#define WRITE_RGBA( _x, _y, r, g, b, a )				\
+   *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) |	\
+					   (((int)g & 0xfc) << 3) |	\
+					   (((int)b & 0xf8) >> 3))
+
+#define WRITE_PIXEL( _x, _y, p )					\
     *(GLushort *)(buf + _x*2 + _y*pitch) = p
 
-#define READ_RGBA(rgba, _x, _y)                                               \
-    do {                                                                      \
-	GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch);               \
-	rgba[0] = (p >> 8) & 0xf8;                                            \
-	rgba[1] = (p >> 3) & 0xfc;                                            \
-	rgba[2] = (p << 3) & 0xf8;                                            \
-	rgba[3] = 0xff;                                                       \
+#define READ_RGBA( rgba, _x, _y )					\
+    do {								\
+	GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch);		\
+	rgba[0] = (p >> 8) & 0xf8;					\
+	rgba[1] = (p >> 3) & 0xfc;					\
+	rgba[2] = (p << 3) & 0xf8;					\
+	rgba[3] = 0xff;							\
     } while (0)
 
 #define TAG(x) r128##x##_RGB565
 #include "spantmp.h"
 
-
 
-/* 15 bit, ARGB1555 color spanline and pixel functions */
-#define WRITE_RGBA(_x, _y, r, g, b, a)                                        \
-    *(GLushort *)(buf + _x*2 + _y*pitch) = (((r & 0xf8) << 7) |               \
-					    ((g & 0xf8) << 2) |               \
-					    ((b & 0xf8) >> 3) |               \
-					    ((a) ? 0x8000 : 0))
-
-#define WRITE_PIXEL(_x, _y, p)                                                \
-    *(GLushort *)(buf + _x*2 + _y*pitch) = p
-
-#define READ_RGBA(rgba, _x, _y)                                               \
-    do {                                                                      \
-	GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch);               \
-	rgba[0] = (p >> 7) & 0xf8;                                            \
-	rgba[1] = (p >> 2) & 0xf8;                                            \
-	rgba[2] = (p << 3) & 0xf8;                                            \
-	rgba[3] = (p & 0x8000) ? 0xff : 0;                                    \
-    } while (0)
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+#define WRITE_RGBA( _x, _y, r, g, b, a )				\
+   *(GLuint *)(buf + _x*4 + _y*pitch) = ((b <<  0) |			\
+					 (g <<  8) |			\
+					 (r << 16) |			\
+					 (a << 24) )
+
+#define WRITE_PIXEL( _x, _y, p )					\
+   *(GLuint *)(buf + _x*4 + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y )					\
+do {									\
+   GLuint p = *(GLuint *)(read_buf + _x*4 + _y*pitch);			\
+   rgba[0] = (p >> 16) & 0xff;						\
+   rgba[1] = (p >>  8) & 0xff;						\
+   rgba[2] = (p >>  0) & 0xff;						\
+   rgba[3] = (p >> 24) & 0xff;						\
+} while (0)
 
-#define TAG(x) r128##x##_ARGB1555
+#define TAG(x) r128##x##_ARGB8888
 #include "spantmp.h"
 
 
+
+/* ================================================================
+ * Depth buffer
+ */
 
-/* 16 bit depthbuffer functions */
-#define WRITE_DEPTH(_x, _y, d)                                                \
-    *(GLushort *)(buf + _x*2 + _y*pitch) = d;
+/* 16-bit depth buffer functions
+ */
 
-#define READ_DEPTH(d, _x, _y)                                                 \
-    d = *(GLushort *)(buf + _x*2 + _y*pitch)
+#define WRITE_DEPTH_SPAN()						\
+   r128WriteDepthSpanLocked( r128ctx, n,				\
+			     x + dPriv->x,				\
+			     y + dPriv->y,				\
+			     depth, mask );
+
+#define WRITE_DEPTH_PIXELS()						\
+do {									\
+   GLint ox[PB_SIZE];							\
+   GLint oy[PB_SIZE];							\
+   for ( i = 0 ; i < n ; i++ ) {					\
+      ox[i] = x[i] + dPriv->x;						\
+   }									\
+   for ( i = 0 ; i < n ; i++ ) {					\
+      oy[i] = Y_FLIP( y[i] ) + dPriv->y;				\
+   }									\
+   r128WriteDepthPixelsLocked( r128ctx, n, ox, oy, depth, mask );	\
+} while (0)
+
+#define READ_DEPTH_SPAN()						\
+do {									\
+   r128ScreenPtr r128scrn = r128ctx->r128Screen;			\
+   GLushort *buf = (GLushort *)((GLubyte *)r128scrn->fb +		\
+				r128scrn->spanOffset);			\
+   GLint i;								\
+									\
+   r128ReadDepthSpanLocked( r128ctx, n,					\
+			    x + dPriv->x,				\
+			    y + dPriv->y );				\
+   r128WaitForIdleLocked( r128ctx );					\
+									\
+   for ( i = 0 ; i < n ; i++ ) {					\
+      depth[i] = buf[i];						\
+   }									\
+} while (0)
+
+#define READ_DEPTH_PIXELS()						\
+do {									\
+   r128ScreenPtr r128scrn = r128ctx->r128Screen;			\
+   GLushort *buf = (GLushort *)((GLubyte *)r128scrn->fb +		\
+				r128scrn->spanOffset);			\
+   GLint i, remaining = n;						\
+									\
+   while ( remaining > 0 ) {						\
+      GLint ox[PB_SIZE];						\
+      GLint oy[PB_SIZE];						\
+      GLint count;							\
+									\
+      if ( remaining <= 128 ) {						\
+	 count = remaining;						\
+      } else {								\
+	 count = 128;							\
+      }									\
+      for ( i = 0 ; i < count ; i++ ) {					\
+	 ox[i] = x[i] + dPriv->x;					\
+      }									\
+      for ( i = 0 ; i < count ; i++ ) {					\
+	 oy[i] = Y_FLIP( y[i] ) + dPriv->y;				\
+      }									\
+									\
+      r128ReadDepthPixelsLocked( r128ctx, count, ox, oy );		\
+      r128WaitForIdleLocked( r128ctx );					\
+									\
+      for ( i = 0 ; i < count ; i++ ) {					\
+	 depth[i] = buf[i];						\
+      }									\
+      depth += count;							\
+      x += count;							\
+      y += count;							\
+      remaining -= count;						\
+   }									\
+} while (0)
 
 #define TAG(x) r128##x##_16
 #include "depthtmp.h"
 
-
-
-/* 24 bit, RGB888 color spanline and pixel functions */
-#define WRITE_RGBA(_x, _y, r, g, b, a)                                        \
-    *(GLuint *)(buf + _x*3 + _y*pitch) = ((r << 16) |                         \
-					  (g << 8)  |                         \
-					  (b << 0))
-
-#define WRITE_PIXEL(_x, _y, p)                                                \
-    *(GLuint *)(buf + _x*3 + _y*pitch) = p
-
-#define READ_RGBA(rgba, _x, _y)                                               \
-    do {                                                                      \
-	GLuint p = *(GLuint *)(read_buf + _x*3 + _y*pitch);                   \
-	rgba[0] = (p >> 16) & 0xff;                                           \
-	rgba[1] = (p >> 8)  & 0xff;                                           \
-	rgba[2] = (p >> 0)  & 0xff;                                           \
-	rgba[3] = 0xff;                                                       \
-    } while (0)
-
-#define TAG(x) r128##x##_RGB888
-#include "spantmp.h"
-
-
-
-/* 24 bit depthbuffer functions */
-#define WRITE_DEPTH(_x, _y, d)                                                \
-    *(GLuint *)(buf + _x*3 + _y*pitch) = d
 
-#define READ_DEPTH(d, _x, _y)                                                 \
-    d = *(GLuint *)(buf + _x*3 + _y*pitch)
+/* 24-bit depth, 8-bit stencil buffer functions
+ */
+#define WRITE_DEPTH_SPAN()						\
+   r128WriteDepthSpanLocked( r128ctx, n,				\
+			     x + dPriv->x,				\
+			     y + dPriv->y,				\
+			     depth, mask );
+
+#define WRITE_DEPTH_PIXELS()						\
+do {									\
+   GLint ox[PB_SIZE];							\
+   GLint oy[PB_SIZE];							\
+   for ( i = 0 ; i < n ; i++ ) {					\
+      ox[i] = x[i] + dPriv->x;						\
+   }									\
+   for ( i = 0 ; i < n ; i++ ) {					\
+      oy[i] = Y_FLIP( y[i] ) + dPriv->y;				\
+   }									\
+   r128WriteDepthPixelsLocked( r128ctx, n, ox, oy, depth, mask );	\
+} while (0)
+
+#define READ_DEPTH_SPAN()						\
+do {									\
+   r128ScreenPtr r128scrn = r128ctx->r128Screen;			\
+   GLuint *buf = (GLuint *)((GLubyte *)r128scrn->fb +			\
+			    r128scrn->spanOffset);			\
+   GLint i;								\
+									\
+   r128ReadDepthSpanLocked( r128ctx, n,					\
+			    x + dPriv->x,				\
+			    y + dPriv->y );				\
+   r128WaitForIdleLocked( r128ctx );					\
+									\
+   for ( i = 0 ; i < n ; i++ ) {					\
+      depth[i] = buf[i] & 0x00ffffff;					\
+   }									\
+} while (0)
+
+#define READ_DEPTH_PIXELS()						\
+do {									\
+   r128ScreenPtr r128scrn = r128ctx->r128Screen;			\
+   GLuint *buf = (GLuint *)((GLubyte *)r128scrn->fb +			\
+			    r128scrn->spanOffset);			\
+   GLint i, remaining = n;						\
+									\
+   while ( remaining > 0 ) {						\
+      GLint ox[PB_SIZE];						\
+      GLint oy[PB_SIZE];						\
+      GLint count;							\
+									\
+      if ( remaining <= 128 ) {						\
+	 count = remaining;						\
+      } else {								\
+	 count = 128;							\
+      }									\
+      for ( i = 0 ; i < count ; i++ ) {					\
+	 ox[i] = x[i] + dPriv->x;					\
+      }									\
+      for ( i = 0 ; i < count ; i++ ) {					\
+	 oy[i] = Y_FLIP( y[i] ) + dPriv->y;				\
+      }									\
+									\
+      r128ReadDepthPixelsLocked( r128ctx, count, ox, oy );		\
+      r128WaitForIdleLocked( r128ctx );					\
+									\
+      for ( i = 0 ; i < count ; i++ ) {					\
+	 depth[i] = buf[i] & 0x00ffffff;				\
+      }									\
+      depth += count;							\
+      x += count;							\
+      y += count;							\
+      remaining -= count;						\
+   }									\
+} while (0)
 
-#define TAG(x) r128##x##_24
+#define TAG(x) r128##x##_24_8
 #include "depthtmp.h"
 
 
-
-/* 32 bit, ARGB8888 color spanline and pixel functions */
-#define WRITE_RGBA(_x, _y, r, g, b, a)                                        \
-    *(GLuint *)(buf + _x*4 + _y*pitch) = ((r << 16) |                         \
-					  (g << 8)  |                         \
-					  (b << 0)  |                         \
-					  (a << 24) )
-
-#define WRITE_PIXEL(_x, _y, p)                                                \
-    *(GLuint *)(buf + _x*4 + _y*pitch) = p
-
-#define READ_RGBA(rgba, _x, _y)                                               \
-    do {                                                                      \
-	GLuint p = *(GLuint *)(read_buf + _x*4 + _y*pitch);                   \
-	rgba[0] = (p >> 16) & 0xff;                                           \
-	rgba[1] = (p >> 8)  & 0xff;                                           \
-	rgba[2] = (p >> 0)  & 0xff;                                           \
-	rgba[3] = (p >> 24) & 0xff;                                           \
-    } while (0)
 
-#define TAG(x) r128##x##_ARGB8888
-#include "spantmp.h"
-
-
-
-/* 32 bit depthbuffer functions */
-#define WRITE_DEPTH(_x, _y, d)                                                \
-    *(GLuint *)(buf + _x*4 + _y*pitch) = d
-
-#define READ_DEPTH(d, _x, _y)                                                 \
-    d = *(GLuint *)(buf + _x*4 + _y*pitch)
+/* ================================================================
+ * Stencil buffer
+ */
 
-#define TAG(x) r128##x##_32
-#include "depthtmp.h"
+/* FIXME: Add support for hardware stencil buffers.
+ */
 
 
 
-void r128DDInitSpanFuncs(GLcontext *ctx)
+void r128DDInitSpanFuncs( GLcontext *ctx )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);
 
-    switch (r128ctx->r128Screen->pixel_code) {
-    case 8: /* Color Index mode not supported */
-	break;
-
-    case 15:
-	ctx->Driver.WriteRGBASpan       = r128WriteRGBASpan_ARGB1555;
-	ctx->Driver.WriteRGBSpan        = r128WriteRGBSpan_ARGB1555;
-	ctx->Driver.WriteMonoRGBASpan   = r128WriteMonoRGBASpan_ARGB1555;
-	ctx->Driver.WriteRGBAPixels     = r128WriteRGBAPixels_ARGB1555;
-	ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB1555;
-	ctx->Driver.ReadRGBASpan        = r128ReadRGBASpan_ARGB1555;
-	ctx->Driver.ReadRGBAPixels      = r128ReadRGBAPixels_ARGB1555;
-
-	ctx->Driver.ReadDepthSpan       = r128ReadDepthSpan_16;
-	ctx->Driver.WriteDepthSpan      = r128WriteDepthSpan_16;
-	ctx->Driver.ReadDepthPixels     = r128ReadDepthPixels_16;
-	ctx->Driver.WriteDepthPixels    = r128WriteDepthPixels_16;
-	break;
-
-    case 16:
-	ctx->Driver.WriteRGBASpan       = r128WriteRGBASpan_RGB565;
-	ctx->Driver.WriteRGBSpan        = r128WriteRGBSpan_RGB565;
-	ctx->Driver.WriteMonoRGBASpan   = r128WriteMonoRGBASpan_RGB565;
-	ctx->Driver.WriteRGBAPixels     = r128WriteRGBAPixels_RGB565;
-	ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB565;
-	ctx->Driver.ReadRGBASpan        = r128ReadRGBASpan_RGB565;
-	ctx->Driver.ReadRGBAPixels      = r128ReadRGBAPixels_RGB565;
-
-	ctx->Driver.ReadDepthSpan       = r128ReadDepthSpan_16;
-	ctx->Driver.WriteDepthSpan      = r128WriteDepthSpan_16;
-	ctx->Driver.ReadDepthPixels     = r128ReadDepthPixels_16;
-	ctx->Driver.WriteDepthPixels    = r128WriteDepthPixels_16;
-	break;
-
-    case 24:
-	ctx->Driver.WriteRGBASpan       = r128WriteRGBASpan_RGB888;
-	ctx->Driver.WriteRGBSpan        = r128WriteRGBSpan_RGB888;
-	ctx->Driver.WriteMonoRGBASpan   = r128WriteMonoRGBASpan_RGB888;
-	ctx->Driver.WriteRGBAPixels     = r128WriteRGBAPixels_RGB888;
-	ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB888;
-	ctx->Driver.ReadRGBASpan        = r128ReadRGBASpan_RGB888;
-	ctx->Driver.ReadRGBAPixels      = r128ReadRGBAPixels_RGB888;
-
-	ctx->Driver.ReadDepthSpan       = r128ReadDepthSpan_24;
-	ctx->Driver.WriteDepthSpan      = r128WriteDepthSpan_24;
-	ctx->Driver.ReadDepthPixels     = r128ReadDepthPixels_24;
-	ctx->Driver.WriteDepthPixels    = r128WriteDepthPixels_24;
-	break;
-
-    case 32:
-	ctx->Driver.WriteRGBASpan       = r128WriteRGBASpan_ARGB8888;
-	ctx->Driver.WriteRGBSpan        = r128WriteRGBSpan_ARGB8888;
-	ctx->Driver.WriteMonoRGBASpan   = r128WriteMonoRGBASpan_ARGB8888;
-	ctx->Driver.WriteRGBAPixels     = r128WriteRGBAPixels_ARGB8888;
-	ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB8888;
-	ctx->Driver.ReadRGBASpan        = r128ReadRGBASpan_ARGB8888;
-	ctx->Driver.ReadRGBAPixels      = r128ReadRGBAPixels_ARGB8888;
-
-	ctx->Driver.ReadDepthSpan       = r128ReadDepthSpan_32;
-	ctx->Driver.WriteDepthSpan      = r128WriteDepthSpan_32;
-	ctx->Driver.ReadDepthPixels     = r128ReadDepthPixels_32;
-	ctx->Driver.WriteDepthPixels    = r128WriteDepthPixels_32;
-	break;
-
-    default:
-	break;
-    }
-
-    ctx->Driver.WriteCI8Span      = NULL;
-    ctx->Driver.WriteCI32Span     = NULL;
-    ctx->Driver.WriteMonoCISpan   = NULL;
-    ctx->Driver.WriteCI32Pixels   = NULL;
-    ctx->Driver.WriteMonoCIPixels = NULL;
-    ctx->Driver.ReadCI32Span      = NULL;
-    ctx->Driver.ReadCI32Pixels    = NULL;
+   switch ( r128ctx->r128Screen->bpp ) {
+   case 16:
+      ctx->Driver.WriteRGBASpan		= r128WriteRGBASpan_RGB565;
+      ctx->Driver.WriteRGBSpan		= r128WriteRGBSpan_RGB565;
+      ctx->Driver.WriteMonoRGBASpan	= r128WriteMonoRGBASpan_RGB565;
+      ctx->Driver.WriteRGBAPixels	= r128WriteRGBAPixels_RGB565;
+      ctx->Driver.WriteMonoRGBAPixels	= r128WriteMonoRGBAPixels_RGB565;
+      ctx->Driver.ReadRGBASpan		= r128ReadRGBASpan_RGB565;
+      ctx->Driver.ReadRGBAPixels	= r128ReadRGBAPixels_RGB565;
+      break;
+
+   case 32:
+      ctx->Driver.WriteRGBASpan		= r128WriteRGBASpan_ARGB8888;
+      ctx->Driver.WriteRGBSpan		= r128WriteRGBSpan_ARGB8888;
+      ctx->Driver.WriteMonoRGBASpan	= r128WriteMonoRGBASpan_ARGB8888;
+      ctx->Driver.WriteRGBAPixels	= r128WriteRGBAPixels_ARGB8888;
+      ctx->Driver.WriteMonoRGBAPixels	= r128WriteMonoRGBAPixels_ARGB8888;
+      ctx->Driver.ReadRGBASpan		= r128ReadRGBASpan_ARGB8888;
+      ctx->Driver.ReadRGBAPixels	= r128ReadRGBAPixels_ARGB8888;
+      break;
+
+   default:
+      break;
+   }
+
+   switch ( r128ctx->DepthSize ) {
+   case 16:
+      ctx->Driver.ReadDepthSpan		= r128ReadDepthSpan_16;
+      ctx->Driver.WriteDepthSpan	= r128WriteDepthSpan_16;
+      ctx->Driver.ReadDepthPixels	= r128ReadDepthPixels_16;
+      ctx->Driver.WriteDepthPixels	= r128WriteDepthPixels_16;
+      break;
+
+   case 24:
+      ctx->Driver.ReadDepthSpan		= r128ReadDepthSpan_24_8;
+      ctx->Driver.WriteDepthSpan	= r128WriteDepthSpan_24_8;
+      ctx->Driver.ReadDepthPixels	= r128ReadDepthPixels_24_8;
+      ctx->Driver.WriteDepthPixels	= r128WriteDepthPixels_24_8;
+      break;
+
+   default:
+      break;
+   }
+
+   ctx->Driver.WriteCI8Span		= NULL;
+   ctx->Driver.WriteCI32Span		= NULL;
+   ctx->Driver.WriteMonoCISpan		= NULL;
+   ctx->Driver.WriteCI32Pixels		= NULL;
+   ctx->Driver.WriteMonoCIPixels	= NULL;
+   ctx->Driver.ReadCI32Span		= NULL;
+   ctx->Driver.ReadCI32Pixels		= NULL;
 }
Index: xc/lib/GL/mesa/src/drv/r128/r128_span.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_span.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_span.h:1.2
--- xc/lib/GL/mesa/src/drv/r128/r128_span.h:1.1	Fri Jun 16 20:03:07 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_span.h	Mon Dec  4 14:21:47 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_span.h,v 1.1 2000/06/17 00:03:07 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_span.h,v 1.2 2000/12/04 19:21:47 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,8 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Gareth Hughes <gareth@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
Index: xc/lib/GL/mesa/src/drv/r128/r128_state.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_state.c:1.3 xc/lib/GL/mesa/src/drv/r128/r128_state.c:1.6
--- xc/lib/GL/mesa/src/drv/r128/r128_state.c:1.3	Mon Jun 26 01:41:29 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_state.c	Tue Dec 12 12:17:07 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_state.c,v 1.3 2000/06/26 05:41:29 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_state.c,v 1.6 2000/12/12 17:17:07 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,1374 +28,1242 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Gareth Hughes <gareth@valinux.com>
+ *   Keith Whitwell <keithw@valinux.com>
  *
  */
 
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
 #include "r128_context.h"
-#include "r128_lock.h"
 #include "r128_state.h"
-#include "r128_reg.h"
-#include "r128_cce.h"
+#include "r128_ioctl.h"
 #include "r128_tris.h"
 #include "r128_vb.h"
 #include "r128_tex.h"
 
 #include "mmath.h"
 #include "pb.h"
+#include "enums.h"
 
-#define INTERESTED (~(NEW_MODELVIEW      | \
-		      NEW_PROJECTION     | \
-		      NEW_TEXTURE_MATRIX | \
-		      NEW_USER_CLIP      | \
-		      NEW_CLIENT_STATE   | \
-		      NEW_TEXTURE_ENABLE))
 
-static void r128DDUpdateState(GLcontext *ctx)
+/* =============================================================
+ * Alpha blending
+ */
+
+static void r128UpdateAlphaMode( GLcontext *ctx )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   CARD32 a = r128ctx->setup.misc_3d_state_cntl_reg;
+   CARD32 t = r128ctx->setup.tex_cntl_c;
+
+   if ( ctx->Color.AlphaEnabled ) {
+      GLubyte ref = ctx->Color.AlphaRef;
+
+      a &= ~(R128_ALPHA_TEST_MASK | R128_REF_ALPHA_MASK);
+
+      switch ( ctx->Color.AlphaFunc ) {
+      case GL_NEVER:
+	 a |= R128_ALPHA_TEST_NEVER;
+	 ref = 0;
+	 break;
+      case GL_LESS:
+	 a |= R128_ALPHA_TEST_LESS;
+         break;
+      case GL_LEQUAL:
+	 a |= R128_ALPHA_TEST_LESSEQUAL;
+	 break;
+      case GL_EQUAL:
+	 a |= R128_ALPHA_TEST_EQUAL;
+	 break;
+      case GL_GEQUAL:
+	 a |= R128_ALPHA_TEST_GREATEREQUAL;
+	 break;
+      case GL_GREATER:
+	 a |= R128_ALPHA_TEST_GREATER;
+	 break;
+      case GL_NOTEQUAL:
+	 a |= R128_ALPHA_TEST_NEQUAL;
+	 break;
+      case GL_ALWAYS:
+	 a |= R128_ALPHA_TEST_ALWAYS;
+	 break;
+      }
+
+      a |= ref & R128_REF_ALPHA_MASK;
+      t |= R128_ALPHA_TEST_ENABLE;
+   } else {
+      t &= ~R128_ALPHA_TEST_ENABLE;
+   }
 
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
-	fprintf(stderr, "r128DDUpdateState(%p)\n", ctx);
-    }
+   if ( ctx->Color.BlendEnabled ) {
+      a &= ~(R128_ALPHA_BLEND_SRC_MASK | R128_ALPHA_BLEND_DST_MASK);
 
-    /* Need to do this here to detect texture fallbacks before
-     * setting triangle functions.
-     */
-    if (r128ctx->dirty & R128_UPDATE_TEXSTATE)
-	r128UpdateHWState(r128ctx);
+      switch ( ctx->Color.BlendSrcRGB ) {
+      case GL_ZERO:
+	 a |= R128_ALPHA_BLEND_SRC_ZERO;
+	 break;
+      case GL_ONE:
+	 a |= R128_ALPHA_BLEND_SRC_ONE;
+	 break;
+      case GL_DST_COLOR:
+	 a |= R128_ALPHA_BLEND_SRC_DESTCOLOR;
+	 break;
+      case GL_ONE_MINUS_DST_COLOR:
+	 a |= R128_ALPHA_BLEND_SRC_INVDESTCOLOR;
+	 break;
+      case GL_SRC_ALPHA:
+	 a |= R128_ALPHA_BLEND_SRC_SRCALPHA;
+	 break;
+      case GL_ONE_MINUS_SRC_ALPHA:
+	 a |= R128_ALPHA_BLEND_SRC_INVSRCALPHA;
+	 break;
+      case GL_DST_ALPHA:
+	 a |= R128_ALPHA_BLEND_SRC_DESTALPHA;
+	 break;
+      case GL_ONE_MINUS_DST_ALPHA:
+	 a |= R128_ALPHA_BLEND_SRC_INVDESTALPHA;
+	 break;
+      case GL_SRC_ALPHA_SATURATE:
+	 a |= R128_ALPHA_BLEND_SRC_SRCALPHASAT;
+	 break;
+      }
 
-    if (ctx->NewState & INTERESTED) {
-	r128ChooseRenderState(ctx);
-	r128ChooseRasterSetupFunc(ctx);
-    }
+      switch ( ctx->Color.BlendDstRGB ) {
+      case GL_ZERO:
+	 a |= R128_ALPHA_BLEND_DST_ZERO;
+	 break;
+      case GL_ONE:
+	 a |= R128_ALPHA_BLEND_DST_ONE;
+	 break;
+      case GL_SRC_COLOR:
+	 a |= R128_ALPHA_BLEND_DST_SRCCOLOR;
+	 break;
+      case GL_ONE_MINUS_SRC_COLOR:
+	 a |= R128_ALPHA_BLEND_DST_INVSRCCOLOR;
+	 break;
+      case GL_SRC_ALPHA:
+	 a |= R128_ALPHA_BLEND_DST_SRCALPHA;
+	 break;
+      case GL_ONE_MINUS_SRC_ALPHA:
+	 a |= R128_ALPHA_BLEND_DST_INVSRCALPHA;
+	 break;
+      case GL_DST_ALPHA:
+	 a |= R128_ALPHA_BLEND_DST_DESTALPHA;
+	 break;
+      case GL_ONE_MINUS_DST_ALPHA:
+	 a |= R128_ALPHA_BLEND_DST_INVDESTALPHA;
+	 break;
+      }
 
-    if (!r128ctx->Fallback) {
-	ctx->IndirectTriangles   &= ~DD_SW_RASTERIZE;
-	ctx->IndirectTriangles   |= r128ctx->IndirectTriangles;
+      t |=  R128_ALPHA_ENABLE;
+   } else {
+      t &= ~R128_ALPHA_ENABLE;
+   }
 
-	ctx->Driver.PointsFunc    = r128ctx->PointsFunc;
-	ctx->Driver.LineFunc      = r128ctx->LineFunc;
-	ctx->Driver.TriangleFunc  = r128ctx->TriangleFunc;
-	ctx->Driver.QuadFunc      = r128ctx->QuadFunc;
-	ctx->Driver.RectFunc      = NULL;
-    }
+   if ( r128ctx->setup.misc_3d_state_cntl_reg != a ) {
+      r128ctx->setup.misc_3d_state_cntl_reg = a;
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
+   }
+   if ( r128ctx->setup.tex_cntl_c != t ) {
+      r128ctx->setup.tex_cntl_c = t;
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
+   }
 }
 
-static void r128DDUpdateHWState(GLcontext *ctx)
+static void r128DDAlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
 
-    /* FIXME: state is being updated too often */
-    if (r128ctx->dirty)
-	r128UpdateHWState(r128ctx);
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_ALPHA;
 }
 
+static void r128DDBlendEquation( GLcontext *ctx, GLenum mode )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
 
-/* This is called when mesa switches between rendering triangle
- * primitives (such as GL_POLYGON, GL_QUADS, GL_TRIANGLE_STRIP, etc),
- * and lines, points and bitmaps.
- *
- * As the r128 uses triangles to render lines and points, it is
- * necessary to turn off hardware culling when rendering these
- * primitives.
- */
-static void r128DDReducedPrimitiveChange(GLcontext *ctx, GLenum prim)
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_ALPHA;
+}
+
+static void r128DDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
 {
-   r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-   CARD32         f       = r128ctx->regs.pm4_vc_fpu_setup;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
 
-   f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID;
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_ALPHA;
+}
 
-   /* Should really use an intermediate value to hold this rather
-    * than recalculating all the time.
-    */
-   if (prim == GL_POLYGON && ctx->Polygon.CullFlag) {
-      switch (ctx->Polygon.CullFaceMode) {
-      case GL_FRONT:          f &= ~R128_FRONTFACE_SOLID;   break;
-      case GL_BACK:           f &= ~R128_BACKFACE_SOLID;    break;
-      case GL_FRONT_AND_BACK: f &= ~(R128_BACKFACE_SOLID |
-				     R128_FRONTFACE_SOLID); break;
-      default: break;
+static void r128DDBlendFuncSeparate( GLcontext *ctx,
+				     GLenum sfactorRGB, GLenum dfactorRGB,
+				     GLenum sfactorA, GLenum dfactorA )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_ALPHA;
+}
+
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void r128UpdateZMode( GLcontext *ctx )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   CARD32 z = r128ctx->setup.z_sten_cntl_c;
+   CARD32 t = r128ctx->setup.tex_cntl_c;
+
+   if ( ctx->Depth.Test ) {
+      z &= ~R128_Z_TEST_MASK;
+
+      switch ( ctx->Depth.Func ) {
+      case GL_NEVER:
+	 z |= R128_Z_TEST_NEVER;
+	 break;
+      case GL_ALWAYS:
+	 z |= R128_Z_TEST_ALWAYS;
+	 break;
+      case GL_LESS:
+	 z |= R128_Z_TEST_LESS;
+	 break;
+      case GL_LEQUAL:
+	 z |= R128_Z_TEST_LESSEQUAL;
+	 break;
+      case GL_EQUAL:
+	 z |= R128_Z_TEST_EQUAL;
+	 break;
+      case GL_GEQUAL:
+	 z |= R128_Z_TEST_GREATEREQUAL;
+	 break;
+      case GL_GREATER:
+	 z |= R128_Z_TEST_GREATER;
+	 break;
+      case GL_NOTEQUAL:
+	 z |= R128_Z_TEST_NEQUAL;
+	 break;
       }
+
+      t |=  R128_Z_ENABLE;
+   } else {
+      t &= ~R128_Z_ENABLE;
    }
 
-    if (r128ctx->regs.pm4_vc_fpu_setup != f) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.pm4_vc_fpu_setup = f;
+   if ( ctx->Depth.Mask ) {
+      t |=  R128_Z_WRITE_ENABLE;
+   } else {
+      t &= ~R128_Z_WRITE_ENABLE;
+   }
 
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_SETUPSTATE;
-    }
+   if ( r128ctx->setup.z_sten_cntl_c != z ) {
+      r128ctx->setup.z_sten_cntl_c = z;
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT;
+   }
+   if ( r128ctx->setup.tex_cntl_c != t ) {
+      r128ctx->setup.tex_cntl_c = t;
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT;
+   }
 }
 
-static void r128DDClearColor(GLcontext *ctx,
-                             GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+static void r128DDDepthFunc( GLcontext *ctx, GLenum func )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
 
-    r128ctx->ClearColor = r128PackColor(r128ctx->r128Screen->depth,
-					r, g, b, a);
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_DEPTH;
 }
 
-static void r128DDColor(GLcontext *ctx,
-			GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+static void r128DDDepthMask( GLcontext *ctx, GLboolean flag )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
 
-    r128ctx->Color = r128PackColor(r128ctx->r128Screen->depth, r, g, b, a);
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_DEPTH;
 }
 
-static GLboolean r128DDSetDrawBuffer(GLcontext *ctx, GLenum mode)
+static void r128DDClearDepth( GLcontext *ctx, GLclampd d )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    int            x       = r128ctx->driDrawable->x;
-    int            y       = r128ctx->driDrawable->y;
-    int            found;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   switch ( r128ctx->DepthSize ) {
+   case 16:
+      r128ctx->ClearDepth = d * 0x0000ffff;
+      break;
+   case 24:
+      r128ctx->ClearDepth = d * 0x00ffffff;
+      break;
+   case 32:
+      r128ctx->ClearDepth = d * 0xffffffff;
+      break;
+   }
+}
+
+
+/* =============================================================
+ * Fog
+ */
 
-    r128ctx->Fallback &= ~R128_FALLBACK_DRAW_BUFFER;
+static void r128UpdateFogAttrib( GLcontext *ctx )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   CARD32 t = r128ctx->setup.tex_cntl_c;
+   GLubyte c[4];
+   CARD32 col;
+
+   if ( ctx->FogMode == FOG_FRAGMENT ) {
+      t |=  R128_FOG_ENABLE;
+   } else {
+      t &= ~R128_FOG_ENABLE;
+   }
 
-    switch (mode) {
-    case GL_FRONT_LEFT:
-	r128ctx->drawX = r128ctx->r128Screen->fbX;
-	r128ctx->drawY = r128ctx->r128Screen->fbY;
-	found = GL_TRUE;
-	break;
-    case GL_BACK_LEFT:
-	r128ctx->drawX = r128ctx->r128Screen->backX;
-	r128ctx->drawY = r128ctx->r128Screen->backY;
-	found = GL_TRUE;
-	break;
-    default:
-	r128ctx->Fallback |= R128_FALLBACK_DRAW_BUFFER;
-	found = GL_FALSE;
-	break;
-    }
+   FLOAT_RGBA_TO_UBYTE_RGBA( c, ctx->Fog.Color );
+   col = r128PackColor( 32, c[0], c[1], c[2], c[3] );
 
-    x += r128ctx->drawX;
-    y += r128ctx->drawY;
+   if ( r128ctx->setup.fog_color_c != col ) {
+      r128ctx->setup.fog_color_c = col;
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT;
+   }
+   if ( r128ctx->setup.tex_cntl_c != t ) {
+      r128ctx->setup.tex_cntl_c = t;
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT;
+   }
+}
 
-    r128FlushVertices(r128ctx);
+static void r128DDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
 
-    r128ctx->regs.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) |
-				      (x << R128_WINDOW_X_SHIFT));
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_FOG;
+}
+
+
+/* =============================================================
+ * Clipping
+ */
+
+static void r128UpdateClipping( GLcontext *ctx )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   if ( r128ctx->driDrawable ) {
+      __DRIdrawablePrivate *drawable = r128ctx->driDrawable;
+      int x1 = 0;
+      int y1 = 0;
+      int x2 = r128ctx->driDrawable->w - 1;
+      int y2 = r128ctx->driDrawable->h - 1;
+
+      if ( ctx->Scissor.Enabled ) {
+	 if ( ctx->Scissor.X > x1 ) {
+	    x1 = ctx->Scissor.X;
+	 }
+	 if ( drawable->h - ctx->Scissor.Y - ctx->Scissor.Height > y1 ) {
+	    y1 = drawable->h - ctx->Scissor.Y - ctx->Scissor.Height;
+	 }
+	 if ( ctx->Scissor.X + ctx->Scissor.Width - 1 < x2 ) {
+	    x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
+	 }
+	 if ( drawable->h - ctx->Scissor.Y - 1 < y2 ) {
+	    y2 = drawable->h - ctx->Scissor.Y - 1;
+	 }
+      }
 
-    /* Recalculate the Z buffer offset since we might be drawing to the
-       back buffer and window_xy_offset affects both color buffer and
-       depth drawing */
-    r128ctx->regs.z_offset_c        = ((r128ctx->r128Screen->depthX -
-					r128ctx->drawX) *
-				       (r128ctx->r128Screen->bpp/8) +
-				       (r128ctx->r128Screen->depthY -
-					r128ctx->drawY) *
-				       r128ctx->r128Screen->fbStride);
-
-    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-    r128ctx->dirty_context |= R128_CTX_WIN_Z_POS;
-    return found;
-}
-
-static void r128DDSetReadBuffer(GLcontext *ctx,
-				GLframebuffer *colorBuffer,
-				GLenum mode)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-
-    r128ctx->Fallback &= ~R128_FALLBACK_READ_BUFFER;
-
-    switch (mode) {
-    case GL_FRONT_LEFT:
-	r128ctx->readX = r128ctx->r128Screen->fbX;
-	r128ctx->readY = r128ctx->r128Screen->fbY;
-	break;
-    case GL_BACK_LEFT:
-	r128ctx->readX = r128ctx->r128Screen->backX;
-	r128ctx->readY = r128ctx->r128Screen->backY;
-	break;
-    default:
-	r128ctx->Fallback |= R128_FALLBACK_READ_BUFFER;
-	break;
-    }
-}
-
-static GLboolean r128DDColorMask(GLcontext *ctx,
-				 GLboolean r, GLboolean g,
-				 GLboolean b, GLboolean a)
+      x1 += r128ctx->driDrawable->x;
+      y1 += r128ctx->driDrawable->y;
+      x2 += r128ctx->driDrawable->x;
+      y2 += r128ctx->driDrawable->y;
+
+      if ( 0 ) {
+	 fprintf( stderr, "%s: drawable %3d %3d %3d %3d\n",
+		  __FUNCTION__,
+		  r128ctx->driDrawable->x,
+		  r128ctx->driDrawable->y,
+		  r128ctx->driDrawable->w,
+		  r128ctx->driDrawable->h );
+	 fprintf( stderr, "%s: draw buf %3d %3d %3d %3d\n",
+		  __FUNCTION__,
+		  ctx->DrawBuffer->Xmin,
+		  ctx->DrawBuffer->Ymin,
+		  ctx->DrawBuffer->Xmax,
+		  ctx->DrawBuffer->Ymax );
+	 fprintf( stderr, "%s:  scissor %3d %3d %3d %3d\n",
+		  __FUNCTION__,
+		  ctx->Scissor.X,
+		  ctx->Scissor.Y,
+		  ctx->Scissor.Width,
+		  ctx->Scissor.Height );
+	 fprintf( stderr, "%s:    final %3d %3d %3d %3d\n",
+		  __FUNCTION__, x1, y1, x2, y2 );
+	 fprintf( stderr, "\n" );
+      }
+
+      r128ctx->setup.sc_top_left_c = ((x1 << 0) |
+				      (y1 << 16));
+      r128ctx->setup.sc_bottom_right_c = ((x2 << 0) |
+					  (y2 << 16));
+
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT;
+   }
+}
+
+static void r128DDScissor( GLcontext *ctx,
+			   GLint x, GLint y, GLsizei w, GLsizei h )
 {
-    r128ContextPtr r128ctx  = R128_CONTEXT(ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_CLIP;
+}
 
-    GLuint mask = r128PackColor(r128ctx->r128Screen->pixel_code,
+
+/* =============================================================
+ * Culling
+ */
+
+static void r128UpdateCull( GLcontext *ctx )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   CARD32 f = r128ctx->setup.pm4_vc_fpu_setup;
+
+   f &= ~R128_FRONT_DIR_MASK;
+
+   switch ( ctx->Polygon.FrontFace ) {
+   case GL_CW:
+      f |= R128_FRONT_DIR_CW;
+      break;
+   case GL_CCW:
+      f |= R128_FRONT_DIR_CCW;
+      break;
+   }
+
+   f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID;
+
+   if ( ctx->Polygon.CullFlag && ctx->PB->primitive == GL_POLYGON ) {
+      switch ( ctx->Polygon.CullFaceMode ) {
+      case GL_FRONT:
+	 f &= ~R128_FRONTFACE_SOLID;
+	 break;
+      case GL_BACK:
+	 f &= ~R128_BACKFACE_SOLID;
+	 break;
+      case GL_FRONT_AND_BACK:
+	 f &= ~(R128_BACKFACE_SOLID |
+		R128_FRONTFACE_SOLID);
+	 break;
+      }
+   }
+
+   if ( r128ctx->setup.pm4_vc_fpu_setup != f ) {
+      r128ctx->setup.pm4_vc_fpu_setup = f;
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_SETUP;
+   }
+}
+
+static void r128DDCullFace( GLcontext *ctx, GLenum mode )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_CULL;
+}
+
+static void r128DDFrontFace( GLcontext *ctx, GLenum mode )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_CULL;
+}
+
+
+/* =============================================================
+ * Masks
+ */
+
+static void r128UpdateMasks( GLcontext *ctx )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   GLuint mask = r128PackColor( r128ctx->r128Screen->bpp,
 				ctx->Color.ColorMask[RCOMP],
 				ctx->Color.ColorMask[GCOMP],
 				ctx->Color.ColorMask[BCOMP],
-				ctx->Color.ColorMask[ACOMP]);
+				ctx->Color.ColorMask[ACOMP] );
 
-    if (r128ctx->regs.plane_3d_mask_c != mask) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.plane_3d_mask_c = mask;
-
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_MISC;
-    }
-
-    return GL_TRUE;
-}
-
-
-static void r128DDDither(GLcontext *ctx, GLboolean enable)
-{
-}
-
-static void r128DDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    CARD32         a       = r128ctx->regs.misc_3d_state_cntl_reg;
-
-    a &= ~(R128_ALPHA_TEST_MASK | R128_REF_ALPHA_MASK);
-    a |= ctx->Color.AlphaRef & R128_REF_ALPHA_MASK;
-
-    switch (func) {
-    case GL_NEVER:    a |= R128_ALPHA_TEST_NEVER;        break;
-    case GL_LESS:     a |= R128_ALPHA_TEST_LESS;         break;
-    case GL_LEQUAL:   a |= R128_ALPHA_TEST_LESSEQUAL;    break;
-    case GL_EQUAL:    a |= R128_ALPHA_TEST_EQUAL;        break;
-    case GL_GEQUAL:   a |= R128_ALPHA_TEST_GREATEREQUAL; break;
-    case GL_GREATER:  a |= R128_ALPHA_TEST_GREATER;      break;
-    case GL_NOTEQUAL: a |= R128_ALPHA_TEST_NEQUAL;       break;
-    case GL_ALWAYS:   a |= R128_ALPHA_TEST_ALWAYS;
-	break;
-    default:
-	/* ERROR!!! */
-	return;
-    }
-
-    if (r128ctx->regs.misc_3d_state_cntl_reg != a) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.misc_3d_state_cntl_reg = a;
-
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_ALPHASTATE;
-    }
-}
-
-static void r128DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    CARD32         b       = r128ctx->regs.misc_3d_state_cntl_reg;
-
-    b &= ~(R128_ALPHA_BLEND_SRC_MASK | R128_ALPHA_BLEND_DST_MASK);
-
-    switch (sfactor) {
-    case GL_ZERO:                     b |= R128_ALPHA_BLEND_SRC_ZERO;
-	break;
-    case GL_ONE:                      b |= R128_ALPHA_BLEND_SRC_ONE;
-	break;
-    case GL_DST_COLOR:                b |= R128_ALPHA_BLEND_SRC_DESTCOLOR;
-	break;
-    case GL_ONE_MINUS_DST_COLOR:      b |= R128_ALPHA_BLEND_SRC_INVDESTCOLOR;
-	break;
-    case GL_SRC_ALPHA:                b |= R128_ALPHA_BLEND_SRC_SRCALPHA;
-	break;
-    case GL_ONE_MINUS_SRC_ALPHA:      b |= R128_ALPHA_BLEND_SRC_INVSRCALPHA;
-	break;
-    case GL_DST_ALPHA:                b |= R128_ALPHA_BLEND_SRC_DESTALPHA;
-	break;
-    case GL_ONE_MINUS_DST_ALPHA:      b |= R128_ALPHA_BLEND_SRC_INVDESTALPHA;
-	break;
-    case GL_SRC_ALPHA_SATURATE:       b |= R128_ALPHA_BLEND_SRC_SRCALPHASAT;
-	break;
-#if 0
-	/* FIXME: These are not supported directly by the Rage 128.
-           They could be emulated using something like the TexEnv
-           modes. */
-    case GL_CONSTANT_COLOR:           b |= 0;
-	break;
-    case GL_ONE_MINUS_CONSTANT_COLOR: b |= 0;
-	break;
-    case GL_CONSTANT_ALPHA:           b |= 0;
-	break;
-    case GL_ONE_MINUS_CONSTANT_ALPHA: b |= 0;
-	break;
-#endif
-    default:
-	/* ERROR!!! */
-	return;
-    }
-
-    switch (dfactor) {
-    case GL_ZERO:                     b |= R128_ALPHA_BLEND_DST_ZERO;
-	break;
-    case GL_ONE:                      b |= R128_ALPHA_BLEND_DST_ONE;
-	break;
-    case GL_SRC_COLOR:                b |= R128_ALPHA_BLEND_DST_SRCCOLOR;
-	break;
-    case GL_ONE_MINUS_SRC_COLOR:      b |= R128_ALPHA_BLEND_DST_INVSRCCOLOR;
-	break;
-    case GL_SRC_ALPHA:                b |= R128_ALPHA_BLEND_DST_SRCALPHA;
-	break;
-    case GL_ONE_MINUS_SRC_ALPHA:      b |= R128_ALPHA_BLEND_DST_INVSRCALPHA;
-	break;
-    case GL_DST_ALPHA:                b |= R128_ALPHA_BLEND_DST_DESTALPHA;
-	break;
-    case GL_ONE_MINUS_DST_ALPHA:      b |= R128_ALPHA_BLEND_DST_INVDESTALPHA;
-	break;
-#if 0
-	/* FIXME: These are not supported directly by the Rage 128.
-           They could be emulated using something like the TexEnv
-           modes. */
-    case GL_CONSTANT_COLOR:           b |= 0;
-	break;
-    case GL_ONE_MINUS_CONSTANT_COLOR: b |= 0;
-	break;
-    case GL_CONSTANT_ALPHA:           b |= 0;
-	break;
-    case GL_ONE_MINUS_CONSTANT_ALPHA: b |= 0;
-	break;
-#endif
-    default:
-	/* ERROR!!! */
-	return;
-    }
-
-    if (r128ctx->regs.misc_3d_state_cntl_reg != b) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.misc_3d_state_cntl_reg = b;
-
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_ALPHASTATE;
-    }
-}
-
-static void r128DDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
-				    GLenum dfactorRGB, GLenum sfactorA,
-				    GLenum dfactorA)
-{
-    if (sfactorRGB != sfactorA || dfactorRGB != dfactorA) {
-	/* ERROR!!! */
-	return;
-    }
-
-    r128DDBlendFunc(ctx, sfactorRGB, dfactorRGB);
-}
-
-static void r128DDClearDepth(GLcontext *ctx, GLclampd d)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-
-    switch (r128ctx->regs.z_sten_cntl_c & R128_Z_PIX_WIDTH_MASK) {
-    case R128_Z_PIX_WIDTH_16: r128ctx->ClearDepth = d * 0x0000ffff; break;
-    case R128_Z_PIX_WIDTH_24: r128ctx->ClearDepth = d * 0x00ffffff; break;
-    case R128_Z_PIX_WIDTH_32: r128ctx->ClearDepth = d * 0xffffffff; break;
-    default: return;
-    }
-}
-
-static void r128DDCullFace(GLcontext *ctx, GLenum mode)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    CARD32         f       = r128ctx->regs.pm4_vc_fpu_setup;
-
-    if (!ctx->Polygon.CullFlag) return;
-
-    f &= ~(R128_BACKFACE_MASK | R128_FRONTFACE_MASK);
-
-    switch (mode) {
-    case GL_FRONT:          f |= R128_BACKFACE_SOLID;  break;
-    case GL_BACK:           f |= R128_FRONTFACE_SOLID; break;
-    case GL_FRONT_AND_BACK:                            break;
-    default: return;
-    }
-
-    if (r128ctx->regs.pm4_vc_fpu_setup != f) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.pm4_vc_fpu_setup = f;
-
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_SETUPSTATE;
-    }
-}
-
-static void r128DDFrontFace(GLcontext *ctx, GLenum mode)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    CARD32         f       = r128ctx->regs.pm4_vc_fpu_setup;
-
-    f &= ~R128_FRONT_DIR_MASK;
-
-    switch (mode) {
-    case GL_CW:  f |= R128_FRONT_DIR_CW;  break;
-    case GL_CCW: f |= R128_FRONT_DIR_CCW; break;
-    default: return;
-    }
-
-    if (r128ctx->regs.pm4_vc_fpu_setup != f) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.pm4_vc_fpu_setup = f;
-
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_SETUPSTATE;
-    }
-}
-
-static void r128DDDepthFunc(GLcontext *ctx, GLenum func)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    CARD32         z       = r128ctx->regs.z_sten_cntl_c;
-
-    z &= ~R128_Z_TEST_MASK;
-
-    switch (func) {
-    case GL_NEVER:    z |= R128_Z_TEST_NEVER;        break;
-    case GL_LESS:     z |= R128_Z_TEST_LESS;         break;
-    case GL_LEQUAL:   z |= R128_Z_TEST_LESSEQUAL;    break;
-    case GL_EQUAL:    z |= R128_Z_TEST_EQUAL;        break;
-    case GL_GEQUAL:   z |= R128_Z_TEST_GREATEREQUAL; break;
-    case GL_GREATER:  z |= R128_Z_TEST_GREATER;      break;
-    case GL_NOTEQUAL: z |= R128_Z_TEST_NEQUAL;       break;
-    case GL_ALWAYS:   z |= R128_Z_TEST_ALWAYS;       break;
-    default: return;
-    }
-
-    if (r128ctx->regs.z_sten_cntl_c != z) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.z_sten_cntl_c = z;
-
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_ZSTENSTATE;
-    }
-}
-
-static void r128DDDepthMask(GLcontext *ctx, GLboolean flag)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    CARD32         t       = r128ctx->regs.tex_cntl_c;
-
-    if (flag) t |=  R128_Z_WRITE_ENABLE;
-    else      t &= ~R128_Z_WRITE_ENABLE;
-
-    if (r128ctx->regs.tex_cntl_c != t) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.tex_cntl_c = t;
-
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_ENGINESTATE;
-    }
+   if ( r128ctx->setup.plane_3d_mask_c != mask ) {
+      r128ctx->setup.plane_3d_mask_c = mask;
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
+   }
 }
 
-static void r128DDLightModelfv(GLcontext *ctx, GLenum pname,
-			       const GLfloat *param)
+static GLboolean r128DDColorMask( GLcontext *ctx,
+				  GLboolean r, GLboolean g,
+				  GLboolean b, GLboolean a )
 {
-   if (pname == GL_LIGHT_MODEL_COLOR_CONTROL)
-   {
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   FLUSH_BATCH( r128ctx );
+   r128ctx->new_state |= R128_NEW_MASKS;
+
+   return GL_TRUE;
+}
+
+
+/* =============================================================
+ * Rendering attributes
+ *
+ * We really don't want to recalculate all this every time we bind a
+ * texture.  These things shouldn't change all that often, so it makes
+ * sense to break them out of the core texture state update routines.
+ */
+
+static void r128UpdateRenderAttrib( GLcontext *ctx )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   CARD32 t = r128ctx->setup.tex_cntl_c;
+   CARD32 bias = r128ctx->lod_bias & 0xff;;
+
+   t &= ~R128_LOD_BIAS_MASK;
+   t |= (bias << R128_LOD_BIAS_SHIFT);
+
+   if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ) {
+      t |=  R128_SPEC_LIGHT_ENABLE;
+   } else {
+      t &= ~R128_SPEC_LIGHT_ENABLE;
+   }
+
+   if ( ctx->Color.DitherFlag ) {
+      t |=  R128_DITHER_ENABLE;
+   } else {
+      t &= ~R128_DITHER_ENABLE;
+   }
+
+   if ( r128ctx->setup.tex_cntl_c != t ) {
+      r128ctx->setup.tex_cntl_c = t;
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT;
+   }
+}
+
+static void r128DDLightModelfv( GLcontext *ctx, GLenum pname,
+				const GLfloat *param )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
+      FLUSH_BATCH( r128ctx );
+      r128ctx->new_state |= R128_NEW_RENDER;
+   }
+}
+
+static void r128DDShadeModel( GLcontext *ctx, GLenum mode )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   CARD32 s = r128ctx->setup.pm4_vc_fpu_setup;
+
+   s &= ~R128_FPU_COLOR_MASK;
+
+   switch ( mode ) {
+   case GL_FLAT:
+      s |= R128_FPU_COLOR_FLAT;
+      break;
+   case GL_SMOOTH:
+      s |= R128_FPU_COLOR_GOURAUD;
+      break;
+   default:
+      return;
+   }
+
+   if ( r128ctx->setup.pm4_vc_fpu_setup != s ) {
+      FLUSH_BATCH( r128ctx );
+      r128ctx->setup.pm4_vc_fpu_setup = s;
+
+      r128ctx->new_state |= R128_NEW_CONTEXT;
+      r128ctx->dirty |= R128_UPLOAD_SETUP;
+   }
+}
+
+
+/* =============================================================
+ * Window position
+ */
+
+void r128UpdateWindow( GLcontext *ctx )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   int x = r128ctx->driDrawable->x;
+   int y = r128ctx->driDrawable->y;
+
+   r128ctx->setup.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) |
+				      (x << R128_WINDOW_X_SHIFT));
+
+   r128ctx->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_WINDOW;
+}
+
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void r128DDClearColor( GLcontext *ctx,
+			      GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   r128ctx->ClearColor = r128PackColor( r128ctx->r128Screen->bpp,
+					r, g, b, a );
+}
+
+static void r128DDColor( GLcontext *ctx,
+			 GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   r128ctx->Color = r128PackColor( r128ctx->r128Screen->bpp,
+				   r, g, b, a );
+}
+
+static void r128DDLogicOpCode( GLcontext *ctx, GLenum opcode )
+{
+   if ( ctx->Color.ColorLogicOpEnabled ) {
       r128ContextPtr r128ctx = R128_CONTEXT( ctx );
-      CARD32         t       = r128ctx->regs.tex_cntl_c;
+
+      FLUSH_BATCH( r128ctx );
+
+      if ( opcode == GL_COPY ) {
+         r128ctx->Fallback &= ~R128_FALLBACK_LOGICOP;
+      } else {
+         r128ctx->Fallback |= R128_FALLBACK_LOGICOP;
+      }
+   }
+}
 
-      if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
-	 t |=  R128_SPEC_LIGHT_ENABLE;
-      else
-	 t &= ~R128_SPEC_LIGHT_ENABLE;
-
-      if (r128ctx->regs.tex_cntl_c != t) {
-	 r128FlushVertices(r128ctx);
-	 r128ctx->regs.tex_cntl_c = t;
-
-	 /* FIXME: Load into hardware now??? */
-	 r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	 r128ctx->dirty_context |= R128_CTX_ENGINESTATE;
+static GLboolean r128DDSetDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   int found = GL_TRUE;
+
+   FLUSH_BATCH( r128ctx );
+
+   if ( r128ctx->DrawBuffer != mode ) {
+      r128ctx->DrawBuffer = mode;
+      r128ctx->Fallback &= ~R128_FALLBACK_DRAW_BUFFER;
+
+      switch ( mode ) {
+      case GL_FRONT_LEFT:
+	 r128ctx->drawX      = r128ctx->r128Screen->frontX;
+	 r128ctx->drawY      = r128ctx->r128Screen->frontY;
+	 r128ctx->drawOffset = r128ctx->r128Screen->frontOffset;
+	 r128ctx->drawPitch  = r128ctx->r128Screen->frontPitch;
+	 r128ctx->readX      = r128ctx->r128Screen->frontX;
+	 r128ctx->readY      = r128ctx->r128Screen->frontY;
+	 break;
+      case GL_BACK_LEFT:
+	 r128ctx->drawX      = r128ctx->r128Screen->backX;
+	 r128ctx->drawY      = r128ctx->r128Screen->backY;
+	 r128ctx->drawOffset = r128ctx->r128Screen->backOffset;
+	 r128ctx->drawPitch  = r128ctx->r128Screen->backPitch;
+	 r128ctx->readX      = r128ctx->r128Screen->backX;
+	 r128ctx->readY      = r128ctx->r128Screen->backY;
+	 break;
+      default:
+	 r128ctx->Fallback |= R128_FALLBACK_DRAW_BUFFER;
+	 found = GL_FALSE;
+	 break;
       }
+
+      r128ctx->setup.dst_pitch_offset_c = (((r128ctx->drawPitch/8) << 21) |
+					   (r128ctx->drawOffset >> 5));
+      r128ctx->new_state |= R128_NEW_WINDOW;
+   }
+
+   return found;
+}
+
+static void r128DDSetReadBuffer( GLcontext *ctx,
+				 GLframebuffer *colorBuffer,
+				 GLenum mode )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   r128ctx->Fallback &= ~R128_FALLBACK_READ_BUFFER;
+
+   switch ( mode ) {
+   case GL_FRONT_LEFT:
+      r128ctx->readOffset = r128ctx->r128Screen->frontOffset;
+      r128ctx->readPitch  = r128ctx->r128Screen->frontPitch;
+      r128ctx->readX      = r128ctx->r128Screen->frontX;
+      r128ctx->readY      = r128ctx->r128Screen->frontY;
+      break;
+   case GL_BACK_LEFT:
+      r128ctx->readOffset = r128ctx->r128Screen->backOffset;
+      r128ctx->readPitch  = r128ctx->r128Screen->backPitch;
+      r128ctx->readX      = r128ctx->r128Screen->backX;
+      r128ctx->readY      = r128ctx->r128Screen->backY;
+      break;
+   default:
+      r128ctx->Fallback |= R128_FALLBACK_READ_BUFFER;
+      break;
    }
 }
 
 
-static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
+/* =============================================================
+ * Polygon stipple
+ */
+
+static void r128DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    CARD32         t       = r128ctx->regs.tex_cntl_c;
-    CARD32         f       = r128ctx->regs.pm4_vc_fpu_setup;
-
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
-	fprintf(stderr, "r128DDEnable( %p, 0x%x = %s )\n",
-		ctx, cap, state ? "GL_TRUE" : "GL_FALSE");
-    }
-
-    switch (cap) {
-    case GL_ALPHA_TEST:
-	if (state) t |=  R128_ALPHA_TEST_ENABLE;
-	else       t &= ~R128_ALPHA_TEST_ENABLE;
-	break;
-
-    case GL_AUTO_NORMAL: return;
-
-    case GL_BLEND:
-	if (state) t |=  R128_ALPHA_ENABLE;
-	else       t &= ~R128_ALPHA_ENABLE;
-	break;
-
-    case GL_CLIP_PLANE0:
-    case GL_CLIP_PLANE1:
-    case GL_CLIP_PLANE2:
-    case GL_CLIP_PLANE3:
-    case GL_CLIP_PLANE4:
-    case GL_CLIP_PLANE5:
-    case GL_COLOR_MATERIAL: return;
-
-    case GL_CULL_FACE:
-        if (ctx->PB->primitive == GL_POLYGON) {
-	    f &= ~(R128_BACKFACE_MASK | R128_FRONTFACE_MASK);
-	    if (state) {
-	        switch (ctx->Polygon.CullFaceMode) {
-	        case GL_FRONT:          f |= R128_BACKFACE_SOLID;  break;
-	        case GL_BACK:           f |= R128_FRONTFACE_SOLID; break;
-	        case GL_FRONT_AND_BACK:                            break;
-	        default: return;
-	        }
-	    } else {
-	        f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID;
-	    }
-        }
-	break;
-
-    case GL_DEPTH_TEST:
-	if (state) t |=  R128_Z_ENABLE;
-	else       t &= ~R128_Z_ENABLE;
-	break;
-
-    case GL_DITHER:
-	if (state) t |=  R128_DITHER_ENABLE;
-	else       t &= ~R128_DITHER_ENABLE;
-	break;
-
-    case GL_FOG:
-	if (state) t |=  R128_FOG_ENABLE;
-	else       t &= ~R128_FOG_ENABLE;
-	break;
-
-    case GL_LIGHT0:
-    case GL_LIGHT1:
-    case GL_LIGHT2:
-    case GL_LIGHT3:
-    case GL_LIGHT4:
-    case GL_LIGHT5:
-    case GL_LIGHT6:
-    case GL_LIGHT7:
-    case GL_LIGHTING:
-    case GL_LINE_SMOOTH:
-    case GL_LINE_STIPPLE:
-    case GL_INDEX_LOGIC_OP:
-    case GL_COLOR_LOGIC_OP:
-    case GL_MAP1_COLOR_4:
-    case GL_MAP1_INDEX:
-    case GL_MAP1_NORMAL:
-    case GL_MAP1_TEXTURE_COORD_1:
-    case GL_MAP1_TEXTURE_COORD_2:
-    case GL_MAP1_TEXTURE_COORD_3:
-    case GL_MAP1_TEXTURE_COORD_4:
-    case GL_MAP1_VERTEX_3:
-    case GL_MAP1_VERTEX_4:
-    case GL_MAP2_COLOR_4:
-    case GL_MAP2_INDEX:
-    case GL_MAP2_NORMAL:
-    case GL_MAP2_TEXTURE_COORD_1:
-    case GL_MAP2_TEXTURE_COORD_2:
-    case GL_MAP2_TEXTURE_COORD_3:
-    case GL_MAP2_TEXTURE_COORD_4:
-    case GL_MAP2_VERTEX_3:
-    case GL_MAP2_VERTEX_4:
-    case GL_NORMALIZE:
-    case GL_POINT_SMOOTH:
-    case GL_POLYGON_SMOOTH:
-    case GL_POLYGON_STIPPLE:
-    case GL_POLYGON_OFFSET_POINT:
-    case GL_POLYGON_OFFSET_LINE:
-    case GL_POLYGON_OFFSET_FILL:
-    case GL_RESCALE_NORMAL_EXT: return;
-
-    case GL_SCISSOR_TEST:
-	/* FIXME: Hook up the software scissor */
-#if 0
-	r128ctx->Scissor = state;
-#endif
-	break;
-
-    case GL_SHARED_TEXTURE_PALETTE_EXT:
-    case GL_STENCIL_TEST: return;
-
-    case GL_TEXTURE_1D:
-    case GL_TEXTURE_2D:
-    case GL_TEXTURE_3D:
-	/* This is handled in r128UpdateTex[01]State() */
-	r128ctx->dirty |= R128_UPDATE_TEXSTATE;
-	break;
-
-    case GL_TEXTURE_GEN_Q:
-    case GL_TEXTURE_GEN_R:
-    case GL_TEXTURE_GEN_S:
-    case GL_TEXTURE_GEN_T: return;
-
-	/* Client state */
-    case GL_VERTEX_ARRAY:
-    case GL_NORMAL_ARRAY:
-    case GL_COLOR_ARRAY:
-    case GL_INDEX_ARRAY:
-    case GL_TEXTURE_COORD_ARRAY:
-    case GL_EDGE_FLAG_ARRAY: return;
-
-    default: return;
-    }
-
-    if (r128ctx->regs.tex_cntl_c != t) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.tex_cntl_c = t;
-
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_ENGINESTATE;
-    }
-    if (r128ctx->regs.pm4_vc_fpu_setup != f) {
-	r128FlushVertices(r128ctx);
-	r128ctx->regs.pm4_vc_fpu_setup = f;
-
-	/* FIXME: Load into hardware now??? */
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_SETUPSTATE;
-    }
-
-}
-
-static void r128DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    GLubyte        c[4];
-    CARD32         col;
-    floatTOint     fog;
-    GLenum         mode;
-
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
-	fprintf(stderr, "r128DDFogfv(%p, 0x%x)\n", ctx, pname);
-    }
-
-    switch (pname) {
-    case GL_FOG_MODE:
-	mode = (GLenum)(GLint)*param;
-	if (r128ctx->FogMode != mode) {
-	    r128FlushVertices(r128ctx);
-	    r128ctx->FogMode = mode;
-
-	    /* FIXME: Load into hardware now??? */
-	    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	    r128ctx->dirty_context |= R128_CTX_FOGTABLE;
-	}
-	break;
-
-    case GL_FOG_DENSITY:
-	fog.f = *param;
-	if (r128ctx->regs.fog_3d_table_density != fog.i) {
-	    r128FlushVertices(r128ctx);
-	    r128ctx->regs.fog_3d_table_density = fog.i;
-
-	    /* FIXME: Load into hardware now??? */
-	    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	    r128ctx->dirty_context |= R128_CTX_FOGSTATE;
-	}
-	break;
-
-    case GL_FOG_START:
-	fog.f = *param;
-	if (r128ctx->regs.fog_3d_table_start != fog.i) {
-	    r128FlushVertices(r128ctx);
-	    r128ctx->regs.fog_3d_table_start = fog.i;
-
-	    /* FIXME: Load into hardware now??? */
-	    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	    r128ctx->dirty_context |= R128_CTX_FOGSTATE;
-	}
-	break;
-
-    case GL_FOG_END:
-	fog.f = *param;
-	if (r128ctx->regs.fog_3d_table_end != fog.i) {
-	    r128FlushVertices(r128ctx);
-	    r128ctx->regs.fog_3d_table_end = fog.i;
-
-	    /* FIXME: Load into hardware now??? */
-	    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	    r128ctx->dirty_context |= R128_CTX_FOGSTATE;
-	}
-	break;
-
-    case GL_FOG_COLOR:
-	FLOAT_RGBA_TO_UBYTE_RGBA(c, ctx->Fog.Color);
-	col = r128PackColor(32, c[0], c[1], c[2], c[3]);
-	if (r128ctx->regs.fog_color_c != col) {
-	    r128FlushVertices(r128ctx);
-	    r128ctx->regs.fog_color_c = col;
-
-	    /* FIXME: Load into hardware now??? */
-	    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	    r128ctx->dirty_context |= R128_CTX_FOGSTATE;
-	}
-	break;
-
-    default:
-	return;
-    }
-}
-
-static void r128DDScissor(GLcontext *ctx,
-			  GLint x, GLint y, GLsizei w, GLsizei h)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-
-    r128ctx->ScissorRect.x1 = x;
-    r128ctx->ScissorRect.y1 = r128ctx->driDrawable->h - (y + h);
-    r128ctx->ScissorRect.x2 = x + w;
-    r128ctx->ScissorRect.y2 = r128ctx->driDrawable->h - y;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   GLuint *stipple = (GLuint *)mask;
+
+   FLUSH_BATCH( r128ctx );
+   ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
+
+   r128ctx->setup.dp_gui_master_cntl_c &= ~R128_GMC_BRUSH_NONE;
+
+   if ( ctx->Polygon.StippleFlag && ctx->PB->primitive == GL_POLYGON ) {
+      r128ctx->setup.dp_gui_master_cntl_c |= R128_GMC_BRUSH_32x32_MONO_FG_LA;
+   } else {
+      r128ctx->setup.dp_gui_master_cntl_c |= R128_GMC_BRUSH_SOLID_COLOR;
+   }
+
+   LOCK_HARDWARE( r128ctx );
+
+   drmR128PolygonStipple( r128ctx->driFd, stipple );
+
+   UNLOCK_HARDWARE( r128ctx );
+
+   r128ctx->new_state |= R128_NEW_CONTEXT;
+   r128ctx->dirty |= R128_UPLOAD_CONTEXT;
 }
 
-/* Initialize the driver's state functions */
-void r128DDInitStateFuncs(GLcontext *ctx)
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void r128DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
 {
-    ctx->Driver.UpdateState            = r128DDUpdateState;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s( %s = %s )\n",
+	       __FUNCTION__, gl_lookup_enum_by_nr( cap ),
+	       state ? "GL_TRUE" : "GL_FALSE" );
+   }
 
-    ctx->Driver.ClearIndex             = NULL;
-    ctx->Driver.ClearColor             = r128DDClearColor;
-    ctx->Driver.Index                  = NULL;
-    ctx->Driver.Color                  = r128DDColor;
-    ctx->Driver.SetDrawBuffer          = r128DDSetDrawBuffer;
-    ctx->Driver.SetReadBuffer          = r128DDSetReadBuffer;
-
-    ctx->Driver.IndexMask              = NULL;
-    ctx->Driver.ColorMask              = r128DDColorMask;
-    ctx->Driver.LogicOp                = NULL;
-    ctx->Driver.Dither                 = r128DDDither;
-
-    ctx->Driver.NearFar                = NULL;
-
-    ctx->Driver.RenderStart            = r128DDUpdateHWState;
-    ctx->Driver.RenderFinish           = NULL;
-    ctx->Driver.RasterSetup            = NULL;
-
-    ctx->Driver.RenderVBClippedTab     = NULL;
-    ctx->Driver.RenderVBCulledTab      = NULL;
-    ctx->Driver.RenderVBRawTab         = NULL;
-
-    ctx->Driver.ReducedPrimitiveChange = r128DDReducedPrimitiveChange;
-    ctx->Driver.MultipassFunc          = NULL;
-
-    ctx->Driver.AlphaFunc              = r128DDAlphaFunc;
-    ctx->Driver.BlendEquation          = NULL;
-    ctx->Driver.BlendFunc              = r128DDBlendFunc;
-    ctx->Driver.BlendFuncSeparate      = r128DDBlendFuncSeparate;
-    ctx->Driver.ClearDepth             = r128DDClearDepth;
-    ctx->Driver.CullFace               = r128DDCullFace;
-    ctx->Driver.FrontFace              = r128DDFrontFace;
-    ctx->Driver.DepthFunc              = r128DDDepthFunc;
-    ctx->Driver.DepthMask              = r128DDDepthMask;
-    ctx->Driver.DepthRange             = NULL;
-    ctx->Driver.Enable                 = r128DDEnable;
-    ctx->Driver.Fogfv                  = r128DDFogfv;
-    ctx->Driver.Hint                   = NULL;
-    ctx->Driver.Lightfv                = NULL;
-    ctx->Driver.LightModelfv           = r128DDLightModelfv;
-    ctx->Driver.PolygonMode            = NULL;
-    ctx->Driver.Scissor                = r128DDScissor;
-    ctx->Driver.ShadeModel             = NULL;
-    ctx->Driver.ClearStencil           = NULL;
-    ctx->Driver.StencilFunc            = NULL;
-    ctx->Driver.StencilMask            = NULL;
-    ctx->Driver.StencilOp              = NULL;
-    ctx->Driver.Viewport               = NULL;
+   switch ( cap ) {
+   case GL_ALPHA_TEST:
+   case GL_BLEND:
+      FLUSH_BATCH( r128ctx );
+      r128ctx->new_state |= R128_NEW_ALPHA;
+      break;
+
+   case GL_CULL_FACE:
+      FLUSH_BATCH( r128ctx );
+      r128ctx->new_state |= R128_NEW_CULL;
+      break;
+
+   case GL_DEPTH_TEST:
+      FLUSH_BATCH( r128ctx );
+      r128ctx->new_state |= R128_NEW_DEPTH;
+      break;
+
+   case GL_DITHER:
+      FLUSH_BATCH( r128ctx );
+      r128ctx->new_state |= R128_NEW_RENDER;
+      break;
+
+   case GL_FOG:
+      FLUSH_BATCH( r128ctx );
+      r128ctx->new_state |= R128_NEW_FOG;
+      break;
+
+   case GL_INDEX_LOGIC_OP:
+   case GL_COLOR_LOGIC_OP:
+      FLUSH_BATCH( r128ctx );
+      if ( state && ctx->Color.LogicOp != GL_COPY ) {
+         r128ctx->Fallback |= R128_FALLBACK_LOGICOP;
+      } else {
+         r128ctx->Fallback &= ~R128_FALLBACK_LOGICOP;
+      }
+      break;
+
+   case GL_SCISSOR_TEST:
+      FLUSH_BATCH( r128ctx );
+      r128ctx->scissor = state;
+      r128ctx->new_state |= R128_NEW_CLIP;
+      break;
+
+   case GL_TEXTURE_1D:
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_3D:
+      FLUSH_BATCH( r128ctx );
+      r128ctx->new_state |= R128_NEW_TEXTURE;
+      break;
+
+   case GL_POLYGON_STIPPLE:
+      if ( (ctx->Driver.TriangleCaps & DD_TRI_STIPPLE) &&
+	   ctx->PB->primitive == GL_POLYGON )
+      {
+	 FLUSH_BATCH( r128ctx );
+	 r128ctx->setup.dp_gui_master_cntl_c &= ~R128_GMC_BRUSH_NONE;
+	 if ( state ) {
+	    r128ctx->setup.dp_gui_master_cntl_c |=
+	       R128_GMC_BRUSH_32x32_MONO_FG_LA;
+	 } else {
+	    r128ctx->setup.dp_gui_master_cntl_c |=
+	       R128_GMC_BRUSH_SOLID_COLOR;
+	 }
+	 r128ctx->new_state |= R128_NEW_CONTEXT;
+	 r128ctx->dirty |= R128_UPLOAD_CONTEXT;
+      }
+      break;
+
+   default:
+      return;
+   }
 }
 
-/* Initialize the context's hardware state */
-void r128DDInitState(r128ContextPtr r128ctx)
+
+/* =============================================================
+ * State initialization, management
+ */
+
+static void r128DDPrintDirty( const char *msg, GLuint state )
 {
-    int    dst_bpp, depth_bpp, pitch, i;
-    CARD32 depthClear;
+   fprintf( stderr,
+	    "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s\n",
+	    msg,
+	    state,
+	    (state & R128_UPLOAD_CORE)		? "core, " : "",
+	    (state & R128_UPLOAD_CONTEXT)	? "context, " : "",
+	    (state & R128_UPLOAD_SETUP)		? "setup, " : "",
+	    (state & R128_UPLOAD_TEX0)		? "tex0, " : "",
+	    (state & R128_UPLOAD_TEX1)		? "tex1, " : "",
+	    (state & R128_UPLOAD_TEX0IMAGES)	? "tex0 images, " : "",
+	    (state & R128_UPLOAD_TEX1IMAGES)	? "tex1 images, " : "",
+	    (state & R128_UPLOAD_MASKS)		? "masks, " : "",
+	    (state & R128_UPLOAD_WINDOW)	? "window, " : "",
+	    (state & R128_UPLOAD_CLIPRECTS)	? "cliprects, " : "",
+	    (state & R128_REQUIRE_QUIESCENCE)	? "quiescence, " : "" );
+}
 
-    pitch = r128ctx->r128Screen->fbStride / r128ctx->r128Screen->bpp;
+/*
+ * Load the current context's state into the hardware.
+ *
+ * NOTE: Be VERY careful about ensuring the context state is marked for
+ * upload, the only place it shouldn't be uploaded is when the setup
+ * state has changed in ReducedPrimitiveChange as this comes right after
+ * a state update.
+ *
+ * Blits of any type should always upload the context and masks after
+ * they are done.
+ */
+void r128EmitHwStateLocked( r128ContextPtr r128ctx )
+{
+   R128SAREAPrivPtr sarea = r128ctx->sarea;
+   r128_context_regs_t *regs = &(r128ctx->setup);
+   r128TexObjPtr t0 = r128ctx->CurrentTexObj[0];
+   r128TexObjPtr t1 = r128ctx->CurrentTexObj[1];
 
-    switch (r128ctx->r128Screen->pixel_code) {
-    case  8: dst_bpp = R128_GMC_DST_8BPP_CI; break;
-    case 15: dst_bpp = R128_GMC_DST_15BPP;   break;
-    case 16: dst_bpp = R128_GMC_DST_16BPP;   break;
-    case 24: dst_bpp = R128_GMC_DST_24BPP;   break;
-    case 32: dst_bpp = R128_GMC_DST_32BPP;   break;
-    default:
-	fprintf(stderr, "Error: Unsupported pixel depth %d... exiting\n",
-		r128ctx->r128Screen->pixel_code);
-	exit(-1);
-    }
-
-    /* FIXME: Figure out how to use 16bpp depth buffer in 32bpp mode */
-    switch (r128ctx->glCtx->Visual->DepthBits) {
-    case 16: depthClear = 0x0000ffff; depth_bpp  = R128_Z_PIX_WIDTH_16; break;
-    case 24: depthClear = 0x00ffffff; depth_bpp  = R128_Z_PIX_WIDTH_24; break;
-    case 32: depthClear = 0xffffffff; depth_bpp  = R128_Z_PIX_WIDTH_32; break;
-    default:
-	fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
-		r128ctx->r128Screen->bpp);
-	exit(-1);
-	break;
-    }
-
-    /* Precalculate the depth scale while we're here */
-    switch (r128ctx->glCtx->Visual->DepthBits) {
-    case 16: r128ctx->depth_scale = 1.0 / 65536.0; break;
-    case 24: r128ctx->depth_scale = 1.0 / 16777216.0; break;
-    case 32: r128ctx->depth_scale = 1.0 / 4294967296.0; break;
-    default: r128ctx->depth_scale = 1.0 / 65536.0; break;
-    }
-
-    r128ctx->dirty             = R128_ALL_DIRTY;
-    r128ctx->dirty_context     = R128_CTX_ALL_DIRTY;
-
-    r128ctx->RenderIndex       = R128_FALLBACK_BIT;
-    r128ctx->PointsFunc        = NULL;
-    r128ctx->LineFunc          = NULL;
-    r128ctx->TriangleFunc      = NULL;
-    r128ctx->QuadFunc          = NULL;
-
-    r128ctx->IndirectTriangles = 0;
-    r128ctx->Fallback          = 0;
-
-    if (r128ctx->glCtx->Visual->DBflag) {
-	r128ctx->drawX         = r128ctx->r128Screen->backX;
-	r128ctx->drawY         = r128ctx->r128Screen->backY;
-	r128ctx->readX         = r128ctx->r128Screen->backX;
-	r128ctx->readY         = r128ctx->r128Screen->backY;
-    } else {
-	r128ctx->drawX         = r128ctx->r128Screen->fbX;
-	r128ctx->drawY         = r128ctx->r128Screen->fbY;
-	r128ctx->readX         = r128ctx->r128Screen->fbX;
-	r128ctx->readY         = r128ctx->r128Screen->fbY;
-    }
-
-    r128ctx->ClearColor = 0x00000000;
-    r128ctx->ClearDepth = depthClear;
-
-    r128ctx->regs.scale_3d_cntl =
-	R128_SCALE_DITHER_TABLE         |
-	R128_TEX_CACHE_SIZE_FULL        |
-	R128_DITHER_INIT_RESET          |
-	R128_SCALE_3D_TEXMAP_SHADE      |
-	R128_SCALE_PIX_REPLICATE        |
-	R128_ALPHA_COMB_ADD_CLAMP       |
-	R128_FOG_TABLE                  |
-	R128_ALPHA_BLEND_SRC_ONE        |
-	R128_ALPHA_BLEND_DST_ZERO       |
-	R128_ALPHA_TEST_ALWAYS          |
-	R128_COMPOSITE_SHADOW_CMP_EQUAL |
-	R128_TEX_MAP_ALPHA_IN_TEXTURE   |
-	R128_TEX_CACHE_LINE_SIZE_8QW;
-
-    r128ctx->regs.dst_pitch_offset_c = pitch << R128_PITCH_SHIFT;
-
-    r128ctx->regs.dp_gui_master_cntl =
-	R128_GMC_DST_PITCH_OFFSET_CNTL |
-	R128_GMC_DST_CLIPPING          |
-	R128_GMC_BRUSH_SOLID_COLOR     |
-	dst_bpp                        |
-	R128_GMC_SRC_DATATYPE_COLOR    |
-	R128_GMC_BYTE_MSB_TO_LSB       |
-	R128_GMC_CONVERSION_TEMP_6500  |
-	R128_ROP3_S                    |
-	R128_DP_SRC_SOURCE_MEMORY      |
-	R128_GMC_3D_FCN_EN             |
-	R128_GMC_CLR_CMP_CNTL_DIS      |
-	R128_GMC_AUX_CLIP_DIS          |
-	R128_GMC_WR_MSK_DIS;
-
-    r128ctx->regs.sc_top_left_c     = 0x00000000;
-    r128ctx->regs.sc_bottom_right_c = 0x1fff1fff;
-
-    r128ctx->regs.aux_sc_cntl       = 0x00000000;
-
-    r128ctx->regs.aux1_sc_left      = 0x00000000;
-    r128ctx->regs.aux1_sc_right     = 0x00001fff;
-    r128ctx->regs.aux1_sc_top       = 0x00000000;
-    r128ctx->regs.aux1_sc_bottom    = 0x00001fff;
-
-    r128ctx->regs.aux2_sc_left      = 0x00000000;
-    r128ctx->regs.aux2_sc_right     = 0x00001fff;
-    r128ctx->regs.aux2_sc_top       = 0x00000000;
-    r128ctx->regs.aux2_sc_bottom    = 0x00001fff;
-
-    r128ctx->regs.aux3_sc_left      = 0x00000000;
-    r128ctx->regs.aux3_sc_right     = 0x00001fff;
-    r128ctx->regs.aux3_sc_top       = 0x00000000;
-    r128ctx->regs.aux3_sc_bottom    = 0x00001fff;
-
-    r128ctx->regs.z_offset_c        = (r128ctx->r128Screen->depthX *
-				       (r128ctx->r128Screen->bpp/8) +
-				       r128ctx->r128Screen->depthY *
-				       r128ctx->r128Screen->fbStride);
-    r128ctx->regs.z_pitch_c         = pitch;
-
-    r128ctx->regs.z_sten_cntl_c =
-	depth_bpp                |
-	R128_Z_TEST_LESS         |
-	R128_STENCIL_TEST_ALWAYS |
-	R128_STENCIL_S_FAIL_KEEP |
-	R128_STENCIL_ZPASS_KEEP  |
-	R128_STENCIL_ZFAIL_KEEP;
-
-    r128ctx->regs.tex_cntl_c =
-	R128_Z_WRITE_ENABLE          |
-	R128_SHADE_ENABLE            |
-	R128_DITHER_ENABLE           |
-	R128_ALPHA_IN_TEX_COMPLETE_A |
-	R128_LIGHT_DIS               |
-	R128_ALPHA_LIGHT_DIS         |
-	R128_TEX_CACHE_FLUSH         |
-	(0x0f << R128_LOD_BIAS_SHIFT);
-
-    r128ctx->regs.misc_3d_state_cntl_reg =
-	R128_MISC_SCALE_3D_TEXMAP_SHADE |
-	R128_MISC_SCALE_PIX_REPLICATE   |
-	R128_ALPHA_COMB_ADD_CLAMP       |
-	R128_FOG_TABLE                  |
-	R128_ALPHA_BLEND_SRC_ONE        |
-	R128_ALPHA_BLEND_DST_ZERO       |
-	R128_ALPHA_TEST_ALWAYS;
-
-    r128ctx->regs.texture_clr_cmp_clr_c = 0x00000000;
-    r128ctx->regs.texture_clr_cmp_msk_c = 0xffffffff;
-
-    r128ctx->regs.prim_tex_cntl_c =
-	R128_MIN_BLEND_NEAREST |
-	R128_MAG_BLEND_NEAREST |
-	R128_MIP_MAP_DISABLE   |
-	R128_TEX_CLAMP_S_WRAP  |
-	R128_TEX_CLAMP_T_WRAP;
-
-    r128ctx->regs.prim_texture_combine_cntl_c =
-	R128_COMB_MODULATE          |
-	R128_COLOR_FACTOR_TEX       |
-	R128_INPUT_FACTOR_INT_COLOR |
-	R128_COMB_ALPHA_COPY        |
-	R128_ALPHA_FACTOR_TEX_ALPHA |
-	R128_INP_FACTOR_A_INT_ALPHA;
-
-    r128ctx->regs.tex_size_pitch_c     =
-	(0 << R128_TEX_PITCH_SHIFT)      |
-	(0 << R128_TEX_SIZE_SHIFT)       |
-	(0 << R128_TEX_HEIGHT_SHIFT)     |
-	(0 << R128_TEX_MIN_SIZE_SHIFT)   |
-	(0 << R128_SEC_TEX_PITCH_SHIFT)  |
-	(0 << R128_SEC_TEX_SIZE_SHIFT)   |
-	(0 << R128_SEC_TEX_HEIGHT_SHIFT) |
-	(0 << R128_SEC_TEX_MIN_SIZE_SHIFT);
-
-    for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-	r128ctx->regs.prim_tex_offset[i]  = 0x00000000;
-
-    r128ctx->regs.sec_tex_cntl_c =
-	R128_SEC_SELECT_PRIM_ST;
-
-    r128ctx->regs.sec_tex_combine_cntl_c =
-	R128_COMB_DIS                |
-	R128_COLOR_FACTOR_TEX        |
-	R128_INPUT_FACTOR_PREV_COLOR |
-	R128_COMB_ALPHA_DIS          |
-	R128_ALPHA_FACTOR_TEX_ALPHA  |
-	R128_INP_FACTOR_A_PREV_ALPHA;
-
-    for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-	r128ctx->regs.sec_tex_offset[i] = 0x00000000;
-
-    r128ctx->regs.constant_color_c            = 0x00ffffff;
-    r128ctx->regs.prim_texture_border_color_c = 0x00ffffff;
-    r128ctx->regs.sec_texture_border_color_c  = 0x00ffffff;
-    r128ctx->regs.sten_ref_mask_c             = 0xffff0000;
-    r128ctx->regs.plane_3d_mask_c             = 0xffffffff;
-
-    r128ctx->regs.setup_cntl =
-	R128_COLOR_GOURAUD         |
-	R128_PRIM_TYPE_TRI         |
-#if 1
-	/* FIXME: Let r128 multiply? */
-	R128_TEXTURE_ST_MULT_W     |
-#else
-	/* FIXME: Or, pre multiply? */
-	R128_TEXTURE_ST_DIRECT     |
-#endif
-	R128_STARTING_VERTEX_1     |
-	R128_ENDING_VERTEX_3       |
-	R128_SU_POLY_LINE_NOT_LAST |
-	R128_SUB_PIX_4BITS;
-
-    r128ctx->regs.pm4_vc_fpu_setup =
-	R128_FRONT_DIR_CCW         |
-	R128_BACKFACE_SOLID        |
-	R128_FRONTFACE_SOLID       |
-	R128_FPU_COLOR_GOURAUD     |
-	R128_FPU_SUB_PIX_4BITS     |
-	R128_FPU_MODE_3D           |
-	R128_TRAP_BITS_DISABLE     |
-	R128_XFACTOR_2             |
-	R128_YFACTOR_2             |
-	R128_FLAT_SHADE_VERTEX_OGL |
-	R128_FPU_ROUND_TRUNCATE    |
-	R128_WM_SEL_8DW;
-
-    r128ctx->FogMode                   = GL_EXP;
-    r128ctx->regs.fog_color_c          = 0x00808080;
-    r128ctx->regs.fog_3d_table_start   = 0x00000000;
-    r128ctx->regs.fog_3d_table_end     = 0xffffffff;
-    r128ctx->regs.fog_3d_table_density = 0x00000000;
-
-    r128ctx->regs.window_xy_offset     = 0x00000000;
-
-    r128ctx->regs.dp_write_mask        = 0xffffffff;
-
-    r128ctx->regs.pc_gui_ctlstat       = R128_PC_FLUSH_GUI;
-
-    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-    r128ctx->dirty_context |= R128_CTX_ALL_DIRTY;
-}
-
-/* Upload the fog table for the current fog mode */
-static void r128UploadFogTable(r128ContextPtr r128ctx)
-{
-    int i;
-
-    R128CCE0(R128_CCE_PACKET0, R128_FOG_TABLE_INDEX, 0);
-    R128CCE(0x00000000);
-
-    R128CCE0(R128_CCE_PACKET0_ONE_REG_WR, R128_FOG_TABLE_DATA, 255);
-
-
-    if (0)
-       fprintf(stderr, "uploading fog table for %s\n",
-	       gl_lookup_enum_by_nr(r128ctx->FogMode));
-
-
-    /* KW: I'm not sure we're doing enough here - shouldn't density
-     *  play a role in calculating the exp and exp2 tables -- is the
-     *  card really doing exponent calculations of its own?  Need to
-     *  see the spec...
-     */
-    switch (r128ctx->FogMode) {
-    case GL_LINEAR:
-	for (i = 0; i < 256; i++) {
-	    R128CCE(255 - i);
-	}
-	break;
-    case GL_EXP:
-	for (i = 0; i < 256; i++) {
-	   float arg = (255 - i)/255.0;
-	   float exparg = (exp(arg) - 1) / (M_E - 1); /* range [0,1] */
-	   int result;
-	   FLOAT_COLOR_TO_UBYTE_COLOR(result, exparg);
-	   R128CCE(result);
-	}
-	break;
-    case GL_EXP2:
-	for (i = 0; i < 256; i++) {
-	   float arg = (255 - i)/255.0;
-	   float exparg = (exp(arg*arg) - 1) / (M_E - 1); /* range [0,1] */
-	   int result;
-	   FLOAT_COLOR_TO_UBYTE_COLOR(result, exparg);
-	   R128CCE(result);
-	}
-	break;
-    }
-}
-
-/* Load the current context's state into the hardware */
-/* NOTE: This function is only called while holding the hardware lock */
-static void r128LoadContext(r128ContextPtr r128ctx)
-{
-    int i;
-    int tex_size_pitch_done = GL_FALSE;
-
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
-	fprintf(stderr, "r128LoadContext(%p)\n", r128ctx->glCtx);
-    }
-
-#if 0
-    r128ctx->dirty_context = R128_CTX_ALL_DIRTY;
-#endif
-
-#if 1
-    /* FIXME: Why do these need to be updated even when they don't change? */
-    r128ctx->dirty_context |= (R128_CTX_MISC        |
-			       R128_CTX_ENGINESTATE |
-			       R128_CTX_ALPHASTATE);
-#endif
-
-#if 1
-    /* FIXME: Is this _really_ needed? */
-    if (r128ctx->dirty_context)
-	if (!R128CCE_USE_RING_BUFFER(r128ctx->r128Screen->CCEMode))
-	    r128WaitForIdleLocked(r128ctx);
-#endif
-
-    if (r128ctx->dirty_context & R128_CTX_MISC) {
-	R128CCE1(R128_CCE_PACKET1, R128_SCALE_3D_CNTL, R128_DP_WRITE_MASK);
-	R128CCE(r128ctx->regs.scale_3d_cntl);
-	R128CCE(r128ctx->regs.dp_write_mask);
-
-	R128CCE0(R128_CCE_PACKET0, R128_DST_PITCH_OFFSET_C, 1);
-	R128CCE(r128ctx->regs.dst_pitch_offset_c);
-	R128CCE(r128ctx->regs.dp_gui_master_cntl);
-
-	R128CCE0(R128_CCE_PACKET0, R128_TEXTURE_CLR_CMP_CLR_C, 1);
-	R128CCE(r128ctx->regs.texture_clr_cmp_clr_c);
-	R128CCE(r128ctx->regs.texture_clr_cmp_msk_c);
-
-	R128CCE0(R128_CCE_PACKET0, R128_STEN_REF_MASK_C, 1);
-	R128CCE(r128ctx->regs.sten_ref_mask_c);
-	R128CCE(r128ctx->regs.plane_3d_mask_c);
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_ENGINESTATE) {
-	R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0);
-	R128CCE(r128ctx->regs.tex_cntl_c);
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_TEX0STATE) {
-	R128CCE0(R128_CCE_PACKET0, R128_PRIM_TEX_CNTL_C, 2+R128_TEX_MAXLEVELS);
-	R128CCE(r128ctx->regs.prim_tex_cntl_c);
-	R128CCE(r128ctx->regs.prim_texture_combine_cntl_c);
-	R128CCE(r128ctx->regs.tex_size_pitch_c);
-	for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-	    R128CCE(r128ctx->regs.prim_tex_offset[i]);
-
-	R128CCE0(R128_CCE_PACKET0, R128_PRIM_TEXTURE_BORDER_COLOR_C, 0);
-	R128CCE(r128ctx->regs.prim_texture_border_color_c);
-
-	tex_size_pitch_done = GL_TRUE;
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_TEX1STATE) {
-	if (!tex_size_pitch_done) {
-	    R128CCE0(R128_CCE_PACKET0, R128_TEX_SIZE_PITCH_C, 0);
-	    R128CCE(r128ctx->regs.tex_size_pitch_c);
-	}
-
-	R128CCE0(R128_CCE_PACKET0, R128_SEC_TEX_CNTL_C, 1+R128_TEX_MAXLEVELS);
-	R128CCE(r128ctx->regs.sec_tex_cntl_c);
-	R128CCE(r128ctx->regs.sec_tex_combine_cntl_c);
-	for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-	    R128CCE(r128ctx->regs.sec_tex_offset[i]);
-
-	R128CCE0(R128_CCE_PACKET0, R128_SEC_TEXTURE_BORDER_COLOR_C, 0);
-	R128CCE(r128ctx->regs.sec_texture_border_color_c);
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_TEXENVSTATE) {
-	R128CCE0(R128_CCE_PACKET0, R128_CONSTANT_COLOR_C, 0);
-	R128CCE(r128ctx->regs.constant_color_c);
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_FOGSTATE) {
-	R128CCE0(R128_CCE_PACKET0, R128_FOG_3D_TABLE_START, 1);
-	R128CCE(r128ctx->regs.fog_3d_table_start);
-	R128CCE(r128ctx->regs.fog_3d_table_end);
-
-	R128CCE1(R128_CCE_PACKET1,
-		 R128_FOG_COLOR_C, R128_FOG_3D_TABLE_DENSITY);
-	R128CCE(r128ctx->regs.fog_color_c);
-	R128CCE(r128ctx->regs.fog_3d_table_density);
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_FOGTABLE) {
-	r128UploadFogTable(r128ctx);
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_ZSTENSTATE) {
-	R128CCE0(R128_CCE_PACKET0, R128_Z_STEN_CNTL_C, 0);
-	R128CCE(r128ctx->regs.z_sten_cntl_c);
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_SCISSORS) {
-	R128CCE0(R128_CCE_PACKET0, R128_SC_TOP_LEFT_C, 1);
-	R128CCE(r128ctx->regs.sc_top_left_c);
-	R128CCE(r128ctx->regs.sc_bottom_right_c);
-    }
-
-    if (r128ctx->dirty_context & (R128_CTX_ALPHASTATE |
-				  R128_CTX_FOGSTATE)) {
-	R128CCE0(R128_CCE_PACKET0, R128_MISC_3D_STATE_CNTL_REG, 0);
-	R128CCE(r128ctx->regs.misc_3d_state_cntl_reg);
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_SETUPSTATE) {
-	R128CCE1(R128_CCE_PACKET1, R128_SETUP_CNTL, R128_PM4_VC_FPU_SETUP);
-	R128CCE(r128ctx->regs.setup_cntl);
-	R128CCE(r128ctx->regs.pm4_vc_fpu_setup);
-    }
-
-    if (r128ctx->dirty_context & R128_CTX_WIN_Z_POS) {
-	R128CCE0(R128_CCE_PACKET0, R128_WINDOW_XY_OFFSET, 0);
-	R128CCE(r128ctx->regs.window_xy_offset);
-
-	R128CCE0(R128_CCE_PACKET0, R128_Z_OFFSET_C, 1);
-	R128CCE(r128ctx->regs.z_offset_c);
-	R128CCE(r128ctx->regs.z_pitch_c);
-    }
-
-#if 0
-    if (r128ctx->dirty_context & R128_CTX_FLUSH_PIX_CACHE) {
-	R128CCE0(R128_CCE_PACKET0, R128_PC_GUI_CTLSTAT, 0);
-	R128CCE(r128ctx->regs.pc_gui_ctlstat);
-    }
-#endif
-
-    R128CCE_SUBMIT_PACKET();
-
-    /* Turn off the texture cache flushing */
-    r128ctx->regs.tex_cntl_c     &= ~R128_TEX_CACHE_FLUSH;
-
-    /* Turn off the pixel cache flushing */
-    r128ctx->regs.pc_gui_ctlstat &= ~R128_PC_FLUSH_ALL;
-
-    r128ctx->dirty_context = R128_CTX_CLEAN;
-}
-
-/* Set the hardware clip rects for drawing to the current color buffer */
-/* NOTE: This function is only called while holding the hardware lock */
-void r128SetClipRects(r128ContextPtr r128ctx,
-		      XF86DRIClipRectPtr pc, int nc)
-{
-    if (!pc) return;
-
-    /* Clear any previous auxiliary scissors */
-    r128ctx->regs.aux_sc_cntl = 0x00000000;
-
-    switch (nc) {
-    case 3:
-	R128CCE0(R128_CCE_PACKET0, R128_AUX3_SC_LEFT, 3);
-	R128CCE(pc[2].x1   + r128ctx->drawX);
-	R128CCE(pc[2].x2-1 + r128ctx->drawX);
-	R128CCE(pc[2].y1   + r128ctx->drawY);
-	R128CCE(pc[2].y2-1 + r128ctx->drawY);
-
-	r128ctx->regs.aux_sc_cntl |= R128_AUX3_SC_EN | R128_AUX3_SC_MODE_OR;
-
-    case 2:
-	R128CCE0(R128_CCE_PACKET0, R128_AUX2_SC_LEFT, 3);
-	R128CCE(pc[1].x1   + r128ctx->drawX);
-	R128CCE(pc[1].x2-1 + r128ctx->drawX);
-	R128CCE(pc[1].y1   + r128ctx->drawY);
-	R128CCE(pc[1].y2-1 + r128ctx->drawY);
-
-	r128ctx->regs.aux_sc_cntl |= R128_AUX2_SC_EN | R128_AUX2_SC_MODE_OR;
-
-    case 1:
-	R128CCE0(R128_CCE_PACKET0, R128_AUX1_SC_LEFT, 3);
-	R128CCE(pc[0].x1   + r128ctx->drawX);
-	R128CCE(pc[0].x2-1 + r128ctx->drawX);
-	R128CCE(pc[0].y1   + r128ctx->drawY);
-	R128CCE(pc[0].y2-1 + r128ctx->drawY);
-
-	r128ctx->regs.aux_sc_cntl |= R128_AUX1_SC_EN | R128_AUX1_SC_MODE_OR;
-	break;
-
-    default:
-	return;
-    }
-
-    R128CCE0(R128_CCE_PACKET0, R128_AUX_SC_CNTL, 0);
-    R128CCE(r128ctx->regs.aux_sc_cntl);
-
-    R128CCE_SUBMIT_PACKET();
-}
-
-/* Update the driver's notion of the window position */
-/* NOTE: This function is only called while holding the hardware lock */
-static void r128UpdateWindowPosition(r128ContextPtr r128ctx)
-{
-    int x = r128ctx->driDrawable->x + r128ctx->drawX;
-    int y = r128ctx->driDrawable->y + r128ctx->drawY;
-
-#if 0
-    /* FIXME: Is this _really_ needed? */
-    R128CCE_FLUSH_VB(r128ctx);
-#endif
-    r128ctx->regs.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) |
-				      (x << R128_WINDOW_X_SHIFT));
+   if ( R128_DEBUG & DEBUG_VERBOSE_MSG ) {
+      r128DDPrintDirty( "r128EmitHwStateLocked", r128ctx->dirty );
+   }
+
+   if ( r128ctx->dirty & R128_UPLOAD_TEX0IMAGES ) {
+      if ( t0 ) r128UploadTexImages( r128ctx, t0 );
+      r128ctx->dirty &= ~R128_UPLOAD_TEX0IMAGES;
+   }
+   if ( r128ctx->dirty & R128_UPLOAD_TEX1IMAGES ) {
+      if ( t1 ) r128UploadTexImages( r128ctx, t1 );
+      r128ctx->dirty &= ~R128_UPLOAD_TEX1IMAGES;
+   }
+
+   if ( r128ctx->dirty & (R128_UPLOAD_CONTEXT |
+			  R128_UPLOAD_SETUP |
+			  R128_UPLOAD_MASKS |
+			  R128_UPLOAD_WINDOW |
+			  R128_UPLOAD_CORE |
+			  R128_UPLOAD_TEX0) ) {
+      memcpy( &sarea->ContextState, regs, sizeof(sarea->ContextState) );
+   }
+
+   if ( (r128ctx->dirty & R128_UPLOAD_TEX0) && t0 ) {
+      memcpy( &sarea->TexState[0], &t0->setup, sizeof(sarea->TexState[0]) );
+   }
 
-    /* Recalculate the Z buffer offset since we might be drawing to the
-       back buffer and window_xy_offset affects both color buffer and
-       depth drawing */
-    r128ctx->regs.z_offset_c        = ((r128ctx->r128Screen->depthX -
-					r128ctx->drawX) *
-				       (r128ctx->r128Screen->bpp/8) +
-				       (r128ctx->r128Screen->depthY -
-					r128ctx->drawY) *
-				       r128ctx->r128Screen->fbStride);
+   if ( (r128ctx->dirty & R128_UPLOAD_TEX1) && t1 ) {
+      memcpy( &sarea->TexState[1], &t1->setup, sizeof(sarea->TexState[1]) );
+   }
+
+   sarea->vertsize = r128ctx->vertsize;
+   sarea->vc_format = r128ctx->vc_format;
+
+   /* Turn off the texture cache flushing */
+   r128ctx->setup.tex_cntl_c &= ~R128_TEX_CACHE_FLUSH;
+
+   sarea->dirty |= r128ctx->dirty;
+   r128ctx->dirty &= R128_UPLOAD_CLIPRECTS;
+}
 
-    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-    r128ctx->dirty_context |= R128_CTX_WIN_Z_POS;
+static void r128DDPrintState( const char *msg, GLuint flags )
+{
+   fprintf( stderr,
+	    "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n",
+	    msg,
+	    flags,
+	    (flags & R128_NEW_CONTEXT)	? "context, " : "",
+	    (flags & R128_NEW_ALPHA)	? "alpha, " : "",
+	    (flags & R128_NEW_DEPTH)	? "depth, " : "",
+	    (flags & R128_NEW_FOG)	? "fog, " : "",
+	    (flags & R128_NEW_CLIP)	? "clip, " : "",
+	    (flags & R128_NEW_TEXTURE)	? "texture, " : "",
+	    (flags & R128_NEW_CULL)	? "cull, " : "",
+	    (flags & R128_NEW_MASKS)	? "masks, " : "",
+	    (flags & R128_NEW_WINDOW)	? "window, " : "" );
 }
 
 /* Update the hardware state */
-/* NOTE: This function is only called while holding the hardware lock */
-static void r128UpdateHWStateLocked(r128ContextPtr r128ctx)
+void r128DDUpdateHWState( GLcontext *ctx )
 {
-    if (r128ctx->dirty & R128_REQUIRE_QUIESCENCE)
-	r128WaitForIdleLocked(r128ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   int new_state = r128ctx->new_state;
+
+   if ( new_state )
+   {
+      FLUSH_BATCH( r128ctx );
+
+      r128ctx->new_state = 0;
 
-    /* Update any state that might have changed recently */
+      if ( R128_DEBUG & DEBUG_VERBOSE_MSG )
+	 r128DDPrintState( "r128UpdateHwState", new_state );
 
-    /* Update the clip rects */
-    if (r128ctx->dirty & R128_UPDATE_WINPOS)
-	r128UpdateWindowPosition(r128ctx);
-
-    /* Update texture state and then upload the images */
-    /* Note: Texture images can only be updated after the state has been set */
-    if (r128ctx->dirty & R128_UPDATE_TEXSTATE)
-	r128UpdateTextureState(r128ctx);
-    if (r128ctx->dirty & R128_UPDATE_TEX0IMAGES)
-        r128UploadTexImages(r128ctx, r128ctx->CurrentTexObj[0]);
-    if (r128ctx->dirty & R128_UPDATE_TEX1IMAGES)
-        r128UploadTexImages(r128ctx, r128ctx->CurrentTexObj[1]);
-
-    /* Load the state into the hardware */
-    /* Note: This must be done after all other state has been set */
-    if (r128ctx->dirty & R128_UPDATE_CONTEXT)
-	r128LoadContext(r128ctx);
+      /* Update the various parts of the context's state.
+       */
+      if ( new_state & R128_NEW_ALPHA )
+	 r128UpdateAlphaMode( ctx );
 
-    r128ctx->dirty = R128_CLEAN;
+      if ( new_state & R128_NEW_DEPTH )
+	 r128UpdateZMode( ctx );
+
+      if ( new_state & R128_NEW_FOG )
+	 r128UpdateFogAttrib( ctx );
+
+      if ( new_state & R128_NEW_CLIP )
+	 r128UpdateClipping( ctx );
+
+      if ( new_state & R128_NEW_CULL )
+	 r128UpdateCull( ctx );
+
+      if ( new_state & R128_NEW_MASKS )
+	 r128UpdateMasks( ctx );
+
+      if ( new_state & R128_NEW_RENDER )
+	 r128UpdateRenderAttrib( ctx );
+
+      if ( new_state & R128_NEW_WINDOW )
+	 r128UpdateWindow( ctx );
+
+      if ( new_state & R128_NEW_TEXTURE )
+	 r128UpdateTextureState( ctx );
+   }
 }
 
-/* Update the hardware state */
-void r128UpdateHWState(r128ContextPtr r128ctx)
+/* This is called when Mesa switches between rendering triangle
+ * primitives (such as GL_POLYGON, GL_QUADS, GL_TRIANGLE_STRIP, etc),
+ * and lines, points and bitmaps.
+ *
+ * As the r128 uses triangles to render lines and points, it is
+ * necessary to turn off hardware culling when rendering these
+ * primitives.
+ */
+static void r128DDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
 {
-    LOCK_HARDWARE(r128ctx);
-    r128UpdateHWStateLocked(r128ctx);
-    UNLOCK_HARDWARE(r128ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   CARD32 f = r128ctx->setup.pm4_vc_fpu_setup;
+
+   f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID;
+
+   if ( ctx->Polygon.CullFlag && ctx->PB->primitive == GL_POLYGON ) {
+      switch ( ctx->Polygon.CullFaceMode ) {
+      case GL_FRONT:
+	 f &= ~R128_FRONTFACE_SOLID;
+	 break;
+      case GL_BACK:
+	 f &= ~R128_BACKFACE_SOLID;
+	 break;
+      case GL_FRONT_AND_BACK:
+	 f &= ~(R128_BACKFACE_SOLID |
+		R128_FRONTFACE_SOLID);
+	 break;
+      }
+   }
+
+   if ( r128ctx->setup.pm4_vc_fpu_setup != f ) {
+      FLUSH_BATCH( r128ctx );
+      r128ctx->setup.pm4_vc_fpu_setup = f;
+
+      /* NOTE: Only upload the setup state, everything else has been
+       * uploaded by the usual means already.
+       */
+      r128ctx->dirty |= R128_UPLOAD_SETUP;
+   }
+}
+
+
+#define INTERESTED (~(NEW_MODELVIEW |		\
+		      NEW_PROJECTION |		\
+		      NEW_TEXTURE_MATRIX |	\
+		      NEW_USER_CLIP |		\
+		      NEW_CLIENT_STATE))
+
+void r128DDUpdateState( GLcontext *ctx )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   if ( ctx->NewState & INTERESTED ) {
+      r128DDChooseRenderState( ctx );
+      r128DDChooseRasterSetupFunc( ctx );
+   }
+
+   /* Need to do this here to detect texture fallbacks before
+    * setting triangle functions.
+    */
+   if ( r128ctx->new_state & R128_NEW_TEXTURE ) {
+      r128DDUpdateHWState( ctx );
+   }
+
+   if ( !r128ctx->Fallback ) {
+      ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
+      ctx->IndirectTriangles |= r128ctx->IndirectTriangles;
+
+      ctx->Driver.PointsFunc     = r128ctx->PointsFunc;
+      ctx->Driver.LineFunc       = r128ctx->LineFunc;
+      ctx->Driver.TriangleFunc   = r128ctx->TriangleFunc;
+      ctx->Driver.QuadFunc       = r128ctx->QuadFunc;
+   }
 }
 
-/* Update the driver's state */
-/* NOTE: This function is only called while holding the hardware lock */
-void r128UpdateState(r128ContextPtr r128ctx, int winMoved)
+
+/* Initialize the context's hardware state */
+void r128DDInitState( r128ContextPtr r128ctx )
 {
-    R128SAREAPrivPtr sarea = r128ctx->r128Screen->SAREA;
-    int              i;
+   int dst_bpp, depth_bpp;
+   CARD32 bias;
+
+   switch ( r128ctx->r128Screen->bpp ) {
+   case 16: dst_bpp = R128_GMC_DST_16BPP;   break;
+   case 32: dst_bpp = R128_GMC_DST_32BPP;   break;
+   default:
+      fprintf( stderr, "Error: Unsupported pixel depth %d... exiting\n",
+	       r128ctx->r128Screen->bpp );
+      exit( -1 );
+   }
 
-    if (sarea->ctxOwner != r128ctx->driContext->hHWContext) {
-	sarea->ctxOwner = r128ctx->driContext->hHWContext;
-	r128ctx->dirty_context = R128_CTX_ALL_DIRTY;
-	r128LoadContext(r128ctx);
-    }
+   switch ( r128ctx->DepthSize ) {
+   case 16:
+      r128ctx->ClearDepth = 0x0000ffff;
+      depth_bpp = R128_Z_PIX_WIDTH_16;
+      r128ctx->depth_scale = 1.0 / 65536.0;
+      break;
+   case 24:
+      r128ctx->ClearDepth = 0x00ffffff;
+      depth_bpp = R128_Z_PIX_WIDTH_24;
+      r128ctx->depth_scale = 1.0 / 16777216.0;
+      break;
+   case 32:
+      r128ctx->ClearDepth = 0xffffffff;
+      depth_bpp = R128_Z_PIX_WIDTH_32;
+      r128ctx->depth_scale = 1.0 / 4294967296.0;
+      break;
+   default:
+      fprintf( stderr, "Error: Unsupported depth %d... exiting\n",
+	       r128ctx->DepthSize );
+      exit( -1 );
+   }
+
+   r128ctx->ClearColor = 0x00000000;
+
+   r128ctx->RenderIndex  = R128_FALLBACK_BIT;
+   r128ctx->PointsFunc   = NULL;
+   r128ctx->LineFunc     = NULL;
+   r128ctx->TriangleFunc = NULL;
+   r128ctx->QuadFunc     = NULL;
+
+   r128ctx->IndirectTriangles = 0;
+   r128ctx->Fallback = 0;
+
+   if ( r128ctx->glCtx->Visual->DBflag ) {
+      r128ctx->DrawBuffer = GL_BACK_LEFT;
+      r128ctx->drawOffset = r128ctx->readOffset =
+	 r128ctx->r128Screen->backOffset;
+      r128ctx->drawPitch = r128ctx->readPitch =
+	 r128ctx->r128Screen->backPitch;
+   } else {
+      r128ctx->DrawBuffer = GL_FRONT_LEFT;
+      r128ctx->drawOffset = r128ctx->readOffset =
+	 r128ctx->r128Screen->frontOffset;
+      r128ctx->drawPitch = r128ctx->readPitch =
+	 r128ctx->r128Screen->frontPitch;
+   }
 
-    for (i = 0; i < r128ctx->r128Screen->NRTexHeaps; i++)
-	r128AgeTextures(r128ctx, i);
+   /* Harware state:
+    */
+   r128ctx->setup.dst_pitch_offset_c = (((r128ctx->drawPitch/8) << 21) |
+					(r128ctx->drawOffset >> 5));
+
+   r128ctx->setup.dp_gui_master_cntl_c = (R128_GMC_DST_PITCH_OFFSET_CNTL |
+					  R128_GMC_DST_CLIPPING |
+					  R128_GMC_BRUSH_SOLID_COLOR |
+					  dst_bpp |
+					  R128_GMC_SRC_DATATYPE_COLOR |
+					  R128_GMC_BYTE_MSB_TO_LSB |
+					  R128_GMC_CONVERSION_TEMP_6500 |
+					  R128_ROP3_S |
+					  R128_DP_SRC_SOURCE_MEMORY |
+					  R128_GMC_3D_FCN_EN |
+					  R128_GMC_CLR_CMP_CNTL_DIS |
+					  R128_GMC_AUX_CLIP_DIS |
+					  R128_GMC_WR_MSK_DIS);
+
+   r128ctx->setup.sc_top_left_c     = 0x00000000;
+   r128ctx->setup.sc_bottom_right_c = 0x1fff1fff;
+
+   r128ctx->setup.z_offset_c = r128ctx->r128Screen->depthOffset;
+   r128ctx->setup.z_pitch_c = ((r128ctx->r128Screen->depthPitch >> 3) |
+			       R128_Z_TILE);
+
+   r128ctx->setup.z_sten_cntl_c = (depth_bpp |
+				   R128_Z_TEST_LESS |
+				   R128_STENCIL_TEST_ALWAYS |
+				   R128_STENCIL_S_FAIL_KEEP |
+				   R128_STENCIL_ZPASS_KEEP |
+				   R128_STENCIL_ZFAIL_KEEP);
+
+   bias = r128ctx->lod_bias & 0xff;
+   r128ctx->setup.tex_cntl_c = (R128_Z_WRITE_ENABLE |
+				R128_SHADE_ENABLE |
+				R128_DITHER_ENABLE |
+				R128_ALPHA_IN_TEX_COMPLETE_A |
+				R128_LIGHT_DIS |
+				R128_ALPHA_LIGHT_DIS |
+				R128_TEX_CACHE_FLUSH |
+				(bias << R128_LOD_BIAS_SHIFT));
+
+   r128ctx->setup.misc_3d_state_cntl_reg = (R128_MISC_SCALE_3D_TEXMAP_SHADE |
+					    R128_MISC_SCALE_PIX_REPLICATE |
+					    R128_ALPHA_COMB_ADD_CLAMP |
+					    R128_FOG_VERTEX |
+					    R128_ALPHA_BLEND_SRC_ONE |
+					    R128_ALPHA_BLEND_DST_ZERO |
+					    R128_ALPHA_TEST_ALWAYS);
+
+   r128ctx->setup.texture_clr_cmp_clr_c = 0x00000000;
+   r128ctx->setup.texture_clr_cmp_msk_c = 0xffffffff;
+
+   r128ctx->setup.fog_color_c = 0x00000000;
+
+   r128ctx->setup.pm4_vc_fpu_setup = (R128_FRONT_DIR_CCW |
+				      R128_BACKFACE_SOLID |
+				      R128_FRONTFACE_SOLID |
+				      R128_FPU_COLOR_GOURAUD |
+				      R128_FPU_SUB_PIX_4BITS |
+				      R128_FPU_MODE_3D |
+				      R128_TRAP_BITS_DISABLE |
+				      R128_XFACTOR_2 |
+				      R128_YFACTOR_2 |
+				      R128_FLAT_SHADE_VERTEX_OGL |
+				      R128_FPU_ROUND_TRUNCATE |
+				      R128_WM_SEL_8DW);
+
+   r128ctx->setup.setup_cntl = (R128_COLOR_GOURAUD |
+				R128_PRIM_TYPE_TRI |
+				R128_TEXTURE_ST_MULT_W |
+				R128_STARTING_VERTEX_1 |
+				R128_ENDING_VERTEX_3 |
+				R128_SU_POLY_LINE_NOT_LAST |
+				R128_SUB_PIX_4BITS);
+
+   r128ctx->setup.tex_size_pitch_c = 0x00000000;
+   r128ctx->setup.constant_color_c = 0x00ffffff;
+
+   r128ctx->setup.dp_write_mask   = 0xffffffff;
+   r128ctx->setup.sten_ref_mask_c = 0xffff0000;
+   r128ctx->setup.plane_3d_mask_c = 0xffffffff;
+
+   r128ctx->setup.window_xy_offset = 0x00000000;
+
+   r128ctx->setup.scale_3d_cntl = (R128_SCALE_DITHER_TABLE |
+				   R128_TEX_CACHE_SIZE_FULL |
+				   R128_DITHER_INIT_RESET |
+				   R128_SCALE_3D_TEXMAP_SHADE |
+				   R128_SCALE_PIX_REPLICATE |
+				   R128_ALPHA_COMB_ADD_CLAMP |
+				   R128_FOG_VERTEX |
+				   R128_ALPHA_BLEND_SRC_ONE |
+				   R128_ALPHA_BLEND_DST_ZERO |
+				   R128_ALPHA_TEST_ALWAYS |
+				   R128_COMPOSITE_SHADOW_CMP_EQUAL |
+				   R128_TEX_MAP_ALPHA_IN_TEXTURE |
+				   R128_TEX_CACHE_LINE_SIZE_4QW);
+
+   r128ctx->new_state = R128_NEW_ALL;
+}
+
+/* Initialize the driver's state functions */
+void r128DDInitStateFuncs( GLcontext *ctx )
+{
+   ctx->Driver.UpdateState		= r128DDUpdateState;
 
-    if (winMoved) r128ctx->dirty |= R128_UPDATE_WINPOS;
+   ctx->Driver.ClearIndex		= NULL;
+   ctx->Driver.ClearColor		= r128DDClearColor;
+   ctx->Driver.Index			= NULL;
+   ctx->Driver.Color			= r128DDColor;
+   ctx->Driver.SetDrawBuffer		= r128DDSetDrawBuffer;
+   ctx->Driver.SetReadBuffer		= r128DDSetReadBuffer;
+
+   ctx->Driver.IndexMask		= NULL;
+   ctx->Driver.ColorMask		= r128DDColorMask;
+   ctx->Driver.LogicOp			= NULL;
+   ctx->Driver.Dither			= NULL;
+
+   ctx->Driver.NearFar			= NULL;
+
+   ctx->Driver.RenderStart		= r128DDUpdateHWState;
+   ctx->Driver.RenderFinish		= NULL;
+   ctx->Driver.RasterSetup		= NULL;
+
+   ctx->Driver.RenderVBClippedTab	= NULL;
+   ctx->Driver.RenderVBCulledTab	= NULL;
+   ctx->Driver.RenderVBRawTab		= NULL;
+
+   ctx->Driver.ReducedPrimitiveChange	= r128DDReducedPrimitiveChange;
+   ctx->Driver.MultipassFunc		= NULL;
+
+   ctx->Driver.AlphaFunc		= r128DDAlphaFunc;
+   ctx->Driver.BlendEquation		= r128DDBlendEquation;
+   ctx->Driver.BlendFunc		= r128DDBlendFunc;
+   ctx->Driver.BlendFuncSeparate	= r128DDBlendFuncSeparate;
+   ctx->Driver.ClearDepth		= r128DDClearDepth;
+   ctx->Driver.CullFace			= r128DDCullFace;
+   ctx->Driver.FrontFace		= r128DDFrontFace;
+   ctx->Driver.DepthFunc		= r128DDDepthFunc;
+   ctx->Driver.DepthMask		= r128DDDepthMask;
+   ctx->Driver.DepthRange		= NULL;
+   ctx->Driver.Enable			= r128DDEnable;
+   ctx->Driver.Fogfv			= r128DDFogfv;
+   ctx->Driver.Hint			= NULL;
+   ctx->Driver.Lightfv			= NULL;
+   ctx->Driver.LightModelfv		= r128DDLightModelfv;
+   ctx->Driver.LogicOpcode		= r128DDLogicOpCode;
+   ctx->Driver.PolygonMode		= NULL;
+   ctx->Driver.PolygonStipple		= r128DDPolygonStipple;
+   ctx->Driver.Scissor			= r128DDScissor;
+   ctx->Driver.ShadeModel		= r128DDShadeModel;
+   ctx->Driver.ClearStencil		= NULL;
+   ctx->Driver.StencilFunc		= NULL;
+   ctx->Driver.StencilMask		= NULL;
+   ctx->Driver.StencilOp		= NULL;
+   ctx->Driver.Viewport			= NULL;
 }
Index: xc/lib/GL/mesa/src/drv/r128/r128_state.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_state.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_state.h:1.2
--- xc/lib/GL/mesa/src/drv/r128/r128_state.h:1.1	Fri Jun 16 20:03:07 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_state.h	Mon Dec  4 14:21:47 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_state.h,v 1.1 2000/06/17 00:03:07 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_state.h,v 1.2 2000/12/04 19:21:47 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,7 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
@@ -37,14 +38,19 @@
 
 #ifdef GLX_DIRECT_RENDERING
 
-extern void   r128DDInitState(r128ContextPtr r128ctx);
-extern void   r128DDInitStateFuncs(GLcontext *ctx);
+#include "r128_context.h"
 
-extern void   r128UpdateState(r128ContextPtr r128ctx, int winMoved);
-extern void   r128UpdateHWState(r128ContextPtr r128ctx);
+extern void r128DDInitState( r128ContextPtr r128ctx );
+extern void r128DDInitStateFuncs( GLcontext *ctx );
 
-extern void   r128SetClipRects(r128ContextPtr r128ctx,
-			       XF86DRIClipRectPtr pc, int nc);
+extern void r128DDUpdateState( GLcontext *ctx );
+extern void r128DDUpdateHWState( GLcontext *ctx );
+
+extern void r128UpdateWindow( GLcontext *ctx );
+extern void r128SetClipRects( r128ContextPtr r128ctx,
+			      XF86DRIClipRectPtr pc, int nc );
+
+extern void r128EmitHwStateLocked( r128ContextPtr r128ctx );
 
 #endif
 #endif /* _R128_STATE_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_swap.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_swap.c:1.1 xc/lib/GL/mesa/src/drv/r128/r128_swap.c:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_swap.c:1.1	Fri Jun 16 20:03:07 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_swap.c	Mon Dec 18 14:23:37 2000
@@ -1,290 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_swap.c,v 1.1 2000/06/17 00:03:07 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *
- */
-
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
-#include "r128_context.h"
-#include "r128_lock.h"
-#include "r128_reg.h"
-#include "r128_cce.h"
-#include "r128_state.h"
-#include "r128_vb.h"
-#include "r128_tex.h"
-#include "r128_swap.h"
-
-
-#if ENABLE_PERF_BOXES
-
-/*
- * Add hardware commands to draw a filled box for the debugging display.
- */
-static void r128ClearBoxLocked( r128ContextPtr r128ctx,
-				int x, int y, int w, int h,
-				int r, int g, int b )
-{
-    int dst_bpp;
-    int color;
-
-    switch ( r128ctx->r128Screen->bpp ) {
-    case 8:
-	dst_bpp = R128_GMC_DST_8BPP_CI;
-	break;
-    case 16:
-	if ( r128ctx->r128Screen->depth == 15 ) {
-	    dst_bpp = R128_GMC_DST_15BPP;
-	} else {
-	    dst_bpp = R128_GMC_DST_16BPP;
-	}
-	break;
-    case 24:
-	dst_bpp = R128_GMC_DST_24BPP;
-	break;
-    case 32:
-    default:
-	dst_bpp = R128_GMC_DST_32BPP;
-	break;
-    }
-
-    x += r128ctx->driDrawable->x + r128ctx->drawX;
-    y += r128ctx->driDrawable->y + r128ctx->drawY;
-
-    color = r128PackColor( r128ctx->r128Screen->bpp, r, g, b, 0 );
-
-    /* Temporarily disable Z and stencil buffer and texture mapping modes */
-    R128CCE0( R128_CCE_PACKET0, R128_TEX_CNTL_C, 0 );
-    R128CCE( r128ctx->regs.tex_cntl_c & ~(R128_Z_ENABLE |
-					  R128_STENCIL_ENABLE |
-					  R128_TEXMAP_ENABLE) );
-
-    R128CCE3( R128_CCE_PACKET3_CNTL_PAINT_MULTI, 3 );
-    R128CCE( R128_GMC_BRUSH_SOLID_COLOR
-	     | dst_bpp
-	     | R128_GMC_SRC_DATATYPE_COLOR
-	     | R128_ROP3_P
-	     | R128_GMC_3D_FCN_EN		/* FIXME?? */
-	     | R128_GMC_CLR_CMP_CNTL_DIS	/* FIXME?? */
-	     | R128_AUX_CLIP_DIS );		/* FIXME?? */
-    R128CCE( color );
-    R128CCE( (x << 16) | y );
-    R128CCE( (w << 16) | h );
-
-    R128CCE_SUBMIT_PACKET();
-}
-
-/*
- * Draw some small boxes in the corner of the buffer based on some
- * performance information.
- */
-void r128PerformanceBoxesLocked( r128ContextPtr r128ctx )
-{
-    int		w, t;
-
-    if ( !r128ctx->boxes ) {
-	return;
-    }
-
-    /* Draw a box to show we are active, so if it is't seen
-     * it means that it is completely software based rendering
-     */
-    if ( R128CCE_USE_RING_BUFFER( r128ctx->r128Screen->CCEMode ) ) {
-	r128ClearBoxLocked( r128ctx, 4, 4, 8, 8, 255, 0, 255 );
-    } else {
-	r128ClearBoxLocked( r128ctx, 4, 4, 8, 8, 255, 255, 255 );
-    }
-
-    /* Draw a red box if we had to wait for drawing to complete
-     * (software render or texture swap)
-     */
-    if ( r128ctx->c_drawWaits ) {
-	r128ClearBoxLocked( r128ctx, 16, 4, 8, 8, 255, 0, 0 );
-    }
-
-    /* Draw a yellow box if textures were swapped */
-    if ( r128ctx->c_textureSwaps ) {
-	r128ClearBoxLocked( r128ctx, 40, 4, 8, 8, 255, 255, 0 );
-    }
-
-    /* Draw a green box if we had to wait for the previous frame
-     * to complete (full utilization)
-     */
-    if ( !r128ctx->hardwareWentIdle ) {
-	r128ClearBoxLocked( r128ctx, 64, 4, 8, 8, 0, 255, 0 );
-    }
-
-    /* Draw bars to represent the utilization of the vertex buffers */
-    r128ClearBoxLocked( r128ctx, 4, 16, 252, 4, 32, 32, 32 );
-    t = r128ctx->r128Screen->vbRgn.size / r128ctx->r128Screen->vbBufSize;
-    w = 252 * r128ctx->c_vertexBuffers / t;
-    if ( w < 1 ) {
-	w = 1;
-    }
-    if ( r128ctx->c_vertexBuffers > t ) {
-	r128ClearBoxLocked( r128ctx, 4, 16, 252, 4, 255, 32, 32 );
-    } else {
-	r128ClearBoxLocked( r128ctx, 4, 16, w, 4, 196, 128, 128 );
-    }
-}
-
-#endif /* ENABLE_PERF_BOXES */
-
-
-static void delay( void ) {
-/* Prevent an optimizing compiler from removing a spin loop */
-}
-
-/* Throttle the frame rate -- only allow one pending swap buffers
- * request at a time.
- * GTH: We probably don't want a timeout here, as we can wait as
- * long as we want for a frame to complete.  If it never does, then
- * the card has locked.
- */
-static int r128WaitForFrameCompletion( r128ContextPtr r128ctx )
-{
-    unsigned char *R128MMIO = r128ctx->r128Screen->mmio;
-    CARD32 swapAge;
-    int i;
-    int wait = 0;
-
-    while ( 1 ) {
-	swapAge = INREG( R128_SWAP_AGE_REG );
-	if ( r128ctx->lastSwapAge <= swapAge ) {
-	    break;
-	}
-
-	/* Spin in place a bit so we aren't hammering the register */
-	wait++;
-	for ( i = 0 ; i < 256 ; i++ ) {
-	    delay();
-	}
-    }
-
-    /* Increment the frame counter */
-    r128ctx->lastSwapAge = ++swapAge;
-
-    return wait;
-}
-
-
-
-/* Copy the back color buffer to the front color buffer */
-void r128SwapBuffers(r128ContextPtr r128ctx)
-{
-    __DRIdrawablePrivate *dPriv = r128ctx->driDrawable;
-    int                   nc;
-    XF86DRIClipRectPtr    c;
-    int                   dst_bpp;
-
-    switch (r128ctx->r128Screen->bpp) {
-    case 8:
-	dst_bpp = R128_GMC_DST_8BPP_CI;
-	break;
-    case 16:
-	if (r128ctx->r128Screen->depth == 15) dst_bpp = R128_GMC_DST_15BPP;
-	else                                  dst_bpp = R128_GMC_DST_16BPP;
-	break;
-    case 24:
-	dst_bpp = R128_GMC_DST_24BPP;
-	break;
-    case 32:
-    default:
-	dst_bpp = R128_GMC_DST_32BPP;
-	break;
-    }
-
-    LOCK_HARDWARE(r128ctx);
-
-    /* Flush any outstanding vertex buffers */
-    r128FlushVerticesLocked(r128ctx);
-
-    /* Throttle the frame rate -- only allow one pending swap buffers
-     * request at a time.
-     */
-    if ( !r128WaitForFrameCompletion(r128ctx) ) {
-	r128ctx->hardwareWentIdle = 1;
-    } else {
-	r128ctx->hardwareWentIdle = 0;
-    }
-
-#if ENABLE_PERF_BOXES
-    /* Draw the performance boxes */
-    r128PerformanceBoxesLocked(r128ctx);
-#endif
-
-    /* Init the clip rects here in case they changed during the
-       LOCK_HARDWARE macro */
-    c  = dPriv->pClipRects;
-    nc = dPriv->numClipRects;
-
-    /* Cycle through the clip rects */
-    while (nc--) {
-	int fx = c[nc].x1;
-	int fy = c[nc].y1;
-	int fw = c[nc].x2 - fx;
-	int fh = c[nc].y2 - fy;
-	int bx = fx + r128ctx->r128Screen->backX;
-	int by = fy + r128ctx->r128Screen->backY;
-
-	fx += r128ctx->r128Screen->fbX;
-	fy += r128ctx->r128Screen->fbY;
-
-	R128CCE3(R128_CCE_PACKET3_CNTL_BITBLT_MULTI, 3);
-	R128CCE(R128_GMC_BRUSH_NONE
-		| R128_GMC_SRC_DATATYPE_COLOR
-		| R128_DP_SRC_SOURCE_MEMORY
-		| dst_bpp
-		| R128_ROP3_S);
-	R128CCE((bx << 16) | by);
-	R128CCE((fx << 16) | fy);
-	R128CCE((fw << 16) | fh);
-    }
-
-    R128CCE0(R128_CCE_PACKET0, R128_SWAP_AGE_REG, 0);
-    R128CCE(r128ctx->lastSwapAge);
-
-    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-/*      r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; */
-    r128ctx->dirty_context |= (R128_CTX_MISC        |
-			       R128_CTX_ENGINESTATE |
-			       R128_CTX_ALPHASTATE);
-
-    R128CCE_SUBMIT_PACKET();
-
-    UNLOCK_HARDWARE(r128ctx);
-
-#if ENABLE_PERF_BOXES
-    /* Log the performance counters if necessary */
-    r128PerformanceCounters(r128ctx);
-#endif
-}
Index: xc/lib/GL/mesa/src/drv/r128/r128_swap.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_swap.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_swap.h:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_swap.h:1.1	Fri Jun 16 20:03:07 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_swap.h	Mon Dec 18 14:23:37 2000
@@ -1,58 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_swap.h,v 1.1 2000/06/17 00:03:07 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *
- */
-
-#ifndef _R128_SWAP_H_
-#define _R128_SWAP_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-extern void r128SwapBuffers(r128ContextPtr r128ctx);
-
-#if ENABLE_PERF_BOXES
-extern void r128PerformanceBoxesLocked(r128ContextPtr r128ctx);
-
-static __inline void r128PerformanceCounters( r128ContextPtr r128ctx )
-{
-    r128ctx->c_clears = 0;
-    r128ctx->c_drawWaits = 0;
-
-    r128ctx->c_textureSwaps = 0;
-    r128ctx->c_textureBytes = 0;
-
-    r128ctx->c_vertexBuffers = 0;
-}
-#endif
-
-#endif
-#endif /* _R128_SWAP_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_tex.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_tex.c:1.2 xc/lib/GL/mesa/src/drv/r128/r128_tex.c:1.6
--- xc/lib/GL/mesa/src/drv/r128/r128_tex.c:1.2	Mon Jun 26 01:41:29 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_tex.c	Mon Dec  4 14:21:47 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.2 2000/06/26 05:41:29 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.6 2000/12/04 19:21:47 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,292 +28,332 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Gareth Hughes <gareth@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
 #include "r128_context.h"
-#include "r128_lock.h"
 #include "r128_state.h"
-#include "r128_reg.h"
-#include "r128_cce.h"
+#include "r128_ioctl.h"
 #include "r128_vb.h"
 #include "r128_tex.h"
 
 #include "mmath.h"
 #include "simple_list.h"
+#include "enums.h"
+#include "mem.h"
 
+
 static void r128SetTexWrap(r128TexObjPtr t, GLenum srwap, GLenum twrap);
 static void r128SetTexFilter(r128TexObjPtr t, GLenum minf, GLenum magf);
 static void r128SetTexBorderColor(r128TexObjPtr t, GLubyte c[4]);
 
 /* Allocate and initialize hardware state associated with texture `t' */
 /* NOTE: This function is only called while holding the hardware lock */
-static r128TexObjPtr r128CreateTexObj(r128ContextPtr r128ctx,
-				      struct gl_texture_object *tObj)
+static r128TexObjPtr r128CreateTexObj( r128ContextPtr r128ctx,
+				       struct gl_texture_object *tObj )
 {
-    r128TexObjPtr            t;
-    struct gl_texture_image *image;
-    int                      log2Pitch, log2Height, log2Size, log2MinSize;
-    int                      totalSize;
-    int                      i;
-
-    image = tObj->Image[0];
-    if (!image) return NULL; /* ERROR!!! */
-
-    t = (r128TexObjPtr)calloc(1,sizeof(*t));
-    if (!t) return NULL;     /* ERROR!!! */
-
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
-	fprintf(stderr, "r128CreateTexObj(%p)\n", tObj);
-
-    switch (image->Format) {
-    case GL_RGBA:
-    case GL_ALPHA:
-    case GL_LUMINANCE_ALPHA:
-    case GL_INTENSITY:
-	if (r128ctx->r128Screen->bpp == 32) {
-	    t->texelBytes    = 4;
-	    t->textureFormat = R128_DATATYPE_ARGB8888;
-	} else {
-	    t->texelBytes    = 2;
-	    t->textureFormat = R128_DATATYPE_ARGB4444;
-	}
-	break;
-
-    case GL_RGB:
-	if (r128ctx->r128Screen->bpp == 32) {
-	    t->texelBytes    = 4;
-	    t->textureFormat = R128_DATATYPE_ARGB8888;
-	} else {
-	    t->texelBytes    = 2;
-	    t->textureFormat = R128_DATATYPE_RGB565;
-	}
-	break;
-
-    case GL_LUMINANCE:
-	if (r128ctx->r128Screen->bpp == 32) {
-	    t->texelBytes    = 4;
-	    t->textureFormat = R128_DATATYPE_ARGB8888;
-	} else {
-	    t->texelBytes    = 2;
-					/* Use this to get true greys */
-	    t->textureFormat = R128_DATATYPE_ARGB1555;
-	}
-	break;
-
-    case GL_COLOR_INDEX:
-	t->texelBytes    = 1;
-	t->textureFormat = R128_DATATYPE_CI8;
-	break;
-
-    default:
-	/* ERROR!!! */
-	fprintf(stderr, "r128CreateTexObj: bad image->Format\n");
-	free(t);
-	return NULL;
-    }
-
-    /* Calculate dimensions in log domain */
-    for (i = 1, log2Height = 0; i < image->Height; i *= 2) log2Height++;
-    for (i = 1, log2Pitch = 0;  i < image->Width;  i *= 2) log2Pitch++;
-    if (image->Width > image->Height) log2Size = log2Pitch;
-    else                              log2Size = log2Height;
-
-    t->dirty_images = 0;
-
-    /* Calculate mipmap offsets and dimensions */
-    totalSize = 0;
-    for (i = 0; i <= log2Size && tObj->Image[i]; i++) {
-	t->image[i].offset  = totalSize;
-	t->image[i].width   = tObj->Image[i]->Width;
-	t->image[i].height  = tObj->Image[i]->Height;
-	t->dirty_images    |= 1 << i;
-	totalSize          += (tObj->Image[i]->Height *
-			       tObj->Image[i]->Width *
-			       t->texelBytes);
-
-	/* Offsets must be 32-byte aligned for host data blits */
-	totalSize           = (totalSize + 31) & ~31;
-    }
-    log2MinSize = log2Size - i + 1;
-
-    t->totalSize    = totalSize;
-    t->internFormat = image->IntFormat;
-
-    t->bound        = 0;
-    t->heap         = 0; /* This is set in r128UploadTexImages */
-    t->tObj         = tObj;
-
-    t->memBlock     = NULL;
-    t->bufAddr      = NULL;
-
-    t->regs.tex_cntl         = t->textureFormat;
-    t->regs.size_pitch       = ((log2Pitch   << R128_TEX_PITCH_SHIFT)  |
-				(log2Size    << R128_TEX_SIZE_SHIFT)   |
-				(log2Height  << R128_TEX_HEIGHT_SHIFT) |
-				(log2MinSize << R128_TEX_MIN_SIZE_SHIFT));
-    t->regs.border_color     = 0x00000000;
-
-    if (log2MinSize == log2Size ||
-	log2MinSize != 0)
-	t->regs.tex_cntl |= R128_MIP_MAP_DISABLE;
-
-    r128SetTexWrap(t, tObj->WrapS, tObj->WrapT);
-    r128SetTexFilter(t, tObj->MinFilter, tObj->MagFilter);
-    r128SetTexBorderColor(t, tObj->BorderColor);
+   r128TexObjPtr t;
+   struct gl_texture_image *image;
+   int log2Pitch, log2Height, log2Size, log2MinSize;
+   int totalSize;
+   int i;
+
+   image = tObj->Image[0];
+   if ( !image )
+      return NULL;
+
+   t = (r128TexObjPtr)CALLOC( sizeof(*t) );
+   if ( !t )
+      return NULL;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API )
+      fprintf( stderr, "%s( %p )\n", __FUNCTION__, tObj );
+
+   switch ( image->Format ) {
+   case GL_RGBA:
+   case GL_ALPHA:
+   case GL_LUMINANCE_ALPHA:
+   case GL_INTENSITY:
+      if ( r128ctx->r128Screen->bpp == 32 ) {
+	 t->texelBytes = 4;
+	 t->textureFormat = R128_DATATYPE_ARGB8888;
+      } else {
+	 t->texelBytes = 2;
+	 t->textureFormat = R128_DATATYPE_ARGB4444;
+      }
+      break;
+
+   case GL_RGB:
+      if ( r128ctx->r128Screen->bpp == 32 ) {
+	 t->texelBytes = 4;
+	 t->textureFormat = R128_DATATYPE_ARGB8888;
+      } else {
+	 t->texelBytes = 2;
+	 t->textureFormat = R128_DATATYPE_RGB565;
+      }
+      break;
+
+   case GL_LUMINANCE:
+      if ( r128ctx->r128Screen->bpp == 32 ) {
+	 t->texelBytes = 4;
+	 t->textureFormat = R128_DATATYPE_ARGB8888;
+      } else {
+	 t->texelBytes = 2;
+	 /* Use this to get true greys */
+	 t->textureFormat = R128_DATATYPE_ARGB1555;
+      }
+      break;
+
+   case GL_COLOR_INDEX:
+      t->texelBytes = 1;
+      t->textureFormat = R128_DATATYPE_CI8;
+      break;
+
+   default:
+      fprintf( stderr, "%s: bad image->Format\n", __FUNCTION__ );
+      FREE( t );
+      return NULL;
+   }
+
+   /* Calculate dimensions in log domain */
+   for ( i = 1, log2Height = 0 ; i < image->Height ; i *= 2 ) {
+      log2Height++;
+   }
+   for ( i = 1, log2Pitch = 0 ;  i < image->Width ;  i *= 2 ) {
+      log2Pitch++;
+   }
+   if ( image->Width > image->Height ) {
+      log2Size = log2Pitch;
+   } else {
+      log2Size = log2Height;
+   }
+
+   t->dirty_images = 0;
+
+   /* Calculate mipmap offsets and dimensions */
+   totalSize = 0;
+   for ( i = 0 ; i <= log2Size && tObj->Image[i] ; i++ ) {
+      t->image[i].offset = totalSize;
+      t->image[i].width  = tObj->Image[i]->Width;
+      t->image[i].height = tObj->Image[i]->Height;
+
+      t->dirty_images |= (1 << i);
+
+      totalSize += (tObj->Image[i]->Height *
+		    tObj->Image[i]->Width *
+		    t->texelBytes);
+
+      /* Offsets must be 32-byte aligned for host data blits and tiling */
+      totalSize = (totalSize + 31) & ~31;
+   }
+   log2MinSize = log2Size - i + 1;
+
+   t->totalSize = totalSize;
+   t->internFormat = image->IntFormat;
+
+   t->age = 0;
+   t->bound = 0;
+   t->heap = 0;
+   t->tObj = tObj;
+
+   t->memBlock = NULL;
+   t->bufAddr = 0;
+
+   /* Hardware state:
+    */
+   t->setup.tex_cntl = (R128_MIN_BLEND_NEAREST |
+			R128_MAG_BLEND_NEAREST |
+			R128_TEX_CLAMP_S_WRAP |
+			R128_TEX_CLAMP_T_WRAP |
+			t->textureFormat);
+
+   t->setup.tex_combine_cntl = 0x00000000;
+
+   t->setup.tex_size_pitch = ((log2Pitch   << R128_TEX_PITCH_SHIFT) |
+			      (log2Size    << R128_TEX_SIZE_SHIFT) |
+			      (log2Height  << R128_TEX_HEIGHT_SHIFT) |
+			      (log2MinSize << R128_TEX_MIN_SIZE_SHIFT));
+
+   for ( i = 0 ; i < R128_TEX_MAXLEVELS ; i++ ) {
+      t->setup.tex_offset[i]  = 0x00000000;
+   }
+   t->setup.tex_border_color = 0x00000000;
+
+   if ( ( log2MinSize == log2Size ) || ( log2MinSize != 0 ) ) {
+      t->setup.tex_cntl |= R128_MIP_MAP_DISABLE;
+   }
+
+   r128SetTexWrap( t, tObj->WrapS, tObj->WrapT );
+   r128SetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+   r128SetTexBorderColor( t, tObj->BorderColor );
 
-    tObj->DriverData = t;
+   tObj->DriverData = t;
 
-    make_empty_list(t);
+   make_empty_list( t );
 
-    return t;
+   return t;
 }
 
 /* Destroy hardware state associated with texture `t' */
-/* NOTE: This function can be called while holding the hardware lock and
-   while not holding the lock*/
-void r128DestroyTexObj(r128ContextPtr r128ctx, r128TexObjPtr t)
+void r128DestroyTexObj( r128ContextPtr r128ctx, r128TexObjPtr t )
 {
 #if ENABLE_PERF_BOXES
-    /* Bump the performace counter */
-    r128ctx->c_textureSwaps++;
+   /* Bump the performace counter */
+   r128ctx->c_textureSwaps++;
 #endif
-    if (!t) return;
-
-    if (t->memBlock) {
-	mmFreeMem(t->memBlock);
-	t->memBlock = NULL;
-    }
+   if ( !t ) return;
 
-    if (t->tObj)  t->tObj->DriverData                = NULL;
-    if (t->bound) r128ctx->CurrentTexObj[t->bound-1] = NULL;
+   if ( t->memBlock ) {
+      mmFreeMem( t->memBlock );
+      t->memBlock = NULL;
+   }
+
+   if ( t->tObj )
+      t->tObj->DriverData = NULL;
+   if ( t->bound )
+      r128ctx->CurrentTexObj[t->bound-1] = NULL;
 
-    remove_from_list(t);
-    free(t);
+   remove_from_list( t );
+   FREE( t );
 }
 
 /* Keep track of swapped out texture objects */
-/* NOTE: This function is only called while holding the hardware lock */
-static void r128SwapOutTexObj(r128ContextPtr r128ctx, r128TexObjPtr t)
+static void r128SwapOutTexObj( r128ContextPtr r128ctx, r128TexObjPtr t )
 {
 #if ENABLE_PERF_BOXES
-    /* Bump the performace counter */
-    r128ctx->c_textureSwaps++;
+   /* Bump the performace counter */
+   r128ctx->c_textureSwaps++;
 #endif
-    if (t->memBlock) {
-	mmFreeMem(t->memBlock);
-	t->memBlock = NULL;
-    }
+   if ( t->memBlock ) {
+      mmFreeMem( t->memBlock );
+      t->memBlock = NULL;
+   }
 
-    t->dirty_images = ~0;
-    move_to_tail(&r128ctx->SwappedOut, t);
+   t->dirty_images = ~0;
+   move_to_tail( &r128ctx->SwappedOut, t );
 }
 
 /* Print out debugging information about texture LRU */
-void r128PrintLocalLRU(r128ContextPtr r128ctx, int heap)
+void r128PrintLocalLRU( r128ContextPtr r128ctx, int heap )
 {
-    r128TexObjPtr t;
-    int           sz = 1 << (r128ctx->r128Screen->log2TexGran[heap]);
+   r128TexObjPtr t;
+   int sz = 1 << (r128ctx->r128Screen->log2TexGran[heap]);
+
+   fprintf( stderr, "\nLocal LRU, heap %d:\n", heap );
 
-    foreach(t, &r128ctx->TexObjList[heap]) {
-	if (!t->tObj) {
-	    fprintf(stderr, "Placeholder %d at 0x%x sz 0x%x\n",
-		    t->memBlock->ofs / sz,
-		    t->memBlock->ofs,
-		    t->memBlock->size);
-	} else {
-	    fprintf(stderr, "Texture (bound %d) at 0x%x sz 0x%x\n",
-		    t->bound,
-		    t->memBlock->ofs,
-		    t->memBlock->size);
-	}
-    }
-}
-
-void r128PrintGlobalLRU(r128ContextPtr r128ctx, int heap)
-{
-    R128TexRegion *list = r128ctx->r128Screen->SAREA->texList[heap];
-    int            i, j;
-
-    for (i = 0, j = R128_NR_TEX_REGIONS ; i < R128_NR_TEX_REGIONS ; i++) {
-	fprintf(stderr, "list[%d] age %d next %d prev %d\n",
-		j, list[j].age, list[j].next, list[j].prev);
-	j = list[j].next;
-	if (j == R128_NR_TEX_REGIONS) break;
-    }
-
-    if (j != R128_NR_TEX_REGIONS) {
-	fprintf(stderr, "Loop detected in global LRU\n");
-    }
+   foreach( t, &r128ctx->TexObjList[heap] ) {
+      if ( !t->tObj ) {
+	 fprintf( stderr, "Placeholder %d at 0x%x sz 0x%x\n",
+		  t->memBlock->ofs / sz,
+		  t->memBlock->ofs,
+		  t->memBlock->size );
+      } else {
+	 fprintf( stderr, "Texture (bound %d) at 0x%x sz 0x%x\n",
+		  t->bound,
+		  t->memBlock->ofs,
+		  t->memBlock->size );
+      }
+   }
+
+   fprintf( stderr, "\n" );
+}
+
+void r128PrintGlobalLRU( r128ContextPtr r128ctx, int heap )
+{
+   r128_tex_region_t *list = r128ctx->sarea->texList[heap];
+   int i, j;
+
+   fprintf( stderr, "\nGlobal LRU, heap %d list %p:\n", heap, list );
+
+   for ( i = 0, j = R128_NR_TEX_REGIONS ; i < R128_NR_TEX_REGIONS ; i++ ) {
+      fprintf( stderr, "list[%d] age %d next %d prev %d\n",
+	       j, list[j].age, list[j].next, list[j].prev );
+      j = list[j].next;
+      if ( j == R128_NR_TEX_REGIONS ) break;
+   }
+
+   if ( j != R128_NR_TEX_REGIONS ) {
+      fprintf( stderr, "Loop detected in global LRU\n" );
+      for ( i = 0 ; i < R128_NR_TEX_REGIONS ; i++ ) {
+	 fprintf( stderr, "list[%d] age %d next %d prev %d\n",
+		  i, list[i].age, list[i].next, list[i].prev );
+      }
+   }
+
+   fprintf( stderr, "\n" );
 }
 
 /* Reset the global texture LRU */
 /* NOTE: This function is only called while holding the hardware lock */
-static void r128ResetGlobalLRU(r128ContextPtr r128ctx, int heap)
+static void r128ResetGlobalLRU( r128ContextPtr r128ctx, int heap )
 {
-    R128TexRegion *list   = r128ctx->r128Screen->SAREA->texList[heap];
-    int            log2sz = 1 << r128ctx->r128Screen->log2TexGran[heap];
-    int            i;
-
-    /*
-     * (Re)initialize the global circular LRU list.  The last element in
-     * the array (R128_NR_TEX_REGIONS) is the sentinal.  Keeping it at
-     * the end of the array allows it to be addressed rationally when
-     * looking up objects at a particular location in texture memory.
-     */
-
-    for (i = 0; (i+1) * log2sz <= r128ctx->r128Screen->texSize[heap]; i++) {
-	list[i].prev = i-1;
-	list[i].next = i+1;
-	list[i].age = 0;
-    }
-
-    i--;
-    list[0].prev = R128_NR_TEX_REGIONS;
-    list[i].prev = i-1;
-    list[i].next = R128_NR_TEX_REGIONS;
-    list[R128_NR_TEX_REGIONS].prev = i;
-    list[R128_NR_TEX_REGIONS].next = 0;
-    r128ctx->r128Screen->SAREA->texAge[heap] = 0;
+   r128_tex_region_t *list = r128ctx->sarea->texList[heap];
+   int sz = 1 << r128ctx->r128Screen->log2TexGran[heap];
+   int i;
+
+   /* (Re)initialize the global circular LRU list.  The last element in
+    * the array (R128_NR_TEX_REGIONS) is the sentinal.  Keeping it at
+    * the end of the array allows it to be addressed rationally when
+    * looking up objects at a particular location in texture memory.
+    */
+   for ( i = 0 ; (i+1) * sz <= r128ctx->r128Screen->texSize[heap] ; i++ ) {
+      list[i].prev = i-1;
+      list[i].next = i+1;
+      list[i].age = 0;
+   }
+
+   i--;
+   list[0].prev = R128_NR_TEX_REGIONS;
+   list[i].prev = i-1;
+   list[i].next = R128_NR_TEX_REGIONS;
+   list[R128_NR_TEX_REGIONS].prev = i;
+   list[R128_NR_TEX_REGIONS].next = 0;
+   r128ctx->sarea->texAge[heap] = 0;
 }
 
 /* Update the local and glock texture LRUs */
 /* NOTE: This function is only called while holding the hardware lock */
-static void r128UpdateTexLRU(r128ContextPtr r128ctx, r128TexObjPtr t)
+static void r128UpdateTexLRU( r128ContextPtr r128ctx, r128TexObjPtr t )
 {
-    int            heap   = t->heap;
-    R128TexRegion *list = r128ctx->r128Screen->SAREA->texList[heap];
-    int            log2sz = r128ctx->r128Screen->log2TexGran[heap];
-
-    int            start  = t->memBlock->ofs >> log2sz;
-    int            end    = (t->memBlock->ofs + t->memBlock->size-1) >> log2sz;
-    int            i;
-
-    r128ctx->lastTexAge[heap] = ++r128ctx->r128Screen->SAREA->texAge[heap];
-
-    /* Update our local LRU */
-    move_to_head(&r128ctx->TexObjList[heap], t);
-
-    /* Update the global LRU */
-    for (i = start ; i <= end ; i++) {
-	list[i].in_use = 1;
-	list[i].age = r128ctx->lastTexAge[heap];
-
-	/* remove_from_list(i) */
-	list[(CARD32)list[i].next].prev = list[i].prev;
-	list[(CARD32)list[i].prev].next = list[i].next;
-
-	/* insert_at_head(list, i) */
-	list[i].prev = R128_NR_TEX_REGIONS;
-	list[i].next = list[R128_NR_TEX_REGIONS].next;
-	list[(CARD32)list[R128_NR_TEX_REGIONS].next].prev = i;
-	list[R128_NR_TEX_REGIONS].next = i;
-    }
+   int heap = t->heap;
+   r128_tex_region_t *list = r128ctx->sarea->texList[heap];
+   int log2sz = r128ctx->r128Screen->log2TexGran[heap];
+   int start = t->memBlock->ofs >> log2sz;
+   int end = (t->memBlock->ofs + t->memBlock->size - 1) >> log2sz;
+   int i;
+
+   r128ctx->lastTexAge[heap] = ++r128ctx->sarea->texAge[heap];
+
+   if ( !t->memBlock ) {
+      fprintf( stderr, "no memblock\n\n" );
+      return;
+   }
+
+   /* Update our local LRU */
+   move_to_head( &r128ctx->TexObjList[heap], t );
+
+   /* Update the global LRU */
+   for ( i = start ; i <= end ; i++ ) {
+      list[i].in_use = 1;
+      list[i].age = r128ctx->lastTexAge[heap];
+
+      /* remove_from_list(i) */
+      list[(CARD32)list[i].next].prev = list[i].prev;
+      list[(CARD32)list[i].prev].next = list[i].next;
+
+      /* insert_at_head(list, i) */
+      list[i].prev = R128_NR_TEX_REGIONS;
+      list[i].next = list[R128_NR_TEX_REGIONS].next;
+      list[(CARD32)list[R128_NR_TEX_REGIONS].next].prev = i;
+      list[R128_NR_TEX_REGIONS].next = i;
+   }
+
+   if ( 0 ) {
+      r128PrintGlobalLRU( r128ctx, t->heap );
+      r128PrintLocalLRU( r128ctx, t->heap );
+   }
 }
 
 /* Update our notion of what textures have been changed since we last
@@ -322,1551 +362,1330 @@
    textures by pushing a placeholder texture onto the LRU list -- these
    are denoted by (tObj == NULL). */
 /* NOTE: This function is only called while holding the hardware lock */
-static void r128TexturesGone(r128ContextPtr r128ctx, int heap,
-			     int offset, int size, int in_use)
+static void r128TexturesGone( r128ContextPtr r128ctx, int heap,
+			      int offset, int size, int in_use )
 {
-    r128TexObjPtr t, tmp;
+   r128TexObjPtr t, tmp;
 
-    foreach_s (t, tmp, &r128ctx->TexObjList[heap]) {
-	if (t->memBlock->ofs >= offset + size ||
-	    t->memBlock->ofs + t->memBlock->size <= offset)
-	    continue;
-
-	/* It overlaps - kick it out.  Need to hold onto the currently
-	   bound objects, however. */
-	if (t->bound) r128SwapOutTexObj(r128ctx, t);
-	else          r128DestroyTexObj(r128ctx, t);
-    }
-
-    if (in_use) {
-	t = (r128TexObjPtr) calloc(1,sizeof(*t));
-	if (!t) return;
-
-	t->memBlock = mmAllocMem(r128ctx->texHeap[heap], size, 0, offset);
-	insert_at_head(&r128ctx->TexObjList[heap], t);
-    }
+   foreach_s ( t, tmp, &r128ctx->TexObjList[heap] ) {
+      if ( t->memBlock->ofs >= offset + size ||
+	   t->memBlock->ofs + t->memBlock->size <= offset )
+	 continue;
+
+      /* It overlaps - kick it out.  Need to hold onto the currently
+       * bound objects, however.
+       */
+      if ( t->bound ) {
+	 r128SwapOutTexObj( r128ctx, t );
+      } else {
+	 r128DestroyTexObj( r128ctx, t );
+      }
+   }
+
+   if ( in_use ) {
+      t = (r128TexObjPtr) CALLOC( sizeof(*t) );
+      if (!t) return;
+
+      t->memBlock = mmAllocMem( r128ctx->texHeap[heap], size, 0, offset );
+      if ( !t->memBlock ) {
+	 fprintf( stderr, "Couldn't alloc placeholder sz %x ofs %x\n",
+		  (int)size, (int)offset );
+	 mmDumpMemInfo( r128ctx->texHeap[heap] );
+	 return;
+      }
+      insert_at_head( &r128ctx->TexObjList[heap], t );
+   }
 }
 
 /* Update our client's shared texture state.  If another client has
    modified a region in which we have textures, then we need to figure
    out which of our textures has been removed, and update our global
    LRU. */
-void r128AgeTextures(r128ContextPtr r128ctx, int heap)
+void r128AgeTextures( r128ContextPtr r128ctx, int heap )
 {
-    R128SAREAPrivPtr sarea = r128ctx->r128Screen->SAREA;
-
-    if (sarea->texAge[heap] != r128ctx->lastTexAge[heap]) {
-	int log2sz = 1 << r128ctx->r128Screen->log2TexGran[heap];
-	int nr     = 0;
-	int idx;
-
-	for (idx = sarea->texList[heap][R128_NR_TEX_REGIONS].prev;
-	     idx != R128_NR_TEX_REGIONS && nr < R128_NR_TEX_REGIONS;
-	     idx = sarea->texList[heap][idx].prev, nr++) {
-
-	    /* If switching texturing schemes, then the SAREA might not
-               have been properly cleared, so we need to reset the
-               global texture LRU. */
-	    if (idx * log2sz > r128ctx->r128Screen->texSize[heap]) {
-		nr = R128_NR_TEX_REGIONS;
-		break;
-	    }
+   R128SAREAPriv *sarea = r128ctx->sarea;
 
-	    if (sarea->texList[heap][idx].age > r128ctx->lastTexAge[heap])
-		r128TexturesGone(r128ctx, heap, idx * log2sz, log2sz,
-				 sarea->texList[heap][idx].in_use);
-	}
-
-	if (nr == R128_NR_TEX_REGIONS) {
-	    r128TexturesGone(r128ctx, heap,
-			     0, r128ctx->r128Screen->texSize[heap], 0);
-	    r128ResetGlobalLRU(r128ctx, heap);
-	}
-
-	r128ctx->dirty |= R128_UPDATE_TEX0IMAGES;
-	r128ctx->dirty |= R128_UPDATE_TEX1IMAGES;
-	r128ctx->lastTexAge[heap] = sarea->texAge[heap];
-    }
+   if ( sarea->texAge[heap] != r128ctx->lastTexAge[heap] ) {
+      int sz = 1 << r128ctx->r128Screen->log2TexGran[heap];
+      int nr = 0;
+      int idx;
+
+      /* Have to go right round from the back to ensure stuff ends up
+       * LRU in our local list...  Fix with a cursor pointer.
+       */
+      for ( idx = sarea->texList[heap][R128_NR_TEX_REGIONS].prev ;
+	    idx != R128_NR_TEX_REGIONS && nr < R128_NR_TEX_REGIONS ;
+	    idx = sarea->texList[heap][idx].prev, nr++ )
+      {
+	 /* If switching texturing schemes, then the SAREA might not
+	    have been properly cleared, so we need to reset the
+	    global texture LRU. */
+	 if ( idx * sz > r128ctx->r128Screen->texSize[heap] ) {
+	    nr = R128_NR_TEX_REGIONS;
+	    break;
+	 }
+
+	 if ( sarea->texList[heap][idx].age > r128ctx->lastTexAge[heap] ) {
+	    r128TexturesGone( r128ctx, heap, idx * sz, sz,
+			      sarea->texList[heap][idx].in_use );
+	 }
+      }
+
+      /* If switching texturing schemes, then the SAREA might not
+       * have been properly cleared, so we need to reset the
+       * global texture LRU.
+       */
+      if ( nr == R128_NR_TEX_REGIONS ) {
+	 r128TexturesGone( r128ctx, heap, 0,
+			   r128ctx->r128Screen->texSize[heap], 0 );
+	 r128ResetGlobalLRU( r128ctx, heap );
+      }
+
+      if ( 0 ) {
+	 r128PrintGlobalLRU( r128ctx, heap );
+	 r128PrintLocalLRU( r128ctx, heap );
+      }
+
+      r128ctx->dirty |= (R128_UPLOAD_CONTEXT |
+			 R128_UPLOAD_TEX0IMAGES |
+			 R128_UPLOAD_TEX1IMAGES);
+      r128ctx->lastTexAge[heap] = sarea->texAge[heap];
+   }
 }
 
 /* Convert a block of Mesa-formatted texture to an 8bpp hardware format */
-static void r128ConvertTexture8bpp(r128ContextPtr r128ctx,
-				   struct gl_texture_image *image,
-				   int x, int y, int width, int height,
-				   int pitch)
-{
-    CARD8  *src;
-    CARD32  pix;
-    int     i, j;
-
-    switch (image->Format) {
-    case GL_RGB:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
-	    for (j = width >> 2; j; j--) {
-		pix = ((R128PACKCOLOR332( src[0], src[1],  src[2])       ) |
-		       (R128PACKCOLOR332( src[3], src[4],  src[5])  <<  8) |
-		       (R128PACKCOLOR332( src[6], src[7],  src[8])  << 16) |
-		       (R128PACKCOLOR332( src[9], src[10], src[11]) << 24));
-		R128CCE(pix);
-		src += 12;
-	    }
-	}
-	break;
-
-    case GL_ALPHA:
-    case GL_LUMINANCE:
-    case GL_INTENSITY:
-    case GL_COLOR_INDEX:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x);
-	    for (j = width >> 2; j; j--) {
-		pix = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
-		R128CCE(pix);
-		src += 4;
-	    }
-	}
-	break;
-
-    default:
-	fprintf(stderr, "r128ConvertTexture8bpp: unsupported format 0x%x\n",
-		image->Format);
-    }
-}
-
-/* Convert a block of Mesa-formatted texture to a 16bpp hardware format */
-static void r128ConvertTexture16bpp(r128ContextPtr r128ctx,
+static void r128ConvertTexture8bpp( CARD32 *dst,
 				    struct gl_texture_image *image,
 				    int x, int y, int width, int height,
-				    int pitch)
+				    int pitch )
 {
-    CARD8  *src;
-    CARD32  pix;
-    int     i, j;
-
-    switch (image->Format) {
-    case GL_RGB:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
-	    for (j = width >> 1; j; j--) {
-		pix = ((R128PACKCOLOR565(src[0], src[1], src[2])      ) |
-		       (R128PACKCOLOR565(src[3], src[4], src[5]) << 16));
-		R128CCE(pix);
-		src += 6;
-	    }
-	}
-	break;
+   CARD8 *src;
+   int i, j;
 
-    case GL_RGBA:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4;
-	    for (j = width >> 1; j; j--) {
-		pix =
-		    ((R128PACKCOLOR4444(src[0], src[1], src[2], src[3])    ) |
-		     (R128PACKCOLOR4444(src[4], src[5], src[6], src[7])<<16));
-		R128CCE(pix);
-		src += 8;
-	    }
-	}
-	break;
-
-    case GL_ALPHA:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x);
-	    for (j = width >> 1; j; j--) {
-		pix = ((R128PACKCOLOR4444(0xff, 0xff, 0xff, src[0])      ) |
-		       (R128PACKCOLOR4444(0xff, 0xff, 0xff, src[1]) << 16));
-		R128CCE(pix);
-		src += 2;
-	    }
-	}
-	break;
-
-    case GL_LUMINANCE:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x);
-	    for (j = width >> 1; j; j--) {
-		pix = ((R128PACKCOLOR1555(src[0], src[0], src[0], 0xff)    ) |
-		       (R128PACKCOLOR1555(src[1], src[1], src[1], 0xff)<<16));
-		R128CCE(pix);
-		src += 2;
-	    }
-	}
-	break;
-
-    case GL_LUMINANCE_ALPHA:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2;
-	    for (j = width >> 1; j; j--) {
-		pix =
-		    ((R128PACKCOLOR4444(src[0], src[0], src[0], src[1])    ) |
-		     (R128PACKCOLOR4444(src[2], src[2], src[2], src[3])<<16));
-		R128CCE(pix);
-		src += 4;
-	    }
-	}
-	break;
-
-    case GL_INTENSITY:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x);
-	    for (j = width >> 1; j; j--) {
-		pix =
-		    ((R128PACKCOLOR4444(src[0], src[0], src[0], src[0])    ) |
-		     (R128PACKCOLOR4444(src[1], src[1], src[1], src[1])<<16));
-		R128CCE(pix);
-		src += 2;
-	    }
-	}
-	break;
+   switch ( image->Format ) {
+   case GL_RGB:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
+	 for ( j = width >> 2 ; j ; j-- ) {
+	    *dst++= ((R128PACKCOLOR332( src[0], src[1], src[2] )) |
+		     (R128PACKCOLOR332( src[3], src[4], src[5] ) << 8) |
+		     (R128PACKCOLOR332( src[6], src[7], src[8] ) << 16) |
+		     (R128PACKCOLOR332( src[9], src[10], src[11] ) << 24));
+	    src += 12;
+	 }
+      }
+      break;
+
+   case GL_ALPHA:
+   case GL_LUMINANCE:
+   case GL_INTENSITY:
+   case GL_COLOR_INDEX:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+	 for ( j = width >> 2 ; j ; j-- ) {
+	    *dst++ = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+	    src += 4;
+	 }
+      }
+      break;
+
+   default:
+      fprintf( stderr, "%s: unsupported format 0x%x\n",
+	       __FUNCTION__, image->Format );
+      break;
+   }
+}
 
-    default:
-	fprintf(stderr, "r128ConvertTexture16bpp: unsupported format 0x%x\n",
-		image->Format);
-    }
+/* Convert a block of Mesa-formatted texture to a 16bpp hardware format */
+static void r128ConvertTexture16bpp( CARD32 *dst,
+				     struct gl_texture_image *image,
+				     int x, int y, int width, int height,
+				     int pitch )
+{
+   CARD8 *src;
+   int i, j;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s: %d,%d at %d,%d\n",
+	       __FUNCTION__, width, height, x, y );
+   }
+
+
+   switch ( image->Format ) {
+   case GL_RGB:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
+	 for ( j = width >> 1 ; j ; j-- ) {
+	    *dst++ = ((R128PACKCOLOR565( src[0], src[1], src[2] )) |
+		      (R128PACKCOLOR565( src[3], src[4], src[5] ) << 16));
+	    src += 6;
+	 }
+      }
+      break;
+
+   case GL_RGBA:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4;
+	 for ( j = width >> 1 ; j ; j-- ) {
+	    *dst++ = ((R128PACKCOLOR4444( src[0], src[1], src[2], src[3] )) |
+		      (R128PACKCOLOR4444( src[4], src[5], src[6], src[7] ) << 16));
+	    src += 8;
+	 }
+      }
+      break;
+
+   case GL_ALPHA:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+	 for ( j = width >> 1 ; j ; j-- ) {
+	    *dst++ = ((R128PACKCOLOR4444( 0xff, 0xff, 0xff, src[0] )) |
+		      (R128PACKCOLOR4444( 0xff, 0xff, 0xff, src[1] ) << 16));
+	    src += 2;
+	 }
+      }
+      break;
+
+   case GL_LUMINANCE:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+	 for ( j = width >> 1 ; j ; j-- ) {
+	    *dst++ = ((R128PACKCOLOR1555( src[0], src[0], src[0], 0xff )) |
+		      (R128PACKCOLOR1555( src[1], src[1], src[1], 0xff ) << 16));
+	    src += 2;
+	 }
+      }
+      break;
+
+   case GL_LUMINANCE_ALPHA:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2;
+	 for ( j = width >> 1 ; j ; j-- ) {
+	    *dst++ = ((R128PACKCOLOR4444( src[0], src[0], src[0], src[1] )) |
+		      (R128PACKCOLOR4444( src[2], src[2], src[2], src[3] ) << 16));
+	    src += 4;
+	 }
+      }
+      break;
+
+   case GL_INTENSITY:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+	 for ( j = width >> 1 ; j ; j-- ) {
+	    *dst++ = ((R128PACKCOLOR4444( src[0], src[0], src[0], src[0] )) |
+		      (R128PACKCOLOR4444( src[1], src[1], src[1], src[1] ) << 16));
+	    src += 2;
+	 }
+      }
+      break;
+
+   default:
+      fprintf( stderr, "%s: unsupported format 0x%x\n",
+	       __FUNCTION__, image->Format );
+      break;
+   }
 }
 
 /* Convert a block of Mesa-formatted texture to a 32bpp hardware format */
-static void r128ConvertTexture32bpp(r128ContextPtr r128ctx,
-				    struct gl_texture_image *image,
-				    int x, int y, int width, int height,
-				    int pitch)
-{
-    CARD8  *src;
-    CARD32  pix;
-    int     i, j;
-
-    switch (image->Format) {
-    case GL_RGB:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
-	    for (j = width; j; j--) {
-		pix = R128PACKCOLOR8888(src[0], src[1], src[2], 0xff);
-		R128CCE(pix);
-		src += 3;
-	    }
-	}
-	break;
-
-    case GL_RGBA:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4;
-	    for (j = width; j; j--) {
-		pix = R128PACKCOLOR8888(src[0], src[1], src[2], src[3]);
-		R128CCE(pix);
-		src += 4;
-	    }
-	}
-	break;
-
-    case GL_ALPHA:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x);
-	    for (j = width; j; j--) {
-		pix = R128PACKCOLOR8888(0xff, 0xff, 0xff, src[0]);
-		R128CCE(pix);
-		src += 1;
-	    }
-	}
-	break;
-
-    case GL_LUMINANCE:
-	for (i = 0 ; i < height ; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x);
-	    for (j = width; j; j--) {
-		pix = R128PACKCOLOR8888(src[0], src[0], src[0], 0xff);
-		R128CCE(pix);
-		src += 1;
-	    }
-	}
-	break;
-
-    case GL_LUMINANCE_ALPHA:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2;
-	    for (j = width; j; j-- ) {
-		pix = R128PACKCOLOR8888(src[0], src[0], src[0], src[1]);
-		R128CCE(pix);
-		src += 2;
-	    }
-	}
-	break;
-
-    case GL_INTENSITY:
-	for (i = 0; i < height; i++) {
-	    src = (CARD8 *)image->Data + ((y + i) * pitch + x);
-	    for (j = width; j; j--) {
-		pix = R128PACKCOLOR8888(src[0], src[0], src[0], src[0]);
-		R128CCE(pix);
-		src += 1;
-	    }
-	}
-	break;
-
-    default:
-	fprintf(stderr, "r128ConvertTexture32bpp: unsupported format 0x%x\n",
-		image->Format);
-    }
+static void r128ConvertTexture32bpp( CARD32 *dst,
+				     struct gl_texture_image *image,
+				     int x, int y, int width, int height,
+				     int pitch )
+{
+   CARD8 *src;
+   int i, j;
+
+   switch ( image->Format ) {
+   case GL_RGB:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
+	 for ( j = width ; j ; j-- ) {
+	    *dst++ = R128PACKCOLOR8888( src[0], src[1], src[2], 0xff );
+	    src += 3;
+	 }
+      }
+      break;
+
+   case GL_RGBA:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4;
+	 for ( j = width ; j ; j-- ) {
+	    *dst++ = R128PACKCOLOR8888( src[0], src[1], src[2], src[3] );
+	    src += 4;
+	 }
+      }
+      break;
+
+   case GL_ALPHA:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+	 for ( j = width ; j ; j-- ) {
+	    *dst++ = R128PACKCOLOR8888( 0xff, 0xff, 0xff, src[0] );
+	    src += 1;
+	 }
+      }
+      break;
+
+   case GL_LUMINANCE:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+	 for ( j = width ; j ; j-- ) {
+	    *dst++ = R128PACKCOLOR8888( src[0], src[0], src[0], 0xff );
+	    src += 1;
+	 }
+      }
+      break;
+
+   case GL_LUMINANCE_ALPHA:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2;
+	 for ( j = width ; j ; j-- ) {
+	    *dst++ = R128PACKCOLOR8888( src[0], src[0], src[0], src[1] );
+	    src += 2;
+	 }
+      }
+      break;
+
+   case GL_INTENSITY:
+      for ( i = 0 ; i < height ; i++ ) {
+	 src = (CARD8 *)image->Data + ((y + i) * pitch + x);
+	 for ( j = width ; j ; j-- ) {
+	    *dst++ = R128PACKCOLOR8888( src[0], src[0], src[0], src[0] );
+	    src += 1;
+	 }
+      }
+      break;
+
+   default:
+      fprintf( stderr, "%s: unsupported format 0x%x\n",
+	       __FUNCTION__, image->Format );
+      break;
+   }
 }
 
 /* Upload the texture image associated with texture `t' at level `level'
    at the address relative to `start'. */
 /* NOTE: This function is only called while holding the hardware lock */
-static void r128UploadSubImage(r128ContextPtr r128ctx,
-			       r128TexObjPtr t, int level,
-			       int x, int y, int width, int height)
-{
-    struct gl_texture_image *image;
-    int                      texelsPerDword = 0;
-    int                      imageWidth, imageHeight;
-    int                      remaining, rows;
-    int                      format, pitch, dwords;
-    CARD32                   offset;
-
-    /* Ensure we have a valid texture to upload */
-    if (level < 0 || level > R128_TEX_MAXLEVELS) return;
-    if (!(image = t->tObj->Image[level]))        return;
-
-    /* FIXME: support RGB888 (i.e., 24bpp) textures? */
-    switch (t->texelBytes) {
-    case 1: texelsPerDword = 4; break;
-    case 2: texelsPerDword = 2; break;
-    case 4: texelsPerDword = 1; break;
-    }
-
-    imageWidth  = image->Width;
-    imageHeight = image->Height;
-
-    format = t->textureFormat >> 16;
-
-    /* The texel upload routines have a minimum width, so force the size
-       if needed */
-    if (imageWidth < texelsPerDword) {
-	int factor;
-
-	factor        = texelsPerDword / imageWidth;
-	imageWidth    = texelsPerDword;
-	imageHeight /= factor;
-	if (imageHeight == 0) {
-	    /* In this case, the texel converter will actually walk a
-	       texel or two off the end of the image, but normal malloc
-	       alignment should prevent it from ever causing a fault. */
-	    imageHeight = 1;
-	}
-    }
-
-    /* We can't upload to a pitch less than 8 texels so we will need to
-       linearly upload all modified rows for textures smaller than this.
-       This makes the x/y/width/height different for the blitter and the
-       texture walker. */
-    if (imageWidth >= 8) {
-	/* The texture walker and the blitter look identical */
-	pitch      = imageWidth >> 3;
-    } else {
-	int factor;
-	int y2;
-	int start, end;
-
-	start = (y * imageWidth) & ~7;
-	end   = (y + height) * imageWidth;
-
-	if (end - start < 8) {
-	    /* Handle the case where the total number of texels uploaded
-               is < 8 */
-	    x       = 0;
-	    y       = start / 8;
-	    width   = end - start;
-	    height  = 1;
-	} else {
-	    /* Upload some number of full 8 texel blit rows */
-	    factor  = 8 / imageWidth;
-
-	    y2      = y + height - 1;
-	    y      /= factor;
-	    y2     /= factor;
-
-	    x       = 0;
-	    width   = 8;
-	    height  = y2 - y + 1;
-	}
-
-	/* Fixed pitch of 8 */
-	pitch = 1;
-    }
+static void r128UploadSubImage( r128ContextPtr r128ctx,
+				r128TexObjPtr t, int level,
+				int x, int y, int width, int height )
+{
+   struct gl_texture_image *image;
+   int texelsPerDword = 0;
+   int imageWidth, imageHeight;
+   int remaining, rows;
+   int format, dwords;
+   CARD32 pitch, offset;
+   drmBufPtr buffer;
+   CARD32 *dst;
+   int i;
+
+   /* Ensure we have a valid texture to upload */
+   if ( ( level < 0 ) || ( level > R128_TEX_MAXLEVELS ) )
+      return;
+
+   image = t->tObj->Image[level];
+   if ( !image )
+      return;
+
+   switch ( t->texelBytes ) {
+   case 1: texelsPerDword = 4; break;
+   case 2: texelsPerDword = 2; break;
+   case 4: texelsPerDword = 1; break;
+   }
+
+#if 1
+   /* FIXME: The subimage index calcs are wrong - who changed them? */
+   x = 0;
+   y = 0;
+   width = image->Width;
+   height = image->Height;
+#endif
+
+   imageWidth  = image->Width;
+   imageHeight = image->Height;
 
-    dwords = width * height / texelsPerDword;
-    offset = (CARD32)(t->bufAddr + t->image[level].offset);
+   format = t->textureFormat >> 16;
 
+   /* The texel upload routines have a minimum width, so force the size
+    * if needed.
+    */
+   if ( imageWidth < texelsPerDword ) {
+      int factor;
+
+      factor = texelsPerDword / imageWidth;
+      imageWidth = texelsPerDword;
+      imageHeight /= factor;
+      if ( imageHeight == 0 ) {
+	 /* In this case, the texel converter will actually walk a
+	  * texel or two off the end of the image, but normal malloc
+	  * alignment should prevent it from ever causing a fault.
+	  */
+	 imageHeight = 1;
+      }
+   }
+
+   /* We can't upload to a pitch less than 8 texels so we will need to
+    * linearly upload all modified rows for textures smaller than this.
+    * This makes the x/y/width/height different for the blitter and the
+    * texture walker.
+    */
+   if ( imageWidth >= 8 ) {
+      /* The texture walker and the blitter look identical */
+      pitch = imageWidth >> 3;
+   } else {
+      int factor;
+      int y2;
+      int start, end;
+
+      start = (y * imageWidth) & ~7;
+      end = (y + height) * imageWidth;
+
+      if ( end - start < 8 ) {
+	 /* Handle the case where the total number of texels
+	  * uploaded is < 8.
+	  */
+	 x = 0;
+	 y = start / 8;
+	 width = end - start;
+	 height = 1;
+      } else {
+	 /* Upload some number of full 8 texel blit rows */
+	 factor = 8 / imageWidth;
+
+	 y2 = y + height - 1;
+	 y /= factor;
+	 y2 /= factor;
+
+	 x = 0;
+	 width = 8;
+	 height = y2 - y + 1;
+      }
+
+      /* Fixed pitch of 8 */
+      pitch = 1;
+   }
+
+   dwords = width * height / texelsPerDword;
+   offset = t->bufAddr + t->image[level].offset;
+
+   /* Fix offset for AGP textures */
+   if ( t->heap == R128_AGP_TEX_HEAP ) {
+      offset += R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset;
+   }
+
 #if ENABLE_PERF_BOXES
-    /* Bump the performace counter */
-    r128ctx->c_textureBytes += (dwords << 2);
+   /* Bump the performace counter */
+   r128ctx->c_textureBytes += (dwords << 2);
 #endif
 
-    /* Fix offset for AGP textures */
-    if (t->heap == R128_AGP_TEX_HEAP)
-	offset += R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset;
-
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
-	fprintf(stderr, "r128UploadSubImage: %d,%d of %d,%d at %d,%d\n",
-		width, height, image->Width, image->Height, x, y);
-	fprintf(stderr, "          blit ofs: 0x%08x pitch: 0x%x dwords: %d "
-				  "level: %d format: %x\n",
-		(int)offset, pitch, dwords, level, format);
-    }
-
-    /* Subdivide the texture if required */
-    if (dwords < R128_CCE_PACKET_MAX_DWORDS) {
-	rows = height;
-    } else {
-	rows = (R128_CCE_PACKET_MAX_DWORDS * texelsPerDword) / (2 * width);
-    }
-
-    /* Flush the pixel cache, and mark the contents as Read Invalid */
-    R128CCE0(R128_CCE_PACKET0, R128_PC_GUI_CTLSTAT, 0);
-    R128CCE(r128ctx->regs.pc_gui_ctlstat |
-	    R128_PC_RI_GUI               |
-	    R128_PC_FLUSH_GUI);
-    R128CCE_SUBMIT_PACKET();
-
-    /* Build the CCE host data blit header */
-    R128CCE3(R128_CCE_PACKET3_CNTL_HOSTDATA_BLT, 0);
-
-    /* DP_GUI_MASTER_CNTL */
-    R128CCE(R128_GMC_DST_PITCH_OFFSET_CNTL |
-	    R128_GMC_BRUSH_NONE            |
-	    (format << 8)                  |
-	    R128_GMC_SRC_DATATYPE_COLOR    |
-	    R128_ROP3_S                    |
-	    R128_DP_SRC_SOURCE_HOST_DATA   |
-	    R128_GMC_CLR_CMP_CNTL_DIS      |
-	    R128_GMC_AUX_CLIP_DIS          |
-	    R128_GMC_WR_MSK_DIS           );
-
-    /* DST_OFFSET_PITCH - fixed at the moment until we get better ring
-       control */
-    R128CCE((pitch << 21) | (offset>>5));
-
-    /* FRGD_COLOR, BKGD_COLOR */
-    R128CCE(0xffffffff);
-    R128CCE(0xffffffff);
-
-    for (remaining = height; remaining > 0; remaining -= rows, y += rows) {
-	height = (remaining >= rows) ? rows : remaining;
-	dwords = width * height / texelsPerDword;
-
-	if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) {
-	    fprintf(stderr, "          blitting: %d,%d at %d,%d - %d dwords\n",
-		    width, height, x, y, dwords);
-	}
-
-	r128ctx->CCEbuf[0] &= ~R128_CCE_PACKET_COUNT_MASK;
-	r128ctx->CCEbuf[0] |= (dwords + 6) << 16;
-
-	/* Blit coords, size */
-	R128CCE((y      << 16) | x);
-	R128CCE((height << 16) | width);
-	R128CCE(dwords);
-
-	/* Actually do the texture conversion */
-	switch (t->texelBytes) {
-	case 1:
-	    r128ConvertTexture8bpp(r128ctx, image,
-				   x, y, width, height, width);
-	    break;
-	case 2:
-	    r128ConvertTexture16bpp(r128ctx, image,
-				    x, y, width, height, width);
-	    break;
-	case 4:
-	    r128ConvertTexture32bpp(r128ctx,
-				    image, x, y, width, height, width);
-	    break;
-	}
 
-	/* Flush the pixel cache */
-	R128CCE0(R128_CCE_PACKET0, R128_PC_GUI_CTLSTAT, 0 );
-	R128CCE(r128ctx->regs.pc_gui_ctlstat | R128_PC_FLUSH_GUI);
-
-	/* Save the partial blit header */
-	R128CCE_SUBMIT_PACKET();
-	r128ctx->CCEcount = 5;
-    }
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "r128UploadSubImage: %d,%d of %d,%d at %d,%d\n",
+	       width, height, image->Width, image->Height, x, y );
+      fprintf( stderr, "          blit ofs: 0x%07x pitch: 0x%x dwords: %d "
+	       "level: %d format: %x\n",
+	       (int)offset, pitch, dwords, level, format );
+   }
+
+   /* Subdivide the texture if required */
+   if ( dwords <= R128_BUFFER_MAX_DWORDS / 2 ) {
+      rows = height;
+   } else {
+      rows = (R128_BUFFER_MAX_DWORDS * texelsPerDword) / (2 * width);
+   }
+
+   for ( i = 0, remaining = height ;
+	 remaining > 0 ;
+	 remaining -= rows, y += rows, i++ )
+   {
+      height = (remaining >= rows) ? rows : remaining;
+      dwords = width * height / texelsPerDword;
+
+      if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+	 fprintf( stderr, "          blitting: %d,%d at %d,%d - %d dwords\n",
+		 width, height, x, y, dwords );
+      }
+
+      /* Grab the indirect buffer for the texture blit */
+      buffer = r128GetBufferLocked( r128ctx );
+
+      dst = (CARD32 *)((char *)buffer->address + R128_HOSTDATA_BLIT_OFFSET);
+
+      /* Actually do the texture conversion */
+      switch ( t->texelBytes ) {
+      case 1:
+	 r128ConvertTexture8bpp( dst, image,
+				 x, y, width, height, width );
+	 break;
+      case 2:
+	 r128ConvertTexture16bpp( dst, image,
+				  x, y, width, height, width );
+	 break;
+      case 4:
+	 r128ConvertTexture32bpp( dst, image,
+				  x, y, width, height, width );
+	 break;
+      }
+
+      r128FireBlitLocked( r128ctx, buffer,
+			  offset, pitch, format,
+			  x, y, width, height );
+   }
 
-    /* Clean up CCE ring buffer */
-    r128ctx->CCEcount = 0;
+   r128ctx->new_state |= R128_NEW_CONTEXT;
+   r128ctx->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
 }
 
 /* Upload the texture images associated with texture `t'.  This might
-   require removing our own and/or other client's texture objects to
-   make room for these images. */
+ * require removing our own and/or other client's texture objects to
+ * make room for these images.
+ */
 /* NOTE: This function is only called while holding the hardware lock */
-int r128UploadTexImages(r128ContextPtr r128ctx, r128TexObjPtr t)
+int r128UploadTexImages( r128ContextPtr r128ctx, r128TexObjPtr t )
 {
-    int i;
-    int minLevel;
-    int maxLevel;
-    int heap;
-
-    if (!t) return 0;
-
-    /* Choose the heap appropriately */
-    heap = t->heap = R128_LOCAL_TEX_HEAP;
-    if (!r128ctx->r128Screen->IsPCI &&
-	t->totalSize > r128ctx->r128Screen->texSize[heap])
-	heap = t->heap = R128_AGP_TEX_HEAP;
-
-    /* Do we need to eject LRU texture objects? */
-    if (!t->memBlock) {
-	/* Allocate a memory block on a 4k boundary (1<<12 == 4096) */
-	t->memBlock = mmAllocMem(r128ctx->texHeap[heap], t->totalSize, 12, 0);
-
-	/* Try AGP before kicking anything out of local mem */
-	if (!t->memBlock && heap == R128_LOCAL_TEX_HEAP) {
-	    t->memBlock = mmAllocMem(r128ctx->texHeap[R128_AGP_TEX_HEAP],
-				     t->totalSize, 12, 0);
-
-	    if (t->memBlock) heap = t->heap = R128_AGP_TEX_HEAP;
-	}
-
-	/* Kick out textures until the requested texture fits */
-	while (!t->memBlock) {
-	    if (r128ctx->TexObjList[heap].prev->bound) {
-		fprintf(stderr,
-			"r128UploadTexImages: ran into bound texture\n");
-		return -1;
-	    }
-	    if (r128ctx->TexObjList[heap].prev ==
-		&(r128ctx->TexObjList[heap])) {
-		if (r128ctx->r128Screen->IsPCI) {
-		    fprintf(stderr, "r128UploadTexImages: upload texture "
-			    "failure on local texture heaps, sz=%d\n",
-			    t->totalSize);
-		    return -1;
-		} else if (heap == R128_LOCAL_TEX_HEAP) {
-		    heap = t->heap = R128_AGP_TEX_HEAP;
-		    continue;
-		} else {
-		    fprintf(stderr, "r128UploadTexImages: upload texture "
-			    "failure on both local and AGP texture heaps, "
-			    "sz=%d\n",
-			    t->totalSize);
-		    return -1;
-		}
-	    }
-
-	    r128DestroyTexObj(r128ctx, r128ctx->TexObjList[heap].prev);
-
-	    t->memBlock = mmAllocMem(r128ctx->texHeap[heap],
-				     t->totalSize, 12, 0);
-	}
-
-	/* Set the base offset of the texture image */
-	t->bufAddr = (unsigned char *)r128ctx->r128Screen->texOffset[heap];
-	t->bufAddr += t->memBlock->ofs;
-
-	maxLevel = ((t->regs.size_pitch & R128_TEX_SIZE_MASK) >>
-		    R128_TEX_SIZE_SHIFT);
-	minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >>
-		    R128_TEX_MIN_SIZE_SHIFT);
-
-	/* Update the hardware's texture image addresses */
-	switch (t->bound) {
-	case 1:
-	    /* Set texture offsets */
-	    if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) {
-		for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-		    r128ctx->regs.prim_tex_offset[i] = (CARD32)t->bufAddr;
-	    } else {
-		for (i = maxLevel; i >= minLevel; i--)
-		    r128ctx->regs.prim_tex_offset[i] =
-			t->image[maxLevel-i].offset + (CARD32)t->bufAddr;
-	    }
-	    /* Fix AGP texture offsets */
-	    if (heap == R128_AGP_TEX_HEAP)
-		for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-		    r128ctx->regs.prim_tex_offset[i] +=
-			R128_AGP_TEX_OFFSET +
-			r128ctx->r128Screen->agpTexOffset;
-	    /* Force loading the new state into the hardware */
-	    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	    r128ctx->dirty_context |= R128_CTX_TEX0STATE;
-	    break;
-
-	case 2:
-	    /* Set texture offsets */
-	    if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) {
-		for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-		    r128ctx->regs.sec_tex_offset[i] = (CARD32)t->bufAddr;
+   int i;
+   int minLevel;
+   int maxLevel;
+   int heap;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s( %p, %p )\n",
+	       __FUNCTION__, r128ctx->glCtx, t );
+   }
+
+   if ( !t ) return 0;
+
+   /* Choose the heap appropriately */
+   heap = t->heap = R128_LOCAL_TEX_HEAP;
+   if ( !r128ctx->r128Screen->IsPCI &&
+	t->totalSize > r128ctx->r128Screen->texSize[heap] ) {
+      heap = t->heap = R128_AGP_TEX_HEAP;
+   }
+
+   /* Do we need to eject LRU texture objects? */
+   if ( !t->memBlock ) {
+      /* Allocate a memory block on a 4k boundary (1<<12 == 4096) */
+      t->memBlock = mmAllocMem( r128ctx->texHeap[heap], t->totalSize, 12, 0 );
+
+      /* Try AGP before kicking anything out of local mem */
+      if ( !t->memBlock && heap == R128_LOCAL_TEX_HEAP ) {
+	 t->memBlock = mmAllocMem( r128ctx->texHeap[R128_AGP_TEX_HEAP],
+				   t->totalSize, 12, 0 );
+
+	 if ( t->memBlock )
+	    heap = t->heap = R128_AGP_TEX_HEAP;
+      }
+
+      /* Kick out textures until the requested texture fits */
+      while ( !t->memBlock ) {
+	 if ( r128ctx->TexObjList[heap].prev->bound ) {
+	    fprintf( stderr,
+		     "r128UploadTexImages: ran into bound texture\n" );
+	    return -1;
+	 }
+	 if ( r128ctx->TexObjList[heap].prev == &r128ctx->TexObjList[heap] ) {
+	    if ( r128ctx->r128Screen->IsPCI ) {
+	       fprintf( stderr, "r128UploadTexImages: upload texture "
+			"failure on local texture heaps, sz=%d\n",
+			t->totalSize );
+	       return -1;
+	    } else if ( heap == R128_LOCAL_TEX_HEAP ) {
+	       heap = t->heap = R128_AGP_TEX_HEAP;
+	       continue;
 	    } else {
-		for (i = maxLevel; i >= minLevel; i--)
-		    r128ctx->regs.sec_tex_offset[i] =
-			t->image[maxLevel-i].offset + (CARD32)t->bufAddr;
-	    }
-	    /* Fix AGP texture offsets */
-	    if (heap == R128_AGP_TEX_HEAP)
-		for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-		    r128ctx->regs.sec_tex_offset[i] +=
-			R128_AGP_TEX_OFFSET +
-			r128ctx->r128Screen->agpTexOffset;
-	    /* Force loading the new state into the hardware */
-	    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	    r128ctx->dirty_context |= R128_CTX_TEX1STATE;
-	    break;
+	       fprintf( stderr, "r128UploadTexImages: upload texture "
+			"failure on both local and AGP texture heaps, "
+			"sz=%d\n",
+			t->totalSize );
+	       return -1;
+	    }
+	 }
+
+	 r128DestroyTexObj( r128ctx, r128ctx->TexObjList[heap].prev );
+
+	 t->memBlock = mmAllocMem( r128ctx->texHeap[heap],
+				   t->totalSize, 12, 0 );
+      }
+
+      /* Set the base offset of the texture image */
+      t->bufAddr = r128ctx->r128Screen->texOffset[heap] + t->memBlock->ofs;
+
+      maxLevel = ((t->setup.tex_size_pitch & R128_TEX_SIZE_MASK) >>
+		  R128_TEX_SIZE_SHIFT);
+      minLevel = ((t->setup.tex_size_pitch & R128_TEX_MIN_SIZE_MASK) >>
+		  R128_TEX_MIN_SIZE_SHIFT);
+
+      /* Set texture offsets */
+      if ( t->setup.tex_cntl & R128_MIP_MAP_DISABLE ) {
+	 for ( i = 0 ; i < R128_TEX_MAXLEVELS ; i++ ) {
+	    t->setup.tex_offset[i] = t->bufAddr;
+	 }
+      } else {
+	 for ( i = maxLevel ; i >= minLevel ; i-- ) {
+	    t->setup.tex_offset[i] =
+	       (t->image[maxLevel-i].offset + t->bufAddr);
+	 }
+      }
+      /* Fix AGP texture offsets */
+      if ( heap == R128_AGP_TEX_HEAP ) {
+	 for ( i = 0 ; i < R128_TEX_MAXLEVELS ; i++ ) {
+	    t->setup.tex_offset[i] += R128_AGP_TEX_OFFSET +
+	       r128ctx->r128Screen->agpTexOffset;
+	 }
+      }
+
+      /* Force loading the new state into the hardware */
+      switch ( t->bound ) {
+      case 1:
+	 r128ctx->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_TEX0;
+	 break;
+
+      case 2:
+	 r128ctx->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_TEX1;
+	 break;
+
+      default:
+	 return -1;
+      }
+   }
+
+   /* Let the world know we've used this memory recently */
+   r128UpdateTexLRU( r128ctx, t );
+
+   /* Upload any images that are new */
+   if ( t->dirty_images ) {
+      int num_levels = (((t->setup.tex_size_pitch & R128_TEX_SIZE_MASK) >>
+			 R128_TEX_SIZE_SHIFT) -
+			((t->setup.tex_size_pitch & R128_TEX_MIN_SIZE_MASK) >>
+			 R128_TEX_MIN_SIZE_SHIFT));
+
+      for ( i = 0 ; i <= num_levels ; i++ ) {
+	 if ( t->dirty_images & (1 << i) ) {
+	    r128UploadSubImage( r128ctx, t, i, 0, 0,
+				t->image[i].width, t->image[i].height );
+	 }
+      }
 
-	default:
-	    return -1;
-	}
-    }
+      r128ctx->setup.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
 
-    /* Let the world know we've used this memory recently */
-    r128UpdateTexLRU(r128ctx, t);
+      r128ctx->dirty |= R128_UPLOAD_CONTEXT;
+   }
 
-    /* Upload any images that are new */
-    if (t->dirty_images) {
-	int num_levels = (((t->regs.size_pitch & R128_TEX_SIZE_MASK) >>
-			   R128_TEX_SIZE_SHIFT) -
-			  ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >>
-			   R128_TEX_MIN_SIZE_SHIFT));
-
-	for (i = 0; i <= num_levels; i++) {
-	    if (t->dirty_images & (1<<i)) {
-		r128UploadSubImage(r128ctx, t, i, 0, 0,
-				   t->image[i].width, t->image[i].height);
-	    }
-	}
-
-	r128ctx->regs.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
+   t->dirty_images = 0;
+   return 0;
+}
 
-	r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	r128ctx->dirty_context |= R128_CTX_ENGINESTATE;
-    }
 
-    t->dirty_images = 0;
-    return 0;
-}
+/*
+ * Texture combiners:
+ */
 
-/* Update the hardware state for texture unit 0 */
-/* NOTE: This function is only called while holding the hardware lock */
-static void r128UpdateTex0State(r128ContextPtr r128ctx)
-{
-    GLcontext                *ctx = r128ctx->glCtx;
-    r128TexObjPtr             t;
-    struct gl_texture_object *tObj;
-    int                       i;
-    CARD32                    tex_size_pitch, tex_combine_cntl;
-
-    /* Only update the hardware texture state if the texture is current,
-       complete and enabled. */
-    if (!(tObj = ctx->Texture.Unit[0].Current))       return;
-    if ((tObj != ctx->Texture.Unit[0].CurrentD[2]) &&
-	(tObj != ctx->Texture.Unit[0].CurrentD[1]))   return;
-    if (!tObj->Complete)                              return;
-
-    /* If neither tex0 nor tex1 is enabled, then disable tex0.  However,
-       if tex1 is enabled but tex0 is disabled, then we need to enable
-       tex0 and have it to copy the input (see how tex_combine_cntl is
-       setup below). */
-    if (!(ctx->Texture.Enabled & (ENABLE_TEX0 | ENABLE_TEX1))) {
-	r128ctx->regs.tex_cntl_c &= ~R128_TEXMAP_ENABLE;
-	return;
-    }
-
-    r128ctx->regs.scale_3d_cntl &= ~R128_TEX_CACHE_SPLIT;
-
-    /* If this is the first time the texture has been used, then create
-       a new texture object for it. */
-    t = tObj->DriverData;
-    if (!t) t = r128CreateTexObj(r128ctx, tObj);
-    if (!t) return;
-
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
-	fprintf(stderr, "r128UpdateTex0State(%p, 0x%08x)\n",
-		tObj, (int)t->dirty_images);
-
-    /* Force any texture images to be loaded into the hardware */
-    if (t->dirty_images) r128ctx->dirty |= R128_UPDATE_TEX0IMAGES;
-
-    /* Bind texture to texture 0 unit */
-    r128ctx->CurrentTexObj[0] = t;
-    t->bound = 1;
-
-    if (t->memBlock) r128UpdateTexLRU(r128ctx, t);
-
-    /* Set the texture environment state */
-    switch (ctx->Texture.Unit[0].EnvMode) {
-    case GL_REPLACE:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	case GL_LUMINANCE_ALPHA:
-	case GL_INTENSITY:
-	    tex_combine_cntl = (R128_COMB_DIS                |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_DIS          |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_RGB:
-	case GL_LUMINANCE:
-	    tex_combine_cntl = (R128_COMB_DIS                |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_COPY_INP     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_ALPHA:
-	    tex_combine_cntl = (R128_COMB_COPY_INP           |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_DIS          |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    case GL_BLEND:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	case GL_LUMINANCE_ALPHA:
-	    switch (r128ctx->regs.constant_color_c &
-		    R128_CONSTANT_COLOR_MASK) {
-	    case R128_CONSTANT_COLOR_ZERO:
-		tex_combine_cntl = (R128_COMB_MODULATE           |
-				    R128_COLOR_FACTOR_NTEX       |
-				    R128_INPUT_FACTOR_INT_COLOR  |
-				    R128_COMB_ALPHA_MODULATE     |
-				    R128_ALPHA_FACTOR_TEX_ALPHA  |
-				    R128_INP_FACTOR_A_INT_ALPHA);
-		break;
-	    case R128_CONSTANT_COLOR_ONE:
-	    default:
-		tex_combine_cntl = (R128_COMB_MODULATE           |
-				    R128_COLOR_FACTOR_TEX        |
-				    R128_INPUT_FACTOR_INT_COLOR  |
-				    R128_COMB_ALPHA_MODULATE     |
-				    R128_ALPHA_FACTOR_TEX_ALPHA  |
-				    R128_INP_FACTOR_A_INT_ALPHA);
-		r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
-		break;
-	    }
-	    break;
-	case GL_RGB:
-	case GL_LUMINANCE:
-	    switch (r128ctx->regs.constant_color_c &
-		    R128_CONSTANT_COLOR_MASK) {
-	    case R128_CONSTANT_COLOR_ZERO:
-		tex_combine_cntl = (R128_COMB_MODULATE           |
-				    R128_COLOR_FACTOR_NTEX       |
-				    R128_INPUT_FACTOR_INT_COLOR  |
-				    R128_COMB_ALPHA_COPY_INP     |
-				    R128_ALPHA_FACTOR_TEX_ALPHA  |
-				    R128_INP_FACTOR_A_INT_ALPHA);
-		break;
-	    case R128_CONSTANT_COLOR_ONE:
-	    default:
-		tex_combine_cntl = (R128_COMB_MODULATE           |
-				    R128_COLOR_FACTOR_TEX        |
-				    R128_INPUT_FACTOR_INT_COLOR  |
-				    R128_COMB_ALPHA_COPY_INP     |
-				    R128_ALPHA_FACTOR_TEX_ALPHA  |
-				    R128_INP_FACTOR_A_INT_ALPHA);
-		r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
-		break;
-	    }
-	    break;
-	case GL_ALPHA:
-	    tex_combine_cntl = (R128_COMB_COPY_INP           |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_MODULATE     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_INTENSITY:
-	    switch (r128ctx->regs.constant_color_c &
-		    R128_CONSTANT_COLOR_MASK) {
-	    case R128_CONSTANT_COLOR_ZERO:
-		tex_combine_cntl = (R128_COMB_MODULATE           |
-				    R128_COLOR_FACTOR_NTEX       |
-				    R128_INPUT_FACTOR_INT_COLOR  |
-				    R128_COMB_ALPHA_MODULATE     |
-				    R128_ALPHA_FACTOR_NTEX_ALPHA |
-				    R128_INP_FACTOR_A_INT_ALPHA);
-		break;
-	    case R128_CONSTANT_COLOR_ONE:
-	    default:
-		tex_combine_cntl = (R128_COMB_MODULATE           |
-				    R128_COLOR_FACTOR_TEX        |
-				    R128_INPUT_FACTOR_INT_COLOR  |
-				    R128_COMB_ALPHA_MODULATE     |
-				    R128_ALPHA_FACTOR_TEX_ALPHA  |
-				    R128_INP_FACTOR_A_INT_ALPHA);
-		r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
-		break;
+#define COLOR_COMB_DISABLE	(R128_COMB_DIS |			\
+				 R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_COPY_INPUT	(R128_COMB_COPY_INP |			\
+				 R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_MODULATE	(R128_COMB_MODULATE |			\
+				 R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_MODULATE_NTEX (R128_COMB_MODULATE |			\
+				  R128_COLOR_FACTOR_NTEX)
+#define COLOR_COMB_ADD		(R128_COMB_ADD |			\
+				 R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_BLEND_TEX	(R128_COMB_BLEND_TEXTURE |		\
+				 R128_COLOR_FACTOR_TEX)
+
+#define ALPHA_COMB_DISABLE	(R128_COMB_ALPHA_DIS |			\
+				 R128_ALPHA_FACTOR_TEX_ALPHA)
+#define ALPHA_COMB_COPY_INPUT	(R128_COMB_ALPHA_COPY_INP |		\
+				 R128_ALPHA_FACTOR_TEX_ALPHA)
+#define ALPHA_COMB_MODULATE	(R128_COMB_ALPHA_MODULATE |		\
+				 R128_ALPHA_FACTOR_TEX_ALPHA)
+#define ALPHA_COMB_MODULATE_NTEX (R128_COMB_ALPHA_MODULATE |		\
+				  R128_ALPHA_FACTOR_NTEX_ALPHA)
+#define ALPHA_COMB_ADD		(R128_COMB_ADD |			\
+				 R128_ALPHA_FACTOR_TEX_ALPHA)
+
+#define INPUT_INTERP		(R128_INPUT_FACTOR_INT_COLOR |		\
+				 R128_INP_FACTOR_A_INT_ALPHA)
+#define INPUT_PREVIOUS		(R128_INPUT_FACTOR_PREV_COLOR |		\
+				 R128_INP_FACTOR_A_PREV_ALPHA)
+
+static void r128UpdateTextureStage( GLcontext *ctx, int unit )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   int source = r128ctx->tmu_source[unit];
+   struct gl_texture_object *tObj;
+   r128TexObjPtr t;
+   GLuint enabled;
+   CARD32 combine;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s( %p, %d )\n",
+	       __FUNCTION__, ctx, unit );
+   }
+
+   enabled = (ctx->Texture.ReallyEnabled >> (source * 4)) & TEXTURE0_ANY;
+   if ( enabled != TEXTURE0_2D && enabled != TEXTURE0_1D )
+      return;
+
+   /* Only update the hardware texture state if the texture is current,
+    * complete and enabled.
+    */
+   tObj = ctx->Texture.Unit[source].Current;
+   if ( !tObj || !tObj->Complete )
+      return;
+
+   if ( ( tObj != ctx->Texture.Unit[source].CurrentD[2] ) &&
+	( tObj != ctx->Texture.Unit[source].CurrentD[1] ) )
+      return;
+
+   /* We definately have a valid texture now */
+   t = tObj->DriverData;
+
+   if ( unit == 0 ) {
+      combine = INPUT_INTERP;
+   } else {
+      combine = INPUT_PREVIOUS;
+   }
+
+   /* Set the texture environment state */
+   switch ( ctx->Texture.Unit[source].EnvMode ) {
+   case GL_REPLACE:
+      switch ( tObj->Image[0]->Format ) {
+      case GL_RGBA:
+      case GL_LUMINANCE_ALPHA:
+      case GL_INTENSITY:
+	 combine |= (COLOR_COMB_DISABLE |		/* C = Ct            */
+		     ALPHA_COMB_DISABLE);		/* A = At            */
+	 break;
+      case GL_RGB:
+      case GL_LUMINANCE:
+	 combine |= (COLOR_COMB_DISABLE |		/* C = Ct            */
+		     ALPHA_COMB_COPY_INPUT);		/* A = Af            */
+	 break;
+      case GL_ALPHA:
+	 combine |= (COLOR_COMB_COPY_INPUT |		/* C = Cf            */
+		     ALPHA_COMB_DISABLE);		/* A = At            */
+	 break;
+      case GL_COLOR_INDEX:
+      default:
+	 return;
+      }
+      break;
+
+   case GL_MODULATE:
+      switch ( tObj->Image[0]->Format ) {
+      case GL_RGBA:
+      case GL_LUMINANCE_ALPHA:
+      case GL_INTENSITY:
+	 combine |= (COLOR_COMB_MODULATE |		/* C = CfCt          */
+		     ALPHA_COMB_MODULATE);		/* A = AfAt          */
+	 break;
+      case GL_RGB:
+      case GL_LUMINANCE:
+	 combine |= (COLOR_COMB_MODULATE |		/* C = CfCt          */
+		     ALPHA_COMB_COPY_INPUT);		/* A = Af            */
+	 break;
+      case GL_ALPHA:
+	 combine |= (COLOR_COMB_COPY_INPUT |		/* C = Cf            */
+		     ALPHA_COMB_MODULATE);		/* A = AfAt          */
+	 break;
+      case GL_COLOR_INDEX:
+      default:
+	 return;
+      }
+      break;
+
+   case GL_DECAL:
+      switch ( tObj->Image[0]->Format ) {
+      case GL_RGBA:
+	 combine |= (COLOR_COMB_BLEND_TEX |		/* C = Cf(1-At)+CtAt */
+		     ALPHA_COMB_COPY_INPUT);		/* A = Af            */
+	 break;
+      case GL_RGB:
+	 combine |= (COLOR_COMB_DISABLE |		/* C = Ct            */
+		     ALPHA_COMB_COPY_INPUT);		/* A = Af            */
+	 break;
+      case GL_ALPHA:
+      case GL_LUMINANCE:
+      case GL_LUMINANCE_ALPHA:
+      case GL_INTENSITY:
+	 /* Undefined behaviour - just copy the incoming fragment */
+	 combine |= (COLOR_COMB_COPY_INPUT |		/* C = undefined     */
+		     ALPHA_COMB_COPY_INPUT);		/* A = undefined     */
+	 break;
+      case GL_COLOR_INDEX:
+      default:
+	 return;
+      }
+      break;
+
+   case GL_BLEND:
+      /* Catch the cases of GL_BLEND we can't handle (yet, in some cases).
+       */
+      if ( r128ctx->blend_flags ) {
+	 r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+      }
+      switch ( tObj->Image[0]->Format ) {
+      case GL_RGBA:
+      case GL_LUMINANCE_ALPHA:
+	 switch ( r128ctx->env_color ) {
+	 case 0x00000000:
+	    combine |= (COLOR_COMB_MODULATE_NTEX |	/* C = Cf(1-Ct)      */
+			ALPHA_COMB_MODULATE);		/* A = AfAt          */
+	    break;
+	 case 0xffffffff:
+	    if ( unit == 0 ) {
+	       combine |= (COLOR_COMB_MODULATE_NTEX |	/* C = Cf(1-Ct)      */
+			   ALPHA_COMB_MODULATE);	/* A = AfAt          */
+	    } else {
+	       combine |= (COLOR_COMB_ADD |		/* C = Cf+Ct         */
+			   ALPHA_COMB_COPY_INPUT);	/* A = Af            */
 	    }
-	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    case GL_MODULATE:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	case GL_LUMINANCE_ALPHA:
-	case GL_INTENSITY:
-	    tex_combine_cntl = (R128_COMB_MODULATE           |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_MODULATE     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_RGB:
-	case GL_LUMINANCE:
-	    tex_combine_cntl = (R128_COMB_MODULATE           |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_COPY_INP     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_ALPHA:
-	    tex_combine_cntl = (R128_COMB_COPY_INP           |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_MODULATE     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    case GL_DECAL:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	    tex_combine_cntl = (R128_COMB_BLEND_TEXTURE      |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_COPY_INP     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_RGB:
-	    tex_combine_cntl = (R128_COMB_DIS                |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_COPY_INP     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_ALPHA:
-	case GL_LUMINANCE:
-	case GL_LUMINANCE_ALPHA:
-	case GL_INTENSITY:
-	    /* Undefined behaviour - just copy the input */
-	    tex_combine_cntl = (R128_COMB_COPY_INP           |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_COPY_INP     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    case GL_ADD:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	case GL_LUMINANCE_ALPHA:
-	case GL_INTENSITY:
-	    tex_combine_cntl = (R128_COMB_ADD                |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_MODULATE     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_RGB:
-	case GL_LUMINANCE:
-	    tex_combine_cntl = (R128_COMB_ADD                |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_COPY_INP     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_ALPHA:
-	    tex_combine_cntl = (R128_COMB_COPY_INP           |
-				R128_COLOR_FACTOR_TEX        |
-				R128_INPUT_FACTOR_INT_COLOR  |
-				R128_COMB_ALPHA_MODULATE     |
-				R128_ALPHA_FACTOR_TEX_ALPHA  |
-				R128_INP_FACTOR_A_INT_ALPHA);
-	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    default:
-	return;
-    }
-
-    /* If tex0 is disabled, then make sure it just copies the input */
-    if (!(ctx->Texture.Enabled & ENABLE_TEX0))
-	tex_combine_cntl = (R128_COMB_COPY_INP           |
-			    R128_COLOR_FACTOR_TEX        |
-			    R128_INPUT_FACTOR_INT_COLOR  |
-			    R128_COMB_ALPHA_COPY_INP     |
-			    R128_ALPHA_FACTOR_TEX_ALPHA  |
-			    R128_INP_FACTOR_A_INT_ALPHA);
-
-    /* Enable tex0 */
-    r128ctx->regs.tex_cntl_c |= R128_TEXMAP_ENABLE;
-
-    tex_size_pitch  = r128ctx->regs.tex_size_pitch_c;
-    tex_size_pitch &= ~R128_TEX_SIZE_PITCH_MASK;
-    tex_size_pitch |= t->regs.size_pitch << R128_TEX_SIZE_PITCH_SHIFT;
-
-    /* Set the primary texture state in r128ctx->regs */
-    r128ctx->regs.prim_tex_cntl_c             = t->regs.tex_cntl;
-    r128ctx->regs.prim_texture_combine_cntl_c = tex_combine_cntl;
-    r128ctx->regs.tex_size_pitch_c            = tex_size_pitch;
-    r128ctx->regs.prim_texture_border_color_c = t->regs.border_color;
-
-    /* Set texture offsets */
-    if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) {
-	for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-	    r128ctx->regs.prim_tex_offset[i] = (CARD32)t->bufAddr;
-    } else {
-	int maxLevel = ((t->regs.size_pitch & R128_TEX_SIZE_MASK) >>
-			R128_TEX_SIZE_SHIFT);
-	int minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >>
-			R128_TEX_MIN_SIZE_SHIFT);
-	for (i = maxLevel; i >= minLevel; i--)
-	    r128ctx->regs.prim_tex_offset[i] =
-		t->image[maxLevel-i].offset + (CARD32)t->bufAddr;
-    }
-    /* Fix AGP texture offsets */
-    if (t->heap == R128_AGP_TEX_HEAP)
-	for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-	    r128ctx->regs.prim_tex_offset[i] +=
-		R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset;
-
-    /* Force loading the new state into the hardware */
-    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-    r128ctx->dirty_context |= R128_CTX_TEX0STATE | R128_CTX_ENGINESTATE;
-}
-
-/* Update the hardware state for texture unit 1 */
-/* NOTE: This function is only called while holding the hardware lock */
-static void r128UpdateTex1State(r128ContextPtr r128ctx)
-{
-    GLcontext                *ctx = r128ctx->glCtx;
-    r128TexObjPtr             t;
-    struct gl_texture_object *tObj;
-    int                       i;
-    CARD32                    tex_size_pitch, tex_combine_cntl, tex_cntl;
-
-    /* Only update the hardware texture state if the texture is current,
-       complete and enabled. */
-    if (!(tObj = ctx->Texture.Unit[1].Current))       return;
-    if ((tObj != ctx->Texture.Unit[1].CurrentD[2]) &&
-	(tObj != ctx->Texture.Unit[1].CurrentD[1]))   return;
-    if (!tObj->Complete)                              return;
-
-    /* If tex1 is not enabled, then disable it */
-    if (!(ctx->Texture.Enabled & ENABLE_TEX1)) {
-	r128ctx->regs.tex_cntl_c &= ~R128_SEC_TEXMAP_ENABLE;
-	return;
-    }
-
-    /* If te1 is enabled, split the texel cache */
-    r128ctx->regs.scale_3d_cntl |= R128_TEX_CACHE_SPLIT;
-
-    /* If this is the first time the texture has been used, then create
-       a new texture object for it. */
-    t = tObj->DriverData;
-    if (!t) t = r128CreateTexObj(r128ctx, tObj);
-    if (!t) return;
-
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
-	fprintf(stderr, "r128UpdateTex1State(%p, 0x%08x)\n",
-		tObj, (int)t->dirty_images);
-
-    /* Force any texture images to be loaded into the hardware */
-    if (t->dirty_images) r128ctx->dirty |= R128_UPDATE_TEX1IMAGES;
-
-    /* Bind texture to texture 1 unit */
-    r128ctx->CurrentTexObj[1] = t;
-    t->bound = 2;
-
-    if (t->memBlock) r128UpdateTexLRU(r128ctx, t);
-
-    /* Set the texture environment state */
-    switch (ctx->Texture.Unit[1].EnvMode) {
-    case GL_REPLACE:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	case GL_LUMINANCE_ALPHA:
-	case GL_INTENSITY:
-	    tex_combine_cntl = (R128_COMB_DIS                 |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_DIS           |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
 	    break;
-	case GL_RGB:
-	case GL_LUMINANCE:
-	    tex_combine_cntl = (R128_COMB_DIS                 |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_COPY_INP      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_ALPHA:
-	    tex_combine_cntl = (R128_COMB_COPY_INP            |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_DIS           |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    case GL_BLEND:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	case GL_LUMINANCE_ALPHA:
-	    switch ( r128ctx->regs.constant_color_c & R128_CONSTANT_COLOR_MASK ) {
-	    case R128_CONSTANT_COLOR_ZERO:
-		tex_combine_cntl = (R128_COMB_MODULATE            |
-				    R128_COLOR_FACTOR_NTEX        |
-				    R128_INPUT_FACTOR_PREV_COLOR  |
-				    R128_COMB_ALPHA_MODULATE      |
-				    R128_ALPHA_FACTOR_TEX_ALPHA   |
-				    R128_INP_FACTOR_A_PREV_ALPHA);
-		break;
-	    case R128_CONSTANT_COLOR_ONE:
-	    default:
-		tex_combine_cntl = (R128_COMB_MODULATE            |
-				    R128_COLOR_FACTOR_TEX         |
-				    R128_INPUT_FACTOR_PREV_COLOR  |
-				    R128_COMB_ALPHA_MODULATE      |
-				    R128_ALPHA_FACTOR_TEX_ALPHA   |
-				    R128_INP_FACTOR_A_PREV_ALPHA);
-		r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
-		break;
+	 default:
+	    combine |= (COLOR_COMB_MODULATE |		/* C = fallback      */
+			ALPHA_COMB_MODULATE);		/* A = fallback      */
+	    r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+	    break;
+	 }
+	 break;
+      case GL_RGB:
+      case GL_LUMINANCE:
+	 switch ( r128ctx->env_color ) {
+	 case 0x00000000:
+	    combine |= (COLOR_COMB_MODULATE_NTEX |	/* C = Cf(1-Ct)      */
+			ALPHA_COMB_COPY_INPUT);		/* A = Af            */
+	    break;
+	 case 0xffffffff:
+	    if ( unit == 0 ) {
+	       combine |= (COLOR_COMB_MODULATE_NTEX |	/* C = Cf(1-Ct)      */
+			   ALPHA_COMB_COPY_INPUT);	/* A = Af            */
+	    } else {
+	       combine |= (COLOR_COMB_ADD |		/* C = Cf+Ct         */
+			   ALPHA_COMB_COPY_INPUT);	/* A = Af            */
 	    }
 	    break;
-	case GL_RGB:
-	case GL_LUMINANCE:
-	    switch (r128ctx->regs.constant_color_c &
-		    R128_CONSTANT_COLOR_MASK) {
-	    case R128_CONSTANT_COLOR_ZERO:
-		tex_combine_cntl = (R128_COMB_MODULATE            |
-				    R128_COLOR_FACTOR_NTEX        |
-				    R128_INPUT_FACTOR_PREV_COLOR  |
-				    R128_COMB_ALPHA_COPY_INP      |
-				    R128_ALPHA_FACTOR_TEX_ALPHA   |
-				    R128_INP_FACTOR_A_PREV_ALPHA );
-		break;
-	    case R128_CONSTANT_COLOR_ONE:
-	    default:
-		tex_combine_cntl = (R128_COMB_MODULATE            |
-				    R128_COLOR_FACTOR_TEX         |
-				    R128_INPUT_FACTOR_PREV_COLOR  |
-				    R128_COMB_ALPHA_COPY_INP      |
-				    R128_ALPHA_FACTOR_TEX_ALPHA   |
-				    R128_INP_FACTOR_A_PREV_ALPHA );
-		r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
-		break;
+	 default:
+	    combine |= (COLOR_COMB_MODULATE |		/* C = fallback      */
+			ALPHA_COMB_COPY_INPUT);		/* A = fallback      */
+	    r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+	    break;
+	 }
+	 break;
+      case GL_ALPHA:
+	 combine |= (COLOR_COMB_COPY_INPUT |		/* C = Cf            */
+		     ALPHA_COMB_MODULATE);		/* A = AfAt          */
+	 break;
+      case GL_INTENSITY:
+	 switch ( r128ctx->env_color ) {
+	 case 0x00000000:
+	    combine |= (COLOR_COMB_MODULATE_NTEX |	/* C = Cf(1-Ct)      */
+			ALPHA_COMB_MODULATE_NTEX);	/* A = Af(1-Ct)      */
+	    break;
+	 case 0x00ffffff:
+	    if ( unit == 0 ) {
+	       combine |= (COLOR_COMB_MODULATE_NTEX |	/* C = Cf(1-Ct)      */
+			   ALPHA_COMB_MODULATE_NTEX);	/* A = Af(1-Ct)      */
+	    } else {
+	       combine |= (COLOR_COMB_ADD |		/* C = Cf+Ct         */
+			   ALPHA_COMB_COPY_INPUT);	/* A = Af            */
 	    }
 	    break;
-	case GL_ALPHA:
-	    tex_combine_cntl = (R128_COMB_COPY_INP            |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_MODULATE      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_INTENSITY:
-	    switch (r128ctx->regs.constant_color_c &
-		    R128_CONSTANT_COLOR_MASK) {
-	    case R128_CONSTANT_COLOR_ZERO:
-		tex_combine_cntl = (R128_COMB_MODULATE            |
-				    R128_COLOR_FACTOR_NTEX        |
-				    R128_INPUT_FACTOR_PREV_COLOR  |
-				    R128_COMB_ALPHA_MODULATE      |
-				    R128_ALPHA_FACTOR_NTEX_ALPHA  |
-				    R128_INP_FACTOR_A_PREV_ALPHA);
-		break;
-	    case R128_CONSTANT_COLOR_ONE:
-	    default:
-		tex_combine_cntl = (R128_COMB_MODULATE            |
-				    R128_COLOR_FACTOR_TEX         |
-				    R128_INPUT_FACTOR_PREV_COLOR  |
-				    R128_COMB_ALPHA_MODULATE      |
-				    R128_ALPHA_FACTOR_TEX_ALPHA   |
-				    R128_INP_FACTOR_A_PREV_ALPHA);
-		r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
-		break;
+	 case 0xffffffff:
+	    if ( unit == 0 ) {
+	       combine |= (COLOR_COMB_MODULATE_NTEX |	/* C = Cf(1-Ct)      */
+			   ALPHA_COMB_MODULATE_NTEX);	/* A = Af(1-Ct)      */
+	    } else {
+	       combine |= (COLOR_COMB_ADD |		/* C = Cf+Ct         */
+			   ALPHA_COMB_ADD);		/* A = Af+At         */
 	    }
-	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    case GL_MODULATE:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	case GL_LUMINANCE_ALPHA:
-	case GL_INTENSITY:
-	    tex_combine_cntl = (R128_COMB_MODULATE            |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_MODULATE      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_RGB:
-	case GL_LUMINANCE:
-	    tex_combine_cntl = (R128_COMB_MODULATE            |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_COPY_INP      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_ALPHA:
-	    tex_combine_cntl = (R128_COMB_COPY_INP            |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_MODULATE      |
-				 R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    case GL_DECAL:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	    tex_combine_cntl = (R128_COMB_BLEND_TEXTURE       |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_COPY_INP      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_RGB:
-	    tex_combine_cntl = (R128_COMB_DIS                 |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_COPY_INP      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_ALPHA:
-	case GL_LUMINANCE:
-	case GL_LUMINANCE_ALPHA:
-	case GL_INTENSITY:
-	    /* Undefined behaviour - just copy the input */
-	    tex_combine_cntl = (R128_COMB_COPY_INP            |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_COPY_INP      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    case GL_ADD:
-	switch (tObj->Image[0]->Format) {
-	case GL_RGBA:
-	case GL_LUMINANCE_ALPHA:
-	case GL_INTENSITY:
-	    tex_combine_cntl = (R128_COMB_ADD                 |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_MODULATE      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_RGB:
-	case GL_LUMINANCE:
-	    tex_combine_cntl = (R128_COMB_ADD                 |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_COPY_INP      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
-	    break;
-	case GL_ALPHA:
-	    tex_combine_cntl = (R128_COMB_COPY_INP            |
-				R128_COLOR_FACTOR_TEX         |
-				R128_INPUT_FACTOR_PREV_COLOR  |
-				R128_COMB_ALPHA_MODULATE      |
-				R128_ALPHA_FACTOR_TEX_ALPHA   |
-				R128_INP_FACTOR_A_PREV_ALPHA);
 	    break;
-	case GL_COLOR_INDEX:
-	default:
-	    return;
-	}
-	break;
-
-    default:
-	return;
-    }
-
-    /* Enable tex1 */
-    r128ctx->regs.tex_cntl_c |= R128_SEC_TEXMAP_ENABLE;
-
-    tex_size_pitch  = r128ctx->regs.tex_size_pitch_c;
-    tex_size_pitch &= ~R128_SEC_TEX_SIZE_PITCH_MASK;
-    tex_size_pitch |= t->regs.size_pitch << R128_SEC_TEX_SIZE_PITCH_SHIFT;
-
-    tex_cntl        = t->regs.tex_cntl | R128_SEC_SELECT_SEC_ST;
-
-    /* Set the secondary texture state in r128ctx->regs */
-    r128ctx->regs.sec_tex_cntl_c              = tex_cntl;
-    r128ctx->regs.sec_tex_combine_cntl_c      = tex_combine_cntl;
-    r128ctx->regs.tex_size_pitch_c            = tex_size_pitch;
-    r128ctx->regs.sec_texture_border_color_c  = t->regs.border_color;
-
-    /* Set texture offsets */
-    if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) {
-	for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-	    r128ctx->regs.sec_tex_offset[i] = (CARD32)t->bufAddr;
-    } else {
-	int maxLevel = ((t->regs.size_pitch & R128_TEX_SIZE_MASK) >>
-			R128_TEX_SIZE_SHIFT);
-	int minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >>
-			R128_TEX_MIN_SIZE_SHIFT);
-	for (i = maxLevel; i >= minLevel; i--)
-	    r128ctx->regs.sec_tex_offset[i] =
-		t->image[maxLevel-i].offset + (CARD32)t->bufAddr;
-    }
-    /* Fix AGP texture offsets */
-    if (t->heap == R128_AGP_TEX_HEAP)
-	for (i = 0; i < R128_TEX_MAXLEVELS; i++)
-	    r128ctx->regs.sec_tex_offset[i] +=
-		R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset;
-
-    /* Force loading the new state into the hardware */
-    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-    r128ctx->dirty_context |= R128_CTX_TEX1STATE | R128_CTX_ENGINESTATE;
+	 default:
+	    combine |= (COLOR_COMB_MODULATE |		/* C = fallback      */
+			ALPHA_COMB_MODULATE);		/* A = fallback      */
+	    r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+	    break;
+	 }
+	 break;
+      case GL_COLOR_INDEX:
+      default:
+	 return;
+      }
+      break;
+
+   case GL_ADD:
+      switch ( tObj->Image[0]->Format ) {
+      case GL_RGBA:
+      case GL_LUMINANCE_ALPHA:
+      case GL_INTENSITY:
+	 combine |= (COLOR_COMB_ADD |			/* C = Cf+Ct         */
+		     ALPHA_COMB_MODULATE);		/* A = AfAt          */
+	 break;
+      case GL_RGB:
+      case GL_LUMINANCE:
+	 combine |= (COLOR_COMB_ADD |			/* C = Cf+Ct         */
+		     ALPHA_COMB_COPY_INPUT);		/* A = Af            */
+	 break;
+      case GL_ALPHA:
+	 combine |= (COLOR_COMB_COPY_INPUT |		/* C = Cf            */
+		     ALPHA_COMB_MODULATE);		/* A = AfAt          */
+	 break;
+      case GL_COLOR_INDEX:
+      default:
+	 return;
+      }
+      break;
+
+   default:
+      return;
+   }
+
+   t->setup.tex_combine_cntl = combine;
+}
+
+static void r128UpdateTextureObject( GLcontext *ctx, int unit )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   int source = r128ctx->tmu_source[unit];
+   struct gl_texture_object *tObj;
+   r128TexObjPtr t;
+   GLuint enabled;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s( %p, %d ) really=0x%x\n",
+	       __FUNCTION__, ctx, unit, ctx->Texture.ReallyEnabled );
+   }
+
+   /* Disable all texturing until it is known to be good */
+   r128ctx->setup.tex_cntl_c &= ~(R128_TEXMAP_ENABLE |
+				  R128_SEC_TEXMAP_ENABLE);
+
+   enabled = (ctx->Texture.ReallyEnabled >> (source * 4)) & TEXTURE0_ANY;
+   if ( enabled != TEXTURE0_2D && enabled != TEXTURE0_1D ) {
+      if ( enabled )
+	 r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+      return;
+   }
+
+   /* Only update the hardware texture state if the texture is current,
+    * complete and enabled.
+    */
+   tObj = ctx->Texture.Unit[source].Current;
+   if ( !tObj || !tObj->Complete ) {
+      r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+      return;
+   }
+
+   if ( ( tObj != ctx->Texture.Unit[source].CurrentD[2] ) &&
+	( tObj != ctx->Texture.Unit[source].CurrentD[1] ) ) {
+      r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+      return;
+   }
+
+   if ( !tObj->DriverData ) {
+      /* If this is the first time the texture has been used, then create
+       * a new texture object for it.
+       */
+      r128CreateTexObj( r128ctx, tObj );
+
+      if ( !tObj->DriverData ) {
+	 /* Can't create a texture object... */
+	 fprintf( stderr, "%s: texture object creation failed!\n",
+		  __FUNCTION__ );
+	 r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
+	 return;
+      }
+   }
+
+   /* We definately have a valid texture now */
+   t = tObj->DriverData;
+
+   /* Force the texture unit state to be loaded into the hardware */
+   r128ctx->dirty |= R128_UPLOAD_CONTEXT | (R128_UPLOAD_TEX0 << unit);
+
+   /* Force any texture images to be loaded into the hardware */
+   if ( t->dirty_images )
+      r128ctx->dirty |= (R128_UPLOAD_TEX0IMAGES << unit);
+
+   /* Bind to the given texture unit */
+   r128ctx->CurrentTexObj[unit] = t;
+   t->bound = unit + 1;
+
+   if ( t->memBlock )
+      r128UpdateTexLRU( r128ctx, t );
+
+   if ( unit == 0 ) {
+      r128ctx->setup.tex_cntl_c       |= R128_TEXMAP_ENABLE;
+      r128ctx->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 0;
+      r128ctx->setup.scale_3d_cntl    &= ~R128_TEX_CACHE_SPLIT;
+
+      t->setup.tex_cntl &= ~R128_SEC_SELECT_SEC_ST;
+   } else {
+      t->setup.tex_cntl |=  R128_SEC_SELECT_SEC_ST;
+
+      r128ctx->setup.tex_cntl_c       |= (R128_TEXMAP_ENABLE |
+					  R128_SEC_TEXMAP_ENABLE) ;
+      r128ctx->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 16;
+      r128ctx->setup.scale_3d_cntl    |= R128_TEX_CACHE_SPLIT;
+   }
 }
 
 /* Update the hardware texture state */
-/* NOTE: This function is only called while holding the hardware lock */
-void r128UpdateTextureState(r128ContextPtr r128ctx)
+void r128UpdateTextureState( GLcontext *ctx )
 {
-    /* Clear the GL_BLEND texturing fallback */
-    r128ctx->Fallback &= ~R128_FALLBACK_TEXTURE;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s( %p ) en=0x%x\n",
+	       __FUNCTION__, ctx, ctx->Texture.ReallyEnabled );
+   }
 
+   /* Clear any texturing fallbacks */
+   r128ctx->Fallback &= ~R128_FALLBACK_TEXTURE;
+
     /* Unbind any currently bound textures */
-    if (r128ctx->CurrentTexObj[0]) r128ctx->CurrentTexObj[0]->bound = 0;
-    if (r128ctx->CurrentTexObj[1]) r128ctx->CurrentTexObj[1]->bound = 0;
-    r128ctx->CurrentTexObj[0] = NULL;
-    r128ctx->CurrentTexObj[1] = NULL;
-
-    if (r128ctx->glCtx->Enabled & (TEXTURE0_3D|TEXTURE1_3D))
-       r128ctx->Fallback |= R128_FALLBACK_TEXTURE;
-
-    /* Update the texture unit 0/1 state */
-    r128UpdateTex0State(r128ctx);
-    r128UpdateTex1State(r128ctx);
+   if ( r128ctx->CurrentTexObj[0] ) r128ctx->CurrentTexObj[0]->bound = 0;
+   if ( r128ctx->CurrentTexObj[1] ) r128ctx->CurrentTexObj[1]->bound = 0;
+   r128ctx->CurrentTexObj[0] = NULL;
+   r128ctx->CurrentTexObj[1] = NULL;
+
+   r128ctx->setup.tex_size_pitch_c = 0x00000000;
+
+   r128UpdateTextureObject( ctx, 0 );
+   r128UpdateTextureStage( ctx, 0 );
+
+   if ( r128ctx->multitex ) {
+      r128UpdateTextureObject( ctx, 1 );
+      r128UpdateTextureStage( ctx, 1 );
+   }
+
+   r128ctx->dirty |= R128_UPLOAD_CONTEXT;
 }
 
+
 /* Set the texture wrap mode */
-static void r128SetTexWrap(r128TexObjPtr t, GLenum swrap, GLenum twrap)
+static void r128SetTexWrap( r128TexObjPtr t, GLenum swrap, GLenum twrap )
 {
-    t->regs.tex_cntl &= ~(R128_TEX_CLAMP_S_MASK | R128_TEX_CLAMP_T_MASK);
+   t->setup.tex_cntl &= ~(R128_TEX_CLAMP_S_MASK | R128_TEX_CLAMP_T_MASK);
 
-    switch (swrap) {
-    case GL_CLAMP:  t->regs.tex_cntl |= R128_TEX_CLAMP_S_CLAMP; break;
-    case GL_REPEAT: t->regs.tex_cntl |= R128_TEX_CLAMP_S_WRAP;  break;
-    default: /* ERROR!! */ return;
-    }
-
-    switch (twrap) {
-    case GL_CLAMP:  t->regs.tex_cntl |= R128_TEX_CLAMP_T_CLAMP; break;
-    case GL_REPEAT: t->regs.tex_cntl |= R128_TEX_CLAMP_T_WRAP;  break;
-    default: /* ERROR!! */ return;
-    }
+   switch ( swrap ) {
+   case GL_CLAMP:
+      t->setup.tex_cntl |= R128_TEX_CLAMP_S_CLAMP;
+      break;
+   case GL_REPEAT:
+      t->setup.tex_cntl |= R128_TEX_CLAMP_S_WRAP;
+      break;
+   }
+
+   switch ( twrap ) {
+   case GL_CLAMP:
+      t->setup.tex_cntl |= R128_TEX_CLAMP_T_CLAMP;
+      break;
+   case GL_REPEAT:
+      t->setup.tex_cntl |= R128_TEX_CLAMP_T_WRAP;
+      break;
+   }
 }
 
 /* Set the texture filter mode */
-static void r128SetTexFilter(r128TexObjPtr t, GLenum minf, GLenum magf)
+static void r128SetTexFilter( r128TexObjPtr t, GLenum minf, GLenum magf )
 {
-    t->regs.tex_cntl &= ~(R128_MIN_BLEND_MASK | R128_MAG_BLEND_MASK);
+   t->setup.tex_cntl &= ~(R128_MIN_BLEND_MASK | R128_MAG_BLEND_MASK);
 
-    switch (minf) {
-    case GL_NEAREST:
-	t->regs.tex_cntl |= R128_MIN_BLEND_NEAREST;
-	break;
-    case GL_LINEAR:
-	t->regs.tex_cntl |= R128_MIN_BLEND_LINEAR;
-	break;
-    case GL_NEAREST_MIPMAP_NEAREST:
-	t->regs.tex_cntl |= R128_MIN_BLEND_MIPNEAREST;
-	break;
-    case GL_LINEAR_MIPMAP_NEAREST:
-	t->regs.tex_cntl |= R128_MIN_BLEND_LINEARMIPNEAREST;
-	break;
-    case GL_NEAREST_MIPMAP_LINEAR:
-	t->regs.tex_cntl |= R128_MIN_BLEND_MIPLINEAR;
-	break;
-    case GL_LINEAR_MIPMAP_LINEAR:
-	t->regs.tex_cntl |= R128_MIN_BLEND_LINEARMIPLINEAR;
-	break;
-    default: /* ERROR!! */ return;
-    }
-
-    switch (magf) {
-    case GL_NEAREST:
-	t->regs.tex_cntl |= R128_MAG_BLEND_NEAREST;
-	break;
-    case GL_LINEAR:
-	t->regs.tex_cntl |= R128_MAG_BLEND_LINEAR;
-	break;
-    }
+   switch ( minf ) {
+   case GL_NEAREST:
+      t->setup.tex_cntl |= R128_MIN_BLEND_NEAREST;
+      break;
+   case GL_LINEAR:
+      t->setup.tex_cntl |= R128_MIN_BLEND_LINEAR;
+      break;
+   case GL_NEAREST_MIPMAP_NEAREST:
+      t->setup.tex_cntl |= R128_MIN_BLEND_MIPNEAREST;
+      break;
+   case GL_LINEAR_MIPMAP_NEAREST:
+      t->setup.tex_cntl |= R128_MIN_BLEND_LINEARMIPNEAREST;
+      break;
+   case GL_NEAREST_MIPMAP_LINEAR:
+      t->setup.tex_cntl |= R128_MIN_BLEND_MIPLINEAR;
+      break;
+   case GL_LINEAR_MIPMAP_LINEAR:
+      t->setup.tex_cntl |= R128_MIN_BLEND_LINEARMIPLINEAR;
+      break;
+   }
+
+   switch ( magf ) {
+   case GL_NEAREST:
+      t->setup.tex_cntl |= R128_MAG_BLEND_NEAREST;
+      break;
+   case GL_LINEAR:
+      t->setup.tex_cntl |= R128_MAG_BLEND_LINEAR;
+      break;
+   }
 }
 
 /* Set the texture border color */
-static void r128SetTexBorderColor(r128TexObjPtr t, GLubyte c[4])
+static void r128SetTexBorderColor( r128TexObjPtr t, GLubyte c[4] )
 {
-    t->regs.border_color = r128PackColor(32, c[0], c[1], c[2], c[3]);
+   t->setup.tex_border_color = r128PackColor( 32, c[0], c[1], c[2], c[3] );
 }
 
+
+/*
+============================================================================
+
+Driver functions called directly from mesa
+
+============================================================================
+*/
+
+
 /* Set the texture environment state */
-static void r128DDTexEnv(GLcontext *ctx, GLenum target, GLenum pname,
-			 const GLfloat *param)
+static void r128DDTexEnv( GLcontext *ctx, GLenum target,
+			  GLenum pname, const GLfloat *param )
 {
-    r128ContextPtr          r128ctx = R128_CONTEXT(ctx);
-    struct gl_texture_unit *texUnit;
-    GLubyte                 c[4];
-    CARD32                  col;
-
-    /* FIXME: Add texture LOD bias extension */
-
-    switch (pname) {
-    case GL_TEXTURE_ENV_MODE:
-	/* TexEnv modes are handled in UpdateTextureState */
-	r128FlushVertices(r128ctx);
-	r128ctx->dirty |= R128_UPDATE_TEXSTATE;
-	break;
-    case GL_TEXTURE_ENV_COLOR:
-	texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
-	FLOAT_RGBA_TO_UBYTE_RGBA(texUnit->EnvColor, c);
-	col = r128PackColor(32, c[0], c[1], c[2], c[3]);
-	if (r128ctx->regs.constant_color_c != col) {
-	    r128FlushVertices(r128ctx);
-	    r128ctx->regs.constant_color_c = col;
-
-	    /* FIXME: Load into hardware now??? */
-	    r128ctx->dirty         |= R128_UPDATE_CONTEXT;
-	    r128ctx->dirty_context |= R128_CTX_TEXENVSTATE;
-	}
-	break;
-    default:
-	return;
-    }
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   struct gl_texture_unit *texUnit;
+   GLubyte c[4];
+   int bias;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s( %s )\n",
+	       __FUNCTION__, gl_lookup_enum_by_nr( pname ) );
+   }
+
+   switch ( pname ) {
+   case GL_TEXTURE_ENV_MODE:
+      /* TexEnv modes are handled in UpdateTextureState */
+      FLUSH_BATCH( r128ctx );
+      r128ctx->new_state |= R128_NEW_TEXTURE | R128_NEW_ALPHA;
+      break;
+
+   case GL_TEXTURE_ENV_COLOR:
+      texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+      FLOAT_RGBA_TO_UBYTE_RGBA( c, texUnit->EnvColor );
+      r128ctx->env_color = r128PackColor( 32, c[0], c[1], c[2], c[3] );
+      if ( r128ctx->setup.constant_color_c != r128ctx->env_color ) {
+	 FLUSH_BATCH( r128ctx );
+	 r128ctx->setup.constant_color_c = r128ctx->env_color;
+
+	 r128ctx->new_state |= R128_NEW_TEXTURE;
+
+	 /* More complex multitexture/multipass fallbacks for GL_BLEND
+	  * can be done later, but this allows a single pass GL_BLEND
+	  * in some cases (ie. Performer town demo).
+	  */
+	 r128ctx->blend_flags &= ~R128_BLEND_ENV_COLOR;
+	 if ( r128ctx->env_color != 0x00000000 &&
+	      r128ctx->env_color != 0xff000000 /*&&
+	      r128ctx->env_color != 0x00ffffff &&
+	      r128ctx->env_color != 0xffffffff */ ) {
+	    r128ctx->blend_flags |= R128_BLEND_ENV_COLOR;
+	 }
+      }
+      break;
+
+   case GL_TEXTURE_LOD_BIAS_EXT:
+      /* GTH: This isn't exactly correct, but gives good results up to a
+       * certain point.  It is better than completely ignoring the LOD
+       * bias.  Unfortunately there isn't much range in the bias, the
+       * spec mentions strides that vary between 0.5 and 2.0 but these
+       * numbers don't seem to relate the the GL LOD bias value at all.
+       */
+      if ( param[0] >= 1.0 ) {
+	 bias = -128;
+      } else if ( param[0] >= 0.5 ) {
+	 bias = -64;
+      } else if ( param[0] >= 0.25 ) {
+	 bias = 0;
+      } else if ( param[0] >= 0.0 ) {
+	 bias = 63;
+      } else {
+	 bias = 127;
+      }
+      if ( r128ctx->lod_bias != bias ) {
+	 FLUSH_BATCH( r128ctx );
+	 r128ctx->lod_bias = bias;
+
+	 r128ctx->new_state |= R128_NEW_RENDER;
+      }
+      break;
+
+   default:
+      return;
+   }
 }
 
 /* Upload a new texture image */
-static void r128DDTexImage(GLcontext *ctx, GLenum target,
-			   struct gl_texture_object *tObj, GLint level,
-			   GLint internalFormat,
-			   const struct gl_texture_image *image)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    r128TexObjPtr  t;
-
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
-	fprintf(stderr, "r128DDTexImage(%p, level %d)\n", tObj, level);
-
-    if ((target != GL_TEXTURE_2D) && (target != GL_TEXTURE_1D)) return;
-    if (level >= R128_TEX_MAXLEVELS) return;
-
-    t = (r128TexObjPtr)tObj->DriverData;
-    if (t) {
-	if (t->bound) r128FlushVertices(r128ctx);
-
-	/* Destroy the old texture, and upload a new one.  The actual
-           uploading of the texture image occurs in the UploadSubImage
-           function. */
-	r128DestroyTexObj(r128ctx, t);
-	r128ctx->dirty |= R128_UPDATE_TEXSTATE;
-    }
+static void r128DDTexImage( GLcontext *ctx, GLenum target,
+			    struct gl_texture_object *tObj, GLint level,
+			    GLint internalFormat,
+			    const struct gl_texture_image *image )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   r128TexObjPtr t;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API )
+      fprintf( stderr, "%s( %p, level %d )\n", __FUNCTION__, tObj, level );
+
+   if ( ( target != GL_TEXTURE_2D ) && ( target != GL_TEXTURE_1D ) ) return;
+   if ( level >= R128_TEX_MAXLEVELS ) return;
+
+   t = (r128TexObjPtr)tObj->DriverData;
+   if ( t ) {
+      if ( t->bound ) FLUSH_BATCH( r128ctx );
+
+      /* Destroy the old texture, and upload a new one.  The actual
+       * uploading of the texture image occurs in the UploadSubImage
+       * function.
+       */
+      r128DestroyTexObj( r128ctx, t );
+      r128ctx->new_state |= R128_NEW_TEXTURE;
+   }
 }
 
 /* Upload a new texture sub-image */
-static void r128DDTexSubImage(GLcontext *ctx, GLenum target,
-			      struct gl_texture_object *tObj, GLint level,
-			      GLint xoffset, GLint yoffset,
-			      GLsizei width, GLsizei height,
-			      GLint internalFormat,
-			      const struct gl_texture_image *image)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    r128TexObjPtr  t;
-
-    if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API)
-	fprintf(stderr, "r128DDTexSubImage(%p, level %d) "
-		"size: %d,%d of %d,%d\n",
-		tObj, level, width, height, image->Width, image->Height);
-
-    if ((target != GL_TEXTURE_2D) && (target != GL_TEXTURE_1D)) return;
-    if (level >= R128_TEX_MAXLEVELS) return;
-
-    t = (r128TexObjPtr)tObj->DriverData;
-    if (t) {
-	if (t->bound) r128FlushVertices(r128ctx);
-
-	LOCK_HARDWARE(r128ctx);
-	r128UploadSubImage(r128ctx, t, level,
-			   xoffset, yoffset, width, height);
-	UNLOCK_HARDWARE(r128ctx);
-
-	/* Update the context state */
-	r128ctx->regs.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
-
-	r128ctx->dirty           |= (R128_UPDATE_CONTEXT |
-				     R128_UPDATE_TEXSTATE);
-	r128ctx->dirty_context   |= (R128_CTX_ENGINESTATE |
-				     R128_CTX_TEX0STATE   |
-				     R128_CTX_TEX1STATE);
-    }
+static void r128DDTexSubImage( GLcontext *ctx, GLenum target,
+			       struct gl_texture_object *tObj, GLint level,
+			       GLint xoffset, GLint yoffset,
+			       GLsizei width, GLsizei height,
+			       GLint internalFormat,
+			       const struct gl_texture_image *image )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   r128TexObjPtr t;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s( %p, level %d ) size: %d,%d of %d,%d\n",
+	       __FUNCTION__, tObj, level, width, height,
+	       image->Width, image->Height );
+   }
+
+   if ( ( target != GL_TEXTURE_2D ) && ( target != GL_TEXTURE_1D ) ) return;
+   if ( level >= R128_TEX_MAXLEVELS ) return;
+
+   t = (r128TexObjPtr)tObj->DriverData;
+   if ( t ) {
+      if ( t->bound ) FLUSH_BATCH( r128ctx );
+
+      LOCK_HARDWARE( r128ctx );
+      r128UploadSubImage( r128ctx, t, level,
+			  xoffset, yoffset, width, height );
+      UNLOCK_HARDWARE( r128ctx );
+
+      /* Update the context state */
+      r128ctx->setup.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
+
+      r128ctx->new_state |= R128_NEW_TEXTURE;
+   }
 }
 
 /* Set the texture parameter state */
-static void r128DDTexParameter(GLcontext *ctx, GLenum target,
-			       struct gl_texture_object *tObj,
-			       GLenum pname, const GLfloat *params)
-{
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    r128TexObjPtr  t       = (r128TexObjPtr)tObj->DriverData;
-
-    if (!t) return;
-    if ((target != GL_TEXTURE_2D) && (target != GL_TEXTURE_1D)) return;
-
-    switch (pname) {
-    case GL_TEXTURE_MIN_FILTER:
-    case GL_TEXTURE_MAG_FILTER:
-	if (t->bound) r128FlushVertices(r128ctx);
-	r128SetTexFilter(t, tObj->MinFilter, tObj->MagFilter);
-	break;
-
-    case GL_TEXTURE_WRAP_S:
-    case GL_TEXTURE_WRAP_T:
-	if (t->bound) r128FlushVertices(r128ctx);
-	r128SetTexWrap(t, tObj->WrapS, tObj->WrapT);
-	break;
-
-    case GL_TEXTURE_BORDER_COLOR:
-	if (t->bound) r128FlushVertices(r128ctx);
-	r128SetTexBorderColor(t, tObj->BorderColor);
-	break;
-
-    default:
-	return;
-    }
+static void r128DDTexParameter( GLcontext *ctx, GLenum target,
+				struct gl_texture_object *tObj,
+				GLenum pname, const GLfloat *params )
+{
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s( %s )\n",
+	       __FUNCTION__, gl_lookup_enum_by_nr( pname ) );
+   }
+
+   if ( !t || !t->bound ) return;
+   if ( ( target != GL_TEXTURE_2D ) && ( target != GL_TEXTURE_1D ) ) return;
+
+   switch ( pname ) {
+   case GL_TEXTURE_MIN_FILTER:
+   case GL_TEXTURE_MAG_FILTER:
+      if ( t->bound ) FLUSH_BATCH( r128ctx );
+      r128SetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+      break;
+
+   case GL_TEXTURE_WRAP_S:
+   case GL_TEXTURE_WRAP_T:
+      if ( t->bound ) FLUSH_BATCH( r128ctx );
+      r128SetTexWrap( t, tObj->WrapS, tObj->WrapT );
+      break;
+
+   case GL_TEXTURE_BORDER_COLOR:
+      if ( t->bound ) FLUSH_BATCH( r128ctx );
+      r128SetTexBorderColor( t, tObj->BorderColor );
+      break;
+
+   default:
+      return;
+   }
 
-    r128ctx->dirty |= R128_UPDATE_TEXSTATE;
+   r128ctx->new_state |= R128_NEW_TEXTURE;
 }
 
 /* Bind a texture to the currently active texture unit */
-static void r128DDBindTexture(GLcontext *ctx, GLenum target,
-			      struct gl_texture_object *tObj)
+static void r128DDBindTexture( GLcontext *ctx, GLenum target,
+			       struct gl_texture_object *tObj )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-
-    r128FlushVertices(r128ctx);
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   GLint unit = ctx->Texture.CurrentUnit;
 
-    /* Unbind the old texture */
-    if (r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit]) {
-	r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0;
-	r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit] = NULL;
-    }
+   if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+      fprintf( stderr, "%s( %p ) unit=%d\n",
+	       __FUNCTION__, tObj, unit );
+   }
+
+   FLUSH_BATCH( r128ctx );
+
+   /* Unbind the old texture */
+   if ( r128ctx->CurrentTexObj[unit] ) {
+      r128ctx->CurrentTexObj[unit]->bound &= ~(unit+1);
+      r128ctx->CurrentTexObj[unit] = NULL;
+   }
 
-    /* The actualy binding occurs in the Tex[01]UpdateState function */
-    r128ctx->dirty |= R128_UPDATE_TEXSTATE;
+   /* The actualy binding occurs in the Tex[01]UpdateState function */
+   r128ctx->new_state |= R128_NEW_TEXTURE;
 }
 
 /* Remove texture from AGP/local texture memory */
-static void r128DDDeleteTexture(GLcontext *ctx,
-				struct gl_texture_object *tObj)
+static void r128DDDeleteTexture( GLcontext *ctx,
+				 struct gl_texture_object *tObj )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    r128TexObjPtr  t       = (r128TexObjPtr)tObj->DriverData;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
 
-    if (t) {
-	if (t->bound) {
-	    r128FlushVertices(r128ctx);
-
-	    r128ctx->CurrentTexObj[t->bound-1] = 0;
-	    r128ctx->dirty |= R128_UPDATE_TEXSTATE;
-	}
-
-	r128DestroyTexObj(r128ctx, t);
-	tObj->DriverData = NULL;
-    }
+   if ( t ) {
+      if ( t->bound ) {
+	 FLUSH_BATCH( r128ctx );
+
+	 r128ctx->CurrentTexObj[t->bound-1] = 0;
+	 r128ctx->new_state |= R128_NEW_TEXTURE;
+      }
+
+      r128DestroyTexObj( r128ctx, t );
+      tObj->DriverData = NULL;
+   }
 }
 
 /* Determine if a texture is currently residing in either AGP/local
-   texture memory */
-static GLboolean r128DDIsTextureResident(GLcontext *ctx,
-					 struct gl_texture_object *tObj)
+ * texture memory.
+ */
+static GLboolean r128DDIsTextureResident( GLcontext *ctx,
+					  struct gl_texture_object *tObj )
 {
-    r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
+   r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
 
-    return t && t->memBlock;
+   return t && t->memBlock;
 }
 
 /* Initialize the driver's texture functions */
-void r128DDInitTextureFuncs(GLcontext *ctx)
+void r128DDInitTextureFuncs( GLcontext *ctx )
 {
-    ctx->Driver.TexEnv                  = r128DDTexEnv;
-    ctx->Driver.TexImage                = r128DDTexImage;
-    ctx->Driver.TexSubImage             = r128DDTexSubImage;
-    ctx->Driver.TexParameter            = r128DDTexParameter;
-    ctx->Driver.BindTexture             = r128DDBindTexture;
-    ctx->Driver.DeleteTexture           = r128DDDeleteTexture;
-    ctx->Driver.UpdateTexturePalette    = NULL;
-    ctx->Driver.ActiveTexture           = NULL;
-    ctx->Driver.IsTextureResident       = r128DDIsTextureResident;
-    ctx->Driver.PrioritizeTexture       = NULL;
+   ctx->Driver.TexEnv			= r128DDTexEnv;
+   ctx->Driver.TexImage			= r128DDTexImage;
+   ctx->Driver.TexSubImage		= r128DDTexSubImage;
+   ctx->Driver.TexParameter		= r128DDTexParameter;
+   ctx->Driver.BindTexture		= r128DDBindTexture;
+   ctx->Driver.DeleteTexture		= r128DDDeleteTexture;
+   ctx->Driver.UpdateTexturePalette	= NULL;
+   ctx->Driver.ActiveTexture		= NULL;
+   ctx->Driver.IsTextureResident	= r128DDIsTextureResident;
+   ctx->Driver.PrioritizeTexture	= NULL;
 }
Index: xc/lib/GL/mesa/src/drv/r128/r128_tex.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_tex.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_tex.h:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_tex.h:1.1	Fri Jun 16 20:03:08 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_tex.h	Tue Dec 12 12:17:08 2000
@@ -1,8 +1,8 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.h,v 1.1 2000/06/17 00:03:08 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.h,v 1.3 2000/12/12 17:17:08 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas. 
+                                               Cedar Park, Texas.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,8 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Gareth Hughes <gareth@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
@@ -38,13 +38,19 @@
 
 #ifdef GLX_DIRECT_RENDERING
 
-extern void r128AgeTextures(r128ContextPtr r128ctx, int heap);
-extern int  r128UploadTexImages(r128ContextPtr r128ctx, r128TexObjPtr t);
-extern void r128UpdateTextureState(r128ContextPtr r128ctx);
-extern void r128DestroyTexObj(r128ContextPtr r128ctx, r128TexObjPtr t);
+extern void r128UpdateTextureState( GLcontext *ctx );
 
-extern void r128DDInitTextureFuncs(GLcontext *ctx);
+extern int r128UploadTexImages( r128ContextPtr r128ctx, r128TexObjPtr t );
 
+extern void r128AgeTextures( r128ContextPtr r128ctx, int heap );
+extern void r128DestroyTexObj( r128ContextPtr r128ctx, r128TexObjPtr t );
+
+extern void r128PrintLocalLRU( r128ContextPtr r128ctx, int heap );
+extern void r128PrintGlobalLRU( r128ContextPtr r128ctx, int heap );
+
+extern void r128DDInitTextureFuncs( GLcontext *ctx );
+
+
 #define R128PACKCOLOR332(r, g, b)                                             \
     (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
 
@@ -64,16 +70,13 @@
 #define R128PACKCOLOR4444(r, g, b, a)                                         \
     ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
 
-static __inline__ CARD32 r128PackColor(GLuint depth,
-				       GLubyte r, GLubyte g,
-				       GLubyte b, GLubyte a)
+static __inline__ CARD32 r128PackColor( GLuint bpp,
+					GLubyte r, GLubyte g,
+					GLubyte b, GLubyte a )
 {
-    switch (depth) {
-    case  8: return R128PACKCOLOR332(r, g, b);
-    case 15: return R128PACKCOLOR1555(r, g, b, a);
-    case 16: return R128PACKCOLOR565(r, g, b);
-    case 24: return R128PACKCOLOR888(r, g, b);
-    case 32: return R128PACKCOLOR8888(r, g, b, a);
+    switch ( bpp ) {
+    case 16: return R128PACKCOLOR565( r, g, b );
+    case 32: return R128PACKCOLOR8888( r, g, b, a );
     default: return 0;
     }
 }
Index: xc/lib/GL/mesa/src/drv/r128/r128_texobj.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_texobj.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_texobj.h:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_texobj.h:1.1	Fri Jun 16 20:03:08 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_texobj.h	Mon Dec  4 14:21:47 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_texobj.h,v 1.1 2000/06/17 00:03:08 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_texobj.h,v 1.3 2000/12/04 19:21:47 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,60 +28,55 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Gareth Hughes <gareth@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
 #ifndef _R128_TEXOBJ_H_
 #define _R128_TEXOBJ_H_
 
+#include "r128_sarea.h"
 #include "mm.h"
 
-#define R128_TEX_MAXLEVELS 11
-
-/* Setup registers for each texture */
-typedef struct {
-    CARD32  tex_cntl;
-    CARD32  size_pitch;
-    CARD32  border_color;
-} r128TextureRegs;
-
 /* Individual texture image information */
 typedef struct {
-    int offset;		/* Offset into locally shared texture space (i.e.,
+    GLuint offset;	/* Offset into locally shared texture space (i.e.,
 			   relative to bufAddr (below) */
-    int width;		/* Width of texture image */
-    int height;		/* Height of texture image */
+    GLuint width;	/* Width of texture image */
+    GLuint height;	/* Height of texture image */
 } r128TexImage;
 
 typedef struct r128_tex_obj r128TexObj, *r128TexObjPtr;
 
 /* Texture object in locally shared texture space */
 struct r128_tex_obj {
-    r128TexObjPtr    next, prev;
+   r128TexObjPtr	next, prev;
 
-    struct gl_texture_object *tObj;	/* Mesa texture object */
+   struct gl_texture_object *tObj;	/* Mesa texture object */
 
-    PMemBlock        memBlock;		/* Memory block containing texture */
-    unsigned char   *bufAddr;		/* Offset to start of locally
+   PMemBlock		memBlock;	/* Memory block containing texture */
+   CARD32		bufAddr;	/* Offset to start of locally
 					   shared texture block */
 
-    CARD32           dirty_images;	/* Flags for whether or not
+   CARD32		dirty_images;	/* Flags for whether or not
 					   images need to be uploaded to
 					   local or AGP texture space */
-    int              bound;		/* Texture unit currently bound to */
-    int              heap;              /* Texture heap currently stored in */
-    r128TexImage     image[R128_TEX_MAXLEVELS]; /* Image data for all
-						   mipmap levels */
-    int              totalSize;		/* Total size of the texture
+
+   GLuint		age;
+   GLint		bound;		/* Texture unit currently bound to */
+   GLint		heap;		/* Texture heap currently stored in */
+   r128TexImage		image[R128_TEX_MAXLEVELS]; /* Image data for all
+						      mipmap levels */
+
+   GLint		totalSize;	/* Total size of the texture
 					   including all mipmap levels */
-    int              internFormat;	/* Internal GL format used to store
+   GLuint		internFormat;	/* Internal GL format used to store
 					   texture on card */
-    int              textureFormat;	/* Actual hardware format */
-    int              texelBytes;	/* Number of bytes per texel */
+   CARD32		textureFormat;	/* Actual hardware format */
+   GLint		texelBytes;	/* Number of bytes per texel */
 
-    r128TextureRegs  regs;		/* Setup regs for texture */
+   r128_texture_regs_t	setup;		/* Setup regs for texture */
 };
 
 #endif /* _R128_TEXOBJ_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_tris.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_tris.c:1.1 xc/lib/GL/mesa/src/drv/r128/r128_tris.c:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_tris.c:1.1	Fri Jun 16 20:03:08 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_tris.c	Mon Dec  4 14:21:47 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.c,v 1.1 2000/06/17 00:03:08 martin Exp $ */ /* -*- c-basic-offset: 4 -*- */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.c,v 1.3 2000/12/04 19:21:47 dawes Exp $ */ /* -*- c-basic-offset: 3 -*- */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,34 +28,59 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
 #include "r128_context.h"
-#include "r128_lock.h"
-#include "r128_reg.h"
-#include "r128_cce.h"
+#include "r128_ioctl.h"
 #include "r128_vb.h"
 #include "r128_tris.h"
 #include "r128_state.h"
 
-static triangle_func tri_tab[0x10];
-static quad_func     quad_tab[0x10];
-static line_func     line_tab[0x10];
-static points_func   points_tab[0x10];
+#include "pipeline.h"
+#include "vbindirect.h"
 
+static struct {
+   points_func		points;
+   line_func		line;
+   triangle_func	triangle;
+   quad_func		quad;
+} rast_tab[R128_MAX_TRIFUNC];
+
 #define R128_COLOR(to, from)                                                \
 do {                                                                        \
-    (to)[0] = (from)[2];                                                    \
-    (to)[1] = (from)[1];                                                    \
-    (to)[2] = (from)[0];                                                    \
-    (to)[3] = (from)[3];                                                    \
+   (to)[0] = (from)[2];                                                    \
+   (to)[1] = (from)[1];                                                    \
+   (to)[2] = (from)[0];                                                    \
+   (to)[3] = (from)[3];                                                    \
 } while (0)
 
+
+static void r128_null_quad( GLcontext *ctx, GLuint v0,
+			    GLuint v1, GLuint v2, GLuint v3, GLuint pv ) {
+}
+static void r128_null_triangle( GLcontext *ctx, GLuint v0,
+				GLuint v1, GLuint v2, GLuint pv ) {
+}
+static void r128_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) {
+}
+
+static void r128_null_points( GLcontext *ctx, GLuint first, GLuint last ) {
+}
+
+static void r128PrintRenderState( const char *msg, GLuint state )
+{
+   fprintf( stderr, "%s: (0x%x) %s%s%s%s%s\n",
+	    msg, state,
+	    (state & R128_FLAT_BIT)       ? "flat, "       : "",
+	    (state & R128_OFFSET_BIT)     ? "offset, "     : "",
+	    (state & R128_TWOSIDE_BIT)    ? "twoside, "    : "",
+	    (state & R128_NODRAW_BIT)     ? "no-draw, "    : "",
+	    (state & R128_FALLBACK_BIT)   ? "fallback"     : "" );
+}
+
 #define IND (0)
 #define TAG(x) x
 #include "r128_tritmp.h"
@@ -88,95 +113,95 @@
 #define TAG(x) x##_twoside_offset_flat
 #include "r128_tritmp.h"
 
+
 /* Initialize the table of points, line and triangle drawing functions */
-void r128TriangleFuncsInit(void)
+void r128DDTriangleFuncsInit( void )
 {
-    init();
-    init_flat();
-    init_offset();
-    init_offset_flat();
-    init_twoside();
-    init_twoside_flat();
-    init_twoside_offset();
-    init_twoside_offset_flat();
+   int i;
+
+   init();
+   init_flat();
+   init_offset();
+   init_offset_flat();
+   init_twoside();
+   init_twoside_flat();
+   init_twoside_offset();
+   init_twoside_offset_flat();
+
+   for ( i = 0 ; i < 0x20 ; i++ ) {
+      if ( (i & (R128_NODRAW_BIT | R128_FALLBACK_BIT)) == R128_NODRAW_BIT ) {
+	 rast_tab[i].points   = r128_null_points;
+	 rast_tab[i].line     = r128_null_line;
+	 rast_tab[i].triangle = r128_null_triangle;
+	 rast_tab[i].quad     = r128_null_quad;
+      }
+   }
 }
 
+
+/* FIXME: Only enable software fallback for stencil in 16 bpp mode after
+ * we have hardware stencil support.
+ */
+#define ALL_FALLBACK	(DD_MULTIDRAW | DD_SELECT | DD_FEEDBACK | DD_STENCIL)
+#define POINT_FALLBACK	(ALL_FALLBACK | DD_POINT_SMOOTH | DD_POINT_ATTEN)
+#define LINE_FALLBACK	(ALL_FALLBACK | DD_LINE_SMOOTH | DD_LINE_STIPPLE)
+#define TRI_FALLBACK	(ALL_FALLBACK | DD_TRI_SMOOTH | DD_TRI_STIPPLE | DD_TRI_UNFILLED)
+#define ANY_FALLBACK	(POINT_FALLBACK | LINE_FALLBACK | TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (/*DD_FLATSHADE |*/ DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET | DD_Z_NEVER)
+
 /* Setup the Point, Line, Triangle and Quad functions based on the
-   current rendering state.  Wherever possible, use the hardware to
-   render the primitive.  Otherwise, fallback to software rendering. */
-void r128ChooseRenderState(GLcontext *ctx)
+ * current rendering state.  Wherever possible, use the hardware to
+ * render the primitive.  Otherwise, fallback to software rendering.
+ */
+void r128DDChooseRenderState( GLcontext *ctx )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    GLuint         flags   = ctx->TriangleCaps;
-
-    /* KW: Includes handling of SWonly rendering:
-     */
-    if (r128ctx->Fallback)
-       return;
-
-    r128ctx->IndirectTriangles = 0;
-
-    if (flags) {
-	CARD32 index    = 0;
-	CARD32 shared   = 0;
- 	CARD32 fallback = R128_FALLBACK_BIT;
-
-	/* KW: I'd prefer to remove SWfallbackDisable & just use
-	 * R128_FALLBACK_BIT throughout this routine.
-	 */
-  	if (r128ctx->SWfallbackDisable) fallback = 0;
-
-	if (flags & DD_FLATSHADE)               shared |= R128_FLAT_BIT;
-	if (flags & DD_TRI_LIGHT_TWOSIDE)       shared |= R128_TWOSIDE_BIT;
-
-	/* TODO: Fix mesa so that these can be handled in
-	 * r128ctx->Fallback.
-	 */
-	if (flags & (DD_MULTIDRAW |
-		     DD_SELECT    |
-		     DD_FEEDBACK))              shared |= R128_FALLBACK_BIT;
-
-	/* FIXME: Only enable in 16 bpp mode after we have hardware
-           stencil support */
-	if (flags & DD_STENCIL)                 shared |= R128_FALLBACK_BIT;
-
-	/* Setup PointFunc */
-	index = shared;
-	if (flags & DD_POINT_SMOOTH)            index  |= fallback;
-
-	r128ctx->RenderIndex = index;
-	r128ctx->PointsFunc  = points_tab[index];
-	if (index & R128_FALLBACK_BIT)
-	    r128ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
-
-	/* Setup LineFunc */
-	index = shared;
-	if (flags & DD_LINE_SMOOTH)             index  |= fallback;
-	if (flags & DD_LINE_STIPPLE)            index  |= fallback;
-
-	r128ctx->RenderIndex |= index;
-	r128ctx->LineFunc     = line_tab[index];
-	if (index & R128_FALLBACK_BIT)
-	    r128ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
-
-	/* Setup TriangleFunc and QuadFunc */
-	index = shared;
-	if (flags & DD_TRI_OFFSET)              index  |= R128_OFFSET_BIT;
-	if (flags & DD_TRI_SMOOTH)              index  |= fallback;
-	if (flags & DD_TRI_UNFILLED)            index  |= fallback;
-	if (flags & DD_TRI_STIPPLE)             index  |= fallback;
-
-	r128ctx->RenderIndex  |= index;
-	r128ctx->TriangleFunc  = tri_tab[index];
-	r128ctx->QuadFunc      = quad_tab[index];
-	if (index & R128_FALLBACK_BIT)
-	    r128ctx->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
-					   DD_QUAD_SW_RASTERIZE);
-    } else if (r128ctx->RenderIndex) {
-	r128ctx->RenderIndex  = 0;
-	r128ctx->PointsFunc   = points_tab[0];
-	r128ctx->LineFunc     = line_tab[0];
-	r128ctx->TriangleFunc = tri_tab[0];
-	r128ctx->QuadFunc     = quad_tab[0];
-    }
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   GLuint flags = ctx->TriangleCaps;
+   CARD32 index = 0;
+
+   if ( r128ctx->Fallback ) {
+      r128ctx->RenderIndex = R128_FALLBACK_BIT;
+      return;
+   }
+
+   if ( flags & ANY_RASTER_FLAGS ) {
+      if ( flags & DD_FLATSHADE )		index |= R128_FLAT_BIT;
+      if ( flags & DD_TRI_LIGHT_TWOSIDE )	index |= R128_TWOSIDE_BIT;
+      if ( flags & DD_TRI_OFFSET )		index |= R128_OFFSET_BIT;
+      if ( flags & DD_Z_NEVER )			index |= R128_NODRAW_BIT;
+   }
+
+   r128ctx->PointsFunc = rast_tab[index].points;
+   r128ctx->LineFunc = rast_tab[index].line;
+   r128ctx->TriangleFunc = rast_tab[index].triangle;
+   r128ctx->QuadFunc = rast_tab[index].quad;
+
+   r128ctx->RenderIndex = index;
+   r128ctx->IndirectTriangles = 0;
+
+   if ( flags & ANY_FALLBACK ) {
+      r128ctx->RenderIndex |= R128_FALLBACK_BIT;
+
+      if ( flags & POINT_FALLBACK ) {
+	 r128ctx->PointsFunc = 0;
+	 r128ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
+      }
+
+      if ( flags & LINE_FALLBACK ) {
+	 r128ctx->LineFunc = 0;
+	 r128ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
+      }
+
+      if ( flags & TRI_FALLBACK ) {
+	 r128ctx->TriangleFunc = 0;
+	 r128ctx->QuadFunc = 0;
+	 r128ctx->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
+					DD_QUAD_SW_RASTERIZE);
+      }
+   }
+
+   if ( 0 ) {
+      gl_print_tri_caps( "tricaps", ctx->TriangleCaps );
+      r128PrintRenderState( "r128 render state", r128ctx->RenderIndex );
+   }
 }
Index: xc/lib/GL/mesa/src/drv/r128/r128_tris.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_tris.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_tris.h:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_tris.h:1.1	Fri Jun 16 20:03:08 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_tris.h	Mon Dec  4 14:21:47 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.h,v 1.1 2000/06/17 00:03:08 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.h,v 1.3 2000/12/04 19:21:47 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,7 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
@@ -39,157 +40,280 @@
 
 #include "r128_vb.h"
 
-extern void r128ChooseRenderState(GLcontext *ctx);
-extern void r128TriangleFuncsInit(void);
+extern void r128DDChooseRenderState(GLcontext *ctx);
+extern void r128DDTriangleFuncsInit(void);
 
-#define R128_FLAT_BIT        0x01
-#define R128_OFFSET_BIT      0x02
-#define R128_TWOSIDE_BIT     0x04
-#define R128_FALLBACK_BIT    0x08
+#define R128_ANTIALIAS_BIT	0x00	/* Ignored for now */
+#define R128_FLAT_BIT		0x01
+#define R128_OFFSET_BIT		0x02
+#define R128_TWOSIDE_BIT	0x04
+#define R128_NODRAW_BIT		0x08
+#define R128_FALLBACK_BIT	0x10
+#define R128_MAX_TRIFUNC	0x20
 
 /* Draw a triangle from the vertices in the vertex buffer */
-static __inline void r128DrawTriangleVB( r128ContextPtr r128ctx,
+static __inline void r128_draw_triangle( r128ContextPtr r128ctx,
 					 r128Vertex *v0,
 					 r128Vertex *v1,
 					 r128Vertex *v2 )
 {
-    int vertsize = r128ctx->vertsize;
-    CARD32 *vb = r128AllocVertexDwordsInlined( r128ctx, 3 * vertsize );
-    int j;
+   int vertsize = r128ctx->vertsize;
+   CARD32 *vb = r128AllocVerticesInline( r128ctx, 3 );
+   int j;
 
 #if defined (USE_X86_ASM)
-    /* GTH: We can safely assume the vertex stride is some number of
-     * dwords, and thus a "rep movsd" is okay.  The vb pointer is
-     * automagically updated with this instruction, so we don't have
-     * to manually take care of incrementing it.
-     */
-    __asm__ __volatile__( "rep ; movsl"
-			  : "=%c" (j)
-			  : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
-			  : "memory" );
-    __asm__ __volatile__( "rep ; movsl"
-			  : "=%c" (j)
-			  : "0" (vertsize), "S" ((long)v1)
-			  : "memory" );
-    __asm__ __volatile__( "rep ; movsl"
-			  : "=%c" (j)
-			  : "0" (vertsize), "S" ((long)v2)
-			  : "memory" );
-#else
-    for (j = 0 ; j < vertsize ; j++)
-        vb[j] = v0->ui[j];
-
-    vb += vertsize;
-    for (j = 0 ; j < vertsize ; j++)
-        vb[j] = v1->ui[j];
-
-    vb += vertsize;
-    for (j = 0 ; j < vertsize ; j++)
-        vb[j] = v2->ui[j];
+   /* GTH: We can safely assume the vertex stride is some number of
+    * dwords, and thus a "rep movsd" is okay.  The vb pointer is
+    * automagically updated with this instruction, so we don't have
+    * to manually take care of incrementing it.
+    */
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
+			 : "memory" );
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "S" ((long)v1)
+			 : "memory" );
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "S" ((long)v2)
+			 : "memory" );
+#else
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = v0->ui[j];
+
+   vb += vertsize;
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = v1->ui[j];
+
+   vb += vertsize;
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = v2->ui[j];
 #endif
 }
 
+/* Draw a quad from the vertices in the vertex buffer */
+static __inline void r128_draw_quad( r128ContextPtr r128ctx,
+				     r128Vertex *v0,
+				     r128Vertex *v1,
+				     r128Vertex *v2,
+				     r128Vertex *v3 )
+{
+   int vertsize = r128ctx->vertsize;
+   CARD32 *vb = r128AllocVerticesInline( r128ctx, 6 );
+   int j;
+
+#if defined (USE_X86_ASM)
+   /* GTH: We can safely assume the vertex stride is some number of
+    * dwords, and thus a "rep movsd" is okay.  The vb pointer is
+    * automagically updated with this instruction, so we don't have
+    * to manually take care of incrementing it.
+    */
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
+			 : "memory" );
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "S" ((long)v1)
+			 : "memory" );
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "S" ((long)v3)
+			 : "memory" );
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "S" ((long)v1)
+			 : "memory" );
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "S" ((long)v2)
+			 : "memory" );
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "S" ((long)v3)
+			 : "memory" );
+#else
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = v0->ui[j];
+
+   vb += vertsize;
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = v1->ui[j];
+
+   vb += vertsize;
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = v3->ui[j];
+
+   vb += vertsize;
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = v1->ui[j];
+
+   vb += vertsize;
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = v2->ui[j];
+
+   vb += vertsize;
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = v3->ui[j];
+#endif
+}
+
 /* Draw a line from the vertices in the vertex buffer */
-static __inline void r128DrawLineVB( r128ContextPtr r128ctx,
+static __inline void r128_draw_line( r128ContextPtr r128ctx,
 				     r128Vertex *tmp0,
 				     r128Vertex *tmp1,
 				     float width )
 {
-    int vertsize = r128ctx->vertsize;
-    CARD32 *vb = r128AllocVertexDwordsInlined( r128ctx, 6 * vertsize );
-    float dx, dy, ix, iy;
-    int j;
-
-    dx = tmp0->vert1.x - tmp1->vert1.x;
-    dy = tmp0->vert1.y - tmp1->vert1.y;
-
-    ix = width * .5; iy = 0;
-
-    if ((ix<.5) && (ix>0.1)) ix = .5; /* I want to see lines with width
-					 0.5 also */
-
-    if (dx * dx > dy * dy) {
-        iy = ix; ix = 0;
-    }
-
-    *(float *)&vb[0] = tmp0->vert1.x - ix;
-    *(float *)&vb[1] = tmp0->vert1.y - iy;
-    for (j = 2 ; j < vertsize ; j++)
-        vb[j] = tmp0->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp1->vert1.x + ix;
-    *(float *)&vb[1] = tmp1->vert1.y + iy;
-    for (j = 2 ; j < vertsize ; j++)
-        vb[j] = tmp1->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp0->vert1.x + ix;
-    *(float *)&vb[1] = tmp0->vert1.y + iy;
-    for (j = 2 ; j < vertsize ; j++)
-        vb[j] = tmp0->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp0->vert1.x - ix;
-    *(float *)&vb[1] = tmp0->vert1.y - iy;
-    for (j = 2 ; j < vertsize ; j++)
-        vb[j] = tmp0->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp1->vert1.x - ix;
-    *(float *)&vb[1] = tmp1->vert1.y - iy;
-    for (j = 2 ; j < vertsize ; j++)
-        vb[j] = tmp1->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp1->vert1.x + ix;
-    *(float *)&vb[1] = tmp1->vert1.y + iy;
-    for (j = 2 ; j < vertsize ; j++)
-        vb[j] = tmp1->ui[j];
+#if 1
+   int vertsize = r128ctx->vertsize;
+   CARD32 *vb = r128AllocVerticesInline( r128ctx, 6 );
+   float dx, dy, ix, iy;
+   int j;
+
+   dx = tmp0->v.x - tmp1->v.x;
+   dy = tmp0->v.y - tmp1->v.y;
+
+   ix = width * .5; iy = 0;
+
+   if ((ix<.5) && (ix>0.1)) ix = .5; /* I want to see lines with width
+					0.5 also */
+
+   if (dx * dx > dy * dy) {
+      iy = ix; ix = 0;
+   }
+
+   *(float *)&vb[0] = tmp0->v.x - ix;
+   *(float *)&vb[1] = tmp0->v.y - iy;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp0->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp1->v.x + ix;
+   *(float *)&vb[1] = tmp1->v.y + iy;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp1->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp0->v.x + ix;
+   *(float *)&vb[1] = tmp0->v.y + iy;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp0->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp0->v.x - ix;
+   *(float *)&vb[1] = tmp0->v.y - iy;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp0->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp1->v.x - ix;
+   *(float *)&vb[1] = tmp1->v.y - iy;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp1->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp1->v.x + ix;
+   *(float *)&vb[1] = tmp1->v.y + iy;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp1->ui[j];
+
+#else
+
+   int vertsize = r128ctx->vertsize;
+   CARD32 *vb = r128AllocVerticesInline( r128ctx, 2 );
+   int j;
+
+#if defined (USE_X86_ASM)
+   /* GTH: We can safely assume the vertex stride is some number of
+    * dwords, and thus a "rep movsd" is okay.  The vb pointer is
+    * automagically updated with this instruction, so we don't have
+    * to manually take care of incrementing it.
+    */
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "D" ((long)vb), "S" ((long)tmp0)
+			 : "memory" );
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "S" ((long)tmp1)
+			 : "memory" );
+#else
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = tmp0->ui[j];
+
+   vb += vertsize;
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = tmp1->ui[j];
+#endif
+#endif
 }
 
 /* Draw a point from the vertices in the vertex buffer */
-static __inline void r128DrawPointVB( r128ContextPtr r128ctx,
+static __inline void r128_draw_point( r128ContextPtr r128ctx,
 				      r128Vertex *tmp, float sz )
 {
-    int vertsize = r128ctx->vertsize;
-    CARD32 *vb = r128AllocVertexDwordsInlined( r128ctx, 6 * vertsize );
-    int j;
-
-    *(float *)&vb[0] = tmp->vert1.x - sz;
-    *(float *)&vb[1] = tmp->vert1.y - sz;
-    for (j = 2 ; j < vertsize ; j++)
-	vb[j] = tmp->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp->vert1.x + sz;
-    *(float *)&vb[1] = tmp->vert1.y - sz;
-    for (j = 2 ; j < vertsize ; j++)
-	vb[j] = tmp->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp->vert1.x + sz;
-    *(float *)&vb[1] = tmp->vert1.y + sz;
-    for (j = 2 ; j < vertsize ; j++)
-	vb[j] = tmp->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp->vert1.x + sz;
-    *(float *)&vb[1] = tmp->vert1.y + sz;
-    for (j = 2 ; j < vertsize ; j++)
-	vb[j] = tmp->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp->vert1.x - sz;
-    *(float *)&vb[1] = tmp->vert1.y + sz;
-    for (j = 2 ; j < vertsize ; j++)
-	vb[j] = tmp->ui[j];
-    vb += vertsize;
-
-    *(float *)&vb[0] = tmp->vert1.x - sz;
-    *(float *)&vb[1] = tmp->vert1.y - sz;
-    for (j = 2 ; j < vertsize ; j++)
-	vb[j] = tmp->ui[j];
+#if 1
+   int vertsize = r128ctx->vertsize;
+   CARD32 *vb = r128AllocVerticesInline( r128ctx, 6 );
+   int j;
+
+   *(float *)&vb[0] = tmp->v.x - sz;
+   *(float *)&vb[1] = tmp->v.y - sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x + sz;
+   *(float *)&vb[1] = tmp->v.y - sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x + sz;
+   *(float *)&vb[1] = tmp->v.y + sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x + sz;
+   *(float *)&vb[1] = tmp->v.y + sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x - sz;
+   *(float *)&vb[1] = tmp->v.y + sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+   vb += vertsize;
+
+   *(float *)&vb[0] = tmp->v.x - sz;
+   *(float *)&vb[1] = tmp->v.y - sz;
+   for (j = 2 ; j < vertsize ; j++)
+      vb[j] = tmp->ui[j];
+#else
+
+   int vertsize = r128ctx->vertsize;
+   CARD32 *vb = r128AllocVerticesInline( r128ctx, 1 );
+   int j;
+
+#if defined (USE_X86_ASM)
+   /* GTH: We can safely assume the vertex stride is some number of
+    * dwords, and thus a "rep movsd" is okay.  The vb pointer is
+    * automagically updated with this instruction, so we don't have
+    * to manually take care of incrementing it.
+    */
+   __asm__ __volatile__( "rep ; movsl"
+			 : "=%c" (j)
+			 : "0" (vertsize), "D" ((long)vb), "S" ((long)tmp)
+			 : "memory" );
+#else
+   for ( j = 0 ; j < vertsize ; j++ )
+      vb[j] = tmp->ui[j];
+#endif
+#endif
 }
 
 #endif
Index: xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h:1.4
--- xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h:1.1	Fri Jun 16 20:03:09 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h	Mon Dec  4 17:46:01 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h,v 1.1 2000/06/17 00:03:09 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h,v 1.4 2000/12/04 22:46:01 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,143 +28,315 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
 #if !defined(TAG) || !defined(IND)
-    this is an error
+this is an error
 #endif
 
 /* Draw a single triangle.  Note that the device-dependent vertex data
    might need to be changed based on the render state. */
-static __inline void TAG(triangle)(GLcontext *ctx,
-				   GLuint e0, GLuint e1, GLuint e2,
-				   GLuint pv)
+static __inline void TAG(triangle)( GLcontext *ctx,
+				    GLuint e0, GLuint e1, GLuint e2,
+				    GLuint pv )
 {
-    r128ContextPtr        r128ctx   = R128_CONTEXT(ctx);
-    int                   vertsize  = r128ctx->vertsize;
-    CARD32               *vb        = r128AllocVertexDwords(r128ctx,
-							    3 * vertsize);
-    struct vertex_buffer *VB        = ctx->VB;
-    r128VertexPtr         r128verts = R128_DRIVER_DATA(VB)->verts;
-    const r128Vertex     *v[3];
-    int                   i, j;
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   struct vertex_buffer *VB = ctx->VB;
+   r128VertexPtr r128verts = R128_DRIVER_DATA(VB)->verts;
+   r128Vertex *v[3];
 
 #if (IND & R128_OFFSET_BIT)
-    GLfloat offset = ctx->Polygon.OffsetUnits * r128ctx->depth_scale;
+   GLfloat offset;
+   GLfloat z[3];
 #endif
 
-#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT))
-    int c[3];
-
-    c[0] = c[1] = c[2] = *(int *)&r128verts[pv].vert1.dif_argb;
+#if (IND & R128_TWOSIDE_BIT)
+   GLuint c[3];
 #endif
+
+   v[0] = &r128verts[e0];
+   v[1] = &r128verts[e1];
+   v[2] = &r128verts[e2];
 
-    v[0] = &r128verts[e0];
-    v[1] = &r128verts[e1];
-    v[2] = &r128verts[e2];
+#if (IND & R128_TWOSIDE_BIT)
+   c[0] = v[0]->ui[4];
+   c[1] = v[1]->ui[4];
+   c[2] = v[2]->ui[4];
+#endif
 
 #if (IND & (R128_TWOSIDE_BIT | R128_OFFSET_BIT))
-    {
-	GLfloat ex = v[0]->vert1.x - v[2]->vert1.x;
-	GLfloat ey = v[0]->vert1.y - v[2]->vert1.y;
-	GLfloat fx = v[1]->vert1.x - v[2]->vert1.x;
-	GLfloat fy = v[1]->vert1.y - v[2]->vert1.y;
-	GLfloat cc  = ex*fy - ey*fx;
-
-#if (IND & R128_TWOSIDE_BIT)
-	{
-	    GLuint  facing        = (cc > 0.0) ^ ctx->Polygon.FrontBit;
-	    GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
-	    if (IND & R128_FLAT_BIT) {
-		R128_COLOR((char *)&c[0], vbcolor[pv]);
-		c[2] = c[1] = c[0];
-	    } else {
-		R128_COLOR((char *)&c[0], vbcolor[e0]);
-		R128_COLOR((char *)&c[1], vbcolor[e1]);
-		R128_COLOR((char *)&c[2], vbcolor[e2]);
-	    }
-	}
+   {
+      GLfloat ex = v[0]->v.x - v[2]->v.x;
+      GLfloat ey = v[0]->v.y - v[2]->v.y;
+      GLfloat fx = v[1]->v.x - v[2]->v.x;
+      GLfloat fy = v[1]->v.y - v[2]->v.y;
+      GLfloat cc  = ex*fy - ey*fx;
+
+#if (IND & R128_TWOSIDE_BIT)
+      {
+	 GLuint  facing        = (cc > 0.0) ^ ctx->Polygon.FrontBit;
+	 GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
+	 if (IND & R128_FLAT_BIT) {
+	    R128_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
+	    v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
+	 } else {
+	    R128_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
+	    R128_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
+	    R128_COLOR( (char *)&v[2]->ui[4], vbcolor[e2] );
+	 }
+      }
 #endif
 
 #if (IND & R128_OFFSET_BIT)
-	{
-	    if (cc * cc > 1e-16) {
-		GLfloat factor = ctx->Polygon.OffsetFactor;
-		GLfloat ez     = v[0]->vert1.z - v[2]->vert1.z;
-		GLfloat fz     = v[1]->vert1.z - v[2]->vert1.z;
-		GLfloat a      = ey*fz - ez*fy;
-		GLfloat b      = ez*fx - ex*fz;
-		GLfloat ic     = 1.0 / cc;
-		GLfloat ac     = a * ic;
-		GLfloat bc     = b * ic;
-		if (ac < 0.0f) ac = -ac;
-		if (bc < 0.0f) bc = -bc;
-		offset += MAX2(ac, bc) * factor;
-	    }
-	}
+      {
+	 offset = ctx->Polygon.OffsetUnits * r128ctx->depth_scale;
+	 z[0] = v[0]->v.z;
+	 z[1] = v[1]->v.z;
+	 z[2] = v[2]->v.z;
+	 if (cc * cc > 1e-16) {
+	    GLfloat ez     = z[0] - z[2];
+	    GLfloat fz     = z[1] - z[2];
+	    GLfloat a      = ey*fz - ez*fy;
+	    GLfloat b      = ez*fx - ex*fz;
+	    GLfloat ic     = 1.0 / cc;
+	    GLfloat ac     = a * ic;
+	    GLfloat bc     = b * ic;
+	    if (ac < 0.0f) ac = -ac;
+	    if (bc < 0.0f) bc = -bc;
+	    offset += MAX2(ac, bc) * ctx->Polygon.OffsetFactor;
+	 }
+	 v[0]->v.z += offset;
+	 v[1]->v.z += offset;
+	 v[2]->v.z += offset;
+      }
+#endif
+   }
+#endif
+
+   r128_draw_triangle( r128ctx, v[0], v[1], v[2] );
+
+#if (IND & R128_OFFSET_BIT)
+   v[0]->v.z = z[0];
+   v[1]->v.z = z[1];
+   v[2]->v.z = z[2];
+#endif
+
+#if (IND & R128_TWOSIDE_BIT)
+   v[0]->ui[4] = c[0];
+   v[1]->ui[4] = c[1];
+   v[2]->ui[4] = c[2];
 #endif
-    }
+}
+
+
+static void TAG(quad)( GLcontext *ctx,
+		       GLuint e0, GLuint e1, GLuint e2, GLuint e3,
+		       GLuint pv )
+{
+#if 0
+   TAG(triangle)( ctx, e0, e1, e3, pv );
+   TAG(triangle)( ctx, e1, e2, e3, pv );
+#else
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   struct vertex_buffer *VB = ctx->VB;
+   r128VertexPtr r128verts = R128_DRIVER_DATA(VB)->verts;
+   r128Vertex *v[4];
+
+#if (IND & R128_OFFSET_BIT)
+   GLfloat offset;
+   GLfloat z[4];
 #endif
 
-    for (j = 0 ; j < 3 ; j++, vb += vertsize) {
+#if (IND & R128_TWOSIDE_BIT)
+   int c[4];
+#endif
+
+   v[0] = &r128verts[e0];
+   v[1] = &r128verts[e1];
+   v[2] = &r128verts[e2];
+   v[3] = &r128verts[e3];
+
+#if (IND & R128_TWOSIDE_BIT)
+   c[0] = v[0]->ui[4];
+   c[1] = v[1]->ui[4];
+   c[2] = v[2]->ui[4];
+   c[3] = v[3]->ui[4];
+#endif
 
-       for (i = 0 ; i < vertsize ; i++)
-	  vb[i] = v[j]->ui[i];
+#if (IND & (R128_TWOSIDE_BIT | R128_OFFSET_BIT))
+   {
+      GLfloat ex = v[0]->v.x - v[2]->v.x;
+      GLfloat ey = v[0]->v.y - v[2]->v.y;
+      GLfloat fx = v[1]->v.x - v[2]->v.x;
+      GLfloat fy = v[1]->v.y - v[2]->v.y;
+      GLfloat cc  = ex*fy - ey*fx;
 
-#if (IND & (R128_FLAT_BIT|R128_TWOSIDE_BIT))
-       vb[4] = c[j];		/* color is the fifth element... */
+#if (IND & R128_TWOSIDE_BIT)
+      {
+	 GLuint  facing        = (cc > 0.0) ^ ctx->Polygon.FrontBit;
+	 GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
+	 if (IND & R128_FLAT_BIT) {
+	    R128_COLOR((char *)&v[0]->ui[4], vbcolor[pv]);
+	    v[3]->ui[4] = v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
+	 } else {
+	    R128_COLOR((char *)&v[0]->ui[4], vbcolor[e0]);
+	    R128_COLOR((char *)&v[1]->ui[4], vbcolor[e1]);
+	    R128_COLOR((char *)&v[2]->ui[4], vbcolor[e2]);
+	    R128_COLOR((char *)&v[3]->ui[4], vbcolor[e3]);
+	 }
+      }
 #endif
+
 #if (IND & R128_OFFSET_BIT)
-       *(float *)&vb[2] = v[j]->vert1.z + offset;
+      {
+	 offset = ctx->Polygon.OffsetUnits * r128ctx->depth_scale;
+	 z[0] = v[0]->v.z;
+	 z[1] = v[1]->v.z;
+	 z[2] = v[2]->v.z;
+	 z[3] = v[3]->v.z;
+	 if (cc * cc > 1e-16) {
+	    GLfloat ez     = z[0] - z[2];
+	    GLfloat fz     = z[1] - z[2];
+	    GLfloat a      = ey*fz - ez*fy;
+	    GLfloat b      = ez*fx - ex*fz;
+	    GLfloat ic     = 1.0 / cc;
+	    GLfloat ac     = a * ic;
+	    GLfloat bc     = b * ic;
+	    if (ac < 0.0f) ac = -ac;
+	    if (bc < 0.0f) bc = -bc;
+	    offset += MAX2(ac, bc) * ctx->Polygon.OffsetFactor;
+	 }
+	 v[0]->v.z += offset;
+	 v[1]->v.z += offset;
+	 v[2]->v.z += offset;
+	 v[3]->v.z += offset;
+      }
 #endif
    }
-}
+#endif
 
+   r128_draw_quad( r128ctx, v[0], v[1], v[2], v[3] );
 
-static void TAG(quad)(GLcontext *ctx,
-		      GLuint v0, GLuint v1, GLuint v2, GLuint v3,
-		      GLuint pv)
-{
-    TAG(triangle)(ctx, v0, v1, v3, pv);
-    TAG(triangle)(ctx, v1, v2, v3, pv);
+#if (IND & R128_OFFSET_BIT)
+   v[0]->v.z = z[0];
+   v[1]->v.z = z[1];
+   v[2]->v.z = z[2];
+   v[3]->v.z = z[3];
+#endif
+
+#if (IND & R128_TWOSIDE_BIT)
+   v[0]->ui[4] = c[0];
+   v[1]->ui[4] = c[1];
+   v[2]->ui[4] = c[2];
+   v[3]->ui[4] = c[3];
+#endif
+#endif
 }
 
 
-/* Draw a single line.  Note that the device-dependent vertex data might
-   need to be changed based on the render state. */
-static void TAG(line)(GLcontext *ctx,
-		      GLuint v0, GLuint v1,
-		      GLuint pv)
+/* Draw a single line.  Note that the device-dependent vertex data
+ *   might need to be changed based on the render state.
+ *
+ * Polygon offset for GL_LINE triangles is dependent on a harness in
+ * core mesa setting up LineZoffset on a per-triangle basis.
+ *
+ * Twosided lighting for GL_LINE triangles is dependent on the same
+ * harness.
+ */
+static void TAG(line)( GLcontext *ctx,
+		       GLuint e0, GLuint e1,
+		       GLuint pv )
 {
-    r128ContextPtr  r128ctx   = R128_CONTEXT(ctx);
-    r128VertexPtr   r128verts = R128_DRIVER_DATA(ctx->VB)->verts;
-    float           width     = ctx->Line.Width;
-
-   if (IND & (R128_TWOSIDE_BIT|R128_FLAT_BIT)) {
-      r128Vertex tmp0 = r128verts[v0];
-      r128Vertex tmp1 = r128verts[v1];
+   r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+   r128VertexPtr r128verts = R128_DRIVER_DATA(ctx->VB)->verts;
+   GLfloat width = ctx->Line.Width;
+   r128Vertex *v[2];
+
+#if (IND & R128_OFFSET_BIT)
+   GLfloat offset;
+   GLfloat z[2];
+#endif
+#if (IND & R128_TWOSIDE_BIT)
+   int c[2];
+#endif
+
+   v[0] = &r128verts[e0];
+   v[1] = &r128verts[e1];
+
+#if (IND & R128_TWOSIDE_BIT)
+   c[0] = v[0]->ui[4];
+   c[1] = v[1]->ui[4];
+#endif
+
+#if (IND & R128_TWOSIDE_BIT)
+   {
+      GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
+      if (IND & R128_FLAT_BIT) {
+	 R128_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
+	 v[1]->ui[4] = v[0]->ui[4];
+      } else {
+	 R128_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
+	 R128_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
+      }
+   }
+#endif
 
+#if (IND & R128_OFFSET_BIT)
+   offset = ctx->LineZoffset * r128ctx->depth_scale;
+   z[0] = v[0]->v.z;
+   z[1] = v[1]->v.z;
+   v[0]->v.z += offset;
+   v[1]->v.z += offset;
+#endif
+
+   r128_draw_line( r128ctx, v[0], v[1], width );
+
+#if (IND & R128_OFFSET_BIT)
+   v[0]->v.z = z[0];
+   v[1]->v.z = z[1];
+#endif
+
+#if (IND & R128_TWOSIDE_BIT)
+   v[0]->ui[4] = c[0];
+   v[1]->ui[4] = c[1];
+#endif
+
+#if 0
+
+
+   if (IND & (R128_TWOSIDE_BIT|R128_FLAT_BIT|R128_OFFSET_BIT)) {
+      r128Vertex tmp0 = r128verts[e0];
+      r128Vertex tmp1 = r128verts[e1];
+
       if (IND & R128_TWOSIDE_BIT) {
 	 GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
 
 	 if (IND & R128_FLAT_BIT) {
- 	    R128_COLOR((char *)&tmp0.vert1.dif_argb, vbcolor[pv]);
-	    *(int *)&tmp1.vert1.dif_argb = *(int *)&tmp0.vert1.dif_argb;
+ 	    R128_COLOR((char *)&tmp0.v.color, vbcolor[pv]);
+	    *(int *)&tmp1.v.color = *(int *)&tmp0.v.color;
 	 } else {
-	    R128_COLOR((char *)&tmp0.vert1.dif_argb, vbcolor[v0]);
-	    R128_COLOR((char *)&tmp1.vert1.dif_argb, vbcolor[v1]);
+	    R128_COLOR((char *)&tmp0.v.color, vbcolor[e0]);
+	    R128_COLOR((char *)&tmp1.v.color, vbcolor[e1]);
 	 }
-      } else {
-	 *(int *)&tmp0.vert1.dif_argb = *(int *)&r128verts[pv].vert1.dif_argb;
-	 *(int *)&tmp1.vert1.dif_argb = *(int *)&r128verts[pv].vert1.dif_argb;
+      } else if (IND & R128_FLAT_BIT) {
+	 *(int *)&tmp0.v.color = *(int *)&r128verts[pv].v.color;
+	 *(int *)&tmp1.v.color = *(int *)&r128verts[pv].v.color;
+      }
+
+      if (IND & R128_OFFSET_BIT) {
+	 GLfloat offset = ctx->LineZoffset * r128ctx->depth_scale;
+	 tmp0.v.z += offset;
+	 tmp1.v.z += offset;
       }
 
-      r128DrawLineVB( r128ctx, &tmp0, &tmp1, width );
+      r128_draw_line( r128ctx, &tmp0, &tmp1, width );
+   } else {
+      r128_draw_line( r128ctx, &r128verts[e0], &r128verts[e1], width );
    }
-   else
-      r128DrawLineVB( r128ctx, &r128verts[v0], &r128verts[v1], width );
+#endif
 }
 
 /* Draw a set of points.  Note that the device-dependent vertex data
@@ -172,32 +344,40 @@
 static void TAG(points)(GLcontext *ctx,
 			GLuint first, GLuint last)
 {
-    r128ContextPtr        r128ctx   = R128_CONTEXT(ctx);
-    struct vertex_buffer *VB        = ctx->VB;
-    r128VertexPtr         r128verts = R128_DRIVER_DATA(VB)->verts;
-    GLfloat               size      = ctx->Point.Size * 0.5;
-    int                   i;
-
-    for(i = first; i <= last; i++) {
-	if(VB->ClipMask[i] == 0) {
-	   if (IND & R128_TWOSIDE_BIT) {
-	      GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
-	      r128Vertex tmp0 = r128verts[i];
-	      R128_COLOR((char *)&tmp0.vert1.dif_argb, vbcolor[i]);
-	      r128DrawPointVB( r128ctx, &tmp0, size );
-	   } else
-	      r128DrawPointVB( r128ctx, &r128verts[i], size );
-	}
-    }
+   r128ContextPtr        r128ctx   = R128_CONTEXT(ctx);
+   struct vertex_buffer *VB        = ctx->VB;
+   r128VertexPtr         r128verts = R128_DRIVER_DATA(VB)->verts;
+   GLfloat               size      = ctx->Point.Size * 0.5;
+   int                   i;
+
+
+   for(i = first; i < last; i++) {
+      if(VB->ClipMask[i] == 0) {
+	 if (IND & (R128_TWOSIDE_BIT|R128_OFFSET_BIT)) {
+	    r128Vertex tmp0 = r128verts[i];
+
+	    if (IND & R128_TWOSIDE_BIT) {
+	       GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
+	       R128_COLOR((char *)&tmp0.v.color, vbcolor[i]);
+	    }
+	    if (IND & R128_OFFSET_BIT) {
+	       GLfloat offset = ctx->PointZoffset * r128ctx->depth_scale;
+	       tmp0.v.z += offset;
+	    }
+	    r128_draw_point( r128ctx, &tmp0, size );
+	 } else
+	    r128_draw_point( r128ctx, &r128verts[i], size );
+      }
+   }
 }
 
 /* Initialize the table of primitives to render. */
 static void TAG(init)(void)
 {
-    tri_tab[IND]    = TAG(triangle);
-    quad_tab[IND]   = TAG(quad);
-    line_tab[IND]   = TAG(line);
-    points_tab[IND] = TAG(points);
+   rast_tab[IND].triangle   = TAG(triangle);
+   rast_tab[IND].quad       = TAG(quad);
+   rast_tab[IND].line       = TAG(line);
+   rast_tab[IND].points     = TAG(points);
 }
 
 #undef IND
Index: xc/lib/GL/mesa/src/drv/r128/r128_vb.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_vb.c:1.3 xc/lib/GL/mesa/src/drv/r128/r128_vb.c:1.10
--- xc/lib/GL/mesa/src/drv/r128/r128_vb.c:1.3	Sun Jun 25 12:03:43 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_vb.c	Tue Dec 12 12:17:08 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.c,v 1.3 2000/06/25 16:03:43 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.c,v 1.10 2000/12/12 17:17:08 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,395 +28,477 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
-#include "r128_init.h"
-#include "r128_mesa.h"
-#include "r128_xmesa.h"
 #include "r128_context.h"
-#include "r128_lock.h"
-#include "r128_reg.h"
-#include "r128_cce.h"
+#include "r128_ioctl.h"
 #include "r128_state.h"
 #include "r128_vb.h"
 
+#include "mem.h"
 #include "stages.h"
 
-#define TEX0                                                            \
-do {                                                                    \
-    v->vert1.tu0 = tc0[i][0];                                           \
-    v->vert1.tv0 = tc0[i][1];                                           \
+#define TEX0								\
+do {									\
+   v->v.tu0 = tc0[i][0];						\
+   v->v.tv0 = tc0[i][1];						\
 } while (0)
 
-#define TEX1                                                            \
-do {                                                                    \
-    v->vert2.tu1 = tc1[i][0];                                           \
-    v->vert2.tv1 = tc1[i][1];                                           \
+#define TEX1								\
+do {									\
+   v->v.tu1 = tc1[i][0];						\
+   v->v.tv1 = tc1[i][1];						\
 } while (0)
 
-#define SPC                                                             \
-do {                                                                    \
-    GLubyte *spec = &(VB->Spec[0][i][0]);                               \
-    v->vert1.spec_frgb.r = spec[0];                                     \
-    v->vert1.spec_frgb.g = spec[1];                                     \
-    v->vert1.spec_frgb.b = spec[2];                                     \
+#define SPC								\
+do {									\
+   GLubyte *spec = &(VB->Spec[0][i][0]);				\
+   v->v.specular.blue  = spec[2];					\
+   v->v.specular.green = spec[1];					\
+   v->v.specular.red   = spec[0];					\
 } while (0)
 
+#define FOG								\
+do {									\
+   GLubyte *spec = &(VB->Spec[0][i][0]);				\
+   v->v.specular.alpha = spec[3];					\
+} while (0)
 
-#define COL                                                             \
-do {                                                                    \
-    GLubyte *col = &(VB->Color[0]->data[i][0]);                         \
-    v->vert1.dif_argb.a = col[3];                                       \
-    v->vert1.dif_argb.r = col[0];                                       \
-    v->vert1.dif_argb.g = col[1];                                       \
-    v->vert1.dif_argb.b = col[2];                                       \
+#define COL								\
+do {									\
+   GLubyte *col = &(VB->Color[0]->data[i][0]);				\
+   v->v.color.blue  = col[2];						\
+   v->v.color.green = col[1];						\
+   v->v.color.red   = col[0];						\
+   v->v.color.alpha = col[3];						\
 } while (0)
 
-#if 1
-/* FIXME: These are handled by the Rage 128 */
-#define TEX0_4
-#define TEX1_4
-#else
-#define TEX0_4                                                          \
-do {                                                                    \
-    if (VB->TexCoordPtr[0]->size == 4) {                                \
-	GLfloat (*tc)[4] = VB->TexCoordPtr[0]->data;                    \
-	v = &(R128_DRIVER_DATA(VB)->verts[start]);                      \
-	for (i = start; i < end; i++, v++)   {                          \
-	    float oow = 1.0 / tc[i][3];                                 \
-	    v->vert1.rhw *= tc[i][3];                                   \
-	    v->vert1.tu0 *= oow;                                        \
-	    v->vert1.tv0 *= oow;                                        \
-	}                                                               \
-    }                                                                   \
+#define TEX0_4								\
+do {									\
+   if (VB->TexCoordPtr[0]->size == 4) {					\
+      GLfloat (*tc)[4] = VB->TexCoordPtr[0]->data;			\
+      v = &(R128_DRIVER_DATA(VB)->verts[start]);			\
+      for (i = start; i < end; i++, v++)   {				\
+	 float oow = 1.0 / tc[i][3];					\
+	 v->v.rhw *= tc[i][3];						\
+	 v->v.tu0 *= oow;						\
+	 v->v.tv0 *= oow;						\
+      }									\
+   }									\
 } while (0)
 
 #ifdef USE_RHW2
-#define TEX1_4                                                          \
-do {                                                                    \
-    if (VB->TexCoordPtr[1]->size == 4) {                                \
-	GLfloat (*tc)[4] = VB->TexCoordPtr[1]->data;                    \
-	v = &(R128_DRIVER_DATA(VB)->verts[start]);                      \
-	for (i = start; i < end; i++, v++)   {                          \
-	    float oow = 1.0 / tc[i][3];                                 \
-	    v->vert3.rhw2 *= tc[i][3];                                  \
-	    v->vert3.tu1  *= oow;                                       \
-	    v->vert3.tv1  *= oow;                                       \
-	}                                                               \
-    }                                                                   \
+
+#define TEX1_4								\
+do {									\
+   if (VB->TexCoordPtr[1]->size == 4) {					\
+      GLfloat (*tc)[4] = VB->TexCoordPtr[1]->data;			\
+      v = &(R128_DRIVER_DATA(VB)->verts[start]);			\
+      for (i = start; i < end; i++, v++)   {				\
+	 float oow = 1.0 / tc[i][3];					\
+	 v->v.rhw2 *= tc[i][3];						\
+	 v->v.tu1 *= oow;						\
+	 v->v.tv1 *= oow;						\
+      }									\
+   }									\
 } while (0)
-#else
-#define TEX1_4
-#endif
-#endif
 
-#ifdef USE_RHW2
-#define COORD                                                           \
-do {                                                                    \
-    GLfloat *win = VB->Win.data[i];                                     \
-    v->vert3.x =                   win[0];                              \
-    v->vert3.y =      r128height - win[1];                              \
-    v->vert3.z =           scale * win[2];                              \
-    v->vert3.rhw = v->vert3.rhw2 = win[3];                              \
+#define COORD								\
+do {									\
+   GLfloat *win = VB->Win.data[i];					\
+   v->v.x =               win[0] + SUBPIXEL_X;				\
+   v->v.y =  r128height - win[1] + SUBPIXEL_Y;				\
+   v->v.z =       scale * win[2];					\
+   v->v.rhw = v->v.rhw2 = win[3];					\
 } while (0)
-#else
-#define COORD                                                           \
-do {                                                                    \
-    GLfloat *win = VB->Win.data[i];                                     \
-    v->vert1.x =                win[0];                                 \
-    v->vert1.y =   r128height - win[1];                                 \
-    v->vert1.z =        scale * win[2];                                 \
-    v->vert1.rhw =              win[3];                                 \
+
+#else /* USE_RHW2 */
+
+#define TEX1_4
+
+#define COORD								\
+do {									\
+   GLfloat *win = VB->Win.data[i];					\
+   v->v.x =              win[0] + SUBPIXEL_X;				\
+   v->v.y = r128height - win[1] + SUBPIXEL_Y;				\
+   v->v.z =      scale * win[2];					\
+   v->v.rhw =            win[3];					\
 } while (0)
-#endif
 
+#endif /* USE_RHW2 */
+
 #define NOP
 
 /* Setup the r128 vertex buffer entries */
-#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,tex1_4,spec)            \
-static void name(struct vertex_buffer *VB, GLuint start, GLuint end)    \
-{                                                                       \
-    r128ContextPtr        r128ctx    = R128_CONTEXT(VB->ctx);           \
-    __DRIdrawablePrivate *dPriv      = r128ctx->driDrawable;            \
-    r128VertexPtr         v;                                            \
-    GLfloat               (*tc0)[4];                                    \
-    GLfloat               (*tc1)[4];                                    \
-    GLfloat               r128height = dPriv->h;                        \
-    GLfloat               scale = r128ctx->depth_scale;                 \
-    int                   i;                                            \
-                                                                        \
-    (void) r128height; (void) r128ctx; (void) scale;                    \
-                                                                        \
-    gl_import_client_data(VB, VB->ctx->RenderFlags,                     \
-			  (VB->ClipOrMask                               \
-			   ? VEC_WRITABLE | VEC_GOOD_STRIDE             \
-			   : VEC_GOOD_STRIDE));                         \
-                                                                        \
-    tc0 = VB->TexCoordPtr[0]->data;                                     \
-    tc1 = VB->TexCoordPtr[1]->data;                                     \
-                                                                        \
-    v = &(R128_DRIVER_DATA(VB)->verts[start]);                          \
-                                                                        \
-    if (VB->ClipOrMask == 0)                                            \
-	for (i = start; i < end; i++, v++) {                            \
-	    win;                                                        \
-	    col;                                                        \
-	    spec;                                                       \
-	    tex0;                                                       \
-	    tex1;                                                       \
-	}                                                               \
-    else                                                                \
-	for (i = start; i < end; i++, v++) {                            \
-	    if (VB->ClipMask[i] == 0) {                                 \
-		win;                                                    \
-		spec;                                                   \
-		tex0;                                                   \
-		tex1;                                                   \
-	    }                                                           \
-	    col;                                                        \
-	}                                                               \
-    tex0_4;                                                             \
-    tex1_4;                                                             \
+#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,tex1_4,spec,fog)	\
+static void name(struct vertex_buffer *VB, GLuint start, GLuint end)	\
+{									\
+   r128ContextPtr        r128ctx    = R128_CONTEXT(VB->ctx);		\
+   __DRIdrawablePrivate *dPriv      = r128ctx->driDrawable;		\
+   r128VertexPtr         v;						\
+   GLfloat               (*tc0)[4];					\
+   GLfloat               (*tc1)[4];					\
+   GLfloat               r128height = dPriv->h;				\
+   GLfloat               scale = r128ctx->depth_scale;			\
+   int                   i;						\
+									\
+   (void) r128height; (void) r128ctx; (void) scale;			\
+									\
+   gl_import_client_data(VB, VB->ctx->RenderFlags,			\
+			 (VB->ClipOrMask				\
+			  ? VEC_WRITABLE | VEC_GOOD_STRIDE		\
+			  : VEC_GOOD_STRIDE));				\
+									\
+   tc0 = VB->TexCoordPtr[r128ctx->tmu_source[0]]->data;			\
+   tc1 = VB->TexCoordPtr[r128ctx->tmu_source[1]]->data;			\
+									\
+   v = &(R128_DRIVER_DATA(VB)->verts[start]);				\
+									\
+   if (VB->ClipOrMask == 0) {						\
+      for (i = start; i < end; i++, v++) {				\
+	 win;								\
+	 col;								\
+	 spec;								\
+	 fog;								\
+	 tex0;								\
+	 tex1;								\
+      }									\
+   } else {								\
+      for (i = start; i < end; i++, v++) {				\
+	 if (VB->ClipMask[i] == 0) {					\
+	    win;							\
+	    spec;							\
+	    fog;							\
+	    tex0;							\
+	    tex1;							\
+	 }								\
+	 col;								\
+      }									\
+   }									\
+   tex0_4;								\
+   tex1_4;								\
 }
 
+
+SETUPFUNC(rs_wt0,	COORD, NOP, TEX0, NOP,  TEX0_4, NOP,    NOP, NOP)
+SETUPFUNC(rs_wt0t1,	COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_wft0,	COORD, NOP, TEX0, NOP,  TEX0_4, NOP,    NOP, FOG)
+SETUPFUNC(rs_wft0t1,	COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_wg,	COORD, COL, NOP,  NOP,  NOP,    NOP,    NOP, NOP)
+SETUPFUNC(rs_wgs,	COORD, COL, NOP,  NOP,  NOP,    NOP,    SPC, NOP)
+SETUPFUNC(rs_wgt0,	COORD, COL, TEX0, NOP,  TEX0_4, NOP,    NOP, NOP)
+SETUPFUNC(rs_wgt0t1,	COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_wgst0,	COORD, COL, TEX0, NOP,  TEX0_4, NOP,    SPC, NOP)
+SETUPFUNC(rs_wgst0t1,	COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP)
+SETUPFUNC(rs_wgf,	COORD, COL, NOP,  NOP,  NOP,    NOP,    NOP, FOG)
+SETUPFUNC(rs_wgfs,	COORD, COL, NOP,  NOP,  NOP,    NOP,    SPC, FOG)
+SETUPFUNC(rs_wgft0,	COORD, COL, TEX0, NOP,  TEX0_4, NOP,    NOP, FOG)
+SETUPFUNC(rs_wgft0t1,	COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_wgfst0,	COORD, COL, TEX0, NOP,  TEX0_4, NOP,    SPC, FOG)
+SETUPFUNC(rs_wgfst0t1,	COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG)
+
+SETUPFUNC(rs_t0,	NOP,   NOP, TEX0, NOP,  TEX0_4, NOP,    NOP, NOP)
+SETUPFUNC(rs_t0t1,	NOP,   NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_f,		NOP,   NOP, NOP,  NOP,  NOP,    NOP,    NOP, FOG)
+SETUPFUNC(rs_ft0,	NOP,   NOP, TEX0, NOP,  TEX0_4, NOP,    NOP, FOG)
+SETUPFUNC(rs_ft0t1,	NOP,   NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_g,		NOP,   COL, NOP,  NOP,  NOP,    NOP,    NOP, NOP)
+SETUPFUNC(rs_gs,	NOP,   COL, NOP,  NOP,  NOP,    NOP,    SPC, NOP)
+SETUPFUNC(rs_gt0,	NOP,   COL, TEX0, NOP,  TEX0_4, NOP,    NOP, NOP)
+SETUPFUNC(rs_gt0t1,	NOP,   COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
+SETUPFUNC(rs_gst0,	NOP,   COL, TEX0, NOP,  TEX0_4, NOP,    SPC, NOP)
+SETUPFUNC(rs_gst0t1,	NOP,   COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP)
+SETUPFUNC(rs_gf,	NOP,   COL, NOP,  NOP,  NOP,    NOP,    NOP, FOG)
+SETUPFUNC(rs_gfs,	NOP,   COL, NOP,  NOP,  NOP,    NOP,    SPC, FOG)
+SETUPFUNC(rs_gft0,	NOP,   COL, TEX0, NOP,  TEX0_4, NOP,    NOP, FOG)
+SETUPFUNC(rs_gft0t1,	NOP,   COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
+SETUPFUNC(rs_gfst0,	NOP,   COL, TEX0, NOP,  TEX0_4, NOP,    SPC, FOG)
+SETUPFUNC(rs_gfst0t1,	NOP,   COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG)
 
-SETUPFUNC(rs_wt0,       COORD, NOP, TEX0, NOP,  TEX0_4, NOP,    NOP)
-SETUPFUNC(rs_wt1,       COORD, NOP, NOP,  TEX1, NOP,    TEX1_4, NOP)
-SETUPFUNC(rs_wt0t1,     COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP)
-SETUPFUNC(rs_wg,        COORD, COL, NOP,  NOP,  NOP,    NOP,    NOP)
-SETUPFUNC(rs_wgs,       COORD, COL, NOP,  NOP,  NOP,    NOP,    SPC)
-SETUPFUNC(rs_wgt0,      COORD, COL, TEX0, NOP,  TEX0_4, NOP,    NOP)
-SETUPFUNC(rs_wgt1,      COORD, COL, NOP,  TEX1, NOP,    TEX1_4, NOP)
-SETUPFUNC(rs_wgt0t1,    COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP)
-SETUPFUNC(rs_wgst0,     COORD, COL, TEX0, NOP,  TEX0_4, NOP,    SPC)
-SETUPFUNC(rs_wgst1,     COORD, COL, NOP,  TEX1, NOP,    TEX1_4, SPC)
-SETUPFUNC(rs_wgst0t1,   COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC)
-
-SETUPFUNC(rs_t0,        NOP,   NOP, TEX0, NOP,  TEX0_4, NOP,    NOP)
-SETUPFUNC(rs_t1,        NOP,   NOP, NOP,  TEX1, NOP,    TEX1_4, NOP)
-SETUPFUNC(rs_t0t1,      NOP,   NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP)
-SETUPFUNC(rs_g,         NOP,   COL, NOP,  NOP,  NOP,    NOP,    NOP)
-SETUPFUNC(rs_gs,        NOP,   COL, NOP,  NOP,  NOP,    NOP,    SPC)
-SETUPFUNC(rs_gt0,       NOP,   COL, TEX0, NOP,  TEX0_4, NOP,    NOP)
-SETUPFUNC(rs_gt1,       NOP,   COL, NOP,  TEX1, NOP,    TEX1_4, NOP)
-SETUPFUNC(rs_gt0t1,     NOP,   COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP)
-SETUPFUNC(rs_gst0,      NOP,   COL, TEX0, NOP,  TEX0_4, NOP,    SPC)
-SETUPFUNC(rs_gst1,      NOP,   COL, NOP,  TEX1, NOP,    TEX1_4, SPC)
-SETUPFUNC(rs_gst0t1,    NOP,   COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC)
 
-static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end)
+static void rs_invalid( struct vertex_buffer *VB, GLuint start, GLuint end )
 {
-    fprintf(stderr, "r128RasterSetup(): invalid setup function\n");
+   fprintf(stderr, "r128RasterSetup(): invalid setup function\n");
 }
 
 typedef void (*setupFunc)(struct vertex_buffer *, GLuint, GLuint);
-static setupFunc setup_func[0x20];
+static setupFunc setup_func[0x40];
 
 /* Initialize the table of vertex buffer setup functions */
-void r128SetupInit(void)
+void r128DDSetupInit( void )
 {
-    int i;
+   int i;
 
-    for (i = 0; i < 0x20; i++) setup_func[i] = rs_invalid;
+   for (i = 0; i < 0x20; i++) setup_func[i] = rs_invalid;
 
-    /* Funcs to build vertices from scratch */
-    setup_func[R128_WIN_BIT|R128_TEX0_BIT] = rs_wt0;
-    setup_func[R128_WIN_BIT|R128_TEX1_BIT] = rs_wt1;
-    setup_func[R128_WIN_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wt0t1;
-
-    setup_func[R128_WIN_BIT|R128_RGBA_BIT] = rs_wg;
-    setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT] = rs_wgs;
-    setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT] = rs_wgt0;
-    setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX1_BIT] = rs_wgt1;
-    setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgt0t1;
-    setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgst0;
-    setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_wgst1;
-    setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgst0t1;
-
-
-    /* Funcs to repair vertices */
-    setup_func[R128_TEX0_BIT] = rs_t0;
-    setup_func[R128_TEX1_BIT] = rs_t1;
-    setup_func[R128_TEX0_BIT|R128_TEX1_BIT] = rs_t0t1;
-    setup_func[R128_RGBA_BIT] = rs_g;
-    setup_func[R128_RGBA_BIT|R128_SPEC_BIT] = rs_gs;
-    setup_func[R128_RGBA_BIT|R128_TEX0_BIT] = rs_gt0;
-    setup_func[R128_RGBA_BIT|R128_TEX1_BIT] = rs_gt1;
-    setup_func[R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gt0t1;
-    setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gst0;
-    setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_gst1;
-    setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gst0t1;
+   /* Functions to build vertices from scratch */
+   setup_func[R128_WIN_BIT|R128_TEX0_BIT] = rs_wt0;
+   setup_func[R128_WIN_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wt0t1;
+   setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_wft0;
+   setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wft0t1;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT] = rs_wg;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT] = rs_wgs;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT] = rs_wgt0;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgt0t1;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgst0;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgst0t1;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT] = rs_wgf;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT] = rs_wgfs;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_wgft0;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgft0t1;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgfst0;
+   setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgfst0t1;
+
+   /* Repair functions */
+   setup_func[R128_TEX0_BIT] = rs_t0;
+   setup_func[R128_TEX0_BIT|R128_TEX1_BIT] = rs_t0t1;
+   setup_func[R128_FOG_BIT] = rs_f;
+   setup_func[R128_FOG_BIT|R128_TEX0_BIT] = rs_ft0;
+   setup_func[R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_ft0t1;
+   setup_func[R128_RGBA_BIT] = rs_g;
+   setup_func[R128_RGBA_BIT|R128_SPEC_BIT] = rs_gs;
+   setup_func[R128_RGBA_BIT|R128_TEX0_BIT] = rs_gt0;
+   setup_func[R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gt0t1;
+   setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gst0;
+   setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gst0t1;
+   setup_func[R128_RGBA_BIT|R128_FOG_BIT] = rs_gf;
+   setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT] = rs_gfs;
+   setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_gft0;
+   setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gft0t1;
+   setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gfst0;
+   setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gfst0t1;
 }
 
+void r128PrintSetupFlags( char *msg, GLuint flags )
+{
+   fprintf( stderr, "%s: %d %s%s%s%s%s%s\n",
+	    msg,
+	    (int)flags,
+	    (flags & R128_WIN_BIT)	? " xyzw," : "",
+	    (flags & R128_RGBA_BIT)	? " rgba," : "",
+	    (flags & R128_SPEC_BIT)	? " spec," : "",
+	    (flags & R128_FOG_BIT)	? " fog," : "",
+	    (flags & R128_TEX0_BIT)	? " tex-0," : "",
+	    (flags & R128_TEX1_BIT)	? " tex-1," : "" );
+}
+
 /* Initialize the vertex buffer setup functions based on the current
    rendering state */
-void r128ChooseRasterSetupFunc(GLcontext *ctx)
+void r128DDChooseRasterSetupFunc( GLcontext *ctx )
 {
-    r128ContextPtr r128ctx   = R128_CONTEXT(ctx);
-    int            funcIndex = R128_WIN_BIT | R128_RGBA_BIT;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   int index = R128_WIN_BIT | R128_RGBA_BIT;
 
-    r128ctx->vertsize = 8;
-    r128ctx->vc_format = R128_TEX0_VERTEX_FORMAT;
-    r128ctx->multitex = 0;
-
-    if (ctx->Texture.Enabled & ENABLE_TEX0) {
-        /* This doesn't work for non-RGBA textures
-	if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
-	    funcIndex &= ~R128_RGBA_BIT;
-        */
-	funcIndex |= R128_TEX0_BIT;
-    }
-
-    if (ctx->Texture.Enabled & ENABLE_TEX1) {
-        /* GTH: we should really only enable the second texture unit
-	 * when we're doing true multitexturing.  I guess there aren't
-	 * that many cases where apps will only bind a texture to the
-	 * second texture unit, but it would definitely be a performance
-	 * win in those cases.
-	 */
-	r128ctx->vertsize = 10;
-	r128ctx->vc_format = R128_TEX1_VERTEX_FORMAT;
-	r128ctx->multitex = 1;
-	funcIndex |= R128_TEX1_BIT;
-    }
-
-    /* FIXME: Verify this works properly */
-    if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
-	funcIndex |= R128_SPEC_BIT;
+   r128ctx->multitex = 0;
+   r128ctx->vertsize = 8;
+   r128ctx->vc_format = R128_TEX0_VERTEX_FORMAT;
+   r128ctx->tmu_source[0] = 0;
+   r128ctx->tmu_source[1] = 1;
+   r128ctx->tex_dest[0] = R128_TEX0_BIT;
+   r128ctx->tex_dest[1] = R128_TEX1_BIT;
+   r128ctx->blend_flags &= ~R128_BLEND_MULTITEX;
+
+   if ( ctx->Texture.ReallyEnabled & ENABLE_TEX0 ) {
+      if ( ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
+	   (r128ctx->env_color & 0x00ffffff) ) {
+	 r128ctx->multitex = 1;
+	 r128ctx->vertsize = 10;
+	 r128ctx->vc_format = R128_TEX1_VERTEX_FORMAT;
+	 r128ctx->tmu_source[1] = 0;
+	 index |= R128_TEX1_BIT;
+      }
+
+      index |= R128_TEX0_BIT;
+   }
+
+   if ( ctx->Texture.ReallyEnabled & ENABLE_TEX1 ) {
+      if ( ctx->Texture.ReallyEnabled & ENABLE_TEX0 ) {
+	 r128ctx->multitex = 1;
+	 r128ctx->vertsize = 10;
+	 r128ctx->vc_format = R128_TEX1_VERTEX_FORMAT;
+	 r128ctx->blend_flags |= R128_BLEND_MULTITEX;
+	 index |= R128_TEX1_BIT;
+      } else {
+	 /* Just a funny way of doing single texturing.
+	  */
+	 r128ctx->tmu_source[0] = 1;
+	 r128ctx->tex_dest[1] = R128_TEX0_BIT;
+
+	 if ( ctx->Texture.Unit[1].EnvMode == GL_BLEND &&
+	      (r128ctx->env_color & 0x00ffffff) ) {
+	    r128ctx->multitex = 1;
+	    r128ctx->vertsize = 10;
+	    r128ctx->vc_format = R128_TEX1_VERTEX_FORMAT;
+	    r128ctx->tmu_source[1] = 1;
+	    index |= R128_TEX1_BIT;
+	 }
+
+	 index |= R128_TEX0_BIT;
+      }
+   }
+
+   if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR )
+      index |= R128_SPEC_BIT;
+
+   if ( ctx->Fog.Enabled )
+      index |= R128_FOG_BIT;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_MSG ) {
+      fprintf( stderr, "\n" );
+      r128PrintSetupFlags( "full setup function", index );
+   }
 
-    r128ctx->SetupIndex = funcIndex;
-    ctx->Driver.RasterSetup = setup_func[funcIndex];
+   r128ctx->new_state |= R128_NEW_TEXTURE;
+   r128ctx->SetupIndex = index;
+
+   ctx->Driver.RasterSetup = setup_func[index];
 }
 
 /* Check to see if any updates of the vertex buffer entries are needed */
-void r128CheckPartialRasterSetup(GLcontext *ctx,
-				 struct gl_pipeline_stage *s)
+void r128DDCheckPartialRasterSetup( GLcontext *ctx,
+				    struct gl_pipeline_stage *s )
 {
-    r128ContextPtr r128ctx = R128_CONTEXT(ctx);
-    int            tmp     = r128ctx->SetupDone;
+   r128ContextPtr r128ctx = R128_CONTEXT( ctx );
+   int tmp = r128ctx->SetupDone;
 
-    s->type = 0;
-    r128ctx->SetupDone = GL_FALSE;
+   s->type = 0;
+   r128ctx->SetupDone = GL_FALSE;
 
-    if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0) return;
-    if (ctx->IndirectTriangles) return;
+   if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0) return;
+   if (ctx->IndirectTriangles) return;
 
-    r128ctx->SetupDone = tmp;
+   r128ctx->SetupDone = tmp;
 }
 
 
 /* Update the vertex buffer entries, if necessary */
-void r128PartialRasterSetup(struct vertex_buffer *VB)
+void r128DDPartialRasterSetup( struct vertex_buffer *VB )
 {
-    r128ContextPtr r128ctx   = R128_CONTEXT(VB->ctx);
-    int            new       = VB->pipeline->new_outputs;
-    int            available = VB->pipeline->outputs;
-    int            index     = 0;
-
-    if (new & VERT_WIN) {
-	new = available;
-	index |= R128_WIN_BIT;
-    }
-
-    if (new & VERT_RGBA)      index |= R128_RGBA_BIT | R128_SPEC_BIT;
-    if (new & VERT_TEX0_ANY)  index |= R128_TEX0_BIT;
-    if (new & VERT_TEX1_ANY)  index |= R128_TEX1_BIT;
-
-    r128ctx->SetupDone &= ~index;
-    index              &= r128ctx->SetupIndex;
-    r128ctx->SetupDone |= index;
+   r128ContextPtr r128ctx = R128_CONTEXT( VB->ctx );
+   int new = VB->pipeline->new_outputs;
+   int available = VB->pipeline->outputs;
+   int index = 0;
+
+   if (new & VERT_WIN) {
+      new = available;
+      index |= R128_WIN_BIT | R128_FOG_BIT;
+   }
+
+   if (new & VERT_RGBA)
+      index |= R128_RGBA_BIT | R128_SPEC_BIT;
+
+   if (new & VERT_TEX0_ANY)
+      index |= R128_TEX0_BIT;
+
+   if (new & VERT_TEX1_ANY)
+      index |= r128ctx->tex_dest[1];
+
+   if (new & VERT_FOG_COORD)
+      index |= R128_FOG_BIT;
+
+   r128ctx->SetupDone &= ~index;
+   index &= r128ctx->SetupIndex;
+   r128ctx->SetupDone |= index;
+
+   if ( R128_DEBUG & DEBUG_VERBOSE_MSG )
+      r128PrintSetupFlags( "partial setup function", index );
 
-    if (index) setup_func[index](VB, VB->Start, VB->Count);
+   if ( index )
+      setup_func[index]( VB, VB->Start, VB->Count );
 }
 
 /* Perform the raster setup for the fast path, if using CVA */
-void r128DoRasterSetup(struct vertex_buffer *VB)
+void r128DDDoRasterSetup( struct vertex_buffer *VB )
 {
-    GLcontext *ctx = VB->ctx;
+   GLcontext *ctx = VB->ctx;
 
-    if (VB->Type == VB_CVA_PRECALC)   r128PartialRasterSetup(VB);
-    else if (ctx->Driver.RasterSetup) ctx->Driver.RasterSetup(VB,
-							      VB->CopyStart,
-							      VB->Count);
+   if ( VB->Type == VB_CVA_PRECALC ) {
+      r128DDPartialRasterSetup( VB );
+   } else if ( ctx->Driver.RasterSetup ) {
+      ctx->Driver.RasterSetup( VB,
+			       VB->CopyStart,
+			       VB->Count );
+   }
 }
 
 /* Resize an existing vertex buffer */
-void r128ResizeVB(struct vertex_buffer *VB, GLuint size)
+void r128DDResizeVB( struct vertex_buffer *VB, GLuint size )
 {
-    r128VertexBufferPtr r128vb = R128_DRIVER_DATA(VB);
+   r128VertexBufferPtr r128vb = R128_DRIVER_DATA(VB);
 
-    while (r128vb->size < size)
-	r128vb->size *= 2;
+   while ( r128vb->size < size )
+      r128vb->size *= 2;
 
-    free(r128vb->vert_store);
-    r128vb->vert_store = malloc(sizeof(r128Vertex) * r128vb->size + 31);
-    if (!r128vb->vert_store) {
-	fprintf(stderr, "Cannot allocate vertex store!  Exiting...\n");
-	exit(1);
-    }
-
-    r128vb->verts = (r128VertexPtr)(((CARD32)r128vb->vert_store + 31) & ~31);
-
-    gl_vector1ui_free(&r128vb->clipped_elements);
-    gl_vector1ui_alloc(&r128vb->clipped_elements,
-		       VEC_WRITABLE, r128vb->size, 32);
-    if (!r128vb->clipped_elements.start) {
-	fprintf(stderr, "Cannot allocate clipped elements!  Exiting...\n");
-	exit(1);
-    }
-
-    free(VB->ClipMask);
-    VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size);
-    if (!VB->ClipMask) {
-	fprintf(stderr, "Cannot allocate clipmask!  Exiting...\n");
-	exit(1);
-    }
+   ALIGN_FREE( r128vb->vert_store );
+   r128vb->vert_store = ALIGN_MALLOC( sizeof(r128Vertex) * r128vb->size, 32 );
+   if ( !r128vb->vert_store ) {
+      fprintf( stderr, "Cannot allocate vertex store!  Exiting...\n" );
+      exit( 1 );
+   }
+
+   r128vb->verts = (r128VertexPtr)r128vb->vert_store;
+
+   gl_vector1ui_free( &r128vb->clipped_elements );
+   gl_vector1ui_alloc( &r128vb->clipped_elements,
+		       VEC_WRITABLE, r128vb->size, 32 );
+   if ( !r128vb->clipped_elements.start ) {
+      fprintf( stderr, "Cannot allocate clipped elements!  Exiting...\n" );
+      exit( 1 );
+   }
+
+   ALIGN_FREE( VB->ClipMask );
+   VB->ClipMask = (GLubyte *)ALIGN_MALLOC( sizeof(GLubyte) * r128vb->size, 32 );
+   if ( !VB->ClipMask ) {
+      fprintf( stderr, "Cannot allocate clipmask!  Exiting...\n" );
+      exit( 1 );
+   }
 }
 
 /* Create a new device-dependent vertex buffer */
-void r128DDRegisterVB(struct vertex_buffer *VB)
+void r128DDRegisterVB( struct vertex_buffer *VB )
 {
-    r128VertexBufferPtr r128vb;
+   r128VertexBufferPtr r128vb;
 
-    r128vb = (r128VertexBufferPtr)calloc(1, sizeof(*r128vb));
+   r128vb = (r128VertexBufferPtr)CALLOC( sizeof(*r128vb) );
 
-    r128vb->size = VB->Size * 2;
-    r128vb->vert_store = malloc(sizeof(r128Vertex) * r128vb->size + 31);
-    if (!r128vb->vert_store) {
-	fprintf(stderr, "Cannot allocate vertex store!  Exiting...\n");
-	exit(1);
-    }
-
-    r128vb->verts = (r128VertexPtr)(((CARD32)r128vb->vert_store + 31) & ~31);
-
-    gl_vector1ui_alloc(&r128vb->clipped_elements,
-		       VEC_WRITABLE, r128vb->size, 32);
-    if (!r128vb->clipped_elements.start) {
-	fprintf(stderr, "Cannot allocate clipped elements!  Exiting...\n");
-	exit(1);
-    }
-
-    free(VB->ClipMask);
-    VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size);
-    if (!VB->ClipMask) {
-	fprintf(stderr, "Cannot allocate clipmask!  Exiting...\n");
-	exit(1);
-    }
+   r128vb->size = VB->Size * 2;
+   r128vb->vert_store = ALIGN_MALLOC( sizeof(r128Vertex) * r128vb->size, 32 );
+   if ( !r128vb->vert_store ) {
+      fprintf( stderr, "Cannot allocate vertex store!  Exiting...\n" );
+      exit( 1 );
+   }
+
+   r128vb->verts = (r128VertexPtr)r128vb->vert_store;
+
+   gl_vector1ui_alloc( &r128vb->clipped_elements,
+		       VEC_WRITABLE, r128vb->size, 32 );
+   if ( !r128vb->clipped_elements.start ) {
+      fprintf( stderr, "Cannot allocate clipped elements!  Exiting...\n" );
+      exit( 1 );
+   }
+
+   ALIGN_FREE( VB->ClipMask );
+   VB->ClipMask = (GLubyte *)ALIGN_MALLOC( sizeof(GLubyte) * r128vb->size, 32 );
+   if ( !VB->ClipMask ) {
+      fprintf( stderr, "Cannot allocate clipmask!  Exiting...\n" );
+      exit( 1 );
+   }
 
-    VB->driver_data = r128vb;
+   VB->driver_data = r128vb;
 }
 
 /* Destroy a device-dependent vertex buffer */
-void r128DDUnregisterVB(struct vertex_buffer *VB)
+void r128DDUnregisterVB( struct vertex_buffer *VB )
 {
-    r128VertexBufferPtr r128vb = R128_DRIVER_DATA(VB);
+   r128VertexBufferPtr r128vb = R128_DRIVER_DATA(VB);
 
-    if (r128vb) {
-	if (r128vb->vert_store)     free(r128vb->vert_store);
-	gl_vector1ui_free(&r128vb->clipped_elements);
-	free(r128vb);
-	VB->driver_data = 0;
-    }
+   if ( r128vb ) {
+      if ( r128vb->vert_store ) ALIGN_FREE( r128vb->vert_store );
+      gl_vector1ui_free( &r128vb->clipped_elements );
+      FREE( r128vb );
+      VB->driver_data = 0;
+   }
 }
Index: xc/lib/GL/mesa/src/drv/r128/r128_vb.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_vb.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_vb.h:1.3
--- xc/lib/GL/mesa/src/drv/r128/r128_vb.h:1.1	Fri Jun 16 20:03:09 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_vb.h	Mon Dec  4 14:21:48 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.h,v 1.1 2000/06/17 00:03:09 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.h,v 1.3 2000/12/04 19:21:48 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,7 +28,8 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
@@ -39,66 +40,24 @@
 
 /* FIXME: This is endian-specific */
 typedef struct {
-    GLubyte b;
-    GLubyte g;
-    GLubyte r;
-    GLubyte a;
-} r128Color;
+    GLubyte	blue;
+    GLubyte	green;
+    GLubyte	red;
+    GLubyte	alpha;
+} r128_color_t;
 
-/* Single texture vertex, single x86 cache line.
- *
- * GTH: This is in use now.
- */
-typedef struct {
-    GLfloat   x, y, z;		/* Coordinates in screen space */
-    GLfloat   rhw;		/* Reciprocal homogeneous w */
-    r128Color dif_argb;		/* Diffuse color */
-    r128Color spec_frgb;	/* Specular color (alpha is fog) */
-    GLfloat   tu0, tv0;		/* Texture 0 coordinates */
-} r128_vertex1;
-
-/* The only vertex format in current use, but unsatisfactory for two
- * reasons:
- *       - Not possible to implement fully conformant rendering
- *         with this format (projective multitexturing),
- *       - Performance is lower with this vertex for single-texture
- *         geometry, as the vertex is unnecessarily larger than
- *         a cacheline.
- *
- * Switching to single-texture vertices can be accomplished in state
- * management, and is relatively trivial.  Switching to the rhw2
- * format is data-dependent (are there any glTexCoord4f's in the
- * current buffer).  One option is to switch between single-texture
- * and rhw2 vertex formats only on the standard path.
- *
- * The fastpath never requires the rhw2 format, as it already makes
- * the data-dependent checks.
- *
- * GTH: This is fixed.
- */
-typedef struct {
-    GLfloat   x, y, z;		/* Coordinates in screen space */
-    GLfloat   rhw;		/* Reciprocal homogeneous w */
-    r128Color dif_argb;		/* Diffuse color */
-    r128Color spec_frgb;	/* Specular color (alpha is fog) */
-    GLfloat   tu0, tv0;		/* Texture 0 coordinates */
-    GLfloat   tu1, tv1;		/* Texture 1 coordinates */
-} r128_vertex2;
-
-/* Need to be slightly clever about flushing vertex buffers in order
- * to use rhw2 only on demand.
- *
- * GTH: This can be used now.
+/* The vertex structure.  The final tu1/tv1 values are only used in
+ * multitexture modes, and the rhw2 value is currently never used.
  */
 typedef struct {
-    GLfloat   x, y, z;		/* Coordinates in screen space */
-    GLfloat   rhw;		/* Reciprocal homogeneous w */
-    r128Color dif_argb;		/* Diffuse color */
-    r128Color spec_frgb;	/* Specular color (alpha is fog) */
-    GLfloat   tu0, tv0;		/* Texture 0 coordinates */
-    GLfloat   tu1, tv1;		/* Texture 1 coordinates */
-    GLfloat   rhw2;		/* Reciprocal homogeneous w2 */
-} r128_vertex2_rhw2;
+    GLfloat x, y, z;		/* Coordinates in screen space */
+    GLfloat rhw;		/* Reciprocal homogeneous w */
+    r128_color_t color;		/* Diffuse color */
+    r128_color_t specular;	/* Specular color (alpha is fog) */
+    GLfloat tu0, tv0;		/* Texture 0 coordinates */
+    GLfloat tu1, tv1;		/* Texture 1 coordinates */
+    GLfloat rhw2;		/* Reciprocal homogeneous w2 */
+} r128_vertex;
 
 /* Format of vertices in r128_vertex struct */
 #define R128_TEX0_VERTEX_FORMAT                                            \
@@ -125,11 +84,9 @@
 
 /* FIXME: We currently only have assembly for 16-stride vertices */
 union r128_vertex_t {
-    r128_vertex1	vert1;
-    r128_vertex2	vert2;
-    r128_vertex2_rhw2	vert3;
-    float		f[16];
-    CARD32		ui[16];
+   r128_vertex	v;
+   GLfloat	f[16];
+   CARD32	ui[16];
 };
 
 typedef union r128_vertex_t r128Vertex;
@@ -146,21 +103,26 @@
 
 #define R128_DRIVER_DATA(vb) ((r128VertexBufferPtr)((vb)->driver_data))
 
-#define R128_SPEC_BIT       0x01
-#define R128_TEX1_BIT       0x02
-#define R128_TEX0_BIT       0x04
-#define R128_RGBA_BIT       0x08
-#define R128_WIN_BIT        0x10
-
-extern void         r128SetupInit(void);
-extern void         r128ChooseRasterSetupFunc(GLcontext *ctx);
-extern void         r128CheckPartialRasterSetup(GLcontext *ctx,
-						struct gl_pipeline_stage *s);
-extern void         r128PartialRasterSetup(struct vertex_buffer *VB);
-extern void         r128DoRasterSetup(struct vertex_buffer *VB);
-extern void         r128ResizeVB(struct vertex_buffer *VB, GLuint size);
-extern void         r128DDRegisterVB(struct vertex_buffer *VB);
-extern void         r128DDUnregisterVB(struct vertex_buffer *VB);
+#define R128_WIN_BIT		0x01
+#define R128_RGBA_BIT		0x02
+#define R128_FOG_BIT		0x04
+#define R128_SPEC_BIT		0x08
+#define R128_TEX0_BIT		0x10
+#define R128_TEX1_BIT		0x20
+
+extern void r128DDSetupInit( void );
+
+extern void r128DDChooseRasterSetupFunc( GLcontext *ctx );
+extern void r128PrintSetupFlags( char *msg, GLuint flags );
+
+extern void r128DDCheckPartialRasterSetup( GLcontext *ctx,
+					 struct gl_pipeline_stage *s );
+extern void r128DDPartialRasterSetup(struct vertex_buffer *VB);
+extern void r128DDDoRasterSetup(struct vertex_buffer *VB);
+
+extern void r128DDResizeVB(struct vertex_buffer *VB, GLuint size);
+extern void r128DDRegisterVB(struct vertex_buffer *VB);
+extern void r128DDUnregisterVB(struct vertex_buffer *VB);
 
 #endif
 #endif /* _R128_VB_H_ */
Index: xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c
diff -u xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c:1.1 xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c:1.4
--- xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c:1.1	Fri Jun 16 20:03:09 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c	Tue Dec 12 12:17:08 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c,v 1.1 2000/06/17 00:03:09 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c,v 1.4 2000/12/12 17:17:08 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -28,45 +28,25 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Gareth Hughes <gareth@valinux.com>
  *
  */
 
 #ifdef GLX_DIRECT_RENDERING
 
 /* r128 Mesa driver includes */
-#include "r128_init.h"
 #include "r128_context.h"
-#include "r128_xmesa.h"
+#include "r128_ioctl.h"
 #include "r128_state.h"
 #include "r128_tex.h"
-#include "r128_swap.h"
 
 /* Mesa src includes */
 #include "context.h"
 #include "simple_list.h"
 #include "mmath.h"
 
-#ifndef R128_DEBUG_FLAGS
-int R128_DEBUG_FLAGS = (0
-/*			| DEBUG_ALWAYS_SYNC */
-/*			| DEBUG_VERBOSE_CCE */
-/*			| DEBUG_VERBOSE_OUTREG */
-/*			| DEBUG_VERBOSE_MSG */
-/*			| DEBUG_NO_OUTRING */
-/*			| DEBUG_NO_OUTREG */
-/*			| DEBUG_VERBOSE_API */
-/*			| DEBUG_VERBOSE_2D */
-/*			| DEBUG_VERBOSE_DRI */
-/*			| DEBUG_VALIDATE_RING */
-/*			| DEBUG_VERBOSE_IOCTL */
-    );
-#endif
-
-#if DEBUG_LOCKING
-char *prevLockFile = NULL;
-int   prevLockLine = 0;
-#endif
+extern void __driRegisterExtensions( void );
 
 static r128ContextPtr r128Context = NULL;
 
@@ -190,16 +170,21 @@
     if (driContextPriv) {
 	r128ContextPtr r128ctx = (r128ContextPtr)driContextPriv->driverPrivate;
 
-	if (r128Context &&
-	    r128ctx == (void *)r128Context &&
-	    driDrawPriv == R128_DRIDRAWABLE(r128Context))
-	    return GL_TRUE;
-
 	r128Context = r128MakeCurrent(r128Context, r128ctx, driDrawPriv);
 
 	gl_make_current2(R128_MESACTX(r128Context),
 			 driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer);
 
+	if (r128Context->driDrawable != driDrawPriv) {
+	   r128Context->driDrawable = driDrawPriv;
+	   r128Context->dirty = R128_UPLOAD_ALL;
+	}
+
+	/* GH: We need this to correctly calculate the window offset
+	 * and aux scissor rects.
+	 */
+	r128Context->new_state = R128_NEW_WINDOW | R128_NEW_CLIP;
+
 	if (!R128_MESACTX(r128Context)->Viewport.Width) {
 	    gl_Viewport(R128_MESACTX(r128Context), 0, 0,
 			driDrawPriv->w, driDrawPriv->h);
@@ -218,38 +203,23 @@
     return GL_TRUE;
 }
 
-/* Update the hardware state.  This is called if another context has
-   grabbed the hardware lock, which includes the X server.  This
-   function also updates the driver's window state after the X server
-   moves, resizes or restacks a window -- the change will be reflected
-   in the drawable position and clip rects.  Since the X server grabs
-   the hardware lock when it changes the window state, this routine will
-   automatically be called after such a change. */
-/* NOTE: This routine is only called while holding the hardware lock. */
-void XMesaUpdateState(__DRIcontextPrivate *driContextPriv)
-{
-    r128ContextPtr        r128ctx = driContextPriv->driverPrivate;
-    __DRIscreenPrivate   *sPriv   = R128_DRISCREEN(r128ctx);
-    __DRIdrawablePrivate *dPriv   = R128_DRIDRAWABLE(r128ctx);
-    int                   stamp   = dPriv->lastStamp;
-
-    /* The window might have moved, so we might need to get new clip
-       rects.
-
-       NOTE: This releases and regrabs the hw lock to allow the X server
-       to respond to the DRI protocol request for new drawable info.
-       Since the hardware state depends on having the latest drawable
-       clip rects, all state checking must be done _after_ this call. */
-    XMESA_VALIDATE_DRAWABLE_INFO(r128ctx->display, sPriv, dPriv);
-
-    r128UpdateState(r128ctx, (stamp != dPriv->lastStamp));
-}
-
 /* This function is called by libGL.so as soon as libGL.so is loaded.
  * This is where we'd register new extension functions with the dispatcher.
  */
-void __driRegisterExtensions(void)
+void __driRegisterExtensions( void )
 {
+}
+
+GLboolean
+XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
+}
+
+GLboolean
+XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
 }
 
 #endif
Index: xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h
diff -u xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h:1.1 xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h:removed
--- xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h:1.1	Fri Jun 16 20:03:09 2000
+++ xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h	Mon Dec 18 14:23:39 2000
@@ -1,44 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_xmesa.h,v 1.1 2000/06/17 00:03:09 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-                                               Cedar Park, Texas. 
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *
- */
-
-#ifndef _R128_XMESA_H_
-#define _R128_XMESA_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-extern void XMesaUpdateState(__DRIcontextPrivate *driContextPriv);
-extern void __driRegisterExtensions(void);
-
-#endif
-#endif /* _R128_XMESA_H_ */
Index: xc/lib/GL/mesa/src/drv/sis/Imakefile
diff -u xc/lib/GL/mesa/src/drv/sis/Imakefile:1.1 xc/lib/GL/mesa/src/drv/sis/Imakefile:1.12
--- xc/lib/GL/mesa/src/drv/sis/Imakefile:1.1	Fri Jun 30 15:30:17 2000
+++ xc/lib/GL/mesa/src/drv/sis/Imakefile	Tue Dec 12 18:24:28 2000
@@ -1,4 +1,4 @@
-XCOMM $PI:$
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/sis/Imakefile,v 1.12 2000/12/12 23:24:28 dawes Exp $
 
 #include <Threads.tmpl>
 
@@ -13,62 +13,89 @@
 
 XCOMM DEBUG_DEFINES = -DDEBUG_LOCKING
 XCOMM DEBUG_DEFINES = -DSIS_DEBUG
- 
+
 #if Malloc0ReturnsNull
 ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
 #endif
 
+#ifdef i386Architecture
+#if MesaUseMMX
+     MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+   3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseKatmai
+  KATMAI_DEFS = -DUSE_KATMAI_ASM
+#endif
+  ASM_DEFINES = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(KATMAI_DEFS)
+#endif
+
 #if BuildXF86DRI
   DRI_DEFINES = GlxDefines $(SIS_DEFINES)
-  DRI_INCLUDES = -I../../../../dri -I../../../../glx \
+ DRI_INCLUDES = -I../../../../dri -I../../../../glx \
 		-I../../../dri \
-      		-I$(TOP)/include -I$(TOP)/include/GL \
-    		-I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
+		-I$(TOP)/include -I$(TOP)/include/GL \
+		-I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
 		-I$(XF86DRIVERSRC)/sis \
 		-I../../../include -I../.. -I../../X \
-                -I../common/ \
-                -I$(XF86OSSRC)/linux/drm/kernel
+                -I../common/
 #endif
 
-MESA_INCLUDES = -I. -I.. -I../../include
+MESA_INCLUDES = -I. -I.. -I../../include \
+		-I../../../../dri/drm
 
 LinkSourceFile(xdriP.h, ../../X)
 
 #if 0
  DEBUG_SRC = sis_debug.c
  DEBUG_OBJ = sis_debug.o
- LinkSourceFile(sis_debug.c, ../../../../../../extras/Mesa/src/SIS)
- LinkSourceFile(sis_debug.h, ../../../../../../extras/Mesa/src/SIS)
  DEBUG_DEFINES += -DSIS_DUMP
 #endif
 
 #if 0
  STEREO_SRC = sis_stereo.c
  STEREO_OBJ = sis_stereo.o
- LinkSourceFile(sis_stereo.c, ../../../../../../extras/Mesa/src/SIS)
- LinkSourceFile(sis_stereo.h, ../../../../../../extras/Mesa/src/SIS)
  STEREO_DEFINES = -DSIS_STEREO=1
 #else
  STEREO_DEFINES = -DSIS_STEREO=0
 #endif
 
-     DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(DEBUG_DEFINES) \
-               $(STEREO_DEFINES)
+      DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFINES) \
+		$(DEBUG_DEFINES) $(STEREO_DEFINES)
      INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) \
 		-I./misc \
                 -I$(SERVERSRC)/hw/xfree86/drivers/sis
 
-     SISSRCS = sis_render.c sis_mesa.c sis_ctx.c sis_alloc.c \
-            sis_fog.c sis_clear.c sis_stencil.c \
-            sis_texture.c sis_xwin.c sis_xmesa.c sis_span.c sis_fastpath.c \
-            $(DEBUG_SRC) \
-            $(STEREO_SRC)
-
-     SISOBJS = sis_render.o sis_mesa.o sis_ctx.o sis_alloc.o \
-            sis_fog.o sis_clear.o sis_stencil.o \
-            sis_texture.o sis_xwin.o sis_xmesa.o sis_span.o sis_fastpath.o \
-            $(DEBUG_OBJ) \
-            $(STEREO_OBJ)
+      SISSRCS = sis_render.c \
+		sis_mesa.c \
+		sis_ctx.c \
+		sis_alloc.c \
+		sis_fog.c \
+		sis_clear.c \
+		sis_stencil.c \
+		sis_texture.c \
+		sis_xwin.c \
+		sis_xmesa.c \
+		sis_span.c \
+		sis_fastpath.c \
+		$(DEBUG_SRC) \
+		$(STEREO_SRC)
+
+      SISOBJS = sis_render.o \
+		sis_mesa.o \
+		sis_ctx.o \
+		sis_alloc.o \
+		sis_fog.o \
+		sis_clear.o \
+		sis_stencil.o \
+		sis_texture.o \
+		sis_xwin.o \
+		sis_xmesa.o \
+		sis_span.o \
+		sis_fastpath.o \
+		$(DEBUG_OBJ) \
+		$(STEREO_OBJ)
 
       DRISRCS = ../../../dri/dri_mesa.c \
 		../../../../dri/dri_tmm.c
@@ -159,8 +186,7 @@
 		../../vertices.c \
 		../../winpos.c \
 		../../xform.c \
-		../../zoom.c \
-		../../X86/common_x86.c
+		../../zoom.c
 
      MESAOBJS = ../../aatriangle.o \
 		../../accum.o \
@@ -236,25 +262,40 @@
 		../../zoom.o
 
 #ifdef i386Architecture
-     X86_SRCS = ../../X86/x86.c \
-		../../X86/x86a.S \
-		../../X86/common_x86.c \
-		../../X86/common_x86asm.S \
-		../../X86/vertex.S
-
-     X86_OBJS = ../../X86/x86.o \
-		../../X86/x86a.o \
-		../../X86/common_x86.o \
-		../../X86/common_x86asm.o \
-		../../X86/vertex.o
+     X86_SRCS = ../../X86/common_x86.c \
+		../../X86/common_x86_asm.S \
+		../../X86/x86.c \
+		../../X86/x86_cliptest.S \
+		../../X86/x86_vertex.S \
+		../../X86/x86_xform_masked2.S \
+		../../X86/x86_xform_masked3.S \
+		../../X86/x86_xform_masked4.S \
+		../../X86/x86_xform_raw2.S \
+		../../X86/x86_xform_raw3.S \
+		../../X86/x86_xform_raw4.S
+
+     X86_OBJS = ../../X86/common_x86.o \
+		../../X86/common_x86_asm.o \
+		../../X86/x86.o \
+		../../X86/x86_cliptest.o \
+		../../X86/x86_vertex.o \
+		../../X86/x86_xform_masked2.o \
+		../../X86/x86_xform_masked3.o \
+		../../X86/x86_xform_masked4.o \
+		../../X86/x86_xform_raw2.o \
+		../../X86/x86_xform_raw3.o \
+		../../X86/x86_xform_raw4.o
 
+#if MesaUseMMX
      MMX_SRCS = ../../X86/mmx_blend.S
 
      MMX_OBJS = ../../X86/mmx_blend.o
+#endif
 
 #if MesaUse3DNow
    3DNOW_SRCS = ../../X86/3dnow.c \
 		../../X86/3dnow_norm_raw.S \
+		../../X86/3dnow_vertex.S \
 		../../X86/3dnow_xform_masked1.S \
 		../../X86/3dnow_xform_masked2.S \
 		../../X86/3dnow_xform_masked3.S \
@@ -262,11 +303,11 @@
 		../../X86/3dnow_xform_raw1.S \
 		../../X86/3dnow_xform_raw2.S \
 		../../X86/3dnow_xform_raw3.S \
-		../../X86/3dnow_xform_raw4.S \
-		../../X86/vertex_3dnow.S
+		../../X86/3dnow_xform_raw4.S
 
    3DNOW_OBJS = ../../X86/3dnow.o \
 		../../X86/3dnow_norm_raw.o \
+		../../X86/3dnow_vertex.o \
 		../../X86/3dnow_xform_masked1.o \
 		../../X86/3dnow_xform_masked2.o \
 		../../X86/3dnow_xform_masked3.o \
@@ -274,19 +315,59 @@
 		../../X86/3dnow_xform_raw1.o \
 		../../X86/3dnow_xform_raw2.o \
 		../../X86/3dnow_xform_raw3.o \
-		../../X86/3dnow_xform_raw4.o \
-		../../X86/vertex_3dnow.o
+		../../X86/3dnow_xform_raw4.o
 #endif
 
+#if MesaUseKatmai
+  KATMAI_SRCS = ../../X86/katmai.c \
+		../../X86/katmai_norm_raw.S \
+		../../X86/katmai_vertex.S \
+		../../X86/katmai_xform_masked1.S \
+		../../X86/katmai_xform_masked2.S \
+		../../X86/katmai_xform_masked3.S \
+		../../X86/katmai_xform_masked4.S \
+		../../X86/katmai_xform_raw1.S \
+		../../X86/katmai_xform_raw2.S \
+		../../X86/katmai_xform_raw3.S \
+		../../X86/katmai_xform_raw4.S
+
+  KATMAI_OBJS = ../../X86/katmai.o \
+		../../X86/katmai_norm_raw.o \
+		../../X86/katmai_vertex.o \
+		../../X86/katmai_xform_masked1.o \
+		../../X86/katmai_xform_masked2.o \
+		../../X86/katmai_xform_masked3.o \
+		../../X86/katmai_xform_masked4.o \
+		../../X86/katmai_xform_raw1.o \
+		../../X86/katmai_xform_raw2.o \
+		../../X86/katmai_xform_raw3.o \
+		../../X86/katmai_xform_raw4.o
 #endif
+#endif
+
+#ifdef GlxSoProf
+       LOSRCS = ../../../../lowpc.c
+       HISRCS = ../../../../highpc.c
+
+       LOOBJS = ../../../../lowpc.o
+       HIOBJS = ../../../../highpc.o
+#endif
 
-      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
-      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS)
+      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS)
 
-	 SRCS = $(DRISRCS) $(DRMSRCS) $(SISSRCS) $(MESASRCS) $(ASMSRCS)
-	 OBJS = $(DRIOBJS) $(DRMOBJS) $(SISOBJS) $(MESAOBJS) $(ASMOBJS)
+         SRCS = $(LOSRCS) $(DRISRCS) $(DRMSRCS) $(MESASRCS) \
+		$(ASMSRCS) $(SISSRCS) $(HISRCS)
+         OBJS = $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) \
+		$(ASMOBJS) $(SISOBJS) $(HIOBJS)
+
+REQUIREDLIBS += MathLibrary
+#if !GlxBuiltInSIS
+REQUIREDLIBS += -L../../../.. -lGL -L../../../../../X11 -lX11
+#endif
+
 
-#if !GlxUseBuiltInDRIDriver || GlxDebugSIS 
+#if !GlxUseBuiltInDRIDriver
 #undef DoNormalLib NormalLibGlx
 #undef DoExtraLib SharedLibGlx
 #undef DoDebugLib DebugLibGlx
@@ -300,16 +381,18 @@
 SubdirLibraryRule($(OBJS))
 NormalLintTarget($(SRCS))
 
-#if !GlxUseBuiltInDRIDriver || GlxDebugSIS
-# if GlxDebugSIS && GlxUseBuiltInDRIDriver
-LIBNAME = libsis_dri.so
-# else
+#if !GlxUseBuiltInDRIDriver
 LIBNAME = sis_dri.so
-# endif
 ALL_OBJS = $(OBJS) 
 ALL_DEPS = DONE
 SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
-InstallDynamicModule($(LIBNAME),$(MODULEDIR)/dri,.)
+InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _sis_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
 #endif
 
 DependTarget()
Index: xc/lib/GL/mesa/src/drv/sis/sis_alloc.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_alloc.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_alloc.c:1.6
--- xc/lib/GL/mesa/src/drv/sis/sis_alloc.c:1.1	Fri Jun 30 15:30:18 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_alloc.c	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_alloc.c,v 1.6 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include <assert.h>
 
 #include "sis_ctx.h"
@@ -7,14 +41,14 @@
 # include "xf86fbman.h"
 #else
 # include "drm.h"
-# include "sis_drm_public.h"
+# include "sis_drm.h"
 # include <sys/ioctl.h>
 #endif
 
 #define Z_BUFFER_HW_ALIGNMENT 16
 #define Z_BUFFER_HW_PLUS (16 + 4)
 
-/* 3D engine uses 2,and bitblt uses 4 */
+/* 3D engine uses 2, and bitblt uses 4 */
 #define DRAW_BUFFER_HW_ALIGNMENT 16
 #define DRAW_BUFFER_HW_PLUS (16 + 4)
 
@@ -34,7 +68,7 @@
 #if defined(XFree86Server) && !defined(XF86DRI)
 
 static void *
-sis_malloc (__GLSiScontext * hwcx, GLuint size, void **free)
+sis_alloc_fb (__GLSiScontext * hwcx, GLuint size, void **free)
 {
   GLcontext *ctx = hwcx->gc;
   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
@@ -58,13 +92,15 @@
 }
 
 static void
-sis_free (__GLSiScontext * hwcx, void *free)
+sis_free_fb (int hHWContext, void *free)
 {
   xf86FreeOffscreenArea ((FBAreaPtr) free);
 }
 
 #else
 
+int gDRMSubFD = -1;
+
 /* debug */
 #if 1
 
@@ -72,7 +108,7 @@
 static int _total_video_memory_count = 0;
 
 static void *
-sis_malloc (__GLSiScontext * hwcx, GLuint size, void **free)
+sis_alloc_fb (__GLSiScontext * hwcx, GLuint size, void **free)
 {
   GLcontext *ctx = hwcx->gc;
   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
@@ -83,46 +119,43 @@
 
   fb.context = xmesa->driContextPriv->hHWContext;
   fb.size = size;
-  if(ioctl(hwcx->drmSubFD, SIS_IOCTL_FB_ALLOC, &fb) || !fb.physical)
+  if(ioctl(hwcx->drmSubFD, SIS_IOCTL_FB_ALLOC, &fb) || !fb.offset)
     return NULL;
   *free = (void *)fb.free;
 
   /* debug */
-  /* memset(fb.physical + GET_FbBase(hwcx), 0xff, size); */
+  /* memset(fb.offset + GET_FbBase(hwcx), 0xff, size); */
 
   if (SIS_VERBOSE&VERBOSE_SIS_MEMORY)
   {
-    fprintf(stderr, "sis_malloc: size=%u, offset=%lu, pid=%lu, count=%d\n", 
-           size, (DWORD)fb.physical, (DWORD)getpid(), 
+    fprintf(stderr, "sis_alloc_fb: size=%u, offset=%lu, pid=%lu, count=%d\n", 
+           size, (DWORD)fb.offset, (DWORD)getpid(), 
            ++_total_video_memory_count);
   }
 
-  return (void *)(fb.physical + GET_FbBase(hwcx));
+  return (void *)(fb.offset + GET_FbBase(hwcx));
 }
 
 static void
-sis_free (__GLSiScontext * hwcx, void *free)
+sis_free_fb (int hHWContext, void *free)
 {
-  GLcontext *ctx = hwcx->gc;
-  XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
-
   drm_sis_mem_t fb;
 
   if (SIS_VERBOSE&VERBOSE_SIS_MEMORY)
   {
-    fprintf(stderr, "sis_free: free=%lu, pid=%lu, count=%d\n", 
+    fprintf(stderr, "sis_free_fb: free=%lu, pid=%lu, count=%d\n", 
             (DWORD)free, (DWORD)getpid(), --_total_video_memory_count);
   }
   
-  fb.context = xmesa->driContextPriv->hHWContext;
-  fb.free = (unsigned int)free;
-  ioctl(hwcx->drmSubFD, SIS_IOCTL_FB_FREE, &fb);
+  fb.context = hHWContext;
+  fb.free = (unsigned long)free;
+  ioctl(gDRMSubFD, SIS_IOCTL_FB_FREE, &fb);
 }
 
 #else
 
 static void *
-sis_malloc (__GLSiScontext * hwcx, GLuint size, void **free)
+sis_alloc_fb (__GLSiScontext * hwcx, GLuint size, void **free)
 {
   static char *vidmem_base = 0x400000;
   char *rval = vidmem_base;
@@ -137,7 +170,7 @@
 }
 
 static void
-sis_free (__GLSiScontext * hwcx, void *free)
+sis_free_fb (int hHWContext, void *free)
 {
   return;
 }
@@ -146,6 +179,49 @@
 
 #endif
 
+static void *
+sis_alloc_agp (__GLSiScontext * hwcx, GLuint size, void **free)
+{
+  GLcontext *ctx = hwcx->gc;
+  XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+
+  drm_sis_mem_t agp;
+  
+  if(!hwcx->AGPSize)
+    return NULL;
+
+  agp.context = xmesa->driContextPriv->hHWContext;
+  agp.size = size;
+  if(ioctl(hwcx->drmSubFD, SIS_IOCTL_AGP_ALLOC, &agp) || !agp.offset)
+    return NULL;
+  *free = (void *)agp.free;
+
+  if (SIS_VERBOSE&VERBOSE_SIS_MEMORY)
+  {
+    fprintf(stderr, "sis_alloc_agp: size=%u, offset=%lu, pid=%lu, count=%d\n", 
+           size, (DWORD)agp.offset, (DWORD)getpid(), 
+           ++_total_video_memory_count);
+  }
+
+  return (void *)(agp.offset + GET_AGPBase(hwcx));
+}
+
+static void
+sis_free_agp (int hHWContext, void *free)
+{
+  drm_sis_mem_t agp;
+
+  if (SIS_VERBOSE&VERBOSE_SIS_MEMORY)
+  {
+    fprintf(stderr, "sis_free_agp: free=%lu, pid=%lu, count=%d\n", 
+            (DWORD)free, (DWORD)getpid(), --_total_video_memory_count);
+  }
+  
+  agp.context = hHWContext;
+  agp.free = (unsigned long)free;
+  ioctl(gDRMSubFD, SIS_IOCTL_AGP_FREE, &agp);
+}
+
 /* debug */
 static unsigned int Total_Real_Textures_Used = 0;
 static unsigned int Total_Textures_Used = 0;
@@ -165,19 +241,18 @@
 
   GLubyte *addr;
 
-  z_depth = (xm_buffer->xm_visual->gl_visual->DepthBits +
-	     xm_buffer->xm_visual->gl_visual->StencilBits) / 8;
+  z_depth = (ctx->Visual->DepthBits + ctx->Visual->StencilBits) / 8;
 
   width2 = ALIGNMENT (xm_buffer->width * z_depth, 4);
 
   totalBytes = xm_buffer->height * width2 + Z_BUFFER_HW_PLUS;
 
-  if (xm_buffer->gl_buffer->DepthBuffer)
+  if (xm_buffer->depthbuffer)
     {
       sis_free_z_stencil_buffer (xm_buffer);
     }
 
-  addr = sis_malloc (hwcx, totalBytes, &priv->zbFree);
+  addr = sis_alloc_fb (hwcx, totalBytes, &priv->zbFree);
   if (!addr)
     {
       fprintf (stderr, "SIS driver : out of video memory\n");
@@ -189,9 +264,9 @@
     fprintf(stderr, "sis_alloc_z_stencil_buffer: addr=%lu\n", (DWORD)addr);
   }
 
-  addr = (GLubyte *) ALIGNMENT ((GLuint) addr, Z_BUFFER_HW_ALIGNMENT);
+  addr = (GLubyte *) ALIGNMENT ((unsigned long) addr, Z_BUFFER_HW_ALIGNMENT);
 
-  xm_buffer->gl_buffer->DepthBuffer = (void *) addr;
+  xm_buffer->depthbuffer = (void *) addr;
 
   /* software render */
   hwcx->swZBase = addr;
@@ -230,11 +305,11 @@
 sis_free_z_stencil_buffer (XMesaBuffer buf)
 {
   sisBufferInfo *priv = (sisBufferInfo *) buf->private;
-  __GLSiScontext *hwcx = (__GLSiScontext *) buf->xm_context->private;
+  XMesaContext xmesa = buf->xm_context;
 
-  sis_free (hwcx, priv->zbFree);
+  sis_free_fb (xmesa->driContextPriv->hHWContext, priv->zbFree);
   priv->zbFree = NULL;
-  buf->gl_buffer->DepthBuffer = NULL;
+  buf->depthbuffer = NULL;
 }
 
 void
@@ -260,16 +335,17 @@
   width2 = (depth == 2) ? ALIGNMENT (xm_buffer->width, 2) : xm_buffer->width;
   size = width2 * xm_buffer->height * depth + DRAW_BUFFER_HW_PLUS;
 
-  addr = sis_malloc (hwcx, size, free);
+  /* Fixme: unique context alloc/free back-buffer? */
+  addr = sis_alloc_fb (hwcx, size, free);
   if (!addr)
     {
       fprintf (stderr, "SIS driver : out of video memory\n");
       sis_fatal_error ();
     }
 
-  addr = (GLbyte *) ALIGNMENT ((GLuint) addr, DRAW_BUFFER_HW_ALIGNMENT);
+  addr = (GLbyte *) ALIGNMENT ((unsigned long) addr, DRAW_BUFFER_HW_ALIGNMENT);
 
-  image->data = addr;
+  image->data = (char *)addr;
 
   image->bytes_per_line = width2 * depth;
   image->bits_per_pixel = depth * 8;
@@ -304,9 +380,9 @@
 void
 sis_free_back_image (XMesaBuffer buf, XMesaImage *image, void *free)
 {
-  __GLSiScontext *hwcx = (__GLSiScontext *) buf->xm_context->private;
+  XMesaContext xmesa = buf->xm_context;
 
-  sis_free (hwcx, free);
+  sis_free_fb (xmesa->driContextPriv->hHWContext, free);
   image->data = NULL; 
 }
 
@@ -403,20 +479,34 @@
 
   size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS;
 
-  addr = sis_malloc (hwcx, size, &area->pArea);
-  if (!addr)
-    {
-      fprintf (stderr, "SIS driver : out of video memory\n");
-      sis_fatal_error ();
-      return;
-    }
+  do{
+    addr = sis_alloc_fb (hwcx, size, &area->free);
+    area->memType = VIDEO_TYPE;
+    if(addr) break;
+    
+    /* TODO: swap to agp memory*/
+    /* video memory allocation fails */
+    addr = sis_alloc_agp(hwcx, size, &area->free);
+    area->memType = AGP_TYPE;
+    if(addr) break;
+    
+    /* TODO: swap to system memory */
+  }  
+  while(0);
 
-  area->Data = (GLbyte *) ALIGNMENT ((GLuint) addr, TEXTURE_HW_ALIGNMENT);
+  if (!addr){
+    fprintf (stderr, "SIS driver : out of video/agp memory\n");
+    sis_fatal_error ();
+    return;
+  }
+
+  area->Data =
+    (GLbyte *) ALIGNMENT ((unsigned long) addr, TEXTURE_HW_ALIGNMENT);
   area->Pitch = image->Width * texel_size;
   area->Format = driver_format;
   area->Size = image->Width * image->Height * texel_size;
   area->texelSize = texel_size;
-  area->hwcx = hwcx;
+  area->hHWContext = xmesa->driContextPriv->hHWContext;
 
   /* debug */
   area->realSize = area->Size;
@@ -430,7 +520,6 @@
 sis_free_texture_image (GLtextureImage * image)
 {
   SIStextureArea *area = (SIStextureArea *) image->DriverData;
-  __GLSiScontext *hwcx = (__GLSiScontext *) area->hwcx;
 
   /* debug */
   Total_Real_Textures_Used -= area->realSize;
@@ -438,9 +527,18 @@
 
   if (!area)
     return;
-
+  
   if (area->Data)
-    sis_free (hwcx, area->pArea);
+    switch(area->memType){
+    case VIDEO_TYPE:  
+      sis_free_fb (area->hHWContext, area->free);
+      break;
+    case AGP_TYPE:  
+      sis_free_agp (area->hHWContext, area->free);
+      break;
+    default:
+      assert(0);
+    }
 
   free (area);
   image->DriverData = NULL;
Index: xc/lib/GL/mesa/src/drv/sis/sis_clear.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_clear.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_clear.c:1.5
--- xc/lib/GL/mesa/src/drv/sis/sis_clear.c:1.1	Fri Jun 30 15:30:19 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_clear.c	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_clear.c,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include "sis_ctx.h"
 #include "sis_mesa.h"
 #include "sis_lock.h"
@@ -47,7 +81,7 @@
    * differs from current draw buffer 
    */
 
-  if ((xm_buffer->xm_visual->gl_visual->StencilBits &&
+  if ((ctx->Visual->StencilBits &&
        ((mask | GL_DEPTH_BUFFER_BIT) ^ (mask | GL_STENCIL_BUFFER_BIT))) 
       || (*(DWORD *) (ctx->Color.ColorMask) != 0xffffffff)
     )
@@ -63,7 +97,7 @@
     }
   if (mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT))
     {
-      if (xm_buffer->gl_buffer->DepthBuffer)
+      if (xm_buffer->depthbuffer)
 	sis_clear_z_stencil_buffer (ctx, mask, x1, y1, width1, height1);
       mask &= ~(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
     }
@@ -127,9 +161,9 @@
 
   bClrColor = 0;
   bClrDepth = (mask & GL_DEPTH_BUFFER_BIT) && 
-              (xmesa->xm_visual->gl_visual->DepthBits);
+              (ctx->Visual->DepthBits);
   bClrStencil = (mask & GL_STENCIL_BUFFER_BIT) && 
-                (xmesa->xm_visual->gl_visual->StencilBits);
+                (ctx->Visual->StencilBits);
 
   /* update HW state */
   /* TODO: if enclosing sis_Clear by sis_RenderStart and sis_RenderEnd is
@@ -435,12 +469,12 @@
   XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
   __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
 
-  GLframebuffer *buffer = ctx->DrawBuffer;
+  XMesaBuffer xm_buffer = xmesa->xm_buffer;
   sisBufferInfo *priv = (sisBufferInfo *) xmesa->xm_buffer->private;
 
   /* TODO: check write mask */
 
-  if (!buffer->DepthBuffer)
+  if (!xm_buffer->depthbuffer)
     return;
 
   /* TODO: consider alignment of width, height? */
@@ -554,17 +588,22 @@
 
   /* frame control */
   /* TODO: need lock? */
-  while((*hwcx->FrameCountPtr) - *(DWORD *)(hwcx->IOBase+0x8a2c) 
-        > SIS_MAX_FRAME_LENGTH)
+  
+#if 1
   {
-    DWORD temp = *(DWORD *)(hwcx->IOBase+0x8a2c);
+    int repeat = 0;
+    
+    while(((*hwcx->FrameCountPtr) - *(DWORD volatile *)(hwcx->IOBase+0x8a2c) 
+          > SIS_MAX_FRAME_LENGTH) && 
+          (repeat++ < 10));
   }
+#endif
 
   LOCK_HARDWARE ();
-  
+
+  sis_swap_image (b, b->frontbuffer, b->backimage);
   *(DWORD *)(hwcx->IOBase+0x8a2c) = *hwcx->FrameCountPtr;
   (*hwcx->FrameCountPtr)++;  
-  sis_swap_image (b, b->frontbuffer, b->backimage);
    
   UNLOCK_HARDWARE ();
 }
Index: xc/lib/GL/mesa/src/drv/sis/sis_common.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_common.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_common.h:1.5
--- xc/lib/GL/mesa/src/drv/sis/sis_common.h:1.1	Fri Jun 30 15:30:19 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_common.h	Tue Sep 26 11:56:48 2000
@@ -1,9 +1,49 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_common.h,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #ifndef _sis_common_h_
 #define _sis_common_h_
 
 #include "types.h"
 #include "sis_xmesaP.h"
 
+#if 0
+#define free(x)
+#define calloc(x,y) sis_debug_malloc((x)*(y))
+extern void *sis_debug_malloc(int x);
+#endif
+
 #if defined(SIS_DUMP)
 #include "sis_debug.h"
 #endif
@@ -47,10 +87,8 @@
 typedef long LONG;
 typedef DWORD *LPDWORD;
 
-/*
- * BitBlt Commands
- */
-#define  Index_SR_Misc_Ctrl11                   0x3e
+/* BitBlt Commands */
+#define  Index_SR_Misc_Ctrl11    0x3e
 #define CMD0_DD_ENABLE      0x06
 #define CMD0_SRC_VIDEO      0x00
 #define CMD0_SRC_CPU        0x10
@@ -121,24 +159,26 @@
 }
 ENGPACKET, *LPENGPACKET;
 
-/* 
- * Hardware Info
- */
+/* Hardware Info */
 #include "sis_reg.h"
 #include "sis_init.h"
 
 typedef struct gl_texture_object GLtextureObject;
 typedef struct gl_texture_image GLtextureImage;
 
+#define VIDEO_TYPE 0
+#define AGP_TYPE 1
+
 typedef struct sis_texure_area
 {
   GLbyte *Data;
   GLenum Format;
-  void *pArea;
+  void *free;
+  GLuint memType;
   GLuint Pitch;
   GLuint Size;
   GLuint texelSize;
-  void *hwcx;
+  unsigned int hHWContext;
 
   /* Debug */
   GLuint realSize;
Index: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_ctx.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_ctx.c:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_ctx.c:1.1	Fri Jun 30 15:30:20 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_ctx.c	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #ifdef XFree86Server
 # define PSZ 8
 # include "cfb.h"
Index: xc/lib/GL/mesa/src/drv/sis/sis_ctx.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_ctx.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_ctx.h:1.5
--- xc/lib/GL/mesa/src/drv/sis/sis_ctx.h:1.1	Fri Jun 30 15:30:20 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_ctx.h	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.h,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #ifndef _sis_ctx_h_
 #define _sis_ctx_h_
 
@@ -107,9 +141,8 @@
 }
 __GLSiSHardware;
 
-/*
- ** Device dependent context state
- */
+/* Device dependent context state */
+
 typedef struct __GLSiScontextRec
 {
   /* This must be first in this structure */
@@ -119,10 +152,10 @@
   unsigned int bytesPerPixel;
   unsigned char *IOBase;
   unsigned char *FbBase;
-  unsigned int displayWidth;	/* per byte */
+  unsigned int displayWidth;
   unsigned int pitch;
 
-  /* for sw-render */
+  /* For Software Renderer */
   GLubyte *swRenderBase;
   GLuint swRenderPitch;
   GLubyte *swZBase;
@@ -141,7 +174,7 @@
   unsigned int clearColorPattern;
   unsigned int clearZStencilPattern;
 
-  /* render function */
+  /* Render Function */
   points_func PointsFunc;
   line_func LineFunc;
   triangle_func TriangleFunc;
@@ -194,7 +227,7 @@
 
   void (*SwapBuffers)(XMesaBuffer b);
 
-  /* stereo */
+  /* Stereo */
   GLboolean isFullScreen;
   GLboolean useStereo;
   GLboolean stereoEnabled;
@@ -219,9 +252,10 @@
 }
 __GLSiScontext;
 
-/* Macros to access hwcx */
+/* Macros */
 #define GET_IOBase(x) ((x)->IOBase)
 #define GET_FbBase(x) ((x)->FbBase)
+#define GET_AGPBase(x) ((x)->AGPBase)
 #define GET_DEPTH(x) ((x)->bytesPerPixel)
 #define GET_WIDTH(x) ((x)->displayWidth)
 #define GET_PITCH(x) ((x)->pitch)
@@ -249,6 +283,9 @@
 void sis_StartAGP (GLcontext * ctx);
 void sis_FlushAGP (GLcontext * ctx);
 extern float *AGP_CurrentPtr;
+
+/* DRM FD */
+extern int gDRMSubFD;
 
 void sis_fatal_error (void);
 
Index: xc/lib/GL/mesa/src/drv/sis/sis_debug.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_debug.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_debug.c:1.5
--- xc/lib/GL/mesa/src/drv/sis/sis_debug.c:1.1	Fri Jun 30 15:30:21 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_debug.c	Tue Sep 26 11:56:48 2000
@@ -1,5 +1,39 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_debug.c,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 /* 
- * dump HW states, set environment variable SIS_DE1BUG
+ * dump HW states, set environment variable SIS_DEBUG
  * to enable these functions 
  */
 
@@ -9,7 +43,7 @@
 #include "sis_ctx.h"
 #include "sis_mesa.h"
 
-/* for SiS 300 */
+/* for SiS 300/630/540 */
 #define MMIOLength (0x8FFF-0x8800+1)
 #define MMIO3DOffset (0x8800)
 #define FILE_NAME "300.dump"
@@ -21,8 +55,6 @@
 
 DWORD _empty[0x10000];
 
-//#if defined(DEBUG)
-
 void
 dump_agp (void *addr, int dword_count)
 {
@@ -123,16 +155,3 @@
       close (fh);
     }
 }
-
-/*
-#else
-
-#define dump_agp(a,b) do{}while(0)
-#define d2f() do{}while(0)
-#define d2f_once(a) do{}while(0)
-#define void d2f(a) do{}while(0)
-#define void d2h(a) do{}while(0)
-#define dvidmem(a,b) do{}while(0)
-
-#endif
-*/
\ No newline at end of file
Index: xc/lib/GL/mesa/src/drv/sis/sis_debug.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_debug.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_debug.h:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_debug.h:1.1	Fri Jun 30 15:30:21 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_debug.h	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_debug.h,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #ifndef _sis_debug_h_
 #define _sis_debug_h_
 
Index: xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c:1.1	Fri Jun 30 15:30:22 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_fastpath.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 /* 
  *  FOR 
  *  1. triangle/strip with 2-texture with no other capability  
Index: xc/lib/GL/mesa/src/drv/sis/sis_fog.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_fog.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_fog.c:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_fog.c:1.1	Fri Jun 30 15:30:22 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_fog.c	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_fog.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include "sis_ctx.h"
 #include "sis_mesa.h"
 
Index: xc/lib/GL/mesa/src/drv/sis/sis_init.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_init.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_init.h:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_init.h:1.1	Fri Jun 30 15:30:23 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_init.h	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_init.h,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #ifndef _sis_init_h_
 #define _sis_init_h_
 
Index: xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h:1.5
--- xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h:1.1	Fri Jun 30 15:30:23 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_linefunc.h,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #define SIS_TRI_FUNC 0
 
 #define SIS_MMIO_WRITE_VERTEX(v, i) \
@@ -16,16 +50,16 @@
     { \
       if(SIS_TRI_FUNC){ \
         MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = \
-  	(VB->Win.data[v][2] + ctx->PolygonZoffset) / 65535.0; \
+  	(VB->Win.data[v][2] + ctx->PolygonZoffset) / SIS_DEPTH_SCALE; \
       } \
       else{ \
         MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = \
-  	(VB->Win.data[v][2] + ctx->LineZoffset) / 65535.0; \
+  	(VB->Win.data[v][2] + ctx->LineZoffset) / SIS_DEPTH_SCALE; \
       } \
     } \
   else \
     { \
-      MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = VB->Win.data[v][2] / 65535.0; \
+      MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = VB->Win.data[v][2] / SIS_DEPTH_SCALE; \
     } \
 \
   if (SIS_STATES & SIS_TEXTURE0) \
@@ -142,19 +176,19 @@
 \
 if (ctx->TriangleCaps & DD_TRI_OFFSET){ \
   if(SIS_TRI_FUNC){ \
-    AGP_CurrentPtr[2] = (VB->Win.data[v][2] + ctx->PolygonZoffset) / 65535.0; \
+    AGP_CurrentPtr[2] = (VB->Win.data[v][2] + ctx->PolygonZoffset) / SIS_DEPTH_SCALE; \
   } \
   else{ \
-    AGP_CurrentPtr[2] = (VB->Win.data[v][2] + ctx->LineZoffset) / 65535.0; \
+    AGP_CurrentPtr[2] = (VB->Win.data[v][2] + ctx->LineZoffset) / SIS_DEPTH_SCALE; \
   } \
 } \
 else{ \
-  AGP_CurrentPtr[2] = VB->Win.data[v][2] / 65535.0; \
+  AGP_CurrentPtr[2] = VB->Win.data[v][2] / SIS_DEPTH_SCALE; \
 }\
 AGP_CurrentPtr+=3; \
 if (SIS_STATES & (SIS_USE_W)) \
 { \
-   if(VB->TexCoordPtr[1]->size == 4){ \
+   if(VB->TexCoordPtr[0]->size == 4){ \
      AGP_CurrentPtr[0] = VB->Win.data[v][3] * \
                          VB->TexCoordPtr[0]->data[v][3]; \
    } \
Index: xc/lib/GL/mesa/src/drv/sis/sis_lock.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_lock.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_lock.h:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_lock.h:1.1	Fri Jun 30 15:30:24 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_lock.h	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_lock.h,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #ifndef _sis_dri_h_
 #define _sis_dri_h_
 
Index: xc/lib/GL/mesa/src/drv/sis/sis_mesa.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_mesa.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_mesa.c:1.5
--- xc/lib/GL/mesa/src/drv/sis/sis_mesa.c:1.1	Fri Jun 30 15:30:24 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_mesa.c	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_mesa.c,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include "sis_ctx.h"
 #include "sis_mesa.h"
 #include "sis_lock.h"
@@ -43,7 +77,9 @@
       sis_StartAGP (ctx);
     }
   
-   /* d2f_once (ctx); */
+#if defined(SIS_DUMP)
+   d2f_once (ctx);
+#endif
 }
 
 void
@@ -168,7 +204,7 @@
   ctx->Driver.Bitmap = sis_Bitmap;
   
   /* Optimization */
-#if NOT_DONE
+#ifdef NOT_DONE
   ctx->Driver.RasterSetup = sis_ChooseRasterSetupFunc(ctx);
   ctx->Driver.RegisterVB = sis_RegisterVB;
   ctx->Driver.UnregisterVB = sis_UnregisterVB;
@@ -293,7 +329,7 @@
 	}
     }
 
-#if NOT_DONE
+#ifdef NOT_DONE
   sis_set_render_vb_tabs(ctx);
 #endif
 
@@ -645,7 +681,6 @@
   __GLSiSHardware *prev = &hwcx->prev;
   __GLSiSHardware *current = &hwcx->current;
 
-  /* TODO, in xfree 3.9.18, no ctx->Buffer */
   if (ctx->Visual->StencilBits)
     {
       if (flag || ctx->Stencil.WriteMask)
@@ -753,7 +788,7 @@
 #endif
       break;
     case GL_DEPTH_TEST:
-      if (state && xmesa->xm_buffer->gl_buffer->DepthBuffer)
+      if (state && xmesa->xm_buffer->depthbuffer)
 	{
 	  current->hwCapEnable |= MASK_ZTestEnable;
 	}
@@ -1010,8 +1045,8 @@
   assert (base != NULL);
 
   if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){
-    fprintf(stderr, "set drawing position: base=%x, pitch=%u\n", 
-            (unsigned int)base, pitch);
+    fprintf(stderr, "set drawing position: base=%x, pitch=%lu\n", 
+            (unsigned long)base, pitch);
   }
 
   /* software render */
@@ -1093,7 +1128,7 @@
 
 
   if (rmask & gmask & bmask &
-      (!xmesa->xm_visual->gl_visual->AlphaBits | amask))
+      (!ctx->Visual->AlphaBits | amask))
     {
       current->hwCapEnable2 &= ~(MASK_AlphaMaskWriteEnable |
 				 MASK_ColorMaskWriteEnable);
@@ -1354,7 +1389,7 @@
   current->hwZ &= ~MASK_ZBufferPitch;
   current->hwZ |= xm_buffer->width * z_depth >> 2;
   /* TODO, in xfree 3.9.18, no ctx->Buffer */
-  current->hwOffsetZ = ((DWORD) (ctx->DrawBuffer->DepthBuffer) -
+  current->hwOffsetZ = ((DWORD) (xm_buffer->depthbuffer) -
 		       (DWORD) GET_FbBase (hwcx)) >> 2;
 
   if ((current->hwOffsetZ ^ prev->hwOffsetZ)
@@ -1422,7 +1457,7 @@
 	                        &priv->cbClearPacket);
 	}
 
-      if (xm_buffer->xm_visual->gl_visual->DepthBits)
+      if (ctx->Visual->DepthBits)
 	sis_alloc_z_stencil_buffer (ctx);
 
       switch (hwcx->zFormat)
@@ -1444,7 +1479,7 @@
       current->hwZ &= ~MASK_ZBufferPitch;
       current->hwZ |= xm_buffer->width * z_depth >> 2;
       /* TODO, in xfree 3.9.18, no ctx->Buffer */
-      current->hwOffsetZ = ((DWORD) (ctx->DrawBuffer->DepthBuffer) -
+      current->hwOffsetZ = ((DWORD) (xm_buffer->depthbuffer) -
 			    (DWORD) GET_FbBase (hwcx)) >> 2;
 
       if ((current->hwOffsetZ ^ prev->hwOffsetZ)
Index: xc/lib/GL/mesa/src/drv/sis/sis_mesa.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_mesa.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_mesa.h:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_mesa.h:1.1	Fri Jun 30 15:30:25 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_mesa.h	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_mesa.h,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #ifndef _sis_mesa_h_
 #define _sis_mesa_h_
 
Index: xc/lib/GL/mesa/src/drv/sis/sis_reg.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_reg.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_reg.h:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_reg.h:1.1	Fri Jun 30 15:30:25 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_reg.h	Tue Sep 26 11:56:48 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_reg.h,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #ifndef _sis_reg_h_
 #define _sis_reg_h_
 
Index: xc/lib/GL/mesa/src/drv/sis/sis_render.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_render.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_render.c:1.5
--- xc/lib/GL/mesa/src/drv/sis/sis_render.c:1.1	Fri Jun 30 15:30:26 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_render.c	Tue Sep 26 11:56:49 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_render.c,v 1.5 2000/09/26 15:56:49 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include "sis_ctx.h"
 #include "sis_mesa.h"
 
@@ -9,6 +43,8 @@
 #define SIS_USE_Z 0x11
 #define SIS_FALLBACK 0x80000000
 
+#define SIS_DEPTH_SCALE 1.0
+
 /* 
  * TODO: assert(hwcx->AGPCmdBufSize % AGP_ALLOC_SIZE == 0) 
  *       depends on VB_SIZE is better
@@ -417,9 +453,12 @@
   hwcx->AGPParseSet &= ~0xffff7000;
   hwcx->AGPParseSet |= AGPParsingValues[line_index & ~SIS_FALLBACK];
 
-  /* Debug, test sw-render 
+  /* Debug, test sw-render
   ctx->Driver.LineFunc = NULL;
   ctx->Driver.TriangleFunc = NULL;  
+  hwcx->swRenderFlag = ~0x0;  
+  ctx->Visual->DepthMax = (sizeof(GLdepth)==2)?0xffff:0xffffffff;
+  ctx->Visual->DepthMaxF = (double)(sizeof(GLdepth)==2)?0xffff:0xffffffff;
   */
 }
 
@@ -470,10 +509,6 @@
       return;
     }
 
-  /* debug
-  d2f_once(ctx); 
-  */
-     
   mWait3DCmdQueue (5);
   mEndPrimitive ();
   MMIO (REG_3D_AGPCmBase, ((DWORD) AGP_StartPtr - (DWORD) hwcx->AGPCmdBufBase)
Index: xc/lib/GL/mesa/src/drv/sis/sis_span.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_span.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_span.c:1.4
--- xc/lib/GL/mesa/src/drv/sis/sis_span.c:1.1	Fri Jun 30 15:30:26 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_span.c	Tue Sep 26 11:56:49 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_span.c,v 1.4 2000/09/26 15:56:49 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include "sis_ctx.h"
 #include "sis_mesa.h"
 
@@ -12,7 +46,7 @@
    XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;  \
    __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private; \
    GLuint pitch = hwcx->swRenderPitch;			\
-   char *buf = hwcx->swRenderBase			
+   char *buf = (char *)hwcx->swRenderBase			
 
 #define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
 			  _y >= miny && _y < maxy)
Index: xc/lib/GL/mesa/src/drv/sis/sis_stencil.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_stencil.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_stencil.c:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_stencil.c:1.1	Fri Jun 30 15:30:27 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_stencil.c	Tue Sep 26 11:56:49 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_stencil.c,v 1.3 2000/09/26 15:56:49 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include "sis_ctx.h"
 #include "sis_mesa.h"
 
Index: xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h:1.1	Fri Jun 30 15:30:27 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h	Tue Sep 26 11:56:49 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_swzfunc.h,v 1.3 2000/09/26 15:56:49 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 static void SIS_TAG (sis_WriteDepthSpan) (GLcontext * ctx, GLuint n, GLint x,
 					  GLint y, const GLdepth depth[],
 					  const GLubyte mask[])
Index: xc/lib/GL/mesa/src/drv/sis/sis_texture.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_texture.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_texture.c:1.5
--- xc/lib/GL/mesa/src/drv/sis/sis_texture.c:1.1	Fri Jun 30 15:30:28 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_texture.c	Tue Sep 26 11:56:49 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_texture.c,v 1.5 2000/09/26 15:56:49 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include "sis_ctx.h"
 #include "sis_mesa.h"
 
@@ -111,10 +145,8 @@
   SIStextureArea *area;
 
   if (target == GL_TEXTURE_3D || image->Border)
-    {
-      return;
-    }
-
+    return;
+  
   if (!tObj->DriverData)
     {
       sisTexobjInfo *info;
@@ -137,8 +169,7 @@
     }
   else
     {
-      /* Optimize */
-      
+      /* Optimize */    
       ((sisTexobjInfo *) tObj->DriverData)->dirtyFlag |= (SIS_TEX_PARAMETER
 							  | SIS_TEX_ENV);
     }
@@ -151,7 +182,7 @@
   if (area->Format == GL_RGB8)
     {
       int i;
-      GLbyte *src = image->Data;
+      GLbyte *src = (GLbyte *)image->Data;
       GLbyte *dst = area->Data;
 
       for (i = 0; i < area->Size / 4; i++)
@@ -201,7 +232,7 @@
 
   if (area->Format == GL_RGB8)
     {
-      src = image->Data + (xoffset + yoffset * image->Width) * 3;
+      src = (GLbyte *)image->Data + (xoffset + yoffset * image->Width) * 3;
       dst = area->Data + (xoffset + yoffset * image->Width) * 4;
       soffset = (image->Width - width) * 3;
       doffset = (image->Width - width) * 4;
@@ -222,7 +253,8 @@
       GLuint texelSize = area->texelSize;
       GLuint copySize = texelSize * width;
 
-      src = image->Data + (xoffset + yoffset * image->Width) * texelSize;
+      src = (GLbyte *)image->Data +
+	(xoffset + yoffset * image->Width) * texelSize;
       dst = area->Data + (xoffset + yoffset * image->Width) * texelSize;
       soffset = image->Width * texelSize;
 
@@ -737,10 +769,22 @@
 
     for (i = 0; i < TxLevel + 1; i++)
       {
-	SIStextureArea *area =
-	  (SIStextureArea *) object->Image[i]->DriverData;
-	GLuint texOffset = ((GLuint) area->Data - (GLuint) GET_FbBase (hwcx));
+	SIStextureArea *area = (SIStextureArea *) object->Image[i]->DriverData;
+        GLuint texOffset;
 	GLuint texPitch = TransferTexturePitch (area->Pitch);
+
+	switch(area->memType){
+	case VIDEO_TYPE:
+	  texOffset = ((char *) area->Data - (char *) GET_FbBase (hwcx));
+	  break;
+	case AGP_TYPE:
+	  texOffset = ((char *) area->Data - (char *) GET_AGPBase (hwcx)) +
+	               (unsigned long) hwcx->AGPAddr;
+          current->texture[hw_unit].hwTextureMip |= (0x40000 << i);
+          break;
+        default:
+          assert(0);
+        }
 
 	switch (i)
 	  {
Index: xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h:1.1	Fri Jun 30 15:30:28 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h	Tue Sep 26 11:56:49 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_trifunc.h,v 1.3 2000/09/26 15:56:49 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #define SIS_TRI_FUNC 1
 
 static void
Index: xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c:1.6
--- xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c:1.1	Fri Jun 30 15:30:29 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c	Thu Dec  7 15:26:10 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c,v 1.6 2000/12/07 20:26:10 dawes Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include <unistd.h>
 #include <sys/mman.h>
 #include "sis_dri.h"
@@ -13,6 +47,18 @@
 #include "vbxform.h"
 #include "types.h"
 
+#if 0
+void *sis_debug_malloc(x){
+  static char buf[2000000];
+  static int count = 0;
+  void *retval;
+  
+  retval = &(buf[count]);
+  count += x;
+  return retval;
+}
+#endif
+
 static XMesaContext XMesa = NULL;  /* Current X/Mesa context pointer */
 
 #ifndef SIS_VERBOSE
@@ -64,6 +110,8 @@
   global_regs = priv->regs;
   global_agp = priv->agp;
   global_FbBase = driScrnPriv->pFB;
+
+  gDRMSubFD = driScrnPriv->fd;
   
   return GL_TRUE;
 }
@@ -171,6 +219,11 @@
 
   driContextPriv->driverPrivate = (void *) c;
   
+  /* TODO, to make VB->Win.data[][2] ranges 0 - 1.0 */
+  /* Fixme, software render, z span seems all 0 */
+  mesaVis->DepthMax = 1;
+  mesaVis->DepthMaxF = 1.0f;
+
   return GL_TRUE;
 }
 
@@ -226,21 +279,11 @@
     return NULL;
 
   b->xm_context = NULL;
-
   b->xm_visual = xmesa->xm_visual;
   b->display = dpy;
-
-  if (mesaVis->DBflag)
-    {
-      b->db_state = BACK_XIMAGE;
-    }
-  else
-    {
-      b->db_state = 0;
-    }
-
+  b->pixmap_flag = GL_FALSE;
+  b->db_state = mesaVis->DBflag;
   b->gl_buffer = driDrawPriv->mesaBuffer;
-
   b->frontbuffer = driDrawPriv->draw;
 
   /* set 0 for buffer update */
@@ -293,7 +336,7 @@
 static void SISDestroyBuffer (XMesaBuffer b)
 {  
   if (SIS_VERBOSE&VERBOSE_SIS_BUFFER){
-    fprintf(stderr, "XMesaDestroyBuffer: b=%lu\n", (DWORD)b);
+    fprintf(stderr, "SISDestroyBuffer: b=%lu\n", (DWORD)b);
   }
   
   if (b->backimage && b->backimage->data)
@@ -315,7 +358,7 @@
 #endif
     }
 
-  if (b->gl_buffer->DepthBuffer)
+  if (b->depthbuffer)
     {
       sis_free_z_stencil_buffer (b);
     }
@@ -355,6 +398,18 @@
 {
   /* TODO */
   return GL_TRUE;
+}
+
+GLboolean
+XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
+}
+
+GLboolean
+XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    return GL_TRUE;
 }
 
 GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv,
Index: xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h
diff -u xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h:1.1 xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h:1.5
--- xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h:1.1	Fri Jun 30 15:30:30 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h	Tue Sep 26 11:56:49 2000
@@ -1,4 +1,3 @@
-
 /*
  * Mesa 3-D graphics library
  * Version:  3.3
@@ -22,7 +21,7 @@
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_xmesaP.h,v 1.5 2000/09/26 15:56:49 tsi Exp $ */
 
 #ifndef XMESAP_H
 #define XMESAP_H
@@ -35,9 +34,6 @@
 # ifdef GLX_DIRECT_RENDERING
 #  include "dri_mesa.h"
 # endif
-# ifdef USE_XSHM
-#  include <X11/extensions/XShm.h>
-# endif
 #endif
 
 #ifdef XFree86Server
@@ -53,11 +49,6 @@
 #endif
 
 #include "types.h"
-#if defined(FX) && !defined(GLX_DIRECT_RENDERING)
-#include "GL/fxmesa.h"
-#include "../FX/fxdrv.h"
-#endif
-
 
 #if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
 #  include "xdriP.h"
@@ -67,76 +58,12 @@
 #  define DRI_CTX_ARG
 #endif
 
-
-/* for PF_8R8G8B24 pixel format */
-typedef struct {
-   GLubyte b;
-   GLubyte g;
-   GLubyte r;
-} bgr_t;
-
-
-/* Function pointer for clearing color buffers */
-typedef void (*clear_func)( GLcontext *ctx,
-                            GLboolean all, GLint x, GLint y,
-                            GLint width, GLint height );
-
-
-/*
- * "Derived" from gl_visual.  Basically corresponds to an XVisualInfo.
- */
 struct xmesa_visual {
    GLvisual *gl_visual;		/* Device independent visual parameters */
    XMesaDisplay *display;	/* The X11 display */
-#ifdef XFree86Server
-   GLint screen_depth;		/* The depth of the screen */
-#else
-   XVisualInfo *vishandle;	/* The pointer returned by glXChooseVisual */
-#endif
    XMesaVisualInfo visinfo;	/* X's visual info */
-   GLint BitsPerPixel;		/* True bits per pixel for XImages */
-
-   GLint level;			/* 0=normal, 1=overlay, etc */
-   GLint VisualCaveat;          /* for GLX_EXT_visual_rating extension */
-
-   GLboolean ximage_flag;	/* Use XImage for back buffer (not pixmap)? */
-
-   GLuint dithered_pf;		/* Pixel format when dithering */
-   GLuint undithered_pf;	/* Pixel format when not dithering */
-
-   GLfloat RedGamma;		/* Gamma values, 1.0 is default */
-   GLfloat GreenGamma;
-   GLfloat BlueGamma;
-
-   GLint rmult, gmult, bmult;	/* Range of color values */
-   GLint index_bits;		/* Bits per pixel in CI mode */
-
-   /* For PF_TRUECOLOR */
-   GLint rshift, gshift, bshift;/* Pixel color component shifts */
-   GLubyte Kernel[16];		/* Dither kernel */
-   unsigned long RtoPixel[512];	/* RGB to pixel conversion */
-   unsigned long GtoPixel[512];
-   unsigned long BtoPixel[512];
-   GLubyte PixelToR[256];	/* Pixel to RGB conversion */
-   GLubyte PixelToG[256];
-   GLubyte PixelToB[256];
-
-   /* For PF_HPCR */
-   short       hpcr_rgbTbl[3][256];
-   GLboolean   hpcr_clear_flag;
-   GLubyte     hpcr_clear_ximage_pattern[2][16];
-   XMesaImage *hpcr_clear_ximage;
-   XMesaPixmap hpcr_clear_pixmap;
-
-   /* For PF_1BIT */
-   int bitFlip;
 };
 
-
-
-/*
- * "Derived" from gl_context.  Basically corresponds to a GLXContext.
- */
 struct xmesa_context {
    GLcontext *gl_ctx;		/* the core library context */
    XMesaVisual xm_visual;	/* Describes the buffers */
@@ -145,30 +72,15 @@
    GLboolean use_read_buffer;	/* read from the xm_read_buffer/ */
 
    XMesaDisplay *display;	/* == xm_visual->display */
-   GLboolean swapbytes;		/* Host byte order != display byte order? */
-   GLboolean direct;		/* Direct rendering context? */
 
-   GLuint pixelformat;		/* Current pixel format */
-
-   GLubyte red, green, blue, alpha;	/* current drawing color */
-   unsigned long pixel;			/* current drawing pixel value */
-
-   GLubyte clearcolor[4];		/* current clearing color */
-   unsigned long clearpixel;		/* current clearing pixel value */
-
 #if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
   __DRIcontextPrivate *driContextPriv; /* back pointer to DRI context
 					* used for locking
 					*/
-  void *private;			/* device-specific private context */
 #endif
+  void *private;			/* device-specific private context */
 };
 
-
-
-/*
- * "Derived" from gl_buffer.  Basically corresponds to a GLXDrawable.
- */
 struct xmesa_buffer {
    GLboolean wasCurrent;	/* was ever the current buffer? */
    GLframebuffer *gl_buffer;	/* depth, stencil, accum, etc buffers */
@@ -178,380 +90,25 @@
    XMesaDisplay *display;
    GLboolean pixmap_flag;	/* is the buffer a Pixmap? */
    XMesaDrawable frontbuffer;	/* either a window or pixmap */
-   XMesaPixmap backpixmap;	/* back buffer Pixmap */
    XMesaImage *backimage;	/* back buffer simulated XImage */
 
-   XMesaDrawable buffer;	/* the current buffer, either equal to */
-				/* frontbuffer, backpixmap or XIMAGE (None) */
-
-   XMesaColormap cmap;		/* the X colormap */
-
-   GLint db_state;		/* 0 = single buffered */
-				/* BACK_PIXMAP = use Pixmap for back buffer */
-				/* BACK_XIMAGE = use XImage for back buffer */
-
-#ifndef XFree86Server
-   GLuint shm;			/* X Shared Memory extension status:	*/
-				/*    0 = not available			*/
-				/*    1 = XImage support available	*/
-				/*    2 = Pixmap support available too	*/
-#ifdef USE_XSHM
-   XShmSegmentInfo shminfo;
-#endif
-#endif
+   GLvoid *depthbuffer;
+   
+   GLboolean db_state;		/* GL_FALSE = single buffered */
 
-   XMesaImage *rowimage;	/* Used for optimized span writing */
-
    GLuint width, height;	/* size of buffer */
 
    GLint bottom;		/* used for FLIP macro below */
-   GLubyte *ximage_origin1;	/* used for PIXELADDR1 macro */
-   GLint ximage_width1;
-   GLushort *ximage_origin2;	/* used for PIXELADDR2 macro */
-   GLint ximage_width2;
-   GLubyte *ximage_origin3;	/* used for PIXELADDR3 macro */
-   GLint ximage_width3;
-   GLuint *ximage_origin4;	/* used for PIXELADDR4 macro */
-   GLint ximage_width4;
-
-   XMesaPixmap stipple_pixmap;	/* For polygon stippling */
-   XMesaGC stipple_gc;		/* For polygon stippling */
-
-   XMesaGC gc1;			/* GC for infrequent color changes */
-   XMesaGC gc2;			/* GC for frequent color changes */
-   XMesaGC cleargc;		/* GC for clearing the color buffer */
-
-   /* The following are here instead of in the XMesaVisual
-    * because they depend on the window's colormap.
-    */
-
-   /* For PF_DITHER, PF_LOOKUP, PF_GRAYSCALE */
-   unsigned long color_table[576];	/* RGB -> pixel value */
-
-   /* For PF_DITHER, PF_LOOKUP, PF_GRAYSCALE */
-   GLubyte pixel_to_r[65536];		/* pixel value -> red */
-   GLubyte pixel_to_g[65536];		/* pixel value -> green */
-   GLubyte pixel_to_b[65536];		/* pixel value -> blue */
-
-   /* Used to do XAllocColor/XFreeColors accounting: */
-   int num_alloced;
-   unsigned long alloced_colors[256];
 
 #if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
   __DRIdrawablePrivate *driDrawPriv;	/* back pointer to DRI drawable
 					 * used for direct access to framebuffer
 					 */
-  void *private;			/* device-specific private drawable */
-#endif
-
-#if defined( FX ) && !defined(GLX_DIRECT_RENDERING)
-   /* For 3Dfx Glide only */
-   GLboolean FXisHackUsable;	/* Can we render into window? */
-   GLboolean FXwindowHack;	/* Are we rendering into a window? */
-   fxMesaContext FXctx;
-#endif
-
-   /* functions for clearing the front and back color buffers */
-   clear_func front_clear_func;
-   clear_func back_clear_func;
-
-   struct xmesa_buffer *Next;	/* Linked list pointer: */
-};
-
-
-
-/* Values for xmesa->dest: */
-#define FRONT_PIXMAP	1
-#define BACK_PIXMAP	2
-#define BACK_XIMAGE	4
-
-
-/* Values for xmesa->pixelformat: */
-#define PF_INDEX          1	/* Color Index mode */
-#define PF_TRUECOLOR      2	/* TrueColor or DirectColor, any depth */
-#define PF_TRUEDITHER     3	/* TrueColor with dithering */
-#define PF_8A8B8G8R       4	/* 32-bit TrueColor:  8-A, 8-B, 8-G, 8-R */
-#define PF_8R8G8B         5	/* 32-bit TrueColor:  8-R, 8-G, 8-B bits */
-#define PF_5R6G5B         6	/* 16-bit TrueColor:  5-R, 6-G, 5-B bits */
-#define PF_DITHER         7	/* Color-mapped RGB with dither */
-#define PF_LOOKUP         8	/* Color-mapped RGB without dither */
-#define PF_HPCR           9	/* HP Color Recovery (ad@lms.be 30/08/95) */
-#define PF_1BIT          10	/* monochrome dithering of RGB */
-#define PF_GRAYSCALE     11	/* Grayscale or StaticGray */
-#define PF_8R8G8B24      12	/* 24-bit TrueColor: 8-R, 8-G, 8-B bits */
-#define PF_DITHER_5R6G5B 13	/* 16-bit dithered TrueColor: 5-R, 6-G, 5-B */
-
-
-/*
- * If pixelformat==PF_TRUECOLOR:
- */
-#define PACK_TRUECOLOR( PIXEL, R, G, B )	\
-   PIXEL = xmesa->xm_visual->RtoPixel[R]	\
-         | xmesa->xm_visual->GtoPixel[G]	\
-         | xmesa->xm_visual->BtoPixel[B];	\
-
-
-/*
- * If pixelformat==PF_TRUEDITHER:
- */
-#define PACK_TRUEDITHER( PIXEL, X, Y, R, G, B )			\
-{								\
-   int d = xmesa->xm_visual->Kernel[((X)&3) | (((Y)&3)<<2)];	\
-   PIXEL = xmesa->xm_visual->RtoPixel[(R)+d]			\
-         | xmesa->xm_visual->GtoPixel[(G)+d]			\
-         | xmesa->xm_visual->BtoPixel[(B)+d];			\
-}
-
-
-
-/*
- * If pixelformat==PF_8A8B8G8R:
- */
-#define PACK_8A8B8G8R( R, G, B, A )	\
-	( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
-
-
-/*
- * Like PACK_8A8B8G8R() but don't use alpha.  This is usually an acceptable
- * shortcut.
- */
-#define PACK_8B8G8R( R, G, B )   ( ((B) << 16) | ((G) << 8) | (R) )
-
-
-
-/*
- * If pixelformat==PF_8R8G8B:
- */
-#define PACK_8R8G8B( R, G, B)	 ( ((R) << 16) | ((G) << 8) | (B) )
-
-
-/*
- * If pixelformat==PF_5R6G5B:
- */
-#define PACK_5R6G5B( R, G, B)	 ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
-
-
-
-
-/*
- * If pixelformat==PF_DITHER:
- *
- * Improved 8-bit RGB dithering code contributed by Bob Mercier
- * (mercier@hollywood.cinenet.net).  Thanks Bob!
- */
-#undef _R
-#undef _G
-#undef _B
-#undef _D
-#ifdef DITHER666
-# define _R   6
-# define _G   6
-# define _B   6
-# define _MIX(r,g,b)  (((r)*_G+(g))*_B+(b))
-#else
-# define _R	5
-# define _G	9
-# define _B	5
-# define _MIX(r,g,b)	( ((g)<<6) | ((b)<<3) | (r) )
 #endif
-#define _DX	4
-#define _DY	4
-#define _D	(_DX*_DY)
-
-/*#define _DITH(C,c,d)	(((unsigned)((_D*(C-1)+1)*c+d))/(_D*256))*/
-#define _DITH(C,c,d)	(((unsigned)((_D*(C-1)+1)*c+d)) >> 12)
-
-#define MAXC	256
-static int kernel8[_DY*_DX] = {
-    0 * MAXC,  8 * MAXC,  2 * MAXC, 10 * MAXC,
-   12 * MAXC,  4 * MAXC, 14 * MAXC,  6 * MAXC,
-    3 * MAXC, 11 * MAXC,  1 * MAXC,  9 * MAXC,
-   15 * MAXC,  7 * MAXC, 13 * MAXC,  5 * MAXC,
-};
-/*static int __d;*/
-
-/* Dither for random X,Y */
-#define DITHER_SETUP						\
-	int __d;						\
-	unsigned long *ctable = xmesa->xm_buffer->color_table;
-
-#define DITHER( X, Y, R, G, B )				\
-	(__d = kernel8[(((Y)&3)<<2) | ((X)&3)],		\
-	 ctable[_MIX(_DITH(_R, (R), __d),		\
-		     _DITH(_G, (G), __d),		\
-		     _DITH(_B, (B), __d))])
-
-/* Dither for random X, fixed Y */
-#define XDITHER_SETUP(Y)					\
-	int __d;						\
-	unsigned long *ctable = xmesa->xm_buffer->color_table;	\
-	int *kernel = &kernel8[ ((Y)&3) << 2 ];
-
-#define XDITHER( X, R, G, B )				\
-	(__d = kernel[(X)&3],				\
-	ctable[_MIX(_DITH(_R, (R), __d),		\
-		    _DITH(_G, (G), __d),		\
-		    _DITH(_B, (B), __d))])
-
-
-
-/*
- * Dithering for flat-shaded triangles.  Precompute all 16 possible
- * pixel values given the triangle's RGB color.  Contributed by Martin Shenk.
- */
-static GLushort DitherValues[16];   /* array of (up to) 16-bit pixel values */
-
-#define FLAT_DITHER_SETUP( R, G, B )					\
-	{								\
-	   unsigned long *ctable = xmesa->xm_buffer->color_table;	\
-	   int msdr = (_D*((_R)-1)+1) * (R);				\
-	   int msdg = (_D*((_G)-1)+1) * (G);				\
-	   int msdb = (_D*((_B)-1)+1) * (B);				\
-	   int i;							\
-	   for (i=0;i<16;i++) {						\
-	      int k = kernel8[i];					\
-	      int j = _MIX( (msdr+k)>>12, (msdg+k)>>12, (msdb+k)>>12 );	\
-	      DitherValues[i] = (GLushort) ctable[j];			\
-	   }								\
-        }
-
-#define FLAT_DITHER_ROW_SETUP(Y)					\
-	GLushort *ditherRow = DitherValues + ( ((Y)&3) << 2);
 
-#define FLAT_DITHER(X)  ditherRow[(X)&3]
-
-
-
-/*
- * If pixelformat==PF_LOOKUP:
- */
-#define _DITH0(C,c)	(((unsigned)((_D*(C-1)+1)*c)) >> 12)
-
-#define LOOKUP_SETUP						\
-	unsigned long *ctable = xmesa->xm_buffer->color_table
-
-#define LOOKUP( R, G, B )			\
-	ctable[_MIX(_DITH0(_R, (R)),		\
-		    _DITH0(_G, (G)),		\
-		    _DITH0(_B, (B)))]
-
-
+  void *private;			/* device-specific private drawable */
 
-/*
- * If pixelformat==PF_HPCR:
- *
- *      HP Color Recovery dithering               (ad@lms.be 30/08/95)
- *      HP has on it's 8-bit 700-series computers, a feature called
- *      'Color Recovery'.  This allows near 24-bit output (so they say).
- *      It is enabled by selecting the 8-bit  TrueColor  visual AND
- *      corresponding  colormap (see tkInitWindow) AND doing some special
- *      dither.
- */
-static const short HPCR_DRGB[3][2][16] = {
-{
-    { 16, -4,  1,-11, 14, -6,  3, -9, 15, -5,  2,-10, 13, -7,  4, -8},
-    {-15,  5,  0, 12,-13,  7, -2, 10,-14,  6, -1, 11,-12,  8, -3,  9} 
-},
-{
-    {-11, 15, -7,  3, -8, 14, -4,  2,-10, 16, -6,  4, -9, 13, -5,  1},
-    { 12,-14,  8, -2,  9,-13,  5, -1, 11,-15,  7, -3, 10,-12,  6,  0} 
-},
-{
-    {  6,-18, 26,-14,  2,-22, 30,-10,  8,-16, 28,-12,  4,-20, 32, -8},
-    { -4, 20,-24, 16,  0, 24,-28, 12, -6, 18,-26, 14, -2, 22,-30, 10} 
-}
+  struct xmesa_buffer *Next;	/* Linked list pointer: */
 };
-
-#define DITHER_HPCR( X, Y, R, G, B )					   \
-  ( ((xmesa->xm_visual->hpcr_rgbTbl[0][R] + HPCR_DRGB[0][(Y)&1][(X)&15]) & 0xE0)     \
-  |(((xmesa->xm_visual->hpcr_rgbTbl[1][G] + HPCR_DRGB[1][(Y)&1][(X)&15]) & 0xE0)>>3) \
-  | ((xmesa->xm_visual->hpcr_rgbTbl[2][B] + HPCR_DRGB[2][(Y)&1][(X)&15])>>6)	   \
-  )
-
-
-
-/*
- * If pixelformat==PF_1BIT:
- */
-static int const kernel1[16] = {
-   0*47,  9*47,  4*47, 12*47,     /* 47 = (255*3)/16 */
-   6*47,  2*47, 14*47,  8*47,
-  10*47,  1*47,  5*47, 11*47,
-   7*47, 13*47,  3*47, 15*47 };
-
-#define SETUP_1BIT  int bitFlip = xmesa->xm_visual->bitFlip
-#define DITHER_1BIT( X, Y, R, G, B )	\
-	(( ((int)(R)+(int)(G)+(int)(B)) > kernel1[(((Y)&3) << 2) | ((X)&3)] ) ^ bitFlip)
-
-
-
-/*
- * If pixelformat==PF_GRAYSCALE:
- */
-#define GRAY_RGB( R, G, B )   xmesa->xm_buffer->color_table[((R) + (G) + (B))/3]
-
-
-
-#define XIMAGE None
-
-
-/*
- * Converts a GL window Y coord to an X window Y coord:
- */
-#define FLIP(BUFFER, Y)  ((BUFFER)->bottom-(Y))
-
-
-/*
- * Return the address of a 1, 2 or 4-byte pixel in the back XImage:
- * X==0 is left, Y==0 is bottom.
- */
-#define PIXELADDR1( BUFFER, X, Y )  \
-   ( (BUFFER)->ximage_origin1 - (Y) * (BUFFER)->ximage_width1 + (X) )
-
-#define PIXELADDR2( BUFFER, X, Y )  \
-   ( (BUFFER)->ximage_origin2 - (Y) * (BUFFER)->ximage_width2 + (X) )
-
-#define PIXELADDR3( BUFFER, X, Y )  \
-   ( (bgr_t *) ( (BUFFER)->ximage_origin3 - (Y) * (BUFFER)->ximage_width3 + 3 * (X) ))
-
-#define PIXELADDR4( BUFFER, X, Y )  \
-   ( (BUFFER)->ximage_origin4 - (Y) * (BUFFER)->ximage_width4 + (X) )
-
-
-
-/*
- * External functions:
- */
-
-extern unsigned long
-xmesa_color_to_pixel( XMesaContext xmesa, GLubyte r, GLubyte g, GLubyte b, GLubyte a,
-                      GLuint pixelFormat );
-
-extern void xmesa_alloc_back_buffer( XMesaBuffer b );
-
-extern void xmesa_update_state( GLcontext *ctx );
-
-extern points_func xmesa_get_points_func( GLcontext *ctx );
-
-extern line_func xmesa_get_line_func( GLcontext *ctx );
-
-extern triangle_func xmesa_get_triangle_func( GLcontext *ctx );
-
-
-/* XXX this is a hack to implement shared display lists with 3Dfx */
-extern XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v,
-					     XMesaWindow w,
-					     XMesaContext c
-					     DRI_DRAWABLE_ARG
-					   );
-
-/*
- * These are the extra routines required for integration with XFree86.
- * None of these routines should be user visible. -KEM
- */
-extern void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v );
-extern GLboolean XMesaForceCurrent(XMesaContext c);
-extern GLboolean XMesaLoseCurrent(XMesaContext c);
-extern void XMesaReset( void );
 
 #endif
Index: xc/lib/GL/mesa/src/drv/sis/sis_xwin.c
diff -u xc/lib/GL/mesa/src/drv/sis/sis_xwin.c:1.1 xc/lib/GL/mesa/src/drv/sis/sis_xwin.c:1.3
--- xc/lib/GL/mesa/src/drv/sis/sis_xwin.c:1.1	Fri Jun 30 15:30:31 2000
+++ xc/lib/GL/mesa/src/drv/sis/sis_xwin.c	Tue Sep 26 11:56:49 2000
@@ -1,3 +1,37 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_xwin.c,v 1.3 2000/09/26 15:56:49 tsi Exp $ */
+
+/*
+ * Authors:
+ *    Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
 #include "sis_ctx.h"
 #include "sis_mesa.h"
 
Index: xc/lib/GL/mesa/src/drv/tdfx/Imakefile
diff -u xc/lib/GL/mesa/src/drv/tdfx/Imakefile:1.8 xc/lib/GL/mesa/src/drv/tdfx/Imakefile:1.19
--- xc/lib/GL/mesa/src/drv/tdfx/Imakefile:1.8	Sun Jun 25 10:44:27 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/Imakefile	Tue Dec 12 18:24:28 2000
@@ -1,3 +1,4 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/tdfx/Imakefile,v 1.19 2000/12/12 23:24:28 dawes Exp $
 
 #include <Threads.tmpl>
 
@@ -11,45 +12,32 @@
 ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
 #endif
 
+#ifdef i386Architecture
+#if MesaUseMMX
+     MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+   3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseKatmai
+  KATMAI_DEFS = -DUSE_KATMAI_ASM
+#endif
+  ASM_DEFINES = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(KATMAI_DEFS)
+#endif
+
 #if BuildXF86DRI
-  DRI_DEFINES = GlxDefines -DFX -DFX_GLIDE3 -DGLIDE3 -DDRIVERTS
+  DRI_DEFINES = GlxDefines -DFX_GLIDE3 -DDRIVERTS
  DRI_INCLUDES = -I../../../../dri -I../../../../glx \
 		-I../../../dri \
 		-I$(TOP)/include -I$(TOP)/include/GL \
 		-I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \
 		-I$(XF86DRIVERSRC)/tdfx \
-		-I../../../include -I../.. -I../../X
+		-I../../../include -I../.. -I../../X -I../common
 #endif
 
 MESA_INCLUDES = -I. -I.. -I../../include
-
-LinkSourceFile(fxclip.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxcliptmp.h, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxcva.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxcva.h, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxcvatmp.h, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxdd.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxddspan.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxddtex.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxdrv.h, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxfastpath.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxfasttmp.h, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxglidew.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxglidew.h, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxpipeline.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxrender.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxsanity.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxsdettmp.h, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxsetup.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxstripdet.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxtexman.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxtrifuncs.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxtritmp.h, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxvsetup.c, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxvsetup.h, ../../../../../../extras/Mesa/src/FX)
-LinkSourceFile(fxvs_tmp.h, ../../../../../../extras/Mesa/src/FX)
 
-      DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
+      DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFINES)
      INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) \
 		-I$(GLIDE3INCDIR)
 
@@ -69,15 +57,41 @@
 		../../../../dri/drm/xf86drmRandom.o \
 		../../../../dri/drm/xf86drmSL.o
 
-     TDFXSRCS = tdfx_xmesa.c tdfx_init.c tdfx_inithw.c \
-		fxclip.c fxcva.c fxdd.c fxddspan.c fxddtex.c fxfastpath.c \
-		fxglidew.c fxpipeline.c fxrender.c fxsanity.c fxsetup.c \
-		fxtexman.c fxtrifuncs.c fxvsetup.c
-
-     TDFXOBJS = tdfx_xmesa.o tdfx_init.o tdfx_inithw.o \
-		fxclip.o fxcva.o fxdd.o fxddspan.o fxddtex.o fxfastpath.o \
-		fxglidew.o fxpipeline.o fxrender.o fxsanity.o fxsetup.o \
-		fxtexman.o fxtrifuncs.o fxvsetup.o
+     TDFXSRCS = tdfx_xmesa.c \
+		tdfx_init.c \
+		tdfx_inithw.c \
+		fxclip.c \
+		fxcva.c \
+		fxdd.c \
+		fxddspan.c \
+		fxddtex.c \
+		fxfastpath.c \
+		fxglidew.c \
+		fxpipeline.c \
+		fxrender.c \
+		fxsanity.c \
+		fxsetup.c \
+		fxtexman.c \
+		fxtrifuncs.c \
+		fxvsetup.c
+
+     TDFXOBJS = tdfx_xmesa.o \
+		tdfx_init.o \
+		tdfx_inithw.o \
+		fxclip.o \
+		fxcva.o \
+		fxdd.o \
+		fxddspan.o \
+		fxddtex.o \
+		fxfastpath.o \
+		fxglidew.o \
+		fxpipeline.o \
+		fxrender.o \
+		fxsanity.o \
+		fxsetup.o \
+		fxtexman.o \
+		fxtrifuncs.o \
+		fxvsetup.o
 
      MESASRCS = ../../aatriangle.c \
 		../../accum.c \
@@ -228,25 +242,40 @@
 		../../zoom.o
 
 #ifdef i386Architecture
-     X86_SRCS = ../../X86/x86.c \
-		../../X86/x86a.S \
-		../../X86/common_x86.c \
-		../../X86/common_x86asm.S \
-		../../X86/vertex.S
-
-     X86_OBJS = ../../X86/x86.o \
-		../../X86/x86a.o \
-		../../X86/common_x86.o \
-		../../X86/common_x86asm.o \
-		../../X86/vertex.o
+     X86_SRCS = ../../X86/common_x86.c \
+		../../X86/common_x86_asm.S \
+		../../X86/x86.c \
+		../../X86/x86_cliptest.S \
+		../../X86/x86_vertex.S \
+		../../X86/x86_xform_masked2.S \
+		../../X86/x86_xform_masked3.S \
+		../../X86/x86_xform_masked4.S \
+		../../X86/x86_xform_raw2.S \
+		../../X86/x86_xform_raw3.S \
+		../../X86/x86_xform_raw4.S
+
+     X86_OBJS = ../../X86/common_x86.o \
+		../../X86/common_x86_asm.o \
+		../../X86/x86.o \
+		../../X86/x86_cliptest.o \
+		../../X86/x86_vertex.o \
+		../../X86/x86_xform_masked2.o \
+		../../X86/x86_xform_masked3.o \
+		../../X86/x86_xform_masked4.o \
+		../../X86/x86_xform_raw2.o \
+		../../X86/x86_xform_raw3.o \
+		../../X86/x86_xform_raw4.o
 
+#if MesaUseMMX
      MMX_SRCS = ../../X86/mmx_blend.S
 
      MMX_OBJS = ../../X86/mmx_blend.o
+#endif
 
 #if MesaUse3DNow
    3DNOW_SRCS = ../../X86/3dnow.c \
 		../../X86/3dnow_norm_raw.S \
+		../../X86/3dnow_vertex.S \
 		../../X86/3dnow_xform_masked1.S \
 		../../X86/3dnow_xform_masked2.S \
 		../../X86/3dnow_xform_masked3.S \
@@ -254,11 +283,11 @@
 		../../X86/3dnow_xform_raw1.S \
 		../../X86/3dnow_xform_raw2.S \
 		../../X86/3dnow_xform_raw3.S \
-		../../X86/3dnow_xform_raw4.S \
-		../../X86/vertex_3dnow.S
+		../../X86/3dnow_xform_raw4.S
 
    3DNOW_OBJS = ../../X86/3dnow.o \
 		../../X86/3dnow_norm_raw.o \
+		../../X86/3dnow_vertex.o \
 		../../X86/3dnow_xform_masked1.o \
 		../../X86/3dnow_xform_masked2.o \
 		../../X86/3dnow_xform_masked3.o \
@@ -266,19 +295,53 @@
 		../../X86/3dnow_xform_raw1.o \
 		../../X86/3dnow_xform_raw2.o \
 		../../X86/3dnow_xform_raw3.o \
-		../../X86/3dnow_xform_raw4.o \
-		../../X86/vertex_3dnow.o
+		../../X86/3dnow_xform_raw4.o
 #endif
 
+#if MesaUseKatmai
+  KATMAI_SRCS = ../../X86/katmai.c \
+		../../X86/katmai_norm_raw.S \
+		../../X86/katmai_vertex.S \
+		../../X86/katmai_xform_masked1.S \
+		../../X86/katmai_xform_masked2.S \
+		../../X86/katmai_xform_masked3.S \
+		../../X86/katmai_xform_masked4.S \
+		../../X86/katmai_xform_raw1.S \
+		../../X86/katmai_xform_raw2.S \
+		../../X86/katmai_xform_raw3.S \
+		../../X86/katmai_xform_raw4.S
+
+  KATMAI_OBJS = ../../X86/katmai.o \
+		../../X86/katmai_norm_raw.o \
+		../../X86/katmai_vertex.o \
+		../../X86/katmai_xform_masked1.o \
+		../../X86/katmai_xform_masked2.o \
+		../../X86/katmai_xform_masked3.o \
+		../../X86/katmai_xform_masked4.o \
+		../../X86/katmai_xform_raw1.o \
+		../../X86/katmai_xform_raw2.o \
+		../../X86/katmai_xform_raw3.o \
+		../../X86/katmai_xform_raw4.o
+#endif
 #endif
 
-      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS)
-      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS)
+#ifdef GlxSoProf
+       LOSRCS = ../../../../lowpc.c
+       HISRCS = ../../../../highpc.c
+
+       LOOBJS = ../../../../lowpc.o
+       HIOBJS = ../../../../highpc.o
+#endif
 
-         SRCS = $(DRISRCS) $(DRMSRCS) $(TDFXSRCS) $(MESASRCS) $(ASMSRCS)
-         OBJS = $(DRIOBJS) $(DRMOBJS) $(TDFXOBJS) $(MESAOBJS) $(ASMOBJS)
+      ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS)
+      ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS)
 
-REQUIREDLIBS = -lglide3x -lm
+         SRCS = $(LOSRCS) $(DRISRCS) $(DRMSRCS) $(MESASRCS) \
+		$(ASMSRCS) $(TDFXSRCS) $(HISRCS)
+         OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) \
+		$(ASMOBJS) $(TDFXOBJS) $(HIOBJS)
+
+REQUIREDLIBS = -l$(GLIDE3LIBNAME) MathLibrary
 #if !GlxBuiltInTdfx
 REQUIREDLIBS += -L../../../.. -lGL
 #endif
@@ -304,6 +367,12 @@
 ALL_DEPS = DONE
 SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
 InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _tdfx_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),$(ALL_DEPS),$(ALL_OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
 #endif
 
 DependTarget()
Index: xc/lib/GL/mesa/src/drv/tdfx/fxclip.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxclip.c:1.2
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxclip.c	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,488 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxclip.c,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#include "fxdrv.h"
+#include "fxtexman.h"
+#include "mmath.h"
+#include "macros.h"
+#include "vector.h"
+#include "types.h"
+
+
+#if 0 && defined(__i386__)
+#define NEGATIVE(f)          ((*(int *)&f) < 0)
+#define DIFFERENT_SIGNS(a,b) (((*(int *)&a)^(*(int *)&b)) < 0)
+#else
+#define NEGATIVE(f)          (f < 0)
+#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
+#endif
+
+#define LINTERP( T, A, B )   ( (A) + (T) * ( (B) - (A) ) )
+
+
+#define CLIP(sgn,v)						\
+do {								\
+   GLuint out = in ^ 1;						\
+   GLfloat **indata = inlist[in];				\
+   GrVertex **inverts = vertlist[in];				\
+   GrVertex **outverts = vertlist[out];				\
+   GLfloat **outdata = inlist[in = out];			\
+   GLfloat *J = indata[n-1];					\
+   GLfloat dpJ = (sgn J[v]) + J[3];				\
+   GLuint nr = n;						\
+								\
+   for (i = n = 0 ; i < nr ; i++) {				\
+      GLfloat *I = indata[i];					\
+      GLfloat dpI = (sgn I[v]) + I[3];				\
+								\
+      if (DIFFERENT_SIGNS(dpI, dpJ)) {				\
+	 GLuint j;						\
+         GLfloat t = dpI / (dpI - dpJ);                         \
+	 outverts[n] = 0;					\
+	 outdata[n++] = store;					\
+	 store[3] = LINTERP(t, I[3], J[3]);			\
+	 store[v] = - sgn store[3];				\
+	 if (v != 0) store[0] = LINTERP(t, I[0], J[0]);		\
+	 if (v != 1) store[1] = LINTERP(t, I[1], J[1]);		\
+	 if (v != 2) store[2] = LINTERP(t, I[2], J[2]);		\
+	 store += 4;						\
+	 for (j = 4 ; j < sz ; j+=4,store+=4) {			\
+	    store[0] = LINTERP(t, I[j],   J[j] );		\
+	    store[1] = LINTERP(t, I[j+1], J[j+1] );		\
+	    store[2] = LINTERP(t, I[j+2], J[j+2] );		\
+	    store[3] = LINTERP(t, I[j+3], J[j+3] );		\
+	 }							\
+      }								\
+								\
+      if (!NEGATIVE(dpI)) {					\
+	 outverts[n] = inverts[i];				\
+	 outdata[n++] = I;					\
+      }								\
+								\
+								\
+      J = I;							\
+      dpJ = dpI;						\
+   }								\
+								\
+   if (n < 3) return 0;						\
+} while (0)
+
+
+/* Originally used this for the viewclip planes as well, as in
+ * CLIP(-1,0,0,1), which was just as fast, but tended to lead to
+ * cracks.  I haven't figured out exactly why this is, but the above
+ * code only really differs in the way it sets store[v] to +- w.
+ */
+#define UCLIP(a,b,c,d)					\
+do {							\
+   GLuint out = in ^ 1;					\
+   GLfloat **indata = inlist[in];			\
+   GrVertex **inverts = vertlist[in];			\
+   GrVertex **outverts = vertlist[out];			\
+   GLfloat **outdata = inlist[in = out];		\
+   GLfloat *J = indata[n-1];				\
+   GLfloat dpJ = DOT4V(J,a,b,c,d);			\
+   GLuint nr = n;					\
+							\
+   for (i = n = 0 ; i < nr ; i++) {			\
+      GLfloat *I = indata[i];				\
+      GLfloat dpI = DOT4V(I,a,b,c,d);			\
+							\
+      if (DIFFERENT_SIGNS(dpI, dpJ)) {			\
+	 GLuint j;					\
+	 GLfloat t = dpI / (dpI - dpJ);			\
+	 outverts[n] = 0;				\
+	 outdata[n++] = store;				\
+	 for (j = 0 ; j < sz ; j+=4,store+=4) {		\
+	    store[0] = LINTERP(t, I[j],   J[j] );	\
+	    store[1] = LINTERP(t, I[j+1], J[j+1] );	\
+	    store[2] = LINTERP(t, I[j+2], J[j+2] );	\
+	    store[3] = LINTERP(t, I[j+3], J[j+3] );	\
+	 }						\
+      }							\
+							\
+      if (!NEGATIVE(dpI)) {				\
+	 outverts[n] = inverts[i];			\
+	 outdata[n++] = I;				\
+      }							\
+							\
+							\
+      J = I;						\
+      dpJ = dpI;					\
+   }							\
+							\
+   if (n < 3) return 0;					\
+} while (0)
+
+
+
+/* Data parameter is organized as 4 clip coordinates followed by an
+ * arbitary number (sz-4) of additional data.  The three original
+ * vertices are packed together at the start, and there is room for at
+ * least VB_MAX_CLIPPED_VERTS vertices of the same size in this
+ * storage.
+ *
+ */
+static INLINE GLuint
+fx_clip_triangle(GLcontext * ctx,
+                 GLfloat * inoutlist[],
+                 GrVertex ** verts, GLuint sz, GLuint mask)
+{
+    GLuint n = 3;
+    GLfloat *store = inoutlist[n - 1] + sz;
+    GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
+    GrVertex *verts2[VB_MAX_CLIPPED_VERTS];
+    GLfloat **inlist[2];
+    GrVertex **vertlist[2];
+    GLuint in = 0;
+    GLuint i;
+
+    inlist[0] = inoutlist;
+    inlist[1] = vlist;
+
+    vertlist[0] = verts;
+    vertlist[1] = verts2;
+
+    if (mask & CLIP_ALL_BITS) {
+        if (mask & CLIP_RIGHT_BIT)
+            CLIP(-, 0);
+
+        if (mask & CLIP_LEFT_BIT)
+            CLIP(+, 0);
+
+        if (mask & CLIP_TOP_BIT)
+            CLIP(-, 1);
+
+        if (mask & CLIP_BOTTOM_BIT)
+            CLIP(+, 1);
+
+        if (mask & CLIP_FAR_BIT)
+            CLIP(-, 2);
+
+        if (mask & CLIP_NEAR_BIT)
+            CLIP(+, 2);
+    }
+
+    if (mask & CLIP_USER_BIT) {
+        GLuint bit;
+        GLfloat(*plane)[4] = &ctx->Transform.ClipUserPlane[0];
+        for (bit = 0x100; bit < mask; plane++, bit *= 2) {
+            if (mask & bit) {
+                GLfloat a = plane[0][0];
+                GLfloat b = plane[0][1];
+                GLfloat c = plane[0][2];
+                GLfloat d = plane[0][3];
+                UCLIP(a, b, c, d);
+            }
+        }
+    }
+
+    if (inlist[in] != inoutlist)
+        for (i = 0; i < n; i++) {
+            inoutlist[i] = inlist[in][i];
+            verts[i] = verts2[i];
+        }
+
+    return n;
+}
+
+
+
+static INLINE GLuint
+fx_view_clip_triangle(GLcontext * ctx,
+                      GLfloat * inoutlist[],
+                      GrVertex ** verts, GLuint sz, GLubyte mask)
+{
+    GLuint n = 3;
+    GLfloat *store = inoutlist[n - 1] + sz;
+    GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
+    GrVertex *verts2[VB_MAX_CLIPPED_VERTS];
+    GLfloat **inlist[2];
+    GrVertex **vertlist[2];
+    GLuint in = 0;
+    GLuint i;
+
+    inlist[0] = inoutlist;
+    inlist[1] = vlist;
+
+    vertlist[0] = verts;
+    vertlist[1] = verts2;
+
+    if (mask & CLIP_RIGHT_BIT)
+        CLIP(-, 0);
+
+    if (mask & CLIP_LEFT_BIT)
+        CLIP(+, 0);
+
+    if (mask & CLIP_TOP_BIT)
+        CLIP(-, 1);
+
+    if (mask & CLIP_BOTTOM_BIT)
+        CLIP(+, 1);
+
+    if (mask & CLIP_FAR_BIT)
+        CLIP(-, 2);
+
+    if (mask & CLIP_NEAR_BIT)
+        CLIP(+, 2);
+
+    if (inlist[in] != inoutlist)
+        for (i = 0; i < n; i++) {
+            inoutlist[i] = inlist[in][i];
+            verts[i] = verts2[i];
+        }
+
+    return n;
+}
+
+
+
+#undef CLIP
+
+#define CLIP(x,y,z,w)					\
+do {							\
+   GLfloat dpI = DOT4V(I,x,y,z,w);			\
+   GLfloat dpJ = DOT4V(J,x,y,z,w);			\
+							\
+   if (DIFFERENT_SIGNS(dpI, dpJ)) {			\
+      GLuint j;						\
+      GLfloat t = dpI / (dpI - dpJ); 			\
+      GLfloat *tmp = store;				\
+							\
+      for (j = 0 ; j < sz ; j+=2) {			\
+	 *store++ = LINTERP(t, I[j],   J[j] );		\
+	 *store++ = LINTERP(t, I[j+1], J[j+1] );	\
+      }							\
+							\
+      if (NEGATIVE(dpI)) 				\
+	 I = tmp;					\
+      else						\
+	 J = tmp;					\
+							\
+   } 							\
+   else if (NEGATIVE(dpI))				\
+      return 0;						\
+							\
+} while (0)
+
+
+static GLuint
+fx_clip_line(GLcontext * ctx,
+             GLfloat * inoutlist[], GLuint sz, GLubyte clipor)
+{
+    GLfloat *I = inoutlist[0];
+    GLfloat *J = inoutlist[1];
+    GLfloat *store = J + sz;
+
+    if (clipor & CLIP_ALL_BITS) {
+        if (clipor & CLIP_LEFT_BIT)
+            CLIP(1, 0, 0, 1);
+
+        if (clipor & CLIP_RIGHT_BIT)
+            CLIP(-1, 0, 0, 1);
+
+        if (clipor & CLIP_TOP_BIT)
+            CLIP(0, -1, 0, 1);
+
+        if (clipor & CLIP_BOTTOM_BIT)
+            CLIP(0, 1, 0, 1);
+
+        if (clipor & CLIP_FAR_BIT)
+            CLIP(0, 0, -1, 1);
+
+        if (clipor & CLIP_NEAR_BIT)
+            CLIP(0, 0, 1, 1);
+    }
+
+    if (clipor & CLIP_USER_BIT) {
+        GLuint i;
+        for (i = 0; i < MAX_CLIP_PLANES; i++) {
+            if (ctx->Transform.ClipEnabled[i]) {
+                GLfloat a = ctx->Transform.ClipUserPlane[i][0];
+                GLfloat b = ctx->Transform.ClipUserPlane[i][1];
+                GLfloat c = ctx->Transform.ClipUserPlane[i][2];
+                GLfloat d = ctx->Transform.ClipUserPlane[i][3];
+                CLIP(a, b, c, d);
+            }
+        }
+    }
+
+    inoutlist[0] = I;
+    inoutlist[1] = J;
+
+    return 2;
+}
+
+
+/* Add window offset to window coords to get screen coords */
+
+#define VARS_XYZW				\
+  GLfloat vsx = mat[MAT_SX];			\
+  GLfloat vsy = mat[MAT_SY];			\
+  GLfloat vsz = mat[MAT_SZ];			\
+  GLfloat vtx = mat[MAT_TX]+fxMesa->x_offset;	\
+  GLfloat vty = mat[MAT_TY]+fxMesa->y_delta;	\
+  GLfloat vtz = mat[MAT_TZ];
+
+#define DO_SETUP_XYZW				\
+{						\
+  GLfloat oow = 1.0 / data[3];			\
+  v->x   = data[0]*oow*vsx + vtx;		\
+  v->y   = data[1]*oow*vsy + vty;		\
+  v->ooz = data[2]*oow*vsz + vtz;		\
+  v->oow = oow;					\
+}
+
+
+
+#define COPY_XYZW_STRIDE				\
+  { GLfloat *clip = VEC_ELT(VB->ClipPtr, GLfloat, e);	\
+    COPY_4FV(out, clip); }
+
+#define VARS_RGBA
+
+#define COPY_RGBA_STRIDE					\
+  { GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, e);		\
+    UBYTE_RGBA_TO_FLOAT_255_RGBA((out+4), color); }
+
+#if FX_USE_PARGB
+#define DO_SETUP_RGBA				\
+  PACK_4F_ARGB(GET_PARGB(v), data[4+3], data[4+0], data[4+1], data[4+2]);
+#else
+#define DO_SETUP_RGBA				\
+  v->r = data[4+0];				\
+  v->g = data[4+1];				\
+  v->b = data[4+2];				\
+  v->a = data[4+3];
+#endif /* FX_USE_PARGB */
+
+#define VARS_TMU0							\
+  struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source];		\
+  GLfloat sScale0 = fxTMGetTexInfo(t0->Current)->sScale;	\
+  GLfloat tScale0 = fxTMGetTexInfo(t0->Current)->tScale;	\
+
+
+#define COPY_TMU0_STRIDE(offset)					\
+  { GLfloat *tc0 = VEC_ELT(tc0_vec, GLfloat, e);	\
+    COPY_2V((out+offset), tc0); }
+
+
+#define DO_SETUP_TMU0(offset)				\
+  v->tmuvtx[0].sow = data[offset+0]*sScale0*v->oow;	\
+  v->tmuvtx[0].tow = data[offset+1]*tScale0*v->oow;
+
+#define VARS_TMU1							\
+  struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source];		\
+  GLfloat sScale1 = fxTMGetTexInfo(t1->Current)->sScale;	\
+  GLfloat tScale1 = fxTMGetTexInfo(t1->Current)->tScale;
+
+#define COPY_TMU1_STRIDE(offset)					\
+  { GLfloat *tc1 = VEC_ELT(tc1_vec, GLfloat, e);	\
+    COPY_2V((out+offset), tc1); }
+
+
+#define DO_SETUP_TMU1(offset)				\
+  v->tmuvtx[1].sow = data[offset+0]*sScale1*v->oow;	\
+  v->tmuvtx[1].tow = data[offset+1]*tScale1*v->oow;
+
+#define COPY_NIL(offset) ASSIGN_2V((out+offset), 0, 0);
+
+#define IND 0
+#define TAG(x) x##_nil
+#include "fxcliptmp.h"
+
+#define IND SETUP_RGBA
+#define TAG(x) x##_RGBA
+#include "fxcliptmp.h"
+
+#define IND SETUP_TMU0
+#define TAG(x) x##_TMU0
+#include "fxcliptmp.h"
+
+#define IND (SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_TMU0_TMU1
+#include "fxcliptmp.h"
+
+#define IND (SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_RGBA_TMU0
+#include "fxcliptmp.h"
+
+#define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_RGBA_TMU0_TMU1
+#include "fxcliptmp.h"
+
+tfxTriViewClipFunc fxTriViewClipTab[0x8];
+tfxTriClipFunc fxTriClipStrideTab[0x8];
+tfxLineClipFunc fxLineClipTab[0x8];
+
+
+void
+fxDDClipInit()
+{
+    fxTriViewClipTab[0] = fx_tri_view_clip_nil;
+    fxTriViewClipTab[SETUP_RGBA] = fx_tri_view_clip_RGBA;
+    fxTriViewClipTab[SETUP_TMU0] = fx_tri_view_clip_TMU0;
+    fxTriViewClipTab[SETUP_TMU0 | SETUP_TMU1] = fx_tri_view_clip_TMU0_TMU1;
+    fxTriViewClipTab[SETUP_RGBA | SETUP_TMU0] = fx_tri_view_clip_RGBA_TMU0;
+    fxTriViewClipTab[SETUP_RGBA | SETUP_TMU0 | SETUP_TMU1] =
+        fx_tri_view_clip_RGBA_TMU0_TMU1;
+
+    fxTriClipStrideTab[0] = fx_tri_clip_stride_nil;
+    fxTriClipStrideTab[SETUP_RGBA] = fx_tri_clip_stride_RGBA;
+    fxTriClipStrideTab[SETUP_TMU0] = fx_tri_clip_stride_TMU0;
+    fxTriClipStrideTab[SETUP_TMU0 | SETUP_TMU1] =
+        fx_tri_clip_stride_TMU0_TMU1;
+    fxTriClipStrideTab[SETUP_RGBA | SETUP_TMU0] =
+        fx_tri_clip_stride_RGBA_TMU0;
+    fxTriClipStrideTab[SETUP_RGBA | SETUP_TMU0 | SETUP_TMU1] =
+        fx_tri_clip_stride_RGBA_TMU0_TMU1;
+
+    fxLineClipTab[0] = fx_line_clip_nil;
+    fxLineClipTab[SETUP_RGBA] = fx_line_clip_RGBA;
+    fxLineClipTab[SETUP_TMU0] = fx_line_clip_TMU0;
+    fxLineClipTab[SETUP_TMU0 | SETUP_TMU1] = fx_line_clip_TMU0_TMU1;
+    fxLineClipTab[SETUP_RGBA | SETUP_TMU0] = fx_line_clip_RGBA_TMU0;
+    fxLineClipTab[SETUP_RGBA | SETUP_TMU0 | SETUP_TMU1] =
+        fx_line_clip_RGBA_TMU0_TMU1;
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxcliptmp.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxcliptmp.h:1.1
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxcliptmp.h	Sun Sep 24 09:51:13 2000
@@ -0,0 +1,353 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxcliptmp.h,v 1.1 2000/09/24 13:51:13 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#define V1 VARS_XYZW
+#define S1 DO_SETUP_XYZW
+#define T1 COPY_XYZW_STRIDE
+#define Z1 4
+
+#if (IND & SETUP_RGBA)
+#define V2 V1 VARS_RGBA
+#define S2 S1 DO_SETUP_RGBA
+#define T2 T1 COPY_RGBA_STRIDE
+#define Z2 (Z1 + 4)
+#else
+#define V2 V1
+#define S2 S1
+#define T2 T1
+#define Z2 Z1
+#endif
+
+#if (IND & SETUP_TMU0)
+#define V3 V2 VARS_TMU0
+#define S3 S2 DO_SETUP_TMU0(Z2)
+#define T3 T2 COPY_TMU0_STRIDE(Z2)
+#define Z3 (Z2 + 2)
+#else
+#define V3 V2
+#define S3 S2
+#define T3 T2
+#define Z3 Z2
+#endif
+
+#if (IND & SETUP_TMU1)
+#define V4 V3 VARS_TMU1
+#define S4 S3 DO_SETUP_TMU1(Z3)
+#define T4 T3 COPY_TMU1_STRIDE(Z3)
+#define Z4 (Z3 + 2)
+#else
+#define V4 V3
+#define S4 S3
+#define T4 T3
+#define Z4 Z3
+#endif
+
+#if (Z4 & 2)
+#define SIZE (Z4+2)
+#define COPY_STRIDE T4 COPY_NIL(Z4)
+#else
+#define SIZE Z4
+#define COPY_STRIDE T4
+#endif
+
+#define VARS V4
+#define SETUP S4
+
+#define DRAW_LINE(fxMesa, tmp0, tmp1, width)		\
+  if (width <= 1.0) {					\
+    FX_grDrawLine(fxMesa, tmp0, tmp1);			\
+  }							\
+  else {						\
+    GrVertex verts[4];					\
+    float dx, dy, ix, iy;				\
+							\
+    dx = tmp0->x - tmp1->x;				\
+    dy = tmp0->y - tmp1->y;				\
+							\
+    if (dx * dx > dy * dy) {				\
+      iy = width * .5;					\
+      ix = 0;						\
+    }							\
+    else {						\
+      iy = 0;						\
+      ix = width * .5;					\
+    }							\
+							\
+    verts[0] = *tmp0;					\
+    verts[1] = *tmp0;					\
+    verts[2] = *tmp1;					\
+    verts[3] = *tmp1;					\
+							\
+    verts[0].x = tmp0->x - ix;				\
+    verts[0].y = tmp0->y - iy;				\
+							\
+    verts[1].x = tmp0->x + ix;				\
+    verts[1].y = tmp0->y + iy;				\
+							\
+    verts[2].x = tmp1->x + ix;				\
+    verts[2].y = tmp1->y + iy;				\
+							\
+    verts[3].x = tmp1->x - ix;				\
+    verts[3].y = tmp1->y - iy;				\
+							\
+    FX_grDrawPolygonVertexList(fxMesa, 4, verts);	\
+  }
+
+
+
+static void TAG(fx_tri_view_clip) (struct vertex_buffer * VB,
+                                   GLuint v[], GLubyte mask)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLfloat data[VB_MAX_CLIPPED_VERTS * 12];
+    GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
+    GrVertex *verts[VB_MAX_CLIPPED_VERTS];
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+    GLfloat *out = data;
+    GLfloat *mat = ctx->Viewport.WindowMap.m;
+    GLuint i, n;
+    GLubyte *clipmask = VB->ClipMask;
+
+    GLuint tmu0_source = fxMesa->tmu_source[0];
+    GLuint tmu1_source = fxMesa->tmu_source[1];
+    GLvector4f *tc0_vec = VB->TexCoordPtr[tmu0_source];
+    GLvector4f *tc1_vec = VB->TexCoordPtr[tmu1_source];
+
+    (void) fxMesa;
+    (void) tmu0_source;
+    (void) tc0_vec;
+    (void) tmu1_source;
+    (void) tc1_vec;
+
+    for (i = 0; i < 3; i++) {
+        GLuint e = v[i];
+        verts[i] = 0;
+        if (!clipmask[e])
+            verts[i] = (GrVertex *) gWin[e].f;
+        vlist[i] = out;
+        COPY_STRIDE;
+        out += SIZE;
+    }
+
+    if ((n = fx_view_clip_triangle(ctx, vlist, verts, SIZE, mask)) >= 3) {
+        GrVertex tmp[VB_MAX_CLIPPED_VERTS];
+        GrVertex *v = tmp, *v2, *v3;
+        VARS;
+
+        for (i = 0; i < n; i++)
+            if (!verts[i]) {
+                GLfloat *data = vlist[i];
+                SETUP;
+                verts[i] = v++;
+            }
+
+        v = verts[0];
+        v2 = verts[1];
+        v3 = verts[2];
+
+        for (i = 2; i < n; v2 = v3, v3 = verts[++i])
+            FX_grDrawTriangle(fxMesa, v, v2, v3);
+    }
+}
+
+
+
+
+
+static void TAG(fx_tri_clip_stride) (struct vertex_buffer * VB,
+                                     GLuint v[], GLuint mask)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLfloat data[VB_MAX_CLIPPED_VERTS * 12];
+    GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
+    GrVertex *verts[VB_MAX_CLIPPED_VERTS];
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+    GLfloat *out = data;
+    GLfloat *mat = ctx->Viewport.WindowMap.m;
+    GLuint i, n;
+    GLubyte *clipmask = VB->ClipMask;
+
+    GLuint tmu0_source = fxMesa->tmu_source[0];
+    GLuint tmu1_source = fxMesa->tmu_source[1];
+    GLvector4f *tc0_vec = VB->TexCoordPtr[tmu0_source];
+    GLvector4f *tc1_vec = VB->TexCoordPtr[tmu1_source];
+
+    (void) fxMesa;
+    (void) tmu0_source;
+    (void) tc0_vec;
+    (void) tmu1_source;
+    (void) tc1_vec;
+
+    for (i = 0; i < 3; i++) {
+        GLuint e = v[i];
+        verts[i] = 0;
+        if (!clipmask[e])
+            verts[i] = (GrVertex *) gWin[e].f;
+        vlist[i] = out;
+        COPY_STRIDE;
+        out += SIZE;
+    }
+
+    if (VB->ClipPtr->size < 4) {
+        vlist[0][3] = vlist[1][3] = vlist[2][3] = 1.0;
+        if (VB->ClipPtr->size == 2)
+            vlist[0][2] = vlist[1][2] = vlist[2][2] = 0.0;
+    }
+
+    if ((n = fx_clip_triangle(ctx, vlist, verts, SIZE, mask)) >= 3) {
+        GrVertex tmp[VB_MAX_CLIPPED_VERTS];
+        GrVertex *v = tmp, *v2, *v3;
+        VARS;
+
+        for (i = 0; i < n; i++)
+            if (!verts[i]) {
+                GLfloat *data = vlist[i];
+                SETUP;
+                verts[i] = v++;
+            }
+
+        v = verts[0];
+        v2 = verts[1];
+        v3 = verts[2];
+
+        for (i = 2; i < n; v2 = v3, v3 = verts[++i])
+            FX_grDrawTriangle(fxMesa, v, v2, v3);
+    }
+}
+
+
+
+static void TAG(fx_line_clip) (struct vertex_buffer * VB,
+                               GLuint v1, GLuint v2, GLubyte mask)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLfloat data[VB_MAX_CLIPPED_VERTS * 12];
+    GLfloat *vlist[VB_MAX_CLIPPED_VERTS];
+    GLfloat *out = data;
+    GLfloat *mat = ctx->Viewport.WindowMap.m;
+    GLfloat w = ctx->Line.Width * .5;
+    GLuint e, n;
+
+    GLuint tmu0_source = fxMesa->tmu_source[0];
+    GLuint tmu1_source = fxMesa->tmu_source[1];
+    GLvector4f *tc0_vec = VB->TexCoordPtr[tmu0_source];
+    GLvector4f *tc1_vec = VB->TexCoordPtr[tmu1_source];
+
+    VARS;
+
+    (void) fxMesa;
+    (void) tmu0_source;
+    (void) tc0_vec;
+    (void) tmu1_source;
+    (void) tc1_vec;
+
+    vlist[0] = out;
+    e = v1;
+    COPY_STRIDE;
+    out += SIZE;
+
+    vlist[1] = out;
+    e = v2;
+    COPY_STRIDE;
+    out += SIZE;
+
+    if (VB->ClipPtr->size < 4) {
+        vlist[0][3] = vlist[1][3] = 1.0;
+        if (VB->ClipPtr->size == 2)
+            vlist[0][2] = vlist[1][2] = 0.0;
+    }
+
+    if ((n = fx_clip_line(ctx, vlist, SIZE, mask)) != 0) {
+        GrVertex gWin[2];
+        GrVertex *v;
+        GLfloat *data;
+
+        v = gWin;
+        data = vlist[0];
+        SETUP;
+
+        v++;
+        data = vlist[1];
+        SETUP;
+
+        DRAW_LINE(fxMesa, gWin, v, w);
+    }
+}
+
+
+
+#undef V1
+#undef S1
+#undef C1
+#undef Z1
+#undef T1
+
+#undef V2
+#undef S2
+#undef C2
+#undef Z2
+#undef T2
+
+#undef V3
+#undef S3
+#undef C3
+#undef Z3
+#undef T3
+
+#undef V4
+#undef S4
+#undef C4
+#undef Z4
+#undef T4
+
+#undef VARS
+#undef SETUP
+#undef COPY
+#undef COPY_STRIDE
+#undef SIZE
+#undef IND
+#undef TAG
Index: xc/lib/GL/mesa/src/drv/tdfx/fxcva.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxcva.c:1.2
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxcva.c	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,482 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxcva.c,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* fxcva.c - the CVA related code */
+
+#include "fxdrv.h"
+#include "fxtexman.h"
+#include "mmath.h"
+#include "vbindirect.h"
+#include "pb.h"
+#include "fxsetup.h"
+#include "fxvsetup.h"
+#include "fxcva.h"
+#include "pipeline.h"
+#include "stages.h"
+
+#define PRIM_POINTS 0
+#define PRIM_LINES  1
+#define PRIM_TRIS   2
+#define PRIM_CULLED 3
+
+
+static GLuint reduce_prim[GL_POLYGON + 2] = {
+    PRIM_POINTS,
+    PRIM_LINES,
+    PRIM_LINES,
+    PRIM_LINES,
+    PRIM_TRIS,
+    PRIM_TRIS,
+    PRIM_TRIS,
+    PRIM_TRIS,
+    PRIM_TRIS,
+    PRIM_TRIS,
+    PRIM_CULLED
+};
+
+typedef void (*mergefunc) (struct vertex_buffer * cvaVB,
+                           struct vertex_buffer * VB,
+                           const struct gl_prim_state * state,
+                           GLuint start, GLuint count);
+
+static void
+fxCvaRenderNoop(struct vertex_buffer *cvaVB,
+                struct vertex_buffer *VB,
+                const struct gl_prim_state *state, GLuint start, GLuint count)
+{
+}
+
+static INLINE void
+fxRenderClippedTriangle2(struct vertex_buffer *VB,
+                         GLuint v1, GLuint v2, GLuint v3)
+{
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+    GLubyte *clipmask = VB->ClipMask;
+    GLubyte mask = clipmask[v1] | clipmask[v2] | clipmask[v3];
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+    if (!mask) {
+        FX_grDrawTriangle(fxMesa, (GrVertex *) gWin[v1].f,
+                          (GrVertex *) gWin[v2].f, (GrVertex *) gWin[v3].f);
+    }
+    else if (!(clipmask[v1] & clipmask[v2] & clipmask[v3] & CLIP_ALL_BITS)) {
+        GLuint n;
+        GLuint vlist[VB_MAX_CLIPPED_VERTS];
+        ASSIGN_3V(vlist, v1, v2, v3);
+
+        n = (VB->ctx->poly_clip_tab[VB->ClipPtr->size]) (VB, 3, vlist, mask);
+        if (n >= 3) {
+            GLuint i, j0 = vlist[0];
+            for (i = 2; i < n; i++) {
+                FX_grDrawTriangle(fxMesa,
+                                  (GrVertex *) gWin[j0].f,
+                                  (GrVertex *) gWin[vlist[i - 1]].f,
+                                  (GrVertex *) gWin[vlist[i]].f);
+            }
+        }
+    }
+}
+
+
+static mergefunc merge_and_render_tab[2][MAX_MERGABLE][PRIM_CULLED + 1];
+
+
+/*
+#define CVA_VARS_RGBA							\
+   GLubyte (*color)[4] = VB->ColorPtr->data;			\
+   GLubyte (*cva_color)[4] = (cvaVB->ColorPtr = cvaVB->LitColor[0])->data;
+*/
+
+#define CVA_VARS_RGBA							\
+   GLubyte (*color)[4] = VB->ColorPtr->data;			\
+   GLubyte (*cva_color)[4] = cvaVB->ColorPtr->data;
+
+
+
+#undef DO_SETUP_RGBA
+#if FX_USE_PARGB
+#define DO_SETUP_RGBA				                \
+{						                \
+  GLubyte *col = color[i];			                \
+  PACK_4F_ARGB(GET_PARGB(v), col[3], col[0], col[1], col[2]);   \
+}
+#else
+#define DO_SETUP_RGBA				                \
+{						                \
+  GLubyte *col = color[i];					\
+  v[GR_VERTEX_R_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]);	\
+  v[GR_VERTEX_G_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]);	\
+  v[GR_VERTEX_B_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]);	\
+  v[GR_VERTEX_A_OFFSET]=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]);	\
+}
+#endif /* FX_USE_PARGB */
+
+
+#define CVA_VARS_TMU0							\
+   VARS_TMU0								\
+   GLfloat (*cva_tex0)[4] = (cvaVB->TexCoordPtr[tmu0_source] = cvaVB->store.TexCoord[tmu0_source])->data;
+
+#define CVA_VARS_TMU1							\
+   VARS_TMU1								\
+   GLfloat (*cva_tex1)[4] = (cvaVB->TexCoordPtr[tmu1_source] = cvaVB->store.TexCoord[tmu1_source])->data;
+
+
+#define INIT_RGBA (void) cva_color;
+#define INIT_TMU0 (void) cva_tex0; (void) tmu0_stride; (void) tmu0_sz;
+#define INIT_TMU1 (void) cva_tex1; (void) tmu1_stride; (void) tmu1_sz;
+
+
+#define DRAW_POINT FX_grDrawPoint( fxMesa, (GrVertex *)v )
+#define DRAW_LINE FX_grDrawLine( fxMesa, (GrVertex *)v, (GrVertex *)prev_v )
+#define DRAW_TRI FX_grDrawTriangle( fxMesa, (GrVertex *)gWin[l[0]].f, (GrVertex *)gWin[l[1]].f, (GrVertex *)v )
+#define DRAW_TRI2 FX_grDrawTriangle( fxMesa, vl[0], vl[1], vl[2] )
+#define CLIP_LINE fxRenderClippedLine( cvaVB, e, prev )
+#define CLIP_OR_DRAW_TRI fxRenderClippedTriangle2( cvaVB, l[0], l[1], e )
+#define DIRECT 1
+
+#define TAG(x) x
+#define IDX 0
+#define VARS
+#define INIT
+#define INCR
+#define MERGE_RAST
+#define MERGE_VB
+#include "fxcvatmp.h"
+
+#define TAG(x) x##RGBA
+#define IDX SETUP_RGBA
+#define VARS CVA_VARS_RGBA
+#define INIT INIT_RGBA
+#define INCR
+#define MERGE_RAST DO_SETUP_RGBA
+#define MERGE_VB COPY_4UBV(cva_color[e], color[i])
+#include "fxcvatmp.h"
+
+#define TAG(x) x##T0
+#define IDX SETUP_TMU0
+#define VARS CVA_VARS_TMU0
+#define INIT INIT_TMU0
+#define INCR , tmu0_data+=4
+#define MERGE_RAST DO_SETUP_TMU0
+#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data)
+#include "fxcvatmp.h"
+
+#define TAG(x) x##T1
+#define IDX SETUP_TMU1
+#define VARS CVA_VARS_TMU1
+#define INIT INIT_TMU1
+#define INCR , tmu1_data+=4
+#define MERGE_RAST DO_SETUP_TMU1
+#define MERGE_VB COPY_2FV(cva_tex1[e], tmu1_data)
+#include "fxcvatmp.h"
+
+#define TAG(x) x##T0T1
+#define IDX SETUP_TMU0|SETUP_TMU1
+#define VARS CVA_VARS_TMU0 CVA_VARS_TMU1
+#define INIT INIT_TMU0 INIT_TMU1
+#define INCR , tmu0_data+=4 , tmu1_data+=4
+#define MERGE_RAST DO_SETUP_TMU0 DO_SETUP_TMU1
+#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
+                 COPY_2FV(cva_tex1[e], tmu1_data);
+#include "fxcvatmp.h"
+
+#define TAG(x) x##RGBAT0
+#define IDX SETUP_RGBA|SETUP_TMU0
+#define VARS CVA_VARS_RGBA CVA_VARS_TMU0
+#define INIT INIT_RGBA INIT_TMU0
+#define INCR , tmu0_data+=4
+#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU0
+#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
+                 COPY_4UBV(cva_color[e], color[i]);
+#include "fxcvatmp.h"
+
+#define TAG(x) x##RGBAT1
+#define IDX SETUP_RGBA|SETUP_TMU1
+#define VARS CVA_VARS_RGBA CVA_VARS_TMU1
+#define INIT INIT_RGBA INIT_TMU1
+#define INCR , tmu1_data+=4
+#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU1
+#define MERGE_VB COPY_2FV(cva_tex1[e], tmu1_data); \
+                 COPY_4UBV(cva_color[e], color[i]);
+#include "fxcvatmp.h"
+
+#define TAG(x) x##RGBAT0T1
+#define IDX SETUP_RGBA|SETUP_TMU0|SETUP_TMU1
+#define VARS CVA_VARS_RGBA CVA_VARS_TMU0 CVA_VARS_TMU1
+#define INIT INIT_RGBA INIT_TMU0 INIT_TMU1
+#define INCR , tmu0_data+=4 , tmu1_data+=4
+#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU0 DO_SETUP_TMU1
+#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
+                 COPY_2FV(cva_tex1[e], tmu1_data); \
+                 COPY_4UBV(cva_color[e], color[i]);
+#include "fxcvatmp.h"
+
+
+
+#undef DRAW_POINT
+#undef DRAW_LINE
+#undef DRAW_TRI
+#undef CLIP_LINE
+#undef CLIP_OR_DRAW_TRI
+#undef DIRECT
+
+#define DRAW_POINT ctx->Driver.PointsFunc( ctx, e, e )
+#define DRAW_LINE ctx->Driver.LineFunc( ctx, e, prev, e )
+#define DRAW_TRI ctx->TriangleFunc( ctx, l[0], l[1], e, e )
+#define CLIP_LINE gl_render_clipped_line( ctx, e, prev )
+#define CLIP_OR_DRAW_TRI 						\
+do {									\
+   if (clip[l[0]] | clip[l[1]] | clip[e]) {				\
+      if (!(clip[l[0]] & clip[l[1]] & clip[e] & CLIP_ALL_BITS)) {	\
+	 COPY_3V(vlist, l);						\
+	 gl_render_clipped_triangle( ctx, 3, vlist, e );		\
+      }									\
+   }									\
+   else ctx->TriangleFunc( ctx, l[0], l[1], e, e );			\
+} while (0)
+
+
+#define DIRECT 0
+
+#define TAG(x) x##_indirect
+#define IDX 0
+#define VARS
+#define INIT
+#define INCR
+#define MERGE_RAST
+#define MERGE_VB
+#include "fxcvatmp.h"
+
+#define TAG(x) x##RGBA_indirect
+#define IDX SETUP_RGBA
+#define VARS CVA_VARS_RGBA
+#define INIT INIT_RGBA
+#define INCR
+#define MERGE_RAST DO_SETUP_RGBA
+#define MERGE_VB COPY_4UBV(cva_color[e], color[i])
+#include "fxcvatmp.h"
+
+#define TAG(x) x##T0_indirect
+#define IDX SETUP_TMU0
+#define VARS CVA_VARS_TMU0
+#define INIT INIT_TMU0
+#define INCR , tmu0_data+=4
+#define MERGE_RAST DO_SETUP_TMU0
+#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data)
+#include "fxcvatmp.h"
+
+#define TAG(x) x##T1_indirect
+#define IDX SETUP_TMU1
+#define VARS CVA_VARS_TMU1
+#define INIT INIT_TMU1
+#define INCR , tmu1_data+=4
+#define MERGE_RAST DO_SETUP_TMU1
+#define MERGE_VB COPY_2FV(cva_tex1[e], tmu1_data)
+#include "fxcvatmp.h"
+
+#define TAG(x) x##T0T1_indirect
+#define IDX SETUP_TMU0|SETUP_TMU1
+#define VARS CVA_VARS_TMU0 CVA_VARS_TMU1
+#define INIT INIT_TMU0 INIT_TMU1
+#define INCR , tmu0_data+=4 , tmu1_data+=4
+#define MERGE_RAST DO_SETUP_TMU0 DO_SETUP_TMU1
+#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
+                 COPY_2FV(cva_tex1[e], tmu1_data);
+#include "fxcvatmp.h"
+
+#define TAG(x) x##RGBAT0_indirect
+#define IDX SETUP_RGBA|SETUP_TMU0
+#define VARS CVA_VARS_RGBA CVA_VARS_TMU0
+#define INIT INIT_RGBA INIT_TMU0
+#define INCR , tmu0_data+=4
+#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU0
+#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
+                 COPY_4UBV(cva_color[e], color[i]);
+#include "fxcvatmp.h"
+
+#define TAG(x) x##RGBAT1_indirect
+#define IDX SETUP_RGBA|SETUP_TMU1
+#define VARS CVA_VARS_RGBA CVA_VARS_TMU1
+#define INIT INIT_RGBA INIT_TMU1
+#define INCR , tmu1_data+=4
+#define MERGE_RAST DO_SETUP_RGBA; DO_SETUP_TMU1
+#define MERGE_VB COPY_2FV(cva_tex1[e], tmu1_data); \
+                 COPY_4UBV(cva_color[e], color[i]);
+#include "fxcvatmp.h"
+
+#define TAG(x) x##RGBAT0T1_indirect
+#define IDX SETUP_RGBA|SETUP_TMU0|SETUP_TMU1
+#define VARS CVA_VARS_RGBA CVA_VARS_TMU0 CVA_VARS_TMU1
+#define INIT INIT_RGBA INIT_TMU0 INIT_TMU1
+#define INCR , tmu0_data+=4 , tmu1_data+=4
+#define MERGE_RAST DO_SETUP_RGBA DO_SETUP_TMU0 DO_SETUP_TMU1
+#define MERGE_VB COPY_2FV(cva_tex0[e], tmu0_data); \
+                 COPY_2FV(cva_tex1[e], tmu1_data); \
+                 COPY_4UBV(cva_color[e], color[i]);
+#include "fxcvatmp.h"
+
+
+
+
+void
+fxDDCvaInit()
+{
+    /* Call grDrawTriangle et al */
+    init_cva();
+    init_cvaT0();
+    init_cvaT1();
+    init_cvaT0T1();
+    init_cvaRGBA();
+    init_cvaRGBAT0();
+    init_cvaRGBAT1();
+    init_cvaRGBAT0T1();
+
+    /* Call ctx->TriangleFunc and friends */
+    init_cva_indirect();
+    init_cvaT0_indirect();
+    init_cvaT1_indirect();
+    init_cvaT0T1_indirect();
+    init_cvaRGBA_indirect();
+    init_cvaRGBAT0_indirect();
+    init_cvaRGBAT1_indirect();
+    init_cvaRGBAT0T1_indirect();
+}
+
+
+void
+fxDDCheckMergeAndRender(GLcontext * ctx, struct gl_pipeline_stage *d)
+{
+    GLuint inputs = ctx->RenderFlags & ~ctx->CVA.pre.outputs;
+
+    if (!(ctx->TriangleCaps & DD_TRI_UNFILLED) &&
+        (ctx->Array.Summary & VERT_OBJ_ANY)) {
+        d->inputs = (VERT_SETUP_PART | VERT_ELT | inputs);
+        d->outputs = 0;
+        d->type = PIPE_IMMEDIATE;
+    }
+
+/*     gl_print_vert_flags("merge&render inputs", d->inputs); */
+}
+
+
+/* static GLboolean edge_flag[GL_POLYGON+2] = { 0,0,0,0,1,0,0,1,0,1,0 }; */
+
+void
+fxDDMergeAndRender(struct vertex_buffer *VB)
+{
+    GLcontext *ctx = VB->ctx;
+    struct vertex_buffer *cvaVB = ctx->CVA.VB;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint i, next, prim;
+    GLuint parity = VB->Parity;
+    GLuint count = VB->Count;
+    const struct gl_prim_state *state;
+    mergefunc func;
+    struct vertex_buffer *saved_vb = ctx->VB;
+    GLuint inputs = ctx->RenderFlags & ~ctx->CVA.pre.outputs;
+    GLuint flags = 0;
+    GLuint direct = (fxMesa->render_index == 0);
+    mergefunc(*tab)[PRIM_CULLED + 1] = merge_and_render_tab[direct];
+    GLuint p = 0;
+
+    if (fxMesa->new_state)
+        fxSetupFXUnits(ctx);
+
+
+    /* May actually contain elements not present in fxMesa->setupindex,
+     * eg RGBA when flat shading.  These need to be copied into the cva
+     * VB so that funcs like fxTriangleFlat will be able to reach them.
+     *
+     * This leads to some duplication of effort in the merge funcs.  
+     */
+    if (inputs & VERT_RGBA) {
+        cvaVB->ColorPtr = cvaVB->Color[0] = cvaVB->LitColor[0];
+        cvaVB->Color[1] = cvaVB->LitColor[1];
+        flags |= SETUP_RGBA;
+    }
+
+    if (inputs & VERT_TEX0_ANY) {
+        cvaVB->TexCoordPtr[0] = cvaVB->store.TexCoord[0];
+        flags |= fxMesa->tex_dest[0];
+    }
+
+    if (inputs & VERT_TEX1_ANY) {
+        cvaVB->TexCoordPtr[1] = cvaVB->store.TexCoord[1];
+        flags |= fxMesa->tex_dest[1];
+    }
+#if 0
+    fxPrintSetupFlags("FX cva merge & render", flags);
+#endif
+
+    if (cvaVB->ClipOrMask)
+        gl_import_client_data(cvaVB, ctx->RenderFlags,
+                              VEC_WRITABLE | VEC_GOOD_STRIDE);
+
+    ctx->VB = cvaVB;
+
+    do {
+        for (i = VB->CopyStart; i < count; parity = 0, i = next) {
+            prim = VB->Primitive[i];
+            next = VB->NextPrimitive[i];
+
+            state = gl_prim_state_machine[prim][parity];
+            func = tab[flags][reduce_prim[prim]];
+            func(cvaVB, VB, state, i, next);
+
+            if (ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE) {
+                cvaVB->Specular = cvaVB->Spec[0];
+                cvaVB->ColorPtr = cvaVB->Color[0];
+                cvaVB->IndexPtr = cvaVB->Index[0];
+            }
+        }
+    } while (ctx->Driver.MultipassFunc && ctx->Driver.MultipassFunc(VB, ++p));
+
+
+
+    if (ctx->PB->count > 0)
+        gl_flush_pb(ctx);
+
+    ctx->VB = saved_vb;
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxcva.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxcva.h:1.1
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxcva.h	Sun Sep 24 09:51:14 2000
@@ -0,0 +1,64 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxcva.h,v 1.1 2000/09/24 13:51:14 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#ifndef _FXCVA_H_
+#define _FXCVA_H_
+
+
+
+extern GLboolean fxMergeAndRenderCVA(struct vertex_buffer *VB,
+                                     struct vertex_buffer *cvaVB);
+
+extern void fxRenderCVAElements(struct vertex_buffer *VB,
+                                GLenum mode, GLuint * elts, GLuint n);
+
+extern GLboolean fxCheckCVA(GLcontext * ctx);
+
+extern void fxPrecalcCVA(struct vertex_buffer *VB);
+
+extern void fxDDCheckMergeAndRender(GLcontext * ctx,
+                                    struct gl_pipeline_stage *d);
+
+
+#endif
Index: xc/lib/GL/mesa/src/drv/tdfx/fxcvatmp.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxcvatmp.h:1.1
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxcvatmp.h	Sun Sep 24 09:51:14 2000
@@ -0,0 +1,278 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxcvatmp.h,v 1.1 2000/09/24 13:51:14 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+static void TAG(cva_render_points) (struct vertex_buffer * cvaVB,
+                                    struct vertex_buffer * VB,
+                                    const struct gl_prim_state * state,
+                                    GLuint start, GLuint count)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    fxVertex *gWin = FX_DRIVER_DATA(cvaVB)->verts;
+    const GLuint *elt = VB->EltPtr->data;
+    GLuint i;
+
+    VARS;
+    INIT;
+    (void) fxMesa;
+
+    if (cvaVB->ClipOrMask) {
+        const GLubyte *clip = cvaVB->ClipMask;
+        for (i = start; i < count; i++ INCR) {
+            GLuint e = elt[i];
+            if (!clip[e]) {
+                GLfloat *v = gWin[e].f;
+                (void) v;
+                if (!DIRECT) {
+                    MERGE_VB;
+                }
+                MERGE_RAST;
+                DRAW_POINT;
+            }
+        }
+    }
+    else {
+        for (i = start; i < count; i++ INCR) {
+            GLuint e = elt[i];
+            GLfloat *v = gWin[e].f;
+            (void) v;
+            if (!DIRECT) {
+                MERGE_VB;
+            }
+            MERGE_RAST;
+            DRAW_POINT;
+        }
+    }
+}
+
+static void TAG(cva_render_lines) (struct vertex_buffer * cvaVB,
+                                   struct vertex_buffer * VB,
+                                   const struct gl_prim_state * state,
+                                   GLuint start, GLuint count)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    fxVertex *gWin = FX_DRIVER_DATA(cvaVB)->verts;
+    const GLuint *elt = VB->EltPtr->data;
+    GLuint i;
+
+    VARS;
+    INIT;
+    (void) fxMesa;
+
+    if (cvaVB->ClipOrMask) {
+        const GLubyte *clip = cvaVB->ClipMask;
+        GLuint prev = 0;
+        GLfloat *prev_v = 0;
+
+        (void) ctx;
+
+        for (i = start; i < count; i++ INCR) {
+            GLuint e = elt[i];
+            GLfloat *v = gWin[e].f;
+
+            MERGE_VB;
+
+            if (!clip[e])
+                MERGE_RAST;
+
+            if (state->draw) {
+                if (clip[e] | clip[prev])
+                    CLIP_LINE;
+                else
+                    DRAW_LINE;
+            }
+
+            prev = e;
+            prev_v = v;
+            state = state->next;
+        }
+        if (state->finish_loop) {
+            GLuint e = elt[start];
+            GLfloat *v = gWin[e].f;
+            (void) v;
+
+            if (!DIRECT) {
+                MERGE_VB;
+            }
+            MERGE_RAST;
+
+            if (clip[e] | clip[prev])
+                CLIP_LINE;
+            else
+                DRAW_LINE;
+        }
+    }
+    else {
+        GLuint prev = 0;
+        GLfloat *prev_v = 0;
+
+        for (i = start; i < count; i++ INCR) {
+            GLuint e = elt[i];
+            GLfloat *v = gWin[e].f;
+
+            if (!DIRECT) {
+                MERGE_VB;
+            }
+            MERGE_RAST;
+            if (state->draw)
+                DRAW_LINE;
+            prev = e;
+            prev_v = v;
+            state = state->next;
+        }
+        if (state->finish_loop) {
+            GLuint e = elt[start];
+            GLfloat *v = gWin[e].f;
+            (void) v;
+
+            if (!DIRECT) {
+                MERGE_VB;
+            }
+            MERGE_RAST;
+            DRAW_LINE;
+        }
+    }
+}
+
+
+static void TAG(cva_render_tris) (struct vertex_buffer * cvaVB,
+                                  struct vertex_buffer * VB,
+                                  const struct gl_prim_state * state,
+                                  GLuint start, GLuint count)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    fxVertex *gWin = FX_DRIVER_DATA(cvaVB)->verts;
+    const GLuint *elt = VB->EltPtr->data;
+    GLuint i;
+    VARS;
+    INIT;
+    (void) fxMesa;
+
+    if (cvaVB->ClipOrMask) {
+        GLuint vlist[VB_MAX_CLIPPED_VERTS];
+        GLuint l[3];
+        const GLubyte *clip = cvaVB->ClipMask;
+
+        (void) vlist;
+
+        for (i = start; i < count; i++ INCR) {
+            GLuint e = l[2] = elt[i];
+            GLfloat *v = gWin[e].f;
+            (void) v;
+
+            MERGE_VB;           /* needed for clip-interp */
+
+            if (!clip[e]) {
+                MERGE_RAST;
+            }
+
+            if (state->draw)
+                CLIP_OR_DRAW_TRI;
+
+
+            l[0] = l[state->v0];
+            l[1] = l[state->v1];
+            state = state->next;
+        }
+    }
+    else if (DIRECT) {
+        GrVertex *vl[3];
+        for (i = start; i < count; i++ INCR) {
+            GLuint e = elt[i];
+            GLfloat *v = gWin[elt[i]].f;
+
+            vl[2] = (GrVertex *) v;
+
+            (void) v;
+            (void) e;
+
+            MERGE_RAST;
+
+            if (state->draw)
+                DRAW_TRI2;
+
+            vl[0] = vl[state->v0];
+            vl[1] = vl[state->v1];
+            state = state->next;
+        }
+    }
+    else {
+        GLuint l[3];
+        for (i = start; i < count; i++ INCR) {
+            GLuint e = l[2] = elt[i];
+            GLfloat *v = gWin[e].f;
+            (void) v;
+
+            MERGE_VB;           /* needed for ctx->trianglefunc? */
+            MERGE_RAST;
+
+            if (state->draw)
+                DRAW_TRI;
+
+            l[0] = l[state->v0];
+            l[1] = l[state->v1];
+            state = state->next;
+        }
+    }
+}
+
+
+static void TAG(init_cva) (void)
+{
+    merge_and_render_tab[DIRECT][IDX][PRIM_POINTS] = TAG(cva_render_points);
+    merge_and_render_tab[DIRECT][IDX][PRIM_LINES] = TAG(cva_render_lines);
+    merge_and_render_tab[DIRECT][IDX][PRIM_TRIS] = TAG(cva_render_tris);
+    merge_and_render_tab[DIRECT][IDX][PRIM_CULLED] = fxCvaRenderNoop;
+}
+
+
+#undef IDX
+#undef MERGE_RAST
+#undef MERGE_VB
+#undef VARS
+#undef INIT
+#undef INCR
+#undef TAG
Index: xc/lib/GL/mesa/src/drv/tdfx/fxdd.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxdd.c:1.3
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxdd.c	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,2020 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxdd.c,v 1.3 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#include <dlfcn.h>
+#include "image.h"
+#include "types.h"
+#include "fxdrv.h"
+#include "fxsetup.h"
+#include "fxpipeline.h"
+#include "fxddtex.h"
+#include "fxtexman.h"
+#include "enums.h"
+#include "extensions.h"
+#include "pb.h"
+
+
+/* These are used in calls to FX_grColorMaskv() */
+static const GLboolean false4[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
+static const GLboolean true4[4] = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
+
+#if	defined(FX_PXCONV_TABULAR)
+/* These lookup table are used to extract RGB values in [0,255] from
+ * 16-bit pixel values.
+ */
+GLubyte FX_PixelToRArray[0x10000];
+GLubyte FX_PixelToGArray[0x10000];
+GLubyte FX_PixelToBArray[0x10000];
+
+/*
+ * Initialize the FX_PixelTo{RGB} arrays.
+ * Input: bgrOrder - if TRUE, pixels are in BGR order, else RGB order.
+ */
+void
+fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder)
+{
+    fxMesa->bgrOrder = bgrOrder;
+   /*
+    * We add a level of braces so that we can define the
+    * variable pixel here.
+    */
+    {
+        GLuint pixel = 0;
+        for (pixel = 0; pixel <= 0xffff; pixel++) {
+            GLuint r, g, b;
+            if (bgrOrder) {
+                r = (pixel & 0x001F) << 3;
+                g = (pixel & 0x07E0) >> 3;
+                b = (pixel & 0xF800) >> 8;
+            }
+            else {
+                r = (pixel & 0xF800) >> 8;
+                g = (pixel & 0x07E0) >> 3;
+                b = (pixel & 0x001F) << 3;
+            }
+            r = r * 255 / 0xF8;     /* fill in low-order bits */
+            g = g * 255 / 0xFC;
+            b = b * 255 / 0xF8;
+            FX_PixelToRArray[pixel] = r;
+            FX_PixelToGArray[pixel] = g;
+            FX_PixelToBArray[pixel] = b;
+        }
+    }
+}
+#endif	/* FX_PXCONV_TABULAR */
+
+/**********************************************************************/
+/*****                 Miscellaneous functions                    *****/
+/**********************************************************************/
+
+
+/* Return buffer size information */
+static void
+fxDDBufferSize(GLcontext * ctx, GLuint * width, GLuint * height)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDBufferSize(...) Start\n");
+    }
+
+    *width = fxMesa->width;
+    *height = fxMesa->height;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDBufferSize(...) End\n");
+    }
+}
+
+
+/* Set current drawing color */
+static void
+fxDDSetColor(GLcontext * ctx, GLubyte red, GLubyte green,
+             GLubyte blue, GLubyte alpha)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GLubyte col[4];
+    ASSIGN_4V(col, red, green, blue, alpha);
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDSetColor(%d,%d,%d,%d)\n", red, green,
+                blue, alpha);
+    }
+    fxMesa->color = FXCOLOR4(col);
+}
+
+
+/* Implements glClearColor() */
+static void
+fxDDClearColor(GLcontext * ctx, GLubyte red, GLubyte green,
+               GLubyte blue, GLubyte alpha)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GLubyte col[4];
+    ASSIGN_4V(col, red, green, blue, 255);
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDClearColor(%d,%d,%d,%d)\n", red, green,
+                blue, alpha);
+    }
+    fxMesa->clearC = FXCOLOR4(col);
+    fxMesa->clearA = alpha;
+}
+
+
+/* Clear the color and/or depth buffers */
+static GLbitfield
+fxDDClear(GLcontext * ctx, GLbitfield mask, GLboolean all,
+          GLint x, GLint y, GLint width, GLint height)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
+    const FxU32 clearD = (FxU32) (ctx->Depth.Clear * fxMesa->depthClear);
+    const FxU32 clearS = (FxU32) (ctx->Stencil.Clear);
+    GLbitfield softwareMask = mask & (DD_ACCUM_BIT);
+    GLuint stencil_size =
+        fxMesa->haveHwStencil ? fxMesa->glVis->StencilBits : 0;
+
+    /* we can't clear accum buffers */
+    mask &= ~(DD_ACCUM_BIT);
+
+    if ((mask & DD_STENCIL_BIT) && !fxMesa->haveHwStencil) {
+        /* software stencil buffer */
+        mask &= ~(DD_STENCIL_BIT);
+        softwareMask |= DD_STENCIL_BIT;
+    }
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDClear(%d,%d,%d,%d)\n", (int) x, (int) y,
+                (int) width, (int) height);
+    }
+
+    if (colorMask != 0xffffffff) {
+        /* do masked color buffer clears in software */
+        softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
+        mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
+    }
+
+    if (fxMesa->haveHwStencil) {
+        /*
+         * If we want to clear stencil, it must be enabled
+         * in the HW, even if the stencil test is not enabled
+         * in the OGL state.
+         */
+        if (mask & DD_STENCIL_BIT) {
+            FX_grStencilMask_NoLock(0xFF /* ctx->Stencil.WriteMask*/ );
+            /* set stencil ref value = desired clear value */
+            FX_grStencilFunc_NoLock(GR_CMP_ALWAYS, ctx->Stencil.Clear, 0xff);
+            FX_grStencilOp_NoLock(GR_STENCILOP_REPLACE,
+                           GR_STENCILOP_REPLACE, GR_STENCILOP_REPLACE);
+            FX_grEnable_NoLock(GR_STENCIL_MODE_EXT);
+        }
+        else {
+            FX_grDisable_NoLock(GR_STENCIL_MODE_EXT);
+        }
+    }
+
+    BEGIN_CLIP_LOOP(fxMesa)
+
+    /*
+     * This could probably be done fancier but doing each possible case
+     * explicitly is less error prone.
+     */
+    switch (mask & ~DD_STENCIL_BIT) {
+    case DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
+        /* back buffer & depth */
+        FX_grDepthMask_NoLock(FXTRUE);
+        FX_grRenderBuffer_NoLock(GR_BUFFER_BACKBUFFER);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                       clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        if (!ctx->Depth.Mask || !ctx->Depth.Test) {
+            FX_grDepthMask_NoLock(FXFALSE);
+        }
+        break;
+    case DD_FRONT_LEFT_BIT | DD_DEPTH_BIT:
+        /* XXX it appears that the depth buffer isn't cleared when
+         * glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set.
+         * This is a work-around/
+         */
+        /* clear depth */
+        FX_grDepthMask_NoLock(FXTRUE);
+        FX_grRenderBuffer_NoLock(GR_BUFFER_BACKBUFFER);
+        FX_grColorMaskv_NoLock(ctx, false4);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        /* clear front */
+        FX_grColorMaskv_NoLock(ctx, true4);
+        FX_grRenderBuffer_NoLock(GR_BUFFER_FRONTBUFFER);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        if (!ctx->Depth.Mask || !ctx->Depth.Test) {
+            FX_grDepthMask_NoLock(FXFALSE);
+        }
+        break;
+    case DD_BACK_LEFT_BIT:
+        /* back buffer only */
+        FX_grDepthMask_NoLock(FXFALSE);
+        FX_grRenderBuffer_NoLock(GR_BUFFER_BACKBUFFER);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        if (ctx->Depth.Mask && ctx->Depth.Test) {
+            FX_grDepthMask_NoLock(FXTRUE);
+        }
+        break;
+    case DD_FRONT_LEFT_BIT:
+        /* front buffer only */
+        FX_grDepthMask_NoLock(FXFALSE);
+        FX_grRenderBuffer_NoLock(GR_BUFFER_FRONTBUFFER);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        if (ctx->Depth.Mask && ctx->Depth.Test) {
+            FX_grDepthMask_NoLock(FXTRUE);
+        }
+        break;
+    case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT:
+        /* front and back */
+        FX_grDepthMask_NoLock(FXFALSE);
+        FX_grRenderBuffer_NoLock(GR_BUFFER_BACKBUFFER);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        FX_grRenderBuffer_NoLock(GR_BUFFER_FRONTBUFFER);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        if (ctx->Depth.Mask && ctx->Depth.Test) {
+            FX_grDepthMask_NoLock(FXTRUE);
+        }
+        break;
+    case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT:
+        /* clear front */
+        FX_grDepthMask_NoLock(FXFALSE);
+        FX_grRenderBuffer_NoLock(GR_BUFFER_FRONTBUFFER);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        /* clear back and depth */
+        FX_grDepthMask_NoLock(FXTRUE);
+        FX_grRenderBuffer_NoLock(GR_BUFFER_BACKBUFFER);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        if (!ctx->Depth.Mask || !ctx->Depth.Mask) {
+            FX_grDepthMask_NoLock(FXFALSE);
+        }
+        break;
+    case DD_DEPTH_BIT:
+        /* just the depth buffer */
+        FX_grRenderBuffer_NoLock(GR_BUFFER_BACKBUFFER);
+        FX_grColorMaskv_NoLock(ctx, false4);
+        FX_grDepthMask_NoLock(FXTRUE);
+        if (stencil_size > 0)
+            FX_grBufferClearExt_NoLock(fxMesa->clearC, fxMesa->clearA, clearD,
+                                clearS);
+        else
+            FX_grBufferClear_NoLock(fxMesa->clearC, fxMesa->clearA, clearD);
+        FX_grColorMaskv_NoLock(ctx, true4);
+        if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT)
+            FX_grRenderBuffer_NoLock(GR_BUFFER_FRONTBUFFER);
+        if (!ctx->Depth.Test || !ctx->Depth.Mask)
+           FX_grDepthMask_NoLock(FXFALSE);
+        break;
+    default:
+         /* clear no color buffers or depth buffer but might clear stencil */
+	 if ((stencil_size > 0) && (mask & DD_STENCIL_BIT)) {
+            FX_grDepthMask_NoLock(FXFALSE);
+            FX_grColorMaskv_NoLock(ctx, false4);
+            FX_grBufferClearExt_NoLock(fxMesa->clearC,
+                                       fxMesa->clearA,
+				       clearD,
+                                       (FxU32) clearS);
+            if (ctx->Depth.Mask && ctx->Depth.Test) {
+               FX_grDepthMask_NoLock(FXTRUE);
+            }
+            FX_grColorMaskv_NoLock(ctx, true4);
+         }
+         break;
+    }
+
+    END_CLIP_LOOP(fxMesa);
+
+    if (fxMesa->haveHwStencil) {
+        if (ctx->Stencil.Enabled) {
+            /* restore stencil state to as it was before the clear */
+            GrStencil_t sfail = fxConvertGLStencilOp(ctx->Stencil.FailFunc);
+            GrStencil_t zfail = fxConvertGLStencilOp(ctx->Stencil.ZFailFunc);
+            GrStencil_t zpass = fxConvertGLStencilOp(ctx->Stencil.ZPassFunc);
+            FX_grStencilOp_NoLock(sfail, zfail, zpass);
+            FX_grStencilMask_NoLock(ctx->Stencil.WriteMask);
+            FX_grStencilFunc_NoLock(ctx->Stencil.Function - GL_NEVER,
+                             ctx->Stencil.Ref, ctx->Stencil.ValueMask);
+            FX_grEnable_NoLock(GR_STENCIL_MODE_EXT);
+        }
+        else {
+            FX_grDisable_NoLock(GR_STENCIL_MODE_EXT);
+        }
+    }
+
+    return softwareMask;
+}
+
+
+/* Set the buffer used for drawing */
+/* XXX support for separate read/draw buffers hasn't been tested */
+static GLboolean
+fxDDSetDrawBuffer(GLcontext * ctx, GLenum mode)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDSetBuffer(%x)\n", (int) mode);
+    }
+
+    if (mode == GL_FRONT_LEFT) {
+        fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
+        FX_grRenderBuffer(fxMesa, fxMesa->currentFB);
+        return GL_TRUE;
+    }
+    else if (mode == GL_BACK_LEFT) {
+        fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
+        FX_grRenderBuffer(fxMesa, fxMesa->currentFB);
+        return GL_TRUE;
+    }
+    else if (mode == GL_NONE) {
+        FX_grColorMaskv(ctx, false4);
+        return GL_TRUE;
+    }
+    else {
+        return GL_FALSE;
+    }
+}
+
+
+/* Set the buffer used for reading */
+/* XXX support for separate read/draw buffers hasn't been tested */
+static void
+fxDDSetReadBuffer(GLcontext * ctx, GLframebuffer * buffer, GLenum mode)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    (void) buffer;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDSetBuffer(%x)\n", (int) mode);
+    }
+
+    if (mode == GL_FRONT_LEFT) {
+        fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
+        FX_grRenderBuffer(fxMesa, fxMesa->currentFB);
+    }
+    else if (mode == GL_BACK_LEFT) {
+        fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
+        FX_grRenderBuffer(fxMesa, fxMesa->currentFB);
+    }
+}
+
+
+/*
+ * These functions just set new-state flags.  The exact state
+ * values will be evaluated later.
+ */
+static void
+fxDDStencilFunc(GLcontext * ctx, GLenum func, GLint ref, GLuint mask)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    (void) func;
+    (void) ref;
+    (void) mask;
+    fxMesa->new_state |= FX_NEW_STENCIL;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+static void
+fxDDStencilMask(GLcontext * ctx, GLuint mask)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    (void) mask;
+    fxMesa->new_state |= FX_NEW_STENCIL;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+static void
+fxDDStencilOp(GLcontext * ctx, GLenum sfail, GLenum zfail, GLenum zpass)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    (void) sfail;
+    (void) zfail;
+    (void) zpass;
+    fxMesa->new_state |= FX_NEW_STENCIL;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+static void
+fxDDDepthFunc(GLcontext * ctx, GLenum func)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    (void) func;
+    fxMesa->new_state |= FX_NEW_DEPTH;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+static void
+fxDDDepthMask(GLcontext * ctx, GLboolean mask)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    (void) mask;
+    fxMesa->new_state |= FX_NEW_DEPTH;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+
+
+/*
+ * Return the current value of the occlusion test flag and
+ * reset the flag (hardware counters) to false.
+ */
+#if 0
+static GLboolean
+get_occlusion_result(GLcontext *ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLboolean result;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+
+    if (ctx->Depth.OcclusionTest) {
+        if (ctx->OcclusionResult) {
+            result = GL_TRUE;  /* result of software rendering */
+        }
+        else {
+           FxI32 zfail, in;
+           zfail = FX_grGetInteger_NoLock(GR_STATS_PIXELS_DEPTHFUNC_FAIL);
+           in = FX_grGetInteger_NoLock(GR_STATS_PIXELS_IN);
+           if (in == zfail)
+               result = GL_FALSE; /* geom was completely occluded */
+           else
+               result = GL_TRUE;  /* all or part of geom was visible */
+        }
+    }
+    else {
+        result = ctx->OcclusionResultSaved;
+    }
+
+    /* reset results now */
+    grReset(GR_STATS_PIXELS);
+    ctx->OcclusionResult = GL_FALSE;
+    ctx->OcclusionResultSaved = GL_FALSE;
+
+    END_BOARD_LOCK(fxMesa);
+
+    return result;
+}
+#else
+
+static GLboolean get_occlusion_result( GLcontext *ctx )
+{
+   fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+   GLboolean result;
+
+   LOCK_HARDWARE( fxMesa );
+
+   printf("start state: %d %d\n", ctx->Depth.OcclusionTest, ctx->OcclusionResult);
+
+   if (ctx->Depth.OcclusionTest) {
+      if (ctx->OcclusionResult) {
+	 result = GL_TRUE;  /* result of software rendering */
+         printf("res = true 1\n");
+      }
+      else {
+	 FxI32 zfail, in;
+	 zfail = FX_grGetInteger_NoLock(GR_STATS_PIXELS_DEPTHFUNC_FAIL);
+	 in = FX_grGetInteger_NoLock(GR_STATS_PIXELS_IN);
+	 if (in == zfail) {
+	    result = GL_FALSE; /* geom was completely occluded */
+         printf("res = false 2\n");
+         }
+	 else {
+	    result = GL_TRUE;  /* all or part of geom was visible */
+         printf("res = true 2\n");
+
+         }
+      }
+   }
+   else {
+      result = ctx->OcclusionResultSaved;
+         printf("res = saved\n");
+   }
+
+   /* reset results now */
+   grReset(GR_STATS_PIXELS);
+   ctx->OcclusionResult = GL_FALSE;
+   ctx->OcclusionResultSaved = GL_FALSE;
+
+   UNLOCK_HARDWARE( fxMesa );
+
+   printf("result = %d\n", result);
+   return result;
+}
+
+#endif
+
+/*
+ * We're only implementing this function to handle the
+ * GL_OCCLUSTION_TEST_RESULT_HP case.  It's special because it
+ * has a side-effect: resetting the occlustion result flag.
+ */
+static GLboolean
+fxDDGetBooleanv(GLcontext *ctx, GLenum pname, GLboolean *result)
+{
+    if (pname == GL_OCCLUSION_TEST_RESULT_HP) {
+        *result = get_occlusion_result(ctx);
+        return GL_TRUE;
+    }
+    return GL_FALSE;
+}
+
+
+static GLboolean
+fxDDGetIntegerv(GLcontext *ctx, GLenum pname, GLint *result)
+{
+    if (pname == GL_OCCLUSION_TEST_RESULT_HP) {
+        *result = (GLint) get_occlusion_result(ctx);
+        return GL_TRUE;
+    }
+    return GL_FALSE;
+}
+
+
+static GLboolean
+fxDDGetFloatv(GLcontext *ctx, GLenum pname, GLfloat *result)
+{
+    if (pname == GL_OCCLUSION_TEST_RESULT_HP) {
+        *result = (GLfloat) get_occlusion_result(ctx);
+        return GL_TRUE;
+    }
+    return GL_FALSE;
+}
+
+
+static GLboolean
+fxDDGetDoublev(GLcontext *ctx, GLenum pname, GLdouble *result)
+{
+    if (pname == GL_OCCLUSION_TEST_RESULT_HP) {
+        *result = (GLdouble) get_occlusion_result(ctx);
+        return GL_TRUE;
+    }
+    return GL_FALSE;
+}
+
+
+/* test if window coord (px,py) is visible */
+static GLboolean
+inClipRects(fxMesaContext fxMesa, int px, int py)
+{
+    int i;
+    for (i = 0; i < fxMesa->numClipRects; i++) {
+        if ((px >= fxMesa->pClipRects[i].x1) &&
+            (px < fxMesa->pClipRects[i].x2) &&
+            (py >= fxMesa->pClipRects[i].y1) &&
+            (py < fxMesa->pClipRects[i].y2)) return GL_TRUE;
+    }
+    return GL_FALSE;
+}
+
+
+
+static GLboolean
+bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py,
+              GLsizei width, GLsizei height,
+              const struct gl_pixelstore_attrib *unpack,
+              const GLubyte * bitmap)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GrLfbInfo_t info;
+    FxU16 color;
+    const struct gl_pixelstore_attrib *finalUnpack;
+    struct gl_pixelstore_attrib scissoredUnpack;
+
+    /* check if there's any raster operations enabled which we can't handle */
+    if (ctx->RasterMask & (ALPHATEST_BIT |
+                           BLEND_BIT |
+                           DEPTH_BIT |
+                           FOG_BIT |
+                           LOGIC_OP_BIT |
+                           SCISSOR_BIT |
+                           STENCIL_BIT |
+                           MASKING_BIT |
+                           ALPHABUF_BIT | MULTI_DRAW_BIT)) return GL_FALSE;
+
+    if (ctx->Scissor.Enabled) {
+        /* This is a bit tricky, but by carefully adjusting the px, py,
+         * width, height, skipPixels and skipRows values we can do
+         * scissoring without special code in the rendering loop.
+         */
+
+        /* we'll construct a new pixelstore struct */
+        finalUnpack = &scissoredUnpack;
+        scissoredUnpack = *unpack;
+        if (scissoredUnpack.RowLength == 0)
+            scissoredUnpack.RowLength = width;
+
+        /* clip left */
+        if (px < ctx->Scissor.X) {
+            scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);
+            width -= (ctx->Scissor.X - px);
+            px = ctx->Scissor.X;
+        }
+        /* clip right */
+        if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {
+            width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));
+        }
+        /* clip bottom */
+        if (py < ctx->Scissor.Y) {
+            scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);
+            height -= (ctx->Scissor.Y - py);
+            py = ctx->Scissor.Y;
+        }
+        /* clip top */
+        if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
+            height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));
+        }
+
+        if (width <= 0 || height <= 0)
+            return GL_TRUE;     /* totally scissored away */
+    }
+    else {
+        finalUnpack = unpack;
+    }
+
+    /* compute pixel value */
+    {
+        GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f);
+        GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f);
+        GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f);
+        /*GLint a = (GLint)(ctx->Current.RasterColor[3]*255.0f); */
+        if (fxMesa->bgrOrder) {
+            color = (FxU16)
+                (((FxU16) 0xf8 & b) << (11 - 3)) |
+                (((FxU16) 0xfc & g) << (5 - 3 + 1)) |
+                (((FxU16) 0xf8 & r) >> 3);
+        }
+        else
+            color = (FxU16)
+                (((FxU16) 0xf8 & r) << (11 - 3)) |
+                (((FxU16) 0xfc & g) << (5 - 3 + 1)) |
+                (((FxU16) 0xf8 & b) >> 3);
+    }
+
+    info.size = sizeof(info);
+    if (!FX_grLfbLock(fxMesa,
+                      GR_LFB_WRITE_ONLY,
+                      fxMesa->currentFB,
+                      GR_LFBWRITEMODE_565,
+                      GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+#ifndef FX_SILENT
+        fprintf(stderr, "fx Driver: error locking the linear frame buffer\n");
+#endif
+        return GL_TRUE;
+    }
+
+    {
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        /* The dest stride depends on the hardware and whether we're drawing
+         * to the front or back buffer.  This compile-time test seems to do
+         * the job for now.
+         */
+        const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+            ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+        GLint row;
+        /* compute dest address of bottom-left pixel in bitmap */
+        GLushort *dst = (GLushort *) info.lfbPtr
+            + (winY - py) * dstStride + (winX + px);
+
+        for (row = 0; row < height; row++) {
+            const GLubyte *src =
+                (const GLubyte *) _mesa_image_address(finalUnpack,
+                                                      bitmap, width, height,
+                                                      GL_COLOR_INDEX,
+                                                      GL_BITMAP, 0, row, 0);
+            if (finalUnpack->LsbFirst) {
+                /* least significan bit first */
+                GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
+                GLint col;
+                for (col = 0; col < width; col++) {
+                    if (*src & mask) {
+                        if (inClipRects(fxMesa, winX + px + col, winY - py - row))
+                            dst[col] = color;
+                    }
+                    if (mask == 128U) {
+                        src++;
+                        mask = 1U;
+                    }
+                    else {
+                        mask = mask << 1;
+                    }
+                }
+                if (mask != 1)
+                    src++;
+            }
+            else {
+                /* most significan bit first */
+                GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);
+                GLint col;
+                for (col = 0; col < width; col++) {
+                    if (*src & mask) {
+                        if (inClipRects(fxMesa, winX + px + col, winY - py - row))
+                            dst[col] = color;
+                    }
+                    if (mask == 1U) {
+                        src++;
+                        mask = 128U;
+                    }
+                    else {
+                        mask = mask >> 1;
+                    }
+                }
+                if (mask != 128)
+                    src++;
+            }
+            dst -= dstStride;
+        }
+    }
+
+    FX_grLfbUnlock(fxMesa, GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    return GL_TRUE;
+}
+
+
+static GLboolean
+bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py,
+                GLsizei width, GLsizei height,
+                const struct gl_pixelstore_attrib *unpack,
+                const GLubyte * bitmap)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GrLfbInfo_t info;
+    GLuint color;
+    const struct gl_pixelstore_attrib *finalUnpack;
+    struct gl_pixelstore_attrib scissoredUnpack;
+
+    /* check if there's any raster operations enabled which we can't handle */
+    if (ctx->RasterMask & (ALPHATEST_BIT |
+                           BLEND_BIT |
+                           DEPTH_BIT |
+                           FOG_BIT |
+                           LOGIC_OP_BIT |
+                           SCISSOR_BIT |
+                           STENCIL_BIT |
+                           MASKING_BIT |
+                           ALPHABUF_BIT | MULTI_DRAW_BIT)) return GL_FALSE;
+
+    if (ctx->Scissor.Enabled) {
+        /* This is a bit tricky, but by carefully adjusting the px, py,
+         * width, height, skipPixels and skipRows values we can do
+         * scissoring without special code in the rendering loop.
+         */
+
+        /* we'll construct a new pixelstore struct */
+        finalUnpack = &scissoredUnpack;
+        scissoredUnpack = *unpack;
+        if (scissoredUnpack.RowLength == 0)
+            scissoredUnpack.RowLength = width;
+
+        /* clip left */
+        if (px < ctx->Scissor.X) {
+            scissoredUnpack.SkipPixels += (ctx->Scissor.X - px);
+            width -= (ctx->Scissor.X - px);
+            px = ctx->Scissor.X;
+        }
+        /* clip right */
+        if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) {
+            width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width));
+        }
+        /* clip bottom */
+        if (py < ctx->Scissor.Y) {
+            scissoredUnpack.SkipRows += (ctx->Scissor.Y - py);
+            height -= (ctx->Scissor.Y - py);
+            py = ctx->Scissor.Y;
+        }
+        /* clip top */
+        if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
+            height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height));
+        }
+
+        if (width <= 0 || height <= 0)
+            return GL_TRUE;     /* totally scissored away */
+    }
+    else {
+        finalUnpack = unpack;
+    }
+
+    /* compute pixel value */
+    {
+        GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f);
+        GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f);
+        GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f);
+        GLint a = (GLint) (ctx->Current.RasterColor[3] * 255.0f);
+        color = PACK_BGRA32(r, g, b, a);
+    }
+
+    info.size = sizeof(info);
+    if (!FX_grLfbLock(fxMesa, GR_LFB_WRITE_ONLY,
+                      fxMesa->currentFB, GR_LFBWRITEMODE_8888,
+                      GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+#ifndef FX_SILENT
+        fprintf(stderr, "fx Driver: error locking the linear frame buffer\n");
+#endif
+        return GL_TRUE;
+    }
+
+    {
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        GLint dstStride;
+        GLuint *dst;
+        GLint row;
+
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            dstStride = fxMesa->screen_width;
+            dst =
+                (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX +
+                                                                    px);
+        }
+        else {
+            dstStride = info.strideInBytes / 4;
+            dst =
+                (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX +
+                                                                    px);
+        }
+
+        /* compute dest address of bottom-left pixel in bitmap */
+        for (row = 0; row < height; row++) {
+            const GLubyte *src =
+                (const GLubyte *) _mesa_image_address(finalUnpack,
+                                                      bitmap, width, height,
+                                                      GL_COLOR_INDEX,
+                                                      GL_BITMAP, 0, row, 0);
+            if (finalUnpack->LsbFirst) {
+                /* least significan bit first */
+                GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7);
+                GLint col;
+                for (col = 0; col < width; col++) {
+                    if (*src & mask) {
+                        if (inClipRects(fxMesa, winX + px + col, winY - py - row))
+                            dst[col] = color;
+                    }
+                    if (mask == 128U) {
+                        src++;
+                        mask = 1U;
+                    }
+                    else {
+                        mask = mask << 1;
+                    }
+                }
+                if (mask != 1)
+                    src++;
+            }
+            else {
+                /* most significan bit first */
+                GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7);
+                GLint col;
+                for (col = 0; col < width; col++) {
+                    if (*src & mask) {
+                        if (inClipRects(fxMesa, winX + px + col, winY - py - row))
+                            dst[col] = color;
+                    }
+                    if (mask == 1U) {
+                        src++;
+                        mask = 128U;
+                    }
+                    else {
+                        mask = mask >> 1;
+                    }
+                }
+                if (mask != 128)
+                    src++;
+            }
+            dst -= dstStride;
+        }
+    }
+
+    FX_grLfbUnlock(fxMesa, GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    return GL_TRUE;
+}
+
+
+static GLboolean
+readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
+                  GLsizei width, GLsizei height,
+                  GLenum format, GLenum type,
+                  const struct gl_pixelstore_attrib *packing,
+                  GLvoid * dstImage)
+{
+    if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) {
+        return GL_FALSE;        /* can't do this */
+    }
+    else {
+        fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+        GrLfbInfo_t info;
+        GLboolean result = GL_FALSE;
+
+        BEGIN_BOARD_LOCK(fxMesa);
+        info.size = sizeof(info);
+        if (grLfbLock(GR_LFB_READ_ONLY,
+                      fxMesa->currentFB,
+                      GR_LFBWRITEMODE_ANY,
+                      GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+            const GLint winX = fxMesa->x_offset;
+            const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+            const GLint srcStride =
+                (fxMesa->glCtx->Color.DrawBuffer ==
+                 GL_FRONT) ? (fxMesa->screen_width) : (info.strideInBytes /
+                                                       2);
+            const GLushort *src = (const GLushort *) info.lfbPtr
+                + (winY - y) * srcStride + (winX + x);
+            GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage,
+                                                           width, height,
+                                                           format, type, 0, 0,
+                                                           0);
+            GLint dstStride =
+                _mesa_image_row_stride(packing, width, format, type);
+
+            if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+                /* convert 5R6G5B into 8R8G8B */
+                GLint row, col;
+                const GLint halfWidth = width >> 1;
+                const GLint extraPixel = (width & 1);
+                for (row = 0; row < height; row++) {
+                    GLubyte *d = dst;
+                    for (col = 0; col < halfWidth; col++) {
+                        const GLuint pixel = ((const GLuint *) src)[col];
+                        const GLint pixel0 = pixel & 0xffff;
+                        const GLint pixel1 = pixel >> 16;
+                        *d++ = FX_PixelToR(fxMesa, pixel0);
+                        *d++ = FX_PixelToG(fxMesa, pixel0);
+                        *d++ = FX_PixelToB(fxMesa, pixel0);
+                        *d++ = FX_PixelToR(fxMesa, pixel1);
+                        *d++ = FX_PixelToG(fxMesa, pixel1);
+                        *d++ = FX_PixelToB(fxMesa, pixel1);
+                    }
+                    if (extraPixel) {
+                        GLushort pixel = src[width - 1];
+                        *d++ = FX_PixelToR(fxMesa, pixel);
+                        *d++ = FX_PixelToG(fxMesa, pixel);
+                        *d++ = FX_PixelToB(fxMesa, pixel);
+                    }
+                    dst += dstStride;
+                    src -= srcStride;
+                }
+                result = GL_TRUE;
+            }
+            else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+                /* convert 5R6G5B into 8R8G8B8A */
+                GLint row, col;
+                const GLint halfWidth = width >> 1;
+                const GLint extraPixel = (width & 1);
+                for (row = 0; row < height; row++) {
+                    GLubyte *d = dst;
+                    for (col = 0; col < halfWidth; col++) {
+                        const GLuint pixel = ((const GLuint *) src)[col];
+                        const GLint pixel0 = pixel & 0xffff;
+                        const GLint pixel1 = pixel >> 16;
+                        *d++ = FX_PixelToR(fxMesa, pixel0);
+                        *d++ = FX_PixelToG(fxMesa, pixel0);
+                        *d++ = FX_PixelToB(fxMesa, pixel0);
+                        *d++ = 255;
+                        *d++ = FX_PixelToR(fxMesa, pixel1);
+                        *d++ = FX_PixelToG(fxMesa, pixel1);
+                        *d++ = FX_PixelToB(fxMesa, pixel1);
+                        *d++ = 255;
+                    }
+                    if (extraPixel) {
+                        const GLushort pixel = src[width - 1];
+                        *d++ = FX_PixelToR(fxMesa, pixel);
+                        *d++ = FX_PixelToG(fxMesa, pixel);
+                        *d++ = FX_PixelToB(fxMesa, pixel);
+                        *d++ = 255;
+                    }
+                    dst += dstStride;
+                    src -= srcStride;
+                }
+                result = GL_TRUE;
+            }
+            else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
+                /* directly memcpy 5R6G5B pixels into client's buffer */
+                const GLint widthInBytes = width * 2;
+                GLint row;
+                for (row = 0; row < height; row++) {
+                    MEMCPY(dst, src, widthInBytes);
+                    dst += dstStride;
+                    src -= srcStride;
+                }
+                result = GL_TRUE;
+            }
+            else {
+                result = GL_FALSE;
+            }
+
+            grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+        }
+        END_BOARD_LOCK(fxMesa);
+        return result;
+    }
+}
+
+
+
+static GLboolean
+readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
+                    GLsizei width, GLsizei height,
+                    GLenum format, GLenum type,
+                    const struct gl_pixelstore_attrib *packing,
+                    GLvoid * dstImage)
+{
+    if (!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8)
+     && !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)
+     && !(format == GL_RGBA && type == GL_UNSIGNED_BYTE)) {
+        return GL_FALSE;        /* format/type not optimised */
+    }
+
+    if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) {
+        return GL_FALSE;        /* can't do this */
+    }
+
+    {
+        fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+        GrLfbInfo_t info;
+        GLboolean result = GL_FALSE;
+
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+
+        BEGIN_BOARD_LOCK(fxMesa);
+        info.size = sizeof(info);
+        if (grLfbLock(GR_LFB_READ_ONLY,
+                      fxMesa->currentFB,
+                      GR_LFBWRITEMODE_ANY,
+                      GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+            const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+                ? (fxMesa->screen_width) : (info.strideInBytes / 4);
+            const GLuint *src = (const GLuint *) info.lfbPtr
+                + scrY * srcStride + scrX;
+            const GLint dstStride =
+                _mesa_image_row_stride(packing, width, format, type);
+            const GLubyte *dst = (GLubyte *) _mesa_image_address(packing,
+                dstImage, width, height, format, type, 0, 0, 0);
+
+            if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8)
+             || (format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
+                const GLint widthInBytes = width * 4;
+                GLint row;
+                for (row = 0; row < height; row++) {
+                    MEMCPY(dst, src, widthInBytes);
+                    dst += dstStride;
+                    src -= srcStride;
+                }
+                result = GL_TRUE;
+            } else
+            if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+                const GLint widthInBytes = width * 4;
+                GLuint *dstp = (GLuint *)dst;
+                GLint row;
+                GLint i;
+                for (row = 0; row < height; row++) {
+                    MEMCPY(dst, src, widthInBytes);
+                    dst += dstStride;
+                    src -= srcStride;
+                    /* Data is in memory in BGRA format */
+                    /* We need to swap R & B values */
+                    for (i = 0; i < width; i++, dstp++) {
+                        char *dstp0 = ((char *)(dstp)) + 0;
+                        char *dstp2 = ((char *)(dstp)) + 2;
+                        *dstp0 ^= *dstp2;
+                        *dstp2 ^= *dstp0;
+                        *dstp0 ^= *dstp2;
+                    }
+                }
+                result = GL_TRUE;
+            }
+
+            grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+        }
+        END_BOARD_LOCK(fxMesa);
+        return result;
+    }
+}
+
+
+
+static GLboolean
+drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
+                    GLsizei width, GLsizei height,
+                    GLenum format, GLenum type,
+                    const struct gl_pixelstore_attrib *unpack,
+                    const GLvoid * pixels)
+{
+    if (!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8)
+     && !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
+        return GL_FALSE;        /* format/type not optimised */
+    }
+
+    if (ctx->Pixel.ZoomX!=1.0F || ctx->Pixel.ZoomY!=1.0F) {
+        return GL_FALSE;        /* can't scale pixels */
+    }
+
+    if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) {
+        return GL_FALSE;        /* can't do this */
+    }
+
+    if (ctx->RasterMask) {
+       return GL_FALSE;         /* can't do any raster ops */
+    }
+
+    {
+        fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+        GrLfbInfo_t info;
+        GLboolean result = GL_FALSE;
+
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+
+        /* look for clipmasks, giveup if region obscured */
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            int i;
+            for (i = 0; i < fxMesa->numClipRects; i++) {
+                const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i];
+                
+                if (scrY < rect->y1 || scrY+height > rect->y2) {
+                    if (scrX < rect->x1 || scrX+width > rect->x2) {
+                        return GL_FALSE;    /* dst is obscured */
+                    }
+                }
+            }
+        }
+
+        BEGIN_BOARD_LOCK(fxMesa);
+        info.size = sizeof(info);
+        if (grLfbLock(GR_LFB_WRITE_ONLY,
+                      fxMesa->currentFB,
+                      GR_LFBWRITEMODE_8888, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+            const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+                ? (fxMesa->screen_width * 4) : (info.strideInBytes);
+            const GLubyte *dst = (const GLubyte *) info.lfbPtr
+                + scrY * dstStride + scrX * 4;
+            const GLint srcStride =
+                _mesa_image_row_stride(unpack, width, format, type);
+            const GLubyte *src = (GLubyte *) _mesa_image_address(unpack,
+                pixels, width, height, format, type, 0, 0, 0);
+
+            if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8)
+             || (format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
+                const GLint widthInBytes = width * 4;
+                GLint row;
+                for (row = 0; row < height; row++) {
+                    MEMCPY(dst, src, widthInBytes);
+                    dst -= dstStride;
+                    src += srcStride;
+                }
+                result = GL_TRUE;
+            }
+
+            grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+        }
+        END_BOARD_LOCK(fxMesa);
+        return result;
+    }
+}
+
+
+static GLboolean
+drawpixels_R8G8B8A8_v2(GLcontext * ctx, GLint x, GLint y,
+                    GLsizei width, GLsizei height,
+                    GLenum format, GLenum type,
+                    const struct gl_pixelstore_attrib *unpack,
+                    const GLvoid * pixels)
+{
+    if (!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8)
+     && !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
+        return GL_FALSE;        /* format/type not optimised */
+    }
+
+    if (ctx->Pixel.ZoomX!=1.0F || ctx->Pixel.ZoomY!=1.0F) {
+        return GL_FALSE;        /* can't scale pixels */
+    }
+
+    if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) {
+        return GL_FALSE;        /* can't do this */
+    }
+
+    if (ctx->RasterMask & (~BLEND_BIT)) {
+        return GL_FALSE;        /* can't do any raster ops, except blend */
+    }
+
+    {
+        fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+        GrLfbInfo_t info;
+        GLboolean result = GL_FALSE;
+
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+
+        /* look for clipmasks, giveup if region obscured */
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            int i;
+            for (i = 0; i < fxMesa->numClipRects; i++) {
+                const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i];
+                
+                if (scrY < rect->y1 || scrY+height > rect->y2) {
+                    if (scrX < rect->x1 || scrX+width > rect->x2) {
+                        return GL_FALSE;    /* dst is obscured */
+                    }
+                }
+            }
+        }
+
+        BEGIN_BOARD_LOCK(fxMesa);
+        info.size = sizeof(info);
+        if (grLfbLock(GR_LFB_WRITE_ONLY,
+                      fxMesa->currentFB,
+                      GR_LFBWRITEMODE_8888, GR_ORIGIN_UPPER_LEFT, FXTRUE, &info)) {
+            const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+                ? (fxMesa->screen_width * 4) : (info.strideInBytes);
+            const GLubyte *dst = (const GLubyte *) info.lfbPtr
+                + scrY * dstStride + scrX * 4;
+            const GLint srcStride =
+                _mesa_image_row_stride(unpack, width, format, type);
+            const GLubyte *src = (GLubyte *) _mesa_image_address(unpack,
+                pixels, width, height, format, type, 0, 0, 0);
+
+            void *grState = NULL;
+            GLint grSize;
+
+            if (grGet(GR_GLIDE_STATE_SIZE, sizeof(grSize), (void *) &grSize)) {
+                if ((grState = malloc(grSize)) != 0) {
+                    grGlideGetState(grState);
+                }
+            }
+
+            if (ctx->RasterMask & BLEND_BIT) {
+                grDisableAllEffects();
+                grAlphaBlendFunction(GR_BLEND_SRC_ALPHA,
+                                     GR_BLEND_ONE_MINUS_SRC_ALPHA,
+                                     GR_BLEND_ONE,
+                                     GR_BLEND_ZERO);
+                grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+                               GR_COMBINE_FACTOR_OTHER_ALPHA,
+                               GR_COMBINE_LOCAL_NONE,
+                               GR_COMBINE_OTHER_ITERATED,
+                               FXFALSE);
+                grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+                               GR_COMBINE_FACTOR_OTHER_ALPHA,
+                               GR_COMBINE_LOCAL_ITERATED,
+                               GR_COMBINE_OTHER_ITERATED,
+                               FXFALSE);
+            }
+
+            if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8)
+             || (format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
+                const GLint widthInBytes = width * 4;
+                GLint row;
+                for (row = 0; row < height; row++) {
+                    MEMCPY(dst, src, widthInBytes);
+                    dst -= dstStride;
+                    src += srcStride;
+                }
+                result = GL_TRUE;
+            }
+
+            if (grState) {
+                grGlideSetState(grState);
+                free(grState);
+            }
+
+            grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+        }
+        END_BOARD_LOCK(fxMesa);
+        return result;
+    }
+}
+
+
+static void
+fxDDFinish(GLcontext *ctx)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    FX_grFinish(fxMesa);
+}
+
+
+static void
+fxDDFlush(GLcontext *ctx)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    FX_grFlush(fxMesa);
+}
+
+
+static GLint
+fxDDGetParameteri(const GLcontext * ctx, GLint param)
+{
+    switch (param) {
+    case DD_HAVE_HARDWARE_FOG:
+        return 1;
+    default:
+        fprintf(stderr,
+                "fx Driver: internal error in fxDDGetParameteri(): %x\n",
+                (int) param);
+        return 0;
+    }
+}
+
+
+static void
+fxDDSetNearFar(GLcontext * ctx, GLfloat n, GLfloat f)
+{
+    FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+
+/* KW: Put the word Mesa in the render string because quakeworld
+ * checks for this rather than doing a glGet(GL_MAX_TEXTURE_SIZE).
+ * Why?
+ */
+static const GLubyte *
+fxDDGetString(GLcontext * ctx, GLenum name)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    switch (name) {
+    case GL_RENDERER:
+        {
+            static char buffer[100];
+            char hardware[100];
+            strcpy(hardware, FX_grGetString(fxMesa, GR_HARDWARE));
+            if (strcmp(hardware, "Voodoo3 (tm)") == 0)
+                strcpy(hardware, "Voodoo3");
+	    else if (strcmp(hardware, "Voodoo4 (tm)") == 0)
+	        strcpy(hardware, "Voodoo4");
+	    else if (strcmp(hardware, "Voodoo5 (tm)") == 0)
+	        strcpy(hardware, "Voodoo5");
+            else if (strcmp(hardware, "Voodoo Banshee (tm)") == 0)
+                strcpy(hardware, "VoodooBanshee");
+            else {
+                /* unexpected result: replace spaces with hyphens */
+                int i;
+                for (i = 0; hardware[i]; i++) {
+                    if (hardware[i] == ' ' || hardware[i] == '\t')
+                        hardware[i] = '-';
+                }
+            }
+            /* now make the GL_RENDERER string */
+            sprintf(buffer, "Mesa DRI %s 20001101", hardware);
+            return buffer;
+        }
+    case GL_VENDOR:
+        return "VA Linux Systems, Inc.";
+    default:
+        return NULL;
+    }
+}
+
+
+#if 0
+/* Example extension function */
+static void
+fxFooBarEXT(GLint i)
+{
+    printf("You called glFooBarEXT(%d)\n", i);
+}
+#endif
+
+
+
+/*
+ * Enable/Disable the extensions for this context.
+ */
+static void
+fxDDInitExtensions(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    gl_extensions_disable(ctx, "GL_EXT_blend_logic_op");
+    gl_extensions_disable(ctx, "GL_EXT_blend_minmax");
+    gl_extensions_disable(ctx, "GL_EXT_blend_subtract");
+    gl_extensions_disable(ctx, "GL_EXT_blend_color");
+    gl_extensions_disable(ctx, "GL_EXT_blend_func_separate");
+    gl_extensions_disable(ctx, "GL_INGR_blend_func_separate");
+    gl_extensions_enable(ctx, "GL_HP_occlusion_test");
+
+    if (!fxMesa->haveTwoTMUs)
+        gl_extensions_disable(ctx, "GL_EXT_texture_env_add");
+
+    if (!fxMesa->emulateTwoTMUs)
+        gl_extensions_disable(ctx, "GL_ARB_multitexture");
+
+    if (fxMesa->isNapalm) {
+        gl_extensions_enable(ctx, "GL_ARB_texture_compression");
+        gl_extensions_enable(ctx, "GL_3DFX_texture_compression_FXT1");
+        {
+            char *legacy_str = getenv("FX_GL_COMPRESS_LEGACY_TEXTURES");
+            if (!legacy_str || ((legacy_str[0] == '0')
+                                && (legacy_str[1] == '\0'))) {
+                gl_extensions_add(ctx, ALWAYS_ENABLED, "GL_S3_s3tc", 0);
+            }
+        }
+        gl_extensions_enable(ctx, "GL_EXT_texture_env_combine");
+    }
+
+    /* Example of hooking in an extension function.
+     * For DRI-based drivers, also see __driRegisterExtensions in the
+     * tdfx_xmesa.c file.
+     */
+#if 0
+    {
+        void **dispatchTable = (void **) ctx->Exec;
+        const int _gloffset_FooBarEXT = 555; /* just an example number! */
+        const int tabSize = _glapi_get_dispatch_table_size();
+        assert(_gloffset_FooBarEXT < tabSize);
+        dispatchTable[_gloffset_FooBarEXT] = (void *) fxFooBarEXT;
+        /* XXX You would also need to hook into the display list dispatch
+         * table.  Really, the implementation of extensions might as well
+         * be in the core of Mesa since core Mesa and the device driver
+         * is one big shared lib.
+         */
+    }
+#endif
+}
+
+
+
+/*
+ * Initialize the state in an fxMesaContext struct.
+ */
+int
+fxDDInitFxMesaContext(fxMesaContext fxMesa)
+{
+    /* Get Glide3 extension function pointers */
+    {
+        void *handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);
+        if (!handle) {
+            txImgQuantizePtr = NULL;
+            txImgDequantizeFXT1Ptr = NULL;
+            txErrorSetCallbackPtr = NULL;
+            grStencilFuncPtr = NULL;
+            grStencilMaskPtr = NULL;
+            grStencilOpPtr = NULL;
+            grBufferClearExtPtr = NULL;
+            grColorMaskExtPtr = NULL;
+            grColorCombineExtPtr = NULL;
+            grTexColorCombineExtPtr = NULL;
+            grAlphaCombineExtPtr = NULL;
+            grTexAlphaCombineExtPtr = NULL;
+            grAlphaBlendFunctionExtPtr = NULL;
+            grConstantColorValueExtPtr = NULL;
+            return 0;
+        }
+        else {
+           /*
+            * These are not exported by Glide.
+            */
+            txImgQuantizePtr = dlsym(handle, "txImgQuantize");
+            txImgDequantizeFXT1Ptr = dlsym(handle, "_txImgDequantizeFXT1");
+            txErrorSetCallbackPtr = dlsym(handle, "txErrorSetCallback");
+            grStencilFuncPtr = dlsym(handle, "grStencilFunc");
+            grStencilMaskPtr = dlsym(handle, "grStencilMask");
+            grStencilOpPtr = dlsym(handle, "grStencilOp");
+            grBufferClearExtPtr = dlsym(handle, "grBufferClearExt");
+            grColorMaskExtPtr = dlsym(handle, "grColorMaskExt");
+            grColorCombineExtPtr = dlsym(handle, "grColorCombineExt");
+            grTexColorCombineExtPtr = dlsym(handle, "grTexColorCombineExt");
+            grAlphaCombineExtPtr = dlsym(handle, "grAlphaCombineExt");
+            grTexAlphaCombineExtPtr = dlsym(handle, "grTexAlphaCombineExt");
+            grAlphaBlendFunctionExtPtr = dlsym(handle, "grAlphaBlendFunctionExt");
+            grConstantColorValueExtPtr = dlsym(handle, "grConstantColorValueExt");
+        }
+        dlclose(handle);
+    }
+
+    FX_setupGrVertexLayout(fxMesa);
+
+    if (getenv("FX_EMULATE_SINGLE_TMU"))
+        fxMesa->haveTwoTMUs = GL_FALSE;
+
+    fxMesa->emulateTwoTMUs = fxMesa->haveTwoTMUs;
+
+    if (!getenv("FX_DONT_FAKE_MULTITEX"))
+        fxMesa->emulateTwoTMUs = GL_TRUE;
+
+    if (getenv("FX_GLIDE_SWAPINTERVAL"))
+        fxMesa->swapInterval = atoi(getenv("FX_GLIDE_SWAPINTERVAL"));
+    else
+        fxMesa->swapInterval = 1;
+
+    if (getenv("MESA_FX_SWAP_PENDING"))
+        fxMesa->maxPendingSwapBuffers = atoi(getenv("MESA_FX_SWAP_PENDING"));
+    else
+        fxMesa->maxPendingSwapBuffers = 2;
+
+    if (getenv("MESA_FX_INFO"))
+        fxMesa->verbose = GL_TRUE;
+    else
+        fxMesa->verbose = GL_FALSE;
+
+#if 0
+    printf("haveTwoTMUs=%d  emulateTwoTMUs=%d\n", 
+           fxMesa->haveTwoTMUs, fxMesa->emulateTwoTMUs);
+#endif
+
+    fxMesa->depthClear = FX_grGetInteger(fxMesa, FX_ZDEPTH_MAX);
+
+    fxMesa->color = 0xffffffff;
+    fxMesa->clearC = 0;
+    fxMesa->clearA = 0;
+
+    fxMesa->stats.swapBuffer = 0;
+    fxMesa->stats.reqTexUpload = 0;
+    fxMesa->stats.texUpload = 0;
+    fxMesa->stats.memTexUpload = 0;
+
+    fxMesa->tmuSrc = FX_TMU_NONE;
+    fxTMInit(fxMesa);
+
+    /* FX units setup */
+    fxMesa->unitsState.alphaTestEnabled = GL_FALSE;
+    fxMesa->unitsState.alphaTestFunc = GR_CMP_ALWAYS;
+    fxMesa->unitsState.alphaTestRefValue = 0;
+
+    fxMesa->unitsState.blendEnabled = GL_FALSE;
+    fxMesa->unitsState.blendSrcFuncRGB = GR_BLEND_ONE;
+    fxMesa->unitsState.blendDstFuncRGB = GR_BLEND_ZERO;
+    fxMesa->unitsState.blendSrcFuncAlpha = GR_BLEND_ONE;
+    fxMesa->unitsState.blendDstFuncAlpha = GR_BLEND_ZERO;
+
+    /*
+       fxMesa->unitsState.depthTestEnabled = GL_FALSE;
+       fxMesa->unitsState.depthMask = GL_TRUE;
+       fxMesa->unitsState.depthTestFunc = GR_CMP_LESS;
+     */
+
+    FX_grColorMaskv(fxMesa->glCtx, true4);
+    if (fxMesa->glVis->DBflag) {
+        fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_BACKBUFFER);
+    }
+    else {
+        fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_FRONTBUFFER);
+    }
+
+    fxMesa->state = NULL;
+    fxMesa->fogTable = NULL;
+
+    fxMesa->state = malloc(FX_grGetInteger(fxMesa, FX_GLIDE_STATE_SIZE));
+    fxMesa->fogTable =
+       malloc(FX_grGetInteger(fxMesa, FX_FOG_TABLE_ENTRIES) * sizeof(GrFog_t));
+
+    if (!fxMesa->state || !fxMesa->fogTable) {
+        if (fxMesa->state)
+            free(fxMesa->state);
+        if (fxMesa->fogTable)
+            free(fxMesa->fogTable);
+        return 0;
+    }
+
+    if (fxMesa->glVis->DepthBits > 0)
+        FX_grDepthBufferMode(fxMesa, GR_DEPTHBUFFER_ZBUFFER);
+
+    FX_grLfbWriteColorFormat(fxMesa, GR_COLORFORMAT_ABGR);
+
+    fxMesa->textureAlign = FX_grGetInteger(fxMesa, FX_TEXTURE_ALIGN);
+    if (fxMesa->isNapalm) {
+       fxMesa->glCtx->Const.MaxTextureLevels = 12;
+       fxMesa->glCtx->Const.MaxTextureSize = 2048;
+       fxMesa->glCtx->Const.NumCompressedTextureFormats = 1;
+    }
+    else {
+       fxMesa->glCtx->Const.MaxTextureLevels = 9;
+       fxMesa->glCtx->Const.MaxTextureSize = 256;
+       fxMesa->glCtx->Const.NumCompressedTextureFormats = 0;
+    }
+    fxMesa->glCtx->Const.MaxTextureUnits = fxMesa->emulateTwoTMUs ? 2 : 1;
+    fxMesa->glCtx->NewState |= NEW_DRVSTATE1;
+    fxMesa->new_state = NEW_ALL;
+
+    fxDDSetupInit();
+    fxDDCvaInit();
+    fxDDClipInit();
+    fxDDTrifuncInit();
+    fxDDFastPathInit();
+
+    fxSetupDDPointers(fxMesa->glCtx);
+    fxDDRenderInit(fxMesa->glCtx);
+    fxDDInitExtensions(fxMesa->glCtx);
+
+    fxDDSetNearFar(fxMesa->glCtx, 1.0, 100.0);
+
+    FX_grGlideGetState(fxMesa, (GrState *) fxMesa->state);
+
+    /* XXX Fix me: callback not registered when main VB is created.
+     */
+    if (fxMesa->glCtx->VB)
+        fxDDRegisterVB(fxMesa->glCtx->VB);
+
+    /* XXX Fix me too: need to have the 'struct dd' prepared prior to
+     * creating the context... The below is broken if you try to insert
+     * new stages.  
+     */
+    if (fxMesa->glCtx->NrPipelineStages)
+        fxMesa->glCtx->NrPipelineStages =
+            fxDDRegisterPipelineStages(fxMesa->glCtx->PipelineStage,
+                                       fxMesa->glCtx->PipelineStage,
+                                       fxMesa->glCtx->NrPipelineStages);
+
+    /* this little bit ensures that all Glide state gets initialized */
+    fxMesa->new_state = NEW_ALL;
+    fxMesa->glCtx->Driver.RenderStart = fxSetupFXUnits;
+
+#if	defined(FX_PXCONV_TABULAR)
+    fxInitPixelTables(fxMesa, GL_FALSE); /* Load tables of pixel colors */
+#endif	/* FX_PXCONV_TABULAR */
+
+    /* Run the config file */
+    gl_context_initialize(fxMesa->glCtx);
+
+    return 1;
+}
+
+
+
+/* Check if the hardware supports the current context 
+ *
+ * Performs similar work to fxDDChooseRenderState() - should be merged.
+ */
+static GLboolean
+fxIsInHardware(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    if (!ctx->Hint.AllowDrawMem)
+        return GL_TRUE;         /* you'll take it and like it */
+
+    if (ctx->Color.BlendEnabled
+        && ctx->Color.BlendEquation != GL_FUNC_ADD_EXT) {
+        return GL_FALSE;
+    }
+
+    if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY) {
+        return GL_FALSE;
+    }
+
+    if (ctx->Light.Enabled &&
+        ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) {
+        return GL_FALSE;
+    }
+
+    if (ctx->Visual->RedBits < 8 &&
+        (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] ||
+         ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP])) {
+        /* can't individually mask R, G, B in 16bpp/Voodoo3 mode */
+        return GL_FALSE;
+    }
+       
+
+#if 000
+    if (
+        ((ctx->Color.BlendEnabled)
+         && (ctx->Color.BlendEquation != GL_FUNC_ADD_EXT))
+        || ((ctx->Color.ColorLogicOpEnabled)
+            && (ctx->Color.LogicOp != GL_COPY))
+        || (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+        ||
+        (!((ctx->Color.ColorMask[RCOMP] == ctx->Color.ColorMask[GCOMP])
+           && (ctx->Color.ColorMask[GCOMP] == ctx->Color.ColorMask[BCOMP])
+           && (ctx->Color.ColorMask[ACOMP] == ctx->Color.ColorMask[ACOMP])))
+        ) {
+        return GL_FALSE;
+    }
+#endif
+
+
+    /* Unsupported texture/multitexture cases */
+
+    if (fxMesa->emulateTwoTMUs) {
+        if ((ctx->Enabled & (TEXTURE0_3D | TEXTURE1_3D)) ||
+            /* Not very well written ... */
+            ((ctx->Enabled & (TEXTURE0_1D | TEXTURE1_1D)) &&
+             ((ctx->Enabled & (TEXTURE0_2D | TEXTURE1_2D)) !=
+              (TEXTURE0_2D | TEXTURE1_2D)))) {
+            return GL_FALSE;
+        }
+
+        if (ctx->Texture.ReallyEnabled & TEXTURE0_2D) {
+#if 0
+           if (ctx->Texture.Unit[0].EnvMode == GL_BLEND) {
+              return GL_FALSE;
+           }
+#endif
+            if (!fxMesa->isNapalm &&
+                ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
+                (ctx->Texture.ReallyEnabled & TEXTURE1_2D ||
+                 ctx->Texture.Unit[0].EnvColor[0] != 0 ||
+                 ctx->Texture.Unit[0].EnvColor[1] != 0 ||
+                 ctx->Texture.Unit[0].EnvColor[2] != 0 ||
+                 ctx->Texture.Unit[0].EnvColor[3] != 1)) {
+                return GL_FALSE;
+            }
+            if (ctx->Texture.Unit[0].Current->Image[0]->Border > 0)
+                return GL_FALSE;
+        }
+
+        if (ctx->Texture.ReallyEnabled & TEXTURE1_2D) {
+            if (!fxMesa->isNapalm && ctx->Texture.Unit[1].EnvMode == GL_BLEND)
+                return GL_FALSE;
+            if (ctx->Texture.Unit[1].Current->Image[0]->Border > 0)
+                return GL_FALSE;
+        }
+
+        if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+            fprintf(stderr, "fxMesa: fxIsInHardware, envmode is %s/%s\n",
+                    gl_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
+                    gl_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
+
+        /* KW: This was wrong (I think) and I changed it... which doesn't mean
+         * it is now correct...
+         */
+        if ((ctx->Enabled & (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D)) &&
+            (ctx->Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D))) {
+            /* Can't use multipass to blend a multitextured triangle - fall
+               * back to software.
+             */
+            if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) {
+                return GL_FALSE;
+            }
+
+            if ((ctx->Texture.Unit[0].EnvMode != ctx->Texture.Unit[1].EnvMode)
+                && (ctx->Texture.Unit[0].EnvMode != GL_MODULATE)
+                && (ctx->Texture.Unit[0].EnvMode != GL_REPLACE)) { /* q2, seems ok... */
+                if (MESA_VERBOSE & VERBOSE_DRIVER)
+                    fprintf(stderr,
+                            "fxMesa: unsupported multitex env mode\n");
+                return GL_FALSE;
+            }
+        }
+    }
+    else {
+        if ((ctx->Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D)) ||
+            /* Not very well written ... */
+            ((ctx->Enabled & TEXTURE0_1D) && (!(ctx->Enabled & TEXTURE0_2D)))
+            ) {
+            return GL_FALSE;
+        }
+
+
+        if (!fxMesa->isNapalm && (ctx->Texture.ReallyEnabled & TEXTURE0_2D) &&
+            (ctx->Texture.Unit[0].EnvMode == GL_BLEND)) {
+            return GL_FALSE;
+        }
+    }
+
+    if (ctx->Stencil.Enabled && !fxMesa->haveHwStencil)
+        return GL_FALSE;
+
+    return GL_TRUE;
+}
+
+
+
+#define INTERESTED (~(NEW_MODELVIEW|NEW_PROJECTION|NEW_PROJECTION|NEW_TEXTURE_MATRIX|NEW_USER_CLIP|NEW_CLIENT_STATE|NEW_TEXTURE_ENABLE))
+
+static void
+fxDDUpdateDDPointers(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint new_state = ctx->NewState;
+
+    if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_STATE))
+        fprintf(stderr, "fxmesa: fxDDUpdateDDPointers(...)\n");
+
+    if (new_state & (NEW_RASTER_OPS | NEW_TEXTURING))
+        fxMesa->is_in_hardware = fxIsInHardware(ctx);
+
+    if (fxMesa->is_in_hardware) {
+        if (fxMesa->new_state)
+            fxSetupFXUnits(ctx);
+
+        if (new_state & INTERESTED) {
+            fxDDChooseRenderState(ctx);
+            fxMesa->RenderVBTables = fxDDChooseRenderVBTables(ctx);
+            fxMesa->RenderVBClippedTab = fxMesa->RenderVBTables[0];
+            fxMesa->RenderVBCulledTab = fxMesa->RenderVBTables[1];
+            fxMesa->RenderVBRawTab = fxMesa->RenderVBTables[2];
+
+            ctx->Driver.RasterSetup = fxDDChooseSetupFunction(ctx);
+        }
+
+        ctx->Driver.PointsFunc = fxMesa->PointsFunc;
+        ctx->Driver.LineFunc = fxMesa->LineFunc;
+        ctx->Driver.TriangleFunc = fxMesa->TriangleFunc;
+        ctx->Driver.QuadFunc = fxMesa->QuadFunc;
+    }
+    else {
+        fxMesa->render_index = FX_FALLBACK;
+    }
+}
+
+static void
+fxDDReducedPrimitiveChange(GLcontext * ctx, GLenum prim)
+{
+    if (ctx->Polygon.CullFlag) {
+        if (ctx->PB->primitive != GL_POLYGON) { /* Lines or Points */
+            fxMesaContext fxMesa = FX_CONTEXT(ctx);
+            FX_grCullMode(fxMesa, GR_CULL_DISABLE);
+            fxMesa->cullMode = GR_CULL_DISABLE;
+        }
+    }
+}
+
+
+void
+fxSetupDDPointers(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxSetupDDPointers()\n");
+    }
+    ctx->Driver.UpdateState = fxDDUpdateDDPointers;
+    ctx->Driver.ClearIndex = NULL;
+    ctx->Driver.ClearColor = fxDDClearColor;
+    ctx->Driver.Clear = fxDDClear;
+    ctx->Driver.Index = NULL;
+    ctx->Driver.Color = fxDDSetColor;
+    ctx->Driver.SetDrawBuffer = fxDDSetDrawBuffer;
+    ctx->Driver.SetReadBuffer = fxDDSetReadBuffer;
+    ctx->Driver.GetBufferSize = fxDDBufferSize;
+    ctx->Driver.Finish = fxDDFinish;
+    ctx->Driver.Flush = fxDDFlush;
+    ctx->Driver.GetString = fxDDGetString;
+    ctx->Driver.NearFar = fxDDSetNearFar;
+    ctx->Driver.GetParameteri = fxDDGetParameteri;
+    ctx->Driver.GetBooleanv = fxDDGetBooleanv;
+    ctx->Driver.GetFloatv = fxDDGetFloatv;
+    ctx->Driver.GetDoublev = fxDDGetDoublev;
+    ctx->Driver.GetIntegerv = fxDDGetIntegerv;
+
+    if (ctx->Visual->RedBits == 8 &&
+        ctx->Visual->GreenBits == 8 &&
+        ctx->Visual->BlueBits == 8 &&
+        ctx->Visual->AlphaBits == 8) {
+        ctx->Driver.Bitmap = bitmap_R8G8B8A8;
+        ctx->Driver.DrawPixels = drawpixels_R8G8B8A8;
+        ctx->Driver.ReadPixels = readpixels_R8G8B8A8;
+    }
+    else if (ctx->Visual->RedBits == 5 &&
+             ctx->Visual->GreenBits == 6 &&
+             ctx->Visual->BlueBits == 5 &&
+             ctx->Visual->AlphaBits == 0) {
+        ctx->Driver.Bitmap = bitmap_R5G6B5;
+        ctx->Driver.DrawPixels = NULL;
+        ctx->Driver.ReadPixels = readpixels_R5G6B5;
+    }
+    else {
+        ctx->Driver.Bitmap = NULL;
+        ctx->Driver.DrawPixels = NULL;
+        ctx->Driver.ReadPixels = NULL;
+    }
+
+    ctx->Driver.RenderStart = NULL;
+    ctx->Driver.RenderFinish = NULL;
+
+    ctx->Driver.TexImage2D = fxDDTexImage2D;
+    ctx->Driver.TexSubImage2D = fxDDTexSubImage2D;
+    ctx->Driver.TestProxyTexImage = fxDDTestProxyTexImage;
+    ctx->Driver.GetTexImage = fxDDGetTexImage;
+    ctx->Driver.CompressedTexImage2D = fxDDCompressedTexImage2D;
+    ctx->Driver.CompressedTexSubImage2D = fxDDCompressedTexSubImage2D;
+    ctx->Driver.GetCompressedTexImage = fxDDGetCompressedTexImage;
+    ctx->Driver.SpecificCompressedTexFormat = fxDDSpecificCompressedTexFormat;
+    ctx->Driver.BaseCompressedTexFormat = fxDDBaseCompressedTexFormat;
+    ctx->Driver.IsCompressedFormat = fxDDIsCompressedFormat;
+    ctx->Driver.CompressedImageSize = fxDDCompressedImageSize;
+    ctx->Driver.TexEnv = fxDDTexEnv;
+    ctx->Driver.TexParameter = fxDDTexParam;
+    ctx->Driver.BindTexture = fxDDTexBind;
+    ctx->Driver.DeleteTexture = fxDDTexDel;
+    ctx->Driver.IsTextureResident = fxDDIsTextureResident;
+    ctx->Driver.UpdateTexturePalette = fxDDTexPalette;
+
+    ctx->Driver.RectFunc = NULL;
+
+    if (fxMesa->haveHwStencil) {
+        ctx->Driver.StencilFunc = fxDDStencilFunc;
+        ctx->Driver.StencilMask = fxDDStencilMask;
+        ctx->Driver.StencilOp = fxDDStencilOp;
+    }
+
+    ctx->Driver.AlphaFunc = fxDDAlphaFunc;
+    ctx->Driver.BlendFunc = fxDDBlendFunc;
+    ctx->Driver.BlendFuncSeparate = fxDDBlendFuncSeparate;
+    ctx->Driver.DepthFunc = fxDDDepthFunc;
+    ctx->Driver.DepthMask = fxDDDepthMask;
+    ctx->Driver.ColorMask = fxDDColorMask;
+    ctx->Driver.Fogfv = fxDDFogfv;
+    ctx->Driver.Scissor = fxDDScissor;
+    ctx->Driver.FrontFace = fxDDFrontFace;
+    ctx->Driver.CullFace = fxDDCullFace;
+    ctx->Driver.ShadeModel = fxDDShadeModel;
+    ctx->Driver.Enable = fxDDEnable;
+    ctx->Driver.ReducedPrimitiveChange = fxDDReducedPrimitiveChange;
+
+    ctx->Driver.RegisterVB = fxDDRegisterVB;
+    ctx->Driver.UnregisterVB = fxDDUnregisterVB;
+
+    ctx->Driver.RegisterPipelineStages = fxDDRegisterPipelineStages;
+
+    ctx->Driver.OptimizeImmediatePipeline = 0; /* nothing done yet */
+    ctx->Driver.OptimizePrecalcPipeline = 0;
+
+/*    if (getenv("MESA_USE_FAST") || getenv("FX_USE_FAST")) */
+/*       ctx->Driver.OptimizePrecalcPipeline = fxDDOptimizePrecalcPipeline; */
+
+    if (!getenv("FX_NO_FAST"))
+        ctx->Driver.BuildPrecalcPipeline = fxDDBuildPrecalcPipeline;
+
+    ctx->Driver.TriangleCaps =
+        DD_TRI_CULL | DD_TRI_OFFSET | DD_TRI_LIGHT_TWOSIDE;
+
+    fxSetupDDSpanPointers(ctx);
+
+    FX_CONTEXT(ctx)->render_index = 1; /* force an update */
+    fxDDUpdateDDPointers(ctx);
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxddspan.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxddspan.c:1.7
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxddspan.c	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,2080 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxddspan.c,v 1.7 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
+
+
+#include "fxdrv.h"
+
+/*
+ * Examine the cliprects to generate an array of flags to indicate
+ * which pixels in a span are visible.  Note: (x,y) is a screen
+ * coordinate.
+ */
+static void
+generate_vismask(const fxMesaContext fxMesa, GLint x, GLint y, GLint n,
+                 GLubyte vismask[])
+{
+    GLboolean initialized = GL_FALSE;
+    GLint i, j;
+
+    /* Ensure we clear the visual mask */
+    MEMSET(vismask, 0, n);
+
+    /* turn on flags for all visible pixels */
+    for (i = 0; i < fxMesa->numClipRects; i++) {
+        const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i];
+
+        if (y >= rect->y1 && y < rect->y2) {
+            if (x >= rect->x1 && x + n <= rect->x2) {
+                /* common case, whole span inside cliprect */
+                MEMSET(vismask, 1, n);
+                return;
+            }
+            if (x < rect->x2 && x + n >= rect->x1) {
+                /* some of the span is inside the rect */
+                GLint start, end;
+                if (!initialized) {
+                    MEMSET(vismask, 0, n);
+                    initialized = GL_TRUE;
+                }
+                if (x < rect->x1)
+                    start = rect->x1 - x;
+                else
+                    start = 0;
+                if (x + n > rect->x2)
+                    end = rect->x2 - x;
+                else
+                    end = n;
+                assert(start >= 0);
+                assert(end <= n);
+                for (j = start; j < end; j++)
+                    vismask[j] = 1;
+            }
+        }
+    }
+}
+
+/*
+ * Examine cliprects and determine if the given screen pixel is visible.
+ */
+static GLboolean
+visible_pixel(const fxMesaContext fxMesa, int scrX, int scrY)
+{
+    int i;
+    for (i = 0; i < fxMesa->numClipRects; i++) {
+        const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i];
+        if (scrX >= rect->x1 &&
+            scrX < rect->x2 &&
+            scrY >= rect->y1 && scrY < rect->y2) return GL_TRUE;
+    }
+    return GL_FALSE;
+}
+
+/*
+ * 16bpp span/pixel functions
+ */
+static void
+write_R5G6B5_rgba_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                       const GLubyte rgba[][4], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GrLfbInfo_t info;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: write_R5G6B5_rgba_span\n");
+    }
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY,
+                  fxMesa->currentFB,
+                  GR_LFBWRITEMODE_565,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+        const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+            ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+        GLushort *data16 = (GLushort *) info.lfbPtr + scrY * srcStride + scrX;
+        GLuint i;
+
+        if (mask) {
+            for (i = 0; i < n; i++) {
+                if (visible_pixel(fxMesa, scrX + i, scrY) && mask[i]) {
+                    GLushort pixel;
+                    if (fxMesa->bgrOrder) {
+                        pixel = PACK_BGR16(rgba[i][0],
+                                           rgba[i][1],
+                                           rgba[i][2]);
+                    } else {
+                        pixel = PACK_RGB16(rgba[i][0],
+                                           rgba[i][1],
+                                           rgba[i][2]);
+                    }
+                    data16[i] = pixel;
+                }
+            }
+        } else {
+            for (i = 0; i < n; i++) {
+                if (visible_pixel(fxMesa, scrX + i, scrY)) {
+                    GLushort pixel;
+
+                    if (fxMesa->bgrOrder) {
+                        pixel = PACK_BGR16(rgba[i][0],
+                                           rgba[i][1],
+                                           rgba[i][2]);
+                    } else {
+                        pixel = PACK_RGB16(rgba[i][0],
+                                           rgba[i][1],
+                                           rgba[i][2]);
+                    }
+                    data16[i] = pixel;
+                }
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+static void
+write_R5G6B5_rgb_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                      const GLubyte rgb[][3], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GrLfbInfo_t info;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: write_R5G6B5_rgb_span\n");
+    }
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY,
+                  fxMesa->currentFB,
+                  GR_LFBWRITEMODE_565,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+        const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+            ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+        GLushort *data16 = (GLushort *) info.lfbPtr + scrY * srcStride + scrX;
+        GLuint i;
+
+        if (mask) {
+            for (i = 0; i < n; i++) {
+                if (visible_pixel(fxMesa, scrX + i, scrY) && mask[i]) {
+                    GLushort pixel;
+                    if (fxMesa->bgrOrder) {
+                        pixel = PACK_BGR16(rgb[i][0],
+                                           rgb[i][1],
+                                           rgb[i][2]);
+                    } else {
+                        pixel = PACK_RGB16(rgb[i][0],
+                                           rgb[i][1],
+                                           rgb[i][2]);
+                    }
+                    data16[i] = pixel;
+                }
+            }
+        } else {
+            for (i = 0; i < n; i++) {
+                if (visible_pixel(fxMesa, scrX + i, scrY)) {
+                    GLushort pixel;
+                    if (fxMesa->bgrOrder) {
+                        pixel = PACK_BGR16(rgb[i][0],
+                                           rgb[i][1],
+                                           rgb[i][2]);
+                    } else {
+                        pixel = PACK_RGB16(rgb[i][0],
+                                           rgb[i][1],
+                                           rgb[i][2]);
+                    }
+                    data16[i] = pixel;
+                }
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+static void
+write_R5G6B5_mono_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                       const GLubyte mask[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GrLfbInfo_t info;
+    GLubyte *constantColor = (GLubyte *)(&fxMesa->color);
+    GLushort pixel;
+
+    if (fxMesa->bgrOrder) {
+        pixel = PACK_BGR16(constantColor[0],
+                           constantColor[1],
+                           constantColor[2]);
+    } else {
+        pixel = PACK_RGB16(constantColor[0],
+                           constantColor[1],
+                           constantColor[2]);
+    }
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: write_r5g6b5_mono_span\n");
+    }
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY,
+                  fxMesa->currentFB,
+                  GR_LFBWRITEMODE_565,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+        const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+            ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+        GLushort *data16 = (GLushort *) info.lfbPtr
+            + scrY * srcStride + scrX;
+        GLuint i;
+
+        if (mask) {
+            for (i = 0; i < n; i++) {
+                if (visible_pixel(fxMesa, scrX + i, scrY) && mask[i]) {
+                    data16[i] = pixel;
+                }
+            }
+        } else {
+            for (i = 0; i < n; i++) {
+                if (visible_pixel(fxMesa, scrX + i, scrY)) {
+                    data16[i] = pixel;
+                }
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+/*
+ * Read a span of 16-bit RGB pixels.  Note, we don't worry about cliprects
+ * since OpenGL says obscured pixels have undefined values.
+ */
+static void
+read_R5G6B5_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                 GLubyte rgba[][4])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_READ_ONLY,
+                  fxMesa->currentFB,
+                  GR_LFBWRITEMODE_ANY,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+            ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+        const GLushort *data16 = (const GLushort *) info.lfbPtr
+            + (winY - y) * srcStride + (winX + x);
+        GLuint i, j;
+        GLuint extraPixel = (n & 1);
+        n -= extraPixel;
+        for (i = j = 0; i < n; i += 2, j++) {
+	    /* use data16[] to keep correct alignment */
+            GLuint pixel0 = data16[i];
+            GLuint pixel1 = data16[i+1];
+            rgba[i][RCOMP] = FX_PixelToR(fxMesa, pixel0);
+            rgba[i][GCOMP] = FX_PixelToG(fxMesa, pixel0);
+            rgba[i][BCOMP] = FX_PixelToB(fxMesa, pixel0);
+            rgba[i][ACOMP] = 255;
+            rgba[i + 1][RCOMP] = FX_PixelToR(fxMesa, pixel1);
+            rgba[i + 1][GCOMP] = FX_PixelToG(fxMesa, pixel1);
+            rgba[i + 1][BCOMP] = FX_PixelToB(fxMesa, pixel1);
+            rgba[i + 1][ACOMP] = 255;
+        }
+        if (extraPixel) {
+            GLushort pixel = data16[n];
+            rgba[n][RCOMP] = FX_PixelToR(fxMesa, pixel);
+            rgba[n][GCOMP] = FX_PixelToG(fxMesa, pixel);
+            rgba[n][BCOMP] = FX_PixelToB(fxMesa, pixel);
+            rgba[n][ACOMP] = 255;
+        }
+        grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+static void
+write_R5G6B5_pixels(const GLcontext * ctx,
+                    GLuint n, const GLint x[], const GLint y[],
+                    CONST GLubyte rgba[][4], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GrLfbInfo_t info;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: write_R5G6B5_pixels\n");
+    }
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY,
+                  fxMesa->currentFB,
+                  GR_LFBWRITEMODE_565,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+            ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+        GLuint i;
+
+        for (i = 0; i < n; i++) {
+            GLint scrX = winX + x[i];
+            GLint scrY = winY - y[i];
+            if (visible_pixel(fxMesa, scrX, scrY) && mask[i]) {
+                GLushort *data16 = (GLushort *) info.lfbPtr
+                    + scrY * srcStride + scrX;
+                GLushort pixel;
+                if (fxMesa->bgrOrder) {
+                    pixel = PACK_BGR16(rgba[i][0],
+                                       rgba[i][1],
+                                       rgba[i][2]);
+                } else {
+                    pixel = PACK_RGB16(rgba[i][0],
+                                       rgba[i][1],
+                                       rgba[i][2]);
+                }
+                data16[0] = pixel;
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+static void
+write_R5G6B5_mono_pixels(const GLcontext * ctx,
+                         GLuint n, const GLint x[], const GLint y[],
+                         const GLubyte mask[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GrLfbInfo_t info;
+    GLubyte *constantColor = (GLubyte *)(&fxMesa->color);
+    GLushort pixel;
+
+    if (fxMesa->bgrOrder) {
+        pixel = PACK_BGR16(constantColor[0],
+                           constantColor[1],
+                           constantColor[2]);
+    } else {
+        pixel = PACK_RGB16(constantColor[0],
+                           constantColor[1],
+                           constantColor[2]);
+    }
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: write_R5G6B5_mono_pixels\n");
+    }
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY,
+                  fxMesa->currentFB,
+                  GR_LFBWRITEMODE_565,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+            ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+        GLuint i;
+
+        for (i = 0; i < n; i++) {
+            GLint scrX = winX + x[i];
+            GLint scrY = winY - y[i];
+            if (visible_pixel(fxMesa, scrX, scrY) && mask[i]) {
+                GLushort *data16 = (GLushort *) info.lfbPtr
+                    + scrY * srcStride + scrX;
+                data16[0] = pixel;
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+static void
+read_R5G6B5_pixels(const GLcontext * ctx,
+                   GLuint n, const GLint x[], const GLint y[],
+                   GLubyte rgba[][4], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_READ_ONLY,
+                  fxMesa->currentFB,
+                  GR_LFBWRITEMODE_ANY,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winX = fxMesa->x_offset;
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+            ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+        GLuint i;
+        for (i = 0; i < n; i++) {
+            if (mask[i]) {
+               const GLushort *data16 = (const GLushort *) info.lfbPtr
+                  + (winY - y[i]) * srcStride + (winX + x[i]);
+               GLushort pixel = *data16;
+               rgba[i][RCOMP] = FX_PixelToR(fxMesa, pixel);
+               rgba[i][GCOMP] = FX_PixelToG(fxMesa, pixel);
+               rgba[i][BCOMP] = FX_PixelToB(fxMesa, pixel);
+               rgba[i][ACOMP] = 255;
+            }
+        }
+        grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+/*
+ * 24bpp span/pixel functions
+ */
+
+static void
+write_R8G8B8_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y,
+                      const GLubyte rgb[][3], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbWriteMode_t mode;
+    GrLfbInfo_t info;
+
+    if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+        mode = GR_LFBWRITEMODE_888;
+    else
+        mode = GR_LFBWRITEMODE_888;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY,
+                  fxMesa->currentFB,
+                  mode, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            /*GLint dstStride = fxMesa->screen_width * 3; */
+            GLint dstStride = info.strideInBytes / 1;
+            GLubyte *dst = (GLubyte *) info.lfbPtr
+                + (winY - y) * dstStride + (winX + x) * 1;
+            GLuint *dst32 = (GLuint *) dst;
+            GLubyte visMask[MAX_WIDTH];
+            GLuint i;
+            generate_vismask(fxMesa, scrX, scrY, n, visMask);
+            for (i = 0; i < n; i++) {
+                if (visMask[i] && (!mask || mask[i])) {
+                    dst32[i] =
+                        PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+                }
+            }
+        }
+        else {
+            /* back buffer */
+            GLint dstStride = info.strideInBytes;
+            GLubyte *dst = (GLubyte *) info.lfbPtr
+                + (winY - y) * dstStride + (winX + x) * 4;
+            GLuint *dst32 = (GLuint *) dst;
+            if (mask) {
+                GLuint i;
+                for (i = 0; i < n; i++) {
+                    if (mask[i]) {
+                        dst32[i] =
+                            PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+                    }
+                }
+            }
+            else {
+                GLuint i;
+                for (i = 0; i < n; i++) {
+                    dst32[i] =
+                        PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+                }
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+
+static void
+write_R8G8B8_rgba_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                       const GLubyte rgba[][4], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbWriteMode_t mode;
+    GrLfbInfo_t info;
+
+    if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+        mode = GR_LFBWRITEMODE_8888;
+    else
+        mode = GR_LFBWRITEMODE_888;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY,
+                  fxMesa->currentFB,
+                  mode, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            /* XXX have to do cliprect clipping! */
+            GLint dstStride = fxMesa->screen_width * 4;
+            GLubyte *dst = (GLubyte *) info.lfbPtr
+                + (winY - y) * dstStride + (winX + x) * 4;
+            GLuint *dst32 = (GLuint *) dst;
+            GLubyte visMask[MAX_WIDTH];
+            GLuint i;
+            generate_vismask(fxMesa, scrX, scrY, n, visMask);
+            for (i = 0; i < n; i++) {
+                if (visMask[i] && (!mask || mask[i])) {
+                    dst32[i] =
+                        PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2],
+                                    rgba[i][3]);
+                }
+            }
+        }
+        else {
+            /* back buffer */
+            GLint dstStride = info.strideInBytes;
+            GLubyte *dst = (GLubyte *) info.lfbPtr
+                + (winY - y) * dstStride + (winX + x) * 4;
+            if (mask) {
+                const GLuint *src32 = (const GLuint *) rgba;
+                GLuint *dst32 = (GLuint *) dst;
+                GLuint i;
+                for (i = 0; i < n; i++) {
+                    if (mask[i]) {
+                        dst32[i] = src32[i];
+                    }
+                }
+            }
+            else {
+                /* no mask, write all pixels */
+                MEMCPY(dst, rgba, 4 * n);
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+static void
+write_R8G8B8_mono_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                       const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GLubyte rgba[MAX_WIDTH][4];
+    GLuint *data = (GLuint *) rgba;
+    GLuint i;
+
+    /* XXX this is a simple-minded implementation but good enough for now */
+    for (i = 0; i < n; i++) {
+        data[i] = (GLuint) fxMesa->color;
+    }
+    write_R8G8B8_rgba_span(ctx, n, x, y, (const GLubyte(*)[4]) rgba, mask);
+}
+
+
+static void
+read_R8G8B8_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                 GLubyte rgba[][4])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB, GR_LFBWRITEMODE_8888,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            GLint srcStride = fxMesa->screen_width * 4;
+            const GLubyte *src = (const GLubyte *) info.lfbPtr
+                + (winY - y) * srcStride + (winX + x) * 4;
+            GLuint i;
+            for (i = 0; i < n; i++) {
+                rgba[i][0] = src[i * 4 + 2];
+                rgba[i][1] = src[i * 4 + 1];
+                rgba[i][2] = src[i * 4 + 0];
+                rgba[i][3] = src[i * 4 + 3];
+            }
+        }
+        else {
+            /* back buffer */
+            GLint srcStride = info.strideInBytes / 2;
+            const GLubyte *src = (const GLubyte *) info.lfbPtr
+                + (winY - y) * srcStride + (winX + x) * 4;
+            GLuint i;
+            for (i = 0; i < n; i++) {
+                rgba[i][0] = src[i * 4 + 2];
+                rgba[i][1] = src[i * 4 + 1];
+                rgba[i][2] = src[i * 4 + 0];
+                rgba[i][3] = src[i * 4 + 3];
+            }
+        }
+        grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+static void
+write_R8G8B8_pixels(const GLcontext * ctx,
+                    GLuint n, const GLint x[], const GLint y[],
+                    CONST GLubyte rgba[][4], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbWriteMode_t mode;
+    GrLfbInfo_t info;
+
+    if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
+        mode = GR_LFBWRITEMODE_8888;
+    else
+        mode = GR_LFBWRITEMODE_888 /*565 */ ;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY,
+                  fxMesa->currentFB,
+                  mode, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            GLuint i;
+            for (i = 0; i < n; i++) {
+                const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+                const GLint winX = fxMesa->x_offset;
+                const GLint scrX = winX + x[i];
+                const GLint scrY = winY - y[i];
+                if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
+                    GLint dstStride = fxMesa->screen_width * 4;
+                    GLubyte *dst =
+                        (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
+                    GLuint *dst32 = (GLuint *) dst;
+                    *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1],
+                                         rgba[i][2], rgba[i][3]);
+                }
+            }
+        }
+        else {
+            /* back buffer */
+            GLuint i;
+            for (i = 0; i < n; i++) {
+                const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+                const GLint winX = fxMesa->x_offset;
+                const GLint scrX = winX + x[i];
+                const GLint scrY = winY - y[i];
+                if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
+                    GLint dstStride = info.strideInBytes;
+                    GLubyte *dst =
+                        (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
+                    GLuint *dst32 = (GLuint *) dst;
+                    *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1],
+                                         rgba[i][2], rgba[i][3]);
+                }
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+static void
+write_R8G8B8_mono_pixels(const GLcontext * ctx,
+                         GLuint n, const GLint x[], const GLint y[],
+                         const GLubyte mask[])
+{
+    printf("write_r8g8b8_mono_pixels\n");
+}
+
+
+static void
+read_R8G8B8_pixels(const GLcontext * ctx,
+                   GLuint n, const GLint x[], const GLint y[],
+                   GLubyte rgba[][4], const GLubyte mask[])
+{
+    printf("read_R8G8B8_pixels %d\n", n);
+}
+
+
+
+/*
+ * 32bpp span/pixel functions
+ */
+
+static void
+write_R8G8B8A8_rgb_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                        const GLubyte rgb[][3], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY, fxMesa->currentFB, GR_LFBWRITEMODE_8888,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+        GLubyte visMask[MAX_WIDTH];
+
+        generate_vismask(fxMesa, scrX, scrY, n, visMask);
+
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            GLint dstStride = fxMesa->screen_width * 4;
+            GLubyte *dst = (GLubyte *) info.lfbPtr
+                + (winY - y) * dstStride + (winX + x) * 4;
+            GLuint *dst32 = (GLuint *) dst;
+            GLuint i;
+            for (i = 0; i < n; i++) {
+                if (visMask[i] && (!mask || mask[i])) {
+                    dst32[i] =
+                       PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+                }
+            }
+        }
+        else {
+            /* back buffer */
+            GLint dstStride = info.strideInBytes;
+            GLubyte *dst = (GLubyte *) info.lfbPtr
+                + (winY - y) * dstStride + (winX + x) * 4;
+            GLuint *dst32 = (GLuint *) dst;
+            if (mask) {
+                GLuint i;
+                for (i = 0; i < n; i++) {
+                    if (visMask[i] && mask[i]) {
+                        dst32[i] =
+                            PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255);
+                    }
+                }
+            }
+            else {
+                GLuint i;
+                for (i = 0; i < n; i++) {
+                    if (visMask[i]) {
+                        dst32[i] = PACK_BGRA32(rgb[i][0], rgb[i][1],
+                                               rgb[i][2], 255);
+                    }
+                }
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+/*
+ *XXX test of grLfbWriteRegion in 32bpp mode.  Doesn't seem to work!
+ */
+#if 0
+static void
+write_R8G8B8A8_rgb_span2(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                         const GLubyte rgb[][3], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+    GLint x2 = fxMesa->x_offset + x;
+    GLint y2 = bottom - y;
+
+    FX_grLfbWriteRegion(fxMesa->currentFB, x2, y2, GR_LFB_SRC_FMT_888,
+                        n, 1, 0, rgb);
+}
+#endif
+
+
+static void
+write_R8G8B8A8_rgba_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                         const GLubyte rgba[][4], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY, fxMesa->currentFB, GR_LFBWRITEMODE_8888,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+        GLubyte visMask[MAX_WIDTH];
+
+        generate_vismask(fxMesa, scrX, scrY, n, visMask);
+
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            GLint dstStride = fxMesa->screen_width * 4;
+            GLubyte *dst = (GLubyte *) info.lfbPtr
+                + (winY - y) * dstStride + (winX + x) * 4;
+            GLuint *dst32 = (GLuint *) dst;
+            GLuint i;
+            for (i = 0; i < n; i++) {
+                if (visMask[i] && (!mask || mask[i])) {
+                    dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2],
+                                           rgba[i][3]);
+                }
+            }
+        }
+        else {
+            /* back buffer */
+            GLint dstStride = info.strideInBytes;
+            GLubyte *dst = (GLubyte *) info.lfbPtr
+                + (winY - y) * dstStride + (winX + x) * 4;
+            GLuint *dst32 = (GLuint *) dst;
+            GLubyte visMask[MAX_WIDTH];
+            generate_vismask(fxMesa, scrX, scrY, n, visMask);
+            if (mask) {
+                GLuint i;
+                for (i = 0; i < n; i++) {
+                    if (visMask[i] && mask[i]) {
+                        dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1],
+                                               rgba[i][2], rgba[i][3]);
+                    }
+                }
+            }
+            else {
+                /* no mask, write all pixels */
+                GLuint i;
+                for (i = 0; i < n; i++) {
+                   if (visMask[i]) {
+                       dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1],
+                                              rgba[i][2], rgba[i][3]);
+                   }
+                }
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    else {
+        info.strideInBytes = -1;
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+static void
+write_R8G8B8A8_mono_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                         const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GLubyte rgba[MAX_WIDTH][4];
+    GLuint *data = (GLuint *) rgba;
+    GLuint i;
+
+    /* XXX this is a simple-minded implementation but good enough for now */
+    for (i = 0; i < n; i++) {
+        data[i] = (GLuint) fxMesa->color;
+    }
+    write_R8G8B8A8_rgba_span(ctx, n, x, y, (const GLubyte(*)[4]) rgba, mask);
+}
+
+
+static void
+read_R8G8B8A8_span(const GLcontext * ctx, GLuint n, GLint x, GLint y,
+                   GLubyte rgba[][4])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB, GR_LFBWRITEMODE_ANY,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            GLint srcStride = fxMesa->screen_width;
+            const GLuint *src32 = (const GLuint *) info.lfbPtr
+                + (winY - y) * srcStride + (winX + x);
+            GLuint i;
+	    MEMCPY(rgba, src32, n * 4);
+            for (i = 0; i < n; i++) {
+		rgba[i][0] ^= rgba[i][2];
+		rgba[i][2] ^= rgba[i][0];
+		rgba[i][0] ^= rgba[i][2];
+            }
+        }
+        else {
+            /* back buffer */
+            GLint srcStride = info.strideInBytes / sizeof(GLuint);
+            const GLuint *src32 = (const GLuint *) info.lfbPtr
+                + (winY - y) * srcStride + (winX + x);
+            GLuint i;
+	    MEMCPY(rgba, src32, n * 4);
+            for (i = 0; i < n; i++) {
+		rgba[i][0] ^= rgba[i][2];
+		rgba[i][2] ^= rgba[i][0];
+		rgba[i][0] ^= rgba[i][2];
+            }
+        }
+        grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+    }
+    else
+        info.strideInBytes = -1;
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+static void
+write_R8G8B8A8_pixels(const GLcontext * ctx,
+                      GLuint n, const GLint x[], const GLint y[],
+                      CONST GLubyte rgba[][4], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    info.size = sizeof(info);
+    if (grLfbLock(GR_LFB_WRITE_ONLY, fxMesa->currentFB, GR_LFBWRITEMODE_8888,
+                  GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+        if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
+            GLuint i;
+            for (i = 0; i < n; i++) {
+                const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+                const GLint winX = fxMesa->x_offset;
+                const GLint scrX = winX + x[i];
+                const GLint scrY = winY - y[i];
+                if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
+                    GLint dstStride = fxMesa->screen_width * 4;
+                    GLubyte *dst =
+                        (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
+                    GLuint *dst32 = (GLuint *) dst;
+                    *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1],
+                                         rgba[i][2], rgba[i][3]);
+                }
+            }
+        }
+        else {
+            /* back buffer */
+            GLuint i;
+            for (i = 0; i < n; i++) {
+                const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+                const GLint winX = fxMesa->x_offset;
+                const GLint scrX = winX + x[i];
+                const GLint scrY = winY - y[i];
+                if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) {
+                    GLint dstStride = info.strideInBytes;
+                    GLubyte *dst =
+                        (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4;
+                    GLuint *dst32 = (GLuint *) dst;
+                    *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1],
+                                         rgba[i][2], rgba[i][3]);
+                }
+            }
+        }
+        grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+static void
+write_R8G8B8A8_mono_pixels(const GLcontext * ctx,
+                           GLuint n, const GLint x[], const GLint y[],
+                           const GLubyte mask[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint i;
+    GLuint color = fxMesa->color;
+    for (i = 0; i < n; i++) {
+        if (mask[i]) {
+            write_R8G8B8A8_rgba_span(ctx, 1, x[i], y[i],
+                                     (const GLubyte(*)[4]) &color, mask + i);
+        }
+    }
+}
+
+
+
+static void
+read_R8G8B8A8_pixels(const GLcontext * ctx,
+                     GLuint n, const GLint x[], const GLint y[],
+                     GLubyte rgba[][4], const GLubyte mask[])
+{
+    GLuint i;
+    for (i = 0; i < n; i++) {
+        if (mask[i]) {
+            read_R8G8B8A8_span(ctx, 1, x[i], y[i], rgba + i);
+        }
+    }
+}
+
+
+
+/*
+ * Depth buffer read/write functions.
+ */
+/*
+ * To read the frame buffer, we need to lock and unlock it.  The
+ * four macros {READ,WRITE}_FB_SPAN_{LOCK,UNLOCK}
+ * do this for us.
+ *
+ * Note that the lock must be matched with an unlock.  These
+ * macros include a spare curly brace, so they must
+ * be syntactically matched.
+ *
+ * Note, also, that you can't lock a buffer twice with different
+ * modes.  That is to say, you can't lock a buffer in both read
+ * and write modes.  The strideInBytes and LFB pointer will be
+ * the same with read and write locks, so you can use either.
+ * o The HW has different state for reads and writes, so
+ *   locking it twice may give screwy results.
+ * o The DRM won't let you lock twice.  It hangs.  This is probably
+ *   because of the BEGIN_BOARD_LOCK IN THE *_FB_SPAN_LOCK macros,
+ *   and could be eliminated with nonlocking lock routines.  But
+ *   what's the point after all.
+ */
+#define READ_FB_SPAN_LOCK(fxMesa, info, target_buffer)              \
+  BEGIN_BOARD_LOCK(fxMesa);                                         \
+  (info).size=sizeof(info);                                         \
+  if (grLfbLock(GR_LFB_READ_ONLY,                                   \
+                target_buffer,                                      \
+                GR_LFBWRITEMODE_ANY,                                \
+                GR_ORIGIN_LOWER_LEFT,                               \
+                FXFALSE,                                            \
+                &(info))) {
+
+#define READ_FB_SPAN_UNLOCK(fxMesa, target_buffer)                  \
+    grLfbUnlock(GR_LFB_READ_ONLY, target_buffer);                   \
+  } else {                                                          \
+    fprintf(stderr, "fxDriver: Can't get %s (%d) read lock\n",      \
+            (target_buffer == GR_BUFFER_BACKBUFFER)                 \
+                ? "back buffer"                                     \
+            : ((target_buffer == GR_BUFFER_AUXBUFFER)               \
+                ? "depth buffer"                                    \
+               : "unknown buffer"),                                 \
+            target_buffer);                                         \
+  }                                                                 \
+  END_BOARD_LOCK(fxMesa);
+
+
+#define WRITE_FB_SPAN_LOCK(fxMesa, info, target_buffer, write_mode) \
+  BEGIN_BOARD_LOCK(fxMesa);                                         \
+  info.size=sizeof(info);                                           \
+  if (grLfbLock(GR_LFB_WRITE_ONLY,                                  \
+                target_buffer,                                      \
+                write_mode,                                         \
+                GR_ORIGIN_LOWER_LEFT,                               \
+                FXFALSE,                                            \
+                &info)) {
+
+#define WRITE_FB_SPAN_UNLOCK(fxMesa, target_buffer)                 \
+    grLfbUnlock(GR_LFB_WRITE_ONLY, target_buffer);                  \
+  } else {                                                          \
+    fprintf(stderr, "fxDriver: Can't get %s (%d) write lock\n",     \
+            (target_buffer == GR_BUFFER_BACKBUFFER)                 \
+                ? "back buffer"                                     \
+            : ((target_buffer == GR_BUFFER_AUXBUFFER)               \
+                ? "depth buffer"                                    \
+               : "unknown buffer"),                                 \
+            target_buffer);                                         \
+  }                                                                 \
+  END_BOARD_LOCK(fxMesa);
+
+/*
+ * Because the Linear Frame Buffer is not necessarily aligned
+ * with the depth buffer, we have to do some fiddling
+ * around to get the right addresses.
+ *
+ * Perhaps a picture is in order.  The Linear Frame Buffer
+ * looks like this:
+ *
+ *   |<----------------------info.strideInBytes------------->|
+ *   |<-----physicalStrideInBytes------->|
+ *   +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
+ *   |                                   |                   |
+ *   |          Legal Memory             |  Forbidden Zone   |
+ *   |                                   |                   |
+ *   +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
+ *
+ * You can only reliably read and write legal locations.  Reads
+ * and writes from the Forbidden Zone will return undefined values,
+ * and may cause segmentation faults.
+ *
+ * Now, the depth buffer may not end up in a location such each
+ * scan line is an LFB line.  For example, the depth buffer may
+ * look like this:
+ *
+ *    wrapped               ordinary.
+ *   +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
+ *   |0000000000000000000000             |                   | back
+ *   |1111111111111111111111             |                   | buffer
+ *   |2222222222222222222222             |                   |
+ *   |4096b align. padxx00000000000000000|  Forbidden Zone   | depth
+ *   |0000              11111111111111111|                   | buffer
+ *   |1111              22222222222222222|                   |
+ *   |2222                               |                   |
+ *   +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
+ * where each number is the scan line number.  We know it will
+ * be aligned on 128 byte boundaries, at least.  Aligning this
+ * on a scanline boundary causes the back and depth buffers to
+ * thrash in the SST1 cache.  (Note that the back buffer is always
+ * allocated at the beginning of LFB memory, and so it is always
+ * properly aligned with the LFB stride.)
+ *
+ * We call the beginning of the line (which is the rightmost
+ * part of the depth line in the picture above) the *ordinary* part
+ * of the scanline, and the end of the line (which is the
+ * leftmost part, one line below) the *wrapped* part of the scanline.
+ * a.) We need to know what x value to subtract from the screen
+ *     x coordinate to index into the wrapped part.
+ * b.) We also need to figure out if we need to read from the ordinary
+ *     part scan line, or from the wrapped part of the scan line.
+ *
+ * [ad a]
+ * The first wrapped x coordinate is that coordinate such that
+ *           depthBufferOffset&(info.strideInBytes) + x*elmentSize  {*}
+ *                            > physicalStrideInBytes
+ *     where depthBufferOffset is the LFB distance in bytes
+ *     from the back buffer to the depth buffer.  The expression
+ *           depthBufferOffset&(info.strideInBytes)
+ *     is then the offset (in bytes) from the beginining of (any)
+ *     depth buffer line to first element in the line.
+ * Simplifying inequation {*} above we see that x is the smallest
+ * value such that
+ *         x*elementSize > physicalStrideInBytes                      {**}
+ *                            - depthBufferOffset&(info.strideInBytes)
+ * Now, we know that both the summands on the right are multiples of
+ * 128, and elementSize <= 4, so if equality holds in {**}, x would
+ * be a multiple of 32.  Thus we can set x to
+ *         xwrapped = (physicalStrideInBytes
+ *                      - depthBufferOffset&(info.strideInBytes))/elementSize
+ *                      + 1
+ *
+ * [ad b]
+ * Question b is now simple.  We read from the wrapped scan line if
+ * x is greater than xwrapped.
+ */
+#define TILE_WIDTH_IN_BYTES		128
+#define TILE_WIDTH_IN_ZOXELS(bpz)	(TILE_WIDTH_IN_BYTES/(bpz))
+#define TILE_HEIGHT_IN_LINES		32
+typedef struct
+{
+    void *lfbPtr;
+    void *lfbWrapPtr;
+    FxU32 LFBStrideInElts;
+    GLint firstWrappedX;
+}
+LFBParameters;
+
+/*
+ * We need information about the back buffer.  Note that
+ * this function *cannot be called* while the aux buffer
+ * is locked, or the caller will hang.
+ *
+ * Only Glide knows the LFB address of the back and depth
+ * offsets.  The upper levels of Mesa know the depth offset,
+ * but that is not in LFB space, it is tiled memory space,
+ * and is not useable for us.
+ */
+static void
+GetBackBufferInfo(fxMesaContext fxMesa, GrLfbInfo_t * backBufferInfo)
+{
+    READ_FB_SPAN_LOCK(fxMesa, *backBufferInfo, GR_BUFFER_BACKBUFFER);
+    READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_BACKBUFFER);
+}
+
+static void
+GetFbParams(fxMesaContext fxMesa,
+            GrLfbInfo_t * info,
+            GrLfbInfo_t * backBufferInfo,
+            LFBParameters * ReadParamsp, FxU32 elementSize)
+{
+    FxU32 physicalStrideInBytes, bufferOffset;
+    FxU32 strideInBytes = info->strideInBytes;
+    char *lfbPtr = (char *) (info->lfbPtr);
+
+    /*
+     * These two come directly from the info structure.
+     */
+    ReadParamsp->lfbPtr = (void *) lfbPtr;
+    ReadParamsp->LFBStrideInElts = strideInBytes / elementSize;
+    /*
+     * Now, calculate the value of firstWrappedX.
+     *
+     * The physical stride is the screen width in bytes rounded up to
+     * the next highest multiple of 128 bytes.  Note that this fails
+     * when TILE_WIDTH_IN_BYTES is not a power of two.
+     *
+     * The buffer Offset is the distance between the beginning of
+     * the LFB space, which is the beginning of the back buffer,
+     * and the buffer we are gathering information about.
+     * We want to make this routine usable for operations on the
+     * back buffer, though we don't actually use it on the back
+     * buffer.  Note, then, that if bufferOffset == 0, the firstWrappedX
+     * is in the forbidden zone, and is therefore never reached.
+     *
+     * Note that if
+     *     physicalStrideInBytes
+     *             < bufferOffset&(info->strideInBytes-1)
+     * the buffer begins in the forbidden zone.  We assert for this.
+     */
+    bufferOffset = (FxU32)(lfbPtr - (char *) backBufferInfo->lfbPtr);
+    physicalStrideInBytes
+        = (fxMesa->screen_width * elementSize + TILE_WIDTH_IN_BYTES - 1)
+        & ~(TILE_WIDTH_IN_BYTES - 1);
+    assert(physicalStrideInBytes > (bufferOffset & (strideInBytes - 1)));
+    ReadParamsp->firstWrappedX
+        = (physicalStrideInBytes
+           - (bufferOffset & (strideInBytes - 1))) / elementSize;
+    /*
+     * This is the address of the next physical line.
+     */
+    ReadParamsp->lfbWrapPtr
+        = (void *) ((char *) backBufferInfo->lfbPtr
+                    + (bufferOffset & ~(strideInBytes - 1))
+                    + (TILE_HEIGHT_IN_LINES) * strideInBytes);
+}
+
+/*
+ * These macros fetch data from the frame buffer.  The type is
+ * the type of data we want to fetch.  It should match the type
+ * whose size was used with GetFbParams to fill in the structure
+ * in *ReadParamsp.  We have a macro to read the ordinary
+ * part, a second macro to read the wrapped part, and one which
+ * will do either.  When we are reading a span, we will know
+ * when the ordinary part ends, so there's no need to test for
+ * it.  However, when reading and writing pixels, we don't
+ * necessarily know.  I suppose it's a matter of taste whether
+ * it's better in the macro or in the call.
+ *
+ * Recall that x and y are screen coordinates.
+ */
+#define GET_FB_DATA(ReadParamsp, type, x, y)                        \
+   (((x) < (ReadParamsp)->firstWrappedX)                            \
+        ? (((type *)((ReadParamsp)->lfbPtr))                        \
+                 [(y) * ((ReadParamsp)->LFBStrideInElts)            \
+                   + (x)])                                          \
+        : (((type *)((ReadParamsp)->lfbWrapPtr))                    \
+                 [((y)) * ((ReadParamsp)->LFBStrideInElts)          \
+                   + ((x) - (ReadParamsp)->firstWrappedX)]))
+#define GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y)               \
+    (((type *)((ReadParamsp)->lfbPtr))                              \
+                 [(y) * ((ReadParamsp)->LFBStrideInElts)            \
+                   + (x)])
+#define GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y)                \
+    (((type *)((ReadParamsp)->lfbWrapPtr))                          \
+                 [((y)) * ((ReadParamsp)->LFBStrideInElts)          \
+                   + ((x) - (ReadParamsp)->firstWrappedX)])
+#define PUT_FB_DATA(ReadParamsp, type, x, y, value)                        \
+    (GET_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
+#define PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value)              \
+    (GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
+#define PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value)                \
+    (GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
+
+static void
+fxDDWriteDepthSpan(GLcontext * ctx,
+                   GLuint n, GLint x, GLint y, const GLdepth depth[],
+                   const GLubyte mask[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLint bottom = fxMesa->y_offset + fxMesa->height - 1;
+    GLuint depth_size = fxMesa->glVis->DepthBits;
+    GLuint stencil_size = fxMesa->glVis->StencilBits;
+    GrLfbInfo_t info;
+    GLubyte visMask[MAX_WIDTH];
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
+    }
+
+    assert((depth_size == 16) || (depth_size == 24) || (depth_size == 32));
+    /*
+     * Convert x and y to screen coordinates.
+     */
+    x += fxMesa->x_offset;
+    y = bottom - y;
+    if (mask) {
+        GLint i;
+        GLushort d16;
+        GrLfbInfo_t backBufferInfo;
+
+        switch (depth_size) {
+        case 16:
+            GetBackBufferInfo(fxMesa, &backBufferInfo);
+           /*
+            * Note that the _LOCK macro adds a curly brace,
+            * and the UNLOCK macro removes it.
+            */
+            WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER,
+                               GR_LFBWRITEMODE_ANY);
+            generate_vismask(fxMesa, x, y, n, visMask);
+            {
+                LFBParameters ReadParams;
+                int wrappedPartStart;
+                GetFbParams(fxMesa, &info, &backBufferInfo,
+                            &ReadParams, sizeof(GLushort));
+                if (ReadParams.firstWrappedX <= x) {
+                    wrappedPartStart = 0;
+                }
+                else if (n <= (ReadParams.firstWrappedX - x)) {
+                    wrappedPartStart = n;
+                }
+                else {
+                    wrappedPartStart = (ReadParams.firstWrappedX - x);
+                }
+                for (i = 0; i < wrappedPartStart; i++) {
+                    if (mask[i] && visMask[i]) {
+                        d16 = depth[i];
+                        PUT_ORDINARY_FB_DATA(&ReadParams, GLushort, x + i, y, d16);
+                    }
+                }
+                for (; i < n; i++) {
+                    if (mask[i] && visMask[i]) {
+                        d16 = depth[i];
+                        PUT_WRAPPED_FB_DATA(&ReadParams, GLushort, x + i, y, d16);
+                    }
+                }
+            }
+            WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+            break;
+        case 24:
+        case 32:
+            GetBackBufferInfo(fxMesa, &backBufferInfo);
+           /*
+            * Note that the _LOCK macro adds a curly brace,
+            * and the UNLOCK macro removes it.
+            */
+            WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER,
+                               GR_LFBWRITEMODE_ANY);
+            generate_vismask(fxMesa, x, y, n, visMask);
+            {
+                LFBParameters ReadParams;
+                int wrappedPartStart;
+                GetFbParams(fxMesa, &info, &backBufferInfo,
+                            &ReadParams, sizeof(GLuint));
+                if (ReadParams.firstWrappedX <= x) {
+                    wrappedPartStart = 0;
+                }
+                else if (n <= (ReadParams.firstWrappedX - x)) {
+                    wrappedPartStart = n;
+                }
+                else {
+                    wrappedPartStart = (ReadParams.firstWrappedX - x);
+                }
+                for (i = 0; i < wrappedPartStart; i++) {
+                    GLuint d32;
+                    if (mask[i] && visMask[i]) {
+                        if (stencil_size > 0) {
+                            d32 =
+                                GET_ORDINARY_FB_DATA(&ReadParams, GLuint,
+                                                     x + i, y);
+                            d32 =
+                                (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF);
+                        }
+                        else {
+                            d32 = depth[i];
+                        }
+                        PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y, d32);
+                    }
+                }
+                for (; i < n; i++) {
+                    GLuint d32;
+                    if (mask[i] && visMask[i]) {
+                        if (stencil_size > 0) {
+                            d32 =
+                                GET_WRAPPED_FB_DATA(&ReadParams, GLuint,
+                                                    x + i, y);
+                            d32 =
+                                (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF);
+                        }
+                        else {
+                            d32 = depth[i];
+                        }
+                        PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y, d32);
+                    }
+                }
+            }
+            WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+            break;
+        }
+    }
+    else {
+        GLint i;
+        GLuint d32;
+        GLushort d16;
+        GrLfbInfo_t backBufferInfo;
+
+        switch (depth_size) {
+        case 16:
+            GetBackBufferInfo(fxMesa, &backBufferInfo);
+           /*
+            * Note that the _LOCK macro adds a curly brace,
+            * and the UNLOCK macro removes it.
+            */
+            WRITE_FB_SPAN_LOCK(fxMesa, info,
+                               GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+            generate_vismask(fxMesa, x, y, n, visMask);
+            {
+                LFBParameters ReadParams;
+                GLuint wrappedPartStart;
+                GetFbParams(fxMesa, &info, &backBufferInfo,
+                            &ReadParams, sizeof(GLushort));
+                if (ReadParams.firstWrappedX <= x) {
+                    wrappedPartStart = 0;
+                }
+                else if (n <= (ReadParams.firstWrappedX - x)) {
+                    wrappedPartStart = n;
+                }
+                else {
+                    wrappedPartStart = (ReadParams.firstWrappedX - x);
+                }
+                for (i = 0; i < wrappedPartStart; i++) {
+                    if (visMask[i]) {
+                        d16 = depth[i];
+                        PUT_ORDINARY_FB_DATA(&ReadParams,
+                                             GLushort,
+                                             x + i, y,
+                                             d16);
+                    }
+                }
+                for (; i < n; i++) {
+                    if (visMask[i]) {
+                        d16 = depth[i];
+                        PUT_WRAPPED_FB_DATA(&ReadParams,
+                                            GLushort,
+                                            x + i, y,
+                                            d16);
+                    }
+                }
+            }
+            WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+            break;
+        case 24:
+        case 32:
+            GetBackBufferInfo(fxMesa, &backBufferInfo);
+           /*
+            * Note that the _LOCK macro adds a curly brace,
+            * and the UNLOCK macro removes it.
+            */
+            WRITE_FB_SPAN_LOCK(fxMesa, info,
+                               GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+            generate_vismask(fxMesa, x, y, n, visMask);
+            {
+                LFBParameters ReadParams;
+                GLuint wrappedPartStart;
+
+                GetFbParams(fxMesa, &info, &backBufferInfo,
+                            &ReadParams, sizeof(GLuint));
+                if (ReadParams.firstWrappedX <= x) {
+                    wrappedPartStart = 0;
+                }
+                else if (n <= (ReadParams.firstWrappedX - x)) {
+                    wrappedPartStart = n;
+                }
+                else {
+                    wrappedPartStart = (ReadParams.firstWrappedX - x);
+                }
+                for (i = 0; i < wrappedPartStart; i++) {
+                    if (visMask[i]) {
+                        if (stencil_size > 0) {
+                            d32 = GET_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y);
+                            d32 =
+                                (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF);
+                        }
+                        else {
+                            d32 = depth[i];
+                        }
+                        PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y, d32);
+                    }
+                }
+                for (; i < n; i++) {
+                    if (visMask[i]) {
+                        if (stencil_size > 0) {
+                            d32 = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y);
+                            d32 =
+                                (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF);
+                        }
+                        else {
+                            d32 = depth[i];
+                        }
+                        PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y, d32);
+                    }
+                }
+            }
+            WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+            break;
+        }
+    }
+}
+
+static void
+fxDDReadDepthSpan(GLcontext * ctx,
+                  GLuint n, GLint x, GLint y, GLdepth depth[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+    GLuint i;
+    GLuint depth_size = fxMesa->glVis->DepthBits;
+    GrLfbInfo_t info;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
+    }
+
+    /*
+     * Convert to screen coordinates.
+     */
+    x += fxMesa->x_offset;
+    y = bottom - y;
+    switch (depth_size) {
+    case 16:
+        {
+            LFBParameters ReadParams;
+            GrLfbInfo_t backBufferInfo;
+            int wrappedPartStart;
+            GetBackBufferInfo(fxMesa, &backBufferInfo);
+           /*
+            * Note that the _LOCK macro adds a curly brace,
+            * and the UNLOCK macro removes it.
+            */
+            READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+            GetFbParams(fxMesa, &info, &backBufferInfo,
+                        &ReadParams, sizeof(GLushort));
+            if (ReadParams.firstWrappedX <= x) {
+                wrappedPartStart = 0;
+            }
+            else if (n <= (ReadParams.firstWrappedX - x)) {
+                wrappedPartStart = n;
+            }
+            else {
+                wrappedPartStart = (ReadParams.firstWrappedX - x);
+            }
+            /*
+             * Read the line.
+             */
+            for (i = 0; i < wrappedPartStart; i++) {
+                depth[i] =
+                    GET_ORDINARY_FB_DATA(&ReadParams, GLushort, x + i, y);
+            }
+            for (; i < n; i++) {
+                depth[i] = GET_WRAPPED_FB_DATA(&ReadParams, GLushort,
+                                               x + i, y);
+            }
+            READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+            break;
+        }
+    case 24:
+    case 32:
+        {
+            LFBParameters ReadParams;
+            GrLfbInfo_t backBufferInfo;
+            int wrappedPartStart;
+            GLuint stencil_size = fxMesa->glVis->StencilBits;
+            GetBackBufferInfo(fxMesa, &backBufferInfo);
+           /*
+            * Note that the _LOCK macro adds a curly brace,
+            * and the UNLOCK macro removes it.
+            */
+            READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+            GetFbParams(fxMesa, &info, &backBufferInfo,
+                        &ReadParams, sizeof(GLuint));
+            if (ReadParams.firstWrappedX <= x) {
+                wrappedPartStart = 0;
+            }
+            else if (n <= (ReadParams.firstWrappedX - x)) {
+                wrappedPartStart = n;
+            }
+            else {
+                wrappedPartStart = (ReadParams.firstWrappedX - x);
+            }
+            /*
+             * Read the line.
+             */
+            for (i = 0; i < wrappedPartStart; i++) {
+                const GLuint mask =
+                    (stencil_size > 0) ? 0x00FFFFFF : 0xFFFFFFFF;
+                depth[i] =
+                    GET_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y);
+                depth[i] &= mask;
+            }
+            for (; i < n; i++) {
+                const GLuint mask =
+                    (stencil_size > 0) ? 0x00FFFFFF : 0xFFFFFFFF;
+                depth[i] = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y);
+                depth[i] &= mask;
+            }
+            READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+            break;
+        }
+    }
+}
+
+
+static void
+fxDDWriteDepthPixels(GLcontext * ctx,
+                     GLuint n, const GLint x[], const GLint y[],
+                     const GLdepth depth[], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+    GLuint i;
+    GLushort d16;
+    GLuint d32;
+    GLuint depth_size = fxMesa->glVis->DepthBits;
+    GLuint stencil_size = fxMesa->glVis->StencilBits;
+    GrLfbInfo_t info;
+    int xpos;
+    int ypos;
+    GrLfbInfo_t backBufferInfo;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n");
+    }
+
+    switch (depth_size) {
+    case 16:
+        GetBackBufferInfo(fxMesa, &backBufferInfo);
+       /*
+        * Note that the _LOCK macro adds a curly brace,
+        * and the UNLOCK macro removes it.
+        */
+        WRITE_FB_SPAN_LOCK(fxMesa, info,
+                           GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+        {
+            LFBParameters ReadParams;
+            GetFbParams(fxMesa, &info, &backBufferInfo,
+                        &ReadParams, sizeof(GLushort));
+            for (i = 0; i < n; i++) {
+                if (mask[i] && visible_pixel(fxMesa, x[i], y[i])) {
+                    xpos = x[i] + fxMesa->x_offset;
+                    ypos = bottom - y[i];
+                    d16 = depth[i];
+                    PUT_FB_DATA(&ReadParams, GLushort, xpos, ypos, d16);
+                }
+            }
+        }
+        WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+        break;
+    case 24:
+    case 32:
+        GetBackBufferInfo(fxMesa, &backBufferInfo);
+       /*
+        * Note that the _LOCK macro adds a curly brace,
+        * and the UNLOCK macro removes it.
+        */
+        WRITE_FB_SPAN_LOCK(fxMesa, info,
+                           GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+        {
+            LFBParameters ReadParams;
+            GetFbParams(fxMesa, &info, &backBufferInfo,
+                        &ReadParams, sizeof(GLuint));
+            for (i = 0; i < n; i++) {
+                if (mask[i]) {
+                    if (visible_pixel(fxMesa, x[i], y[i])) {
+                        xpos = x[i] + fxMesa->x_offset;
+                        ypos = bottom - y[i];
+                        if (stencil_size > 0) {
+                            d32 =
+                                GET_FB_DATA(&ReadParams, GLuint, xpos, ypos);
+                            d32 = (d32 & 0xFF000000) | (depth[i] & 0xFFFFFF);
+                        }
+                        else {
+                            d32 = depth[i];
+                        }
+                        PUT_FB_DATA(&ReadParams, GLuint, xpos, ypos, d32);
+                    }
+                }
+            }
+        }
+        WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+        break;
+    }
+}
+
+
+static void
+fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
+                    const GLint x[], const GLint y[], GLdepth depth[])
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+    GLuint i;
+    GLuint depth_size = fxMesa->glVis->DepthBits;
+    GLushort d16;
+    int xpos;
+    int ypos;
+    GrLfbInfo_t info;
+    GLuint stencil_size;
+    GrLfbInfo_t backBufferInfo;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDReadDepthPixels(...)\n");
+    }
+
+    assert((depth_size == 16) || (depth_size == 24) || (depth_size == 32));
+    switch (depth_size) {
+    case 16:
+        GetBackBufferInfo(fxMesa, &backBufferInfo);
+       /*
+        * Note that the _LOCK macro adds a curly brace,
+        * and the UNLOCK macro removes it.
+        */
+        READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+        {
+            LFBParameters ReadParams;
+            GetFbParams(fxMesa, &info, &backBufferInfo,
+                        &ReadParams, sizeof(GLushort));
+            for (i = 0; i < n; i++) {
+                /*
+                 * Convert to screen coordinates.
+                 */
+                xpos = x[i] + fxMesa->x_offset;
+                ypos = bottom - y[i];
+                d16 = GET_FB_DATA(&ReadParams, GLushort, xpos, ypos);
+                depth[i] = d16;
+            }
+        }
+        READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+        break;
+    case 24:
+    case 32:
+        GetBackBufferInfo(fxMesa, &backBufferInfo);
+       /*
+        * Note that the _LOCK macro adds a curly brace,
+        * and the UNLOCK macro removes it.
+        */
+        READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+        stencil_size = fxMesa->glVis->StencilBits;
+        {
+            LFBParameters ReadParams;
+            GetFbParams(fxMesa, &info, &backBufferInfo,
+                        &ReadParams, sizeof(GLuint));
+            for (i = 0; i < n; i++) {
+                GLuint d32;
+
+                /*
+                 * Convert to screen coordinates.
+                 */
+                xpos = x[i] + fxMesa->x_offset;
+                ypos = bottom - y[i];
+                d32 = GET_FB_DATA(&ReadParams, GLuint, xpos, ypos);
+                if (stencil_size > 0) {
+                    d32 &= 0x00FFFFFF;
+                }
+                depth[i] = d32;
+            }
+        }
+        READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+        break;
+    default:
+        assert(0);
+    }
+}
+
+/*
+ * Stencil buffer read/write functions.
+ */
+#define EXTRACT_S_FROM_ZS(zs) (((zs) >> 24) & 0xFF)
+#define EXTRACT_Z_FROM_ZS(zs) ((zs) & 0xffffff)
+#define BUILD_ZS(z, s)  (((s) << 24) | (z))
+
+static void
+write_stencil_span(GLcontext * ctx, GLuint n, GLint x, GLint y,
+                   const GLstencil stencil[], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+    GrLfbInfo_t backBufferInfo;
+
+    GetBackBufferInfo(fxMesa, &backBufferInfo);
+   /*
+    * Note that the _LOCK macro adds a curly brace,
+    * and the UNLOCK macro removes it.
+    */
+    WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+    {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+        const GLint scrX = winX + x;
+        const GLint scrY = winY - y;
+        LFBParameters ReadParams;
+        GLubyte visMask[MAX_WIDTH];
+        GLuint i;
+        int wrappedPartStart;
+
+        GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams,
+                    sizeof(GLuint));
+        if (ReadParams.firstWrappedX <= x) {
+            wrappedPartStart = 0;
+        }
+        else if (n <= (ReadParams.firstWrappedX - x)) {
+            wrappedPartStart = n;
+        }
+        else {
+            wrappedPartStart = (ReadParams.firstWrappedX - x);
+        }
+        generate_vismask(fxMesa, scrX, scrY, n, visMask);
+        for (i = 0; i < wrappedPartStart; i++) {
+            if (visMask[i] && (!mask || mask[i])) {
+                GLuint z = GET_ORDINARY_FB_DATA(&ReadParams, GLuint,
+                                                scrX + i, scrY) & 0x00FFFFFF;
+                z |= (stencil[i] & 0xFF) << 24;
+                PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, scrX + i, scrY, z);
+            }
+        }
+        for (; i < n; i++) {
+            if (visMask[i] && (!mask || mask[i])) {
+                GLuint z = GET_WRAPPED_FB_DATA(&ReadParams, GLuint,
+                                               scrX + i, scrY) & 0x00FFFFFF;
+                z |= (stencil[i] & 0xFF) << 24;
+                PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, scrX + i, scrY, z);
+            }
+        }
+    }
+    WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+}
+
+
+static void
+read_stencil_span(GLcontext * ctx, GLuint n, GLint x, GLint y,
+                  GLstencil stencil[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+    GrLfbInfo_t backBufferInfo;
+
+    GetBackBufferInfo(fxMesa, &backBufferInfo);
+   /*
+    * Note that the _LOCK macro adds a curly brace,
+    * and the UNLOCK macro removes it.
+    */
+    READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+    {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+        GLuint i;
+        LFBParameters ReadParams;
+        int wrappedPartStart;
+
+        /*
+         * Convert to screen coordinates.
+         */
+        x += winX;
+        y = winY - y;
+        GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams,
+                    sizeof(GLuint));
+        if (ReadParams.firstWrappedX <= x) {
+            wrappedPartStart = 0;
+        }
+        else if (n <= (ReadParams.firstWrappedX - x)) {
+            wrappedPartStart = n;
+        }
+        else {
+            wrappedPartStart = (ReadParams.firstWrappedX - x);
+        }
+        for (i = 0; i < wrappedPartStart; i++) {
+            stencil[i] = (GET_ORDINARY_FB_DATA(&ReadParams, GLuint,
+                                               x + i, y) >> 24) & 0xFF;
+        }
+        for (; i < n; i++) {
+            stencil[i] = (GET_WRAPPED_FB_DATA(&ReadParams, GLuint,
+                                              x + i, y) >> 24) & 0xFF;
+        }
+    }
+    READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+}
+
+
+static void
+write_stencil_pixels(GLcontext * ctx, GLuint n,
+                     const GLint x[], const GLint y[],
+                     const GLstencil stencil[], const GLubyte mask[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+    GrLfbInfo_t backBufferInfo;
+
+    GetBackBufferInfo(fxMesa, &backBufferInfo);
+   /*
+    * Note that the _LOCK macro adds a curly brace,
+    * and the UNLOCK macro removes it.
+    */
+    WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+    {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+        LFBParameters ReadParams;
+        GLuint i;
+
+        GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams,
+                    sizeof(GLuint));
+        for (i = 0; i < n; i++) {
+            const GLint scrX = winX + x[i];
+            const GLint scrY = winY - y[i];
+            if ((!mask || mask[i]) && visible_pixel(fxMesa, scrX, scrY)) {
+                GLuint z =
+                    GET_FB_DATA(&ReadParams, GLuint, scrX, scrY) & 0x00FFFFFF;
+                z |= (stencil[i] & 0xFF) << 24;
+                PUT_FB_DATA(&ReadParams, GLuint, scrX, scrY, z);
+            }
+        }
+    }
+    WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+}
+
+
+static void
+read_stencil_pixels(GLcontext * ctx, GLuint n, const GLint x[],
+                    const GLint y[], GLstencil stencil[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    GrLfbInfo_t info;
+    GrLfbInfo_t backBufferInfo;
+
+    GetBackBufferInfo(fxMesa, &backBufferInfo);
+   /*
+    * Note that the _LOCK macro adds a curly brace,
+    * and the UNLOCK macro removes it.
+    */
+    READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+    {
+        const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+        const GLint winX = fxMesa->x_offset;
+        GLuint i;
+        LFBParameters ReadParams;
+
+        GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams,
+                    sizeof(GLuint));
+        for (i = 0; i < n; i++) {
+            const GLint scrX = winX + x[i];
+            const GLint scrY = winY - y[i];
+            stencil[i] =
+                (GET_FB_DATA(&ReadParams, GLuint, scrX, scrY) >> 24) & 0xFF;
+        }
+    }
+    READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+}
+
+void
+fxSetupDDSpanPointers(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+    if (ctx->Visual->RedBits == 5 &&
+        ctx->Visual->GreenBits == 6 &&
+        ctx->Visual->BlueBits == 5 && ctx->Visual->AlphaBits == 0) {
+        /* 16bpp mode */
+        ctx->Driver.WriteRGBASpan = write_R5G6B5_rgba_span;
+        ctx->Driver.WriteRGBSpan = write_R5G6B5_rgb_span;
+        ctx->Driver.WriteMonoRGBASpan = write_R5G6B5_mono_span;
+        ctx->Driver.WriteRGBAPixels = write_R5G6B5_pixels;
+        ctx->Driver.WriteMonoRGBAPixels = write_R5G6B5_mono_pixels;
+        ctx->Driver.ReadRGBASpan = read_R5G6B5_span;
+        ctx->Driver.ReadRGBAPixels = read_R5G6B5_pixels;
+    }
+    else if (ctx->Visual->RedBits == 8 &&
+             ctx->Visual->GreenBits == 8 &&
+             ctx->Visual->BlueBits == 8 && ctx->Visual->AlphaBits == 0) {
+        /* 24bpp mode */
+        ctx->Driver.WriteRGBASpan = write_R8G8B8_rgba_span;
+        ctx->Driver.WriteRGBSpan = write_R8G8B8_rgb_span;
+        ctx->Driver.WriteMonoRGBASpan = write_R8G8B8_mono_span;
+        ctx->Driver.WriteRGBAPixels = write_R8G8B8_pixels;
+        ctx->Driver.WriteMonoRGBAPixels = write_R8G8B8_mono_pixels;
+        ctx->Driver.ReadRGBASpan = read_R8G8B8_span;
+        ctx->Driver.ReadRGBAPixels = read_R8G8B8_pixels;
+    }
+    else if (ctx->Visual->RedBits == 8 &&
+             ctx->Visual->GreenBits == 8 &&
+             ctx->Visual->BlueBits == 8 && ctx->Visual->AlphaBits == 8) {
+        /* 32bpp mode */
+        ctx->Driver.WriteRGBASpan = write_R8G8B8A8_rgba_span;
+        ctx->Driver.WriteRGBSpan = write_R8G8B8A8_rgb_span;
+        ctx->Driver.WriteMonoRGBASpan = write_R8G8B8A8_mono_span;
+        ctx->Driver.WriteRGBAPixels = write_R8G8B8A8_pixels;
+        ctx->Driver.WriteMonoRGBAPixels = write_R8G8B8A8_mono_pixels;
+        ctx->Driver.ReadRGBASpan = read_R8G8B8A8_span;
+        ctx->Driver.ReadRGBAPixels = read_R8G8B8A8_pixels;
+    }
+    else {
+        abort();
+    }
+
+    if (fxMesa->haveHwStencil) {
+        ctx->Driver.WriteStencilSpan = write_stencil_span;
+        ctx->Driver.ReadStencilSpan = read_stencil_span;
+        ctx->Driver.WriteStencilPixels = write_stencil_pixels;
+        ctx->Driver.ReadStencilPixels = read_stencil_pixels;
+    }
+
+    ctx->Driver.WriteDepthSpan = fxDDWriteDepthSpan;
+    ctx->Driver.WriteDepthPixels = fxDDWriteDepthPixels;
+    ctx->Driver.ReadDepthSpan = fxDDReadDepthSpan;
+    ctx->Driver.ReadDepthPixels = fxDDReadDepthPixels;
+
+    ctx->Driver.WriteCI8Span = NULL;
+    ctx->Driver.WriteCI32Span = NULL;
+    ctx->Driver.WriteMonoCISpan = NULL;
+    ctx->Driver.WriteCI32Pixels = NULL;
+    ctx->Driver.WriteMonoCIPixels = NULL;
+    ctx->Driver.ReadCI32Span = NULL;
+    ctx->Driver.ReadCI32Pixels = NULL;
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxddtex.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxddtex.c:1.3
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxddtex.c	Fri Dec  8 16:34:20 2000
@@ -0,0 +1,1737 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxddtex.c,v 1.3 2000/12/08 21:34:20 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#include "fxdrv.h"
+#include "fxddtex.h"
+#include "fxtexman.h"
+#include "fxsetup.h"
+#include "image.h"
+#include "texutil.h"
+
+
+void
+fxPrintTextureData(tfxTexInfo * ti)
+{
+    fprintf(stderr, "Texture Data:\n");
+    if (ti->tObj) {
+        fprintf(stderr, "\tName: %d\n", ti->tObj->Name);
+        fprintf(stderr, "\tBaseLevel: %d\n", ti->tObj->BaseLevel);
+        fprintf(stderr, "\tSize: %d x %d\n",
+                ti->tObj->Image[ti->tObj->BaseLevel]->Width,
+                ti->tObj->Image[ti->tObj->BaseLevel]->Height);
+    }
+    else
+        fprintf(stderr, "\tName: UNNAMED\n");
+    fprintf(stderr, "\tLast used: %d\n", ti->lastTimeUsed);
+    fprintf(stderr, "\tTMU: %ld\n", (unsigned long)ti->whichTMU);
+    fprintf(stderr, "\t%s\n", (ti->isInTM) ? "In TMU" : "Not in TMU");
+    if (ti->tm[0])
+        fprintf(stderr, "\tMem0: %x-%x\n", (unsigned) ti->tm[0]->startAddr,
+                (unsigned) ti->tm[0]->endAddr);
+    if (ti->tm[1])
+        fprintf(stderr, "\tMem1: %x-%x\n", (unsigned) ti->tm[1]->startAddr,
+                (unsigned) ti->tm[1]->endAddr);
+    fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel);
+    fprintf(stderr, "\tFilters: min %d min %d\n",
+            (int) ti->minFilt, (int) ti->maxFilt);
+    fprintf(stderr, "\tClamps: s %d t %d\n", (int) ti->sClamp,
+            (int) ti->tClamp);
+    fprintf(stderr, "\tScales: s %f t %f\n", ti->sScale, ti->tScale);
+    fprintf(stderr, "\tInt Scales: s %d t %d\n",
+            ti->int_sScale / 0x800000, ti->int_tScale / 0x800000);
+    fprintf(stderr, "\t%s\n",
+            (ti->fixedPalette) ? "Fixed palette" : "Non fixed palette");
+    fprintf(stderr, "\t%s\n",
+            (ti->validated) ? "Validated" : "Not validated");
+}
+
+
+/************************************************************************/
+/*************************** Texture Mapping ****************************/
+/************************************************************************/
+
+static void
+fxTexInvalidate(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    tfxTexInfo *ti;
+
+    ti = fxTMGetTexInfo(tObj);
+    if (ti->isInTM)
+        fxTMMoveOutTM(fxMesa, tObj); /* TO DO: SLOW but easy to write */
+
+    ti->validated = GL_FALSE;
+    fxMesa->new_state |= FX_NEW_TEXTURING;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+static tfxTexInfo *
+fxAllocTexObjData(fxMesaContext fxMesa)
+{
+    tfxTexInfo *ti;
+    int i;
+
+    if (!(ti = CALLOC(sizeof(tfxTexInfo)))) {
+        gl_problem(NULL, "fx Driver: out of memory !\n");
+        return NULL;
+    }
+
+    ti->validated = GL_FALSE;
+    ti->isInTM = GL_FALSE;
+
+    ti->whichTMU = FX_TMU_NONE;
+
+    ti->tm[FX_TMU0] = NULL;
+    ti->tm[FX_TMU1] = NULL;
+
+    ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+    ti->maxFilt = GR_TEXTUREFILTER_BILINEAR;
+
+    ti->sClamp = GR_TEXTURECLAMP_WRAP;
+    ti->tClamp = GR_TEXTURECLAMP_WRAP;
+
+    ti->mmMode = GR_MIPMAP_NEAREST;
+    ti->LODblend = FXFALSE;
+
+    for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+        ti->mipmapLevel[i].data = NULL;
+    }
+
+    return ti;
+}
+
+
+/*
+ * Called via glBindTexture.
+ */
+void
+fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    tfxTexInfo *ti;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDTexBind(%d,%x)\n", tObj->Name,
+                tObj->DriverData);
+    }
+
+    if (target != GL_TEXTURE_2D)
+        return;
+
+    if (!tObj->DriverData) {
+        tObj->DriverData = fxAllocTexObjData(fxMesa);
+    }
+
+    ti = fxTMGetTexInfo(tObj);
+
+    fxMesa->texBindNumber++;
+    ti->lastTimeUsed = fxMesa->texBindNumber;
+
+    fxMesa->new_state |= FX_NEW_TEXTURING;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+void
+fxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
+           const GLfloat * param)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        if (param)
+            fprintf(stderr, "fxmesa: texenv(%x,%x)\n", pname,
+                    (GLint) (*param));
+        else
+            fprintf(stderr, "fxmesa: texenv(%x)\n", pname);
+    }
+
+    /* apply any lod biasing right now */
+    if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
+        FX_grTexLodBiasValue(GR_TMU0, *param);
+        if (fxMesa->haveTwoTMUs) {
+            FX_grTexLodBiasValue(GR_TMU1, *param);
+        }
+    }
+
+    /* invalidate currently bound texture(s) */
+    {
+       int i;
+       for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+          struct gl_texture_object *tObj = ctx->Texture.Unit[i].CurrentD[2];
+          if (!tObj->DriverData) {
+             tObj->DriverData = fxAllocTexObjData(fxMesa);
+          }
+          fxTexInvalidate(ctx, tObj);
+       }
+    }
+
+    fxMesa->new_state |= FX_NEW_TEXTURING;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+void
+fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj,
+             GLenum pname, const GLfloat * params)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLenum param = (GLenum) (GLint) params[0];
+    tfxTexInfo *ti;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDTexParam(%d,%x,%x,%x)\n", tObj->Name,
+                tObj->DriverData, pname, param);
+    }
+
+    if (target != GL_TEXTURE_2D)
+        return;
+
+    if (!tObj->DriverData)
+        tObj->DriverData = fxAllocTexObjData(fxMesa);
+
+    ti = fxTMGetTexInfo(tObj);
+
+    switch (pname) {
+
+    case GL_TEXTURE_MIN_FILTER:
+        switch (param) {
+        case GL_NEAREST:
+            ti->mmMode = GR_MIPMAP_DISABLE;
+            ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+            ti->LODblend = FXFALSE;
+            break;
+        case GL_LINEAR:
+            ti->mmMode = GR_MIPMAP_DISABLE;
+            ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+            ti->LODblend = FXFALSE;
+            break;
+        case GL_NEAREST_MIPMAP_NEAREST:
+            ti->mmMode = GR_MIPMAP_NEAREST;
+            ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+            ti->LODblend = FXFALSE;
+            break;
+        case GL_LINEAR_MIPMAP_NEAREST:
+            ti->mmMode = GR_MIPMAP_NEAREST;
+            ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+            ti->LODblend = FXFALSE;
+            break;
+        case GL_NEAREST_MIPMAP_LINEAR:
+            if (fxMesa->haveTwoTMUs) {
+                ti->mmMode = GR_MIPMAP_NEAREST;
+                ti->LODblend = FXTRUE;
+            }
+            else {
+                ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+                ti->LODblend = FXFALSE;
+            }
+            ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+            break;
+        case GL_LINEAR_MIPMAP_LINEAR:
+            if (fxMesa->haveTwoTMUs) {
+                ti->mmMode = GR_MIPMAP_NEAREST;
+                ti->LODblend = FXTRUE;
+            }
+            else {
+                ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+                ti->LODblend = FXFALSE;
+            }
+            ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+            break;
+        default:
+            break;
+        }
+        fxTexInvalidate(ctx, tObj);
+        break;
+
+    case GL_TEXTURE_MAG_FILTER:
+        switch (param) {
+        case GL_NEAREST:
+            ti->maxFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+            break;
+        case GL_LINEAR:
+            ti->maxFilt = GR_TEXTUREFILTER_BILINEAR;
+            break;
+        default:
+            break;
+        }
+        fxTexInvalidate(ctx, tObj);
+        break;
+
+    case GL_TEXTURE_WRAP_S:
+        switch (param) {
+        case GL_CLAMP:
+            ti->sClamp = GR_TEXTURECLAMP_CLAMP;
+            break;
+        case GL_REPEAT:
+            ti->sClamp = GR_TEXTURECLAMP_WRAP;
+            break;
+        default:
+            break;
+        }
+        fxMesa->new_state |= FX_NEW_TEXTURING;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+        break;
+
+    case GL_TEXTURE_WRAP_T:
+        switch (param) {
+        case GL_CLAMP:
+            ti->tClamp = GR_TEXTURECLAMP_CLAMP;
+            break;
+        case GL_REPEAT:
+            ti->tClamp = GR_TEXTURECLAMP_WRAP;
+            break;
+        default:
+            break;
+        }
+        fxMesa->new_state |= FX_NEW_TEXTURING;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+        break;
+
+    case GL_TEXTURE_BORDER_COLOR:
+        /* TO DO */
+        break;
+
+    case GL_TEXTURE_MIN_LOD:
+        /* TO DO */
+        break;
+    case GL_TEXTURE_MAX_LOD:
+        /* TO DO */
+        break;
+    case GL_TEXTURE_BASE_LEVEL:
+        fxTexInvalidate(ctx, tObj);
+        break;
+    case GL_TEXTURE_MAX_LEVEL:
+        fxTexInvalidate(ctx, tObj);
+        break;
+
+    default:
+        break;
+    }
+}
+
+
+/*
+ * Called via glDeleteTextures to delete a texture object.
+ * Here, we delete the Glide data associated with the texture.
+ */
+void
+fxDDTexDel(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    fxTMFreeTexture(fxMesa, tObj);
+    ctx->NewState |= NEW_TEXTURING;
+}
+
+
+/*
+ * Return true if texture is resident, false otherwise.
+ */
+GLboolean
+fxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj)
+{
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+    /*printf("resident %d\n", (int) (ti && ti->isInTM));*/
+    return (GLboolean) (ti && ti->isInTM);
+}
+
+
+
+/*
+ * Convert a gl_color_table texture palette to Glide's format.
+ */
+static void
+convertPalette(FxU32 data[256], const struct gl_color_table *table)
+{
+    const GLubyte *tableUB = (const GLubyte *) table->Table;
+    GLint width = table->Size;
+    FxU32 r, g, b, a;
+    GLint i;
+
+    ASSERT(table->TableType == GL_UNSIGNED_BYTE);
+
+    switch (table->Format) {
+    case GL_INTENSITY:
+        for (i = 0; i < width; i++) {
+            r = tableUB[i];
+            g = tableUB[i];
+            b = tableUB[i];
+            a = tableUB[i];
+            data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+        }
+        break;
+    case GL_LUMINANCE:
+        for (i = 0; i < width; i++) {
+            r = tableUB[i];
+            g = tableUB[i];
+            b = tableUB[i];
+            a = 255;
+            data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+        }
+        break;
+    case GL_ALPHA:
+        for (i = 0; i < width; i++) {
+            r = g = b = 255;
+            a = tableUB[i];
+            data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+        }
+        break;
+    case GL_LUMINANCE_ALPHA:
+        for (i = 0; i < width; i++) {
+            r = g = b = tableUB[i * 2 + 0];
+            a = tableUB[i * 2 + 1];
+            data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+        }
+        break;
+    case GL_RGB:
+        for (i = 0; i < width; i++) {
+            r = tableUB[i * 3 + 0];
+            g = tableUB[i * 3 + 1];
+            b = tableUB[i * 3 + 2];
+            a = 255;
+            data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+        }
+        break;
+    case GL_RGBA:
+        for (i = 0; i < width; i++) {
+            r = tableUB[i * 4 + 0];
+            g = tableUB[i * 4 + 1];
+            b = tableUB[i * 4 + 2];
+            a = tableUB[i * 4 + 3];
+            data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+        }
+        break;
+    }
+}
+
+
+
+void
+fxDDTexPalette(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+    if (tObj) {
+        /* per-texture palette */
+        tfxTexInfo *ti;
+        if (MESA_VERBOSE & VERBOSE_DRIVER) {
+            fprintf(stderr, "fxmesa: fxDDTexPalette(%d,%x)\n",
+                    tObj->Name, tObj->DriverData);
+        }
+        if (!tObj->DriverData)
+            tObj->DriverData = fxAllocTexObjData(fxMesa);
+        ti = fxTMGetTexInfo(tObj);
+        convertPalette(ti->palette.data, &tObj->Palette);
+        fxTexInvalidate(ctx, tObj);
+    }
+    else {
+        /* global texture palette */
+        if (MESA_VERBOSE & VERBOSE_DRIVER) {
+            fprintf(stderr, "fxmesa: fxDDTexPalette(global)\n");
+        }
+        convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette);
+        fxMesa->new_state |= FX_NEW_TEXTURING;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+    }
+}
+
+
+/*
+ * Enable/disable the shared texture palette feature.
+ */
+void
+fxDDTexUseGlbPalette(GLcontext * ctx, GLboolean state)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDTexUseGlbPalette(%d)\n", state);
+    }
+
+    if (state) {
+        FX_grTexDownloadTable(fxMesa, GR_TMU0, GR_TEXTABLE_PALETTE_6666_EXT,
+                              &(fxMesa->glbPalette));
+        if (fxMesa->haveTwoTMUs)
+            FX_grTexDownloadTable(fxMesa, GR_TMU1, GR_TEXTABLE_PALETTE_6666_EXT,
+                                  &(fxMesa->glbPalette));
+    }
+    else {
+        if ((ctx->Texture.Unit[0].Current == ctx->Texture.Unit[0].CurrentD[2])
+            && (ctx->Texture.Unit[0].Current != NULL)) {
+            struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current;
+
+            if (!tObj->DriverData)
+                tObj->DriverData = fxAllocTexObjData(fxMesa);
+
+            fxTexInvalidate(ctx, tObj);
+        }
+    }
+}
+
+
+static int
+logbase2(int n)
+{
+    GLint i = 1;
+    GLint log2 = 0;
+
+    if (n < 0) {
+        return -1;
+    }
+
+    while (n > i) {
+        i *= 2;
+        log2++;
+    }
+    if (i != n) {
+        return -1;
+    }
+    else {
+        return log2;
+    }
+}
+
+/* Need different versions for different cpus.
+ */
+#define INT_TRICK(pow2) (0x800000 * (pow2))
+
+/*
+ * Compute various texture image parameters.
+ * Input:  w, h - source texture width and height
+ * Output:  lodlevel - Glide lod level token
+ *          aspectratio - Glide aspect ratio token
+ *          sscale - S scale factor used during triangle setup
+ *          tscale - T scale factor used during triangle setup
+ *          i_sscale - integer S scale used during triangle setup
+ *          i_tscale - integer T scale used during triangle setup
+ *          wscale - OpenGL -> Glide image width scale factor
+ *          hscale - OpenGL -> Glide image height scale factor
+ */
+void
+fxTexGetInfo(const GLcontext *ctx, int w, int h,
+             GrLOD_t *lodlevel, GrAspectRatio_t *aspectratio,
+             float *sscale, float *tscale,
+             int *i_sscale, int *i_tscale,
+             int *wscale, int *hscale)
+{
+    int logw, logh, ar, lod, is, it, ws, hs;
+    float s, t;
+
+    ASSERT(w >= 1);
+    ASSERT(h >= 1);
+
+    logw = logbase2(w);
+    logh = logbase2(h);
+    ar = logw - logh;  /* aspect ratio = difference in log dimensions */
+
+    /* Hardware only allows a maximum aspect ratio of 8x1, so handle
+       |ar| > 3 by scaling the image and using an 8x1 aspect ratio */
+    if (ar >= 0) {
+        ASSERT(width >= height);
+        lod = logw;
+#if 1
+        s = 256.0;
+        is = INT_TRICK(8);
+#else
+        s = ctx->Const.MaxTextureSize;
+        is = INT_TRICK(ctx->Const.MaxTextureLevels - 1);
+#endif
+        ws = 1;
+        if (ar < 3) {
+#if 1
+            t = 256 >> ar;
+            it = INT_TRICK(8 - ar);
+#else
+            t = ctx->Const.MaxTextureSize >> ar;
+            it = INT_TRICK(ctx->Const.MaxTextureLevels - 1 - ar);
+#endif
+            hs = 1;
+        }
+        else {
+            t = 32.0;
+            it = INT_TRICK(5);
+            hs = 1 << (ar - 3);
+        }
+    }
+    else {
+        ASSERT(width < height);
+        lod = logh;
+#if 1
+        t = 256.0;
+        it = INT_TRICK(8);
+#else
+        t = ctx->Const.MaxTextureSize;
+        it = INT_TRICK(ctx->Const.MaxTextureLevels - 1);
+#endif
+        hs = 1;
+        if (-ar < 3) {
+#if 1
+            s = 256 >> -ar;
+            is = INT_TRICK(8 + ar);
+#else
+            s = ctx->Const.MaxTextureSize >> - ar;
+            is = INT_TRICK(ctx->Const.MaxTextureLevels - 1 + ar);
+#endif
+            ws = 1;
+        }
+        else {
+            s = 32.0;
+            is = INT_TRICK(5);
+            ws = 1 << (-ar - 3);
+        }
+    }
+    if (ar < -3)
+        ar = -3;
+    if (ar > 3)
+        ar = 3;
+
+    if (lodlevel)
+        *lodlevel = (GrLOD_t) lod;
+    if (aspectratio)
+        *aspectratio = (GrAspectRatio_t) ar;
+    if (sscale)
+        *sscale = s;
+    if (tscale)
+        *tscale = t;
+    if (wscale)
+        *wscale = ws;
+    if (hscale)
+        *hscale = hs;
+    if (i_sscale)
+        *i_sscale = is;
+    if (i_tscale)
+        *i_tscale = it;
+}
+
+/*
+ * Given an OpenGL internal texture format, return the corresponding
+ * Glide internal texture format and base texture format.
+ * If allow32bpp is true, we'll return 32-bit texel formats when
+ * appropriate.
+ */
+void
+fxTexGetFormat(GLenum glformat, GrTextureFormat_t *glideFormat,
+               GLint *glFormat, MesaIntTexFormat *mesaFormat,
+               GLint *texelSize, GLboolean allow32bpp)
+{
+    switch (glformat) {
+    case 1:
+    case GL_LUMINANCE:
+    case GL_LUMINANCE4:
+    case GL_LUMINANCE8:
+    case GL_LUMINANCE12:
+    case GL_LUMINANCE16:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_INTENSITY_8;
+        if (glFormat)
+            *glFormat = GL_LUMINANCE;
+        if (mesaFormat)
+            *mesaFormat = MESA_L8;
+        if (texelSize)
+            *texelSize = 1;
+        break;
+    case 2:
+    case GL_LUMINANCE_ALPHA:
+    case GL_LUMINANCE4_ALPHA4:
+    case GL_LUMINANCE6_ALPHA2:
+    case GL_LUMINANCE8_ALPHA8:
+    case GL_LUMINANCE12_ALPHA4:
+    case GL_LUMINANCE12_ALPHA12:
+    case GL_LUMINANCE16_ALPHA16:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_ALPHA_INTENSITY_88;
+        if (glFormat)
+            *glFormat = GL_LUMINANCE_ALPHA;
+        if (mesaFormat)
+            *mesaFormat = MESA_A8_L8;
+        if (texelSize)
+            *texelSize = 2;
+        break;
+    case GL_INTENSITY:
+    case GL_INTENSITY4:
+    case GL_INTENSITY8:
+    case GL_INTENSITY12:
+    case GL_INTENSITY16:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_ALPHA_8;
+        if (glFormat)
+            *glFormat = GL_INTENSITY;
+        if (mesaFormat)
+            *mesaFormat = MESA_I8;
+        if (texelSize)
+            *texelSize = 1;
+       break;
+    case GL_ALPHA:
+    case GL_ALPHA4:
+    case GL_ALPHA8:
+    case GL_ALPHA12:
+    case GL_ALPHA16:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_ALPHA_8;
+        if (glFormat)
+            *glFormat = GL_ALPHA;
+        if (mesaFormat)
+            *mesaFormat = MESA_A8;
+        if (texelSize)
+            *texelSize = 1;
+        break;
+    case GL_R3_G3_B2:
+    case GL_RGB4:
+    case GL_RGB5:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_RGB_565;
+        if (glFormat)
+            *glFormat = GL_RGB;
+        if (mesaFormat)
+            *mesaFormat = MESA_R5_G6_B5;
+        if (texelSize)
+            *texelSize = 2;
+        break;
+    case 3:
+    case GL_RGB:
+    case GL_RGB8:
+    case GL_RGB10:
+    case GL_RGB12:
+    case GL_RGB16:
+        if (allow32bpp) {
+            if (glideFormat)
+                *glideFormat = GR_TEXFMT_ARGB_8888;
+            if (glFormat)
+                *glFormat = GL_RGB;
+            if (mesaFormat)
+                *mesaFormat = MESA_FF_R8_G8_B8;
+            if (texelSize)
+                *texelSize = 4;
+        }
+        else {
+            if (glideFormat)
+                *glideFormat = GR_TEXFMT_RGB_565;
+            if (glFormat)
+                *glFormat = GL_RGB;
+            if (mesaFormat)
+                *mesaFormat = MESA_R5_G6_B5;
+            if (texelSize)
+                *texelSize = 2;
+        }
+        break;
+    case GL_RGBA2:
+    case GL_RGBA4:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_ARGB_4444;
+        if (glFormat)
+            *glFormat = GL_RGBA;
+        if (mesaFormat)
+            *mesaFormat = MESA_A4_R4_G4_B4;
+        if (texelSize)
+            *texelSize = 2;
+        break;
+    case 4:
+    case GL_RGBA:
+    case GL_RGBA8:
+    case GL_RGB10_A2:
+    case GL_RGBA12:
+    case GL_RGBA16:
+        if (allow32bpp) {
+            if (glideFormat)
+                *glideFormat = GR_TEXFMT_ARGB_8888;
+            if (glFormat)
+                *glFormat = GL_RGBA;
+            if (mesaFormat)
+                *mesaFormat = MESA_A8_R8_G8_B8;
+            if (texelSize)
+                *texelSize = 4;
+        }
+        else {
+            if (glideFormat)
+                *glideFormat = GR_TEXFMT_ARGB_4444;
+            if (glFormat)
+                *glFormat = GL_RGBA;
+            if (mesaFormat)
+                *mesaFormat = MESA_A4_R4_G4_B4;
+            if (texelSize)
+                *texelSize = 2;
+        }
+        break;
+    case GL_RGB5_A1:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_ARGB_1555;
+        if (glFormat)
+            *glFormat = GL_RGBA;
+        if (mesaFormat)
+            *mesaFormat = MESA_A1_R5_G5_B5;
+        if (texelSize)
+           *texelSize = 2;
+        break;
+    case GL_COLOR_INDEX:
+    case GL_COLOR_INDEX1_EXT:
+    case GL_COLOR_INDEX2_EXT:
+    case GL_COLOR_INDEX4_EXT:
+    case GL_COLOR_INDEX8_EXT:
+    case GL_COLOR_INDEX12_EXT:
+    case GL_COLOR_INDEX16_EXT:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_P_8;
+        if (glFormat)
+            *glFormat = GL_RGBA;  /* XXX why is this RGBA? */
+        if (mesaFormat)
+            *mesaFormat = MESA_C8;
+        if (texelSize)
+            *texelSize = 1;
+        break;
+    case GL_COMPRESSED_RGB_FXT1_3DFX:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_ARGB_CMP_FXT1;
+        if (glFormat)
+            *glFormat = GL_COMPRESSED_RGB_FXT1_3DFX;
+        if (mesaFormat)
+            *mesaFormat = MESA_A8_R8_G8_B8;
+        if (texelSize)
+            *texelSize = 4;
+        break;
+    case GL_COMPRESSED_RGBA_FXT1_3DFX:
+        if (glideFormat)
+            *glideFormat = GR_TEXFMT_ARGB_CMP_FXT1;
+        if (glFormat)
+            *glFormat = GL_COMPRESSED_RGBA_FXT1_3DFX;
+        if (mesaFormat)
+            *mesaFormat = MESA_A8_R8_G8_B8;
+        if (texelSize)
+            *texelSize = 4;
+        break;
+    default:
+        gl_problem(NULL, "bad texture format in fxTexGetFormat()\n");
+        break;
+    }
+}
+
+
+/**********************************************************************/
+/**** NEW TEXTURE IMAGE FUNCTIONS                                  ****/
+/**********************************************************************/
+
+static FxBool TexusFatalError = FXFALSE;
+static FxBool TexusError = FXFALSE;
+
+#define TX_DITHER_NONE                                  0x00000000
+
+static void
+fxTexusError(const char *string, FxBool fatal)
+{
+    gl_problem(NULL, string);
+   /*
+    * Just propagate the fatal value up.
+    */
+    TexusError = FXTRUE;
+    TexusFatalError = fatal;
+}
+
+GLboolean
+fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+               GLenum format, GLenum type, const GLvoid * pixels,
+               const struct gl_pixelstore_attrib * packing,
+               struct gl_texture_object * texObj,
+               struct gl_texture_image * texImage,
+               GLboolean * retainInternalCopy)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    const GLboolean allow32bpt = fxMesa->haveHwStencil;
+    GrTextureFormat_t gldformat;
+    tfxTexInfo *ti;
+    tfxMipMapLevel *mml;
+    GLint dstWidth, dstHeight, wScale, hScale, texelSize, dstStride;
+    MesaIntTexFormat intFormat;
+    GLboolean isCompressedFormat;
+    GLint texsize;
+    void *uncompressedImage;
+
+    isCompressedFormat = texImage->IsCompressed;
+    if (target != GL_TEXTURE_2D || texImage->Border > 0)
+        return GL_FALSE;
+
+    if (!texObj->DriverData)
+        texObj->DriverData = fxAllocTexObjData(fxMesa);
+
+    ti = fxTMGetTexInfo(texObj);
+    mml = &ti->mipmapLevel[level];
+
+    /* Determine the appropriate GL internal texel format, Mesa internal
+     * texel format, and texelSize (bytes) given the user's internal
+     * texture format hint.
+     */
+    fxTexGetFormat(texImage->IntFormat, &gldformat, NULL, &intFormat,
+                   &texelSize, allow32bpt);
+
+    /* Determine width and height scale factors for texture.
+     * Remember, Glide is limited to 8:1 aspect ratios.
+     */
+    fxTexGetInfo(ctx,
+                 texImage->Width, texImage->Height,
+                 NULL,       /* lod level          */
+                 NULL,       /* aspect ratio       */
+                 NULL, NULL, /* sscale, tscale     */
+                 NULL, NULL, /* i_sscale, i_tscale */
+                 &wScale, &hScale);
+    dstWidth = texImage->Width * wScale;
+    dstHeight = texImage->Height * hScale;
+    if (isCompressedFormat) {
+        texsize = fxDDCompressedImageSize(ctx,
+                                          texImage->IntFormat,
+                                          2,
+                                          texImage->Width,
+                                          texImage->Height,
+                                          1);
+    } else {
+        texsize = dstWidth * dstHeight * texelSize;
+    }
+   /*
+    * If the image is not compressed, this doesn't
+    * matter, but it might as well have a sensible
+    * value, and it might save a failure later on.
+    */
+    texImage->CompressedSize = texsize;
+    /* housekeeping */
+    _mesa_set_teximage_component_sizes(intFormat, texImage);
+
+    /*
+     * allocate new storage for texture image, if needed.
+     * This conditional wants to set uncompressedImage to
+     * point to the uncompressed image, and mml->data to
+     * the texture data.  If the image is uncompressed,
+     * these are identical.  If the image is not compressed,
+     * these are different.
+     */
+    if (!mml->data || mml->glideFormat != gldformat ||
+        mml->width != dstWidth || mml->height != dstHeight ||
+        texsize != mml->dataSize ) {
+        if (mml->data) {
+            FREE(mml->data);
+        }
+        uncompressedImage
+            = (void *)MALLOC(dstWidth * dstHeight * texelSize);
+        if (!uncompressedImage) {
+            return(GL_FALSE);
+        }
+        if (isCompressedFormat) {
+            mml->data = MALLOC(texsize);
+            if (!mml->data) {
+                FREE(uncompressedImage);
+                return GL_FALSE;
+            }
+        } else {
+            mml->data = uncompressedImage;
+        }
+        mml->texelSize = texelSize;
+        mml->glideFormat = gldformat;
+        mml->width = dstWidth;
+        mml->height = dstHeight;
+        mml->dataSize = texsize;
+        fxTexInvalidate(ctx, texObj);
+    } else {
+       /*
+        * Here we don't have to allocate anything, but we
+        * do have to point uncompressedImage to the uncompressed
+        * data.
+        */
+        if (isCompressedFormat) {
+            uncompressedImage
+                = (void *)MALLOC(dstWidth * dstHeight * texelSize);
+            if (!uncompressedImage) {
+                return GL_FALSE;
+            }
+        } else {
+            uncompressedImage = mml->data;
+        }
+    }
+
+    dstStride = dstWidth * texelSize;
+
+    /* store the texture image into uncompressedImage */
+    if (!_mesa_convert_teximage(intFormat,
+                                dstWidth, dstHeight,
+                                uncompressedImage,
+                                dstStride,
+                                texImage->Width, texImage->Height,
+                                format, type, pixels, packing)) {
+        /*printf("convert failed\n");*/
+        return GL_FALSE;  /* not necessarily an error */
+    }
+   /*
+    * Now compress it if necessary.
+    */
+    if (isCompressedFormat) {
+        TxErrorCallbackFnc_t oldErrorCallback;
+        (*txErrorSetCallbackPtr)(fxTexusError, &oldErrorCallback);
+        (*txImgQuantizePtr)((char *)mml->data,
+                            (char *)uncompressedImage,
+                            texImage->Width,
+                            texImage->Height,
+                            gldformat,
+                            TX_DITHER_NONE);
+        (*txErrorSetCallbackPtr)(oldErrorCallback, NULL);
+        if (uncompressedImage != mml->data) {
+            /*
+             * We do not need this any more, errors or no.
+             */
+            FREE(uncompressedImage);
+        }
+        TexusError = FXFALSE;
+        if (TexusFatalError) {
+            FREE(mml->data);
+            mml->data = (unsigned short *)0;
+            TexusFatalError = FXFALSE;
+            return(GL_FALSE);
+        }
+    }
+    if (ti->validated && ti->isInTM) {
+        fxTMReloadMipMapLevel(ctx, texObj, level);
+    }
+    else {
+        fxTexInvalidate(ctx, texObj);
+    }
+
+    *retainInternalCopy = GL_FALSE;
+    return GL_TRUE;
+}
+
+
+GLboolean
+fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
+                  GLint xoffset, GLint yoffset,
+                  GLsizei width, GLsizei height,
+                  GLenum format, GLenum type, const GLvoid * pixels,
+                  const struct gl_pixelstore_attrib * packing,
+                  struct gl_texture_object * texObj,
+                  struct gl_texture_image * texImage)
+{
+    tfxTexInfo *ti;
+    GLint wscale, hscale, dstStride = 0;
+    tfxMipMapLevel *mml;
+    GLboolean result;
+    void *uncompressedImage = (void *)0;
+    FxU32 uncompressedSize;
+    TxErrorCallbackFnc_t oldErrorCallback;
+
+    if (target != GL_TEXTURE_2D)
+        return GL_FALSE;
+
+    if (!texObj->DriverData)
+        return GL_FALSE;
+
+    ti = fxTMGetTexInfo(texObj);
+    mml = &ti->mipmapLevel[level];
+
+    fxTexGetInfo(ctx, texImage->Width, texImage->Height, NULL, NULL,
+                 NULL, NULL, NULL, NULL, &wscale, &hscale);
+
+    /*
+     * Must have an existing texture image!
+     */
+    assert(mml->data);
+
+    switch (mml->glideFormat) {
+    case GR_TEXFMT_INTENSITY_8:
+        dstStride = mml->width;
+        result = _mesa_convert_texsubimage(MESA_I8, xoffset, yoffset,
+                                           mml->width, mml->height, mml->data,
+                                           dstStride, width, height,
+                                           texImage->Width, texImage->Height,
+                                           format, type, pixels, packing);
+        break;
+    case GR_TEXFMT_ALPHA_8:
+        dstStride = mml->width;
+        result = _mesa_convert_texsubimage(MESA_A8, xoffset, yoffset,
+                                           mml->width, mml->height, mml->data,
+                                           dstStride, width, height,
+                                           texImage->Width, texImage->Height,
+                                           format, type, pixels, packing);
+        break;
+    case GR_TEXFMT_P_8:
+        dstStride = mml->width;
+        result = _mesa_convert_texsubimage(MESA_C8, xoffset, yoffset,
+                                           mml->width, mml->height, mml->data,
+                                           dstStride, width, height,
+                                           texImage->Width, texImage->Height,
+                                           format, type, pixels, packing);
+        break;
+    case GR_TEXFMT_ALPHA_INTENSITY_88:
+        dstStride = mml->width * 2;
+        result = _mesa_convert_texsubimage(MESA_A8_L8, xoffset, yoffset,
+                                           mml->width, mml->height, mml->data,
+                                           dstStride, width, height,
+                                           texImage->Width, texImage->Height,
+                                           format, type, pixels, packing);
+        break;
+    case GR_TEXFMT_RGB_565:
+        dstStride = mml->width * 2;
+        result = _mesa_convert_texsubimage(MESA_R5_G6_B5, xoffset, yoffset,
+                                           mml->width, mml->height, mml->data,
+                                           dstStride, width, height,
+                                           texImage->Width, texImage->Height,
+                                           format, type, pixels, packing);
+        break;
+    case GR_TEXFMT_ARGB_4444:
+        dstStride = mml->width * 2;
+        result = _mesa_convert_texsubimage(MESA_A4_R4_G4_B4, xoffset, yoffset,
+                                           mml->width, mml->height, mml->data,
+                                           dstStride, width, height,
+                                           texImage->Width, texImage->Height,
+                                           format, type, pixels, packing);
+        break;
+    case GR_TEXFMT_ARGB_CMP_FXT1:
+        /*
+         * There are some special legality constraints for compressed
+         * textures.
+         */
+        if ((xoffset != texImage->Border)
+            || (yoffset != texImage->Border)) {
+            gl_error( ctx,
+                      GL_INVALID_OPERATION,
+                      "glTexSubImage2D(offset)" );
+            return GL_FALSE;
+        }
+        if ((width != texImage->Width)
+            || (height != texImage->Height)) {
+            gl_error( ctx,
+                      GL_INVALID_VALUE,
+                      "glTexSubImage2D(image size)" );
+            return GL_FALSE;
+        }
+        /*
+         * The width and height have to be multiples of
+         * 8 and 4 respectively.
+         */
+        width  = (mml->width  + 0x7) &~ 0x7;
+        height = (mml->height + 0x3) &~ 0x3;
+        /*
+         * A texel is 8888 for this format. 
+         */
+        uncompressedSize = mml->width * mml->height * 4;
+        uncompressedImage = (void *)MALLOC(uncompressedSize);
+        /*
+         * Convert the data.
+         */
+        dstStride = mml->width * 4;
+        result = _mesa_convert_texsubimage(MESA_A8_R8_G8_B8, xoffset, yoffset,
+                                           mml->width, mml->height, uncompressedImage,
+                                           dstStride, width, height,
+                                           texImage->Width, texImage->Height,
+                                           format, type, pixels, packing);
+        if (!result) {
+            FREE(uncompressedImage);
+            return GL_FALSE;
+        }
+        /*
+         * Now that we have converted the data, then compress it.
+         */
+        (*txErrorSetCallbackPtr)(fxTexusError, &oldErrorCallback);
+        (*txImgQuantizePtr)((char *)mml->data,
+                            (char *)uncompressedImage,
+                            mml->width,
+                            mml->height,
+                            mml->glideFormat,
+                            TX_DITHER_NONE);
+        (*txErrorSetCallbackPtr)(oldErrorCallback, NULL);
+        result = TexusFatalError;
+        TexusFatalError = TexusError = FXFALSE;
+        /*
+         * We don't need this any more.
+         */
+        FREE(uncompressedImage);
+        break;
+    case GR_TEXFMT_ARGB_8888:
+        {
+            MesaIntTexFormat intFormat;
+            if (texImage->Format == GL_RGB) {
+                /* An RGB image padded out to 4 bytes/texel */
+                intFormat = MESA_FF_R8_G8_B8;
+            }
+            else {
+                intFormat = MESA_A8_R8_G8_B8;
+            }
+            dstStride = mml->width * 4;
+            result = _mesa_convert_texsubimage(intFormat, xoffset, yoffset,
+                                            mml->width, mml->height, mml->data,
+                                            dstStride, width, height,
+                                            texImage->Width, texImage->Height,
+                                            format, type, pixels, packing);
+        }
+        break;
+    case GR_TEXFMT_ARGB_1555:
+        dstStride = mml->width * 2;
+        result = _mesa_convert_texsubimage(MESA_A1_R5_G5_B5, xoffset, yoffset,
+                                           mml->width, mml->height, mml->data,
+                                           dstStride, width, height,
+                                           texImage->Width, texImage->Height,
+                                           format, type, pixels, packing);
+        break;
+    default:
+        gl_problem(NULL, "tdfx driver: fxTexBuildSubImageMap() bad format");
+        result = GL_FALSE;
+    }
+
+    if (!result) {
+        return GL_FALSE;
+    }
+
+    if (ti->validated && ti->isInTM)
+        /* Don't use this, it's very broken.  Download whole image for now.*/
+#if 0
+        fxTMReloadSubMipMapLevel(ctx, texObj, level, yoffset, height);
+#else
+        fxTMReloadMipMapLevel(ctx, texObj, level);
+#endif
+    else
+        fxTexInvalidate(ctx, texObj);
+
+    return GL_TRUE;
+}
+
+
+/**********************************************************************/
+/**** COMPRESSED TEXTURE IMAGE FUNCTIONS                           ****/
+/**********************************************************************/
+
+GLboolean
+fxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
+                          GLint level, GLsizei imageSize,
+                          const GLvoid *data,
+                          struct gl_texture_object *texObj,
+                          struct gl_texture_image *texImage,
+                          GLboolean *retainInternalCopy)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    const GLboolean allow32bpt = fxMesa->haveHwStencil;
+    GrTextureFormat_t gldformat;
+    tfxTexInfo *ti;
+    tfxMipMapLevel *mml;
+    GLint dstWidth, dstHeight, wScale, hScale, texelSize;
+    MesaIntTexFormat intFormat;
+    GLboolean isCompressedFormat;
+    GLsizei texsize;
+
+    if (target != GL_TEXTURE_2D || texImage->Border > 0)
+        return GL_FALSE;
+
+    if (!texObj->DriverData)
+        texObj->DriverData = fxAllocTexObjData(fxMesa);
+
+    ti = fxTMGetTexInfo(texObj);
+    mml = &ti->mipmapLevel[level];
+
+    isCompressedFormat = fxDDIsCompressedGlideFormatMacro(texImage->IntFormat);
+    if (!isCompressedFormat) {
+        gl_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage2D(format)" );
+        return GL_FALSE;
+    } 
+    /* Determine the apporpriate GL internal texel format, Mesa internal
+     * texel format, and texelSize (bytes) given the user's internal
+     * texture format hint.
+     */
+    fxTexGetFormat(texImage->IntFormat, &gldformat, NULL, &intFormat,
+                   &texelSize, allow32bpt);
+
+    /* Determine width and height scale factors for texture.
+     * Remember, Glide is limited to 8:1 aspect ratios.
+     */
+    fxTexGetInfo(ctx,
+                 texImage->Width, texImage->Height,
+                 NULL,       /* lod level          */
+                 NULL,       /* aspect ratio       */
+                 NULL, NULL, /* sscale, tscale     */
+                 NULL, NULL, /* i_sscale, i_tscale */
+                 &wScale, &hScale);
+    dstWidth = texImage->Width * wScale;
+    dstHeight = texImage->Height * hScale;
+    /* housekeeping */
+    _mesa_set_teximage_component_sizes(intFormat, texImage);
+
+    texsize = fxDDCompressedImageSize(ctx,
+                                      texImage->IntFormat,
+                                      2,
+                                      texImage->Width,
+                                      texImage->Height,
+                                      1);
+    if (texsize != imageSize) {
+        gl_error(ctx,
+                 GL_INVALID_VALUE,
+                 "glCompressedTexImage2D(texsize)");
+        return GL_FALSE;
+    }
+    /* allocate new storage for texture image, if needed */
+    if (!mml->data || mml->glideFormat != gldformat ||
+        mml->width != dstWidth || mml->height != dstHeight ||
+        texsize != mml->dataSize) {
+        if (mml->data) {
+            FREE(mml->data);
+        }
+        mml->data = MALLOC(texsize);
+        if (!mml->data) {
+            return GL_FALSE;
+        }
+        mml->texelSize = texelSize;
+        mml->glideFormat = gldformat;
+        mml->width = dstWidth;
+        mml->height = dstHeight;
+        fxTexInvalidate(ctx, texObj);
+    }
+
+    MEMCPY(mml->data, data, imageSize);
+    if (ti->validated && ti->isInTM) {
+        fxTMReloadMipMapLevel(ctx, texObj, level);
+    }
+    else {
+        fxTexInvalidate(ctx, texObj);
+    }
+
+    *retainInternalCopy = GL_FALSE;
+    return GL_TRUE;
+}
+
+GLboolean
+fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
+                             GLint level, GLint xoffset,
+                             GLint yoffset, GLsizei width,
+                             GLint height, GLenum format,
+                             GLsizei imageSize, const GLvoid *data,
+                             struct gl_texture_object *texObj,
+                             struct gl_texture_image *texImage )
+{
+    tfxTexInfo *ti;
+    tfxMipMapLevel *mml;
+   /*
+    * We punt if we are not replacing the entire image.  This
+    * is allowed by the spec.
+    */
+    if ((xoffset != 0) && (yoffset != 0)
+        && (width != texImage->Width)
+        && (height != texImage->Height)) {
+        return(GL_FALSE);
+    }
+    ti = fxTMGetTexInfo(texObj);
+    mml = &ti->mipmapLevel[level];
+    if (imageSize != mml->dataSize) {
+        return(GL_FALSE);
+    }
+    MEMCPY(data, mml->data, imageSize);
+    return(GL_TRUE);
+}
+
+#if	0
+static void
+PrintTexture(int w, int h, int c, const GLubyte * data)
+{
+    int i, j;
+    for (i = 0; i < h; i++) {
+        for (j = 0; j < w; j++) {
+            if (c == 2)
+                printf("%02x %02x  ", data[0], data[1]);
+            else if (c == 3)
+                printf("%02x %02x %02x  ", data[0], data[1], data[2]);
+            data += c;
+        }
+        printf("\n");
+    }
+}
+#endif
+
+
+GLboolean
+fxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
+                      GLint level, GLint internalFormat,
+                      GLenum format, GLenum type,
+                      GLint width, GLint height,
+                      GLint depth, GLint border )
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+    struct TdfxSharedState *shared = (struct TdfxSharedState *) mesaShared->DriverData;
+
+    switch (target) {
+    case GL_PROXY_TEXTURE_1D:
+        return GL_TRUE;  /* software rendering */
+    case GL_PROXY_TEXTURE_2D:
+        {
+            struct gl_texture_object *tObj;
+            tfxTexInfo *ti;
+            int memNeeded;
+
+            tObj = ctx->Texture.Proxy2D;
+            if (!tObj->DriverData)
+                tObj->DriverData = fxAllocTexObjData(fxMesa);
+            ti = fxTMGetTexInfo(tObj);
+
+            /* assign the parameters to test against */
+            tObj->Image[level]->Width = width;
+            tObj->Image[level]->Height = height;
+            tObj->Image[level]->Border = border;
+            tObj->Image[level]->IntFormat = internalFormat;
+            if (level == 0) {
+               /* don't use mipmap levels > 0 */
+               tObj->MinFilter = tObj->MagFilter = GL_NEAREST;
+            }
+            else {
+               /* test with all mipmap levels */
+               tObj->MinFilter = GL_LINEAR_MIPMAP_LINEAR;
+               tObj->MagFilter = GL_NEAREST;
+            }
+            ti->validated = GL_FALSE;
+            fxTexValidate(ctx, tObj);
+
+            /*
+            printf("small lodlog2 0x%x\n", ti->info.smallLodLog2);
+            printf("large lodlog2 0x%x\n", ti->info.largeLodLog2);
+            printf("aspect ratio 0x%x\n", ti->info.aspectRatioLog2);
+            printf("glide format 0x%x\n", ti->info.format);
+            printf("data %p\n", ti->info.data);
+            printf("lodblend %d\n", (int) ti->LODblend);
+            */
+
+            /* determine where texture will reside */
+            if (ti->LODblend && !shared->umaTexMemory) {
+                /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */
+                memNeeded = FX_grTexTextureMemRequired_NoLock(
+                                        GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+            }
+            else {
+                /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */
+                memNeeded = FX_grTexTextureMemRequired_NoLock(
+                                        GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+            }
+            /*
+            printf("Proxy test %d > %d\n", memNeeded, shared->totalTexMem[0]);
+            */
+            if (memNeeded > shared->totalTexMem[0])
+                return GL_FALSE;
+            else
+                return GL_TRUE;
+        }
+    case GL_PROXY_TEXTURE_3D:
+        return GL_TRUE;  /* software rendering */
+    default:
+        return GL_TRUE;  /* never happens, silence compiler */
+    }
+}
+
+
+/*
+ * Return a texture image to Mesa.  This is either to satisfy
+ * a glGetTexImage() call or to prepare for software texturing.
+ */
+GLvoid *
+fxDDGetTexImage(GLcontext * ctx, GLenum target, GLint level,
+                const struct gl_texture_object *texObj,
+                GLenum * formatOut, GLenum * typeOut,
+                GLboolean * freeImageOut)
+{
+    tfxTexInfo *ti;
+    tfxMipMapLevel *mml;
+
+    if (target != GL_TEXTURE_2D)
+        return NULL;
+
+    if (!texObj->DriverData)
+        return NULL;
+
+    ti = fxTMGetTexInfo(texObj);
+    mml = &ti->mipmapLevel[level];
+    if (mml->data) {
+        MesaIntTexFormat mesaFormat;
+        GLenum glFormat;
+        struct gl_texture_image *texImage = texObj->Image[level];
+        GLint srcStride;
+        void *uncompressedImage = NULL;
+
+        GLubyte *data =
+            (GLubyte *) MALLOC(texImage->Width * texImage->Height * 4);
+        if (!data)
+            return NULL;
+
+        uncompressedImage = (void *)mml->data;
+        switch (mml->glideFormat) {
+        case GR_TEXFMT_INTENSITY_8:
+            mesaFormat = MESA_I8;
+            glFormat = GL_INTENSITY;
+            srcStride = mml->width;
+            break;
+        case GR_TEXFMT_ALPHA_INTENSITY_88:
+            mesaFormat = MESA_A8_L8;
+            glFormat = GL_LUMINANCE_ALPHA;
+            srcStride = mml->width;
+            break;
+        case GR_TEXFMT_ALPHA_8:
+            if (texImage->Format == GL_INTENSITY) {
+                mesaFormat = MESA_I8;
+                glFormat = GL_INTENSITY;
+            }
+            else {
+                mesaFormat = MESA_A8;
+                glFormat = GL_ALPHA;
+            }
+            srcStride = mml->width;
+            break;
+        case GR_TEXFMT_RGB_565:
+            mesaFormat = MESA_R5_G6_B5;
+            glFormat = GL_RGB;
+            srcStride = mml->width * 2;
+            break;
+        case GR_TEXFMT_ARGB_8888:
+            mesaFormat = MESA_A8_R8_G8_B8;
+            glFormat = GL_RGBA;
+            srcStride = mml->width * 4;
+            break;
+        case GR_TEXFMT_ARGB_4444:
+            mesaFormat = MESA_A4_R4_G4_B4;
+            glFormat = GL_RGBA;
+            srcStride = mml->width * 2;
+            break;
+        case GR_TEXFMT_ARGB_1555:
+            mesaFormat = MESA_A1_R5_G5_B5;
+            glFormat = GL_RGBA;
+            srcStride = mml->width * 2;
+            break;
+        case GR_TEXFMT_P_8:
+            mesaFormat = MESA_C8;
+            glFormat = GL_COLOR_INDEX;
+            srcStride = mml->width;
+            break;
+        case GR_TEXFMT_ARGB_CMP_FXT1:
+            mesaFormat = MESA_A8_R8_G8_B8;
+            glFormat = GL_RGBA;
+            srcStride = mml->width * 4;
+           /*
+            * Allocate data for the uncompressed image,
+            * decompress the image.  The data will be deallocated
+            * after it is converted to the mesa format.
+            */
+            uncompressedImage = MALLOC(mml->width * mml->height * 4);
+            if (!uncompressedImage) {
+                gl_problem(NULL, "can't get memory in fxDDGetTexImage");
+                return(NULL);
+            }
+            (*txImgDequantizeFXT1Ptr)((FxU32 *)uncompressedImage,
+                                      (FxU32 *)mml->data,
+                                      mml->width,
+                                      mml->height);
+            break;
+        default:
+            gl_problem(NULL, "Bad glideFormat in fxDDGetTexImage");
+            return NULL;
+        }
+        _mesa_unconvert_teximage(mesaFormat, mml->width, mml->height,
+                                 uncompressedImage, srcStride, texImage->Width,
+                                 texImage->Height, glFormat, data);
+        if (uncompressedImage != mml->data) {
+            FREE(uncompressedImage);
+        }
+        *formatOut = glFormat;
+        *typeOut = GL_UNSIGNED_BYTE;
+        *freeImageOut = GL_TRUE;
+        return data;
+    }
+    else {
+        return NULL;
+    }
+}
+
+/*
+ * This is called from _mesa_GetCompressedTexImage.  We just
+ * copy out the compressed data.
+ */
+void
+fxDDGetCompressedTexImage( GLcontext *ctx, GLenum target,
+                           GLint lod, void *image,
+                           const struct gl_texture_object *texObj,
+                           struct gl_texture_image *texImage )
+{
+    tfxTexInfo *ti;
+    tfxMipMapLevel *mml;
+
+    if (target != GL_TEXTURE_2D)
+        return;
+
+    if (!texObj->DriverData)
+        return;
+
+    ti = fxTMGetTexInfo(texObj);
+    mml = &ti->mipmapLevel[lod];
+    if (mml->data) {
+        MEMCPY(image, mml->data, mml->dataSize);
+    }
+}
+
+/*
+ * Calculate a specific texture format given a generic
+ * texture format.
+ */
+GLint
+fxDDSpecificCompressedTexFormat(GLcontext *ctx,
+                                GLint      internalFormat,
+                                GLint      numDimensions,
+                                GLint     *levelp,
+                                GLsizei   *widthp,
+                                GLsizei   *heightp,
+                                GLsizei   *depthp,
+                                GLint     *borderp,
+                                GLenum    *formatp,
+                                GLenum    *typep)
+{
+    if (numDimensions != 2) {
+        return internalFormat;
+    }
+   /*
+    * If we don't have pointers to the functions, then
+    * we drop back to uncompressed format.  The logic
+    * in Mesa proper handles this for us.
+    *
+    * This is just to ease the transition to a Glide with
+    * the texus2 library.
+    */
+    if (!txImgQuantizePtr || !txImgDequantizeFXT1Ptr) {
+        return(internalFormat);
+    }
+    switch (internalFormat) {
+   /*
+    * GL_S3_s3tc uses negative level values.
+    */
+    case GL_RGB_S3TC:
+    case GL_RGB4_S3TC:
+        {
+            GLint level;
+            if (levelp) {
+                level = *levelp;
+                if (level < 0) {
+                    level = -level;
+                    *levelp = level;
+                }
+            }
+        }
+        return GL_COMPRESSED_RGB_FXT1_3DFX;
+    case GL_RGBA_S3TC:
+    case GL_RGBA4_S3TC:
+        {
+            GLint level;
+            if (levelp) {
+                level = *levelp;
+                if (level < 0) {
+                    level = -level;
+                    *levelp = level;
+                }
+            }
+        }
+        return GL_COMPRESSED_RGBA_FXT1_3DFX;
+    case GL_COMPRESSED_RGB_ARB:
+        return GL_COMPRESSED_RGB_FXT1_3DFX;
+    case GL_COMPRESSED_RGBA_ARB:
+        return GL_COMPRESSED_RGBA_FXT1_3DFX;
+    }
+    return internalFormat;
+}
+
+/*
+ * Calculate a specific texture format given a generic
+ * texture format.
+ */
+GLint
+fxDDBaseCompressedTexFormat(GLcontext *ctx,
+                            GLint      internalFormat)
+{
+    switch (internalFormat) {
+    case GL_COMPRESSED_RGB_FXT1_3DFX:
+        return(GL_RGB);
+    case GL_COMPRESSED_RGBA_FXT1_3DFX:
+        return(GL_RGBA);
+    }
+    return -1;
+}
+
+/*
+ * Tell us if an image is compressed.  The real work is done
+ * in a macro, but we need to have a function to create a
+ * function pointer.
+ */
+GLboolean
+fxDDIsCompressedFormat(GLcontext *ctx, GLint internalFormat)
+{
+    return(fxDDIsCompressedFormatMacro(internalFormat));
+}
+
+
+/*
+ * Calculate the image size of a compressed texture.
+ *
+ * The current compressed format, the FXT1 family, all
+ * map 8x32 texel blocks into 128 bits.
+ *
+ * We return 0 if we can't calculate the size.
+ *
+ * Glide would report this out to us, but we don't have
+ * exactly the right parameters.
+ */
+GLsizei
+fxDDCompressedImageSize(GLcontext *ctx,
+                        GLenum intFormat,
+                        GLuint numDimensions,
+                        GLuint width, 
+                        GLuint height,
+                        GLuint depth)
+{
+    if (numDimensions != 2) {
+        return 0;
+    }
+    switch (intFormat) {
+    case GL_COMPRESSED_RGB_FXT1_3DFX:
+    case GL_COMPRESSED_RGBA_FXT1_3DFX:
+       /*
+        * Round height and width to multiples of 4 and 8,
+        * divide the resulting product by 32 to get the number
+        * of blocks, and multiply by 32 = 128/8 to get the.
+        * number of bytes required.  That is to say, just
+        * return the product.  Remember that we are returning
+        * bytes, not texels, so we have shrunk the texture
+        * by a factor of the texel size.
+        */
+        width = (width   + 0x7) &~ 0x7;
+        height = (height + 0x3) &~ 0x3;
+        return(width * height);
+    }
+    return(0);
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxddtex.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxddtex.h:1.2
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxddtex.h	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,123 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxddtex.h,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+#ifndef FXDDTEX_H
+#define FXDDTEX_H
+
+
+#include "texutil.h"
+
+
+extern void fxPrintTextureData(tfxTexInfo * ti);
+
+extern void fxTexGetFormat(GLenum, GrTextureFormat_t *, GLint *,
+                           MesaIntTexFormat *, GLint *, GLboolean);
+
+extern void fxTexGetInfo(const GLcontext *, int, int, GrLOD_t *,
+                         GrAspectRatio_t *,
+                         float *, float *, int *, int *, int *, int *);
+
+extern GLboolean fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+                                GLenum format, GLenum type,
+                                const GLvoid * pixels,
+                                const struct gl_pixelstore_attrib *packing,
+                                struct gl_texture_object *texObj,
+                                struct gl_texture_image *texImage,
+                                GLboolean * retainInternalCopy);
+
+extern GLboolean fxDDTexSubImage2D(GLcontext * ctx, GLenum target,
+                                   GLint level, GLint xoffset, GLint yoffset,
+                                   GLsizei width, GLsizei height,
+                                   GLenum format, GLenum type,
+                                   const GLvoid * pixels,
+                                   const struct gl_pixelstore_attrib *packing,
+                                   struct gl_texture_object *texObj,
+                                   struct gl_texture_image *texImage);
+
+extern GLboolean fxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
+                                       GLint level, GLint internalFormat,
+                                       GLenum format, GLenum type,
+                                       GLint width, GLint height,
+                                       GLint depth, GLint border );
+
+extern GLvoid *fxDDGetTexImage(GLcontext * ctx, GLenum target, GLint level,
+                               const struct gl_texture_object *texObj,
+                               GLenum * formatOut, GLenum * typeOut,
+                               GLboolean * freeImageOut);
+
+extern GLboolean fxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
+                                           GLint level, GLsizei imageSize,
+                                           const GLvoid *data,
+                                           struct gl_texture_object *texObj,
+                                           struct gl_texture_image *texImage,
+                                           GLboolean *retainInternalCopy);
+extern GLboolean fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
+                                              GLint level, GLint xoffset,
+                                              GLint yoffset, GLsizei width,
+                                              GLint height, GLenum format,
+                                              GLsizei imageSize, const GLvoid *data,
+                                              struct gl_texture_object *texObj,
+                                              struct gl_texture_image *texImage );
+extern void fxDDGetCompressedTexImage( GLcontext *ctx, GLenum target,
+                                       GLint lod, void *image,
+                                       const struct gl_texture_object *texObj,
+                                       struct gl_texture_image *texImage );
+extern GLint fxDDSpecificCompressedTexFormat(GLcontext *ctx,
+                                             GLint      internalFormat,
+                                             GLint      numDimensions,
+                                             GLint     *levelp,
+                                             GLsizei   *widthp,
+                                             GLsizei   *heightp,
+                                             GLsizei   *depthp,
+                                             GLint     *borderp,
+                                             GLenum    *formatp,
+                                             GLenum    *typep);
+extern GLint fxDDBaseCompressedTexFormat(GLcontext *ctx,
+                                         GLint      internalFormat);
+
+#define fxDDIsCompressedFormatMacro(internalFormat) \
+    (((internalFormat) == GL_COMPRESSED_RGB_FXT1_3DFX) || \
+     ((internalFormat) == GL_COMPRESSED_RGBA_FXT1_3DFX))
+#define fxDDIsCompressedGlideFormatMacro(internalFormat) \
+    ((internalFormat) == GR_TEXFMT_ARGB_CMP_FXT1)
+extern GLboolean fxDDIsCompressedFormat(GLcontext *ctx, GLint internalFormat);
+
+extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
+
+extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
+                         GLenum, const GLfloat *);
+
+extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *);
+
+extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
+
+extern GLboolean fxDDIsTextureResident(GLcontext *ctx,
+                                       struct gl_texture_object *t);
+
+extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
+
+extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
+
+/*
+ * Calculate the image size of a compressed texture.
+ *
+ * We return 0 if we can't calculate the size.
+ */
+
+extern GLsizei fxDDCompressedImageSize(GLcontext *ctx,
+                                       GLenum internalFormat,
+                                       GLuint numDimensions,
+                                       GLuint width,
+                                       GLuint height,
+                                       GLuint depth);
+                                      
+/*
+ * This is not in glext.h, since this is not an EXT or ARB
+ * extension.  It probably shouldn't be here exactly, but
+ * there's not an obvious good place for it.
+ */
+#ifndef GL_S3_s3tc
+#define GL_RGB_S3TC                       0x83A0
+#define GL_RGB4_S3TC                      0x83A1
+#define GL_RGBA_S3TC                      0x83A2
+#define GL_RGBA4_S3TC                     0x83A3
+#endif
+#endif
Index: xc/lib/GL/mesa/src/drv/tdfx/fxdrv.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxdrv.h:1.2
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxdrv.h	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,800 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxdrv.h,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Brian Paul <brianp@valinux.com>
+ */
+
+
+#ifndef _FXDRV_H_
+#define _FXDRV_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <sys/time.h>
+#include "dri_tmm.h"
+#include "dri_mesaint.h"
+#include "dri_mesa.h"
+#include "dri_xmesaapi.h"
+#ifdef XFree86Server
+#include "GL/xf86glx.h"
+#else
+#include "glheader.h"
+#endif
+#if defined(__linux__)
+#include <signal.h>
+#endif
+#include "clip.h"
+#include "context.h"
+#include "fxglidew.h"
+#include "macros.h"
+#include "matrix.h"
+#include "mem.h"
+#include "texture.h"
+#include "types.h"
+#include "vb.h"
+#include "vbrender.h"
+#include "xform.h"
+
+typedef struct {
+    drmHandle handle;
+    drmSize size;
+    drmAddress map;
+} tdfxRegion, *tdfxRegionPtr;
+
+typedef struct {
+    tdfxRegion regs;
+    int deviceID;
+    int width;
+    int height;
+    int mem;
+    int cpp;
+    int stride;
+    int fifoOffset;
+    int fifoSize;
+    int fbOffset;
+    int backOffset;
+    int depthOffset;
+    int textureOffset;
+    int textureSize;
+    __DRIscreenPrivate *driScrnPriv;
+} tdfxScreenPrivate;
+
+typedef struct {
+    volatile int fifoPtr;
+    volatile int fifoRead;
+    volatile int fifoOwner;
+    volatile int ctxOwner;
+    volatile int texOwner;
+} TDFXSAREAPriv;
+
+
+extern void fx_sanity_triangle(fxMesaContext fxMesa,
+                               GrVertex *, GrVertex *, GrVertex *);
+#if defined(MESA_DEBUG) && 0
+#define grDrawTriangle fx_sanity_triangle
+#endif
+
+
+/* Define some shorter names for these things.
+ */
+#define XCOORD   GR_VERTEX_X_OFFSET
+#define YCOORD   GR_VERTEX_Y_OFFSET
+#define ZCOORD   GR_VERTEX_OOZ_OFFSET
+#define OOWCOORD GR_VERTEX_OOW_OFFSET
+
+#define RCOORD   GR_VERTEX_R_OFFSET
+#define GCOORD   GR_VERTEX_G_OFFSET
+#define BCOORD   GR_VERTEX_B_OFFSET
+#define ACOORD   GR_VERTEX_A_OFFSET
+
+#define S0COORD  GR_VERTEX_SOW_TMU0_OFFSET
+#define T0COORD  GR_VERTEX_TOW_TMU0_OFFSET
+#define S1COORD  GR_VERTEX_SOW_TMU1_OFFSET
+#define T1COORD  GR_VERTEX_TOW_TMU1_OFFSET
+
+
+#define CLIP_XCOORD 0           /* normal place */
+#define CLIP_YCOROD 1           /* normal place */
+#define CLIP_ZCOORD 2           /* GR_VERTEX_Z_OFFSET */
+#define CLIP_WCOORD 3           /* GR_VERTEX_R_OFFSET */
+#define CLIP_GCOORD 4           /* normal place */
+#define CLIP_BCOORD 5           /* normal place */
+#define CLIP_RCOORD 6           /* GR_VERTEX_OOZ_OFFSET */
+#define CLIP_ACOORD 7           /* normal place */
+
+
+/* Should have size == 16 * sizeof(float).
+ */
+typedef struct
+{
+    GLfloat f[15];              /* Same layout as GrVertex */
+    GLubyte mask;               /* Unsued  */
+    GLubyte usermask;           /* Unused */
+}
+fxVertex;
+
+
+#ifdef __i386__
+#define FXCOLOR4( c )  (* (int *)c)
+#else
+#define FXCOLOR4( c ) (      \
+  ( ((unsigned int)(c[3]))<<24 ) | \
+  ( ((unsigned int)(c[2]))<<16 ) | \
+  ( ((unsigned int)(c[1]))<<8 )  | \
+  (  (unsigned int)(c[0])) )
+#endif
+
+
+#define FX_VB_COLOR(fxm, color)				\
+  do {							\
+    if (sizeof(GLint) == 4*sizeof(GLubyte)) {		\
+      if (fxm->constColor != *(GLuint*)color) {		\
+	fxm->constColor = *(GLuint*)color;		\
+	FX_grConstantColorValue(fxm, FXCOLOR4(color));	\
+      }							\
+    } else {						\
+      FX_grConstantColorValue(fxm, FXCOLOR4(color));	\
+    }							\
+  } while (0)
+
+#define GOURAUD(x) {					\
+  GLubyte *col = VB->ColorPtr->data[(x)];		\
+  gWin[(x)].v.r=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]);	\
+  gWin[(x)].v.g=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]);	\
+  gWin[(x)].v.b=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]);	\
+  gWin[(x)].v.a=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]);	\
+}
+
+#if FX_USE_PARGB
+#define GOURAUD2(v, c) {			                \
+  GLubyte *col = c;     			                \
+  PACK_4F_ARGB(GET_PARGB(v), col[3], col[0], col[1], col[2]);   \
+}
+#else
+#define GOURAUD2(v, c) {			\
+  GLubyte *col = c;  				\
+  v->r=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[0]);	\
+  v->g=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[1]);	\
+  v->b=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[2]);	\
+  v->a=UBYTE_COLOR_TO_FLOAT_255_COLOR(col[3]);	\
+}
+#endif /* FX_USE_PARGB */
+
+
+/* Mergable items first
+ */
+#define SETUP_RGBA 0x1
+#define SETUP_TMU0 0x2
+#define SETUP_TMU1 0x4
+#define SETUP_XY   0x8
+#define SETUP_Z    0x10
+#define SETUP_W    0x20
+
+#define MAX_MERGABLE 0x8
+
+
+#define FX_NUM_TMU 2
+
+#define FX_TMU0      GR_TMU0
+#define FX_TMU1      GR_TMU1
+#define FX_TMU_SPLIT 98
+#define FX_TMU_BOTH  99
+#define FX_TMU_NONE  100
+
+/* Used for fxMesa->lastUnitsMode */
+
+#define FX_UM_NONE                  0x00000000
+
+#define FX_UM_E0_REPLACE            0x00000001
+#define FX_UM_E0_MODULATE           0x00000002
+#define FX_UM_E0_DECAL              0x00000004
+#define FX_UM_E0_BLEND              0x00000008
+#define FX_UM_E0_ADD		    0x00000010
+
+#define FX_UM_E1_REPLACE            0x00000020
+#define FX_UM_E1_MODULATE           0x00000040
+#define FX_UM_E1_DECAL              0x00000080
+#define FX_UM_E1_BLEND              0x00000100
+#define FX_UM_E1_ADD		    0x00000200
+
+#define FX_UM_E_ENVMODE             0x000003ff
+
+#define FX_UM_E0_ALPHA              0x00001000
+#define FX_UM_E0_LUMINANCE          0x00002000
+#define FX_UM_E0_LUMINANCE_ALPHA    0x00004000
+#define FX_UM_E0_INTENSITY          0x00008000
+#define FX_UM_E0_RGB                0x00010000
+#define FX_UM_E0_RGBA               0x00020000
+
+#define FX_UM_E1_ALPHA              0x00040000
+#define FX_UM_E1_LUMINANCE          0x00080000
+#define FX_UM_E1_LUMINANCE_ALPHA    0x00100000
+#define FX_UM_E1_INTENSITY          0x00200000
+#define FX_UM_E1_RGB                0x00400000
+#define FX_UM_E1_RGBA               0x00800000
+
+#define FX_UM_E_IFMT                0x00fff000
+
+#define FX_UM_COLOR_ITERATED        0x01000000
+#define FX_UM_COLOR_CONSTANT        0x02000000
+#define FX_UM_ALPHA_ITERATED        0x04000000
+#define FX_UM_ALPHA_CONSTANT        0x08000000
+
+
+#define PACK_BGRA32(R, G, B, A)  \
+    ( (((GLuint) (R)) << 16) | \
+      (((GLuint) (G)) <<  8) | \
+      (((GLuint) (B))      ) | \
+      (((GLuint) (A)) << 24) )
+
+#define PACK_RGBA32(R, G, B, A)  \
+    ( (((GLuint) (R))      ) | \
+      (((GLuint) (G)) <<  8) | \
+      (((GLuint) (B)) << 16) | \
+      (((GLuint) (A)) << 24) )
+
+/*
+ * The first two macros are to pack 8 bit color
+ * channel values into a 565 format.
+ */
+#define PACK_RGB16(R, G, B)         \
+    ((((GLuint) (R) & 0xF8) << 8) | \
+     (((GLuint) (G) & 0xFC) << 3) | \
+      (((GLuint) (B) & 0xFF)         >> 3))
+#define PACK_BGR16(R, G, B)         \
+    ((((GLuint) (B) & 0xF8) << 8) | \
+     (((GLuint) (G) & 0xFC) << 3) | \
+     (((GLuint) (R) & 0xFF) >> 3))
+/*
+ * The second two macros pack 8 bit color channel values
+ * into 1555 values.
+ */
+#define PACK_RGBA16(R, G, B, A)       \
+    (((((GLuint) (A) & 0xFF) > 0) << 15)| \
+     (((GLuint) (R)  & 0xF8)      << 7) | \
+     (((GLuint) (G)  & 0xF8)      << 2) | \
+     (((GLuint) (B)  & 0xF8)      >> 3))
+#define PACK_BGRA16(R, G, B, A) \
+    (((((GLuint) (A) & 0xFF) > 0) << 15)| \
+      (((GLuint) (B) & 0xF8)     << 7)  | \
+      (((GLuint) (G) & 0xF8)     << 2)  | \
+      (((GLuint) (R) & 0xF8)     >> 3))
+
+typedef void (*tfxRenderVBFunc) (GLcontext *);
+
+/*
+  Memory range from startAddr to endAddr-1
+*/
+typedef struct MemRange_t
+{
+    struct MemRange_t *next;
+    FxU32 startAddr, endAddr;
+}
+MemRange;
+
+
+typedef struct
+{
+    GLsizei width, height;              /* image size */
+    GLint texelSize;                    /* How many bytes to a texel */
+    GrTextureFormat_t glideFormat;      /* Glide image format */
+    unsigned short *data;               /* Glide-formated texture image */
+    FxU32           dataSize;           /* Count of the data size */
+}
+tfxMipMapLevel;
+
+
+typedef struct tfxTexInfo_t
+{
+    struct tfxTexInfo *next;
+    struct gl_texture_object *tObj;
+
+    GLuint lastTimeUsed;
+    FxU32 whichTMU;
+    GLboolean isInTM;
+
+    GrAspectRatio_t aspectRatio;
+    tfxMipMapLevel mipmapLevel[MAX_TEXTURE_LEVELS];
+
+    MemRange *tm[FX_NUM_TMU];
+
+    GLint minLevel, maxLevel;
+    GLint baseLevelInternalFormat;
+
+    GrTexInfo info;
+
+    GrTextureFilterMode_t minFilt;
+    GrTextureFilterMode_t maxFilt;
+    FxBool LODblend;
+
+    GrTextureClampMode_t sClamp;
+    GrTextureClampMode_t tClamp;
+
+    GrMipMapMode_t mmMode;
+
+    GLfloat sScale, tScale;
+    GLint int_sScale, int_tScale; /* x86 floating point trick for
+                                   * multiplication by powers of 2.  
+                                   * Used in fxfasttmp.h
+                                   */
+    GuTexPalette palette;
+
+    GLboolean fixedPalette;
+    GLboolean validated;
+}
+tfxTexInfo;
+
+
+typedef struct
+{
+    GLuint swapBuffer;
+    GLuint reqTexUpload;
+    GLuint texUpload;
+    GLuint memTexUpload;
+    GLuint texSwaps;
+}
+tfxStats;
+
+
+typedef void (*tfxTriViewClipFunc) (struct vertex_buffer * VB,
+                                    GLuint v[], GLubyte mask);
+
+typedef void (*tfxTriClipFunc) (struct vertex_buffer * VB,
+                                GLuint v[], GLuint mask);
+
+
+typedef void (*tfxLineClipFunc) (struct vertex_buffer * VB,
+                                 GLuint v1, GLuint v2, GLubyte mask);
+
+
+extern tfxTriViewClipFunc fxTriViewClipTab[0x8];
+extern tfxTriClipFunc fxTriClipStrideTab[0x8];
+extern tfxLineClipFunc fxLineClipTab[0x8];
+
+typedef struct
+{
+    /* Alpha test */
+    GLboolean alphaTestEnabled;
+    GrCmpFnc_t alphaTestFunc;
+    GrAlpha_t alphaTestRefValue;
+
+    /* Blend function */
+    GLboolean blendEnabled;
+    GrAlphaBlendFnc_t blendSrcFuncRGB;
+    GrAlphaBlendFnc_t blendDstFuncRGB;
+    GrAlphaBlendFnc_t blendSrcFuncAlpha;
+    GrAlphaBlendFnc_t blendDstFuncAlpha;
+}
+tfxUnitsState;
+
+
+
+/* Flags for render_index.
+ */
+#define FX_OFFSET             0x1
+#define FX_TWOSIDE            0x2
+#define FX_FRONT_BACK         0x4
+#define FX_FLAT               0x8
+#define FX_ANTIALIAS          0x10
+#define FX_FALLBACK           0x20
+
+
+/* Flags for fxMesa->new_state
+ */
+#define FX_NEW_TEXTURING      0x1
+#define FX_NEW_BLEND          0x2
+#define FX_NEW_ALPHA          0x4
+#define FX_NEW_DEPTH          0x8
+#define FX_NEW_FOG            0x10
+#define FX_NEW_SCISSOR        0x20
+#define FX_NEW_COLOR_MASK     0x40
+#define FX_NEW_CULL           0x80
+#define FX_NEW_STENCIL        0x100
+
+/* FX struct stored in VB->driver_data.
+ */
+struct tfxMesaVertexBuffer
+{
+    GLuint size;                   /* Number of vertexes */
+    GLvector1ui clipped_elements;  /* Array [size] of GLuints */
+    fxVertex *verts;               /* Array of [size] fxVertex */
+    fxVertex *last_vert;           /* Points into verts array */
+#if defined(FX_GLIDE3)
+    GrVertex **triangle_b;         /* Triangle buffer */
+    GrVertex **strips_b;           /* Strips buffer */
+#endif
+};
+
+#define FX_DRIVER_DATA(vb) ((struct tfxMesaVertexBuffer *)((vb)->driver_data))
+#define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
+#define FX_TEXTURE_DATA(t) fxTMGetTexInfo((t)->Current)
+
+#if !defined(FX_PXCONV_TABULAR) \
+    && !defined(FX_PXCONV_APPROXIMATION) \
+    && !defined(FX_PXCONV_EXACT)
+#define	FX_PXCONV_TABULAR
+#endif
+/* These lookup table are used to extract RGB values in [0,255] from
+ * 16-bit pixel values.
+ *
+ * In general, we want to convert 5 or 6 bit numbers to 8
+ * bit numbers.
+ * o In the FX_PXCONV_TABULAR case, we do the numerically
+ *   correct calculation at initialization time, and store
+ *   the results in three large tables.
+ * o In the FX_PXCONV_APPROXIMATION method we approximate
+ *   the numerically correct value by using the upper bits
+ *   of the 5 or 6 bit value.  That is,
+ *      8bitvalue = 5bitvalue << 3 | (5bitvalue >> 2)
+ * o In the FX_PXCONV_EXACT method, we calculate the
+ *   exact value at runtime every time, using a floating
+ *   point calculation.
+ */
+#define FX_PXCONV_INT_FIELD(v, w, s) (((v) >> (s)) & ((1 << (w)) - 1))
+#if	defined(FX_PXCONV_TABULAR)
+/* These lookup table are used to extract RGB values in [0,255] from
+ * 16-bit pixel values.
+ */
+extern GLubyte FX_PixelToRArray[0x10000];
+extern GLubyte FX_PixelToGArray[0x10000];
+extern GLubyte FX_PixelToBArray[0x10000];
+#define FX_PixelToB(fxMesa, v) (FX_PixelToBArray[(v)])
+#define FX_PixelToR(fxMesa, v) (FX_PixelToRArray[(v)])
+#define FX_PixelToG(fxMesa, v) (FX_PixelToGArray[(v)])
+#elif	defined(FX_PXCONV_APPROXIMATION)
+#define FX_PixelToR(fxMesa, v) \
+    ((fxMesa)->bgrOrder \
+     ? (FX_PXCONV_INT_FIELD(v, 5,  0) << 3) | FX_PXCONV_INT_FIELD(v, 3,  2) \
+     : (FX_PXCONV_INT_FIELD(v, 5, 11) << 3) | FX_PXCONV_INT_FIELD(v, 3, 13))
+#define FX_PixelToG(fxMesa, v) \
+     ((FX_PXCONV_INT_FIELD(v, 6, 5) << 2) | FX_PXCONV_INT_FIELD(v, 2, 7))
+#define FX_PixelToB(fxMesa, v) \
+    ((fxMesa)->bgrOrder \
+     ? (FX_PXCONV_INT_FIELD(v, 5, 11) << 3) | FX_PXCONV_INT_FIELD(v, 3, 13)\
+     : (FX_PXCONV_INT_FIELD(v, 5,  0) << 3) | FX_PXCONV_INT_FIELD(v, 3,  2))
+#elif	defined(FX_PXCONV_EXACT)
+#define FX_PixelToR(fxMesa, v) \
+    ((((fxMesa)->bgrOrder \
+        ? FX_PXCONV_INT_FIELD(v, 5,  0) \
+        : FX_PXCONV_INT_FIELD(v, 5, 11)) * 8 * 255) / 0xF8)
+#define FX_PixelToG(fxMesa, v) \
+     ((FX_PXCONV_INT_FIELD(v, 6, 5) * 4 * 255) / 0xFC)
+#define FX_PixelToB(fxMesa, v) \
+    ((((fxMesa)->bgrOrder \
+        ? FX_PXCONV_INT_FIELD(v, 5, 11) \
+        : FX_PXCONV_INT_FIELD(v, 5,  0)) * 8 * 255) / 0xF8)
+#else
+#error	Need to define pixel a conversion method.
+#endif
+
+
+/*
+ * This is state which may be shared by several tdfx contexts.
+ * It hangs off of Mesa's gl_shared_state object (ctx->Shared->DriverData).
+ */
+struct TdfxSharedState
+{
+    GLboolean umaTexMemory;
+    GLuint totalTexMem[FX_NUM_TMU]; /* constant */
+    GLuint freeTexMem[FX_NUM_TMU]; /* changes as we go */
+    MemRange *tmPool;
+    MemRange *tmFree[FX_NUM_TMU];
+};
+
+
+/*
+ * This is the tdfx context struct.
+ */
+struct tfxMesaContext
+{
+    /*
+     * Set once and never changed:
+     */
+    GLcontext *glCtx;           /* the core Mesa context */
+    GLvisual *glVis;            /* describes the color buffer */
+
+    GLboolean initDone;         /* has this context been initialized? */
+    GLint board;                /* the board used for this context */
+    int screen_width;
+    int screen_height;
+
+    FX_GrContext_t glideContext; /* returned by grSstWinOpen() */
+    void *state;                 /* Glide state buffer */
+
+    GLint textureAlign;
+    GLboolean bgrOrder;
+    GLboolean verbose;
+    GLboolean haveTwoTMUs;      /* True if we really have 2 tmu's  */
+    GLboolean emulateTwoTMUs;   /* True if we present 2 tmu's to mesa.  */
+    GLboolean haveHwStencil;
+    GLboolean isNapalm;
+    GLint swapInterval;
+    GLint maxPendingSwapBuffers;
+
+    /* stuff added for DRI */
+    __DRIcontextPrivate *driContextPriv;
+    drmContext hHWContext;
+    int numClipRects;
+    XF86DRIClipRectPtr pClipRects;
+    tdfxScreenPrivate *tdfxScrnPriv;
+
+    /*
+     * Changes during execution:
+     */
+    int width, height;   /* size of window */
+    int x_offset;        /* distance from window left to screen left */
+    int y_offset;        /* distance from window top to screen top */
+    int y_delta;         /* distance from window bottom to screen bottom */
+    int needClip;        /* need to loop over cliprects? */
+    int clipMinX;        /* if !needClip, bounds of the single clip rect */
+    int clipMaxX;        /* "" */
+    int clipMinY;        /* "" */
+    int clipMaxY;        /* "" */
+
+
+    GrBuffer_t currentFB;  /* front buffer or back buffer */
+
+    GLuint depthClear;     /* glClear depth value */
+    GrColor_t clearC;      /* glClear color value */
+    GrAlpha_t clearA;      /* glClear alpha value */
+    GLuint constColor;
+    GrColor_t color;
+    GrCullMode_t cullMode;
+
+    tfxUnitsState unitsState;
+    tfxUnitsState restoreUnitsState; /* saved during multipass */
+
+    GuTexPalette glbPalette;         /* global texture palette */
+
+    GLuint tmu_source[FX_NUM_TMU];
+    GLuint tex_dest[MAX_TEXTURE_UNITS];
+    GLuint setupindex;
+    GLuint partial_setup_index;
+    GLuint setupdone;
+    GLuint mergeindex;
+    GLuint mergeinputs;
+    GLuint render_index;
+    GLuint last_tri_caps;
+    GLuint stw_hint_state;      /* for grHints */
+    GLuint is_in_hardware;
+    GLuint new_state;
+    GLuint using_fast_path, passes, multipass;
+    GLuint texBindNumber;
+    GLint tmuSrc;
+
+    tfxLineClipFunc clip_line;
+    tfxTriClipFunc clip_tri_stride;
+    tfxTriViewClipFunc view_clip_tri;
+
+    GLenum fogTableMode;
+    GLfloat fogDensity;
+    GLfloat fogStart, fogEnd;
+    GrFog_t *fogTable;
+
+    /* Acc. functions */
+
+    points_func PointsFunc;
+    line_func LineFunc;
+    triangle_func TriangleFunc;
+    quad_func QuadFunc;
+
+    render_func **RenderVBTables;
+    render_func *RenderVBClippedTab;
+    render_func *RenderVBCulledTab;
+    render_func *RenderVBRawTab;
+
+    tfxStats stats;
+};
+
+
+typedef void (*tfxSetupFunc) (struct vertex_buffer *, GLuint, GLuint);
+
+
+extern void fxPrintSetupFlags(const char *msg, GLuint flags);
+extern void fxSetupDDPointers(GLcontext *);
+
+extern void fxDDSetupInit(void);
+extern void fxDDCvaInit(void);
+extern void fxDDTrifuncInit(void);
+extern void fxDDFastPathInit(void);
+
+extern void fxDDRenderInitGlide3(GLcontext * ctx);
+
+extern void fxDDChooseRenderState(GLcontext * ctx);
+
+extern void fxRenderClippedLine(struct vertex_buffer *VB,
+                                GLuint v1, GLuint v2);
+
+extern void fxRenderClippedTriangle(struct vertex_buffer *VB,
+                                    GLuint n, GLuint vlist[]);
+
+
+extern tfxSetupFunc fxDDChooseSetupFunction(GLcontext *);
+
+extern points_func fxDDChoosePointsFunction(GLcontext *);
+extern line_func fxDDChooseLineFunction(GLcontext *);
+extern triangle_func fxDDChooseTriangleFunction(GLcontext *);
+extern quad_func fxDDChooseQuadFunction(GLcontext *);
+extern render_func **fxDDChooseRenderVBTables(GLcontext *);
+
+extern void fxDDRenderInit(GLcontext *);
+extern void fxDDClipInit(void);
+
+extern void fxSetupDDSpanPointers(GLcontext *);
+
+
+extern void fxDDRegisterVB(struct vertex_buffer *VB);
+extern void fxDDUnregisterVB(struct vertex_buffer *VB);
+extern void fxDDResizeVB(struct vertex_buffer *VB, GLuint size);
+
+extern void fxDDMergeAndRender(struct vertex_buffer *VB);
+
+extern void fxDDCheckPartialRasterSetup(GLcontext * ctx,
+                                        struct gl_pipeline_stage *d);
+
+extern void fxDDPartialRasterSetup(struct vertex_buffer *VB);
+
+extern void fxDDDoRasterSetup(struct vertex_buffer *VB);
+
+extern void fxDDRenderElementsDirect(struct vertex_buffer *VB);
+extern void fxDDRenderVBIndirectDirect(struct vertex_buffer *VB);
+
+extern void fxDDFastPath(struct vertex_buffer *VB);
+
+extern void fxPrintRenderState(const char *msg, GLuint state);
+extern void fxPrintHintState(const char *msg, GLuint state);
+
+extern void fxDDDoRenderVB(struct vertex_buffer *VB);
+
+extern int fxDDInitFxMesaContext(fxMesaContext fxMesa);
+
+
+extern void fxSetScissorValues(GLcontext * ctx);
+extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
+                                struct gl_texture_object *tObj, FxU32 where);
+extern void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder);
+
+
+
+extern GLboolean tdfxMapAllRegions(__DRIscreenPrivate * driScrnPriv);
+extern void tdfxUnmapAllRegions(__DRIscreenPrivate * driScrnPriv);
+extern GLboolean tdfxInitHW(__DRIdrawablePrivate * driDrawPrivate,
+                            fxMesaContext cPriv);
+
+extern void XMesaUpdateState(fxMesaContext fxMesa);
+
+
+/* This is the private interface between Glide and DRI */
+#if 0
+extern void grDRIOpen(char *pFB, tdfxScreenPrivate *sPriv,
+                      volatile int *fifoPtr, volatile int *fifoRead);
+#endif
+extern void grDRIPosition(int x, int y, int w, int h,
+                          int numClip, XF86DRIClipRectPtr pClip);
+extern void grDRILostContext(void);
+extern void grDRIImportFifo(int fifoPtr, int fifoRead);
+extern void grDRIInvalidateAll(void);
+extern void grDRIResetSAREA(void);
+extern void grDRIBufferSwap(FxU32 swapInterval);
+extern void grDRISwapClipRects(FxU32 swapInterval,
+                               int numClip,
+                               const XF86DRIClipRectPtr pClip);
+
+
+
+/* You can turn this on to find locking conflicts.
+#define DEBUG_LOCKING 
+*/
+
+#ifdef DEBUG_LOCKING
+extern char *prevLockFile;
+extern int prevLockLine;
+#define DEBUG_LOCK() \
+  do { \
+    prevLockFile=(__FILE__); \
+    prevLockLine=(__LINE__); \
+  } while (0)
+#define DEBUG_RESET() \
+  do { \
+    prevLockFile=0; \
+    prevLockLine=0; \
+  } while (0)
+#define DEBUG_CHECK_LOCK() \
+  do { \
+    if (prevLockFile) { \
+      fprintf(stderr, "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
+	prevLockFile, prevLockLine, __FILE__, __LINE__); \
+      exit(1); \
+    } \
+  } while (0)
+#else
+#define DEBUG_LOCK()
+#define DEBUG_RESET()
+#define DEBUG_CHECK_LOCK()
+#endif /* DEBUG_LOCKING */
+
+
+/* !!! We may want to separate locks from locks with validation.
+   This could be used to improve performance for those things
+   commands that do not do any drawing !!! */
+
+#define DRM_LIGHT_LOCK_RETURN(fd,lock,context,__ret)                   \
+	do {                                                           \
+		DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret);     \
+                if (__ret) drmGetLock(fd,context,0);                   \
+        } while(0)
+
+#define LOCK_HARDWARE(fxMesa) XMesaUpdateState(fxMesa)
+
+/* Unlock the hardware using the global current context */
+#define UNLOCK_HARDWARE(fxMesa)					\
+  do {								\
+    __DRIcontextPrivate *cPriv = fxMesa->driContextPriv;	\
+    __DRIdrawablePrivate *dPriv = cPriv->driDrawablePriv;	\
+    __DRIscreenPrivate *sPriv = dPriv->driScreenPriv;		\
+    DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock,			\
+	       dPriv->driContextPriv->hHWContext);		\
+    DEBUG_RESET();						\
+  } while (0)
+
+#define BEGIN_BOARD_LOCK(fxMesa) LOCK_HARDWARE(fxMesa)
+#define END_BOARD_LOCK(fxMesa) UNLOCK_HARDWARE(fxMesa)
+
+/*
+  This pair of macros makes a loop over the drawing operations
+  so it is not self contained and doesn't have the nice single 
+  statement semantics of most macros
+*/
+#define BEGIN_CLIP_LOOP(fxMesa)					\
+  do {								\
+    __DRIcontextPrivate *cPriv = fxMesa->driContextPriv;	\
+    __DRIdrawablePrivate *dPriv = cPriv->driDrawablePriv;	\
+    int _nc;							\
+    LOCK_HARDWARE(fxMesa);					\
+    _nc = dPriv->numClipRects;					\
+    while (_nc--) {						\
+      if (fxMesa->needClip) {					\
+        fxMesa->clipMinX = dPriv->pClipRects[_nc].x1;		\
+        fxMesa->clipMaxX = dPriv->pClipRects[_nc].x2;		\
+        fxMesa->clipMinY = dPriv->pClipRects[_nc].y1;		\
+        fxMesa->clipMaxY = dPriv->pClipRects[_nc].y2;		\
+        fxSetScissorValues(fxMesa->glCtx);			\
+      }
+
+#define END_CLIP_LOOP(fxMesa)	\
+    }				\
+    UNLOCK_HARDWARE(fxMesa);	\
+  } while (0)
+
+
+#endif /* GLX_DIRECT_RENDERING */
+
+#endif /* _FXDRV_H_ */
Index: xc/lib/GL/mesa/src/drv/tdfx/fxfastpath.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxfastpath.c:1.4
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxfastpath.c	Fri Dec  8 21:13:22 2000
@@ -0,0 +1,365 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxfastpath.c,v 1.4 2000/12/09 02:13:22 dawes Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#include "types.h"
+#include "cva.h"
+#include "mmath.h"
+#include "fxdrv.h"
+#include "fxtexman.h"
+#include "vertices.h"
+#ifdef __i386__
+#include "X86/common_x86_asm.h"
+#endif
+
+
+#if 0 && defined(__i386__)
+#define NEGATIVE(f)          ((*(int *)&f) < 0)
+#define DIFFERENT_SIGNS(a,b) (((*(int *)&a)^(*(int *)&b)) < 0)
+#else
+#define NEGATIVE(f)          (f < 0)
+#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
+#endif
+
+#define LINTERP( T, A, B )   ( (A) + (T) * ( (B) - (A) ) )
+
+
+#define CLIP(sgn,v,PLANE)					\
+if (mask & PLANE) {						\
+   GLuint *indata = inlist[in];					\
+   GLuint *outdata = inlist[in ^= 1];				\
+   GLuint nr = n;						\
+   GLfloat *J = verts[indata[nr-1]].f;				\
+   GLfloat dpJ = (sgn J[v]) + J[CLIP_WCOORD];			\
+								\
+   inlist[0] = vlist1;						\
+   for (i = n = 0 ; i < nr ; i++) {				\
+      GLuint elt_i = indata[i];					\
+      GLfloat *I = verts[elt_i].f;				\
+      GLfloat dpI = (sgn I[v]) + I[CLIP_WCOORD];		\
+								\
+      if (DIFFERENT_SIGNS(dpI, dpJ)) {				\
+	 GLfloat *O = verts[next_vert].f;			\
+         GLfloat t = dpI / (dpI - dpJ);				\
+	 GLuint j;						\
+								\
+	 clipmask[next_vert] = 0;				\
+	 outdata[n++] = next_vert++;				\
+								\
+         for (j = 0 ; j < SIZE ; j += 2) {			\
+	    O[j]   = LINTERP(t, I[j],   J[j]);			\
+	    O[j+1] = LINTERP(t, I[j+1], J[j+1]);	       	\
+	 }							\
+      }								\
+								\
+      clipmask[elt_i] |= PLANE;		/* don't set up */	\
+								\
+      if (!NEGATIVE(dpI)) {					\
+	 outdata[n++] = elt_i;					\
+	 clipmask[elt_i] &= ~PLANE;	/* set up after all */	\
+      }								\
+								\
+      J = I;							\
+      dpJ = dpI;						\
+   }								\
+								\
+   if (n < 3) return;						\
+}
+
+#define LINE_CLIP(x,y,z,w,PLANE)				\
+if (mask & PLANE) {						\
+   GLfloat dpI = DOT4V(I,x,y,z,w);				\
+   GLfloat dpJ = DOT4V(J,x,y,z,w);				\
+								\
+   if (DIFFERENT_SIGNS(dpI, dpJ)) {				\
+      GLfloat *O = verts[next_vert].f;				\
+      GLfloat t = dpI / (dpI - dpJ);				\
+      GLuint j;							\
+								\
+      for (j = 0 ; j < SIZE ; j += 2) {				\
+         O[j]   = LINTERP(t, I[j],   J[j]);			\
+	 O[j+1] = LINTERP(t, I[j+1], J[j+1]);	       		\
+      }								\
+								\
+      clipmask[next_vert] = 0;					\
+								\
+      if (NEGATIVE(dpI)) {					\
+  	 clipmask[elts[0]] |= PLANE;				\
+	 I = O; elts[0] = next_vert++;				\
+      } else {							\
+  	 clipmask[elts[1]] |= PLANE;				\
+	 J = O;	elts[1] = next_vert++;				\
+      }								\
+   }								\
+   else if (NEGATIVE(dpI))					\
+      return;							\
+}
+
+
+#define CLIP_POINT( e )				\
+   if (mask[e])					\
+      *out++ = e
+
+#define CLIP_LINE( e1, e0 )						\
+do {									\
+   GLubyte ormask = mask[e0] | mask[e1];				\
+   out[0] = e1;								\
+   out[1] = e0;								\
+   out+=2;								\
+   if (ormask) {							\
+      out-=2;								\
+      if (!(mask[e0] & mask[e1])) {					\
+	 TAG(fx_line_clip)( &out, verts, mask, &next_vert, ormask);	\
+      }									\
+   }									\
+} while (0)
+
+#define CLIP_TRIANGLE( e2, e1, e0 )					\
+do {									\
+   GLubyte ormask;							\
+   out[0] = e2;								\
+   out[1] = e1;								\
+   out[2] = e0;								\
+   out += 3;								\
+   ormask = mask[e2] | mask[e1] | mask[e0];				\
+   if (ormask) {							\
+      out -= 3;								\
+      if ( !(mask[e2] & mask[e1] & mask[e0])) {				\
+	 TAG(fx_tri_clip)( &out, verts, mask, &next_vert, ormask );	\
+      }									\
+   }									\
+} while (0)
+
+
+/* Add window offset to window coords to get screen coords */
+
+#define VARS_XYZ				\
+  GLfloat vsx = mat[MAT_SX];			\
+  GLfloat vsy = mat[MAT_SY];			\
+  GLfloat vsz = mat[MAT_SZ];			\
+  GLfloat vtx = mat[MAT_TX];			\
+  GLfloat vty = mat[MAT_TY];			\
+  GLfloat vtz = mat[MAT_TZ];
+
+#define DO_SETUP_XYZ				\
+  f[XCOORD] = f[0] * oow * vsx + vtx;		\
+  f[YCOORD] = f[1] * oow * vsy + vty;		\
+  f[ZCOORD] = f[2] * oow * vsz + vtz;
+
+
+
+
+struct fx_fast_tab
+{
+    void (*build_vertices) (struct vertex_buffer * VB, GLuint do_clip);
+
+    void (*clip[GL_POLYGON + 1]) (struct vertex_buffer * VB,
+                                  GLuint start, GLuint count, GLuint parity);
+
+    void (*project_clipped_vertices) (GLfloat * first,
+                                      GLfloat * last,
+                                      const GLfloat * mat,
+                                      GLuint stride, const GLubyte * mask);
+
+    void (*project_vertices) (GLfloat * first,
+                              GLfloat * last,
+                              const GLfloat * mat, GLuint stride);
+};
+
+/* Pack either rgba or texture into the remaining half of a 32 byte vertex.
+ */
+#define CLIP_R  CLIP_RCOORD
+#define CLIP_G  CLIP_GCOORD
+#define CLIP_B  CLIP_BCOORD
+#define CLIP_A  CLIP_ACOORD
+#define CLIP_S0 4
+#define CLIP_T0 5
+#define CLIP_S1 6
+#define CLIP_T1 7
+
+#define SIZE 4
+#define TYPE (0)
+#define TAG(x) x
+#include "fxfasttmp.h"
+
+#define SIZE 8
+#define TYPE (SETUP_RGBA)
+#define TAG(x) x##_RGBA
+#include "fxfasttmp.h"
+
+#define SIZE 6
+#define TYPE (SETUP_TMU0)
+#define TAG(x) x##_TMU0
+#include "fxfasttmp.h"
+
+#define SIZE 8
+#define TYPE (SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_TMU0_TMU1
+#include "fxfasttmp.h"
+
+#undef CLIP_S1
+#undef CLIP_T1
+#define CLIP_S1 4
+#define CLIP_T1 5
+
+#define SIZE 6
+#define TYPE (SETUP_TMU1)
+#define TAG(x) x##_TMU1
+#include "fxfasttmp.h"
+
+/* These three need to use a full 64 byte clip-space vertex.
+ */
+#undef CLIP_S0
+#undef CLIP_T0
+#undef CLIP_S1
+#undef CLIP_T1
+
+#define CLIP_S0 8
+#define CLIP_T0 9
+#define CLIP_S1 10
+#define CLIP_T1 11
+
+#define SIZE 10
+#define TYPE (SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_RGBA_TMU0
+#include "fxfasttmp.h"
+
+#define SIZE 12
+#define TYPE (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_RGBA_TMU0_TMU1
+#include "fxfasttmp.h"
+
+#undef CLIP_S1
+#undef CLIP_T1
+#define CLIP_S1 8
+#define CLIP_T1 9
+
+#define SIZE 10
+#define TYPE (SETUP_RGBA|SETUP_TMU1)
+#define TAG(x) x##_RGBA_TMU1
+#include "fxfasttmp.h"
+
+static struct fx_fast_tab fxFastTab[0x8];
+
+void
+fxDDFastPathInit()
+{
+    fx_init_fastpath(&fxFastTab[0]);
+    fx_init_fastpath_RGBA(&fxFastTab[SETUP_RGBA]);
+    fx_init_fastpath_TMU0(&fxFastTab[SETUP_TMU0]);
+    fx_init_fastpath_TMU1(&fxFastTab[SETUP_TMU1]);
+    fx_init_fastpath_RGBA_TMU0(&fxFastTab[SETUP_RGBA | SETUP_TMU0]);
+    fx_init_fastpath_RGBA_TMU1(&fxFastTab[SETUP_RGBA | SETUP_TMU1]);
+    fx_init_fastpath_TMU0_TMU1(&fxFastTab[SETUP_TMU0 | SETUP_TMU1]);
+    fx_init_fastpath_RGBA_TMU0_TMU1(&fxFastTab[SETUP_RGBA | SETUP_TMU0 |
+                                               SETUP_TMU1]);
+}
+
+
+
+void
+fxDDFastPath(struct vertex_buffer *VB)
+{
+    GLcontext *ctx = VB->ctx;
+    GLenum prim = ctx->CVA.elt_mode;
+    struct tfxMesaContext *fxMesa = FX_CONTEXT(ctx);
+    struct fx_fast_tab *tab = &fxFastTab[fxMesa->setupindex & 0x7];
+    GLuint do_clip = 1;
+    struct tfxMesaVertexBuffer *fxVB = FX_DRIVER_DATA(VB);
+    GLfloat tx, ty;
+
+    fxVertex *first;
+    GLfloat *mat = ctx->Viewport.WindowMap.m;
+
+    gl_prepare_arrays_cva(VB);  /* still need this */
+
+    if (VB->EltPtr->count * 12 > fxVB->size) {
+        fxDDResizeVB(VB, VB->EltPtr->count * 12);
+        do_clip = 1;
+    }
+
+    tab->build_vertices(VB, do_clip); /* object->clip space */
+
+    first = FX_DRIVER_DATA(VB)->verts;
+
+    /* Add window offset to window coords to get screen coords */
+    tx = mat[MAT_TX];
+    ty = mat[MAT_TY];
+    mat[MAT_TX] = tx + fxMesa->x_offset;
+    mat[MAT_TY] = ty + fxMesa->y_delta;
+
+    if (VB->ClipOrMask) {
+        if (!VB->ClipAndMask) {
+            GLubyte tmp = VB->ClipOrMask;
+
+            tab->clip[prim] (VB, 0, VB->EltPtr->count, 0); /* clip */
+
+            tab->project_clipped_vertices(fxVB->verts->f,
+                                          fxVB->last_vert->f,
+                                          mat, 16 * 4, VB->ClipMask);
+
+            ctx->CVA.elt_mode = gl_reduce_prim[prim];
+            VB->EltPtr = &(FX_DRIVER_DATA(VB)->clipped_elements);
+
+            VB->ClipOrMask = 0;
+            fxDDRenderElementsDirect(VB); /* render using new list */
+            VB->ClipOrMask = tmp;
+        }
+    }
+    else {
+        tab->project_vertices(fxVB->verts->f, fxVB->last_vert->f, mat,
+                              16 * 4);
+
+        fxDDRenderElementsDirect(VB); /* render using orig list */
+    }
+
+    /* Add window offset to window coords to get screen coords */
+    mat[MAT_TX] = tx;
+    mat[MAT_TY] = ty;
+
+    /* This indicates that there is no cached data to reuse.  
+     */
+    VB->pipeline->data_valid = 0;
+    VB->pipeline->pipeline_valid = 0;
+}
+
Index: xc/lib/GL/mesa/src/drv/tdfx/fxfasttmp.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxfasttmp.h:1.4
--- /dev/null	Mon Dec 18 14:23:41 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxfasttmp.h	Tue Dec 12 18:24:28 2000
@@ -0,0 +1,357 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxfasttmp.h,v 1.4 2000/12/12 23:24:28 dawes Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* Build clip space vertices from object space data.
+ */
+static void TAG(fx_setup_full) (struct vertex_buffer * VB, GLuint do_clip)
+{
+    GLcontext *ctx = VB->ctx;
+    GLfloat *f = (GLfloat *) FX_DRIVER_DATA(VB)->verts;
+    fxMesaContext fxMesa = FX_CONTEXT(VB->ctx);
+    GLuint count = VB->Count;
+    GLuint i;
+
+    const GLfloat *const m = ctx->ModelProjectMatrix.m;
+
+#if (TYPE & SETUP_RGBA)
+    GLubyte *color = (GLubyte *) VB->ColorPtr->data;
+    GLuint color_stride = VB->ColorPtr->stride;
+#endif
+
+#if (TYPE & SETUP_TMU0)
+    GLuint tmu0_source = fxMesa->tmu_source[0];
+    struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source];
+    GLint s0scale = FX_TEXTURE_DATA(t0)->int_sScale;
+    GLint t0scale = FX_TEXTURE_DATA(t0)->int_tScale;
+    GLint *tmu0_int_data = (GLint *) VB->TexCoordPtr[tmu0_source]->data;
+    GLuint tmu0_stride = VB->TexCoordPtr[tmu0_source]->stride;
+#endif
+
+#if (TYPE & SETUP_TMU1)
+    GLuint tmu1_source = fxMesa->tmu_source[1];
+    struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source];
+    GLint s1scale = FX_TEXTURE_DATA(t1)->int_sScale;
+    GLint t1scale = FX_TEXTURE_DATA(t1)->int_tScale;
+    GLint *tmu1_int_data = (GLint *) VB->TexCoordPtr[tmu1_source]->data;
+    GLuint tmu1_stride = VB->TexCoordPtr[tmu1_source]->stride;
+#endif
+
+    (void) fxMesa;
+    (void) ctx;
+    (void) i;
+    (void) f;
+
+    /* Use 3 seperate loops because it's easier for assembly.  A
+     * best-case solution might be to do all three in a single assembly
+     * loop.
+     */
+    gl_xform_points3_v16_general(FX_DRIVER_DATA(VB)->verts[0].f,
+                                 m,
+                                 VB->ObjPtr->start, VB->ObjPtr->stride,
+                                 count);
+
+    if (do_clip) {
+        VB->ClipAndMask = ~0;
+        VB->ClipOrMask = 0;
+        gl_cliptest_points4_v16(FX_DRIVER_DATA(VB)->verts[0].f,
+                                FX_DRIVER_DATA(VB)->verts[count].f,
+                                &(VB->ClipOrMask),
+                                &(VB->ClipAndMask), VB->ClipMask);
+    }
+
+
+#if (TYPE)
+    for (i = 0; i < count; i++, f += 16) {
+#if (TYPE & SETUP_RGBA)
+        GLubyte *col = color;
+        color += color_stride;
+        UBYTE_COLOR_TO_FLOAT_255_COLOR2(f[CLIP_R], col[0]);
+        UBYTE_COLOR_TO_FLOAT_255_COLOR2(f[CLIP_G], col[1]);
+        UBYTE_COLOR_TO_FLOAT_255_COLOR2(f[CLIP_B], col[2]);
+        UBYTE_COLOR_TO_FLOAT_255_COLOR2(f[CLIP_A], col[3]);
+#endif
+#if (TYPE & SETUP_TMU0)
+        *(int *) &f[CLIP_S0] = s0scale + tmu0_int_data[0];
+        *(int *) &f[CLIP_T0] = t0scale + tmu0_int_data[1];
+        STRIDE_T(tmu0_int_data, GLint, tmu0_stride);
+#endif
+#if (TYPE & SETUP_TMU1)
+        *(int *) &f[CLIP_S1] = s1scale + tmu1_int_data[0];
+        *(int *) &f[CLIP_T1] = t1scale + tmu1_int_data[1];
+        STRIDE_T(tmu1_int_data, GLint, tmu1_stride);
+#endif
+    }
+#endif
+
+    FX_DRIVER_DATA(VB)->last_vert = &(FX_DRIVER_DATA(VB)->verts[count]);
+}
+
+
+/* Do viewport map, device scale and perspective projection.
+ *
+ * Rearrange fxVertices to look like grVertices.
+ */
+static void TAG(fx_project_vertices) (GLfloat * first,
+                                      GLfloat * last,
+                                      const GLfloat * mat, GLuint stride)
+{
+    GLfloat *f;
+    VARS_XYZ;
+
+    for (f = first; f != last; STRIDE_F(f, stride)) {
+        GLfloat oow = 1.0f / f[CLIP_WCOORD]; /* urp! */
+
+#if FX_USE_PARGB
+        if (TYPE & SETUP_RGBA) {
+            PACK_4F_ARGB(GET_PARGB(f), f[CLIP_A], f[CLIP_R], f[CLIP_G], f[CLIP_B]);
+        }
+#else
+        if (TYPE & SETUP_RGBA) {
+            f[RCOORD] = f[CLIP_R];
+        }
+#endif
+        if (TYPE & SETUP_TMU1) {
+            f[S1COORD] = f[CLIP_S1] * oow;
+            f[T1COORD] = f[CLIP_T1] * oow;
+        }
+
+        if (TYPE & SETUP_TMU0) {
+            f[T0COORD] = f[CLIP_T0] * oow;
+            f[S0COORD] = f[CLIP_S0] * oow;
+        }
+
+        DO_SETUP_XYZ;
+
+        f[OOWCOORD] = oow;
+    }
+}
+
+static void TAG(fx_project_clipped_vertices) (GLfloat * first,
+                                              GLfloat * last,
+                                              const GLfloat * mat,
+                                              GLuint stride,
+                                              const GLubyte * mask)
+{
+    GLfloat *f;
+    VARS_XYZ;
+
+    for (f = first; f != last; STRIDE_F(f, stride), mask++) {
+        if (!*mask) {
+
+            GLfloat oow = 1.0f / f[CLIP_WCOORD];
+#if FX_USE_PARGB
+            if (TYPE & SETUP_RGBA) {
+                PACK_4F_ARGB(GET_PARGB(f), f[CLIP_A], f[CLIP_R], f[CLIP_G], f[CLIP_B]);
+            }
+#else
+            if (TYPE & SETUP_RGBA) {
+                f[RCOORD] = f[CLIP_R];
+            }
+#endif
+
+            if (TYPE & SETUP_TMU1) {
+                f[S1COORD] = f[CLIP_S1] * oow;
+                f[T1COORD] = f[CLIP_T1] * oow;
+            }
+
+            if (TYPE & SETUP_TMU0) {
+                f[T0COORD] = f[CLIP_T0] * oow;
+                f[S0COORD] = f[CLIP_S0] * oow;
+            }
+
+            DO_SETUP_XYZ;
+
+            f[OOWCOORD] = oow;
+        }
+    }
+}
+
+
+static
+#if (SIZE <= 8)
+  INLINE
+#endif
+void TAG(fx_tri_clip) (GLuint ** p_elts,
+                       fxVertex * verts,
+                       GLubyte * clipmask, GLuint * p_next_vert, GLubyte mask)
+{
+    GLuint *elts = *p_elts;
+    GLuint next_vert = *p_next_vert;
+    GLuint vlist1[VB_MAX_CLIPPED_VERTS];
+    GLuint vlist2[VB_MAX_CLIPPED_VERTS];
+    GLuint *inlist[2];
+    GLuint *out;
+    GLuint in = 0;
+    GLuint n = 3;
+    GLuint i;
+
+    inlist[0] = elts;
+    inlist[1] = vlist2;
+
+    CLIP(-, 0, CLIP_RIGHT_BIT);
+    CLIP(+, 0, CLIP_LEFT_BIT);
+    CLIP(-, 1, CLIP_TOP_BIT);
+    CLIP(+, 1, CLIP_BOTTOM_BIT);
+    CLIP(-, 2, CLIP_FAR_BIT);
+    CLIP(+, 2, CLIP_NEAR_BIT);
+
+    /* Convert the planar polygon to a list of triangles.
+     */
+    out = inlist[in];
+
+    for (i = 2; i < n; i++) {
+        elts[0] = out[0];
+        elts[1] = out[i - 1];
+        elts[2] = out[i];
+        elts += 3;
+    }
+
+    *p_next_vert = next_vert;
+    *p_elts = elts;
+}
+
+
+static INLINE void TAG(fx_line_clip) (GLuint ** p_elts,
+                                      fxVertex * verts,
+                                      GLubyte * clipmask,
+                                      GLuint * p_next_vert, GLubyte mask)
+{
+    GLuint *elts = *p_elts;
+    GLfloat *I = verts[elts[0]].f;
+    GLfloat *J = verts[elts[1]].f;
+    GLuint next_vert = *p_next_vert;
+
+    LINE_CLIP(1, 0, 0, -1, CLIP_LEFT_BIT);
+    LINE_CLIP(-1, 0, 0, 1, CLIP_RIGHT_BIT);
+    LINE_CLIP(0, 1, 0, -1, CLIP_TOP_BIT);
+    LINE_CLIP(0, -1, 0, 1, CLIP_BOTTOM_BIT);
+    LINE_CLIP(0, 0, 1, -1, CLIP_FAR_BIT);
+    LINE_CLIP(0, 0, -1, 1, CLIP_NEAR_BIT);
+
+    *p_next_vert = next_vert;
+    *p_elts += 2;
+}
+
+
+/* Build a table of functions to clip each primitive type.
+ */
+#define LOCAL_VARS							\
+   GLuint *elt = VB->EltPtr->data;					\
+   fxVertex *verts = FX_DRIVER_DATA(VB)->verts;				\
+   GLuint next_vert = VB->Count;					\
+   GLuint *out = FX_DRIVER_DATA(VB)->clipped_elements.data;		\
+   GLubyte *mask = VB->ClipMask;                                        \
+
+
+#define POSTFIX							\
+   FX_DRIVER_DATA(VB)->clipped_elements.count = 		\
+          out - FX_DRIVER_DATA(VB)->clipped_elements.data;	\
+   FX_DRIVER_DATA(VB)->last_vert = &verts[next_vert];
+
+#define INIT(x)
+
+#define RENDER_POINTS(start, count)			\
+do {							\
+   GLuint i;						\
+   for (i = start ; i < count ; i++ )			\
+      CLIP_POINT( elt[i] );				\
+} while (0)
+
+#define RENDER_LINE(i1, i0) 			\
+   CLIP_LINE(elt[i1], elt[i0])
+
+#define RENDER_TRI(i2, i1, i0, pv, parroty)		\
+do {							\
+   GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0];	\
+   if (parroty) e2 = elt[i1], e1 = elt[i2];		\
+   CLIP_TRIANGLE( e2, e1, e0 );				\
+} while (0)
+
+#define RENDER_QUAD(i3, i2, i1, i0, pv)		\
+  CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]);	\
+  CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0])
+
+#define PRESERVE_TAG
+#include "render_tmp.h"
+
+
+static void TAG(fx_init_fastpath) (struct fx_fast_tab * tab)
+{
+    GLuint i;
+
+    /* Use the render templates to do clipping.
+     */
+    TAG(render_init) ();
+    for (i = 0; i < GL_POLYGON + 2; i++)
+        tab->clip[i] = TAG(render_tab)[i];
+
+    tab->build_vertices = TAG(fx_setup_full);
+    tab->project_vertices = TAG(fx_project_vertices);
+    tab->project_clipped_vertices = TAG(fx_project_clipped_vertices);
+
+#if 0 && defined(USE_3DNOW_ASM)
+    if (gl_x86_cpu_features & X86_FEATURE_3DNOW) {
+        extern void TAG(fx_3dnow_project_vertices) (GLfloat * first,
+                                                    GLfloat * last,
+                                                    const GLfloat * mat,
+                                                    GLuint stride);
+
+        extern void TAG(fx_3dnow_project_clipped_vertices) (GLfloat * first,
+                                                            GLfloat * last,
+                                                            const GLfloat *
+                                                            mat,
+                                                            GLuint stride,
+                                                            const GLubyte *
+                                                            mask);
+
+        tab->project_vertices = TAG(fx_3dnow_project_vertices);
+        tab->project_clipped_vertices =
+            TAG(fx_3dnow_project_clipped_vertices);
+    }
+#endif
+}
+
+#undef TYPE
+#undef TAG
+#undef SIZE
Index: xc/lib/GL/mesa/src/drv/tdfx/fxglidew.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxglidew.c:1.2
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxglidew.c	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,407 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxglidew.c,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include "glide.h"
+#include "fxdrv.h"
+#include "fxglidew.h"
+
+
+grStencilFunc_t grStencilFuncPtr = NULL;
+grStencilMask_t grStencilMaskPtr = NULL;
+grStencilOp_t grStencilOpPtr = NULL;
+grBufferClearExt_t grBufferClearExtPtr = NULL;
+grColorMaskExt_t grColorMaskExtPtr = NULL;
+txImgQuantize_t  txImgQuantizePtr = NULL;
+txImgDeQuantize_t txImgDequantizeFXT1Ptr = NULL;
+txErrorSetCallback_t txErrorSetCallbackPtr = NULL;
+grColorCombineExt_t grColorCombineExtPtr = NULL;
+grTexColorCombineExt_t grTexColorCombineExtPtr = NULL;
+grAlphaCombineExt_t grAlphaCombineExtPtr = NULL;
+grTexAlphaCombineExt_t grTexAlphaCombineExtPtr = NULL;
+grAlphaBlendFunctionExt_t grAlphaBlendFunctionExtPtr = NULL;
+grConstantColorValueExt_t grConstantColorValueExtPtr = NULL;
+
+
+FxI32
+FX_grGetInteger_NoLock(FxU32 pname)
+{
+    switch (pname) {
+    case FX_FOG_TABLE_ENTRIES:
+    case FX_GLIDE_STATE_SIZE:
+    case FX_LFB_PIXEL_PIPE:
+    case FX_PENDING_BUFFERSWAPS:
+    case FX_TEXTURE_ALIGN:
+    case GR_STATS_PIXELS_DEPTHFUNC_FAIL:
+    case GR_STATS_PIXELS_IN:
+    case GR_STATS_PIXELS_OUT:
+        {
+            FxI32 result;
+            FxU32 grname = pname;
+            grGet(grname, 4, &result);
+            return result;
+        }
+    case FX_ZDEPTH_MAX:
+        {
+            FxI32 zvals[2];
+            grGet(GR_ZDEPTH_MIN_MAX, 8, zvals);
+            return zvals[0];
+        }
+    default:
+        if (MESA_VERBOSE & VERBOSE_DRIVER) {
+            fprintf(stderr, "Wrong parameter in FX_grGetInteger!\n");
+        }
+    }
+
+    return 0;
+}
+
+
+FxI32
+FX_grGetInteger(fxMesaContext fxMesa, FxU32 pname)
+{
+    int result;
+    BEGIN_BOARD_LOCK(fxMesa);
+    result = FX_grGetInteger_NoLock(pname);
+    END_BOARD_LOCK(fxMesa);
+    return result;
+}
+
+
+const char *
+FX_grGetString(fxMesaContext fxMesa, FxU32 pname)
+{
+    const char *s;
+    BEGIN_BOARD_LOCK(fxMesa);
+    s = grGetString(pname);
+    END_BOARD_LOCK(fxMesa);
+    return s;
+}
+
+
+
+/* Wrapper for grColorMask() and grColorMaskExt().
+ */
+void
+FX_grColorMask(GLcontext *ctx, GLboolean r, GLboolean g,
+               GLboolean b, GLboolean a)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    BEGIN_BOARD_LOCK(fxMesa);
+    if (ctx->Visual->RedBits == 8) {
+        /* 32bpp mode */
+        ASSERT(grColorMaskExtPtr);
+        (*grColorMaskExtPtr)(r, g, b, a);
+    }
+    else {
+        /* 16 bpp mode */
+        /* we never have an alpha buffer */
+        grColorMask(r || g || b, GL_FALSE);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+void
+FX_grColorMask_NoLock(GLcontext *ctx, GLboolean r, GLboolean g,
+                      GLboolean b, GLboolean a)
+{
+    if (ctx->Visual->RedBits == 8) {
+        /* 32bpp mode */
+        ASSERT(grColorMaskExtPtr);
+        (*grColorMaskExtPtr)(r, g, b, a);
+    }
+    else {
+        /* 16 bpp mode */
+        /* we never have an alpha buffer */
+        grColorMask(r || g || b, GL_FALSE);
+    }
+}
+
+
+/* As above, but pass the mask as an array
+ */
+void
+FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    BEGIN_BOARD_LOCK(fxMesa);
+    if (ctx->Visual->RedBits == 8) {
+        /* 32bpp mode */
+        ASSERT(grColorMaskExtPtr);
+        (*grColorMaskExtPtr)(rgba[RCOMP], rgba[GCOMP],
+                             rgba[BCOMP], rgba[ACOMP]);
+    }
+    else {
+        /* 16 bpp mode */
+        /* we never have an alpha buffer */
+        grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP], GL_FALSE);
+    }
+    END_BOARD_LOCK(fxMesa);
+}
+
+void
+FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4])
+{
+    if (ctx->Visual->RedBits == 8) {
+        /* 32bpp mode */
+        ASSERT(grColorMaskExtPtr);
+        (*grColorMaskExtPtr)(rgba[RCOMP], rgba[GCOMP],
+                             rgba[BCOMP], rgba[ACOMP]);
+    }
+    else {
+        /* 16 bpp mode */
+        /* we never have an alpha buffer */
+        grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP], GL_FALSE);
+    }
+}
+
+
+
+FxBool
+FX_grLfbLock(fxMesaContext fxMesa, GrLock_t type, GrBuffer_t buffer,
+             GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
+             FxBool pixelPipeline, GrLfbInfo_t * info)
+{
+    FxBool result;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    result = grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info);
+    END_BOARD_LOCK(fxMesa);
+    return result;
+}
+
+FxU32
+FX_grTexTextureMemRequired(fxMesaContext fxMesa, FxU32 evenOdd, GrTexInfo * info)
+{
+    FxU32 result;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    result = grTexTextureMemRequired(evenOdd, info);
+    END_BOARD_LOCK(fxMesa);
+    return result;
+}
+
+FxU32
+FX_grTexMinAddress(fxMesaContext fxMesa, GrChipID_t tmu)
+{
+    FxU32 result;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    result = grTexMinAddress(tmu);
+    END_BOARD_LOCK(fxMesa);
+    return result;
+}
+
+extern FxU32
+FX_grTexMaxAddress(fxMesaContext fxMesa, GrChipID_t tmu)
+{
+    FxU32 result;
+
+    BEGIN_BOARD_LOCK(fxMesa);
+    result = grTexMaxAddress(tmu);
+    END_BOARD_LOCK(fxMesa);
+    return result;
+}
+
+
+int
+FX_getFogTableSize(fxMesaContext fxMesa)
+{
+    int result;
+    BEGIN_BOARD_LOCK(fxMesa);
+    grGet(GR_FOG_TABLE_ENTRIES, sizeof(int), (void *) &result);
+    END_BOARD_LOCK(fxMesa);
+    return result;
+}
+
+int
+FX_getGrStateSize(fxMesaContext fxMesa)
+{
+    int result;
+    BEGIN_BOARD_LOCK(fxMesa);
+    grGet(GR_GLIDE_STATE_SIZE, sizeof(int), (void *) &result);
+    END_BOARD_LOCK(fxMesa);
+    return result;
+}
+
+void
+FX_grAADrawLine(fxMesaContext fxMesa, GrVertex * a, GrVertex * b)
+{
+    /* ToDo */
+    BEGIN_CLIP_LOOP(fxMesa);
+    grDrawLine(a, b);
+    END_CLIP_LOOP(fxMesa);
+}
+
+void
+FX_grAADrawPoint(fxMesaContext fxMesa, GrVertex * a)
+{
+    BEGIN_CLIP_LOOP(fxMesa);
+    grDrawPoint(a);
+    END_CLIP_LOOP(fxMesa);
+}
+
+void
+FX_grDrawPolygonVertexList(fxMesaContext fxMesa, int n, GrVertex * verts)
+{
+    BEGIN_CLIP_LOOP(fxMesa);
+    grDrawVertexArrayContiguous(GR_POLYGON, n, verts, sizeof(GrVertex));
+    END_CLIP_LOOP(fxMesa);
+}
+
+#if FX_USE_PARGB
+void
+FX_setupGrVertexLayout(fxMesaContext fxMesa)
+{
+    BEGIN_BOARD_LOCK(fxMesa);
+    grReset(GR_VERTEX_PARAMETER);
+
+    grCoordinateSpace(GR_WINDOW_COORDS);
+    grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
+    grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+    grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+    END_BOARD_LOCK(fxMesa);
+}
+#else /* FX_USE_PARGB */
+void
+FX_setupGrVertexLayout(fxMesaContext fxMesa)
+{
+    BEGIN_BOARD_LOCK(fxMesa);
+    grReset(GR_VERTEX_PARAMETER);
+
+    grCoordinateSpace(GR_WINDOW_COORDS);
+    grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
+    grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
+    grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+    grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
+    END_BOARD_LOCK(fxMesa);
+}
+#endif /* FX_USE_PARGB */
+
+void
+FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask)
+{
+    switch (hintType) {
+    case GR_HINT_STWHINT:
+        {
+            if (hintMask & GR_STWHINT_W_DIFF_TMU0)
+                grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
+                               GR_PARAM_ENABLE);
+            else
+                grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
+                               GR_PARAM_DISABLE);
+
+            if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
+                grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
+                               GR_PARAM_ENABLE);
+            else
+                grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
+                               GR_PARAM_DISABLE);
+
+            if (hintMask & GR_STWHINT_W_DIFF_TMU1)
+                grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
+                               GR_PARAM_ENABLE);
+            else
+                grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
+                               GR_PARAM_DISABLE);
+
+        }
+    }
+}
+
+void
+FX_grHints(fxMesaContext fxMesa, GrHint_t hintType, FxU32 hintMask)
+{
+    BEGIN_BOARD_LOCK(fxMesa);
+    FX_grHints_NoLock(hintType, hintMask);
+    END_BOARD_LOCK(fxMesa);
+}
+
+/* It appears to me that this function is needed either way. */
+FX_GrContext_t
+FX_grSstWinOpen(fxMesaContext fxMesa,
+                FxU32 hWnd,
+                GrScreenResolution_t screen_resolution,
+                GrScreenRefresh_t refresh_rate,
+                GrColorFormat_t color_format,
+                GrOriginLocation_t origin_location,
+                int nColBuffers, int nAuxBuffers)
+{
+    FX_GrContext_t i;
+    BEGIN_BOARD_LOCK(fxMesa);
+    i = grSstWinOpen(hWnd,
+                     screen_resolution,
+                     refresh_rate,
+                     color_format, origin_location, nColBuffers, nAuxBuffers);
+
+    /*
+       fprintf(stderr, 
+       "grSstWinOpen( win %d res %d ref %d fmt %d\n"
+       "              org %d ncol %d naux %d )\n"
+       " ==> %d\n",
+       hWnd,
+       screen_resolution,
+       refresh_rate,
+       color_format,
+       origin_location,
+       nColBuffers,
+       nAuxBuffers,
+       i);
+     */
+    END_BOARD_LOCK(fxMesa);
+    return i;
+}
+
Index: xc/lib/GL/mesa/src/drv/tdfx/fxglidew.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxglidew.h:1.3
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxglidew.h	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,813 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxglidew.h,v 1.3 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#ifndef __FX_GLIDE_WARPER__
+#define __FX_GLIDE_WARPER__
+
+#include <glide.h>
+#include <g3ext.h>
+
+typedef struct tfxMesaContext *fxMesaContext;
+
+
+/*
+ * These are glide extension definitions.  These are not
+ * defined in glide.h.  They should really be defined in
+ * g3ext.h, but they are not.
+ */
+#if 0
+FX_ENTRY void FX_CALL
+grStencilFunc(GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask);
+
+FX_ENTRY void FX_CALL grStencilMask(GrStencil_t write_mask);
+
+FX_ENTRY void FX_CALL
+grStencilOp(GrStencilOp_t stencil_fail,
+            GrStencilOp_t depth_fail, GrStencilOp_t depth_pass);
+
+FX_ENTRY void FX_CALL
+grBufferClearExt(GrColor_t color,
+                 GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil);
+
+FX_ENTRY void FX_CALL
+grColorMaskExt(FxBool r, FxBool g, FxBool b, FxBool a);
+#endif
+
+
+typedef void (*grStencilFunc_t) (GrCmpFnc_t fnc, GrStencil_t ref,
+                                 GrStencil_t mask);
+typedef void (*grStencilMask_t) (GrStencil_t write_mask);
+typedef void (*grStencilOp_t) (GrStencilOp_t stencil_fail,
+                               GrStencilOp_t depth_fail,
+                               GrStencilOp_t depth_pass);
+typedef void (*grBufferClearExt_t) (GrColor_t color, GrAlpha_t alpha,
+                                    FxU32 depth, GrStencil_t stencil);
+typedef void (*grColorMaskExt_t) (FxBool r, FxBool g, FxBool b, FxBool a);
+
+/*
+ * "COMBINE" extension for Napalm
+ */
+typedef void (*grColorCombineExt_t)(GrCCUColor_t a, GrCombineMode_t a_mode,
+                                    GrCCUColor_t b, GrCombineMode_t b_mode,
+                                    GrCCUColor_t c, FxBool c_invert,
+                                    GrCCUColor_t d, FxBool d_invert,
+                                    FxU32 shift, FxBool invert);
+typedef void (*grTexColorCombineExt_t)(FxU32 tmu,
+                                       GrTCCUColor_t a, GrCombineMode_t a_mode,
+                                       GrCCUColor_t b, GrCombineMode_t b_mode,
+                                       GrCCUColor_t c, FxBool c_invert,
+                                       GrCCUColor_t d, FxBool d_invert,
+                                       FxU32 shift, FxBool invert);
+typedef void (*grAlphaCombineExt_t)(GrCCUColor_t a, GrCombineMode_t a_mode,
+                                    GrCCUColor_t b, GrCombineMode_t b_mode,
+                                    GrCCUColor_t c, FxBool c_invert,
+                                    GrCCUColor_t d, FxBool d_invert,
+                                    FxU32 shift, FxBool invert);
+typedef void (*grTexAlphaCombineExt_t)(FxU32 tmu,
+                                       GrTACUColor_t a, GrCombineMode_t a_mode,
+                                       GrTACUColor_t b, GrCombineMode_t b_mode,
+                                       GrTACUColor_t c, FxBool c_invert,
+                                       GrTACUColor_t d, FxBool d_invert,
+                                       FxU32 shift, FxBool invert);
+typedef void (*grAlphaBlendFunctionExt_t)(GrAlphaBlendFnc_t rgb_sf,
+                                          GrAlphaBlendFnc_t rgb_df,
+                                          GrAlphaBlendOp_t rgb_op,
+                                          GrAlphaBlendFnc_t alpha_sf,
+                                          GrAlphaBlendFnc_t alpha_df,
+                                          GrAlphaBlendOp_t alpha_op);
+typedef void (*grConstantColorValueExt_t)(FxU32 tmu, GrColor_t value);
+
+
+
+/*
+ * These are functions to compress and decompress images.
+ * The types of the first and second parameters are not exactly
+ * right.  The texus library declares them to be "char *", not
+ * "void *".  However, "void *" is more correct, and more convenient.
+ */
+typedef void (*txImgQuantize_t)  (void *dst, void *src, 
+                                  int w, int h, 
+                                  FxU32 format, FxU32 dither);
+typedef void (*txImgDeQuantize_t)(void *dst, void *src, 
+                                  int w, int h);
+/*
+ * These next three declarations should probably be taken from
+ * texus.h.  However, there are duplicate declarations in g3ext.h
+ * and texus.h which make it hard to include them both.
+ */
+typedef void (*TxErrorCallbackFnc_t)( const char *string, FxBool fatal );
+typedef void (*txErrorSetCallback_t)(TxErrorCallbackFnc_t  fnc,
+                                     TxErrorCallbackFnc_t *old_fnc);
+
+extern grStencilFunc_t grStencilFuncPtr;
+extern grStencilMask_t grStencilMaskPtr;
+extern grStencilOp_t grStencilOpPtr;
+extern grBufferClearExt_t grBufferClearExtPtr;
+extern grColorMaskExt_t grColorMaskExtPtr;
+extern txImgQuantize_t  txImgQuantizePtr;
+extern txImgDeQuantize_t txImgDequantizeFXT1Ptr;
+extern txErrorSetCallback_t txErrorSetCallbackPtr;
+extern grColorCombineExt_t grColorCombineExtPtr;
+extern grTexColorCombineExt_t grTexColorCombineExtPtr;
+extern grAlphaCombineExt_t grAlphaCombineExtPtr;
+extern grTexAlphaCombineExt_t grTexAlphaCombineExtPtr;
+extern grAlphaBlendFunctionExt_t grAlphaBlendFunctionExtPtr;
+extern grConstantColorValueExt_t grConstantColorValueExtPtr;
+
+
+/* 
+ * General context: 
+ */
+typedef GrContext_t FX_GrContext_t;
+
+#define FX_FOG_TABLE_ENTRIES            GR_FOG_TABLE_ENTRIES
+#define FX_GLIDE_STATE_SIZE             GR_GLIDE_STATE_SIZE
+#define FX_LFB_PIXEL_PIPE               GR_LFB_PIXEL_PIPE
+#define FX_PENDING_BUFFERSWAPS          GR_PENDING_BUFFERSWAPS
+#define FX_TEXTURE_ALIGN		GR_TEXTURE_ALIGN
+
+#define FX_ZDEPTH_MAX 0x100
+
+
+#define GR_ASPECT_1x1 GR_ASPECT_LOG2_1x1
+#define GR_ASPECT_2x1 GR_ASPECT_LOG2_2x1
+#define GR_ASPECT_4x1 GR_ASPECT_LOG2_4x1
+#define GR_ASPECT_8x1 GR_ASPECT_LOG2_8x1
+#define GR_ASPECT_1x2 GR_ASPECT_LOG2_1x2
+#define GR_ASPECT_1x4 GR_ASPECT_LOG2_1x4
+#define GR_ASPECT_1x8 GR_ASPECT_LOG2_1x8
+
+#define GR_LOD_256	GR_LOD_LOG2_256
+#define GR_LOD_128	GR_LOD_LOG2_128
+#define GR_LOD_64	GR_LOD_LOG2_64
+#define GR_LOD_32	GR_LOD_LOG2_32
+#define GR_LOD_16	GR_LOD_LOG2_16
+#define GR_LOD_8	GR_LOD_LOG2_8
+#define GR_LOD_4	GR_LOD_LOG2_4
+#define GR_LOD_2	GR_LOD_LOG2_2
+#define GR_LOD_1	GR_LOD_LOG2_1
+
+#define GR_FOG_WITH_TABLE GR_FOG_WITH_TABLE_ON_Q
+
+
+typedef FxU32 GrHint_t;
+#define GR_HINTTYPE_MIN                 0
+#define GR_HINT_STWHINT                 0
+
+typedef FxU32 GrSTWHint_t;
+#define GR_STWHINT_W_DIFF_FBI   FXBIT(0)
+#define GR_STWHINT_W_DIFF_TMU0  FXBIT(1)
+#define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2)
+#define GR_STWHINT_W_DIFF_TMU1  FXBIT(3)
+#define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4)
+#define GR_STWHINT_W_DIFF_TMU2  FXBIT(5)
+#define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
+
+#define GR_CONTROL_ACTIVATE 		1
+#define GR_CONTROL_DEACTIVATE		0
+
+#define GrState				void
+
+/*
+** move the vertex layout defintion to application
+*/
+typedef struct
+{
+    GLfloat sow;                  /* s texture ordinate (s over w) */
+    GLfloat tow;                  /* t texture ordinate (t over w) */
+    GLfloat oow;                  /* 1/w (used mipmapping - really 0xfff/w) */
+}
+GrTmuVertex;
+
+
+#if FX_USE_PARGB
+
+/* standard vertex, packed argb, double texture, 12 dwords */
+typedef struct
+{
+    GLfloat x, y;                 /* X and Y in screen space */
+    GLfloat ooz;                  /* 65535/Z (used for Z-buffering) */
+    GLfloat oow;                  /* 1/W (used for W-buffering, texturing) */
+    FxU32 argb;                   /* R, G, B, A [0..255.0] */
+    GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
+    GLfloat z;                    /* Z is ignored */
+}
+GrVertex_12;
+
+/* optimised vertex, packed argb, single texture, 8 dwords = 1 cacheline */
+typedef struct
+{
+    GLfloat x, y;                 /* X and Y in screen space */
+    GLfloat ooz;                  /* 65535/Z (used for Z-buffering) */
+    GLfloat oow;                  /* 1/W (used for W-buffering, texturing) */
+    FxU32 argb;                   /* R, G, B, A [0..255.0] */
+    GrTmuVertex tmuvtx;           /* only 1 TMU used to keep vertex size down */
+}
+GrVertex_8;
+
+/* vertex structure, padded to 16 dwords */
+typedef union
+{
+    GrVertex_8    v_8;
+    GrVertex_12   v_12;
+    GLfloat       f[16];
+    GLuint        u[16];
+}
+GrVertex_t;
+
+/* keep the compiler happy for now */
+typedef GrVertex_12 GrVertex;
+
+/* following offsets work for both vertex layouts */
+#define GR_VERTEX_X_OFFSET              0
+#define GR_VERTEX_Y_OFFSET              1
+#define GR_VERTEX_OOZ_OFFSET            2
+#define GR_VERTEX_OOW_OFFSET            3
+#define GR_VERTEX_PARGB_OFFSET          4
+#define GR_VERTEX_SOW_TMU0_OFFSET       5
+#define GR_VERTEX_TOW_TMU0_OFFSET       6
+#define GR_VERTEX_OOW_TMU0_OFFSET       7
+#define GR_VERTEX_SOW_TMU1_OFFSET       8
+#define GR_VERTEX_TOW_TMU1_OFFSET       9
+#define GR_VERTEX_OOW_TMU1_OFFSET       10
+#define GR_VERTEX_Z_OFFSET		11
+
+#if GLIDE_ENDIAN == GLIDE_ENDIAN_BIG
+#define GET_PA(v)		((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+3]
+#define GET_PR(v)		((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+2]
+#define GET_PG(v)		((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+1]
+#define GET_PB(v)		((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+0]
+#else
+#define GET_PA(v)		((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+0]
+#define GET_PR(v)		((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+1]
+#define GET_PG(v)		((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+2]
+#define GET_PB(v)		((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+3]
+#endif
+
+#define GET_PARGB(v)	        ((FxU32*)(v))[GR_VERTEX_PARGB_OFFSET]
+#define PACK_4F_ARGB(dest, a, r, g, b) { 					\
+    			        const GLuint cr = (int)r;		        \
+    				const GLuint cg = (int)g;		        \
+    				const GLuint ca = (int)a;		        \
+    				const GLuint cb = (int)b;		        \
+    				dest = ca << 24 | cr << 16 | cg << 8 | cb;	\
+                                }
+
+#else /* FX_USE_PARGB */
+
+typedef struct
+{
+    float x, y, z;              /* X, Y, and Z of scrn space -- Z is ignored */
+    float r, g, b;              /* R, G, B, ([0..255.0]) */
+    float ooz;                  /* 65535/Z (used for Z-buffering) */
+    float a;                    /* Alpha [0..255.0] */
+    float oow;                  /* 1/W (used for W-buffering, texturing) */
+    GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
+}
+GrVertex;
+
+#define GR_VERTEX_X_OFFSET              0
+#define GR_VERTEX_Y_OFFSET              1
+#define GR_VERTEX_Z_OFFSET              2
+#define GR_VERTEX_R_OFFSET              3
+#define GR_VERTEX_G_OFFSET              4
+#define GR_VERTEX_B_OFFSET              5
+#define GR_VERTEX_OOZ_OFFSET            6
+#define GR_VERTEX_A_OFFSET              7
+#define GR_VERTEX_OOW_OFFSET            8
+#define GR_VERTEX_SOW_TMU0_OFFSET       9
+#define GR_VERTEX_TOW_TMU0_OFFSET       10
+#define GR_VERTEX_OOW_TMU0_OFFSET       11
+#define GR_VERTEX_SOW_TMU1_OFFSET       12
+#define GR_VERTEX_TOW_TMU1_OFFSET       13
+#define GR_VERTEX_OOW_TMU1_OFFSET       14
+#endif /* FX_USE_PARGB */
+
+
+
+extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
+
+extern FxI32 FX_grGetInteger(fxMesaContext fxMesa, FxU32 pname);
+
+extern const char *FX_grGetString(fxMesaContext fxMesa, FxU32 pname);
+
+
+#define FX_grTexDownloadTable(fxMesa, TMU, type, data)	\
+  do { 							\
+    BEGIN_BOARD_LOCK(fxMesa); 				\
+    grTexDownloadTable(type,data); 			\
+    END_BOARD_LOCK(fxMesa); 				\
+  } while (0);
+
+#define FX_grTexDownloadTable_NoLock(TMU, type, data) \
+  grTexDownloadTable(type, data)
+
+
+#define FX_grFlush(fxMesa)	\
+  do {				\
+    BEGIN_BOARD_LOCK(fxMesa);	\
+    grFlush();			\
+    END_BOARD_LOCK(fxMesa);	\
+  } while (0)
+
+#define FX_grFinish(fxMesa)	\
+  do {				\
+    BEGIN_BOARD_LOCK(fxMesa); \
+    grFinish();			\
+    END_BOARD_LOCK(fxMesa);	\
+  } while (0)
+
+
+#define FX_grLfbWriteRegion(fxMesa,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)		\
+  do {				\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data);	\
+    END_BOARD_LOCK(fxMesa);		\
+  } while(0)
+
+
+#define FX_grLfbReadRegion(fxMesa,src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data)			\
+  do {				\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data);				\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0);
+
+
+#define FX_grDrawTriangle_NoLock(a,b,c) grDrawTriangle(a,b,c)
+#define FX_grDrawTriangle(fxMesa, a,b,c)	\
+  do {						\
+    BEGIN_CLIP_LOOP(fxMesa);			\
+    FX_grDrawTriangle_NoLock(a,b,c);		\
+    END_CLIP_LOOP(fxMesa);			\
+  } while (0)
+
+/*
+ * For Lod/LodLog2 conversion.
+ */
+#define FX_largeLodLog2(info)		(info).largeLodLog2
+
+#define FX_smallLodLog2(info)		(info).smallLodLog2
+
+#define FX_aspectRatioLog2(info)	(info).aspectRatioLog2
+
+#define FX_lodToValue(val)		((int)(GR_LOD_256-val))
+
+#define FX_largeLodValue(info)		((int)(GR_LOD_256-(info).largeLodLog2))
+#define FX_largeLodValue_NoLock FX_largeLodValue
+
+#define FX_smallLodValue(info)		((int)(GR_LOD_256-(info).smallLodLog2))
+#define FX_smallLodValue_NoLock FX_smallLodValue
+
+#define FX_valueToLod(val)		((GrLOD_t)(GR_LOD_256-val))
+
+
+
+extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
+extern void FX_grHints(fxMesaContext fxMesa, GrHint_t hintType, FxU32 hintMask);
+
+
+extern void FX_grAADrawLine(fxMesaContext fxMesa, GrVertex * a, GrVertex * b);
+
+extern void FX_grAADrawPoint(fxMesaContext fxMesa, GrVertex * a);
+
+
+extern void FX_setupGrVertexLayout(fxMesaContext fxMesa);
+
+
+extern FX_GrContext_t FX_grSstWinOpen(fxMesaContext fxMesa,
+                                      FxU32 hWnd,
+                                      GrScreenResolution_t screen_resolution,
+                                      GrScreenRefresh_t refresh_rate,
+                                      GrColorFormat_t color_format,
+                                      GrOriginLocation_t origin_location,
+                                      int nColBuffers, int nAuxBuffers);
+
+
+#define FX_grDrawLine_NoLock(v1, v2) grDrawLine(v1, v2)
+#define FX_grDrawLine(fxMesa, v1, v2)	\
+  do {					\
+    BEGIN_CLIP_LOOP(fxMesa);		\
+    FX_grDrawLine_NoLock(v1, v2);	\
+    END_CLIP_LOOP(fxMesa);		\
+  } while (0)
+
+#define FX_grDrawPoint_NoLock(p) grDrawPoint(p)
+#define FX_grDrawPoint(fxMesa, p)	\
+  do {					\
+    BEGIN_CLIP_LOOP(fxMesa);		\
+    FX_grDrawPoint_NoLock(p);		\
+    END_CLIP_LOOP(fxMesa);		\
+  } while (0)
+
+extern void FX_grDrawPolygonVertexList(fxMesaContext fxMesa,
+                                       int n, GrVertex * v);
+
+#define FX_grDitherMode(fxMesa, m)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grDitherMode(m);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grRenderBuffer(fxMesa, b)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grRenderBuffer(b);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grRenderBuffer_NoLock(b)  grRenderBuffer(b)
+
+#define FX_grBufferClear(fxMesa, c, a, d)	\
+  do {						\
+    BEGIN_CLIP_LOOP(fxMesa);			\
+    grBufferClear(c, a, d);			\
+    END_CLIP_LOOP(fxMesa);			\
+  } while (0)
+
+#define FX_grBufferClearExt_NoLock(c, a, d, s)  (*grBufferClearExtPtr)(c, a, d, s)
+
+#define FX_grBufferClearExt(fxMesa, c, a, d, s)	\
+  do {						\
+    BEGIN_CLIP_LOOP(fxMesa);			\
+    (*grBufferClearExtPtr)(c, a, d, s);		\
+    END_CLIP_LOOP(fxMesa);			\
+  } while (0)
+
+#define FX_grBufferClear_NoLock(c, a, d)  grBufferClear(c, a, d)
+
+
+#define FX_grEnable(fxMesa, m)           \
+  do {				         \
+    BEGIN_BOARD_LOCK(fxMesa);	         \
+    grEnable(m);                         \
+    END_BOARD_LOCK(fxMesa);	         \
+  } while (0)
+
+#define FX_grEnable_NoLock(m) grEnable(m)
+
+#define FX_grDisable(fxMesa, m)          \
+  do {				         \
+    BEGIN_BOARD_LOCK(fxMesa);	         \
+    grDisable(m);                        \
+    END_BOARD_LOCK(fxMesa);	         \
+  } while (0)
+
+#define FX_grDisable_NoLock(m) grDisable(m)
+
+
+#define FX_grStencilFunc(fxMesa, fnc, ref, mask)	\
+  do {							\
+    BEGIN_BOARD_LOCK(fxMesa);				\
+    (*grStencilFuncPtr)((fnc), (ref), (mask));		\
+    END_BOARD_LOCK(fxMesa);				\
+  } while (0)
+
+#define FX_grStencilFunc_NoLock(f, r, m)  (*grStencilFuncPtr)(f, r, m)
+
+#define FX_grStencilMask(fxMesa, write_mask)	\
+  do {						\
+    BEGIN_BOARD_LOCK(fxMesa);			\
+    (*grStencilMaskPtr)(write_mask);		\
+    END_BOARD_LOCK(fxMesa);			\
+  } while (0)
+
+#define FX_grStencilMask_NoLock(m) (*grStencilMaskPtr)(m)
+
+#define FX_grStencilOp(fxMesa, stencil_fail, depth_fail, depth_pass)	\
+  do {									\
+    BEGIN_BOARD_LOCK(fxMesa);						\
+    (*grStencilOpPtr)((stencil_fail), (depth_fail), (depth_pass));	\
+    END_BOARD_LOCK(fxMesa);						\
+  } while (0)
+
+#define FX_grStencilOp_NoLock(sf, df, dp)  (*grStencilOpPtr)(sf, df, dp)
+
+#define FX_grDepthMask(fxMesa, m)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grDepthMask(m);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grDepthMask_NoLock(m)  grDepthMask(m)
+
+
+extern void FX_grColorMask(GLcontext *ctx, GLboolean r, GLboolean g,
+                           GLboolean b, GLboolean a);
+
+extern void FX_grColorMask_NoLock(GLcontext *ctx, GLboolean r, GLboolean g,
+                                  GLboolean b, GLboolean a);
+
+extern void FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4]);
+
+extern void FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4]);
+
+
+extern FxBool FX_grLfbLock(fxMesaContext fxMesa,
+                           GrLock_t type, GrBuffer_t buffer,
+                           GrLfbWriteMode_t writeMode,
+                           GrOriginLocation_t origin, FxBool pixelPipeline,
+                           GrLfbInfo_t * info);
+
+#define FX_grLfbUnlock(fxMesa, t, b)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grLfbUnlock(t, b);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grConstantColorValue(fxMesa, v)	\
+  do {						\
+    BEGIN_BOARD_LOCK(fxMesa);			\
+    grConstantColorValue(v);			\
+    END_BOARD_LOCK(fxMesa);			\
+  } while (0)
+
+#define FX_grConstantColorValue_NoLock grConstantColorValue
+
+#define FX_grAADrawTriangle(fxMesa, a, b, c, ab, bc, ca)	\
+  do {								\
+    BEGIN_CLIP_LOOP(fxMesa);					\
+    grAADrawTriangle(a, b, c, ab, bc, ca);			\
+    END_CLIP_LOOP(fxMesa);					\
+  } while (0)
+
+#define FX_grAlphaBlendFunction(rs, rd, as, ad)		\
+  do {							\
+    BEGIN_BOARD_LOCK(fxMesa);				\
+    grAlphaBlendFunction(rs, rd, as, ad);		\
+    END_BOARD_LOCK(fxMesa);				\
+  } while (0)
+
+#define FX_grAlphaCombine(func, fact, loc, oth, inv)	\
+  do {							\
+    BEGIN_BOARD_LOCK(fxMesa);				\
+    grAlphaCombine(func, fact, loc, oth, inv);		\
+    END_BOARD_LOCK(fxMesa);				\
+  } while (0)
+
+#define FX_grAlphaCombine_NoLock grAlphaCombine
+
+#define FX_grAlphaTestFunction(fxMesa, f)	\
+  do {						\
+    BEGIN_BOARD_LOCK(fxMesa);			\
+    grAlphaTestFunction(f);			\
+    END_BOARD_LOCK(fxMesa);			\
+  } while (0)
+
+#define FX_grAlphaTestReferenceValue(fxMesa, v)	\
+  do {						\
+    BEGIN_BOARD_LOCK(fxMesa);			\
+    grAlphaTestReferenceValue(v);		\
+    END_BOARD_LOCK(fxMesa);			\
+  } while (0)
+
+#define FX_grClipWindow(fxMesa, minx, miny, maxx, maxy)	\
+  do {							\
+    BEGIN_BOARD_LOCK(fxMesa);				\
+    grClipWindow(minx, miny, maxx, maxy);		\
+    END_BOARD_LOCK(fxMesa);				\
+  } while (0)
+
+#define FX_grClipWindow_NoLock grClipWindow
+
+#define FX_grColorCombine(fxMesa, func, fact, loc, oth, inv)	\
+  do {								\
+    BEGIN_BOARD_LOCK(fxMesa);					\
+    grColorCombine(func, fact, loc, oth, inv);			\
+    END_BOARD_LOCK(fxMesa);					\
+  } while (0)
+
+#define FX_grColorCombine_NoLock grColorCombine
+
+#define FX_grCullMode(fxMesa, m)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grCullMode(m);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grDepthBiasLevel(fxMesa, lev)	\
+  do {						\
+    BEGIN_BOARD_LOCK(fxMesa);			\
+    grDepthBiasLevel(lev);			\
+    END_BOARD_LOCK(fxMesa);			\
+  } while (0)
+
+#define FX_grDepthBufferFunction(fxMesa, func)	\
+  do {						\
+    BEGIN_BOARD_LOCK(fxMesa);			\
+    grDepthBufferFunction(func);		\
+    END_BOARD_LOCK(fxMesa);			\
+  } while (0)
+
+#define FX_grFogColorValue(fxMesa, c)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grFogColorValue(c);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grFogMode(fxMesa, m)	\
+  do {				\
+    BEGIN_BOARD_LOCK(fxMesa);	\
+    grFogMode(m);		\
+    END_BOARD_LOCK(fxMesa);	\
+  } while (0)
+
+#define FX_grFogTable(fxMesa, t)\
+  do {				\
+    BEGIN_BOARD_LOCK(fxMesa);	\
+    grFogTable(t);		\
+    END_BOARD_LOCK(fxMesa);	\
+  } while (0)
+
+#define FX_grTexClampMode(fxMesa, t, sc, tc)	\
+  do {						\
+    BEGIN_BOARD_LOCK(fxMesa);			\
+    grTexClampMode(t, sc, tc);			\
+    END_BOARD_LOCK(fxMesa);			\
+  } while (0)
+
+#define FX_grTexClampMode_NoLock grTexClampMode
+
+#define FX_grTexCombine(fxMesa, t, rfunc, rfact, afunc, afact, rinv, ainv)	\
+  do {									\
+    BEGIN_BOARD_LOCK(fxMesa);						\
+    grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv);		\
+    END_BOARD_LOCK(fxMesa);						\
+  } while (0)
+
+#define FX_grTexCombine_NoLock grTexCombine
+
+#define FX_grTexDownloadMipMapLevel(fxMesa, t, sa, tlod, llod, ar, f, eo, d)	\
+  do {									\
+    BEGIN_BOARD_LOCK(fxMesa);						\
+    grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d);		\
+    END_BOARD_LOCK(fxMesa);						\
+  } while (0)
+
+#define FX_grTexDownloadMipMapLevel_NoLock grTexDownloadMipMapLevel
+
+#define FX_grTexDownloadMipMapLevelPartial(fxMesa, t, sa, tlod, llod, ar, f, eo, d, s, e);	\
+  do {									    \
+    BEGIN_BOARD_LOCK(fxMesa);						    \
+    grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
+    END_BOARD_LOCK(fxMesa);						    \
+  } while (0)
+
+#define FX_grTexFilterMode(fxMesa, t, minf, magf)	\
+  do {							\
+    BEGIN_BOARD_LOCK(fxMesa);				\
+    grTexFilterMode(t, minf, magf);			\
+    END_BOARD_LOCK(fxMesa);				\
+  } while (0)
+
+#define FX_grTexFilterMode_NoLock grTexFilterMode
+
+extern FxU32 FX_grTexMinAddress(fxMesaContext fxMesa, GrChipID_t tmu);
+extern FxU32 FX_grTexMaxAddress(fxMesaContext fxMesa, GrChipID_t tmu);
+
+#define FX_grTexMipMapMode(t, m, lod)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grTexMipMapMode(t, m, lod);		\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grTexMipMapMode_NoLock grTexMipMapMode
+
+#define FX_grTexSource(t, sa, eo, i)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grTexSource(t, sa, eo, i);		\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grTexSource_NoLock grTexSource
+
+extern FxU32 FX_grTexTextureMemRequired(fxMesaContext fxMesa,
+                                        FxU32 evenOdd, GrTexInfo * info);
+
+#define FX_grTexTextureMemRequired_NoLock grTexTextureMemRequired
+
+#define FX_grGlideGetState(fxMesa, s)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grGlideGetState(s);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+#define FX_grGlideGetState_NoLock(s) grGlideGetState(s);
+
+#define FX_grDRIBufferSwap(fxMesa, i)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grDRIBufferSwap(i);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grSstSelect(fxMesa, b)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grSstSelect(b);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grSstSelect_NoLock grSstSelect
+
+#define FX_grGlideSetState(fxMesa, s)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grGlideSetState(s);			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+#define FX_grGlideSetState_NoLock(s) grGlideSetState(s);
+
+#define FX_grDepthBufferMode(fxMesa, m)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grDepthBufferMode(m);		\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grLfbWriteColorFormat(fxMesa, f)	\
+  do {						\
+    BEGIN_BOARD_LOCK(fxMesa);			\
+    grLfbWriteColorFormat(f);			\
+    END_BOARD_LOCK(fxMesa);			\
+  } while (0)
+
+#define FX_grDrawVertexArray(fxMesa, m, c, p)	\
+  do {						\
+    BEGIN_CLIP_LOOP(fxMesa);			\
+    grDrawVertexArray(m, c, p);			\
+    END_CLIP_LOOP(fxMesa);			\
+  } while (0)
+
+#define FX_grGlideShutdown(fxMesa)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grGlideShutdown();			\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grTexLodBiasValue_NoLock(t, v) grTexLodBiasValue(t, v)
+
+#define FX_grTexLodBiasValue(t, v)	\
+  do {					\
+    BEGIN_BOARD_LOCK(fxMesa);		\
+    grTexLodBiasValue(t, v);		\
+    END_BOARD_LOCK(fxMesa);		\
+  } while (0)
+
+#define FX_grGlideInit_NoLock grGlideInit
+#define FX_grSstWinOpen_NoLock grSstWinOpen
+
+extern int FX_getFogTableSize(fxMesaContext fxMesa);
+
+extern int FX_getGrStateSize(fxMesaContext fxMesa);
+
+#endif /* __FX_GLIDE_WARPER__ */
Index: xc/lib/GL/mesa/src/drv/tdfx/fxpipeline.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxpipeline.c:1.1
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxpipeline.c	Sun Sep 24 09:51:16 2000
@@ -0,0 +1,293 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxpipeline.c,v 1.1 2000/09/24 13:51:16 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#include "fxdrv.h"
+#include "fxcva.h"
+#include "fxpipeline.h"
+#include "vbindirect.h"
+
+
+/* We don't handle texcoord-4 in the safe clip routines - maybe we should.
+ */
+static void
+fxDDRenderElements(struct vertex_buffer *VB)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    if (fxMesa->render_index != 0 ||
+        ((ctx->Texture.ReallyEnabled & 0xf) && VB->TexCoordPtr[0]->size > 2)
+        || ((ctx->Texture.ReallyEnabled & 0xf0)
+            && VB->TexCoordPtr[1]->size > 2) || (VB->ClipPtr->size != 4)) /* Brokes clipping otherwise */
+        gl_render_elts(VB);
+    else
+        fxDDRenderElementsDirect(VB);
+}
+
+static void
+fxDDCheckRenderVBIndirect(GLcontext * ctx, struct gl_pipeline_stage *d)
+{
+    d->type = 0;
+
+    if ((ctx->IndirectTriangles & DD_SW_SETUP) == 0 &&
+        ctx->Driver.MultipassFunc == 0) {
+        d->type = PIPE_IMMEDIATE;
+        d->inputs = VERT_SETUP_FULL | VERT_ELT | VERT_PRECALC_DATA;
+    }
+}
+
+static void
+fxDDRenderVBIndirect(struct vertex_buffer *VB)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    struct vertex_buffer *cvaVB = ctx->CVA.VB;
+
+    if (fxMesa->render_index != 0 || ((ctx->Texture.ReallyEnabled & 0xf)
+                                      && cvaVB->TexCoordPtr[0]->size > 2)
+        || ((ctx->Texture.ReallyEnabled & 0xf0)
+            && cvaVB->TexCoordPtr[1]->size > 2) || (VB->ClipPtr->size != 4)) /* Brokes clipping otherwise */
+        gl_render_vb_indirect(VB);
+    else
+        fxDDRenderVBIndirectDirect(VB);
+}
+
+
+static void
+fxDDRenderVB(struct vertex_buffer *VB)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    if ((fxMesa->render_index != 0) ||
+        ((ctx->Texture.ReallyEnabled & 0xf) && VB->TexCoordPtr[0]->size > 2)
+        || ((ctx->Texture.ReallyEnabled & 0xf0)
+            && VB->TexCoordPtr[1]->size > 2))
+        gl_render_vb(VB);
+    else
+        fxDDDoRenderVB(VB);
+}
+
+
+
+
+/* This sort of driver-based reconfiguration of the pipeline could be
+ * used to support accelerated transformation and lighting on capable
+ * hardware.
+ *
+ */
+GLuint
+fxDDRegisterPipelineStages(struct gl_pipeline_stage *out,
+                           const struct gl_pipeline_stage *in, GLuint nr)
+{
+    GLuint i, o;
+
+    for (i = o = 0; i < nr; i++) {
+        switch (in[i].ops) {
+        case PIPE_OP_RAST_SETUP_1 | PIPE_OP_RENDER:
+            out[o] = in[i];
+            out[o].state_change = NEW_CLIENT_STATE;
+            out[o].check = fxDDCheckMergeAndRender;
+            out[o].run = fxDDMergeAndRender;
+            o++;
+            break;
+        case PIPE_OP_RAST_SETUP_0:
+            out[o] = in[i];
+            out[o].cva_state_change =
+                NEW_LIGHTING | NEW_TEXTURING | NEW_RASTER_OPS;
+            out[o].state_change = ~0;
+            out[o].check = fxDDCheckPartialRasterSetup;
+            out[o].run = fxDDPartialRasterSetup;
+            o++;
+            break;
+        case PIPE_OP_RAST_SETUP_0 | PIPE_OP_RAST_SETUP_1:
+            out[o] = in[i];
+            out[o].run = fxDDDoRasterSetup;
+            o++;
+            break;
+        case PIPE_OP_RENDER:
+            out[o] = in[i];
+            if (in[i].run == gl_render_elts) {
+                out[o].run = fxDDRenderElements;
+            }
+            else if (in[i].run == gl_render_vb_indirect) {
+                out[o].check = fxDDCheckRenderVBIndirect;
+                out[o].run = fxDDRenderVBIndirect;
+            }
+            else if (in[i].run == gl_render_vb) {
+                out[o].run = fxDDRenderVB;
+            }
+
+            o++;
+            break;
+        default:
+            out[o++] = in[i];
+            break;
+        }
+    }
+
+    return o;
+}
+
+#define ILLEGAL_ENABLES (TEXTURE0_3D|		\
+			 TEXTURE1_3D|		\
+			 ENABLE_TEXMAT0 |	\
+			 ENABLE_TEXMAT1 |	\
+			 ENABLE_TEXGEN0 |	\
+			 ENABLE_TEXGEN1 |	\
+			 ENABLE_USERCLIP |	\
+			 ENABLE_LIGHT |		\
+			 ENABLE_FOG)
+
+
+
+/* Because this is slotted in by the OptimizePipeline function, most
+ * of the information here is just for gl_print_pipeline().  Only the
+ * run member is required.  
+ */
+static struct gl_pipeline_stage fx_fast_stage = {
+    "FX combined vertex transform, setup and rasterization stage",
+    PIPE_OP_VERT_XFORM | PIPE_OP_RAST_SETUP_0 | PIPE_OP_RAST_SETUP_1 |
+        PIPE_OP_RENDER,
+    PIPE_PRECALC,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,                          /* never called */
+    fxDDFastPath
+};
+
+
+
+
+/* Better than optimizing the pipeline, we can do the whole build very
+ * quickly with the aid of a new flags member.
+ */
+GLboolean
+fxDDBuildPrecalcPipeline(GLcontext * ctx)
+{
+    struct gl_pipeline *pipe = &ctx->CVA.pre;
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+
+    if (fxMesa->is_in_hardware &&
+        fxMesa->render_index == 0 &&
+        (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
+        (ctx->Array.Flags & (VERT_OBJ_234 |
+                             VERT_TEX0_4 |
+                             VERT_TEX1_4 |
+                             VERT_ELT)) == (VERT_OBJ_23 | VERT_ELT)) {
+        if (MESA_VERBOSE & (VERBOSE_STATE | VERBOSE_DRIVER))
+            if (!fxMesa->using_fast_path)
+                fprintf(stderr, "fxMesa: using fast path\n");
+
+        pipe->stages[0] = &fx_fast_stage;
+        pipe->stages[1] = 0;
+        pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
+        pipe->ops = pipe->stages[0]->ops;
+        fxMesa->using_fast_path = 1;
+        return 1;
+    }
+
+    if (fxMesa->using_fast_path) {
+        if (MESA_VERBOSE & (VERBOSE_STATE | VERBOSE_DRIVER))
+            fprintf(stderr,
+                    "fxMesa: fall back to full pipeline %x %x %x %x %x\n",
+                    fxMesa->is_in_hardware, fxMesa->render_index,
+                    (ctx->Enabled & ILLEGAL_ENABLES),
+                    (ctx->Array.Summary & (VERT_OBJ_23)),
+                    (ctx->Array.Summary & (VERT_OBJ_4 | VERT_TEX0_4 |
+                                           VERT_TEX1_4)));
+
+        fxMesa->using_fast_path = 0;
+        ctx->CVA.VB->ClipOrMask = 0;
+        ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS;
+        ctx->Array.NewArrayState |= ctx->Array.Summary;
+        return 0;
+    }
+
+    return 0;
+}
+
+
+
+
+
+
+/* Perform global optimizations to the pipeline.  The fx driver
+ * implements a single such fast path, which corresponds to the standard
+ * quake3 cva pipeline.
+ *
+ * This is now handled by the 'build' function above.
+ */
+void
+fxDDOptimizePrecalcPipeline(GLcontext * ctx, struct gl_pipeline *pipe)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+    if (fxMesa->is_in_hardware &&
+        fxMesa->render_index == 0 &&
+        (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
+        (ctx->Array.Summary & VERT_ELT)) {
+        pipe->stages[0] = &fx_fast_stage;
+        pipe->stages[1] = 0;
+    }
+}
+
+
+
+/* unused?
+void
+fxDDOptimizeEltPipeline( GLcontext *ctx, struct gl_pipeline *pipe )
+{
+   (void) ctx;
+   (void) pipe;
+}
+*/
+
Index: xc/lib/GL/mesa/src/drv/tdfx/fxpipeline.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxpipeline.h:1.1
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxpipeline.h	Sun Sep 24 09:51:16 2000
@@ -0,0 +1,16 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxpipeline.h,v 1.1 2000/09/24 13:51:16 alanh Exp $ */
+#ifndef FXPIPELINE_H
+#define FXPIPELINE_H
+
+
+extern GLuint fxDDRegisterPipelineStages(struct gl_pipeline_stage *out,
+                                         const struct gl_pipeline_stage *in,
+                                         GLuint nr);
+
+extern GLboolean fxDDBuildPrecalcPipeline(GLcontext * ctx);
+
+extern void fxDDOptimizePrecalcPipeline(GLcontext * ctx,
+                                        struct gl_pipeline *pipe);
+
+
+#endif
Index: xc/lib/GL/mesa/src/drv/tdfx/fxrender.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxrender.c:1.2
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxrender.c	Mon Nov 13 18:31:32 2000
@@ -0,0 +1,780 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxrender.c,v 1.2 2000/11/13 23:31:32 dawes Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* fxrender.c - 3Dfx VooDoo RenderVB driver function support */
+
+#include "fxdrv.h"
+#include "vbcull.h"
+#include "fxsetup.h"
+
+
+
+/*
+ * Render a line segment from VB[v1] to VB[v2] when either one or both
+ * endpoints must be clipped.
+ */
+#if !defined(__MWERKS__)
+INLINE
+#endif
+    void
+fxRenderClippedLine(struct vertex_buffer *VB, GLuint v1, GLuint v2)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(VB->ctx);
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+    GLubyte mask = VB->ClipMask[v1] | VB->ClipMask[v2];
+
+    if (!mask || (VB->ctx->line_clip_tab[VB->ClipPtr->size]) (VB, &v1, &v2,
+                                                              mask))
+       FX_grDrawLine(fxMesa, (GrVertex *) gWin[v1].f, (GrVertex *) gWin[v2].f);
+}
+
+
+
+
+/* This is legal for Quads as well as triangles, hence the 'n' parameter.
+ */
+INLINE void
+fxRenderClippedTriangle(struct vertex_buffer *VB, GLuint n, GLuint vlist[])
+{
+    fxMesaContext fxMesa = FX_CONTEXT(VB->ctx);
+    GLubyte mask = 0;
+    GLuint i;
+
+    for (i = 0; i < n; i++)
+        mask |= VB->ClipMask[vlist[i]];
+
+    if (mask & CLIP_USER_BIT) {
+        GLubyte *userclipmask = VB->UserClipMask;
+        if (userclipmask[vlist[0]] & userclipmask[vlist[1]] &
+            userclipmask[vlist[2]])
+            return;
+    }
+
+    n = (VB->ctx->poly_clip_tab[VB->ClipPtr->size]) (VB, n, vlist, mask);
+    if (n >= 3) {
+        fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+        GrVertex *i0 = (GrVertex *) gWin[vlist[0]].f;
+        GrVertex *i1 = (GrVertex *) gWin[vlist[1]].f;
+        GrVertex *i2 = (GrVertex *) gWin[vlist[2]].f;
+        GLuint i;
+
+        for (i = 2; i < n; i++, i1 = i2, i2 = (GrVertex *) gWin[vlist[i]].f) {
+            FX_grDrawTriangle(fxMesa, i0, i1, i2);
+        }
+    }
+}
+
+
+
+
+
+static INLINE void
+fxSafeClippedLine(struct vertex_buffer *VB, GLuint v1, GLuint v2)
+{
+    GLubyte mask = VB->ClipMask[v1] | VB->ClipMask[v2];
+    fxMesaContext fxMesa = FX_CONTEXT(VB->ctx);
+
+    if (!mask) {
+        fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+        FX_grDrawLine(fxMesa, (GrVertex *) gWin[v1].f, (GrVertex *) gWin[v2].f);
+    }
+    else {
+        fxMesaContext fxMesa = (fxMesaContext) VB->ctx->DriverCtx;
+        fxLineClipTab[fxMesa->setupindex & 0x7] (VB, v1, v2, mask);
+    }
+}
+
+
+static INLINE void
+fxSafeClippedTriangle(struct vertex_buffer *VB,
+                      fxVertex * gWin,
+                      tfxTriClipFunc cliptri, GLuint v2, GLuint v1, GLuint v)
+{
+    GLubyte *clipmask = VB->ClipMask;
+    GLubyte mask = clipmask[v2] | clipmask[v1] | clipmask[v];
+    fxMesaContext fxMesa = FX_CONTEXT(VB->ctx);
+
+    if (!mask) {
+        FX_grDrawTriangle(fxMesa, (GrVertex *) gWin[v2].f,
+                          (GrVertex *) gWin[v1].f, (GrVertex *) gWin[v].f);
+        return;
+    }
+
+    if (!(clipmask[v2] & clipmask[v1] & clipmask[v] & CLIP_ALL_BITS)) {
+        GLuint vl[3];
+        GLuint imask = mask;
+
+        if (imask & CLIP_USER_BIT) {
+            GLubyte *userclipmask = VB->UserClipMask;
+            if (userclipmask[v2] & userclipmask[v1] & userclipmask[v])
+                return;
+            imask |=
+                (userclipmask[v2] | userclipmask[v1] | userclipmask[v]) << 8;
+        }
+
+        ASSIGN_3V(vl, v2, v1, v);
+        cliptri(VB, vl, imask);
+    }
+}
+
+
+static INLINE void
+fxSafeClippedTriangle2(struct vertex_buffer *VB,
+                       fxVertex * gWin,
+                       tfxTriViewClipFunc cliptri,
+                       GLuint v2, GLuint v1, GLuint v)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(VB->ctx);
+    GLubyte *clipmask = VB->ClipMask;
+    GLubyte mask = clipmask[v2] | clipmask[v1] | clipmask[v];
+
+    if (!mask) {
+        FX_grDrawTriangle(fxMesa,
+                          (GrVertex *) gWin[v2].f, (GrVertex *) gWin[v1].f,
+                          (GrVertex *) gWin[v].f);
+    }
+    else if (!(clipmask[v2] & clipmask[v1] & clipmask[v])) {
+        GLuint vl[3];
+        ASSIGN_3V(vl, v2, v1, v);
+        cliptri(VB, vl, mask);
+    }
+}
+
+
+static INLINE void
+fxSafeClippedTriangle3(struct vertex_buffer *VB,
+                       fxVertex * gWin,
+                       tfxTriClipFunc cliptri, GLuint v2, GLuint v1, GLuint v)
+{
+    GLubyte *clipmask = VB->ClipMask;
+    GLubyte mask = clipmask[v2] | clipmask[v1] | clipmask[v];
+    GLuint imask = mask;
+
+    if (imask & CLIP_USER_BIT) {
+        GLubyte *userclipmask = VB->UserClipMask;
+        if (userclipmask[v2] & userclipmask[v1] & userclipmask[v])
+            return;
+        imask |= (userclipmask[v2] | userclipmask[v1] | userclipmask[v]) << 8;
+    }
+
+    {
+        GLuint vl[3];
+        ASSIGN_3V(vl, v2, v1, v);
+        cliptri(VB, vl, imask);
+    }
+}
+
+
+
+
+
+/************************************************************************/
+/************************ RenderVB functions ****************************/
+/************************************************************************/
+
+
+/* Render front-facing, non-clipped primitives.
+ */
+
+#define RENDER_POINTS( start, count )				\
+   (void) gWin;							\
+   (void) VB;							\
+   (VB->ctx->Driver.PointsFunc)( VB->ctx, start, count )
+
+#define RENDER_LINE( i1, i )			\
+  do {						\
+     RVB_COLOR(i);				\
+     FX_grDrawLine(fxMesa, (GrVertex *)gWin[i1].f,	\
+		(GrVertex *)gWin[i].f);		\
+  } while (0)
+
+#define RENDER_TRI( i2, i1, i, pv, parity )	\
+  do {						\
+    RVB_COLOR(pv);				\
+    if (parity) {				\
+      FX_grDrawTriangle(fxMesa, (GrVertex *)gWin[i1].f,	\
+		      (GrVertex *)gWin[i2].f,	\
+		      (GrVertex *)gWin[i].f);	\
+    } else {					\
+      FX_grDrawTriangle(fxMesa, (GrVertex *)gWin[i2].f,	\
+		      (GrVertex *)gWin[i1].f,	\
+		      (GrVertex *)gWin[i].f);	\
+    }						\
+  } while (0)
+
+#define RENDER_QUAD( i3, i2, i1, i, pv )	\
+  do {						\
+    RVB_COLOR(pv);				\
+    FX_grDrawTriangle(fxMesa, (GrVertex *)gWin[i3].f,	\
+		    (GrVertex *)gWin[i2].f,	\
+		    (GrVertex *)gWin[i].f);	\
+    FX_grDrawTriangle(fxMesa, (GrVertex *)gWin[i2].f,	\
+		    (GrVertex *)gWin[i1].f,	\
+		    (GrVertex *)gWin[i].f);	\
+  } while (0)
+
+
+
+#define LOCAL_VARS						\
+   fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;	\
+   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;			\
+   (void) fxMesa;
+
+#define INIT(x)
+
+#define TAG(x) x##_fx_flat_raw
+#undef  RVB_COLOR
+#define RVB_COLOR(pv)  FX_VB_COLOR(fxMesa, VB->ColorPtr->data[pv])
+#define PRESERVE_VB_DEFS
+
+#include "render_tmp.h"
+
+#define TAG(x) x##_fx_smooth_raw
+#undef  RVB_COLOR
+#define RVB_COLOR(x)
+
+#include "render_tmp.h"
+
+
+
+/* Render with clipped and/or culled primitives with cullmask information.
+ */
+#define RENDER_POINTS( start, count )				\
+   (void) gWin;							\
+   (void) cullmask;						\
+   (VB->ctx->Driver.PointsFunc)( VB->ctx, start, count )
+
+
+#define RENDER_LINE( i1, i )						\
+  do {									\
+    const GLubyte flags = cullmask[i];					\
+									\
+    if (!(flags & PRIM_NOT_CULLED))					\
+      continue;								\
+									\
+    RVB_COLOR(i);							\
+    if (flags & PRIM_ANY_CLIP)						\
+      fxRenderClippedLine( VB, i1, i );					\
+    else								\
+      FX_grDrawLine( fxMesa, (GrVertex *)gWin[i1].f, (GrVertex *)gWin[i].f );	\
+ } while (0)
+
+
+#define RENDER_TRI( i2, i1, i, pv, parity)		\
+  do {							\
+    const GLubyte flags = cullmask[i];			\
+    GLuint e2,e1;					\
+							\
+    if (!(flags & PRIM_NOT_CULLED))			\
+      continue;						\
+							\
+     e2=i2, e1=i1;					\
+     if (parity) { e2=i1; e1=i2; }			\
+							\
+     RVB_COLOR(pv);					\
+     if (flags & PRIM_ANY_CLIP) {			\
+       fxSafeClippedTriangle3(VB,gWin,cliptri,e2,e1,i);	\
+     } else {						\
+       FX_grDrawTriangle(fxMesa, (GrVertex *)gWin[e2].f,	\
+		    (GrVertex *)gWin[e1].f,		\
+		    (GrVertex *)gWin[i].f);		\
+     }							\
+  } while (0)
+
+
+#define RENDER_QUAD(i3, i2, i1, i, pv)			\
+  do {							\
+    const GLubyte flags = cullmask[i];			\
+							\
+    if (!(flags & PRIM_NOT_CULLED))			\
+      continue;						\
+							\
+    RVB_COLOR(pv);					\
+    if (flags&PRIM_ANY_CLIP) {				\
+      fxSafeClippedTriangle3(VB,gWin,cliptri,i3,i2,i);	\
+      fxSafeClippedTriangle3(VB,gWin,cliptri,i2,i1,i);	\
+    } else {						\
+      FX_grDrawTriangle(fxMesa, (GrVertex *)gWin[i3].f,		\
+		     (GrVertex *)gWin[i2].f,		\
+		     (GrVertex *)gWin[i].f);		\
+      FX_grDrawTriangle(fxMesa, (GrVertex *)gWin[i2].f,		\
+		     (GrVertex *)gWin[i1].f,		\
+		     (GrVertex *)gWin[i].f);		\
+    }							\
+  } while (0)
+
+
+
+
+
+#define LOCAL_VARS						\
+   fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;	\
+   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;			\
+   const GLubyte *cullmask = VB->CullMask;			\
+   tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
+
+
+
+
+#define INIT(x)     (void) cliptri; (void) fxMesa;
+
+#define TAG(x) x##_fx_smooth_culled
+#undef  RVB_COLOR
+#define RVB_COLOR(x)
+#define PRESERVE_VB_DEFS
+#include "render_tmp.h"
+
+#define TAG(x) x##_fx_flat_culled
+#undef  RVB_COLOR
+#define RVB_COLOR(pv)  FX_VB_COLOR(fxMesa, VB->ColorPtr->data[pv])
+
+#include "render_tmp.h"
+
+
+
+
+/* Direct, with the possibility of clipping.
+ */
+#define RENDER_POINTS( start, count )		\
+  do {						\
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;	\
+    GLubyte *clipmask = VB->ClipMask;		\
+    GLuint i;					\
+    for (i = start ; i < count ; i++)		\
+      if (clipmask[i] == 0) {			\
+        RVB_COLOR(i);				\
+        FX_grDrawPoint( fxMesa, (GrVertex *)gWin[i].f );\
+      }						\
+  } while (0)
+
+#define RENDER_LINE( i1, i )			\
+  do {						\
+    RVB_COLOR(i);				\
+    fxSafeClippedLine( VB, i1, i );		\
+  } while (0)
+
+#define RENDER_TRI( i2, i1, i, pv, parity)		\
+  do {							\
+    GLuint e2=i2, e1=i1;					\
+    if (parity) { GLuint t=e2; e2=e1; e1=t; }		\
+    RVB_COLOR(pv);					\
+    fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,i);	\
+  } while (0)
+
+#define RENDER_QUAD( i3, i2, i1, i, pv)			\
+  do {							\
+    RVB_COLOR(pv);					\
+    fxSafeClippedTriangle(VB,gWin,cliptri,i3,i2,i);	\
+    fxSafeClippedTriangle(VB,gWin,cliptri,i2,i1,i);	\
+  } while (0)
+
+#define LOCAL_VARS						\
+   fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;	\
+   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;			\
+   tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
+
+#define INIT(x)  (void) cliptri; (void) gWin;
+
+#define TAG(x) x##_fx_smooth_clipped
+#undef  RVB_COLOR
+#define RVB_COLOR(x)
+#define PRESERVE_VB_DEFS
+#include "render_tmp.h"
+
+
+#define TAG(x) x##_fx_flat_clipped
+#undef  RVB_COLOR
+#define RVB_COLOR(pv)  FX_VB_COLOR(fxMesa, VB->ColorPtr->data[pv])
+#include "render_tmp.h"
+
+
+
+
+
+
+/* Indirect, with the possibility of clipping.
+ */
+#define RENDER_POINTS( start, count )			\
+  do {							\
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;		\
+    GLuint e;						\
+    GLubyte *clipmask = VB->ClipMask;			\
+    for(e=start;e<count;e++)				\
+      if(clipmask[elt[e]]==0) {				\
+        FX_grDrawPoint(fxMesa, (GrVertex *)gWin[elt[e]].f);	\
+      }							\
+  } while (0)
+
+#define RENDER_LINE( i1, i )			\
+  do {						\
+    GLuint e1 = elt[i1], e = elt[i];		\
+    RVB_COLOR(e);				\
+    fxSafeClippedLine( VB, e1, e );		\
+  } while (0)
+
+#define RENDER_TRI( i2, i1, i, pv, parity)		\
+  do {							\
+    GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];	\
+    if (parity) { GLuint t=e2; e2=e1; e1=t; }		\
+    fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e);	\
+  } while (0)
+
+#define RENDER_QUAD( i3, i2, i1, i, pv)				\
+  do {								\
+    GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
+    fxSafeClippedTriangle(VB,gWin,cliptri,e3,e2,e);		\
+    fxSafeClippedTriangle(VB,gWin,cliptri,e2,e1,e);		\
+  } while (0)
+
+#define LOCAL_VARS const GLuint *elt = VB->EltPtr->data;	\
+   fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;	\
+   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;			\
+   tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
+
+#define INIT(x)  (void) cliptri; (void) gWin;
+
+#define TAG(x) x##_fx_smooth_indirect_clipped
+#undef  RVB_COLOR
+#define RVB_COLOR(x)
+#include "render_tmp.h"
+
+
+/* Indirect, clipped, but no user clip.
+ */
+#define RENDER_POINTS( start, count )			\
+  do {							\
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;		\
+    GLuint e;						\
+    GLubyte *clipmask = VB->ClipMask;			\
+    for(e=start;e<count;e++)				\
+      if(clipmask[elt[e]]==0) {				\
+        FX_grDrawPoint(fxMesa, (GrVertex *)gWin[elt[e]].f);	\
+      }							\
+  } while (0)
+
+#define RENDER_LINE( i1, i )			\
+  do {						\
+    GLuint e1 = elt[i1], e = elt[i];		\
+    RVB_COLOR(e);				\
+    fxSafeClippedLine( VB, e1, e );		\
+  } while (0)
+
+#define RENDER_TRI( i2, i1, i, pv, parity)		\
+  do {							\
+    GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];	\
+    if (parity) { GLuint t=e2; e2=e1; e1=t; }		\
+    fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e);	\
+  } while (0)
+
+#define RENDER_QUAD( i3, i2, i1, i, pv)				\
+  do {								\
+    GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
+    fxSafeClippedTriangle2(VB,gWin,cliptri,e3,e2,e);		\
+    fxSafeClippedTriangle2(VB,gWin,cliptri,e2,e1,e);		\
+  } while (0)
+
+#define LOCAL_VARS const GLuint *elt = VB->EltPtr->data;	\
+   fxMesaContext fxMesa = (fxMesaContext)VB->ctx->DriverCtx;	\
+   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;			\
+   tfxTriViewClipFunc cliptri = fxMesa->view_clip_tri;
+
+#define INIT(x)  (void) cliptri; (void) gWin;
+
+#define TAG(x) x##_fx_smooth_indirect_view_clipped
+#undef  RVB_COLOR
+#define RVB_COLOR(x)
+#include "render_tmp.h"
+
+
+
+
+
+
+
+/* Indirect, and no clipping required.
+ */
+#define RENDER_POINTS( start, count )			\
+  do {							\
+    GLuint e;						\
+    for(e=start;e<count;e++) {				\
+      FX_grDrawPoint_NoLock((GrVertex *)gWin[elt[e]].f);\
+    }							\
+  } while (0)
+
+#define RENDER_LINE( i1, i )						\
+  do {									\
+    GLuint e1 = elt[i1], e = elt[i];					\
+    FX_grDrawLine_NoLock((GrVertex *)gWin[e1].f, (GrVertex *)gWin[e].f);\
+  } while (0)
+
+
+#define RENDER_TRI( i2, i1, i, pv, parity)		\
+  do {							\
+    GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i];	\
+    if (parity) {GLuint tmp = e2; e2 = e1; e1 = tmp;} 	\
+    FX_grDrawTriangle_NoLock((GrVertex *)gWin[e2].f,	\
+		             (GrVertex *)gWin[e1].f,	\
+		             (GrVertex *)gWin[e].f);	\
+  } while (0)
+
+
+#define RENDER_QUAD( i3, i2, i1, i, pv)				\
+  do {								\
+    GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i];\
+    FX_grDrawTriangle_NoLock((GrVertex *)gWin[e3].f,		\
+		             (GrVertex *)gWin[e2].f,		\
+		             (GrVertex *)gWin[e].f);		\
+    FX_grDrawTriangle_NoLock((GrVertex *)gWin[e2].f,		\
+		             (GrVertex *)gWin[e1].f,		\
+		             (GrVertex *)gWin[e].f);		\
+  } while (0)
+
+#define LOCAL_VARS				\
+   fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;	\
+   const GLuint *elt = VB->EltPtr->data;        \
+   fxMesaContext fxMesa = FX_CONTEXT(VB->ctx);
+
+#define INIT(x)  BEGIN_CLIP_LOOP(fxMesa);
+#define POSTFIX  END_CLIP_LOOP(fxMesa);
+
+#define TAG(x) x##_fx_smooth_indirect
+#undef  RVB_COLOR
+#define RVB_COLOR(x)
+#include "render_tmp.h"
+
+
+
+
+
+/* Direct in this context means that triangles, lines, points can be
+ * rendered simply by calling grDrawTriangle, etc., without any
+ * additional setup (such as calling grConstantColor).  We also use a
+ * 'safe' set of clipping routines which don't require write-access to
+ * the arrays in the vertex buffer, and don't care about array
+ * stride.  
+ *
+ * Thus there is no call to gl_import_arrays() in this function.  
+ *
+ * This safe clipping should be generalized to call driver->trianglefunc
+ * under the appropriate conditions.
+ *
+ * We don't handle texcoord-4 in the safe clip routines - maybe we should.
+ *
+ */
+void
+fxDDRenderElementsDirect(struct vertex_buffer *VB)
+{
+    GLcontext *ctx = VB->ctx;
+    struct vertex_buffer *saved_vb = ctx->VB;
+    GLenum prim = ctx->CVA.elt_mode;
+    GLuint nr = VB->EltPtr->count;
+    render_func func = render_tab_fx_smooth_indirect[prim];
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint p = 0;
+
+    if (!nr)
+        return;
+
+    if (fxMesa->new_state)
+        fxSetupFXUnits(ctx);
+
+    if (!nr)
+        return;
+
+    if (VB->ClipOrMask) {
+        func = render_tab_fx_smooth_indirect_view_clipped[prim];
+        if (VB->ClipOrMask & CLIP_USER_BIT)
+            func = render_tab_fx_smooth_indirect_clipped[prim];
+    }
+
+    ctx->VB = VB;               /* kludge */
+
+    do {
+        func(VB, 0, nr, 0);
+    } while (ctx->Driver.MultipassFunc && ctx->Driver.MultipassFunc(VB, ++p));
+
+
+    ctx->VB = saved_vb;
+}
+
+
+void
+fxDDRenderVBIndirectDirect(struct vertex_buffer *VB)
+{
+    GLcontext *ctx = VB->ctx;
+    struct vertex_buffer *cvaVB = ctx->CVA.VB;
+    struct vertex_buffer *saved_vb = ctx->VB;
+    GLuint i, next, count = VB->Count;
+    render_func *tab = render_tab_fx_smooth_indirect;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint p = 0;
+
+    if (cvaVB->ClipOrMask)
+        tab = render_tab_fx_smooth_indirect_clipped;
+
+    if (!VB->CullDone)
+        gl_fast_copy_vb(VB);
+
+    if (fxMesa->new_state)
+        fxSetupFXUnits(ctx);
+
+    ctx->VB = cvaVB;
+    cvaVB->EltPtr = VB->EltPtr;
+
+    do {
+        GLuint parity = VB->Parity;
+
+        for (i = VB->CopyStart; i < count; parity = 0, i = next) {
+            GLuint prim = VB->Primitive[i];
+            next = VB->NextPrimitive[i];
+            tab[prim] (cvaVB, i, next, parity);
+        }
+        /* loop never taken */
+    } while (ctx->Driver.MultipassFunc &&
+             ctx->Driver.MultipassFunc(cvaVB, ++p));
+
+    cvaVB->EltPtr = 0;
+    ctx->VB = saved_vb;
+}
+
+
+static render_func *fxDDRenderVBSmooth_tables[3] = {
+    render_tab_fx_smooth_clipped,
+    render_tab_fx_smooth_culled,
+    render_tab_fx_smooth_raw
+};
+
+static render_func *fxDDRenderVBFlat_tables[3] = {
+    render_tab_fx_flat_clipped,
+    render_tab_fx_flat_culled,
+    render_tab_fx_flat_raw
+};
+
+
+static render_func *null_tables[3] = {
+    0,
+    0,
+    0
+};
+
+#if defined(FX_GLIDE3)
+#include "fxstripdet.c"
+#endif
+
+void
+fxDDRenderInit(GLcontext * ctx)
+{
+    render_init_fx_smooth_indirect_view_clipped();
+    render_init_fx_smooth_indirect_clipped();
+    render_init_fx_smooth_indirect();
+    render_init_fx_smooth_raw();
+    render_init_fx_smooth_culled();
+    render_init_fx_smooth_clipped();
+    render_init_fx_flat_raw();
+    render_init_fx_flat_culled();
+    render_init_fx_flat_clipped();
+#if defined(FX_GLIDE3)
+    fxDDRenderInitGlide3(ctx);
+#endif
+}
+
+
+/* Now used to set an internal var in fxMesa - we hook out at the
+ * level of gl_render_vb() instead.
+ */
+render_func **
+fxDDChooseRenderVBTables(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    if (ctx->IndirectTriangles & DD_SW_SETUP)
+        return null_tables;
+
+    switch (fxMesa->render_index) {
+/*    case FX_FLAT: */
+/*      return fxDDRenderVBFlat_tables; */
+    case 0:
+        return fxDDRenderVBSmooth_tables;
+    default:
+        return null_tables;
+    }
+}
+
+
+void
+fxDDDoRenderVB(struct vertex_buffer *VB)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint i, next, prim;
+    GLuint parity = VB->Parity;
+    render_func *tab;
+    GLuint count = VB->Count;
+    GLint p = 0;
+
+    if (fxMesa->new_state)
+        fxSetupFXUnits(ctx);
+
+    if (VB->Indirect) {
+        return;
+    }
+    else if (VB->CullMode & CLIP_MASK_ACTIVE) {
+        tab = fxMesa->RenderVBClippedTab;
+    }
+    else {
+        tab = fxMesa->RenderVBRawTab;
+    }
+
+    if (!VB->CullDone)
+        gl_fast_copy_vb(VB);
+
+    do {
+        for (i = VB->CopyStart; i < count; parity = 0, i = next) {
+            prim = VB->Primitive[i];
+            next = VB->NextPrimitive[i];
+            tab[prim] (VB, i, next, parity);
+        }
+
+    } while (ctx->Driver.MultipassFunc && ctx->Driver.MultipassFunc(VB, ++p));
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxsanity.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxsanity.c:1.2
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxsanity.c	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,128 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxsanity.c,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#include "fxdrv.h"
+
+/* I have found this quite useful in tracking down transformation &
+ * clipping bugs.  If you get a random graphics card freeze, running
+ * your triangles through this will probably catch the problem.
+ */
+
+#define WID 640
+#define HI  480
+
+#undef grDrawTriangle
+
+void
+fx_sanity_triangle(fxMesaContext fxMesa,
+                   GrVertex * v1, GrVertex * v2, GrVertex * v3)
+{
+    GLuint rv = 1, print = 0;
+
+    GLfloat area = ((v1->x - v3->x) * (v2->y - v3->y) -
+                    (v1->y - v3->y) * (v2->x - v3->x));
+
+    if (v1->x < 0 || v1->y < 0 || v1->x > WID || v1->y > HI ||
+        v2->x < 0 || v2->y < 0 || v2->x > WID || v2->y > HI ||
+        v3->x < 0 || v3->y < 0 || v3->x > WID || v3->y > HI) {
+        fprintf(stderr, "not clipped/set up!!!!!\n");
+        rv = 0;
+        print = 1;
+    }
+
+    if (area > (WID * HI)) {
+        fprintf(stderr, "too big\n");
+        rv = 0;
+    }
+    if (v1->oow == 0 || v2->oow == 0 || v3->oow == 0) {
+        fprintf(stderr, "zero oow\n");
+        rv = 0;
+    }
+    if (0 && area == 0) {
+        fprintf(stderr, "zero area %p %p %p\n", v1, v2, v3);
+        rv = 0;
+    }
+
+    if (print) {
+#if FX_USE_PARGB
+        fprintf(stderr,
+                "v1: %f %f %f %f col %d %d %d %d t0 %f %f %f t1 %f %f %f\n",
+                v3->x, v3->y, v3->ooz, v3->oow, GET_PR(v1), GET_PG(v1), GET_PB(v1), GET_PA(v1),
+                v1->tmuvtx[0].sow, v1->tmuvtx[0].tow, v1->tmuvtx[0].oow,
+                v1->tmuvtx[1].sow, v1->tmuvtx[1].tow, v1->tmuvtx[1].oow);
+        fprintf(stderr,
+                "v2: %f %f %f %f col %d %d %d %d t0 %f %f %f t1 %f %f %f\n",
+                v3->x, v3->y, v3->ooz, v3->oow, GET_PR(v1), GET_PG(v1), GET_PB(v1), GET_PA(v1),
+                v2->tmuvtx[0].sow, v2->tmuvtx[0].tow, v2->tmuvtx[0].oow,
+                v2->tmuvtx[1].sow, v2->tmuvtx[1].tow, v2->tmuvtx[1].oow);
+        fprintf(stderr,
+                "v3: %f %f %f %f col %d %d %d %d t0 %f %f %f t1 %f %f %f\n",
+                v3->x, v3->y, v3->ooz, v3->oow, GET_PR(v1), GET_PG(v1), GET_PB(v1), GET_PA(v1),
+                v3->tmuvtx[0].sow, v3->tmuvtx[0].tow, v3->tmuvtx[0].oow,
+                v3->tmuvtx[1].sow, v3->tmuvtx[1].tow, v3->tmuvtx[1].oow);
+#else
+        fprintf(stderr,
+                "v1: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
+                v1->x, v1->y, v1->ooz, v1->oow, v1->r, v1->g, v1->b, v1->a,
+                v1->tmuvtx[0].sow, v1->tmuvtx[0].tow, v1->tmuvtx[0].oow,
+                v1->tmuvtx[1].sow, v1->tmuvtx[1].tow, v1->tmuvtx[1].oow);
+        fprintf(stderr,
+                "v2: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
+                v2->x, v2->y, v2->ooz, v2->oow, v2->r, v2->g, v2->b, v2->a,
+                v2->tmuvtx[0].sow, v2->tmuvtx[0].tow, v2->tmuvtx[0].oow,
+                v2->tmuvtx[1].sow, v2->tmuvtx[1].tow, v2->tmuvtx[1].oow);
+        fprintf(stderr,
+                "v3: %f %f %f %f col %.0f %.0f %.0f %.0f t0 %f %f %f t1 %f %f %f\n",
+                v3->x, v3->y, v3->ooz, v3->oow, v3->r, v3->g, v3->b, v3->a,
+                v3->tmuvtx[0].sow, v3->tmuvtx[0].tow, v3->tmuvtx[0].oow,
+                v3->tmuvtx[1].sow, v3->tmuvtx[1].tow, v3->tmuvtx[1].oow);
+#endif
+    }
+
+    if (1)
+        FX_grDrawTriangle(fxMesa, v1, v2, v3);
+    else
+        fprintf(stderr, "\n\n\n");
+}
+
Index: xc/lib/GL/mesa/src/drv/tdfx/fxsdettmp.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxsdettmp.h:1.1
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxsdettmp.h	Sun Sep 24 09:51:19 2000
@@ -0,0 +1,154 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxsdettmp.h,v 1.1 2000/09/24 13:51:19 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* 
+ * Notes: the folowing code works only if count is > start.
+ * Corrently we are looking for the pattern:
+ * v0,v1,v2 v2,v1,v3, v2,v3,v4....
+ *
+ * For this:
+ * #define STRIP0		((u1 == v1) && (u2 == v0))	
+ * #define STRIP1		((u0 == v0) && (u2 == v1))
+ *
+ */
+
+
+static void TAG(render_vb_triangles_smooth_indirect_sd)
+  (struct vertex_buffer * VB, GLuint start, GLuint count, GLuint parity)
+{
+    GLint u0, u1, u2;
+    GLint v0, v1, v2;
+    GLuint *elt = VB->EltPtr->data;
+
+    int i;
+    LOCAL_VARS INIT(GL_TRIANGLES);
+
+    elt = &elt[start - 1];
+    u0 = *(++elt);
+    u1 = *(++elt);
+    u2 = *(++elt);
+    i = start + 3;
+    while (i < count) {
+        v0 = *(++elt);
+        v1 = *(++elt);
+        v2 = *(++elt);
+
+        if (CLIPPED(u0, u1, u2)) {
+            if (!CULLED(u0, u1, u2))
+                SENDCLIPTRI(u0, u1, u2);
+        }
+        else {
+            if (STRIP0(u, v)) {
+                int is_strips = 1;
+                int parity = 0;
+                STRIPSLOCAL_VAR FLUSHTRI();
+                STARTSTRIPS(u0, u1, u2);
+                while (is_strips && i < count) {
+                    SENDSTRIPS(v2);
+
+                    u0 = v0;
+                    u1 = v1;
+                    u2 = v2;
+                    i += 3;
+                    v0 = *(++elt);
+                    v1 = *(++elt);
+                    v2 = *(++elt);
+
+                    if (parity) {
+                        is_strips = STRIP0(u, v);
+                        parity = 0;
+                    }
+                    else {
+                        is_strips = STRIP1(u, v);
+                        parity = 1;
+                    }
+                }
+                FLUSHSTRIPS();
+
+                if (i >= count)
+                    return;
+            }
+            else {
+                SENDTRI(u0, u1, u2);
+            }
+        }
+        u0 = v0;
+        u1 = v1;
+        u2 = v2;
+        i += 3;
+    }
+    if (CLIPPED(u0, u1, u2)) {
+        if (!CULLED(u0, u1, u2))
+            SENDCLIPTRI(u0, u1, u2);
+    }
+    else {
+        SENDTRI(u0, u1, u2);
+    }
+    FLUSHTRI();
+
+}
+
+#ifndef PRESERVE_VB_DEFS
+#undef SENDTRI
+#undef STRIP0
+#undef STRIP1
+#undef LOCAL_VARS
+#undef STRIPSLOCAL_VAR
+#undef INIT
+#undef SENDTRI
+#undef FLUSHTRI
+#undef STARTSTRIPS
+#undef SENDSTRIPS
+#undef FLUSHSTRIPS
+#undef CLIPPED
+#undef CULLED
+#undef SENDCLIPTRI
+#endif
+
+#ifndef PRESERVE_TAG
+#undef TAG
+#endif
+
+#undef PRESERVE_VB_DEFS
+#undef PRESERVE_TAG
Index: xc/lib/GL/mesa/src/drv/tdfx/fxsetup.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxsetup.c:1.2
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxsetup.c	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,2886 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxsetup.c,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
+
+#include "fxdrv.h"
+#include "fxddtex.h"
+#include "fxtexman.h"
+#include "fxsetup.h"
+#include "enums.h"
+
+
+static GLboolean fxMultipassTexture(struct vertex_buffer *, GLuint);
+
+
+
+void
+fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+    GLint minl, maxl;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxTexValidate(...) Start\n");
+    }
+
+    if (ti->validated) {
+        if (MESA_VERBOSE & VERBOSE_DRIVER) {
+            fprintf(stderr,
+                    "fxmesa: fxTexValidate(...) End (validated=GL_TRUE)\n");
+        }
+        return;
+    }
+
+    ti->tObj = tObj;
+    minl = ti->minLevel = tObj->BaseLevel;
+    maxl = ti->maxLevel = MIN2(tObj->MaxLevel, tObj->Image[0]->MaxLog2);
+
+    fxTexGetInfo(ctx, tObj->Image[minl]->Width, tObj->Image[minl]->Height,
+                 &(FX_largeLodLog2(ti->info)),
+                 &(FX_aspectRatioLog2(ti->info)), &(ti->sScale),
+                 &(ti->tScale), &(ti->int_sScale), &(ti->int_tScale), NULL,
+                 NULL);
+
+    if ((tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR))
+        fxTexGetInfo(ctx, tObj->Image[maxl]->Width, tObj->Image[maxl]->Height,
+                     &(FX_smallLodLog2(ti->info)), NULL,
+                     NULL, NULL, NULL, NULL, NULL, NULL);
+    else
+        FX_smallLodLog2(ti->info) = FX_largeLodLog2(ti->info);
+
+    fxTexGetFormat(tObj->Image[minl]->IntFormat, &(ti->info.format),
+                   &(ti->baseLevelInternalFormat), NULL, NULL,
+                   fxMesa->haveHwStencil);
+
+    switch (tObj->WrapS) {
+    case GL_CLAMP_TO_EDGE:
+    case GL_CLAMP:
+        ti->sClamp = 1;
+        break;
+    case GL_REPEAT:
+        ti->sClamp = 0;
+        break;
+    default:
+        ;                       /* silence compiler warning */
+    }
+    switch (tObj->WrapT) {
+    case GL_CLAMP_TO_EDGE:
+    case GL_CLAMP:
+        ti->tClamp = 1;
+        break;
+    case GL_REPEAT:
+        ti->tClamp = 0;
+        break;
+    default:
+        ;                       /* silence compiler warning */
+    }
+
+    ti->validated = GL_TRUE;
+
+    ti->info.data = NULL;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxTexValidate(...) End\n");
+    }
+}
+
+static void
+fxPrintUnitsMode(const char *msg, GLuint mode)
+{
+    fprintf(stderr,
+            "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+            msg,
+            mode,
+            (mode & FX_UM_E0_REPLACE) ? "E0_REPLACE, " : "",
+            (mode & FX_UM_E0_MODULATE) ? "E0_MODULATE, " : "",
+            (mode & FX_UM_E0_DECAL) ? "E0_DECAL, " : "",
+            (mode & FX_UM_E0_BLEND) ? "E0_BLEND, " : "",
+            (mode & FX_UM_E1_REPLACE) ? "E1_REPLACE, " : "",
+            (mode & FX_UM_E1_MODULATE) ? "E1_MODULATE, " : "",
+            (mode & FX_UM_E1_DECAL) ? "E1_DECAL, " : "",
+            (mode & FX_UM_E1_BLEND) ? "E1_BLEND, " : "",
+            (mode & FX_UM_E0_ALPHA) ? "E0_ALPHA, " : "",
+            (mode & FX_UM_E0_LUMINANCE) ? "E0_LUMINANCE, " : "",
+            (mode & FX_UM_E0_LUMINANCE_ALPHA) ? "E0_LUMINANCE_ALPHA, " : "",
+            (mode & FX_UM_E0_INTENSITY) ? "E0_INTENSITY, " : "",
+            (mode & FX_UM_E0_RGB) ? "E0_RGB, " : "",
+            (mode & FX_UM_E0_RGBA) ? "E0_RGBA, " : "",
+            (mode & FX_UM_E1_ALPHA) ? "E1_ALPHA, " : "",
+            (mode & FX_UM_E1_LUMINANCE) ? "E1_LUMINANCE, " : "",
+            (mode & FX_UM_E1_LUMINANCE_ALPHA) ? "E1_LUMINANCE_ALPHA, " : "",
+            (mode & FX_UM_E1_INTENSITY) ? "E1_INTENSITY, " : "",
+            (mode & FX_UM_E1_RGB) ? "E1_RGB, " : "",
+            (mode & FX_UM_E1_RGBA) ? "E1_RGBA, " : "",
+            (mode & FX_UM_COLOR_ITERATED) ? "COLOR_ITERATED, " : "",
+            (mode & FX_UM_COLOR_CONSTANT) ? "COLOR_CONSTANT, " : "",
+            (mode & FX_UM_ALPHA_ITERATED) ? "ALPHA_ITERATED, " : "",
+            (mode & FX_UM_ALPHA_CONSTANT) ? "ALPHA_CONSTANT, " : "");
+}
+
+static GLuint
+fxGetTexSetConfiguration(GLcontext * ctx,
+                         struct gl_texture_object *tObj0,
+                         struct gl_texture_object *tObj1)
+{
+    GLuint unitsmode = 0;
+    GLuint envmode = 0;
+    GLuint ifmt = 0;
+
+    if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 ||
+        (ctx->Point.SmoothFlag) ||
+        (ctx->Line.SmoothFlag) ||
+        (ctx->Polygon.SmoothFlag))
+        unitsmode |= FX_UM_ALPHA_ITERATED;
+    else
+        unitsmode |= FX_UM_ALPHA_CONSTANT;
+
+    if (ctx->Light.ShadeModel == GL_SMOOTH || 1)
+        unitsmode |= FX_UM_COLOR_ITERATED;
+    else
+        unitsmode |= FX_UM_COLOR_CONSTANT;
+
+
+
+    /* 
+       OpenGL Feeds Texture 0 into Texture 1
+       Glide Feeds Texture 1 into Texture 0
+     */
+    if (tObj0) {
+        tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0);
+
+        switch (ti0->baseLevelInternalFormat) {
+        case GL_ALPHA:
+            ifmt |= FX_UM_E0_ALPHA;
+            break;
+        case GL_LUMINANCE:
+            ifmt |= FX_UM_E0_LUMINANCE;
+            break;
+        case GL_LUMINANCE_ALPHA:
+            ifmt |= FX_UM_E0_LUMINANCE_ALPHA;
+            break;
+        case GL_INTENSITY:
+            ifmt |= FX_UM_E0_INTENSITY;
+            break;
+        case GL_RGB:
+            ifmt |= FX_UM_E0_RGB;
+            break;
+        case GL_RGBA:
+            ifmt |= FX_UM_E0_RGBA;
+            break;
+        }
+
+        switch (ctx->Texture.Unit[0].EnvMode) {
+        case GL_DECAL:
+            envmode |= FX_UM_E0_DECAL;
+            break;
+        case GL_MODULATE:
+            envmode |= FX_UM_E0_MODULATE;
+            break;
+        case GL_REPLACE:
+            envmode |= FX_UM_E0_REPLACE;
+            break;
+        case GL_BLEND:
+            envmode |= FX_UM_E0_BLEND;
+            break;
+        case GL_ADD:
+            envmode |= FX_UM_E0_ADD;
+            break;
+        default:
+            /* do nothing */
+            break;
+        }
+    }
+
+    if (tObj1) {
+        tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1);
+
+        switch (ti1->baseLevelInternalFormat) {
+        case GL_ALPHA:
+            ifmt |= FX_UM_E1_ALPHA;
+            break;
+        case GL_LUMINANCE:
+            ifmt |= FX_UM_E1_LUMINANCE;
+            break;
+        case GL_LUMINANCE_ALPHA:
+            ifmt |= FX_UM_E1_LUMINANCE_ALPHA;
+            break;
+        case GL_INTENSITY:
+            ifmt |= FX_UM_E1_INTENSITY;
+            break;
+        case GL_RGB:
+            ifmt |= FX_UM_E1_RGB;
+            break;
+        case GL_RGBA:
+            ifmt |= FX_UM_E1_RGBA;
+            break;
+        default:
+            /* do nothing */
+            break;
+        }
+
+        switch (ctx->Texture.Unit[1].EnvMode) {
+        case GL_DECAL:
+            envmode |= FX_UM_E1_DECAL;
+            break;
+        case GL_MODULATE:
+            envmode |= FX_UM_E1_MODULATE;
+            break;
+        case GL_REPLACE:
+            envmode |= FX_UM_E1_REPLACE;
+            break;
+        case GL_BLEND:
+            envmode |= FX_UM_E1_BLEND;
+            break;
+        case GL_ADD:
+            envmode |= FX_UM_E1_ADD;
+            break;
+        default:
+            /* do nothing */
+            break;
+        }
+    }
+
+    unitsmode |= (ifmt | envmode);
+
+    if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+        fxPrintUnitsMode("unitsmode", unitsmode);
+
+    return unitsmode;
+}
+
+/************************************************************************/
+/************************* Rendering Mode SetUp *************************/
+/************************************************************************/
+
+/************************* Single Texture Set ***************************/
+
+static void
+fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj)
+{
+    struct TdfxSharedState *shared = (struct TdfxSharedState *) fxMesa->glCtx->Shared->DriverData;
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+    const GLcontext *ctx = fxMesa->glCtx;
+
+    /* Make sure we're not loaded incorrectly */
+    if (ti->isInTM && !shared->umaTexMemory) {
+        /* if doing filtering between mipmap levels, alternate mipmap levels
+         * must be in alternate TMUs.
+         */
+        if (ti->LODblend) {
+            if (ti->whichTMU != FX_TMU_SPLIT)
+                fxTMMoveOutTM(fxMesa, tObj);
+        }
+        else {
+            if (ti->whichTMU == FX_TMU_SPLIT)
+                fxTMMoveOutTM(fxMesa, tObj);
+        }
+    }
+
+    /* Make sure we're loaded correctly */
+    if (!ti->isInTM) {
+        /* Have to download the texture */
+        if (shared->umaTexMemory) {
+           fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0);
+        }
+        else {
+           /* Voodoo3 (split texture memory) */
+           if (ti->LODblend) {
+               fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU_SPLIT);
+           }
+           else {
+               if (fxMesa->haveTwoTMUs) {
+                   GLint memReq = FX_grTexTextureMemRequired_NoLock(
+                                         GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+                   if (shared->freeTexMem[FX_TMU0] > memReq) {
+                       fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0);
+                   }
+                   else {
+                       fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU1);
+                   }
+               }
+               else
+                   fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0);
+           }
+        }
+    }
+
+    if (ti->LODblend && ti->whichTMU == FX_TMU_SPLIT) {
+        /* mipmap levels split between texture banks */
+        if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
+            if (MESA_VERBOSE & VERBOSE_DRIVER) {
+                fprintf(stderr, "fxmesa: uploading texture palette\n");
+            }
+            FX_grTexDownloadTable_NoLock(GR_TMU0, GR_TEXTABLE_PALETTE_6666_EXT,
+                                         &(ti->palette));
+            FX_grTexDownloadTable_NoLock(GR_TMU1, GR_TEXTABLE_PALETTE_6666_EXT,
+                                         &(ti->palette));
+        }
+
+        FX_grTexClampMode_NoLock(GR_TMU0, ti->sClamp, ti->tClamp);
+        FX_grTexClampMode_NoLock(GR_TMU1, ti->sClamp, ti->tClamp);
+        FX_grTexFilterMode_NoLock(GR_TMU0, ti->minFilt, ti->maxFilt);
+        FX_grTexFilterMode_NoLock(GR_TMU1, ti->minFilt, ti->maxFilt);
+        FX_grTexMipMapMode_NoLock(GR_TMU0, ti->mmMode, ti->LODblend);
+        FX_grTexMipMapMode_NoLock(GR_TMU1, ti->mmMode, ti->LODblend);
+
+        FX_grTexSource_NoLock(GR_TMU0, ti->tm[FX_TMU0]->startAddr,
+                              GR_MIPMAPLEVELMASK_ODD, &(ti->info));
+        FX_grTexSource_NoLock(GR_TMU1, ti->tm[FX_TMU1]->startAddr,
+                              GR_MIPMAPLEVELMASK_EVEN, &(ti->info));
+    }
+    else {
+        FxU32 tmu;
+
+        if (ti->whichTMU == FX_TMU_BOTH)
+            tmu = FX_TMU0;
+        else
+            tmu = ti->whichTMU;
+
+        if (shared->umaTexMemory) {
+            assert(ti->whichTMU == FX_TMU0);
+            assert(tmu == FX_TMU0);
+        }
+
+        if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
+            if (MESA_VERBOSE & VERBOSE_DRIVER) {
+                fprintf(stderr, "fxmesa: uploading texture palette\n");
+            }
+            FX_grTexDownloadTable_NoLock(tmu, GR_TEXTABLE_PALETTE_6666_EXT,
+                                         &(ti->palette));
+        }
+
+        /* KW: The alternative is to do the download to the other tmu.  If
+         * we get to this point, I think it means we are thrashing the
+         * texture memory, so perhaps it's not a good idea.  
+         */
+        if (ti->LODblend && (MESA_VERBOSE & VERBOSE_DRIVER))
+            fprintf(stderr,
+                    "fxmesa: not blending texture - only on one tmu\n");
+
+        FX_grTexClampMode_NoLock(tmu, ti->sClamp, ti->tClamp);
+        FX_grTexFilterMode_NoLock(tmu, ti->minFilt, ti->maxFilt);
+        FX_grTexMipMapMode_NoLock(tmu, ti->mmMode, FXFALSE);
+
+        if (ti->tm[tmu]) {
+           FX_grTexSource_NoLock(tmu, ti->tm[tmu]->startAddr,
+                                 GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+        }
+    }
+}
+
+static void
+fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend)
+{
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxSelectSingleTMUSrc(%d,%d)\n", tmu,
+                LODblend);
+    }
+
+    if (LODblend) {
+        FX_grTexCombine_NoLock(GR_TMU0,
+                               GR_COMBINE_FUNCTION_BLEND,
+                               GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION,
+                               GR_COMBINE_FUNCTION_BLEND,
+                               GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION,
+                               FXFALSE, FXFALSE);
+
+        if (fxMesa->haveTwoTMUs) {
+            const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+            const struct TdfxSharedState *shared = (struct TdfxSharedState *) mesaShared->DriverData;
+            int tmu;
+
+            if (shared->umaTexMemory)
+                tmu = GR_TMU0;
+            else
+                tmu = GR_TMU1;
+
+            FX_grTexCombine_NoLock(tmu,
+                                   GR_COMBINE_FUNCTION_LOCAL,
+                                   GR_COMBINE_FACTOR_NONE,
+                                   GR_COMBINE_FUNCTION_LOCAL,
+                                   GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+        }
+        fxMesa->tmuSrc = FX_TMU_SPLIT;
+    }
+    else {
+        if (tmu != FX_TMU1) {
+            FX_grTexCombine_NoLock(GR_TMU0,
+                                   GR_COMBINE_FUNCTION_LOCAL,
+                                   GR_COMBINE_FACTOR_NONE,
+                                   GR_COMBINE_FUNCTION_LOCAL,
+                                   GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+            if (fxMesa->haveTwoTMUs) {
+                FX_grTexCombine_NoLock(GR_TMU1,
+                                       GR_COMBINE_FUNCTION_ZERO,
+                                       GR_COMBINE_FACTOR_NONE,
+                                       GR_COMBINE_FUNCTION_ZERO,
+                                       GR_COMBINE_FACTOR_NONE, FXFALSE,
+                                       FXFALSE);
+            }
+            fxMesa->tmuSrc = FX_TMU0;
+        }
+        else {
+            FX_grTexCombine_NoLock(GR_TMU1,
+                                   GR_COMBINE_FUNCTION_LOCAL,
+                                   GR_COMBINE_FACTOR_NONE,
+                                   GR_COMBINE_FUNCTION_LOCAL,
+                                   GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+
+            /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */
+
+            FX_grTexCombine_NoLock(GR_TMU0,
+                                   GR_COMBINE_FUNCTION_BLEND,
+                                   GR_COMBINE_FACTOR_ONE,
+                                   GR_COMBINE_FUNCTION_BLEND,
+                                   GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE);
+
+            fxMesa->tmuSrc = FX_TMU1;
+        }
+    }
+}
+
+
+/*
+ * Setup the texture env mode for a texture unit on Banshee/Voodoo3
+ */
+static void
+SetupTexEnvVoodoo3(GLcontext *ctx, FxU32 unit, GLboolean iteratedRGBA,
+                   GLenum envMode, GLenum baseFormat)
+{
+    GrCombineLocal_t localc, locala;
+    if (iteratedRGBA)
+       localc = locala = GR_COMBINE_LOCAL_ITERATED;
+    else
+       localc = locala = GR_COMBINE_LOCAL_CONSTANT;
+
+    switch (envMode) {
+    case GL_DECAL:
+        FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                                 GR_COMBINE_FACTOR_NONE,
+                                 locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+
+        FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_BLEND,
+                                 GR_COMBINE_FACTOR_TEXTURE_ALPHA,
+                                 localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+        break;
+    case GL_MODULATE:
+        FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                 GR_COMBINE_FACTOR_LOCAL,
+                                 locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+
+        if (baseFormat == GL_ALPHA)
+            FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                                     GR_COMBINE_FACTOR_NONE,
+                                     localc, GR_COMBINE_OTHER_NONE, FXFALSE);
+        else
+            FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                     GR_COMBINE_FACTOR_LOCAL,
+                                     localc, GR_COMBINE_OTHER_TEXTURE,
+                                     FXFALSE);
+        break;
+    case GL_BLEND:
+#if 0
+        FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                 GR_COMBINE_FACTOR_LOCAL,
+                                 locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+        if (baseFormat == GL_ALPHA)
+            FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                                     GR_COMBINE_FACTOR_NONE,
+                                     localc, GR_COMBINE_OTHER_NONE, FXFALSE);
+        else
+            FX_grColorCombine_NoLock
+                (GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+                 GR_COMBINE_FACTOR_LOCAL, localc, GR_COMBINE_OTHER_TEXTURE,
+                 FXTRUE);
+        ctx->Driver.MultipassFunc = fxMultipassBlend;
+#else
+        if (MESA_VERBOSE & VERBOSE_DRIVER)
+            fprintf(stderr, "fx Driver: GL_BLEND not yet supported\n");
+#endif
+        break;
+    case GL_REPLACE:
+        if ((baseFormat == GL_RGB) || (baseFormat == GL_LUMINANCE))
+            FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                                     GR_COMBINE_FACTOR_NONE,
+                                     locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+        else
+            FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                     GR_COMBINE_FACTOR_ONE,
+                                     locala, GR_COMBINE_OTHER_TEXTURE,
+                                     FXFALSE);
+
+        if (baseFormat == GL_ALPHA)
+            FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                                     GR_COMBINE_FACTOR_NONE,
+                                     localc, GR_COMBINE_OTHER_NONE, FXFALSE);
+        else
+            FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                     GR_COMBINE_FACTOR_ONE,
+                                     localc, GR_COMBINE_OTHER_TEXTURE,
+                                     FXFALSE);
+        break;
+    case GL_ADD:
+        if (baseFormat == GL_ALPHA ||
+            baseFormat == GL_LUMINANCE_ALPHA ||
+            baseFormat == GL_RGBA) {
+            /* product of texel and fragment alpha */
+            FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                     GR_COMBINE_FACTOR_LOCAL,
+                                     locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+        }
+        else if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+            /* fragment alpha is unchanged */
+            FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                                     GR_COMBINE_FACTOR_NONE,
+                                     locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+        }
+        else {
+            ASSERT(baseFormat == GL_INTENSITY);
+            /* sum of texel and fragment alpha */
+            FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+                                     GR_COMBINE_FACTOR_ONE,
+                                     locala, GR_COMBINE_OTHER_TEXTURE,
+                                     FXFALSE);
+        }
+        if (baseFormat == GL_ALPHA) {
+            /* rgb unchanged */
+            FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                                     GR_COMBINE_FACTOR_NONE,
+                                     localc, GR_COMBINE_OTHER_NONE, FXFALSE);
+        }
+        else {
+            /* sum of texel and fragment rgb */
+            FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+                                     GR_COMBINE_FACTOR_ONE,
+                                     localc, GR_COMBINE_OTHER_TEXTURE,
+                                     FXFALSE);
+        }
+        break;
+    default:
+        gl_problem(ctx, "Bad baseFormat in SetupTexEnvVoodoo3");
+    }
+}
+
+
+/*
+ * These macros are used below when handling COMBINE_EXT.
+ */
+#define TEXENV_OPERAND_INVERTED(operand)                            \
+  (((operand) == GL_ONE_MINUS_SRC_ALPHA)                            \
+   || ((operand) == GL_ONE_MINUS_SRC_COLOR))
+#define TEXENV_OPERAND_ALPHA(operand)                               \
+  (((operand) == GL_SRC_ALPHA) || ((operand) == GL_ONE_MINUS_SRC_ALPHA))
+#define TEXENV_SETUP_ARG_A(param, source, operand, iteratedAlpha)   \
+    switch (source) {                                               \
+    case GL_TEXTURE:                                                \
+        param = GR_CMBX_LOCAL_TEXTURE_ALPHA;                        \
+        break;                                                      \
+    case GL_CONSTANT_EXT:                                           \
+        param = GR_CMBX_TMU_CALPHA;                                 \
+        break;                                                      \
+    case GL_PRIMARY_COLOR_EXT:                                      \
+        param = GR_CMBX_ITALPHA;                                    \
+        break;                                                      \
+    case GL_PREVIOUS_EXT:                                           \
+        param = iteratedAlpha;                                      \
+        break;                                                      \
+    default:                                                        \
+       /*                                                           \
+        * This is here just to keep from getting                    \
+        * compiler warnings.                                        \
+        */                                                          \
+        param = GR_CMBX_ZERO;                                       \
+        break;                                                      \
+    }
+
+#define TEXENV_SETUP_ARG_RGB(param, source, operand, iteratedColor, iteratedAlpha) \
+    if (!TEXENV_OPERAND_ALPHA(operand)) {                           \
+        switch (source) {                                           \
+        case GL_TEXTURE:                                            \
+            param = GR_CMBX_LOCAL_TEXTURE_RGB;                      \
+            break;                                                  \
+        case GL_CONSTANT_EXT:                                       \
+            param = GR_CMBX_TMU_CCOLOR;                             \
+            break;                                                  \
+        case GL_PRIMARY_COLOR_EXT:                                  \
+            param = GR_CMBX_ITRGB;                                  \
+            break;                                                  \
+        case GL_PREVIOUS_EXT:                                       \
+            param = iteratedColor;                                  \
+            break;                                                  \
+        default:                                                    \
+           /*                                                       \
+            * This is here just to keep from getting                \
+            * compiler warnings.                                    \
+            */                                                      \
+            param = GR_CMBX_ZERO;                                   \
+            break;                                                  \
+        }                                                           \
+    } else {                                                        \
+        switch (source) {                                           \
+        case GL_TEXTURE:                                            \
+            param = GR_CMBX_LOCAL_TEXTURE_ALPHA;                    \
+            break;                                                  \
+        case GL_CONSTANT_EXT:                                       \
+            param = GR_CMBX_TMU_CALPHA;                             \
+            break;                                                  \
+        case GL_PRIMARY_COLOR_EXT:                                  \
+            param = GR_CMBX_ITALPHA;                                \
+            break;                                                  \
+        case GL_PREVIOUS_EXT:                                       \
+            param = iteratedAlpha;                                  \
+            break;                                                  \
+        default:                                                    \
+           /*                                                       \
+            * This is here just to keep from getting                \
+            * compiler warnings.                                    \
+            */                                                      \
+            param = GR_CMBX_ZERO;                                   \
+            break;                                                  \
+        }                                                           \
+    }
+
+#define TEXENV_SETUP_MODE_RGB(param, operand)                       \
+    switch (operand) {                                              \
+    case GL_SRC_COLOR:                                              \
+    case GL_SRC_ALPHA:                                              \
+        param = GR_FUNC_MODE_X;                                     \
+        break;                                                      \
+    case GL_ONE_MINUS_SRC_ALPHA:                                    \
+    case GL_ONE_MINUS_SRC_COLOR:                                    \
+        param = GR_FUNC_MODE_ONE_MINUS_X;                           \
+        break;                                                      \
+    default:                                                        \
+        param = GR_FUNC_MODE_ZERO;                                  \
+        break;                                                      \
+    }
+
+#define TEXENV_SETUP_MODE_A(param, operand)                         \
+    switch (operand) {                                              \
+    case GL_SRC_ALPHA:                                              \
+        param = GR_FUNC_MODE_X;                                     \
+        break;                                                      \
+    case GL_ONE_MINUS_SRC_ALPHA:                                    \
+        param = GR_FUNC_MODE_ONE_MINUS_X;                           \
+        break;                                                      \
+    default:                                                        \
+        param = GR_FUNC_MODE_ZERO;                                  \
+        break;                                                      \
+    }
+
+/*
+ * Setup the texture env mode for a texture unit on Napalm.
+ * If useIteratedRGBA is true, we'll feed the interpolated fragment
+ * color into the combiner, else we'll feed in the upstream texture
+ * unit's resultant color.
+ */
+static void
+SetupTexEnvNapalm(GLcontext *ctx, FxU32 unit, GLboolean useIteratedRGBA,
+                  struct gl_texture_unit *texUnit, GLenum baseFormat)
+{
+    GrTCCUColor_t incomingRGB, incomingAlpha;
+    GLenum envMode = texUnit->EnvMode;
+
+    if (useIteratedRGBA) {
+        incomingRGB = GR_CMBX_ITRGB;
+        incomingAlpha = GR_CMBX_ITALPHA;
+    }
+    else {
+        incomingRGB = GR_CMBX_OTHER_TEXTURE_RGB;
+        incomingAlpha = GR_CMBX_OTHER_TEXTURE_ALPHA;
+    }
+
+    switch (envMode) {
+    case GL_REPLACE:
+        /* Setup RGB combiner */
+        if (baseFormat == GL_ALPHA) {
+            /* Rv = Rf */
+             (*grTexColorCombineExtPtr)(unit,
+                                        incomingRGB, GR_FUNC_MODE_X,
+                                        GR_CMBX_ZERO, GR_FUNC_MODE_ZERO,
+                                        GR_CMBX_ZERO, FXTRUE,
+                                        GR_CMBX_ZERO, FXFALSE,
+                                        0, FXFALSE);
+        }
+        else {
+            /* Rv = Rt */
+            (*grTexColorCombineExtPtr)(unit,
+                                     GR_CMBX_LOCAL_TEXTURE_RGB, GR_FUNC_MODE_X,
+                                     GR_CMBX_ZERO, GR_FUNC_MODE_X,
+                                     GR_CMBX_ZERO, FXTRUE,
+                                     GR_CMBX_ZERO, FXFALSE,
+                                     0, FXFALSE);
+        }
+        /* Setup Alpha combiner */
+        if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+            /* Av = Af */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                       GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ZERO, FXFALSE,
+                                       incomingAlpha, FXFALSE,
+                                       0, FXFALSE);
+        }
+        else {
+            /* Av = At */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                       GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ZERO, FXFALSE,
+                                       GR_CMBX_LOCAL_TEXTURE_ALPHA, FXFALSE,
+                                       0, FXFALSE);
+        }
+        break;
+    case GL_MODULATE:
+        /* Setup RGB combiner */
+        if (baseFormat == GL_ALPHA) {
+            /* Rv = Rf */
+            (*grTexColorCombineExtPtr)(unit,
+                                       incomingRGB, GR_FUNC_MODE_X,
+                                       GR_CMBX_ZERO, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ZERO, FXTRUE,
+                                       GR_CMBX_ZERO, FXFALSE,
+                                       0, FXFALSE);
+        }
+        else {
+            /* Result = Frag * Tex */
+            (*grTexColorCombineExtPtr)(unit,
+                                       incomingRGB, GR_FUNC_MODE_X,
+                                       GR_CMBX_ZERO, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_LOCAL_TEXTURE_RGB, FXFALSE,
+                                       GR_CMBX_ZERO, FXFALSE,
+                                       0, FXFALSE);
+        }
+        /* Setup Alpha combiner */
+        if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+            /* Av = Af */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                       incomingAlpha, GR_FUNC_MODE_X,
+                                       GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ZERO, FXTRUE,
+                                       GR_CMBX_ZERO, FXFALSE,
+                                       0, FXFALSE);
+        }
+        else {
+            /* Av = Af * At */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                   GR_CMBX_LOCAL_TEXTURE_ALPHA, GR_FUNC_MODE_X,
+                                   GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                   incomingAlpha, FXFALSE,
+                                   GR_CMBX_ZERO, FXFALSE,
+                                   0, FXFALSE);
+        }
+        break;
+    case GL_DECAL:
+        /* Setup RGB combiner */
+        if (baseFormat == GL_RGB) {
+            /* Rv = Rt */
+            (*grTexColorCombineExtPtr)(unit,
+                                     GR_CMBX_LOCAL_TEXTURE_RGB, GR_FUNC_MODE_X,
+                                     GR_CMBX_ZERO, GR_FUNC_MODE_X,
+                                     GR_CMBX_ZERO, FXTRUE,
+                                     GR_CMBX_ZERO, FXFALSE,
+                                     0, FXFALSE);
+        }
+        else {
+            /* Rv = Rf * (1 - At) + Rt * At */
+            (*grTexColorCombineExtPtr)(unit,
+                                    GR_CMBX_LOCAL_TEXTURE_RGB, GR_FUNC_MODE_X,
+                                    incomingRGB, GR_FUNC_MODE_NEGATIVE_X,
+                                    GR_CMBX_LOCAL_TEXTURE_ALPHA, FXFALSE,
+                                    GR_CMBX_B, FXFALSE,
+                                    0, FXFALSE);
+        }
+        /* Setup Alpha combiner */
+        /* Av = Af */
+        (*grTexAlphaCombineExtPtr)(unit,
+                                   incomingAlpha, GR_FUNC_MODE_X,
+                                   GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                   GR_CMBX_ZERO, FXTRUE,
+                                   GR_CMBX_ZERO, FXFALSE,
+                                   0, FXFALSE);
+        break;
+    case GL_BLEND:
+        /* Setup RGB combiner */
+        if (baseFormat == GL_ALPHA) {
+            /* Rv = Rf */
+            (*grTexColorCombineExtPtr)(unit,
+                                       incomingRGB, GR_FUNC_MODE_X,
+                                       GR_CMBX_ZERO, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ZERO, FXTRUE,
+                                       GR_CMBX_ZERO, FXFALSE,
+                                       0, FXFALSE);
+        }
+        else {
+            /* Rv = Rf * (1 - Rt) + Rc * Rt */
+            (*grTexColorCombineExtPtr)(unit,
+                                       GR_CMBX_TMU_CCOLOR, GR_FUNC_MODE_X,
+                                       incomingRGB, GR_FUNC_MODE_NEGATIVE_X,
+                                       GR_CMBX_LOCAL_TEXTURE_RGB, FXFALSE,
+                                       GR_CMBX_B, FXFALSE,
+                                       0, FXFALSE);
+        }
+        /* Setup Alpha combiner */
+        if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+            /* Av = Af */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                       incomingAlpha, GR_FUNC_MODE_X,
+                                       GR_CMBX_ZERO, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ZERO, FXTRUE,
+                                       GR_CMBX_ZERO, FXFALSE,
+                                       0, FXFALSE);
+        }
+        else if (baseFormat == GL_INTENSITY) {
+            /* Av = Af * (1 - It) + Ac * It */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                      GR_CMBX_TMU_CALPHA, GR_FUNC_MODE_X,
+                                      incomingAlpha, GR_FUNC_MODE_NEGATIVE_X,
+                                      GR_CMBX_LOCAL_TEXTURE_ALPHA, FXFALSE,
+                                      GR_CMBX_B, FXFALSE,
+                                      0, FXFALSE);
+        }
+        else {
+            /* Av = Af * At */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                   GR_CMBX_LOCAL_TEXTURE_ALPHA, GR_FUNC_MODE_X,
+                                   GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                   incomingAlpha, FXFALSE,
+                                   GR_CMBX_ZERO, FXFALSE,
+                                   0, FXFALSE);
+        }
+        /* Also have to set up the tex env constant color */
+        {
+            GrColor_t constColor;
+            GLubyte *abgr = (GLubyte *) &constColor;
+            abgr[0] = ctx->Texture.Unit[0].EnvColor[0] * 255.0F;
+            abgr[1] = ctx->Texture.Unit[0].EnvColor[1] * 255.0F;
+            abgr[2] = ctx->Texture.Unit[0].EnvColor[2] * 255.0F;
+            abgr[3] = ctx->Texture.Unit[0].EnvColor[3] * 255.0F;
+            (*grConstantColorValueExtPtr)(unit, constColor);
+        }
+        break;
+    case GL_ADD:
+        /* Setup RGB combiner */
+        if (baseFormat == GL_ALPHA) {
+            /* Rv = Rf */
+            (*grTexColorCombineExtPtr)(unit,
+                                       incomingRGB, GR_FUNC_MODE_X,
+                                       GR_CMBX_ZERO, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ZERO, FXTRUE,
+                                       GR_CMBX_ZERO, FXFALSE,
+                                       0, FXFALSE);
+        }
+        else {
+            /* Rv = Rf + Tt */
+            (*grTexColorCombineExtPtr)(unit,
+                                     incomingRGB, GR_FUNC_MODE_X,
+                                     GR_CMBX_LOCAL_TEXTURE_RGB, GR_FUNC_MODE_X,
+                                     GR_CMBX_ZERO, FXTRUE,
+                                     GR_CMBX_ZERO, FXFALSE,
+                                     0, FXFALSE);
+        }
+        /* Setup Alpha combiner */
+        if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+            /* Av = Af */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                       incomingAlpha, GR_FUNC_MODE_X,
+                                       GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                       GR_CMBX_ZERO, FXTRUE,
+                                       GR_CMBX_ZERO, FXFALSE,
+                                       0, FXFALSE);
+        }
+        else if (baseFormat == GL_INTENSITY) {
+            /* Av = Af + It */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                   incomingAlpha, GR_FUNC_MODE_X,
+                                   GR_CMBX_LOCAL_TEXTURE_ALPHA, GR_FUNC_MODE_X,
+                                   GR_CMBX_ZERO, FXTRUE,
+                                   GR_CMBX_ZERO, FXFALSE,
+                                   0, FXFALSE);
+        }
+        else {
+            /* Av = Af * At */
+            (*grTexAlphaCombineExtPtr)(unit,
+                                   GR_CMBX_LOCAL_TEXTURE_ALPHA, GR_FUNC_MODE_X,
+                                   GR_CMBX_ITALPHA, GR_FUNC_MODE_ZERO,
+                                   incomingAlpha, FXFALSE,
+                                   GR_CMBX_ZERO, FXFALSE,
+                                   0, FXFALSE);
+        }
+        break;
+    case GL_COMBINE_EXT:
+        {
+            FxU32 A_RGB, B_RGB, C_RGB, D_RGB;
+            FxU32 Amode_RGB, Bmode_RGB;
+            FxBool Cinv_RGB, Dinv_RGB, Ginv_RGB;
+            FxU32 Shift_RGB;
+            FxU32 A_A, B_A, C_A, D_A;
+            FxU32 Amode_A, Bmode_A;
+            FxBool Cinv_A, Dinv_A, Ginv_A;
+            FxU32 Shift_A;
+           /*
+            *
+            * In the formulas below, we write:
+            *  o "1(x)" for the identity function applied to x,
+            *    so 1(x) = x.
+            *  o "0(x)" for the constant function 0, so
+            *    0(x) = 0 for all values of x.
+            *
+            * Calculate the color combination.
+            */
+            Shift_RGB = texUnit->CombineScaleShiftRGB;
+            Shift_A = texUnit->CombineScaleShiftA;
+            switch (texUnit->CombineModeRGB) {
+            case GL_REPLACE:
+               /*
+                * The formula is: Arg0
+                * We implement this by the formula:
+                *   (Arg0 + 0(0))*(1-0) + 0
+                */
+                TEXENV_SETUP_ARG_RGB(A_RGB,
+                                     texUnit->CombineSourceRGB[0],
+                                     texUnit->CombineOperandRGB[0],
+                                     incomingRGB, incomingAlpha);
+                TEXENV_SETUP_MODE_RGB(Amode_RGB,
+                                      texUnit->CombineOperandRGB[0]);
+                B_RGB = C_RGB = D_RGB = GR_CMBX_ZERO;
+                Bmode_RGB = GR_FUNC_MODE_ZERO;
+                Cinv_RGB = FXTRUE;
+                Dinv_RGB = Ginv_RGB = FXFALSE;
+                break;
+            case GL_MODULATE:
+               /*
+                * The formula is: Arg0 * Arg1
+                *
+                * We implement this by the formula
+                *   (Arg0 + 0(0)) * Arg1 + 0(0)
+                */
+                TEXENV_SETUP_ARG_RGB(A_RGB,
+                                     texUnit->CombineSourceRGB[0],
+                                     texUnit->CombineOperandRGB[0],
+                                     incomingRGB, incomingAlpha);
+                TEXENV_SETUP_MODE_RGB(Amode_RGB,
+                                      texUnit->CombineOperandRGB[0]);
+                B_RGB = GR_CMBX_ZERO;
+                Bmode_RGB = GR_CMBX_ZERO;
+                TEXENV_SETUP_ARG_RGB(C_RGB,
+                                     texUnit->CombineSourceRGB[1],
+                                     texUnit->CombineOperandRGB[1],
+                                     incomingRGB, incomingAlpha);
+                Cinv_RGB = TEXENV_OPERAND_INVERTED
+                               (texUnit->CombineOperandRGB[1]);
+                D_RGB = GR_CMBX_ZERO;
+                Dinv_RGB = Ginv_RGB = FXFALSE;
+                break;
+            case GL_ADD:
+               /*
+                * The formula is Arg0 + Arg1
+                */
+                TEXENV_SETUP_ARG_RGB(A_RGB,
+                                     texUnit->CombineSourceRGB[0],
+                                     texUnit->CombineOperandRGB[0],
+                                     incomingRGB, incomingAlpha);
+                TEXENV_SETUP_MODE_RGB(Amode_RGB,
+                                      texUnit->CombineOperandRGB[0]);
+                TEXENV_SETUP_ARG_RGB(B_RGB,
+                                     texUnit->CombineSourceRGB[1],
+                                     texUnit->CombineOperandRGB[1],
+                                     incomingRGB, incomingAlpha);
+                TEXENV_SETUP_MODE_RGB(Bmode_RGB,
+                                      texUnit->CombineOperandRGB[1]);
+                C_RGB = D_RGB = GR_CMBX_ZERO;
+                Cinv_RGB = FXTRUE;
+                Dinv_RGB = Ginv_RGB = FXFALSE;
+                break;
+            case GL_ADD_SIGNED_EXT:
+               /*
+                * The formula is: Arg0 + Arg1 - 0.5.
+                * We compute this by calculating:
+                *      (Arg0 - 1/2) + Arg1         if op0 is SRC_{COLOR,ALPHA}
+                *      Arg0 + (Arg1 - 1/2)         if op1 is SRC_{COLOR,ALPHA}
+                * If both op0 and op1 are ONE_MINUS_SRC_{COLOR,ALPHA}
+                * we cannot implement the formula properly.
+                */
+                TEXENV_SETUP_ARG_RGB(A_RGB,
+                                     texUnit->CombineSourceRGB[0],
+                                     texUnit->CombineOperandRGB[0],
+                                     incomingRGB, incomingAlpha);
+                TEXENV_SETUP_ARG_RGB(B_RGB,
+                                     texUnit->CombineSourceRGB[1],
+                                     texUnit->CombineOperandRGB[1],
+                                     incomingRGB, incomingAlpha);
+                if (!TEXENV_OPERAND_INVERTED(texUnit->CombineOperandRGB[0])) {
+                   /*
+                    * A is not inverted.  So, choose it.
+                    */
+                    Amode_RGB = GR_FUNC_MODE_X_MINUS_HALF;
+                    if (!TEXENV_OPERAND_INVERTED
+                            (texUnit->CombineOperandRGB[1])) {
+                        Bmode_RGB = GR_FUNC_MODE_X;
+                    } else {
+                        Bmode_RGB = GR_FUNC_MODE_ONE_MINUS_X;
+                    }
+                } else {
+                   /*
+                    * A is inverted, so try to subtract 1/2
+                    * from B.
+                    */
+                    Amode_RGB = GR_FUNC_MODE_ONE_MINUS_X;
+                    if (!TEXENV_OPERAND_INVERTED
+                            (texUnit->CombineOperandRGB[1])) {
+                        Bmode_RGB = GR_FUNC_MODE_X_MINUS_HALF;
+                    } else {
+                       /*
+                        * Both are inverted.  This is the case
+                        * we cannot handle properly.  We just
+                        * choose to not add the - 1/2.
+                        */
+                        Bmode_RGB = GR_FUNC_MODE_ONE_MINUS_X;
+                    }
+                }
+                C_RGB = D_RGB = GR_CMBX_ZERO;
+                Cinv_RGB = FXTRUE;
+                Dinv_RGB = Ginv_RGB = FXFALSE;
+                break;
+            case GL_INTERPOLATE_EXT:
+               /*
+                * The formula is: Arg0 * Arg2 + Arg1 * (1 - Arg2).
+                * We compute this by the formula:
+                *            (Arg0 - Arg1) * Arg2 + Arg1
+                *               == Arg0 * Arg2 - Arg1 * Arg2 + Arg1
+                *               == Arg0 * Arg2 + Arg1 * (1 - Arg2)
+                * However, if both Arg1 is ONE_MINUS_X, the HW does
+                * not support it properly.
+                */
+                TEXENV_SETUP_ARG_RGB(A_RGB,
+                                     texUnit->CombineSourceRGB[0],
+                                     texUnit->CombineOperandRGB[0],
+                                     incomingRGB, incomingAlpha);
+                TEXENV_SETUP_MODE_RGB(Amode_RGB,
+                                      texUnit->CombineOperandRGB[0]);
+                TEXENV_SETUP_ARG_RGB(B_RGB,
+                                     texUnit->CombineSourceRGB[1],
+                                     texUnit->CombineOperandRGB[1],
+                                     incomingRGB, incomingAlpha);
+                if (!TEXENV_OPERAND_INVERTED(texUnit->CombineOperandRGB[1])) {
+                    Bmode_RGB = GR_FUNC_MODE_NEGATIVE_X;
+                } else {
+                   /*
+                    * This case is wrong.
+                    */
+                    Bmode_RGB = GR_FUNC_MODE_NEGATIVE_X;
+                }
+               /*
+                * The Source/Operand for the C value must
+                * specify some kind of alpha value.
+                */
+                TEXENV_SETUP_ARG_A(C_RGB,
+                                   texUnit->CombineSourceRGB[2],
+                                   texUnit->CombineOperandRGB[2],
+                                   incomingAlpha);
+                Cinv_RGB = FXFALSE;
+                D_RGB = GR_CMBX_B;
+                Dinv_RGB = Ginv_RGB = FXFALSE;
+                break;
+            default:
+               /*
+                * This is here mostly to keep from getting
+                * a compiler warning about these not being set.
+                * However, this should set all the texture values
+                * to zero.
+                */
+                A_RGB = B_RGB = C_RGB = D_RGB = GR_CMBX_ZERO;
+                Amode_RGB = Bmode_RGB = GR_FUNC_MODE_X;
+                Cinv_RGB = Dinv_RGB = Ginv_RGB = FXFALSE;
+                break;
+            }
+           /*
+            * Calculate the alpha combination.
+            */
+            switch (texUnit->CombineModeA) {
+            case GL_REPLACE:
+               /*
+                * The formula is: Arg0
+                * We implement this by the formula:
+                *   (Arg0 + 0(0))*(1-0) + 0
+                */
+                TEXENV_SETUP_ARG_A(A_A,
+                                   texUnit->CombineSourceA[0],
+                                   texUnit->CombineOperandA[0],
+                                   incomingAlpha);
+                TEXENV_SETUP_MODE_A(Amode_A,
+                                    texUnit->CombineOperandA[0]);
+                B_A = C_A = D_A = GR_CMBX_ZERO;
+                Bmode_A = GR_FUNC_MODE_ZERO;
+                Cinv_A = FXTRUE;
+                Dinv_A = Ginv_A = FXFALSE;
+                break;
+            case GL_MODULATE:
+               /*
+                * The formula is: Arg0 * Arg1
+                *
+                * We implement this by the formula
+                *   (Arg0 + 0(0)) * Arg1 + 0(0)
+                */
+                TEXENV_SETUP_ARG_A(A_A,
+                                   texUnit->CombineSourceA[0],
+                                   texUnit->CombineOperandA[0],
+                                   incomingAlpha);
+                TEXENV_SETUP_MODE_A(Amode_A,
+                                    texUnit->CombineOperandA[0]);
+                B_A = GR_CMBX_ZERO;
+                Bmode_A = GR_CMBX_ZERO;
+                TEXENV_SETUP_ARG_A(C_A,
+                                   texUnit->CombineSourceA[1],
+                                   texUnit->CombineOperandA[1],
+                                   incomingAlpha);
+                Cinv_A = TEXENV_OPERAND_INVERTED
+                               (texUnit->CombineOperandA[1]);
+                D_A = GR_CMBX_ZERO;
+                Dinv_A = Ginv_A = FXFALSE;
+                break;
+            case GL_ADD:
+               /*
+                * The formula is Arg0 + Arg1
+                */
+                TEXENV_SETUP_ARG_A(A_A,
+                                   texUnit->CombineSourceA[0],
+                                   texUnit->CombineOperandA[0],
+                                   incomingAlpha);
+                TEXENV_SETUP_MODE_A(Amode_A,
+                                    texUnit->CombineOperandA[0]);
+                TEXENV_SETUP_ARG_A(B_A,
+                                   texUnit->CombineSourceA[1],
+                                   texUnit->CombineOperandA[1],
+                                   incomingAlpha);
+                TEXENV_SETUP_MODE_A(Bmode_A,
+                                    texUnit->CombineOperandA[0]);
+                C_A = D_A = GR_CMBX_ZERO;
+                Cinv_A = FXTRUE;
+                Dinv_A = Ginv_A = FXFALSE;
+                break;
+            case GL_ADD_SIGNED_EXT:
+               /*
+                * The formula is: Arg0 + Arg1 - 0.5.
+                * We compute this by calculating:
+                *      (Arg0 - 1/2) + Arg1         if op0 is SRC_{COLOR,ALPHA}
+                *      Arg0 + (Arg1 - 1/2)         if op1 is SRC_{COLOR,ALPHA}
+                * If both op0 and op1 are ONE_MINUS_SRC_{COLOR,ALPHA}
+                * we cannot implement the formula properly.
+                */
+                TEXENV_SETUP_ARG_A(A_A,
+                                   texUnit->CombineSourceA[0],
+                                   texUnit->CombineOperandA[0],
+                                   incomingAlpha);
+                TEXENV_SETUP_ARG_A(B_A,
+                                   texUnit->CombineSourceA[1],
+                                   texUnit->CombineOperandA[1],
+                                   incomingAlpha);
+                if (!TEXENV_OPERAND_INVERTED(texUnit->CombineOperandA[0])) {
+                   /*
+                    * A is not inverted.  So, choose it.
+                    */
+                    Amode_A = GR_FUNC_MODE_X_MINUS_HALF;
+                    if (!TEXENV_OPERAND_INVERTED
+                            (texUnit->CombineOperandA[1])) {
+                        Bmode_A = GR_FUNC_MODE_X;
+                    } else {
+                        Bmode_A = GR_FUNC_MODE_ONE_MINUS_X;
+                    }
+                } else {
+                   /*
+                    * A is inverted, so try to subtract 1/2
+                    * from B.
+                    */
+                    Amode_A = GR_FUNC_MODE_ONE_MINUS_X;
+                    if (!TEXENV_OPERAND_INVERTED
+                            (texUnit->CombineOperandA[1])) {
+                        Bmode_A = GR_FUNC_MODE_X_MINUS_HALF;
+                    } else {
+                       /*
+                        * Both are inverted.  This is the case
+                        * we cannot handle properly.  We just
+                        * choose to not add the - 1/2.
+                        */
+                        Bmode_A = GR_FUNC_MODE_ONE_MINUS_X;
+                    }
+                }
+                C_A = D_A = GR_CMBX_ZERO;
+                Cinv_A = FXTRUE;
+                Dinv_A = Ginv_A = FXFALSE;
+                break;
+            case GL_INTERPOLATE_EXT:
+               /*
+                * The formula is: Arg0 * Arg2 + Arg1 * (1 - Arg2).
+                * We compute this by the formula:
+                *            (Arg0 - Arg1) * Arg2 + Arg1
+                *               == Arg0 * Arg2 - Arg1 * Arg2 + Arg1
+                *               == Arg0 * Arg2 + Arg1 * (1 - Arg2)
+                * However, if both Arg1 is ONE_MINUS_X, the HW does
+                * not support it properly.
+                */
+                TEXENV_SETUP_ARG_A(A_A,
+                                   texUnit->CombineSourceA[0],
+                                   texUnit->CombineOperandA[0],
+                                   incomingAlpha);
+                TEXENV_SETUP_MODE_A(Amode_A,
+                                    texUnit->CombineOperandA[0]);
+                TEXENV_SETUP_ARG_A(B_A,
+                                   texUnit->CombineSourceA[1],
+                                   texUnit->CombineOperandA[1],
+                                   incomingAlpha);
+                if (!TEXENV_OPERAND_INVERTED(texUnit->CombineOperandA[1])) {
+                    Bmode_A = GR_FUNC_MODE_NEGATIVE_X;
+                } else {
+                   /*
+                    * This case is wrong.
+                    */
+                    Bmode_A = GR_FUNC_MODE_NEGATIVE_X;
+                }
+               /*
+                * The Source/Operand for the C value must
+                * specify some kind of alpha value.
+                */
+                TEXENV_SETUP_ARG_A(C_A,
+                                   texUnit->CombineSourceA[2],
+                                   texUnit->CombineOperandA[2],
+                                   incomingAlpha);
+                Cinv_A = FXFALSE;
+                D_A = GR_CMBX_ZERO;
+                Dinv_A = Ginv_A = FXFALSE;
+                break;
+            default:
+               /*
+                * This is here mostly to keep from getting
+                * a compiler warning about these not being set.
+                * However, this should set all the alpha values
+                * to one.
+                */
+                A_A = B_A = C_A = D_A = GR_CMBX_ZERO;
+                Amode_A = Bmode_A = GR_FUNC_MODE_X;
+                Cinv_A = Dinv_A = FXFALSE;
+                Ginv_A = FXTRUE;
+                break;
+            }
+           /*
+            * Call the functions.
+            */
+            (*grTexColorCombineExtPtr)(unit,
+                                       A_RGB, Amode_RGB,
+                                       B_RGB, Bmode_RGB,
+                                       C_RGB, Cinv_RGB,
+                                       D_RGB, Dinv_RGB,
+                                       Shift_RGB, Ginv_RGB);
+            (*grTexAlphaCombineExtPtr)(unit,
+                                       A_A, Amode_A,
+                                       B_A, Bmode_A,
+                                       C_A, Cinv_A,
+                                       D_A, Dinv_A,
+                                       Shift_A, Ginv_A);
+        }
+    break;
+    default:
+        gl_problem(ctx, "Bad baseFormat in SetupTexEnvNapalm");
+    }
+
+    /* setup Color and Alpha combine always the same */
+    (*grColorCombineExtPtr)(GR_CMBX_TEXTURE_RGB, GR_FUNC_MODE_X, 
+                            GR_CMBX_ZERO, GR_FUNC_MODE_X, 
+                            GR_CMBX_ZERO, FXTRUE,
+                            GR_CMBX_ZERO, FXFALSE,
+                            0, FXFALSE);
+    (*grAlphaCombineExtPtr)(GR_CMBX_TEXTURE_ALPHA, GR_FUNC_MODE_X, 
+                            GR_CMBX_ZERO, GR_FUNC_MODE_X, 
+                            GR_CMBX_ZERO, FXTRUE,
+                            GR_CMBX_ZERO, FXFALSE,
+                            0, FXFALSE);
+}
+
+
+static void
+fxSetupTextureSingleTMU_NoLock(GLcontext * ctx, GLuint textureset)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint unitsmode;
+    GLint ifmt;
+    tfxTexInfo *ti;
+    struct gl_texture_object *tObj =
+        ctx->Texture.Unit[textureset].CurrentD[2];
+    int tmu;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxSetupTextureSingleTMU(...) Start\n");
+    }
+
+    ti = fxTMGetTexInfo(tObj);
+    fxTexValidate(ctx, tObj);
+
+    fxSetupSingleTMU_NoLock(fxMesa, tObj);
+
+    if (ti->whichTMU == FX_TMU_BOTH)
+        tmu = FX_TMU0;
+    else
+        tmu = ti->whichTMU;
+
+    if (fxMesa->tmuSrc != tmu)
+        fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend);
+
+    fxMesa->stw_hint_state = 0;
+    FX_grHints_NoLock(GR_HINT_STWHINT, 0);
+
+    ifmt = ti->baseLevelInternalFormat;
+
+    if (/*0*/fxMesa->isNapalm) {
+        SetupTexEnvNapalm(ctx, tmu, GL_TRUE,
+                          &(ctx->Texture.Unit[textureset]),
+                          ti->baseLevelInternalFormat);
+    }
+    else {
+        GLboolean iteratedRGBA = GL_FALSE;
+        if (textureset == 0 || !fxMesa->haveTwoTMUs)
+            unitsmode = fxGetTexSetConfiguration(ctx, tObj, NULL);
+        else
+            unitsmode = fxGetTexSetConfiguration(ctx, NULL, tObj);
+        if ((unitsmode & FX_UM_ALPHA_ITERATED) ||
+            (unitsmode & FX_UM_COLOR_ITERATED)) {
+            iteratedRGBA = GL_TRUE;
+        }
+        SetupTexEnvVoodoo3(ctx, tmu, iteratedRGBA,
+                           ctx->Texture.Unit[textureset].EnvMode,
+                           ti->baseLevelInternalFormat);
+    }
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxSetupTextureSingleTMU(...) End\n");
+    }
+}
+
+
+static void
+fxSetupTextureSingleTMU(GLcontext * ctx, GLuint textureset)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    BEGIN_BOARD_LOCK(fxMesa);
+    fxSetupTextureSingleTMU_NoLock(ctx, textureset);
+    END_BOARD_LOCK(fxMesa);
+}
+
+/************************* Double Texture Set ***************************/
+
+static void
+fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
+                        struct gl_texture_object *tObj0,
+                        struct gl_texture_object *tObj1)
+{
+#define T0_NOT_IN_TMU  0x01
+#define T1_NOT_IN_TMU  0x02
+#define T0_IN_TMU0     0x04
+#define T1_IN_TMU0     0x08
+#define T0_IN_TMU1     0x10
+#define T1_IN_TMU1     0x20
+
+    const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+    const struct TdfxSharedState *shared = (struct TdfxSharedState *) mesaShared->DriverData;
+    const GLcontext *ctx = fxMesa->glCtx;
+    tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0);
+    tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1);
+    GLuint tstate = 0;
+    int tmu0 = 0, tmu1 = 1;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxSetupDoubleTMU(...)\n");
+    }
+
+    /* We shouldn't need to do this. There is something wrong with
+       mutlitexturing when the TMUs are swapped. So, we're forcing
+       them to always be loaded correctly. !!! */
+    if (ti0->whichTMU == FX_TMU1)
+        fxTMMoveOutTM_NoLock(fxMesa, tObj0);
+    if (ti1->whichTMU == FX_TMU0)
+        fxTMMoveOutTM_NoLock(fxMesa, tObj1);
+
+    if (ti0->isInTM) {
+        switch (ti0->whichTMU) {
+        case FX_TMU0:
+            tstate |= T0_IN_TMU0;
+            break;
+        case FX_TMU1:
+            tstate |= T0_IN_TMU1;
+            break;
+        case FX_TMU_BOTH:
+            tstate |= T0_IN_TMU0 | T0_IN_TMU1;
+            break;
+        case FX_TMU_SPLIT:
+            tstate |= T0_NOT_IN_TMU;
+            break;
+        }
+    }
+    else
+        tstate |= T0_NOT_IN_TMU;
+
+    if (ti1->isInTM) {
+        switch (ti1->whichTMU) {
+        case FX_TMU0:
+            tstate |= T1_IN_TMU0;
+            break;
+        case FX_TMU1:
+            tstate |= T1_IN_TMU1;
+            break;
+        case FX_TMU_BOTH:
+            tstate |= T1_IN_TMU0 | T1_IN_TMU1;
+            break;
+        case FX_TMU_SPLIT:
+            tstate |= T1_NOT_IN_TMU;
+            break;
+        }
+    }
+    else
+        tstate |= T1_NOT_IN_TMU;
+
+    ti0->lastTimeUsed = fxMesa->texBindNumber;
+    ti1->lastTimeUsed = fxMesa->texBindNumber;
+
+    /* Move texture maps into TMUs */
+
+    if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) ||
+          ((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) {
+        if (tObj0 == tObj1) {
+            if (shared->umaTexMemory)
+               fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0);
+            else
+               fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU_BOTH);
+        }
+        else {
+            /* Find the minimal way to correct the situation */
+            if ((tstate & T0_IN_TMU0) || (tstate & T1_IN_TMU1)) {
+                /* We have one in the standard order, setup the other */
+                if (tstate & T0_IN_TMU0) { /* T0 is in TMU0, put T1 in TMU1 */
+                    if (shared->umaTexMemory)
+                        fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0);
+                    else
+                        fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
+                }
+                else {
+                    fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
+                }
+                /* tmu0 and tmu1 are setup */
+            }
+            else if ((tstate & T0_IN_TMU1) || (tstate & T1_IN_TMU0)) {
+                /* we have one in the reverse order, setup the other */
+                if (tstate & T1_IN_TMU0) { /* T1 is in TMU0, put T0 in TMU1 */
+                    if (shared->umaTexMemory)
+                        fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
+                    else
+                        fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU1);
+                }
+                else {
+                    fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0);
+                }
+                tmu0 = 1;
+                tmu1 = 0;
+            }
+            else {              /* Nothing is loaded */
+                fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
+                if (shared->umaTexMemory)
+                    fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0);
+                else
+                    fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
+                /* tmu0 and tmu1 are setup */
+            }
+        }
+    }
+
+    if (!ctx->Texture.SharedPalette) {
+        if (ti0->info.format == GR_TEXFMT_P_8) {
+            if (MESA_VERBOSE & VERBOSE_DRIVER) {
+                fprintf(stderr, "fxmesa: uploading texture palette TMU0\n");
+            }
+            FX_grTexDownloadTable_NoLock(tmu0, GR_TEXTABLE_PALETTE_6666_EXT,
+                                         &(ti0->palette));
+        }
+
+        if (ti1->info.format == GR_TEXFMT_P_8) {
+            if (MESA_VERBOSE & VERBOSE_DRIVER) {
+                fprintf(stderr, "fxmesa: uploading texture palette TMU1\n");
+            }
+            FX_grTexDownloadTable_NoLock(tmu1, GR_TEXTABLE_PALETTE_6666_EXT,
+                                         &(ti1->palette));
+        }
+    }
+
+    FX_grTexSource_NoLock(tmu0, ti0->tm[tmu0]->startAddr,
+                          GR_MIPMAPLEVELMASK_BOTH, &(ti0->info));
+    FX_grTexClampMode_NoLock(tmu0, ti0->sClamp, ti0->tClamp);
+    FX_grTexFilterMode_NoLock(tmu0, ti0->minFilt, ti0->maxFilt);
+    FX_grTexMipMapMode_NoLock(tmu0, ti0->mmMode, FXFALSE);
+
+    if (shared->umaTexMemory)
+        FX_grTexSource_NoLock(tmu1, ti1->tm[tmu0]->startAddr,
+                              GR_MIPMAPLEVELMASK_BOTH, &(ti1->info));
+    else
+        FX_grTexSource_NoLock(tmu1, ti1->tm[tmu1]->startAddr,
+                              GR_MIPMAPLEVELMASK_BOTH, &(ti1->info));
+
+    FX_grTexClampMode_NoLock(tmu1, ti1->sClamp, ti1->tClamp);
+    FX_grTexFilterMode_NoLock(tmu1, ti1->minFilt, ti1->maxFilt);
+    FX_grTexMipMapMode_NoLock(tmu1, ti1->mmMode, FXFALSE);
+
+#undef T0_NOT_IN_TMU
+#undef T1_NOT_IN_TMU
+#undef T0_IN_TMU0
+#undef T1_IN_TMU0
+#undef T0_IN_TMU1
+#undef T1_IN_TMU1
+}
+
+static void
+fxSetupTextureDoubleTMU_NoLock(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GrCombineLocal_t localc, locala;
+    tfxTexInfo *ti0, *ti1;
+    struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].CurrentD[2];
+    struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].CurrentD[2];
+    GLuint envmode, ifmt, unitsmode;
+    int tmu0 = 0, tmu1 = 1;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxSetupTextureDoubleTMU(...) Start\n");
+    }
+
+    ti0 = fxTMGetTexInfo(tObj0);
+    fxTexValidate(ctx, tObj0);
+
+    ti1 = fxTMGetTexInfo(tObj1);
+    fxTexValidate(ctx, tObj1);
+
+    fxSetupDoubleTMU_NoLock(fxMesa, tObj0, tObj1);
+
+    unitsmode = fxGetTexSetConfiguration(ctx, tObj0, tObj1);
+
+    fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1;
+    FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state);
+
+    envmode = unitsmode & FX_UM_E_ENVMODE;
+    ifmt = unitsmode & FX_UM_E_IFMT;
+
+    if (unitsmode & FX_UM_ALPHA_ITERATED)
+        locala = GR_COMBINE_LOCAL_ITERATED;
+    else
+        locala = GR_COMBINE_LOCAL_CONSTANT;
+
+    if (unitsmode & FX_UM_COLOR_ITERATED)
+        localc = GR_COMBINE_LOCAL_ITERATED;
+    else
+        localc = GR_COMBINE_LOCAL_CONSTANT;
+
+
+    if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+        fprintf(stderr, "fxMesa: fxSetupTextureDoubleTMU, envmode is %s/%s\n",
+                gl_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
+                gl_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
+
+
+    if ((ti0->whichTMU == FX_TMU1) || (ti1->whichTMU == FX_TMU0)) {
+        tmu0 = 1;
+        tmu1 = 0;
+    }
+    fxMesa->tmuSrc = FX_TMU_BOTH;
+
+    if (fxMesa->isNapalm) {
+        /* Remember, Glide has its texture units numbered in backward
+         * order compared to OpenGL.
+         */
+        SetupTexEnvNapalm(ctx, FX_TMU1, GL_TRUE, &(ctx->Texture.Unit[0]),
+                          ti0->baseLevelInternalFormat);
+        SetupTexEnvNapalm(ctx, FX_TMU0, GL_FALSE, &(ctx->Texture.Unit[1]),
+                          ti1->baseLevelInternalFormat);
+    }
+    else {
+        switch (envmode) {
+        case (FX_UM_E0_MODULATE | FX_UM_E1_MODULATE):
+            {
+                GLboolean isalpha[FX_NUM_TMU];
+
+                if (ti0->baseLevelInternalFormat == GL_ALPHA)
+                    isalpha[tmu0] = GL_TRUE;
+                else
+                    isalpha[tmu0] = GL_FALSE;
+
+                if (ti1->baseLevelInternalFormat == GL_ALPHA)
+                    isalpha[tmu1] = GL_TRUE;
+                else
+                    isalpha[tmu1] = GL_FALSE;
+
+                if (isalpha[FX_TMU1])
+                    FX_grTexCombine_NoLock(GR_TMU1,
+                                           GR_COMBINE_FUNCTION_ZERO,
+                                           GR_COMBINE_FACTOR_NONE,
+                                           GR_COMBINE_FUNCTION_LOCAL,
+                                           GR_COMBINE_FACTOR_NONE, FXTRUE,
+                                           FXFALSE);
+                else
+                    FX_grTexCombine_NoLock(GR_TMU1, GR_COMBINE_FUNCTION_LOCAL,
+                                           GR_COMBINE_FACTOR_NONE,
+                                           GR_COMBINE_FUNCTION_LOCAL,
+                                           GR_COMBINE_FACTOR_NONE, FXFALSE,
+                                           FXFALSE);
+
+                if (isalpha[FX_TMU0])
+                    FX_grTexCombine_NoLock(GR_TMU0,
+                                           GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                           GR_COMBINE_FACTOR_ONE,
+                                           GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                           GR_COMBINE_FACTOR_LOCAL, FXFALSE,
+                                           FXFALSE);
+                else
+                    FX_grTexCombine_NoLock(GR_TMU0,
+                                           GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                           GR_COMBINE_FACTOR_LOCAL,
+                                           GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                           GR_COMBINE_FACTOR_LOCAL, FXFALSE,
+                                           FXFALSE);
+
+                FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                         GR_COMBINE_FACTOR_LOCAL,
+                                         localc, GR_COMBINE_OTHER_TEXTURE,
+                                         FXFALSE);
+
+                FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                         GR_COMBINE_FACTOR_LOCAL,
+                                         locala, GR_COMBINE_OTHER_TEXTURE,
+                                         FXFALSE);
+                break;
+            }
+        case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */
+            if (tmu1 == FX_TMU1) {
+                FX_grTexCombine_NoLock(GR_TMU1,
+                                       GR_COMBINE_FUNCTION_LOCAL,
+                                       GR_COMBINE_FACTOR_NONE,
+                                       GR_COMBINE_FUNCTION_LOCAL,
+                                       GR_COMBINE_FACTOR_NONE, FXTRUE, FXFALSE);
+
+                FX_grTexCombine_NoLock(GR_TMU0,
+                                       GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                       GR_COMBINE_FACTOR_LOCAL,
+                                       GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                       GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE);
+            }
+            else {
+                FX_grTexCombine_NoLock(GR_TMU1,
+                                       GR_COMBINE_FUNCTION_LOCAL,
+                                       GR_COMBINE_FACTOR_NONE,
+                                       GR_COMBINE_FUNCTION_LOCAL,
+                                       GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+
+                FX_grTexCombine_NoLock(GR_TMU0,
+                                       GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                       GR_COMBINE_FACTOR_ONE_MINUS_LOCAL,
+                                       GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                       GR_COMBINE_FACTOR_ONE_MINUS_LOCAL,
+                                       FXFALSE, FXFALSE);
+            }
+
+            FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                                     GR_COMBINE_FACTOR_NONE,
+                                     locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+
+            FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                     GR_COMBINE_FACTOR_ONE,
+                                     localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+            break;
+        case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */
+            if (tmu1 == FX_TMU1) {
+                FX_grTexCombine_NoLock(GR_TMU1,
+                                       GR_COMBINE_FUNCTION_LOCAL,
+                                       GR_COMBINE_FACTOR_NONE,
+                                       GR_COMBINE_FUNCTION_ZERO,
+                                       GR_COMBINE_FACTOR_NONE, FXFALSE, FXTRUE);
+
+                FX_grTexCombine_NoLock(GR_TMU0,
+                                       GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                       GR_COMBINE_FACTOR_LOCAL,
+                                       GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                       GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE);
+
+            }
+            else {
+                FX_grTexCombine_NoLock(GR_TMU1,
+                                       GR_COMBINE_FUNCTION_LOCAL,
+                                       GR_COMBINE_FACTOR_NONE,
+                                       GR_COMBINE_FUNCTION_LOCAL,
+                                       GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE);
+
+                FX_grTexCombine_NoLock(GR_TMU0,
+                                       GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                       GR_COMBINE_FACTOR_LOCAL,
+                                       GR_COMBINE_FUNCTION_BLEND_OTHER,
+                                       GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE);
+            }
+
+            if (ti0->baseLevelInternalFormat == GL_RGB)
+                FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                                         GR_COMBINE_FACTOR_NONE,
+                                         locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+            else
+                FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                         GR_COMBINE_FACTOR_ONE,
+                                         locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+
+
+            FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                     GR_COMBINE_FACTOR_ONE,
+                                     localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
+            break;
+
+
+        case (FX_UM_E0_MODULATE | FX_UM_E1_ADD): /* Quake 3 Sky */
+            {
+                GLboolean isalpha[FX_NUM_TMU];
+
+                if (ti0->baseLevelInternalFormat == GL_ALPHA)
+                    isalpha[tmu0] = GL_TRUE;
+                else
+                    isalpha[tmu0] = GL_FALSE;
+
+                if (ti1->baseLevelInternalFormat == GL_ALPHA)
+                    isalpha[tmu1] = GL_TRUE;
+                else
+                    isalpha[tmu1] = GL_FALSE;
+
+                if (isalpha[FX_TMU1])
+                    FX_grTexCombine_NoLock(GR_TMU1,
+                                           GR_COMBINE_FUNCTION_ZERO,
+                                           GR_COMBINE_FACTOR_NONE,
+                                           GR_COMBINE_FUNCTION_LOCAL,
+                                           GR_COMBINE_FACTOR_NONE, FXTRUE,
+                                           FXFALSE);
+                else
+                    FX_grTexCombine_NoLock(GR_TMU1, GR_COMBINE_FUNCTION_LOCAL,
+                                           GR_COMBINE_FACTOR_NONE,
+                                           GR_COMBINE_FUNCTION_LOCAL,
+                                           GR_COMBINE_FACTOR_NONE, FXFALSE,
+                                           FXFALSE);
+
+                if (isalpha[FX_TMU0])
+                    FX_grTexCombine_NoLock(GR_TMU0,
+                                           GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                           GR_COMBINE_FACTOR_ONE,
+                                           GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+                                           GR_COMBINE_FACTOR_ONE, FXFALSE,
+                                           FXFALSE);
+                else
+                    FX_grTexCombine_NoLock(GR_TMU0,
+                                           GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+                                           GR_COMBINE_FACTOR_ONE,
+                                           GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+                                           GR_COMBINE_FACTOR_ONE, FXFALSE,
+                                           FXFALSE);
+
+                FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                         GR_COMBINE_FACTOR_LOCAL,
+                                         localc, GR_COMBINE_OTHER_TEXTURE,
+                                         FXFALSE);
+
+                FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+                                         GR_COMBINE_FACTOR_LOCAL,
+                                         locala, GR_COMBINE_OTHER_TEXTURE,
+                                         FXFALSE);
+                break;
+            }
+        default:
+            fprintf(stderr, "Unexpected dual texture mode encountered\n");
+            break;
+        }
+    }
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxSetupTextureDoubleTMU(...) End\n");
+    }
+}
+
+/************************* No Texture ***************************/
+
+static void
+fxSetupTextureNone_NoLock(GLcontext * ctx)
+{
+    /*fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;*/
+    GrCombineLocal_t localc, locala;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxSetupTextureNone(...)\n");
+    }
+
+    if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 ||
+        (ctx->Point.SmoothFlag) ||
+        (ctx->Line.SmoothFlag) ||
+        (ctx->Polygon.SmoothFlag)) locala = GR_COMBINE_LOCAL_ITERATED;
+    else
+        locala = GR_COMBINE_LOCAL_CONSTANT;
+
+    if (ctx->Light.ShadeModel == GL_SMOOTH || 1)
+        localc = GR_COMBINE_LOCAL_ITERATED;
+    else
+        localc = GR_COMBINE_LOCAL_CONSTANT;
+
+    FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                             GR_COMBINE_FACTOR_NONE,
+                             locala, GR_COMBINE_OTHER_NONE, FXFALSE);
+
+    FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+                             GR_COMBINE_FACTOR_NONE,
+                             localc, GR_COMBINE_OTHER_NONE, FXFALSE);
+}
+
+/************************************************************************/
+/************************** Texture Mode SetUp **************************/
+/************************************************************************/
+
+static void
+fxSetupTexture_NoLock(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint tex2Denabled;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxSetupTexture(...)\n");
+    }
+
+    /* Disable multipass texturing.
+     */
+    ctx->Driver.MultipassFunc = 0;
+
+    /* Texture Combine, Color Combine and Alpha Combine.
+     */
+    tex2Denabled = (ctx->Texture.ReallyEnabled & TEXTURE0_2D);
+
+    if (fxMesa->emulateTwoTMUs)
+        tex2Denabled |= (ctx->Texture.ReallyEnabled & TEXTURE1_2D);
+
+    switch (tex2Denabled) {
+    case TEXTURE0_2D:
+        fxSetupTextureSingleTMU_NoLock(ctx, 0);
+        break;
+    case TEXTURE1_2D:
+        fxSetupTextureSingleTMU_NoLock(ctx, 1);
+        break;
+    case (TEXTURE0_2D | TEXTURE1_2D):
+        if (fxMesa->haveTwoTMUs)
+            fxSetupTextureDoubleTMU_NoLock(ctx);
+        else {
+            if (MESA_VERBOSE & VERBOSE_DRIVER)
+                fprintf(stderr, "fxmesa: enabling fake multitexture\n");
+
+            fxSetupTextureSingleTMU_NoLock(ctx, 0);
+            ctx->Driver.MultipassFunc = fxMultipassTexture;
+        }
+        break;
+    default:
+        fxSetupTextureNone_NoLock(ctx);
+        break;
+    }
+}
+
+static void
+fxSetupTexture(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    BEGIN_BOARD_LOCK(fxMesa);
+    fxSetupTexture_NoLock(ctx);
+    END_BOARD_LOCK(fxMesa);
+}
+
+/************************************************************************/
+/**************************** Blend SetUp *******************************/
+/************************************************************************/
+
+void
+fxDDBlendFunc(GLcontext * ctx, GLenum sfactor, GLenum dfactor)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    tfxUnitsState *us = &fxMesa->unitsState;
+    GrAlphaBlendFnc_t sfact, dfact, asfact, adfact;
+
+    /* From the Glide documentation:
+       For alpha source and destination blend function factor
+       parameters, Voodoo Graphics supports only
+       GR_BLEND_ZERO and GR_BLEND_ONE.
+     */
+
+    switch (sfactor) {
+    case GL_ZERO:
+        asfact = sfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE:
+        asfact = sfact = GR_BLEND_ONE;
+        break;
+    case GL_DST_COLOR:
+        sfact = GR_BLEND_DST_COLOR;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_ONE_MINUS_DST_COLOR:
+        sfact = GR_BLEND_ONE_MINUS_DST_COLOR;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_SRC_ALPHA:
+        sfact = GR_BLEND_SRC_ALPHA;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_ONE_MINUS_SRC_ALPHA:
+        sfact = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_DST_ALPHA:
+        sfact = GR_BLEND_DST_ALPHA;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_ONE_MINUS_DST_ALPHA:
+        sfact = GR_BLEND_ONE_MINUS_DST_ALPHA;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_SRC_ALPHA_SATURATE:
+        sfact = GR_BLEND_ALPHA_SATURATE;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_SRC_COLOR:
+    case GL_ONE_MINUS_SRC_COLOR:
+        /* USELESS */
+        asfact = sfact = GR_BLEND_ONE;
+        break;
+    default:
+        asfact = sfact = GR_BLEND_ONE;
+        break;
+    }
+
+    if ((sfact != us->blendSrcFuncRGB) || (asfact != us->blendSrcFuncAlpha)) {
+        us->blendSrcFuncRGB = sfact;
+        us->blendSrcFuncAlpha = asfact;
+        fxMesa->new_state |= FX_NEW_BLEND;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+    }
+
+    switch (dfactor) {
+    case GL_ZERO:
+        adfact = dfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE:
+        adfact = dfact = GR_BLEND_ONE;
+        break;
+    case GL_SRC_COLOR:
+        dfact = GR_BLEND_SRC_COLOR;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE_MINUS_SRC_COLOR:
+        dfact = GR_BLEND_ONE_MINUS_SRC_COLOR;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_SRC_ALPHA:
+        dfact = GR_BLEND_SRC_ALPHA;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE_MINUS_SRC_ALPHA:
+        dfact = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_DST_ALPHA:
+        /* dfact=GR_BLEND_DST_ALPHA; */
+        /* We can't do DST_ALPHA */
+        dfact = GR_BLEND_ONE;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE_MINUS_DST_ALPHA:
+        /* dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; */
+        /* We can't do DST_ALPHA */
+        dfact = GR_BLEND_ZERO;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_SRC_ALPHA_SATURATE:
+    case GL_DST_COLOR:
+    case GL_ONE_MINUS_DST_COLOR:
+        /* USELESS */
+        adfact = dfact = GR_BLEND_ZERO;
+        break;
+    default:
+        adfact = dfact = GR_BLEND_ZERO;
+        break;
+    }
+
+    if ((dfact != us->blendDstFuncRGB) || (adfact != us->blendDstFuncAlpha)) {
+        us->blendDstFuncRGB = dfact;
+        us->blendDstFuncAlpha = adfact;
+        fxMesa->new_state |= FX_NEW_BLEND;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+    }
+}
+
+
+/* XXX not done yet, but it looks do-able in the hardware */
+void
+fxDDBlendFuncSeparate(GLcontext *ctx,
+                      GLenum sfactorRGB, GLenum sfactorA,
+                      GLenum dfactorRGB, GLenum dfactorA)
+{
+#if 000
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    tfxUnitsState *us = &fxMesa->unitsState;
+    GrAlphaBlendFnc_t sfact, dfact, asfact, adfact;
+
+    /* From the Glide documentation:
+       For alpha source and destination blend function factor
+       parameters, Voodoo Graphics supports only
+       GR_BLEND_ZERO and GR_BLEND_ONE.
+     */
+
+    switch (sfactor) {
+    case GL_ZERO:
+        asfact = sfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE:
+        asfact = sfact = GR_BLEND_ONE;
+        break;
+    case GL_DST_COLOR:
+        sfact = GR_BLEND_DST_COLOR;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_ONE_MINUS_DST_COLOR:
+        sfact = GR_BLEND_ONE_MINUS_DST_COLOR;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_SRC_ALPHA:
+        sfact = GR_BLEND_SRC_ALPHA;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_ONE_MINUS_SRC_ALPHA:
+        sfact = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_DST_ALPHA:
+        sfact = GR_BLEND_DST_ALPHA;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_ONE_MINUS_DST_ALPHA:
+        sfact = GR_BLEND_ONE_MINUS_DST_ALPHA;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_SRC_ALPHA_SATURATE:
+        sfact = GR_BLEND_ALPHA_SATURATE;
+        asfact = GR_BLEND_ONE;
+        break;
+    case GL_SRC_COLOR:
+    case GL_ONE_MINUS_SRC_COLOR:
+        /* USELESS */
+        asfact = sfact = GR_BLEND_ONE;
+        break;
+    default:
+        asfact = sfact = GR_BLEND_ONE;
+        break;
+    }
+
+    if ((sfact != us->blendSrcFuncRGB) || (asfact != us->blendSrcFuncAlpha)) {
+        us->blendSrcFuncRGB = sfact;
+        us->blendSrcFuncAlpha = asfact;
+        fxMesa->new_state |= FX_NEW_BLEND;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+    }
+
+    switch (dfactor) {
+    case GL_ZERO:
+        adfact = dfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE:
+        adfact = dfact = GR_BLEND_ONE;
+        break;
+    case GL_SRC_COLOR:
+        dfact = GR_BLEND_SRC_COLOR;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE_MINUS_SRC_COLOR:
+        dfact = GR_BLEND_ONE_MINUS_SRC_COLOR;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_SRC_ALPHA:
+        dfact = GR_BLEND_SRC_ALPHA;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE_MINUS_SRC_ALPHA:
+        dfact = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_DST_ALPHA:
+        /* dfact=GR_BLEND_DST_ALPHA; */
+        /* We can't do DST_ALPHA */
+        dfact = GR_BLEND_ONE;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_ONE_MINUS_DST_ALPHA:
+        /* dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; */
+        /* We can't do DST_ALPHA */
+        dfact = GR_BLEND_ZERO;
+        adfact = GR_BLEND_ZERO;
+        break;
+    case GL_SRC_ALPHA_SATURATE:
+    case GL_DST_COLOR:
+    case GL_ONE_MINUS_DST_COLOR:
+        /* USELESS */
+        adfact = dfact = GR_BLEND_ZERO;
+        break;
+    default:
+        adfact = dfact = GR_BLEND_ZERO;
+        break;
+    }
+
+    if ((dfact != us->blendDstFuncRGB) || (adfact != us->blendDstFuncAlpha)) {
+        us->blendDstFuncRGB = dfact;
+        us->blendDstFuncAlpha = adfact;
+        fxMesa->new_state |= FX_NEW_BLEND;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+    }
+#endif
+}
+
+
+static void
+fxSetupBlend(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    tfxUnitsState *us = &fxMesa->unitsState;
+
+    if (us->blendEnabled)
+        FX_grAlphaBlendFunction(us->blendSrcFuncRGB, us->blendDstFuncRGB,
+                                us->blendSrcFuncAlpha, us->blendDstFuncAlpha);
+    else
+        FX_grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO,
+                                GR_BLEND_ONE, GR_BLEND_ZERO);
+}
+
+
+/************************************************************************/
+/************************** Alpha Test SetUp ****************************/
+/************************************************************************/
+
+void
+fxDDAlphaFunc(GLcontext * ctx, GLenum func, GLclampf ref)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    tfxUnitsState *us = &fxMesa->unitsState;
+    GrCmpFnc_t newfunc;
+
+    switch (func) {
+    case GL_NEVER:
+        newfunc = GR_CMP_NEVER;
+        break;
+    case GL_LESS:
+        newfunc = GR_CMP_LESS;
+        break;
+    case GL_EQUAL:
+        newfunc = GR_CMP_EQUAL;
+        break;
+    case GL_LEQUAL:
+        newfunc = GR_CMP_LEQUAL;
+        break;
+    case GL_GREATER:
+        newfunc = GR_CMP_GREATER;
+        break;
+    case GL_NOTEQUAL:
+        newfunc = GR_CMP_NOTEQUAL;
+        break;
+    case GL_GEQUAL:
+        newfunc = GR_CMP_GEQUAL;
+        break;
+    case GL_ALWAYS:
+        newfunc = GR_CMP_ALWAYS;
+        break;
+    default:
+        gl_problem(ctx, "fx Driver: internal error in fxDDAlphaFunc()\n");
+        return;
+    }
+
+    if (newfunc != us->alphaTestFunc) {
+        us->alphaTestFunc = newfunc;
+        fxMesa->new_state |= FX_NEW_ALPHA;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+    }
+
+    if (ctx->Color.AlphaRef != us->alphaTestRefValue) {
+        us->alphaTestRefValue = ctx->Color.AlphaRef;
+        fxMesa->new_state |= FX_NEW_ALPHA;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+    }
+}
+
+static void
+fxSetupAlphaTest(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    tfxUnitsState *us = &fxMesa->unitsState;
+
+    if (us->alphaTestEnabled) {
+        FX_grAlphaTestFunction(fxMesa, us->alphaTestFunc);
+        FX_grAlphaTestReferenceValue(fxMesa, us->alphaTestRefValue);
+    }
+    else
+        FX_grAlphaTestFunction(fxMesa, GR_CMP_ALWAYS);
+}
+
+
+/*
+ * Evaluate all depth-test state and make the Glide calls.
+ */
+static void
+fxSetupDepthTest(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    if (ctx->Depth.Test) {
+        GrCmpFnc_t dfunc;
+        switch (ctx->Depth.Func) {
+        case GL_NEVER:
+            dfunc = GR_CMP_NEVER;
+            break;
+        case GL_LESS:
+            dfunc = GR_CMP_LESS;
+            break;
+        case GL_GEQUAL:
+            dfunc = GR_CMP_GEQUAL;
+            break;
+        case GL_LEQUAL:
+            dfunc = GR_CMP_LEQUAL;
+            break;
+        case GL_GREATER:
+            dfunc = GR_CMP_GREATER;
+            break;
+        case GL_NOTEQUAL:
+            dfunc = GR_CMP_NOTEQUAL;
+            break;
+        case GL_EQUAL:
+            dfunc = GR_CMP_EQUAL;
+            break;
+        case GL_ALWAYS:
+            dfunc = GR_CMP_ALWAYS;
+            break;
+        default:
+            gl_problem(ctx, "bad depth mode in fxSetupDepthTest");
+            dfunc = GR_CMP_ALWAYS;
+        }
+        FX_grDepthBufferFunction(fxMesa, dfunc);
+        FX_grDepthMask(fxMesa, ctx->Depth.Mask);
+    }
+    else {
+        /* depth test always passes, don't update Z buffer */
+        FX_grDepthBufferFunction(fxMesa, GR_CMP_ALWAYS);
+        FX_grDepthMask(fxMesa, FXFALSE);
+    }
+}
+
+
+/*
+ * Evaluate all stencil state and make the Glide calls.
+ */
+GrStencil_t
+fxConvertGLStencilOp(GLenum op)
+{
+    switch (op) {
+    case GL_KEEP:
+        return GR_STENCILOP_KEEP;
+    case GL_ZERO:
+        return GR_STENCILOP_ZERO;
+    case GL_REPLACE:
+        return GR_STENCILOP_REPLACE;
+    case GL_INCR:
+        return GR_STENCILOP_INCR_CLAMP;
+    case GL_DECR:
+        return GR_STENCILOP_DECR_CLAMP;
+    case GL_INVERT:
+        return GR_STENCILOP_INVERT;
+    default:
+        gl_problem(NULL, "bad stencil op in fxConvertGLStencilOp");
+    }
+    return GR_STENCILOP_KEEP;   /* never get, silence compiler warning */
+}
+
+/*
+ * This function is called just before any rendering is done.
+ * It will validate the stencil parameters.
+ */
+static void
+fxSetupStencilTest(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    if (fxMesa->haveHwStencil) {
+        if (ctx->Stencil.Enabled) {
+            GrStencil_t sfail = fxConvertGLStencilOp(ctx->Stencil.FailFunc);
+            GrStencil_t zfail = fxConvertGLStencilOp(ctx->Stencil.ZFailFunc);
+            GrStencil_t zpass = fxConvertGLStencilOp(ctx->Stencil.ZPassFunc);
+            FX_grStencilOp(fxMesa, sfail, zfail, zpass);
+            FX_grStencilFunc(fxMesa, ctx->Stencil.Function - GL_NEVER,
+                             ctx->Stencil.Ref, ctx->Stencil.ValueMask);
+            FX_grStencilMask(fxMesa, ctx->Stencil.WriteMask);
+            FX_grEnable(fxMesa, GR_STENCIL_MODE_EXT);
+        }
+        else {
+            FX_grDisable(fxMesa, GR_STENCIL_MODE_EXT);
+        }
+    }
+}
+
+
+/*
+ * Set the state so that stencil is either enabled or disabled.
+ * This is called from Mesa only.  Glide is invoked at
+ * setup time, not now.
+ */
+static void
+fxDDEnableStencil(GLcontext * ctx, GLboolean state)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    (void) state;
+    fxMesa->new_state |= FX_NEW_STENCIL;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+
+/************************************************************************/
+/**************************** Color Mask SetUp **************************/
+/************************************************************************/
+
+GLboolean
+fxDDColorMask(GLcontext *ctx,
+              GLboolean r, GLboolean g, GLboolean b, GLboolean a)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    fxMesa->new_state |= FX_NEW_COLOR_MASK;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+    (void) r;
+    (void) g;
+    (void) b;
+    (void) a;
+    return GL_FALSE;
+}
+
+static void
+fxSetupColorMask(GLcontext *ctx)
+{
+    if (ctx->Color.DrawBuffer == GL_NONE) {
+        FX_grColorMask(ctx, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+    }
+    else {
+        fxMesaContext fxMesa = FX_CONTEXT(ctx);
+        /* XXX need to call grRenderBuffer to work around strange mask bug */
+        FX_grRenderBuffer(fxMesa, fxMesa->currentFB);
+        FX_grColorMaskv(ctx, ctx->Color.ColorMask);
+    }
+}
+
+
+/************************************************************************/
+/**************************** Fog Mode SetUp ****************************/
+/************************************************************************/
+
+/*
+ * This is called during state update in order to update the Glide fog state.
+ */
+static void
+fxSetupFog(GLcontext * ctx)
+{
+   fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    if (ctx->Fog.Enabled && ctx->FogMode == FOG_FRAGMENT) {
+
+        /* update fog color */
+        GLubyte col[4];
+        col[0] = (unsigned int) (255 * ctx->Fog.Color[0]);
+        col[1] = (unsigned int) (255 * ctx->Fog.Color[1]);
+        col[2] = (unsigned int) (255 * ctx->Fog.Color[2]);
+        col[3] = (unsigned int) (255 * ctx->Fog.Color[3]);
+        FX_grFogColorValue(fxMesa, FXCOLOR4(col));
+
+        if (fxMesa->fogTableMode != ctx->Fog.Mode ||
+            fxMesa->fogDensity != ctx->Fog.Density ||
+            fxMesa->fogStart != ctx->Fog.Start ||
+            fxMesa->fogEnd != ctx->Fog.End) {
+            /* reload the fog table */
+            switch (ctx->Fog.Mode) {
+            case GL_LINEAR:
+                guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start,
+                                    ctx->Fog.End);
+                break;
+            case GL_EXP:
+                guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density);
+                break;
+            case GL_EXP2:
+                guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density);
+                break;
+            default:
+                ;
+            }
+            fxMesa->fogTableMode = ctx->Fog.Mode;
+            fxMesa->fogDensity = ctx->Fog.Density;
+            fxMesa->fogStart = ctx->Fog.Start;
+            fxMesa->fogEnd = ctx->Fog.End;
+        }
+
+        FX_grFogTable(fxMesa, fxMesa->fogTable);
+        FX_grFogMode(fxMesa, GR_FOG_WITH_TABLE);
+    }
+    else {
+        FX_grFogMode(fxMesa, GR_FOG_DISABLE);
+    }
+}
+
+void
+fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params)
+{
+    FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG;
+    ctx->Driver.RenderStart = fxSetupFXUnits; /* XXX why is this here? */
+}
+
+/************************************************************************/
+/************************** Scissor Test SetUp **************************/
+/************************************************************************/
+
+/* This routine is used in managing the lock state, and therefore can't lock */
+void
+fxSetScissorValues(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    int xmin, xmax, ymin, ymax;
+
+    if (ctx->Scissor.Enabled) {
+        xmin = ctx->Scissor.X;
+        xmax = ctx->Scissor.X + ctx->Scissor.Width;
+        ymin = ctx->Scissor.Y;
+        ymax = ctx->Scissor.Y + ctx->Scissor.Height;
+    }
+    else {
+        xmin = 0;
+        ymin = 0;
+        xmax = fxMesa->width;
+        ymax = fxMesa->height;
+    }
+    /* translate to screen coords */
+    xmin += fxMesa->x_offset;
+    xmax += fxMesa->x_offset;
+    ymin += fxMesa->y_delta;
+    ymax += fxMesa->y_delta;
+
+    /* intersect scissor region with first clip rect */
+    if (xmin < fxMesa->clipMinX)
+        xmin = fxMesa->clipMinX;
+    else if (xmin > fxMesa->clipMaxX)
+        xmin = fxMesa->clipMaxX;
+
+    if (xmax > fxMesa->clipMaxX)
+        xmax = fxMesa->clipMaxX;
+
+    if (ymin < fxMesa->screen_height - fxMesa->clipMaxY)
+        ymin = fxMesa->screen_height - fxMesa->clipMaxY;
+    else if (ymin > fxMesa->screen_height - fxMesa->clipMinY)
+        ymin = fxMesa->screen_height - fxMesa->clipMinY;
+
+    if (ymax > fxMesa->screen_height - fxMesa->clipMinY)
+        ymax = fxMesa->screen_height - fxMesa->clipMinY;
+
+    /* prevent wrap-around problems */
+    if (xmax < xmin)
+       xmax = xmin;
+    if (ymax < ymin)
+       ymax = ymin;
+
+    FX_grClipWindow_NoLock(xmin, ymin, xmax, ymax);
+}
+
+static void
+fxSetupScissor(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    if (!fxMesa->needClip) {
+        BEGIN_BOARD_LOCK(fxMesa);
+        fxSetScissorValues(ctx);
+        END_BOARD_LOCK(fxMesa);
+    }
+}
+
+void
+fxDDScissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+    FX_CONTEXT(ctx)->new_state |= FX_NEW_SCISSOR;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+/************************************************************************/
+/*************************** Cull mode setup ****************************/
+/************************************************************************/
+
+
+void
+fxDDCullFace(GLcontext * ctx, GLenum mode)
+{
+    (void) mode;
+    FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+void
+fxDDFrontFace(GLcontext * ctx, GLenum mode)
+{
+    (void) mode;
+    FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+
+static void
+fxSetupCull(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    if (ctx->Polygon.CullFlag) {
+        switch (ctx->Polygon.CullFaceMode) {
+        case GL_BACK:
+            if (ctx->Polygon.FrontFace == GL_CCW)
+                FX_CONTEXT(ctx)->cullMode = GR_CULL_NEGATIVE;
+            else
+                FX_CONTEXT(ctx)->cullMode = GR_CULL_POSITIVE;
+            break;
+        case GL_FRONT:
+            if (ctx->Polygon.FrontFace == GL_CCW)
+                FX_CONTEXT(ctx)->cullMode = GR_CULL_POSITIVE;
+            else
+                FX_CONTEXT(ctx)->cullMode = GR_CULL_NEGATIVE;
+            break;
+        case GL_FRONT_AND_BACK:
+            FX_CONTEXT(ctx)->cullMode = GR_CULL_DISABLE;
+            break;
+        default:
+            break;
+        }
+    }
+    else {
+        FX_CONTEXT(ctx)->cullMode = GR_CULL_DISABLE;
+    }
+    FX_grCullMode(fxMesa, FX_CONTEXT(ctx)->cullMode);
+}
+
+
+/************************************************************************/
+/****************************** DD Enable ******************************/
+/************************************************************************/
+
+void
+fxDDEnable(GLcontext * ctx, GLenum cap, GLboolean state)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    tfxUnitsState *us = &fxMesa->unitsState;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxDDEnable(...)\n");
+    }
+
+    switch (cap) {
+    case GL_ALPHA_TEST:
+        if (state != us->alphaTestEnabled) {
+            us->alphaTestEnabled = state;
+            fxMesa->new_state |= FX_NEW_ALPHA;
+            ctx->Driver.RenderStart = fxSetupFXUnits;
+        }
+        break;
+    case GL_BLEND:
+        if (state != us->blendEnabled) {
+            us->blendEnabled = state;
+            fxMesa->new_state |= FX_NEW_BLEND;
+            ctx->Driver.RenderStart = fxSetupFXUnits;
+        }
+        break;
+    case GL_DEPTH_TEST:
+        fxMesa->new_state |= FX_NEW_DEPTH;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+        break;
+    case GL_DITHER:
+        if (state)
+            FX_grDitherMode(fxMesa, GR_DITHER_4x4);
+        else
+            FX_grDitherMode(fxMesa, GR_DITHER_DISABLE);
+        break;
+    case GL_SCISSOR_TEST:
+        fxMesa->new_state |= FX_NEW_SCISSOR;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+        break;
+    case GL_SHARED_TEXTURE_PALETTE_EXT:
+        fxDDTexUseGlbPalette(ctx, state);
+        break;
+    case GL_FOG:
+        fxMesa->new_state |= FX_NEW_FOG;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+        break;
+    case GL_CULL_FACE:
+        fxMesa->new_state |= FX_NEW_CULL;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+        break;
+    case GL_LINE_SMOOTH:
+    case GL_LINE_STIPPLE:
+    case GL_POINT_SMOOTH:
+    case GL_POLYGON_SMOOTH:
+    case GL_TEXTURE_2D:
+        fxMesa->new_state |= FX_NEW_TEXTURING;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+        break;
+    case GL_STENCIL_TEST:
+        fxMesa->new_state |= FX_NEW_STENCIL;
+        ctx->Driver.RenderStart = fxSetupFXUnits;
+        break;
+    default:
+        ;                       /* no-op */
+    }
+}
+
+
+#if 0
+/*
+  Multipass to do GL_BLEND texture functions
+  Cf*(1-Ct) has already been written to the buffer during the first pass
+  Cc*Ct gets written during the second pass (in this function)
+  Everything gets reset in the third call (in this function)
+*/
+static GLboolean
+fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+    switch (pass) {
+    case 1:
+        /* Add Cc*Ct */
+        fxMesa->restoreUnitsState = fxMesa->unitsState;
+        if (ctx->Depth.Mask) {
+            /* We don't want to check or change the depth buffers */
+            switch (ctx->Depth.Func) {
+            case GL_NEVER:
+            case GL_ALWAYS:
+                break;
+            default:
+                fxDDDepthFunc(ctx, GL_EQUAL);
+                break;
+            }
+            fxDDDepthMask(ctx, FALSE);
+        }
+        /*
+         * Disable stencil as well.
+         */
+        if (ctx->Stencil.Enabled) {
+            fxDDEnableStencil(ctx, GL_FALSE);
+        }
+        /* Enable Cc*Ct mode */
+        /* XXX Set the Constant Color ? */
+        fxDDEnable(ctx, GL_BLEND, GL_TRUE);
+        fxDDBlendFunc(ctx, XXX, XXX);
+        fxSetupTextureSingleTMU(ctx, XXX);
+        fxSetupBlend(ctx);
+        fxSetupDepthTest(ctx);
+        break;
+
+    case 2:
+        /* Reset everything back to normal */
+        fxMesa->unitsState = fxMesa->restoreUnitsState;
+        fxMesa->setupdone &= XXX;
+        fxSetupTextureSingleTMU(ctx, XXX);
+        fxSetupBlend(ctx);
+        fxSetupDepthTest(ctx);
+        fxSetupStencilText(ctx);
+        break;
+    }
+
+    return pass == 1;
+}
+#endif
+
+/************************************************************************/
+/******************** Fake Multitexture Support *************************/
+/************************************************************************/
+
+/* Its considered cheeky to try to fake ARB multitexture by doing
+ * multipass rendering, because it is not possible to emulate the full
+ * spec in this way.  The fact is that the voodoo 2 supports only a
+ * subset of the possible multitexturing modes, and it is possible to
+ * support almost the same subset using multipass blending on the
+ * voodoo 1.  In all other cases for both voodoo 1 and 2, we fall back
+ * to software rendering, satisfying the spec if not the user.  
+ */
+static GLboolean
+fxMultipassTexture(struct vertex_buffer *VB, GLuint pass)
+{
+    GLcontext *ctx = VB->ctx;
+    fxVertex *v = FX_DRIVER_DATA(VB)->verts;
+    fxVertex *last = FX_DRIVER_DATA(VB)->last_vert;
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+    switch (pass) {
+    case 1:
+        if (MESA_VERBOSE &
+            (VERBOSE_DRIVER | VERBOSE_PIPELINE | VERBOSE_TEXTURE))
+                fprintf(stderr, "fxmesa: Second texture pass\n");
+
+        for (; v != last; v++) {
+            v->f[S0COORD] = v->f[S1COORD];
+            v->f[T0COORD] = v->f[T1COORD];
+        }
+
+        fxMesa->restoreUnitsState = fxMesa->unitsState;
+        fxMesa->tmu_source[0] = 1;
+
+        if (ctx->Depth.Mask) {
+            switch (ctx->Depth.Func) {
+            case GL_NEVER:
+            case GL_ALWAYS:
+                break;
+            default:
+                /*fxDDDepthFunc( ctx, GL_EQUAL ); */
+                FX_grDepthBufferFunction(fxMesa, GR_CMP_EQUAL);
+                break;
+            }
+
+            /*fxDDDepthMask( ctx, GL_FALSE ); */
+            FX_grDepthMask(fxMesa, FXFALSE);
+        }
+        fxDDEnableStencil(ctx, GL_FALSE);
+        if (ctx->Texture.Unit[1].EnvMode == GL_MODULATE) {
+            fxDDEnable(ctx, GL_BLEND, GL_TRUE);
+            fxDDBlendFunc(ctx, GL_DST_COLOR, GL_ZERO);
+        }
+
+        fxSetupTextureSingleTMU(ctx, 1);
+        fxSetupBlend(ctx);
+        fxSetupDepthTest(ctx);
+        break;
+
+    case 2:
+        /* Restore original state.  
+         */
+        fxMesa->tmu_source[0] = 0;
+        fxMesa->unitsState = fxMesa->restoreUnitsState;
+        fxMesa->setupdone &= ~SETUP_TMU0;
+        fxSetupTextureSingleTMU(ctx, 0);
+        fxSetupBlend(ctx);
+        fxSetupDepthTest(ctx);
+        fxSetupStencilTest(ctx);
+        break;
+    }
+
+    return pass == 1;
+}
+
+
+/************************************************************************/
+/************************** Changes to units state **********************/
+/************************************************************************/
+
+
+/* All units setup is handled under texture setup.
+ */
+void
+fxDDShadeModel(GLcontext * ctx, GLenum mode)
+{
+    FX_CONTEXT(ctx)->new_state |= FX_NEW_TEXTURING;
+    ctx->Driver.RenderStart = fxSetupFXUnits;
+}
+
+
+
+/************************************************************************/
+/****************************** Units SetUp *****************************/
+/************************************************************************/
+static void
+gl_print_fx_state_flags(const char *msg, GLuint flags)
+{
+    fprintf(stderr,
+            "%s: (0x%x) %s%s%s%s%s%s%s\n",
+            msg,
+            flags,
+            (flags & FX_NEW_TEXTURING) ? "texture, " : "",
+            (flags & FX_NEW_BLEND) ? "blend, " : "",
+            (flags & FX_NEW_ALPHA) ? "alpha, " : "",
+            (flags & FX_NEW_FOG) ? "fog, " : "",
+            (flags & FX_NEW_SCISSOR) ? "scissor, " : "",
+            (flags & FX_NEW_COLOR_MASK) ? "colormask, " : "",
+            (flags & FX_NEW_CULL) ? "cull, " : "");
+}
+
+void
+fxSetupFXUnits(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint newstate = fxMesa->new_state;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER)
+        gl_print_fx_state_flags("fxmesa: fxSetupFXUnits", newstate);
+
+    if (newstate) {
+        if (newstate & FX_NEW_TEXTURING)
+            fxSetupTexture(ctx);
+
+        if (newstate & FX_NEW_BLEND)
+            fxSetupBlend(ctx);
+
+        if (newstate & FX_NEW_ALPHA)
+            fxSetupAlphaTest(ctx);
+
+        if (newstate & FX_NEW_DEPTH)
+            fxSetupDepthTest(ctx);
+
+        if (newstate & FX_NEW_STENCIL)
+            fxSetupStencilTest(ctx);
+
+        if (newstate & FX_NEW_FOG)
+            fxSetupFog(ctx);
+
+        if (newstate & FX_NEW_SCISSOR)
+            fxSetupScissor(ctx);
+
+        if (newstate & FX_NEW_COLOR_MASK)
+            fxSetupColorMask(ctx);
+
+        if (newstate & FX_NEW_CULL)
+            fxSetupCull(ctx);
+        fxMesa->new_state = 0;
+/*       ctx->Driver.RenderStart = 0; */
+    }
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxsetup.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxsetup.h:1.2
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxsetup.h	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,36 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxsetup.h,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+#ifndef FXSETUP_H
+#define FXSETUP_H
+
+extern void fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj);
+
+extern void fxDDEnable(GLcontext *, GLenum, GLboolean);
+
+extern void fxDDAlphaFunc(GLcontext *, GLenum, GLclampf);
+
+extern void fxDDBlendFunc(GLcontext *, GLenum, GLenum);
+
+extern void fxDDBlendFuncSeparate(GLcontext *ctx,
+                                  GLenum sfactorRGB, GLenum sfactorA,
+                                  GLenum dfactorRGB, GLenum dfactorA);
+
+extern GrStencil_t fxConvertGLStencilOp(GLenum op);
+
+extern void fxDDScissor(GLcontext *ctx,
+                        GLint x, GLint y, GLsizei w, GLsizei h);
+
+extern void fxDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat * params);
+
+extern GLboolean fxDDColorMask(GLcontext *ctx,
+                               GLboolean r, GLboolean g,
+                               GLboolean b, GLboolean a);
+
+extern void fxDDShadeModel(GLcontext * ctx, GLenum mode);
+
+extern void fxDDCullFace(GLcontext * ctx, GLenum mode);
+
+extern void fxDDFrontFace(GLcontext * ctx, GLenum mode);
+
+extern void fxSetupFXUnits(GLcontext *);
+
+#endif
Index: xc/lib/GL/mesa/src/drv/tdfx/fxstripdet.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxstripdet.c:1.1
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxstripdet.c	Sun Sep 24 09:51:19 2000
@@ -0,0 +1,161 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxstripdet.c,v 1.1 2000/09/24 13:51:19 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#include "fxdrv.h"
+#include "vbcull.h"
+
+
+#define STRIP0(u,v)		((u1 == v1) && (u2 == v0))
+#define STRIP1(u,v)		((u0 == v0) && (u2 == v1))
+
+#define LOCAL_VARS		fxVertex* gWin = FX_DRIVER_DATA(VB)->verts;	\
+				GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;\
+                                fxMesaContext fxMesa = FX_CONTEXT(VB->ctx);
+
+
+#define STRIPSLOCAL_VAR		int sc	       = 0;
+
+#define INIT(a)
+
+#define SENDTRI(u0,u1,u2)	FX_grDrawTriangle(fxMesa, (GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
+#define FLUSHTRI()              /* No-Op */
+#define STARTSTRIPS(u0,u1,u2)	{ sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
+#define SENDSTRIPS(v2)		{ sb[sc++] = (GrVertex*)&(gWin[v2].f); }
+#define FLUSHSTRIPS()		FX_grDrawVertexArray(fxMesa, GR_TRIANGLE_STRIP,sc,sb)
+
+#define CLIPPED(a,b,c)		0
+#define CULLED(a,b,c)		0
+#define SENDCLIPTRI(a,b,c)      /* NoOp */
+
+#define TAG(x)			x##_fx
+
+#include "fxsdettmp.h"
+
+
+/* Clipped but no userclip */
+#define STRIP0(u,v)		((u1 == v1) && (u2 == v0)) && !clipmask[v2]
+#define STRIP1(u,v)		((u0 == v0) && (u2 == v1)) && !clipmask[v2]
+
+#define LOCAL_VARS		fxVertex* gWin = FX_DRIVER_DATA(VB)->verts;			\
+				GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;			\
+				const GLubyte *const clipmask = VB->ClipMask;				\
+				const fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;	\
+				const tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
+
+#define STRIPSLOCAL_VAR		int sc	       = 0;
+
+#define INIT(a)
+
+#define SENDTRI(u0,u1,u2)	FX_grDrawTriangle(fxMesa, (GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
+#define FLUSHTRI()              /* No-Op */
+#define STARTSTRIPS(u0,u1,u2)	{ sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
+#define SENDSTRIPS(v2)		{ sb[sc++] = (GrVertex*)&(gWin[v2].f); }
+#define FLUSHSTRIPS()		FX_grDrawVertexArray(fxMesa, GR_TRIANGLE_STRIP,sc,sb)
+
+#define CLIPPED(u0,u1,u2)	(clipmask[u0] | clipmask[u1] | clipmask[u2])
+#define CULLED(u0,u1,u2)	(clipmask[u0] & clipmask[u1] & clipmask[u2])
+#define SENDCLIPTRI(u0,u1,u2)	{									\
+				   GLuint vl[3];							\
+    				   ASSIGN_3V(vl, u0, u1, u2 );						\
+				   cliptri(VB,vl,clipmask[u0] | clipmask[u1] | clipmask[u2]);		\
+				}
+
+#define TAG(x)			x##_fx_view_clipped
+
+#include "fxsdettmp.h"
+
+/* Clipped and might be userclip */
+#define STRIP0(u,v)		((u1 == v1) && (u2 == v0)) && !clipmask[v2]
+#define STRIP1(u,v)		((u0 == v0) && (u2 == v1)) && !clipmask[v2]
+
+#define LOCAL_VARS		fxVertex* gWin = FX_DRIVER_DATA(VB)->verts;			\
+				GrVertex** sb = FX_DRIVER_DATA(VB)->strips_b;			\
+				const GLubyte *const clipmask = VB->ClipMask;			\
+				const GLubyte *userclipmask = VB->UserClipMask;			\
+				const fxMesaContext fxMesa=(fxMesaContext)VB->ctx->DriverCtx;	\
+				const tfxTriClipFunc cliptri = fxMesa->clip_tri_stride;
+
+#define STRIPSLOCAL_VAR		int sc	       = 0;
+
+#define INIT(a)
+
+#define SENDTRI(u0,u1,u2)	FX_grDrawTriangle(fxMesa, (GrVertex*)&(gWin[u0].f),(GrVertex*)&(gWin[u1].f),(GrVertex*)&(gWin[u2].f))
+#define FLUSHTRI()              /* No-Op */
+#define STARTSTRIPS(u0,u1,u2)	{ sb[sc++] = (GrVertex*)&(gWin[u0].f); sb[sc++] = (GrVertex*)&(gWin[u1].f); sb[sc++] = (GrVertex*)&(gWin[u2].f); }
+#define SENDSTRIPS(v2)		{ sb[sc++] = (GrVertex*)&(gWin[v2].f); }
+#define FLUSHSTRIPS()		FX_grDrawVertexArray(fxMesa, GR_TRIANGLE_STRIP,sc,sb)
+
+#define CLIPPED(u0,u1,u2)	(clipmask[u0] | clipmask[u1] | clipmask[u2])
+#define CULLED(u0,u1,u2)	(clipmask[u0] & clipmask[u1] & clipmask[u2] & CLIP_ALL_BITS)
+#define SENDCLIPTRI(u0,u1,u2)	{									                  \
+    					GLuint vl[3];							                  \
+    					GLuint imask = (clipmask[u0] | clipmask[u1] | clipmask[u2]);			  \
+    															  \
+					if (imask & CLIP_USER_BIT) {					                  \
+      						if (!(userclipmask[u2] & userclipmask[u1] & userclipmask[u0]))		  \
+      						{ ASSIGN_3V(vl, u2, u1, u0 );						  \
+      						  imask |= (userclipmask[u2] | userclipmask[u1] | userclipmask[u0]) << 8; \
+      						   cliptri( VB, vl, imask );}					          \
+    					}										  \
+    					else { ASSIGN_3V(vl, u2, u1, u0 );						  \
+    					    cliptri( VB, vl, imask );	}						  \
+  				}
+
+#define TAG(x)			x##_fx_clipped
+
+#include "fxsdettmp.h"
+
+
+void
+fxDDRenderInitGlide3(GLcontext * ctx)
+{
+#if 0
+    render_tab_fx_smooth_indirect[GL_TRIANGLES] =
+        render_vb_triangles_smooth_indirect_sd_fx;
+    render_tab_fx_smooth_indirect_view_clipped[GL_TRIANGLES] =
+        render_vb_triangles_smooth_indirect_sd_fx_view_clipped;
+    render_tab_fx_smooth_indirect_clipped[GL_TRIANGLES] =
+        render_vb_triangles_smooth_indirect_sd_fx_clipped;
+#endif
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxtexman.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxtexman.c:1.3
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxtexman.c	Fri Dec  8 16:34:20 2000
@@ -0,0 +1,959 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxtexman.c,v 1.3 2000/12/08 21:34:20 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* fxtexman.c - 3Dfx VooDoo texture memory functions */
+
+
+#include "fxdrv.h"
+#include "fxtexman.h"
+#include "fxddtex.h"
+
+
+#define BAD_ADDRESS ((FxU32) -1)
+
+
+#ifdef TEXSANITY
+static void
+fubar(void)
+{
+}
+
+/*
+ * Sanity Check
+ */
+static void
+sanity(fxMesaContext fxMesa)
+{
+    MemRange *tmp, *prev, *pos;
+
+    prev = 0;
+    tmp = fxMesa->tmFree[0];
+    while (tmp) {
+        if (!tmp->startAddr && !tmp->endAddr) {
+            fprintf(stderr, "Textures fubar\n");
+            fubar();
+        }
+        if (tmp->startAddr >= tmp->endAddr) {
+            fprintf(stderr, "Node fubar\n");
+            fubar();
+        }
+        if (prev && (prev->startAddr >= tmp->startAddr ||
+                     prev->endAddr > tmp->startAddr)) {
+            fprintf(stderr, "Sorting fubar\n");
+            fubar();
+        }
+        prev = tmp;
+        tmp = tmp->next;
+    }
+    prev = 0;
+    tmp = fxMesa->tmFree[1];
+    while (tmp) {
+        if (!tmp->startAddr && !tmp->endAddr) {
+            fprintf(stderr, "Textures fubar\n");
+            fubar();
+        }
+        if (tmp->startAddr >= tmp->endAddr) {
+            fprintf(stderr, "Node fubar\n");
+            fubar();
+        }
+        if (prev && (prev->startAddr >= tmp->startAddr ||
+                     prev->endAddr > tmp->startAddr)) {
+            fprintf(stderr, "Sorting fubar\n");
+            fubar();
+        }
+        prev = tmp;
+        tmp = tmp->next;
+    }
+}
+#endif
+
+
+/*
+ * Allocate and initialize a new MemRange struct.
+ * Try to allocate it from the pool of free MemRange nodes rather than malloc.
+ */
+static MemRange *
+NewRangeNode(fxMesaContext fxMesa, FxU32 start, FxU32 end)
+{
+    struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+    struct TdfxSharedState *shared = (struct TdfxSharedState *) mesaShared->DriverData;
+    MemRange *result;
+
+    _glthread_LOCK_MUTEX(mesaShared->Mutex);
+    if (shared && shared->tmPool) {
+        result = shared->tmPool;
+        shared->tmPool = shared->tmPool->next;
+    }
+    else {
+        result = MALLOC(sizeof(MemRange));
+
+    }
+    _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+
+    if (!result) {
+        /*fprintf(stderr, "fxDriver: out of memory!\n");*/
+        return NULL;
+    }
+
+    result->startAddr = start;
+    result->endAddr = end;
+    result->next = NULL;
+
+    return result;
+}
+
+
+/*
+ * Delete a MemRange struct.
+ * We keep a linked list of free/available MemRange structs to
+ * avoid extra malloc/free calls.
+ */
+#if 0
+static void
+DeleteRangeNode_NoLock(struct TdfxSharedState *shared, MemRange *range)
+{
+    /* insert at head of list */
+    range->next = shared->tmPool;
+    shared->tmPool = range;
+}
+#endif
+
+#define DELETE_RANGE_NODE(shared, range) \
+    (range)->next = (shared)->tmPool;    \
+    (shared)->tmPool = (range)
+
+
+/*
+ * When we've run out of texture memory we have to throw out an
+ * existing texture to make room for the new one.  This function
+ * determins the texture to throw out.
+ */
+static struct gl_texture_object *
+FindOldestObject(fxMesaContext fxMesa, FxU32 tmu)
+{
+    const GLuint bindnumber = fxMesa->texBindNumber;
+    struct gl_texture_object *oldestObj, *obj, *lowestPriorityObj;
+    GLfloat lowestPriority;
+    GLuint oldestAge;
+
+    oldestObj = NULL;
+    oldestAge = 0;
+
+    lowestPriority = 1.0F;
+    lowestPriorityObj = NULL;
+
+    for (obj = fxMesa->glCtx->Shared->TexObjectList; obj; obj = obj->Next) {
+        tfxTexInfo *info = fxTMGetTexInfo(obj);
+
+        if (info && info->isInTM &&
+            ((info->whichTMU == tmu) || (info->whichTMU == FX_TMU_BOTH) ||
+             (info->whichTMU == FX_TMU_SPLIT))) {
+            GLuint age, lasttime;
+
+            lasttime = info->lastTimeUsed;
+
+            if (lasttime > bindnumber)
+                age = bindnumber + (UINT_MAX - lasttime + 1); /* TO DO: check wrap around */
+            else
+                age = bindnumber - lasttime;
+
+            if (age >= oldestAge) {
+                oldestAge = age;
+                oldestObj = obj;
+            }
+
+            /* examine priority */
+            if (obj->Priority < lowestPriority) {
+                lowestPriority = obj->Priority;
+                lowestPriorityObj = obj;
+            }
+        }
+    }
+
+    if (lowestPriority < 1.0) {
+        ASSERT(lowestPriorityObj);
+        /*
+        printf("discard %d pri=%f\n", lowestPriorityObj->Name, lowestPriority);
+        */
+        return lowestPriorityObj;
+    }
+    else {
+        /*
+        printf("discard %d age=%d\n", oldestObj->Name, oldestAge);
+        */
+        return oldestObj;
+    }
+}
+
+
+/*
+ * Find the address (offset?) at which we can store a new texture.
+ * <tmu> is the texture unit.
+ * <size> is the texture size in bytes.
+ */
+static FxU32
+FindStartAddr(fxMesaContext fxMesa, FxU32 tmu, FxU32 size)
+{
+    struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+    struct TdfxSharedState *shared = (struct TdfxSharedState *) mesaShared->DriverData;
+    MemRange *prev, *block;
+    FxU32 result;
+    struct gl_texture_object *obj;
+
+    if (shared->umaTexMemory) {
+        assert(tmu == FX_TMU0);
+    }
+
+    _glthread_LOCK_MUTEX(mesaShared->Mutex);
+    while (1) {
+        prev = NULL;
+        block = shared->tmFree[tmu];
+        while (block) {
+            if (block->endAddr - block->startAddr >= size) {
+                /* The texture will fit here */
+                result = block->startAddr;
+                block->startAddr += size;
+                if (block->startAddr == block->endAddr) {
+                    /* Remove this node since it's empty */
+                    if (prev) {
+                        prev->next = block->next;
+                    }
+                    else {
+                        shared->tmFree[tmu] = block->next;
+                    }
+                    DELETE_RANGE_NODE(shared, block);
+                }
+                shared->freeTexMem[tmu] -= size;
+                _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+                return result;
+            }
+            prev = block;
+            block = block->next;
+        }
+        /* No free space. Discard oldest */
+        obj = FindOldestObject(fxMesa, tmu);
+        if (!obj) {
+            /*gl_problem(NULL, "fx Driver: No space for texture\n");*/
+            _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+            return BAD_ADDRESS;
+        }
+        fxTMMoveOutTM_NoLock(fxMesa, obj);
+        fxMesa->stats.texSwaps++;
+    }
+
+    /* never get here, but play it safe */
+    _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+    return BAD_ADDRESS;
+}
+
+
+/*
+ * Remove the given MemRange node from hardware texture memory.
+ */
+static void
+RemoveRange_NoLock(fxMesaContext fxMesa, FxU32 tmu, MemRange *range)
+{
+    struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+    struct TdfxSharedState *shared = (struct TdfxSharedState *) mesaShared->DriverData;
+    MemRange *block, *prev;
+
+    if (shared->umaTexMemory) {
+       assert(tmu == FX_TMU0);
+    }
+
+    if (!range)
+        return;
+
+    if (range->startAddr == range->endAddr) {
+        DELETE_RANGE_NODE(shared, range);
+        return;
+    }
+    shared->freeTexMem[tmu] += range->endAddr - range->startAddr;
+
+    /* find position in linked list to insert this MemRange node */
+    prev = NULL;
+    block = shared->tmFree[tmu];
+    while (block) {
+        if (range->startAddr > block->startAddr) {
+            prev = block;
+            block = block->next;
+        }
+        else {
+            break;
+        }
+    }
+
+    /* Insert the free block, combine with adjacent blocks when possible */
+    range->next = block;
+    if (block) {
+        if (range->endAddr == block->startAddr) {
+            /* Combine */
+            block->startAddr = range->startAddr;
+            DELETE_RANGE_NODE(shared, range);
+            range = block;
+        }
+    }
+    if (prev) {
+        if (prev->endAddr == range->startAddr) {
+            /* Combine */
+            prev->endAddr = range->endAddr;
+            prev->next = range->next;
+            DELETE_RANGE_NODE(shared, range);
+        }
+        else {
+            prev->next = range;
+        }
+    }
+    else {
+        shared->tmFree[tmu] = range;
+    }
+}
+
+
+static void
+RemoveRange(fxMesaContext fxMesa, FxU32 tmu, MemRange *range)
+{
+    struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+    _glthread_LOCK_MUTEX(mesaShared->Mutex);
+    RemoveRange_NoLock(fxMesa, tmu, range);
+    _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+}
+
+
+/*
+ * Allocate space for a texture image.
+ * <tmu> is the texture unit
+ * <texmemsize> is the number of bytes to allocate
+ */
+static MemRange *
+AllocTexMem(fxMesaContext fxMesa, FxU32 tmu, FxU32 texmemsize)
+{
+    FxU32 startAddr = FindStartAddr(fxMesa, tmu, texmemsize);
+    if (startAddr == BAD_ADDRESS) {
+        return NULL;
+    }
+    else {
+        MemRange *range;
+        range = NewRangeNode(fxMesa, startAddr, startAddr + texmemsize);
+        return range;
+    }
+}
+
+
+/*
+ * Download (copy) the given texture data into the Voodoo's texture memory.
+ * The texture memory must have already been allocated.
+ * Called by fxTMMoveInTM_NoLock() and fxTMRestoreTextures().
+ */
+static void
+DownloadTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj)
+{
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+    int i, l;
+    FxU32 targetTMU;
+
+    assert(tObj);
+    assert(ti);
+
+    targetTMU = ti->whichTMU;
+
+    switch (targetTMU) {
+    case FX_TMU0:
+    case FX_TMU1:
+        if (ti->tm[targetTMU]) {
+            for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
+                 i <= FX_smallLodValue(ti->info); i++, l++)
+                FX_grTexDownloadMipMapLevel_NoLock(targetTMU,
+                                                   ti->tm[targetTMU]->startAddr,
+                                                   FX_valueToLod(i),
+                                                   FX_largeLodLog2(ti->info),
+                                                   FX_aspectRatioLog2(ti->info),
+                                                   ti->info.format,
+                                                   GR_MIPMAPLEVELMASK_BOTH,
+                                                   ti->mipmapLevel[l].data);
+        }
+        break;
+    case FX_TMU_SPLIT:
+        if (ti->tm[FX_TMU0] && ti->tm[FX_TMU1]) {
+            for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
+                 i <= FX_smallLodValue(ti->info); i++, l++) {
+                FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
+                                                  ti->tm[FX_TMU0]->startAddr,
+                                                  FX_valueToLod(i),
+                                                  FX_largeLodLog2(ti->info),
+                                                  FX_aspectRatioLog2(ti->info),
+                                                  ti->info.format,
+                                                  GR_MIPMAPLEVELMASK_ODD,
+                                                  ti->mipmapLevel[l].data);
+
+                FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
+                                                  ti->tm[FX_TMU1]->startAddr,
+                                                  FX_valueToLod(i),
+                                                  FX_largeLodLog2(ti->info),
+                                                  FX_aspectRatioLog2(ti->info),
+                                                  ti->info.format,
+                                                  GR_MIPMAPLEVELMASK_EVEN,
+                                                  ti->mipmapLevel[l].data);
+            }
+        }
+        break;
+    case FX_TMU_BOTH:
+        if (ti->tm[FX_TMU0] && ti->tm[FX_TMU1]) {
+            for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
+                 i <= FX_smallLodValue(ti->info); i++, l++) {
+                FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
+                                                  ti->tm[FX_TMU0]->startAddr,
+                                                  FX_valueToLod(i),
+                                                  FX_largeLodLog2(ti->info),
+                                                  FX_aspectRatioLog2(ti->info),
+                                                  ti->info.format,
+                                                  GR_MIPMAPLEVELMASK_BOTH,
+                                                  ti->mipmapLevel[l].data);
+
+                FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
+                                                  ti->tm[FX_TMU1]->startAddr,
+                                                  FX_valueToLod(i),
+                                                  FX_largeLodLog2(ti->info),
+                                                  FX_aspectRatioLog2(ti->info),
+                                                  ti->info.format,
+                                                  GR_MIPMAPLEVELMASK_BOTH,
+                                                  ti->mipmapLevel[l].data);
+            }
+        }
+        break;
+    default:
+        fprintf(stderr,
+            "fx Driver: internal error in DownloadTexture -> bad tmu (%d)\n",
+            (int) targetTMU);
+        return;  /* used to abort here */
+    }
+}
+
+
+
+/*
+ * Allocate space for the given texture in texture memory then
+ * download (copy) it into that space.
+ */
+void
+fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj,
+                    FxU32 targetTMU)
+{
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+    FxU32 texmemsize;
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxTMMoveInTM(%d)\n", tObj->Name);
+    }
+
+    fxMesa->stats.reqTexUpload++;
+
+    if (!ti->validated) {
+        gl_problem(NULL,
+            "fx Driver: internal error in fxTMMoveInTM() -> not validated\n");
+        return;  /* used to abort here */
+    }
+
+    if (ti->isInTM) {
+        if (ti->whichTMU == targetTMU)
+            return;
+        if (targetTMU == FX_TMU_SPLIT || ti->whichTMU == FX_TMU_SPLIT) {
+            fxTMMoveOutTM_NoLock(fxMesa, tObj);
+        }
+        else {
+            if (ti->whichTMU == FX_TMU_BOTH)
+                return;
+            targetTMU = FX_TMU_BOTH;
+        }
+    }
+
+    if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) {
+        fprintf(stderr,
+                "fxmesa: downloading %x (%d) in texture memory in %d\n",
+                 tObj, tObj->Name, (int) targetTMU);
+    }
+
+    ti->whichTMU = targetTMU;
+
+    switch (targetTMU) {
+    case FX_TMU0:
+    case FX_TMU1:
+        texmemsize = FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
+                                                       &(ti->info));
+        ti->tm[targetTMU] = AllocTexMem(fxMesa, targetTMU, texmemsize);
+        DownloadTexture(fxMesa, tObj);
+        break;
+    case FX_TMU_SPLIT:
+        texmemsize = FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_ODD,
+                                                       &(ti->info));
+        ti->tm[FX_TMU0] = AllocTexMem(fxMesa, FX_TMU0, texmemsize);
+        if (ti->tm[FX_TMU0])
+           fxMesa->stats.memTexUpload += texmemsize;
+
+        texmemsize = FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_EVEN,
+                                                       &(ti->info));
+        ti->tm[FX_TMU1] = AllocTexMem(fxMesa, FX_TMU1, texmemsize);
+        DownloadTexture(fxMesa, tObj);
+        break;
+    case FX_TMU_BOTH:
+        texmemsize = FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
+                                                       &(ti->info));
+        ti->tm[FX_TMU0] = AllocTexMem(fxMesa, FX_TMU0, texmemsize);
+        if (ti->tm[FX_TMU0])
+           fxMesa->stats.memTexUpload += texmemsize;
+
+        texmemsize = FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
+                                                       &(ti->info));
+        ti->tm[FX_TMU1] = AllocTexMem(fxMesa, FX_TMU1, texmemsize);
+        DownloadTexture(fxMesa, tObj);
+        break;
+    default:
+        fprintf(stderr,
+            "fx Driver: internal error in fxTMMoveInTM() -> bad tmu (%d)\n",
+            (int) targetTMU);
+        return;  /* used to abort here */
+    }
+
+    fxMesa->stats.texUpload++;
+
+    ti->isInTM = GL_TRUE;
+}
+
+
+void
+fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj,
+             FxU32 targetTMU)
+{
+    BEGIN_BOARD_LOCK(fxMesa);
+    fxTMMoveInTM_NoLock(fxMesa, tObj, targetTMU);
+    END_BOARD_LOCK(fxMesa);
+}
+
+
+void
+fxTMReloadMipMapLevel(GLcontext *ctx, struct gl_texture_object *tObj,
+                      GLint level)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+    GrLOD_t lodlevel;
+    FxU32 tmu;
+
+    if (!ti->validated) {
+        gl_problem(ctx, "internal error in fxTMReloadMipMapLevel() -> not validated\n");
+        return;
+    }
+
+    tmu = ti->whichTMU;
+    fxTMMoveInTM(fxMesa, tObj, tmu);
+
+    fxTexGetInfo(ctx, ti->mipmapLevel[0].width, ti->mipmapLevel[0].height,
+                 &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
+#ifdef FX_GLIDE3
+    lodlevel -= level;
+#else
+    lodlevel += level;
+#endif
+    switch (tmu) {
+    case FX_TMU0:
+    case FX_TMU1:
+        FX_grTexDownloadMipMapLevel(fxMesa, tmu,
+                                    ti->tm[tmu]->startAddr,
+                                    FX_valueToLod(FX_lodToValue(lodlevel)),
+                                    FX_largeLodLog2(ti->info),
+                                    FX_aspectRatioLog2(ti->info),
+                                    ti->info.format,
+                                    GR_MIPMAPLEVELMASK_BOTH,
+                                    ti->mipmapLevel[level].data);
+        break;
+    case FX_TMU_SPLIT:
+        FX_grTexDownloadMipMapLevel(fxMesa, GR_TMU0,
+                                    ti->tm[GR_TMU0]->startAddr,
+                                    FX_valueToLod(FX_lodToValue(lodlevel)),
+                                    FX_largeLodLog2(ti->info),
+                                    FX_aspectRatioLog2(ti->info),
+                                    ti->info.format,
+                                    GR_MIPMAPLEVELMASK_ODD,
+                                    ti->mipmapLevel[level].data);
+
+        FX_grTexDownloadMipMapLevel(fxMesa, GR_TMU1,
+                                    ti->tm[GR_TMU1]->startAddr,
+                                    FX_valueToLod(FX_lodToValue(lodlevel)),
+                                    FX_largeLodLog2(ti->info),
+                                    FX_aspectRatioLog2(ti->info),
+                                    ti->info.format,
+                                    GR_MIPMAPLEVELMASK_EVEN,
+                                    ti->mipmapLevel[level].data);
+        break;
+    case FX_TMU_BOTH:
+        FX_grTexDownloadMipMapLevel(fxMesa, GR_TMU0,
+                                    ti->tm[GR_TMU0]->startAddr,
+                                    FX_valueToLod(FX_lodToValue(lodlevel)),
+                                    FX_largeLodLog2(ti->info),
+                                    FX_aspectRatioLog2(ti->info),
+                                    ti->info.format,
+                                    GR_MIPMAPLEVELMASK_BOTH,
+                                    ti->mipmapLevel[level].data);
+
+        FX_grTexDownloadMipMapLevel(fxMesa, GR_TMU1,
+                                    ti->tm[GR_TMU1]->startAddr,
+                                    FX_valueToLod(FX_lodToValue(lodlevel)),
+                                    FX_largeLodLog2(ti->info),
+                                    FX_aspectRatioLog2(ti->info),
+                                    ti->info.format,
+                                    GR_MIPMAPLEVELMASK_BOTH,
+                                    ti->mipmapLevel[level].data);
+        break;
+
+    default:
+        fprintf(stderr,
+                "fx Driver: internal error in fxTMReloadMipMapLevel() -> wrong tmu (%d)\n",
+                (int) tmu);
+        break;
+    }
+}
+
+#if	0
+/*
+ * This doesn't work.  It can't work for compressed textures.
+ */
+void
+fxTMReloadSubMipMapLevel(GLcontext *ctx,
+                         struct gl_texture_object *tObj,
+                         GLint level, GLint yoffset, GLint height)
+{
+    fxMesaContext fxMesa = FX_CONTEXT(ctx);
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+    GrLOD_t lodlevel;
+    unsigned short *data;
+    GLint tmu;
+
+    if (!ti->validated) {
+       gl_problem(ctx, "fx Driver: internal error in fxTMReloadSubMipMapLevel() -> not validated\n");
+       return;
+    }
+
+    tmu = (int) ti->whichTMU;
+    fxTMMoveInTM(fxMesa, tObj, tmu);
+
+    fxTexGetInfo(ctx, ti->mipmapLevel[0].width, ti->mipmapLevel[0].height,
+                 &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
+    data = ti->mipmapLevel[level].data +
+        yoffset * ti->mipmapLevel[level].width *
+        ti->mipmapLevel[level].texelSize;
+
+    switch (tmu) {
+    case FX_TMU0:
+    case FX_TMU1:
+        FX_grTexDownloadMipMapLevelPartial(fxMesa, tmu,
+                                           ti->tm[tmu]->startAddr,
+                                           FX_valueToLod(FX_lodToValue
+                                                         (lodlevel) + level),
+                                           FX_largeLodLog2(ti->info),
+                                           FX_aspectRatioLog2(ti->info),
+                                           ti->info.format,
+                                           GR_MIPMAPLEVELMASK_BOTH, data,
+                                           yoffset, yoffset + height - 1);
+        break;
+    case FX_TMU_SPLIT:
+        FX_grTexDownloadMipMapLevelPartial(fxMesa, GR_TMU0,
+                                           ti->tm[FX_TMU0]->startAddr,
+                                           FX_valueToLod(FX_lodToValue
+                                                         (lodlevel) + level),
+                                           FX_largeLodLog2(ti->info),
+                                           FX_aspectRatioLog2(ti->info),
+                                           ti->info.format,
+                                           GR_MIPMAPLEVELMASK_ODD, data,
+                                           yoffset, yoffset + height - 1);
+
+        FX_grTexDownloadMipMapLevelPartial(fxMesa, GR_TMU1,
+                                           ti->tm[FX_TMU1]->startAddr,
+                                           FX_valueToLod(FX_lodToValue
+                                                         (lodlevel) + level),
+                                           FX_largeLodLog2(ti->info),
+                                           FX_aspectRatioLog2(ti->info),
+                                           ti->info.format,
+                                           GR_MIPMAPLEVELMASK_EVEN, data,
+                                           yoffset, yoffset + height - 1);
+        break;
+    case FX_TMU_BOTH:
+        FX_grTexDownloadMipMapLevelPartial(fxMesa, GR_TMU0,
+                                           ti->tm[FX_TMU0]->startAddr,
+                                           FX_valueToLod(FX_lodToValue
+                                                         (lodlevel) + level),
+                                           FX_largeLodLog2(ti->info),
+                                           FX_aspectRatioLog2(ti->info),
+                                           ti->info.format,
+                                           GR_MIPMAPLEVELMASK_BOTH, data,
+                                           yoffset, yoffset + height - 1);
+
+        FX_grTexDownloadMipMapLevelPartial(fxMesa, GR_TMU1,
+                                           ti->tm[FX_TMU1]->startAddr,
+                                           FX_valueToLod(FX_lodToValue
+                                                         (lodlevel) + level),
+                                           FX_largeLodLog2(ti->info),
+                                           FX_aspectRatioLog2(ti->info),
+                                           ti->info.format,
+                                           GR_MIPMAPLEVELMASK_BOTH, data,
+                                           yoffset, yoffset + height - 1);
+        break;
+    default:
+        fprintf(stderr,
+                "fx Driver: internal error in fxTMReloadSubMipMapLevel() -> wrong tmu (%d)\n",
+                tmu);
+        return;
+    }
+}
+#endif
+
+
+/*
+ * Move the given texture out of hardware texture memory.
+ * This deallocates the texture's memory space.
+ */
+void
+fxTMMoveOutTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj)
+{
+    struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+    struct TdfxSharedState *shared = (struct TdfxSharedState *) mesaShared->DriverData;
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxTMMoveOutTM(%x (%d))\n", 
+		tObj, tObj->Name);
+    }
+
+    if (!ti->isInTM)
+        return;
+
+    switch (ti->whichTMU) {
+    case FX_TMU0:
+    case FX_TMU1:
+        RemoveRange_NoLock(fxMesa, ti->whichTMU, ti->tm[ti->whichTMU]);
+        break;
+    case FX_TMU_SPLIT:
+    case FX_TMU_BOTH:
+        assert(!shared->umaTexMemory);
+        RemoveRange_NoLock(fxMesa, FX_TMU0, ti->tm[FX_TMU0]);
+        RemoveRange_NoLock(fxMesa, FX_TMU1, ti->tm[FX_TMU1]);
+        break;
+    default:
+        fprintf(stderr, "fx Driver: internal error in fxTMMoveOutTM()\n");
+        return;
+    }
+
+    ti->isInTM = GL_FALSE;
+    ti->whichTMU = FX_TMU_NONE;
+}
+
+void
+fxTMMoveOutTM(fxMesaContext fxMesa, struct gl_texture_object *tObj)
+{
+    struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+    struct TdfxSharedState *shared = (struct TdfxSharedState *) mesaShared->DriverData;
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+
+    if (MESA_VERBOSE & VERBOSE_DRIVER) {
+        fprintf(stderr, "fxmesa: fxTMMoveOutTM(%x (%d))\n", 
+		tObj, tObj->Name);
+    }
+
+    if (!ti->isInTM)
+        return;
+
+    switch (ti->whichTMU) {
+    case FX_TMU0:
+    case FX_TMU1:
+        RemoveRange(fxMesa, ti->whichTMU, ti->tm[ti->whichTMU]);
+        break;
+    case FX_TMU_SPLIT:
+    case FX_TMU_BOTH:
+        assert(!shared->umaTexMemory);
+        RemoveRange(fxMesa, FX_TMU0, ti->tm[FX_TMU0]);
+        RemoveRange(fxMesa, FX_TMU1, ti->tm[FX_TMU1]);
+        break;
+    default:
+        fprintf(stderr, "fx Driver: internal error in fxTMMoveOutTM()\n");
+        return;
+    }
+
+    ti->isInTM = GL_FALSE;
+    ti->whichTMU = FX_TMU_NONE;
+}
+
+
+/*
+ * Called via glDeleteTexture to delete a texture object.
+ */
+void
+fxTMFreeTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj)
+{
+    tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+    if (ti) {
+        int i;
+        fxTMMoveOutTM(fxMesa, tObj);
+        for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+            if (ti->mipmapLevel[i].data) {
+                FREE(ti->mipmapLevel[i].data);
+                ti->mipmapLevel[i].data = NULL;
+            }
+        }
+        FREE(ti);
+        tObj->DriverData = NULL;
+    }
+}
+
+
+/*
+ * Initialize texture memory.
+ * We take care of one or both TMU's here.
+ */
+void
+fxTMInit(fxMesaContext fxMesa)
+{
+    if (!fxMesa->glCtx->Shared->DriverData) {
+        const char *extensions;
+        struct TdfxSharedState *shared = CALLOC_STRUCT(TdfxSharedState);
+        if (!shared)
+           return;
+
+        extensions = FX_grGetString(fxMesa, GR_EXTENSION);
+        if (strstr(extensions, "TEXUMA")) {
+            FxU32 start, end;
+            shared->umaTexMemory = GL_TRUE;
+            FX_grEnable(fxMesa, GR_TEXTURE_UMA_EXT);
+            start = FX_grTexMinAddress(fxMesa, 0);
+            end = FX_grTexMaxAddress(fxMesa, 0);
+            shared->totalTexMem[0] = end - start;
+            shared->totalTexMem[1] = 0;
+            shared->freeTexMem[0] = end - start;
+            shared->tmFree[0] = NewRangeNode(fxMesa, start, end);
+            /*printf("UMA tex memory: %d\n", (int) (end - start));*/
+        }
+        else {
+            const int numTMUs = fxMesa->haveTwoTMUs ? 2 : 1;
+            int tmu;
+            shared->umaTexMemory = GL_FALSE;
+            for (tmu = 0; tmu < numTMUs; tmu++) {
+                FxU32 start = FX_grTexMinAddress(fxMesa, tmu);
+                FxU32 end = FX_grTexMaxAddress(fxMesa, tmu);
+                shared->totalTexMem[tmu] = end - start;
+                shared->freeTexMem[tmu] = end - start;
+                shared->tmFree[tmu] = NewRangeNode(fxMesa, start, end);
+                /*printf("Split tex memory: %d\n", (int) (end - start));*/
+            }
+        }
+
+        shared->tmPool = NULL;
+        fxMesa->glCtx->Shared->DriverData = shared;
+        /*printf("Texture memory init UMA: %d\n", shared->umaTexMemory);*/
+    }        
+}
+
+
+/*
+ * Clean-up texture memory before destroying context.
+ */
+void
+fxTMClose(fxMesaContext fxMesa)
+{
+    if (fxMesa->glCtx->Shared->RefCount == 1) {
+        /* refcount will soon go to zero, free our 3dfx stuff */
+        struct TdfxSharedState *shared = (struct TdfxSharedState *) fxMesa->glCtx->Shared->DriverData;
+
+        const int numTMUs = fxMesa->haveTwoTMUs ? 2 : 1;
+        int tmu;
+        MemRange *tmp, *next;
+
+        /* Deallocate the pool of free MemRange nodes */
+        tmp = shared->tmPool;
+        while (tmp) {
+            next = tmp->next;
+            FREE(tmp);
+            tmp = next;
+        }
+
+        /* Delete the texture memory block MemRange nodes */
+        for (tmu = 0; tmu < numTMUs; tmu++) {
+            tmp = shared->tmFree[tmu];
+            while (tmp) {
+                next = tmp->next;
+                FREE(tmp);
+                tmp = next;
+            }
+        }
+
+        FREE(shared);
+        fxMesa->glCtx->Shared->DriverData = NULL;
+    }
+}
+
+
+/*
+ * After a context switch this function will be called to restore
+ * texture memory for the new context.
+ */
+void
+fxTMRestoreTextures_NoLock(fxMesaContext ctx)
+{
+    struct gl_texture_object *tObj;
+
+    for (tObj = ctx->glCtx->Shared->TexObjectList; tObj; tObj = tObj->Next) {
+        tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+        if (ti && ti->isInTM) {
+            int i;
+            for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+                if (ctx->glCtx->Texture.Unit[i].Current == tObj) {
+                    DownloadTexture(ctx, tObj);
+                    break;
+                }
+            }
+            if (i == MAX_TEXTURE_UNITS) {
+                fxTMMoveOutTM_NoLock(ctx, tObj);
+            }
+        }
+    }
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxtexman.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxtexman.h:1.2
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxtexman.h	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,29 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxtexman.h,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+#ifndef FXTEXMAN_H
+#define FXTEXMAN_H
+
+
+#define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData))
+
+extern void fxTMReloadMipMapLevel(GLcontext *, struct gl_texture_object *,
+                                  GLint);
+extern void fxTMReloadSubMipMapLevel(GLcontext *,
+                                     struct gl_texture_object *, GLint, GLint,
+                                     GLint);
+
+extern void fxTMInit(fxMesaContext ctx);
+
+extern void fxTMClose(fxMesaContext ctx);
+
+extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx);
+
+extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, FxU32);
+
+extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
+
+extern void fxTMMoveOutTM_NoLock(fxMesaContext, struct gl_texture_object *);
+
+extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
+
+
+#endif
Index: xc/lib/GL/mesa/src/drv/tdfx/fxtrifuncs.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxtrifuncs.c:1.1
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxtrifuncs.c	Sun Sep 24 09:51:20 2000
@@ -0,0 +1,365 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxtrifuncs.c,v 1.1 2000/09/24 13:51:20 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* fxtris.c - 3Dfx VooDoo triangle functions */
+
+
+#include "fxdrv.h"
+#include "../mmath.h"
+
+
+
+/* Is this enough?  Do we need more triangle funcs?  
+ */
+static triangle_func tri_tab[0x40]; /* only 0x20 actually used */
+static quad_func quad_tab[0x40]; /* only 0x20 actually used */
+static line_func line_tab[0x40]; /* less than 0x20 used */
+static points_func points_tab[0x40]; /* less than 0x20 used */
+
+#define IND (0)
+#define TAG(x) x
+#include "fxtritmp.h"
+
+#define IND (FX_OFFSET)
+#define TAG(x) x##_offset
+#include "fxtritmp.h"
+
+#define IND (FX_TWOSIDE)
+#define TAG(x) x##_twoside
+#include "fxtritmp.h"
+
+#define IND (FX_TWOSIDE|FX_OFFSET)
+#define TAG(x) x##_twoside_offset
+#include "fxtritmp.h"
+
+#define IND (FX_FRONT_BACK)
+#define TAG(x) x##_front_back
+#include "fxtritmp.h"
+
+#define IND (FX_FRONT_BACK|FX_OFFSET)
+#define TAG(x) x##_front_back_offset
+#include "fxtritmp.h"
+
+#define IND (FX_FRONT_BACK|FX_TWOSIDE)
+#define TAG(x) x##_front_back_twoside
+#include "fxtritmp.h"
+
+#define IND (FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
+#define TAG(x) x##_front_back_twoside_offset
+#include "fxtritmp.h"
+
+#define IND (FX_FLAT)
+#define TAG(x) x##_flat
+#include "fxtritmp.h"
+
+#define IND (FX_FLAT|FX_OFFSET)
+#define TAG(x) x##_flat_offset
+#include "fxtritmp.h"
+
+#define IND (FX_FLAT|FX_TWOSIDE)
+#define TAG(x) x##_flat_twoside
+#include "fxtritmp.h"
+
+#define IND (FX_FLAT|FX_TWOSIDE|FX_OFFSET)
+#define TAG(x) x##_flat_twoside_offset
+#include "fxtritmp.h"
+
+#define IND (FX_FLAT|FX_FRONT_BACK)
+#define TAG(x) x##_flat_front_back
+#include "fxtritmp.h"
+
+#define IND (FX_FLAT|FX_FRONT_BACK|FX_OFFSET)
+#define TAG(x) x##_flat_front_back_offset
+#include "fxtritmp.h"
+
+#define IND (FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE)
+#define TAG(x) x##_flat_front_back_twoside
+#include "fxtritmp.h"
+
+#define IND (FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
+#define TAG(x) x##_flat_front_back_twoside_offset
+#include "fxtritmp.h"
+
+/* We don't actually do antialiasing correctly. Geometry has to be
+   sorted for glide's antialiasing to operate */
+#if 0
+#define IND (FX_ANTIALIAS)
+#define TAG(x) x##_aa
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_OFFSET)
+#define TAG(x) x##_aa_offset
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_TWOSIDE)
+#define TAG(x) x##_aa_twoside
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_TWOSIDE|FX_OFFSET)
+#define TAG(x) x##_aa_twoside_offset
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FRONT_BACK)
+#define TAG(x) x##_aa_front_back
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FRONT_BACK|FX_OFFSET)
+#define TAG(x) x##_aa_front_back_offset
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FRONT_BACK|FX_TWOSIDE)
+#define TAG(x) x##_aa_front_back_twoside
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
+#define TAG(x) x##_aa_front_back_twoside_offset
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FLAT)
+#define TAG(x) x##_aa_flat
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FLAT|FX_OFFSET)
+#define TAG(x) x##_aa_flat_offset
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FLAT|FX_TWOSIDE)
+#define TAG(x) x##_aa_flat_twoside
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FLAT|FX_TWOSIDE|FX_OFFSET)
+#define TAG(x) x##_aa_flat_twoside_offset
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK)
+#define TAG(x) x##_aa_flat_front_back
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK|FX_OFFSET)
+#define TAG(x) x##_aa_flat_front_back_offset
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE)
+#define TAG(x) x##_aa_flat_front_back_twoside
+#include "fxtritmp.h"
+
+#define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
+#define TAG(x) x##_aa_flat_front_back_twoside_offset
+#include "fxtritmp.h"
+#endif
+
+void
+fxDDTrifuncInit()
+{
+    init();
+    init_offset();
+    init_twoside();
+    init_twoside_offset();
+    init_front_back();
+    init_front_back_offset();
+    init_front_back_twoside();
+    init_front_back_twoside_offset();
+    init_flat();
+    init_flat_offset();
+    init_flat_twoside();
+    init_flat_twoside_offset();
+    init_flat_front_back();
+    init_flat_front_back_offset();
+    init_flat_front_back_twoside();
+    init_flat_front_back_twoside_offset();
+#if 0
+    init_aa();
+    init_aa_offset();
+    init_aa_twoside();
+    init_aa_twoside_offset();
+    init_aa_front_back();
+    init_aa_front_back_offset();
+    init_aa_front_back_twoside();
+    init_aa_front_back_twoside_offset();
+    init_aa_flat();
+    init_aa_flat_offset();
+    init_aa_flat_twoside();
+    init_aa_flat_twoside_offset();
+    init_aa_flat_front_back();
+    init_aa_flat_front_back_offset();
+    init_aa_flat_front_back_twoside();
+    init_aa_flat_front_back_twoside_offset();
+#endif
+}
+
+void
+fxPrintRenderState(const char *msg, GLuint state)
+{
+    fprintf(stderr, "%s: (%x) %s%s%s%s%s%s\n",
+            msg, state,
+            (state & FX_ANTIALIAS) ? "antialias, " : "",
+            (state & FX_FLAT) ? "flat, " : "",
+            (state & FX_TWOSIDE) ? "twoside, " : "",
+            (state & FX_OFFSET) ? "offset, " : "",
+            (state & FX_FRONT_BACK) ? "front-back, " : "",
+            (state & FX_FALLBACK) ? "fallback" : "");
+}
+
+
+void
+fxPrintHintState(const char *msg, GLuint state)
+{
+    fprintf(stderr, "%s: (%x) %s %s%s %s%s\n",
+            msg, state,
+            (state & GR_STWHINT_W_DIFF_FBI) ? "w-fbi, " : "",
+            (state & GR_STWHINT_W_DIFF_TMU0) ? "w-tmu0, " : "",
+            (state & GR_STWHINT_ST_DIFF_TMU0) ? "st-tmu0, " : "",
+            (state & GR_STWHINT_W_DIFF_TMU1) ? "w-tmu1, " : "",
+            (state & GR_STWHINT_ST_DIFF_TMU1) ? "st-tmu1, " : "");
+
+}
+
+
+void
+fxDDChooseRenderState(GLcontext * ctx)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint ind = 0;
+    GLuint flags = ctx->TriangleCaps;
+
+    ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
+
+    if (flags) {
+        if (fxMesa->render_index & FX_OFFSET)
+            FX_grDepthBiasLevel(fxMesa, 0);
+
+        if (flags & (DD_SELECT | DD_FEEDBACK)) {
+            fxMesa->PointsFunc = 0;
+            fxMesa->LineFunc = 0;
+            fxMesa->TriangleFunc = 0;
+            fxMesa->QuadFunc = 0;
+            fxMesa->render_index = FX_FALLBACK;
+            ctx->IndirectTriangles |= DD_SW_RASTERIZE;
+#if 0
+            fprintf(stderr, "Fallback select|feeback\n");
+#endif
+            return;
+        }
+
+        if (flags & DD_FLATSHADE)
+            ind |= FX_FLAT;
+        if (flags & DD_TRI_LIGHT_TWOSIDE)
+            ind |= FX_TWOSIDE;
+#if 000
+        /* XXX this is rather broken, don't use it. */
+        if (flags & DD_MULTIDRAW)
+            ind |= FX_FRONT_BACK;
+#else
+        if (flags & DD_MULTIDRAW)
+            ctx->IndirectTriangles |= DD_SW_RASTERIZE;
+#endif
+
+        if (flags & (DD_POINT_ATTEN | DD_POINT_SMOOTH)) {
+            ind |= FX_FALLBACK;
+#if 0
+            if (flags & DD_POINT_ATTEN)
+                fprintf(stderr, "Fallback point atten\n");
+            if (flags & DD_POINT_SMOOTH)
+                fprintf(stderr, "Fallback point smooth\n");
+#endif
+        }
+
+        fxMesa->render_index = ind;
+        fxMesa->PointsFunc = points_tab[ind];
+        if (ind & FX_FALLBACK)
+            ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
+        ind &= ~(FX_ANTIALIAS | FX_FALLBACK);
+
+        if (flags & (DD_LINE_STIPPLE | DD_LINE_SMOOTH)) {
+            ind |= FX_FALLBACK;
+#if 0
+            if (flags & DD_LINE_STIPPLE)
+                fprintf(stderr, "Fallback line stipple\n");
+            if (flags & DD_LINE_SMOOTH)
+                fprintf(stderr, "Fallback line smooth\n");
+#endif
+        }
+
+        fxMesa->render_index |= ind;
+        fxMesa->LineFunc = line_tab[ind];
+        if (ind & FX_FALLBACK)
+            ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
+        ind &= ~(FX_ANTIALIAS | FX_FALLBACK);
+
+        if (flags & DD_TRI_OFFSET)
+            ind |= FX_OFFSET;
+        if (flags & (DD_TRI_UNFILLED | DD_TRI_STIPPLE | DD_TRI_SMOOTH)) {
+            ind |= FX_FALLBACK;
+#if 0
+            if (flags & DD_TRI_UNFILLED)
+                fprintf(stderr, "Fallback tri unfilled\n");
+            if (flags & DD_TRI_STIPPLE)
+                fprintf(stderr, "Fallback tri stippled\n");
+            if (flags & DD_TRI_SMOOTH)
+                fprintf(stderr, "Fallback tri smooth\n");
+#endif
+        }
+
+        fxMesa->render_index |= ind;
+        fxMesa->TriangleFunc = tri_tab[ind];
+        fxMesa->QuadFunc = quad_tab[ind];
+
+        if (ind & FX_FALLBACK)
+            ctx->IndirectTriangles |=
+                DD_TRI_SW_RASTERIZE | DD_QUAD_SW_RASTERIZE;
+    }
+    else if (fxMesa->render_index) {
+        if (fxMesa->render_index & FX_OFFSET)
+            FX_grDepthBiasLevel(fxMesa, 0);
+
+        fxMesa->render_index = 0;
+        fxMesa->PointsFunc = points_tab[0];
+        fxMesa->LineFunc = line_tab[0];
+        fxMesa->TriangleFunc = tri_tab[0];
+        fxMesa->QuadFunc = quad_tab[0];
+    }
+
+    if (MESA_VERBOSE & (VERBOSE_STATE | VERBOSE_DRIVER))
+        fxPrintRenderState("fxmesa: Render state", fxMesa->render_index);
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxtritmp.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxtritmp.h:1.3
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxtritmp.h	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,441 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxtritmp.h,v 1.3 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+static void TAG(fx_tri) (GLcontext * ctx, GLuint e1, GLuint e2, GLuint e3,
+                         GLuint pv)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    struct vertex_buffer *VB = ctx->VB;
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+    GrVertex *v1 = (GrVertex *) gWin[e1].f;
+    GrVertex *v2 = (GrVertex *) gWin[e2].f;
+    GrVertex *v3 = (GrVertex *) gWin[e3].f;
+
+    (void) fxMesa;
+
+    if (IND & (FX_TWOSIDE | FX_OFFSET)) {
+        GLfloat ex = v1->x - v3->x;
+        GLfloat ey = v1->y - v3->y;
+        GLfloat fx = v2->x - v3->x;
+        GLfloat fy = v2->y - v3->y;
+        GLfloat c = ex * fy - ey * fx;
+
+        if (IND & FX_TWOSIDE) {
+            GLuint facing = (c < 0.0) ^ ctx->Polygon.FrontBit;
+            GLubyte(*color)[4] = VB->Color[facing]->data;
+            if (IND & FX_FLAT) {
+                GOURAUD2(v1, color[pv]);
+                GOURAUD2(v2, color[pv]);
+                GOURAUD2(v3, color[pv]);
+            }
+            else {
+                GOURAUD2(v1, color[e1]);
+                GOURAUD2(v2, color[e2]);
+                GOURAUD2(v3, color[e3]);
+            }
+        }
+
+        /* Should apply a factor to ac to compensate for different x/y
+         * scaling introduced in the Viewport matrix.
+         *
+         * The driver should supply scaling factors for 'factor' and 'units'.
+         */
+        if (IND & FX_OFFSET) {
+            GLfloat offset = ctx->Polygon.OffsetUnits;
+
+            if (c * c > 1e-16) {
+                GLfloat factor = ctx->Polygon.OffsetFactor;
+                GLfloat ez = v1->ooz - v3->ooz;
+                GLfloat fz = v2->ooz - v3->ooz;
+                GLfloat a = ey * fz - ez * fy;
+                GLfloat b = ez * fx - ex * fz;
+                GLfloat ic = 1.0 / c;
+                GLfloat ac = a * ic;
+                GLfloat bc = b * ic;
+                if (ac < 0.0F)
+                    ac = -ac;
+                if (bc < 0.0F)
+                    bc = -bc;
+                offset += MAX2(ac, bc) * factor;
+            }
+            /* Probably a lot quicker just to nudge the z values and put
+             * them back afterwards.
+             */
+            FX_grDepthBiasLevel(fxMesa, (int) offset);
+        }
+    }
+    else if (IND & FX_FLAT) {
+        GLubyte(*color)[4] = VB->Color[0]->data;
+        GOURAUD2(v1, color[pv]);
+        GOURAUD2(v2, color[pv]);
+        GOURAUD2(v3, color[pv]);
+    }
+
+    if (IND & FX_FRONT_BACK) {
+        FX_grColorMaskv(ctx, ctx->Color.ColorMask);
+        FX_grDepthMask(fxMesa, FXFALSE);
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_BACKBUFFER);
+    }
+
+    if (IND & FX_ANTIALIAS)
+        FX_grAADrawTriangle(fxMesa, v1, v2, v3, FXTRUE, FXTRUE, FXTRUE);
+    else
+        FX_grDrawTriangle(fxMesa, v1, v2, v3);
+
+    /* Might be quicker to do two passes, one for each buffer?
+     */
+    if (IND & FX_FRONT_BACK) {
+        FX_grColorMaskv(ctx, ctx->Color.ColorMask);
+
+        if (ctx->Depth.Mask)
+            FX_grDepthMask(fxMesa, FXTRUE);
+
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_FRONTBUFFER);
+
+        if (IND & FX_ANTIALIAS)
+            FX_grAADrawTriangle(fxMesa, v1, v2, v3, FXTRUE, FXTRUE, FXTRUE);
+        else
+            FX_grDrawTriangle(fxMesa, v1, v2, v3);
+    }
+}
+
+
+/* Not worth the space?
+ */
+static void TAG(fx_quad) (GLcontext * ctx, GLuint e1, GLuint e2, GLuint e3,
+                          GLuint e4, GLuint pv)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    struct vertex_buffer *VB = ctx->VB;
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+    GrVertex *v1 = (GrVertex *) gWin[e1].f;
+    GrVertex *v2 = (GrVertex *) gWin[e2].f;
+    GrVertex *v3 = (GrVertex *) gWin[e3].f;
+    GrVertex *v4 = (GrVertex *) gWin[e4].f;
+
+    (void) fxMesa;
+
+    if (IND & (FX_TWOSIDE | FX_OFFSET)) {
+        GLfloat ex = v3->x - v1->x;
+        GLfloat ey = v3->y - v1->y;
+        GLfloat fx = v4->x - v2->x;
+        GLfloat fy = v4->y - v2->y;
+        GLfloat c = ex * fy - ey * fx;
+
+        if (IND & FX_TWOSIDE) {
+            GLuint facing = (c < 0.0) ^ ctx->Polygon.FrontBit;
+            GLubyte(*color)[4] = VB->Color[facing]->data;
+            if (IND & FX_FLAT) {
+                GOURAUD2(v1, color[pv]);
+                GOURAUD2(v2, color[pv]);
+                GOURAUD2(v3, color[pv]);
+                GOURAUD2(v4, color[pv]);
+            }
+            else {
+                GOURAUD2(v1, color[e1]);
+                GOURAUD2(v2, color[e2]);
+                GOURAUD2(v3, color[e3]);
+                GOURAUD2(v4, color[e4]);
+            }
+        }
+
+        /* Should apply a factor to ac to compensate for different x/y
+         * scaling introduced in the Viewport matrix.
+         *
+         * The driver should supply scaling factors for 'factor' and 'units'.
+         */
+        if (IND & FX_OFFSET) {
+            GLfloat offset = ctx->Polygon.OffsetUnits;
+
+            if (c * c > 1e-16) {
+                GLfloat factor = ctx->Polygon.OffsetFactor;
+                GLfloat ez = v3->ooz - v1->ooz;
+                GLfloat fz = v4->ooz - v2->ooz;
+                GLfloat a = ey * fz - ez * fy;
+                GLfloat b = ez * fx - ex * fz;
+                GLfloat ic = 1.0 / c;
+                GLfloat ac = a * ic;
+                GLfloat bc = b * ic;
+                if (ac < 0.0F)
+                    ac = -ac;
+                if (bc < 0.0F)
+                    bc = -bc;
+                offset += MAX2(ac, bc) * factor;
+            }
+            /* Probably a lot quicker just to nudge the z values and put
+             * them back afterwards.
+             */
+            FX_grDepthBiasLevel(fxMesa, (int) offset);
+        }
+    }
+    else if (IND & FX_FLAT) {
+        GLubyte(*color)[4] = VB->Color[0]->data;
+        GOURAUD2(v1, color[pv]);
+        GOURAUD2(v2, color[pv]);
+        GOURAUD2(v3, color[pv]);
+        GOURAUD2(v4, color[pv]);
+    }
+
+    if (IND & FX_FRONT_BACK) {
+        FX_grColorMaskv(ctx, ctx->Color.ColorMask);
+        FX_grDepthMask(fxMesa, FXFALSE);
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_BACKBUFFER);
+    }
+
+    if (IND & FX_ANTIALIAS) {
+        FX_grAADrawTriangle(fxMesa, v1, v2, v4, FXTRUE, FXTRUE, FXTRUE);
+        FX_grAADrawTriangle(fxMesa, v2, v3, v4, FXTRUE, FXTRUE, FXTRUE);
+    }
+    else {
+        FX_grDrawTriangle(fxMesa, v1, v2, v4);
+        FX_grDrawTriangle(fxMesa, v2, v3, v4);
+    }
+
+    /* Might be quicker to do two passes, one for each buffer?
+     */
+    if (IND & FX_FRONT_BACK) {
+        FX_grColorMaskv(ctx, ctx->Color.ColorMask);
+
+        if (ctx->Depth.Mask)
+            FX_grDepthMask(fxMesa, FXTRUE);
+
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_FRONTBUFFER);
+
+        if (IND & FX_ANTIALIAS) {
+            FX_grAADrawTriangle(fxMesa, v1, v2, v4, FXTRUE, FXTRUE, FXTRUE);
+            FX_grAADrawTriangle(fxMesa, v2, v3, v4, FXTRUE, FXTRUE, FXTRUE);
+        }
+        else {
+            FX_grDrawTriangle(fxMesa, v1, v2, v4);
+            FX_grDrawTriangle(fxMesa, v2, v3, v4);
+        }
+    }
+}
+
+#define DRAW_LINE(fxMesa, tmp0, tmp1, width)		\
+  if (width <= 1.0) {					\
+    FX_grDrawLine(fxMesa, tmp0, tmp1);			\
+  }							\
+  else {						\
+    GrVertex verts[4];					\
+    float dx, dy, ix, iy;				\
+							\
+    dx = tmp0->x - tmp1->x;				\
+    dy = tmp0->y - tmp1->y;				\
+							\
+    if (dx * dx > dy * dy) {				\
+      iy = width * .5;					\
+      ix = 0;						\
+    }							\
+    else {						\
+      iy = 0;						\
+      ix = width * .5;					\
+    }							\
+							\
+    verts[0] = *tmp0;					\
+    verts[1] = *tmp0;					\
+    verts[2] = *tmp1;					\
+    verts[3] = *tmp1;					\
+							\
+    verts[0].x = tmp0->x - ix;				\
+    verts[0].y = tmp0->y - iy;				\
+							\
+    verts[1].x = tmp0->x + ix;				\
+    verts[1].y = tmp0->y + iy;				\
+							\
+    verts[2].x = tmp1->x + ix;				\
+    verts[2].y = tmp1->y + iy;				\
+							\
+    verts[3].x = tmp1->x - ix;				\
+    verts[3].y = tmp1->y - iy;				\
+							\
+    FX_grDrawPolygonVertexList(fxMesa, 4, verts);	\
+  }
+
+
+#if (IND & FX_OFFSET) == 0
+static void TAG(fx_line) (GLcontext * ctx, GLuint e1, GLuint e2, GLuint pv)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    struct vertex_buffer *VB = ctx->VB;
+    fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+    GLubyte(*const color)[4] = VB->ColorPtr->data;
+    GrVertex *v1 = (GrVertex *) gWin[e1].f;
+    GrVertex *v2 = (GrVertex *) gWin[e2].f;
+    GLfloat w = ctx->Line.Width * .5;
+
+    if (IND & FX_FLAT) {
+        GOURAUD2(v1, color[pv]);
+        GOURAUD2(v2, color[pv]);
+    }
+    else if (IND & FX_TWOSIDE) {
+        /* XXX use signed area of the polygon to determine front/back color choice */
+        GOURAUD2(v1, color[e1]);
+        GOURAUD2(v2, color[e2]);
+    }
+
+    if (IND & FX_FRONT_BACK) {
+        FX_grColorMaskv(ctx, ctx->Color.ColorMask);
+        FX_grDepthMask(fxMesa, FXFALSE);
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_BACKBUFFER);
+    }
+
+    if (IND & FX_ANTIALIAS)
+        FX_grAADrawLine(fxMesa, v1, v2);
+    else
+        DRAW_LINE(fxMesa, v1, v2, w);
+
+    if (IND & FX_FRONT_BACK) {
+        FX_grColorMaskv(ctx, ctx->Color.ColorMask);
+
+        if (ctx->Depth.Mask)
+            FX_grDepthMask(fxMesa, FXTRUE);
+
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_FRONTBUFFER);
+
+        if (IND & FX_ANTIALIAS)
+            FX_grAADrawLine(fxMesa, v1, v2);
+        else
+            DRAW_LINE(fxMesa, v1, v2, w);
+    }
+}
+#endif
+
+
+#if (IND & FX_OFFSET) == 0
+
+/*
+ * Draw large points (size > 1) with a polygon.
+ */
+#define DRAW_POINT(i, radius, color)				\
+    do {							\
+	GrVertex verts[4], *tmp;				\
+	tmp = (GrVertex *) gWin[i].f;				\
+        GOURAUD2(tmp, color);                                   \
+	verts[0] = *tmp;					\
+	verts[1] = *tmp;					\
+	verts[2] = *tmp;					\
+	verts[3] = *tmp;					\
+	verts[0].x = verts[3].x = tmp->x + radius;		\
+	verts[0].y = verts[1].y = tmp->y + radius;		\
+	verts[2].x = verts[1].x = tmp->x - radius;		\
+	verts[2].y = verts[3].y = tmp->y - radius;		\
+	FX_grDrawPolygonVertexList(fxMesa, 4, verts);		\
+    } while (0)
+
+
+static void TAG(fx_points) (GLcontext * ctx, GLuint first, GLuint last)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    const struct vertex_buffer *VB = ctx->VB;
+    const fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+    GLubyte (*color)[4] = VB->ColorPtr->data;
+    GLuint i;
+    const GLfloat radius = ctx->Point.Size * .5;
+
+    (void) color;
+    (void) fxMesa;
+
+    if (IND & FX_FRONT_BACK) {
+        FX_grColorMaskv(ctx, ctx->Color.ColorMask);
+        FX_grDepthMask(fxMesa, FXFALSE);
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_BACKBUFFER);
+    }
+
+    if (!VB->ClipOrMask) {
+        for (i = first; i <= last; i++) {
+            DRAW_POINT(i, radius, color[i]);
+        }
+    }
+    else {
+        for (i = first; i <= last; i++) {
+            if (VB->ClipMask[i] == 0) {
+                DRAW_POINT(i, radius, color[i]);
+            }
+        }
+    }
+
+    if (IND & FX_FRONT_BACK) {
+        FX_grColorMaskv(ctx, ctx->Color.ColorMask);
+        if (ctx->Depth.Mask)
+            FX_grDepthMask(fxMesa, FXTRUE);
+        FX_grRenderBuffer(fxMesa, GR_BUFFER_FRONTBUFFER);
+
+        if (!VB->ClipOrMask) {
+            for (i = first; i <= last; i++) {
+                DRAW_POINT(i, radius, color[i]);
+            }
+        }
+        else {
+            for (i = first; i <= last; i++) {
+                if (VB->ClipMask[i] == 0) {
+                    DRAW_POINT(i, radius, color[i]);
+                }
+            }
+        }
+    }
+}
+
+#endif
+
+
+
+static void TAG(init) (void)
+{
+    tri_tab[IND] = TAG(fx_tri);
+    quad_tab[IND] = TAG(fx_quad);
+
+#if ((IND & FX_OFFSET) == 0)
+    line_tab[IND] = TAG(fx_line);
+    points_tab[IND] = TAG(fx_points);
+#else
+    line_tab[IND] = line_tab[IND & ~FX_OFFSET];
+    points_tab[IND] = points_tab[IND & ~FX_OFFSET];
+#endif
+}
+
+#undef IND
+#undef TAG
+#undef FLAT_COLOR
+#undef DRAW_POINT
Index: xc/lib/GL/mesa/src/drv/tdfx/fxvs_tmp.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxvs_tmp.h:1.1
--- /dev/null	Mon Dec 18 14:23:42 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxvs_tmp.h	Sun Sep 24 09:51:20 2000
@@ -0,0 +1,215 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxvs_tmp.h,v 1.1 2000/09/24 13:51:20 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#if (IND & (SETUP_XY|SETUP_W|SETUP_Z))
+#define V1 VARS_XY
+#define I1 , INCR_XY
+#else
+#define V1
+#define I1
+#endif
+
+#if (IND & SETUP_XY)
+#define S1 DO_SETUP_XY
+#else
+#define S1
+#endif
+
+#if (IND & SETUP_W)
+#define S2 S1 DO_SETUP_W
+#define V2 V1 VARS_W
+#else
+#define S2 S1
+#define V2 V1
+#endif
+
+#if (IND & SETUP_Z)
+#define S3 S2 DO_SETUP_Z
+#else
+#define S3 S2
+#endif
+
+#if (IND & SETUP_RGBA)
+#define V4 V2 VARS_RGBA
+#define S4 S3 DO_SETUP_RGBA
+#define I4 I1 , INCR_RGBA
+#else
+#define V4 V2
+#define S4 S3
+#define I4 I1
+#endif
+
+#if (IND & SETUP_TMU0)
+#define V5 V4 VARS_TMU0
+#define S5 S4 DO_SETUP_TMU0
+#define I5 I4 , INCR_TMU0
+#define F5    FIXUP_TMU0
+#else
+#define V5 V4
+#define S5 S4
+#define I5 I4
+#define F5
+#endif
+
+#if (IND & SETUP_TMU1)
+#define V6 V5 VARS_TMU1
+#define S6 S5 DO_SETUP_TMU1
+#define I6 I5 , INCR_TMU1
+#define F6 F5 FIXUP_TMU1
+#else
+#define V6 V5
+#define S6 S5
+#define I6 I5
+#define F6 F5
+#endif
+
+#if (IND & SETUP_TMU0) && (IND & SETUP_TMU1)
+#define F7 FIXUP_TMU01
+#else
+#define F7 F6
+#endif
+
+#define VARS V6
+#define DO_SETUP S6
+#define INCR I6
+#define FIXUP F7
+
+static void
+NAME(struct vertex_buffer *VB, GLuint start, GLuint end)
+{
+    GLcontext *ctx = VB->ctx;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    if (fxMesa->new_state)
+        fxSetupFXUnits(ctx);
+
+    {
+        const float snapper = (3L << 18);
+        fxVertex *gWin = FX_DRIVER_DATA(VB)->verts;
+        GLfloat *v = gWin[start].f;
+        GLfloat *vend = gWin[end].f;
+        VARS;
+
+        (void) gWin;
+        (void) fxMesa;
+        (void) snapper;
+
+        if (VB->ClipOrMask) {
+            GLubyte *clipmask = &VB->ClipMask[start];
+            for (; v != vend; v += 16, clipmask++ INCR) {
+                if (*clipmask == 0) {
+                    DO_SETUP;
+                }
+            }
+        }
+        else {
+            for (; v != vend; v += 16 INCR) {
+                DO_SETUP;
+            }
+        }
+
+        if (ctx->FogMode == FOG_FRAGMENT
+            && ctx->ProjectionMatrix.m[15] != 0.0F) {
+            /* need to compute W values for fogging purposes */
+            const GLfloat m10 = ctx->ProjectionMatrix.m[10];
+            const GLfloat m14 = ctx->ProjectionMatrix.m[14];
+            const GLfloat v10 = ctx->Viewport.WindowMap.m[10];
+            const GLfloat v14 = ctx->Viewport.WindowMap.m[14];
+            GLfloat *v = gWin[start].f;
+            GLfloat *win = VB->Win.data[start];
+            if (VB->ClipOrMask) {
+                GLubyte *clipmask = &VB->ClipMask[start];
+                for (; v != vend; v += 16, clipmask++, win += 4) {
+                    if (*clipmask == 0) {
+                        GLfloat zNDC = (win[2] - v14) / v10;
+                        GLfloat zEye = (zNDC - m14) / m10;
+                        v[OOWCOORD] = -1.0F / zEye;
+                    }
+                }
+            }
+            else {
+                for (; v != vend; v += 16, win += 4) {
+                    GLfloat zNDC = (win[2] - v14) / v10;
+                    GLfloat zEye = (zNDC - m14) / m10;
+                    v[OOWCOORD] = -1.0F / zEye;
+                }
+            }
+        }
+
+        /* rare - I hope */
+        FIXUP;
+    }
+}
+
+
+#undef V1
+#undef V2
+#undef V3
+#undef V4
+#undef V5
+#undef V6
+#undef VARS
+
+#undef S1
+#undef S2
+#undef S3
+#undef S4
+#undef S5
+#undef S6
+#undef DO_SETUP
+
+#undef I1
+#undef I4
+#undef I5
+#undef I6
+#undef INCR
+
+#undef F5
+#undef F6
+#undef F7
+#undef FIXUP
+
+
+#undef IND
+#undef NAME
Index: xc/lib/GL/mesa/src/drv/tdfx/fxvsetup.c
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxvsetup.c:1.2
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxvsetup.c	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,578 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxvsetup.c,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+/* fxvsetup.c - 3Dfx VooDoo vertices setup functions */
+
+
+#include "fxdrv.h"
+#include "fxtexman.h"
+#include "fxsetup.h"
+#include "mmath.h"
+#include "pipeline.h"
+#include "fxvsetup.h"
+
+
+void
+fxPrintSetupFlags(const char *msg, GLuint flags)
+{
+    fprintf(stderr, "%s: %d %s%s%s%s%s%s\n",
+            msg,
+            flags,
+            (flags & SETUP_XY) ? " xy," : "",
+            (flags & SETUP_Z) ? " z," : "",
+            (flags & SETUP_W) ? " w," : "",
+            (flags & SETUP_RGBA) ? " rgba," : "",
+            (flags & SETUP_TMU0) ? " tmu0," : "",
+            (flags & SETUP_TMU1) ? " tmu1," : "");
+}
+
+static void
+project_texcoords(struct vertex_buffer *VB,
+                  GLuint tmu_nr, GLuint tc_nr, GLuint start, GLuint count)
+{
+    fxVertex *v = FX_DRIVER_DATA(VB)->verts + start;
+    GrTmuVertex *tmu = &(((GrVertex *) v->f)->tmuvtx[tmu_nr]);
+    GLvector4f *vec = VB->TexCoordPtr[tc_nr];
+
+    GLuint i;
+    GLuint stride = vec->stride;
+    GLfloat *data = VEC_ELT(vec, GLfloat, start);
+
+    for (i = start; i < count; i++, STRIDE_F(data, stride), v++) {
+        tmu->oow = v->f[OOWCOORD] * data[3];
+        tmu = (GrTmuVertex *) ((char *) tmu + sizeof(fxVertex));
+    }
+}
+
+
+static void
+copy_w(struct vertex_buffer *VB, GLuint tmu_nr, GLuint start, GLuint count)
+{
+    fxVertex *v = FX_DRIVER_DATA(VB)->verts + start;
+    GrTmuVertex *tmu = &(((GrVertex *) v->f)->tmuvtx[tmu_nr]);
+    GLuint i;
+
+    for (i = start; i < count; i++, v++) {
+        tmu->oow = v->f[OOWCOORD];
+        tmu = (GrTmuVertex *) ((char *) tmu + sizeof(fxVertex));
+    }
+}
+
+
+static tfxSetupFunc setupfuncs[0x40];
+
+
+
+
+#define IND SETUP_XY
+#define NAME fxsetupXY
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_XY|SETUP_Z)
+#define NAME fxsetupXYZ
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_XY|SETUP_W)
+#define NAME fxsetupXYW
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_XY|SETUP_Z|SETUP_W)
+#define NAME fxsetupXYZW
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_RGBA|SETUP_XY)
+#define NAME fxsetupXYRGBA
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_RGBA|SETUP_XY|SETUP_Z)
+#define NAME fxsetupXYZRGBA
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_RGBA|SETUP_XY|SETUP_W)
+#define NAME fxsetupXYWRGBA
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W)
+#define NAME fxsetupXYZWRGBA
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU0|SETUP_XY|SETUP_W)
+#define NAME fxsetupXYWT0
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W)
+#define NAME fxsetupXYZWT0
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_W)
+#define NAME fxsetupXYWT0T1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_XY|SETUP_Z|SETUP_W)
+#define NAME fxsetupXYZWT0T1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W)
+#define NAME fxsetupXYWRGBAT0
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W)
+#define NAME fxsetupXYZWRGBAT0
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_W)
+#define NAME fxsetupXYWRGBAT0T1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA|SETUP_XY|SETUP_Z|SETUP_W)
+#define NAME fxsetupXYZWRGBAT0T1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_RGBA)
+#define NAME fxsetupRGBA
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU0)
+#define NAME fxsetupT0
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU1)
+#define NAME fxsetupT1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU1|SETUP_TMU0)
+#define NAME fxsetupT0T1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU0|SETUP_RGBA)
+#define NAME fxsetupRGBAT0
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU1|SETUP_RGBA)
+#define NAME fxsetupRGBAT1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA)
+#define NAME fxsetupRGBAT0T1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_W|SETUP_RGBA)
+#define NAME fxsetupWRGBA
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_W|SETUP_TMU0)
+#define NAME fxsetupWT0
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_W|SETUP_TMU1)
+#define NAME fxsetupWT1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_W|SETUP_TMU1|SETUP_TMU0)
+#define NAME fxsetupWT0T1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_W|SETUP_TMU0|SETUP_RGBA)
+#define NAME fxsetupWRGBAT0
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_W|SETUP_TMU1|SETUP_RGBA)
+#define NAME fxsetupWRGBAT1
+#include "fxvs_tmp.h"
+
+#define IND (SETUP_W|SETUP_TMU1|SETUP_TMU0|SETUP_RGBA)
+#define NAME fxsetupWRGBAT0T1
+#include "fxvs_tmp.h"
+
+
+
+void
+fxDDSetupInit(void)
+{
+    setupfuncs[SETUP_XY] = fxsetupXY;
+    setupfuncs[SETUP_XY | SETUP_Z] = fxsetupXYZ;
+    setupfuncs[SETUP_XY | SETUP_W] = fxsetupXYW;
+    setupfuncs[SETUP_XY | SETUP_Z | SETUP_W] = fxsetupXYZW;
+
+    setupfuncs[SETUP_RGBA | SETUP_XY] = fxsetupXYRGBA;
+    setupfuncs[SETUP_RGBA | SETUP_XY | SETUP_Z] = fxsetupXYZRGBA;
+    setupfuncs[SETUP_RGBA | SETUP_XY | SETUP_W] = fxsetupXYWRGBA;
+    setupfuncs[SETUP_RGBA | SETUP_XY | SETUP_Z | SETUP_W] = fxsetupXYZWRGBA;
+
+    /* If we have texture and xy then we must have w.
+     * If we have texture1 and w then we must have texture 0.
+     */
+    setupfuncs[SETUP_TMU0 | SETUP_XY | SETUP_W] = fxsetupXYWT0;
+    setupfuncs[SETUP_TMU0 | SETUP_XY | SETUP_Z | SETUP_W] = fxsetupXYZWT0;
+
+    setupfuncs[SETUP_TMU1 | SETUP_TMU0 | SETUP_XY | SETUP_W] = fxsetupXYWT0T1;
+    setupfuncs[SETUP_TMU1 | SETUP_TMU0 | SETUP_XY | SETUP_Z | SETUP_W] =
+        fxsetupXYZWT0T1;
+
+    setupfuncs[SETUP_TMU0 | SETUP_RGBA | SETUP_XY | SETUP_W] =
+        fxsetupXYWRGBAT0;
+    setupfuncs[SETUP_TMU0 | SETUP_RGBA | SETUP_XY | SETUP_Z | SETUP_W] =
+        fxsetupXYZWRGBAT0;
+
+    setupfuncs[SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA | SETUP_XY | SETUP_W] =
+        fxsetupXYWRGBAT0T1;
+    setupfuncs[SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA | SETUP_XY | SETUP_Z |
+               SETUP_W] = fxsetupXYZWRGBAT0T1;
+
+    /* If we don't have xy then we can't have z... w is still a possibility.
+     */
+    setupfuncs[SETUP_RGBA] = fxsetupRGBA;
+    setupfuncs[SETUP_TMU0] = fxsetupT0;
+    setupfuncs[SETUP_TMU1] = fxsetupT1;
+    setupfuncs[SETUP_TMU1 | SETUP_TMU0] = fxsetupT0T1;
+    setupfuncs[SETUP_TMU0 | SETUP_RGBA] = fxsetupRGBAT0;
+    setupfuncs[SETUP_TMU1 | SETUP_RGBA] = fxsetupRGBAT1;
+    setupfuncs[SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA] = fxsetupRGBAT0T1;
+
+    setupfuncs[SETUP_W | SETUP_RGBA] = fxsetupWRGBA;
+    setupfuncs[SETUP_W | SETUP_TMU0] = fxsetupWT0;
+    setupfuncs[SETUP_W | SETUP_TMU1] = fxsetupWT1;
+    setupfuncs[SETUP_W | SETUP_TMU1 | SETUP_TMU0] = fxsetupWT0T1;
+    setupfuncs[SETUP_W | SETUP_TMU0 | SETUP_RGBA] = fxsetupWRGBAT0;
+    setupfuncs[SETUP_W | SETUP_TMU1 | SETUP_RGBA] = fxsetupWRGBAT1;
+    setupfuncs[SETUP_W | SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA] =
+        fxsetupWRGBAT0T1;
+
+}
+
+
+
+tfxSetupFunc
+fxDDChooseSetupFunction(GLcontext * ctx)
+{
+    GLuint setupindex = SETUP_XY | SETUP_Z;
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+
+    fxMesa->setupindex = 0;
+
+    if (ctx->RenderMode != GL_RENDER)
+        return 0;
+
+    fxMesa->tmu_source[0] = 0;
+    fxMesa->tmu_source[1] = 1;
+
+    fxMesa->tex_dest[0] = SETUP_TMU0;
+    fxMesa->tex_dest[1] = SETUP_TMU1;
+
+    if (ctx->Light.ShadeModel == GL_SMOOTH && !ctx->Light.Model.TwoSide)
+        setupindex |= SETUP_RGBA;
+
+    if (ctx->Fog.Enabled && ctx->FogMode == FOG_FRAGMENT)
+        setupindex |= SETUP_RGBA | SETUP_W;
+
+    if ((ctx->Texture.ReallyEnabled & (TEXTURE0_2D | TEXTURE0_3D)) ==
+        TEXTURE0_2D) {
+        /* This doesn't work for non-RGBA textures
+           if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE) 
+           setupindex &= ~SETUP_RGBA;
+         */
+        setupindex |= SETUP_TMU0 | SETUP_W;
+    }
+
+    if ((ctx->Texture.ReallyEnabled & (TEXTURE1_2D | TEXTURE1_3D)) ==
+        TEXTURE1_2D) {
+        setupindex |= SETUP_TMU1 | SETUP_W;
+        if (setupindex & SETUP_TMU0) { /* both TMUs in use */
+            struct gl_texture_object *tObj = ctx->Texture.Unit[0].CurrentD[2];
+            tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+
+            if (ti->whichTMU != FX_TMU0) { /* TMU0 and TMU1 are swapped */
+                fxMesa->tmu_source[0] = 1;
+                fxMesa->tex_dest[1] = SETUP_TMU0;
+                fxMesa->tmu_source[1] = 0;
+                fxMesa->tex_dest[0] = SETUP_TMU1;
+            }
+        }
+    }
+
+    if (ctx->Color.BlendEnabled)
+        setupindex |= SETUP_RGBA;
+
+    if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_PIPELINE | VERBOSE_STATE))
+        fxPrintSetupFlags("fxmesa: vertex setup function", setupindex);
+
+    fxMesa->setupindex = setupindex;
+    fxMesa->view_clip_tri = fxTriViewClipTab[setupindex & 0x7];
+    fxMesa->clip_tri_stride = fxTriClipStrideTab[setupindex & 0x7];
+    return setupfuncs[setupindex];
+}
+
+void
+fxDDDoRasterSetup(struct vertex_buffer *VB)
+{
+    GLcontext *ctx = VB->ctx;
+    FX_DRIVER_DATA(VB)->last_vert = FX_DRIVER_DATA(VB)->verts + VB->Count;
+
+#if 0                           /* leaving this out fixes the Heretic2 stray polygon bug */
+    if ((ctx->IndirectTriangles & DD_SW_RASTERIZE) == DD_SW_RASTERIZE) {
+        fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+        fxMesa->setupdone = 0;
+        return;
+    }
+#endif
+
+    if (VB->Type == VB_CVA_PRECALC)
+        fxDDPartialRasterSetup(VB);
+    else if (ctx->Driver.RasterSetup) /* NULL if in feedback/selection mode */
+        ctx->Driver.RasterSetup(VB, VB->CopyStart, VB->Count);
+
+}
+
+
+/*
+ * Need to check that merge&render will work before allowing this to
+ * happen here.  Therefore - need to know that this will be fired when
+ * we get a forbidden input in the elt pipeline - and therefore need to check
+ * whether we have one *now*.  Similarly need to know if state changes cause
+ * size4 texcoords to be introduced.  
+ */
+void
+fxDDCheckPartialRasterSetup(GLcontext * ctx, struct gl_pipeline_stage *d)
+{
+    fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+    GLuint tmp = fxMesa->setupdone;
+
+    d->type = 0;
+    d->pre_forbidden_inputs = 0;
+    fxMesa->setupdone = 0;      /* cleared if we return */
+
+    /* Indirect triangles must be rendered via the immediate pipeline.  
+     * If all rasterization is software, no need to set up.  
+     */
+    if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0)
+        return;
+
+    if ((ctx->IndirectTriangles & DD_SW_SETUP) ||
+        (ctx->IndirectTriangles & DD_SW_RASTERIZE) == DD_SW_RASTERIZE)
+        return;
+
+    if ((ctx->Texture.ReallyEnabled & 0xf) &&
+        !(ctx->Array.Flags & VERT_TEX0_ANY)) {
+        if (ctx->TextureMatrix[0].type == MATRIX_GENERAL ||
+            ctx->TextureMatrix[0].type == MATRIX_PERSPECTIVE ||
+            (ctx->Texture.Unit[0].TexGenEnabled & Q_BIT))
+            return;
+
+        d->pre_forbidden_inputs |= VERT_TEX0_4;
+    }
+
+    if ((ctx->Texture.ReallyEnabled & 0xf0) &&
+        !(ctx->Array.Flags & VERT_TEX1_ANY)) {
+        if (ctx->TextureMatrix[1].type == MATRIX_GENERAL ||
+            ctx->TextureMatrix[1].type == MATRIX_PERSPECTIVE ||
+            (ctx->Texture.Unit[1].TexGenEnabled & Q_BIT))
+            return;
+
+        d->pre_forbidden_inputs |= VERT_TEX1_4;
+    }
+
+
+    fxMesa->setupdone = tmp;
+    d->inputs = 0;
+    d->outputs = VERT_SETUP_PART;
+    d->type = PIPE_PRECALC;
+}
+
+
+/* Will be different every time - no point in trying to precalc the
+ * function to call.
+ */
+void
+fxDDPartialRasterSetup(struct vertex_buffer *VB)
+{
+    GLuint new = VB->pipeline->new_outputs;
+    fxMesaContext fxMesa = (fxMesaContext) VB->ctx->DriverCtx;
+    GLuint ind = 0;
+
+    FX_DRIVER_DATA(VB)->last_vert = FX_DRIVER_DATA(VB)->verts + VB->Count;
+
+    if (new & VERT_WIN) {
+        new = VB->pipeline->outputs;
+        ind |= SETUP_XY | SETUP_W | SETUP_Z;
+    }
+
+    if (new & VERT_TEX0_ANY)
+        ind |= SETUP_W | fxMesa->tex_dest[0];
+
+    if (new & VERT_TEX1_ANY)
+        ind |= SETUP_W | fxMesa->tex_dest[1];
+
+    if (new & VERT_RGBA)
+        ind |= SETUP_W | SETUP_RGBA;
+
+    if ((new & VERT_WIN) == 0)
+        ind &= ~(fxMesa->setupdone & SETUP_W);
+
+    fxMesa->setupdone &= ~ind;
+    ind &= fxMesa->setupindex;
+    fxMesa->setupdone |= ind;
+
+    if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_PIPELINE)) {
+        gl_print_vert_flags("new outputs", VB->pipeline->new_outputs);
+        fxPrintSetupFlags("fxmesa: partial setup function", ind);
+    }
+
+    if (ind)
+        setupfuncs[ind] (VB, VB->Start, VB->Count);
+}
+
+
+/*
+ * This is called by the fastpath code if we need to resize a vertex buffer.
+ * (Almost certainly never called.)
+ */
+void
+fxDDResizeVB(struct vertex_buffer *VB, GLuint size)
+{
+    struct tfxMesaVertexBuffer *fvb = FX_DRIVER_DATA(VB);
+
+    while (fvb->size < size)
+        fvb->size *= 2;
+
+    ALIGN_FREE(VB->ClipMask);
+    VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * fvb->size, 4);
+
+    ALIGN_FREE(fvb->verts);
+    fvb->verts = (fxVertex *) ALIGN_MALLOC(sizeof(fxVertex) * fvb->size, 32);
+
+    gl_vector1ui_free(&fvb->clipped_elements);
+    gl_vector1ui_alloc(&fvb->clipped_elements, VEC_WRITABLE, fvb->size, 32);
+
+    if (!fvb->verts || !VB->ClipMask || !fvb->clipped_elements.start) {
+        gl_problem(NULL, "tdfx driver out of memory in fxDDResizeVB");
+        return;
+    }
+}
+
+
+/*
+ * This is called by Mesa when it creates a new vertex buffer.
+ * Here, we allocate a tfxMesaVertexBuffer and hook it to VB->driver_data.
+ */
+void
+fxDDRegisterVB(struct vertex_buffer *VB)
+{
+    struct tfxMesaVertexBuffer *fvb;
+
+    fvb = (struct tfxMesaVertexBuffer *) calloc(1, sizeof(*fvb));
+
+    /* This looks like it allocates a lot of memory, but it basically
+     * just sets an upper limit on how much can be used - nothing like
+     * this amount will ever be turned into 'real' memory.
+     */
+    if (VB->Type == VB_CVA_PRECALC) {
+        fvb->size = VB->Size * 5;
+        fvb->verts = (fxVertex *) ALIGN_MALLOC(sizeof(fxVertex)*fvb->size, 32);
+        if (!fvb->verts)
+            goto memerror;
+
+#if defined(FX_GLIDE3)
+        fvb->triangle_b = MALLOC(sizeof(GrVertex *) * 4 * fvb->size + 31);
+        if (!fvb->triangle_b)
+            goto memerror;
+        fvb->strips_b = MALLOC(sizeof(GrVertex *) * 4 * fvb->size + 31);
+        if (!fvb->strips_b)
+            goto memerror;
+#endif
+        gl_vector1ui_alloc(&fvb->clipped_elements, VEC_WRITABLE, fvb->size,32);
+        if (!fvb->clipped_elements.start)
+            goto memerror;
+
+        ALIGN_FREE(VB->ClipMask);
+        VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*fvb->size, 4);
+        if (!VB->ClipMask)
+            goto memerror;
+    }
+    else {
+        fvb->size = VB->Size + 12;
+        fvb->verts = (fxVertex *) ALIGN_MALLOC(sizeof(fxVertex)*fvb->size, 32);
+        if (!fvb->verts)
+            goto memerror;
+
+#if defined(FX_GLIDE3)
+        fvb->triangle_b = MALLOC(sizeof(GrVertex *) * 4 * fvb->size + 31);
+        if (!fvb->triangle_b)
+            goto memerror;
+        fvb->strips_b = MALLOC(sizeof(GrVertex *) * 4 * fvb->size + 31);
+        if (!fvb->strips_b)
+            goto memerror;
+#endif
+    }
+
+    VB->driver_data = fvb;
+    return;
+
+  memerror:
+    fprintf(stderr, "fx Driver: out of memory !\n");
+}
+
+
+/*
+ * This is called by Mesa when it's about to deallocate a vertex buffer.
+ * Here we free the tfxMesaVertexBuffer we attached to VB->driver_data.
+ */
+void
+fxDDUnregisterVB(struct vertex_buffer *VB)
+{
+    struct tfxMesaVertexBuffer *fvb = FX_DRIVER_DATA(VB);
+
+    if (fvb) {
+        if (fvb->verts)
+            ALIGN_FREE(fvb->verts);
+        gl_vector1ui_free(&fvb->clipped_elements);
+#if defined(FX_GLIDE3)
+        if (fvb->strips_b)
+            FREE(fvb->strips_b);
+        if (fvb->triangle_b)
+            FREE(fvb->triangle_b);
+#endif
+        FREE(fvb);
+        VB->driver_data = NULL;
+    }
+}
Index: xc/lib/GL/mesa/src/drv/tdfx/fxvsetup.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/fxvsetup.h:1.2
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/fxvsetup.h	Fri Dec  8 14:36:23 2000
@@ -0,0 +1,177 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/fxvsetup.h,v 1.2 2000/12/08 19:36:23 alanh Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version:  3.3
+ *
+ * Copyright (C) 1999-2000  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
+ * terms stated above.
+ *
+ * Thank you for your contribution, David!
+ *
+ * Please make note of the above copyright/license statement.  If you
+ * contributed code or bug fixes to this code under the previous (GNU
+ * Library) license and object to the new license, your code will be
+ * removed at your request.  Please see the Mesa docs/COPYRIGHT file
+ * for more information.
+ *
+ * Additional Mesa/3Dfx driver developers:
+ *   Daryll Strauss <daryll@precisioninsight.com>
+ *   Keith Whitwell <keith@precisioninsight.com>
+ *
+ * See fxapi.h for more revision/author details.
+ */
+
+
+#ifndef _FXVSETUP_H_
+#define _FXVSETUP_H_
+
+
+#define VARS_W
+
+#define VARS_Z
+
+#define VARS_TMU0							\
+  GLuint tmu0_source = fxMesa->tmu_source[0];				\
+  GLfloat *tmu0_data = VEC_ELT(VB->TexCoordPtr[tmu0_source],		\
+			       GLfloat, start);				\
+  GLuint tmu0_stride = VB->TexCoordPtr[tmu0_source]->stride;		\
+  GLuint tmu0_sz = VB->TexCoordPtr[tmu0_source]->size;			\
+  struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source];		\
+  GLfloat sscale0 = FX_TEXTURE_DATA(t0)->sScale;	\
+  GLfloat tscale0 = FX_TEXTURE_DATA(t0)->tScale;
+
+#define VARS_TMU1							\
+  GLuint tmu1_source = fxMesa->tmu_source[1];				\
+  GLfloat *tmu1_data = VEC_ELT(VB->TexCoordPtr[tmu1_source],		\
+			       GLfloat, start);				\
+  GLuint tmu1_stride = VB->TexCoordPtr[tmu1_source]->stride;		\
+  GLuint tmu1_sz = VB->TexCoordPtr[tmu1_source]->size;			\
+  struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source];		\
+  GLfloat sscale1 = FX_TEXTURE_DATA(t1)->sScale;	\
+  GLfloat tscale1 = FX_TEXTURE_DATA(t1)->tScale;
+
+#define VARS_RGBA 						\
+  GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, start); 	\
+  GLuint col_stride = VB->ColorPtr->stride;
+
+#define VARS_XY GLfloat *win = VB->Win.data[start];
+
+#define INCR_XY win += 4
+
+
+/* Add window offset to window coords to get screen coords */
+#  define DO_SETUP_XY 				\
+  v[XCOORD]=win[0]+fxMesa->x_offset;		\
+  v[YCOORD]=win[1]+fxMesa->y_delta;
+
+
+#define DO_SETUP_W {			\
+   v[OOWCOORD]=win[3];			\
+}
+
+#define DO_SETUP_Z v[ZCOORD]=win[2];
+
+#define DO_SETUP_TMU0					\
+{							\
+  v[S0COORD]=sscale0*tmu0_data[0]*v[OOWCOORD];		\
+  v[T0COORD]=tscale0*tmu0_data[1]*v[OOWCOORD];		\
+}
+
+#define INCR_TMU0 STRIDE_F(tmu0_data, tmu0_stride)
+
+#define DO_SETUP_TMU1				\
+{						\
+  v[S1COORD]=sscale1*tmu1_data[0]*v[OOWCOORD];	\
+  v[T1COORD]=tscale1*tmu1_data[1]*v[OOWCOORD];	\
+}
+
+#define INCR_TMU1 STRIDE_F(tmu1_data, tmu1_stride)
+
+#if FX_USE_PARGB
+#define DO_SETUP_RGBA	                                                \
+{                                                                       \
+  PACK_4F_ARGB(GET_PARGB(v), color[3], color[0], color[1], color[2]);   \
+}
+#else
+#define DO_SETUP_RGBA					                \
+{							                \
+  UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[RCOORD], color[0]);	                \
+  UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[GCOORD], color[1]);	                \
+  UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[BCOORD], color[2]);	                \
+  UBYTE_COLOR_TO_FLOAT_255_COLOR2(v[ACOORD], color[3]);	                \
+}
+#endif
+
+#define INCR_RGBA color += col_stride
+
+
+#define _FIXUP_PRE							\
+   GLuint hs = fxMesa->stw_hint_state & ~(GR_STWHINT_W_DIFF_TMU0 |	\
+					  GR_STWHINT_W_DIFF_TMU1);
+
+#define _FIXUP_TMU0							\
+   if (tmu0_sz == 4) {							\
+      project_texcoords( VB, 0, tmu0_source, start, end );		\
+      hs |= GR_STWHINT_W_DIFF_TMU0;			\
+   }
+
+
+#define _FIXUP_TMU1							\
+   if (tmu1_sz == 4) {							\
+      project_texcoords( VB, 1, tmu1_source, start, end );		\
+      hs |= GR_STWHINT_W_DIFF_TMU1;			\
+   }
+
+
+#define _FIXUP_TMU01						\
+   if (tmu0_sz == 4) {						\
+      project_texcoords( VB, 0, tmu0_source, start, end );	\
+      if (tmu1_sz == 4) 					\
+	 project_texcoords( VB, 1, tmu1_source, start, end );	\
+      else 							\
+	 copy_w( VB, 1, start, end );				\
+      hs |= (GR_STWHINT_W_DIFF_TMU0|GR_STWHINT_W_DIFF_TMU1);	\
+   } else if (tmu1_sz == 4) {					\
+      project_texcoords( VB, 1, tmu1_source, start, end );	\
+      hs |= GR_STWHINT_W_DIFF_TMU1;				\
+   }
+
+#define _FIXUP_POST					\
+   if (hs != fxMesa->stw_hint_state) {			\
+      fxMesa->stw_hint_state = hs;			\
+      FX_grHints(fxMesa, GR_HINT_STWHINT, hs);			\
+   }
+
+
+#define FIXUP_TMU0 { _FIXUP_PRE _FIXUP_TMU0 _FIXUP_POST }
+#define FIXUP_TMU1 { _FIXUP_PRE _FIXUP_TMU1 _FIXUP_POST }
+#define FIXUP_TMU01 { _FIXUP_PRE _FIXUP_TMU01 _FIXUP_POST }
+
+
+/* v - pointer to destination GrVertex
+ * VB - source of data
+ * i - index into vb for data
+ */
+
+
+#endif
Index: xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c
diff -u xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c:1.3 xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c:1.5
--- xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c:1.3	Tue Feb 22 23:46:50 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c	Tue Sep 26 11:56:50 2000
@@ -24,6 +24,7 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.c,v 1.5 2000/09/26 15:56:50 tsi Exp $ */
 
 /*
  * Authors:
@@ -36,74 +37,60 @@
 #include <X11/Xlibint.h>
 #include "xf86dri.h"
 #include "tdfx_dri.h"
-#include "tdfx_init.h"
+#include "fxdrv.h"
 
+
 #ifdef DEBUG_LOCKING
-char *prevLockFile=0;
-int prevLockLine=0;
+char *prevLockFile = 0;
+int prevLockLine = 0;
 #endif
 
-static void performMagic(__DRIscreenPrivate *driScrnPriv)
+static void
+performMagic(__DRIscreenPrivate * driScrnPriv)
 {
-    tdfxScreenPrivate *gPriv = (tdfxScreenPrivate *)driScrnPriv->private;
-    TDFXDRIPtr         gDRIPriv = (TDFXDRIPtr)driScrnPriv->pDevPriv;
+    tdfxScreenPrivate *gPriv = (tdfxScreenPrivate *) driScrnPriv->private;
+    TDFXDRIPtr gDRIPriv = (TDFXDRIPtr) driScrnPriv->pDevPriv;
 
-    gPriv->regs.handle=gDRIPriv->regs;
-    gPriv->regs.size=gDRIPriv->regsSize;
-    gPriv->deviceID=gDRIPriv->deviceID;
-    gPriv->width=gDRIPriv->width;
-    gPriv->height=gDRIPriv->height;
-    gPriv->mem=gDRIPriv->mem;
-    gPriv->cpp=gDRIPriv->cpp;
-    gPriv->stride=gDRIPriv->stride;
-    gPriv->fifoOffset=gDRIPriv->fifoOffset;
-    gPriv->fifoSize=gDRIPriv->fifoSize;
-    gPriv->fbOffset=gDRIPriv->fbOffset;
-    gPriv->backOffset=gDRIPriv->backOffset;
-    gPriv->depthOffset=gDRIPriv->depthOffset;
-    gPriv->textureOffset=gDRIPriv->textureOffset;
-    gPriv->textureSize=gDRIPriv->textureSize;
+    gPriv->regs.handle = gDRIPriv->regs;
+    gPriv->regs.size = gDRIPriv->regsSize;
+    gPriv->deviceID = gDRIPriv->deviceID;
+    gPriv->width = gDRIPriv->width;
+    gPriv->height = gDRIPriv->height;
+    gPriv->mem = gDRIPriv->mem;
+    gPriv->cpp = gDRIPriv->cpp;
+    gPriv->stride = gDRIPriv->stride;
+    gPriv->fifoOffset = gDRIPriv->fifoOffset;
+    gPriv->fifoSize = gDRIPriv->fifoSize;
+    gPriv->fbOffset = gDRIPriv->fbOffset;
+    gPriv->backOffset = gDRIPriv->backOffset;
+    gPriv->depthOffset = gDRIPriv->depthOffset;
+    gPriv->textureOffset = gDRIPriv->textureOffset;
+    gPriv->textureSize = gDRIPriv->textureSize;
 }
 
-GLboolean tdfxMapAllRegions(__DRIscreenPrivate *driScrnPriv)
+GLboolean
+tdfxMapAllRegions(__DRIscreenPrivate * driScrnPriv)
 {
-    tdfxScreenPrivate *gPriv = (tdfxScreenPrivate *)driScrnPriv->private;
-    
+    tdfxScreenPrivate *gPriv = (tdfxScreenPrivate *) driScrnPriv->private;
+
     /* First, pick apart pDevPriv & friends */
     performMagic(driScrnPriv);
 
-    if (drmMap(driScrnPriv->fd, gPriv->regs.handle, gPriv->regs.size, 
-	       &gPriv->regs.map)) {
-      return GL_FALSE;
+    if (drmMap(driScrnPriv->fd, gPriv->regs.handle, gPriv->regs.size,
+               &gPriv->regs.map)) {
+        return GL_FALSE;
     }
 
     return GL_TRUE;
 }
 
-void tdfxUnmapAllRegions(__DRIscreenPrivate *driScrnPriv)
+void
+tdfxUnmapAllRegions(__DRIscreenPrivate * driScrnPriv)
 {
-    tdfxScreenPrivate *gPriv = (tdfxScreenPrivate *)driScrnPriv->private;
+    tdfxScreenPrivate *gPriv = (tdfxScreenPrivate *) driScrnPriv->private;
 
     drmUnmap(gPriv->regs.map, gPriv->regs.size);
 }
 
-/*
- * Shutdown Glide library
- */
-void fxCloseHardware(void)
-{
-  if (getenv("MESA_FX_INFO")) {
-    GrSstPerfStats_t		st;
-
-    FX_grSstPerfStats(&st);
-    fprintf(stderr,"Pixels Stats:\n");
-    fprintf(stderr,"  # pixels processed (minus buffer clears): %u\n",(unsigned)st.pixelsIn);
-    fprintf(stderr,"  # pixels not drawn due to chroma key test failure: %u\n",(unsigned)st.chromaFail);
-    fprintf(stderr,"  # pixels not drawn due to depth test failure: %u\n",(unsigned)st.zFuncFail);
-    fprintf(stderr,"  # pixels not drawn due to alpha test failure: %u\n",(unsigned)st.aFuncFail);
-    fprintf(stderr,"  # pixels drawn (including buffer clears and LFB writes): %u\n",(unsigned)st.pixelsOut);
-  }
-  FX_grGlideShutdown();
-}
 
 #endif
Index: xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h
diff -u xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h:1.4 xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h:removed
--- xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h:1.4	Fri Jun 16 20:03:10 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h	Mon Dec 18 14:23:43 2000
@@ -1,228 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- *   Daryll Strauss <daryll@precisioninsight.com>
- *
- */
-
-#ifndef _TDFX_INIT_H_
-#define _TDFX_INIT_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include <sys/time.h>
-#include <glide.h>
-#include "dri_tmm.h"
-#include "dri_mesaint.h"
-#include "dri_mesa.h"
-#include "dri_xmesaapi.h"
-
-
-typedef struct {
-  drmHandle handle;
-  drmSize size;
-  drmAddress map;
-} tdfxRegion, *tdfxRegionPtr;
-
-typedef struct {
-  tdfxRegion regs;
-  int deviceID;
-  int width;
-  int height;
-  int mem;
-  int cpp;
-  int stride;
-  int fifoOffset;
-  int fifoSize;
-  int fbOffset;
-  int backOffset;
-  int depthOffset;
-  int textureOffset;
-  int textureSize;
-  __DRIscreenPrivate *driScrnPriv;
-} tdfxScreenPrivate;
-
-typedef struct {
-  volatile int fifoPtr;
-  volatile int fifoRead;
-  volatile int fifoOwner;
-  volatile int ctxOwner;
-  volatile int texOwner;
-} TDFXSAREAPriv;
-
-/* KW: The extra stuff we need to add to an fxContext to make it
- * equivalent to a tdfxContextPrivate struct.  It may be nice to
- * package this up in a struct, but in the meantime this means we
- * don't have to be merging stuff by hand between unrelated files.
- *
- * PLEASE NOTE: if you add stuff here, you have to make sure you only
- * try to access it from places which are protected by tests for
- * defined(GLX_DIRECT_RENDERING) or defined(XFree86Server).
- */
-#define DRI_FX_CONTEXT				\
-  drmContext hHWContext;			\
-  int numClipRects;				\
-  XF86DRIClipRectPtr pClipRects;		\
-  tdfxScreenPrivate *tdfxScrnPriv;
-
-typedef struct tfxMesaContext tdfxContextPrivate;
-
-#include "fxdrv.h"
-
-extern GLboolean tdfxMapAllRegions(__DRIscreenPrivate *driScrnPriv);
-extern void tdfxUnmapAllRegions(__DRIscreenPrivate *driScrnPriv);
-extern GLboolean tdfxInitHW(__DRIdrawablePrivate *driDrawPrivate,
-                            tdfxContextPrivate *cPriv);
-
-extern void XMesaWindowMoved(void);
-extern void XMesaUpdateState(int windowMoved);
-extern void XMesaSetSAREA(void);
-
-/* This is the private interface between Glide and DRI */
-extern void grDRIOpen(char *pFB, char *pRegs, int deviceID, 
-		      int width, int height, 
-		      int mem, int cpp, int stride, 
-		      int fifoOffset, int fifoSize, 
-		      int fbOffset, int backOffset, int depthOffset, 
-		      int textureOffset, int textureSize, 
-		      volatile int *fifoPtr, volatile int *fifoRead);
-extern void grDRIPosition(int x, int y, int w, int h, 
-			  int numClip, XF86DRIClipRectPtr pClip);
-extern void grDRILostContext(void);
-extern void grDRIImportFifo(int fifoPtr, int fifoRead);
-extern void grDRIInvalidateAll(void);
-extern void grDRIResetSAREA(void);
-
-extern __DRIcontextPrivate *gCC;
-/*000extern tdfxContextPrivate *gCCPriv;*/
-
-/* You can turn this on to find locking conflicts.
-#define DEBUG_LOCKING 
-*/
-
-#ifdef DEBUG_LOCKING
-extern char *prevLockFile;
-extern int prevLockLine;
-#define DEBUG_LOCK() \
-  do { \
-    prevLockFile=(__FILE__); \
-    prevLockLine=(__LINE__); \
-  } while (0)
-#define DEBUG_RESET() \
-  do { \
-    prevLockFile=0; \
-    prevLockLine=0; \
-  } while (0)
-#define DEBUG_CHECK_LOCK() \
-  do { \
-    if (prevLockFile) { \
-      fprintf(stderr, "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
-	prevLockFile, prevLockLine, __FILE__, __LINE__); \
-      exit(1); \
-    } \
-  } while (0)
-#else
-#define DEBUG_LOCK()
-#define DEBUG_RESET()
-#define DEBUG_CHECK_LOCK()    
-#endif
-
-/* !!! We may want to separate locks from locks with validation.
-   This could be used to improve performance for those things
-   commands that do not do any drawing !!! */
-
-#define DRM_LIGHT_LOCK_RETURN(fd,lock,context,__ret)                   \
-	do {                                                           \
-		DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret);     \
-                if (__ret) drmGetLock(fd,context,0);                   \
-        } while(0)
-
-/* Lock the hardware using the global current context */
-#define LOCK_HARDWARE() \
-  do { \
-    char __ret=0; \
-    __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; \
-    __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \
-    DEBUG_CHECK_LOCK(); \
-    DRM_CAS(&sPriv->pSAREA->lock, dPriv->driContextPriv->hHWContext, \
-	    DRM_LOCK_HELD|dPriv->driContextPriv->hHWContext, __ret); \
-    if (__ret) { \
-        int stamp; \
-	drmGetLock(sPriv->fd, dPriv->driContextPriv->hHWContext, 0); \
-        stamp=dPriv->lastStamp; \
-        XMESA_VALIDATE_DRAWABLE_INFO(gCC->display, sPriv, dPriv); \
-        if (*(dPriv->pStamp)!=stamp) XMesaUpdateState(GL_TRUE); \
-	else XMesaUpdateState(GL_FALSE); \
-    } \
-    DEBUG_LOCK(); \
-  } while (0)
-
-/* Unlock the hardware using the global current context */
-#define UNLOCK_HARDWARE() \
-  do { \
-    __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; \
-    __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \
-    XMesaSetSAREA(); \
-    DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock,  \
-	       dPriv->driContextPriv->hHWContext); \
-    DEBUG_RESET(); \
-  } while (0)
-
-#define BEGIN_BOARD_LOCK() LOCK_HARDWARE()
-#define END_BOARD_LOCK() UNLOCK_HARDWARE()
-
-/*
-  This pair of macros makes a loop over the drawing operations
-  so it is not self contained and doesn't have the nice single 
-  statement semantics of most macros
-*/
-#define BEGIN_CLIP_LOOP()					\
-  do {								\
-    __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv;		\
-    int _nc;							\
-    LOCK_HARDWARE();						\
-    _nc = dPriv->numClipRects;					\
-    while (_nc--) {						\
-      tdfxContextPrivate *gCCPriv =				\
-                    (tdfxContextPrivate *) gCC->driverPrivate;	\
-      if (gCCPriv->needClip) {					\
-        gCCPriv->clipMinX=dPriv->pClipRects[_nc].x1;		\
-        gCCPriv->clipMaxX=dPriv->pClipRects[_nc].x2;		\
-        gCCPriv->clipMinY=dPriv->pClipRects[_nc].y1;		\
-        gCCPriv->clipMaxY=dPriv->pClipRects[_nc].y2;		\
-        fxSetScissorValues(gCCPriv->glCtx);			\
-      }
-
-#define END_CLIP_LOOP()		\
-    }				\
-    UNLOCK_HARDWARE();		\
-  } while (0)
-
-#endif
-#endif
Index: xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c
diff -u xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c:1.4 xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c:1.7
--- xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c:1.4	Fri Jun 16 20:03:10 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c	Fri Dec  8 14:36:23 2000
@@ -24,6 +24,7 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c,v 1.7 2000/12/08 19:36:23 alanh Exp $ */
 
 /*
  * Authors:
@@ -33,67 +34,59 @@
 
 #ifdef GLX_DIRECT_RENDERING
 
-#include "tdfx_init.h"
 #include <glide.h>
+#include "fxdrv.h"
 
-GLboolean tdfxInitHW(__DRIdrawablePrivate *driDrawPriv,
-                     tdfxContextPrivate *fxMesa)
+
+GLboolean
+tdfxInitHW(__DRIdrawablePrivate * driDrawPriv, fxMesaContext fxMesa)
 {
-  /* KW: Would be nice to make one of these a member of the other.
-   */
-  __DRIscreenPrivate *driScrnPriv = driDrawPriv->driScreenPriv;
-  tdfxScreenPrivate *sPriv = (tdfxScreenPrivate*)driScrnPriv->private;
+    /* KW: Would be nice to make one of these a member of the other.
+     */
+    __DRIscreenPrivate *driScrnPriv = driDrawPriv->driScreenPriv;
+    tdfxScreenPrivate *sPriv = (tdfxScreenPrivate *) driScrnPriv->private;
 
 #ifdef DEBUG_LOCKING
-  fprintf(stderr, "Debug locking enabled\n");
+    fprintf(stderr, "Debug locking enabled\n");
 #endif
-    
-  if (fxMesa->initDone) return GL_TRUE;
-
-  fxMesa->width=driDrawPriv->w;
-  fxMesa->height=driDrawPriv->h;
 
-  /* We have to use a light lock here, because we can't do any glide
-     operations yet. No use of FX_* functions in this function. */
-  DRM_LIGHT_LOCK(driScrnPriv->fd, &driScrnPriv->pSAREA->lock, 
-		 driDrawPriv->driContextPriv->hHWContext);
-  FX_grGlideInit_NoLock();
+    if (fxMesa->initDone)
+        return GL_TRUE;
 
-  fxMesa->board = 0;
-  FX_grSstSelect_NoLock(fxMesa->board); 
+    fxMesa->width = driDrawPriv->w;
+    fxMesa->height = driDrawPriv->h;
 
-  if (sPriv->deviceID==0x3)
-    fxMesa->haveTwoTMUs=GL_FALSE;
-  else
-    fxMesa->haveTwoTMUs=GL_TRUE;
+    /* We have to use a light lock here, because we can't do any glide
+       operations yet. No use of FX_* functions in this function. */
+    DRM_LIGHT_LOCK(driScrnPriv->fd, &driScrnPriv->pSAREA->lock,
+                   driDrawPriv->driContextPriv->hHWContext);
+    FX_grGlideInit_NoLock();
 
-  /* !!! We are forcing these !!! */
-  fxMesa->haveAlphaBuffer=GL_FALSE; 
-  fxMesa->haveGlobalPaletteTexture=GL_FALSE;
+    fxMesa->board = 0;
+    FX_grSstSelect_NoLock(fxMesa->board);
 
-  fxMesa->glideContext =  FX_grSstWinOpen_NoLock((FxU32)-1, GR_RESOLUTION_NONE,
-						 GR_REFRESH_NONE,
-						 GR_COLORFORMAT_ABGR,
-						 GR_ORIGIN_LOWER_LEFT, 2, 1);
+    if (sPriv->deviceID == 0x3)
+        fxMesa->haveTwoTMUs = GL_FALSE;
+    else
+        fxMesa->haveTwoTMUs = GL_TRUE;
 
-  grDRIResetSAREA();
-  DRM_UNLOCK(driScrnPriv->fd, &driScrnPriv->pSAREA->lock, 
-	     driDrawPriv->driContextPriv->hHWContext);
+    fxMesa->glideContext =
+        FX_grSstWinOpen_NoLock((FxU32) - 1, GR_RESOLUTION_NONE,
+                               GR_REFRESH_NONE, GR_COLORFORMAT_ABGR,
+                               GR_ORIGIN_LOWER_LEFT, 2, 1);
 
-  fxMesa->needClip=1;
+    grDRIResetSAREA();
+    DRM_UNLOCK(driScrnPriv->fd, &driScrnPriv->pSAREA->lock,
+               driDrawPriv->driContextPriv->hHWContext);
 
-  if (!fxMesa->glideContext || !fxDDInitFxMesaContext( fxMesa ))
-    return GL_FALSE;
+    fxMesa->needClip = 1;
 
-  fxInitPixelTables(fxMesa, GL_FALSE); /* Load tables of pixel colors */
+    if (!fxMesa->glideContext || !fxDDInitFxMesaContext(fxMesa))
+        return GL_FALSE;
 
-  fxMesa->initDone=GL_TRUE;
-  return GL_TRUE;
+    fxMesa->initDone = GL_TRUE;
 
+    return GL_TRUE;
 }
 
 #endif
-
-
-
-
Index: xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c
diff -u xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c:1.6 xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c:1.10
--- xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c:1.6	Fri Jun 16 20:03:10 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c	Fri Dec  8 14:36:24 2000
@@ -1,6 +1,7 @@
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,98 +25,110 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c,v 1.10 2000/12/08 19:36:24 alanh Exp $ */
 
 /*
  * Authors:
- *   Daryll Strauss <daryll@precisioninsight.com>
- *   Brian E. Paul <brian@precisioninsight.com>
+ *   Daryll Strauss <daryll@valinux.com>
+ *   Brian E. Paul <brianp@valinux.com>
  */
 
 #ifdef GLX_DIRECT_RENDERING
 
 #include <X11/Xlibint.h>
 #include <glide.h>
-#include "tdfx_init.h"
+#include "fxdrv.h"
 #include "context.h"
 #include "matrix.h"
 #include "mmath.h"
 #include "vbxform.h"
+#include "fxtexman.h"
 
 
-__DRIcontextPrivate *gCC = 0;
+/* including xf86PciInfo.h causes a bunch of errors */
+#ifndef PCI_CHIP_VOODOO5
+#define PCI_CHIP_VOODOO5	0x0009
+#endif
+
+
+GLboolean
+XMesaInitDriver(__DRIscreenPrivate * sPriv)
+{
+    tdfxScreenPrivate *gsp;
+
+    /* Check the DRI version */
+    {
+        int major, minor, patch;
+        if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
+            if (major != 3 || minor != 0 || patch < 0) {
+                char msg[1000];
+                sprintf(msg,
+                        "3dfx DRI driver expected DRI version 3.0.x but got version %d.%d.%d",
+                        major, minor, patch);
+                __driMesaMessage(msg);
+                return GL_FALSE;
+            }
+        }
+    }
+
+    /* Check that the DDX driver version is compatible */
+    if (sPriv->ddxMajor != 1 || sPriv->ddxMinor != 0 || sPriv->ddxPatch < 0) {
+        char msg[1000];
+        sprintf(msg,
+                "3dfx DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d",
+                sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
+        __driMesaMessage(msg);
+        return GL_FALSE;
+    }
+
+    /* Check that the DRM driver version is compatible */
+    if (sPriv->drmMajor != 1 || sPriv->drmMinor != 0 || sPriv->drmPatch < 0) {
+        char msg[1000];
+        sprintf(msg,
+                "3dfx DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d",
+                sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
+        __driMesaMessage(msg);
+        return GL_FALSE;
+    }
+
+    /* Allocate the private area */
+    gsp = (tdfxScreenPrivate *) Xmalloc(sizeof(tdfxScreenPrivate));
+    if (!gsp)
+        return GL_FALSE;
 
+    gsp->driScrnPriv = sPriv;
 
-GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
+    sPriv->private = (void *) gsp;
+
+    if (!tdfxMapAllRegions(sPriv)) {
+        Xfree(gsp);
+        sPriv->private = NULL;
+        return GL_FALSE;
+    }
+
+    return GL_TRUE;
+}
+
+
+void
+XMesaResetDriver(__DRIscreenPrivate * sPriv)
 {
-   tdfxScreenPrivate *gsp;
+    tdfxUnmapAllRegions(sPriv);
+    Xfree(sPriv->private);
+    sPriv->private = NULL;
+}
 
-   /* Check the DRI version */
-   {
-      int major, minor, patch;
-      if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
-         if (major != 3 || minor != 0 || patch < 0) {
-            char msg[1000];
-            sprintf(msg, "3dfx DRI driver expected DRI version 3.0.x but got version %d.%d.%d", major, minor, patch);
-            __driMesaMessage(msg);
-            return GL_FALSE;
-         }
-      }
-   }
-
-   /* Check that the DDX driver version is compatible */
-   if (sPriv->ddxMajor != 1 ||
-       sPriv->ddxMinor != 0 ||
-       sPriv->ddxPatch < 0) {
-      char msg[1000];
-      sprintf(msg, "3dfx DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
-      __driMesaMessage(msg);
-      return GL_FALSE;
-   }
-
-   /* Check that the DRM driver version is compatible */
-   if (sPriv->drmMajor != 1 ||
-       sPriv->drmMinor != 0 ||
-       sPriv->drmPatch < 0) {
-      char msg[1000];
-      sprintf(msg, "3dfx DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
-      __driMesaMessage(msg);
-      return GL_FALSE;
-   }
-
-   /* Allocate the private area */
-   gsp = (tdfxScreenPrivate *)Xmalloc(sizeof(tdfxScreenPrivate));
-   if (!gsp)
-      return GL_FALSE;
-
-   gsp->driScrnPriv = sPriv;
-
-   sPriv->private = (void *) gsp;
-
-   if (!tdfxMapAllRegions(sPriv)) {
-      Xfree(gsp);
-      sPriv->private = NULL;
-      return GL_FALSE;
-   }
-
-   return GL_TRUE;
-}
-
-void XMesaResetDriver(__DRIscreenPrivate *sPriv)
-{
-  tdfxUnmapAllRegions(sPriv);
-  Xfree(sPriv->private);
-  sPriv->private = NULL;
-}
-
-GLvisual *XMesaCreateVisual(Display *dpy,
-                            __DRIscreenPrivate *driScrnPriv,
-                            const XVisualInfo *visinfo,
-                            const __GLXvisualConfig *config)
-{
-   /* Drivers may change the args to _mesa_create_visual() in order to
-    * setup special visuals.
-    */
-   return _mesa_create_visual( config->rgba,
+
+GLvisual *
+XMesaCreateVisual(Display * dpy,
+                  __DRIscreenPrivate * driScrnPriv,
+                  const XVisualInfo * visinfo,
+                  const __GLXvisualConfig * config)
+{
+    /* Drivers may change the args to _mesa_create_visual() in order to
+     * setup special visuals.
+     */
+    return _mesa_create_visual(config->rgba,
                                config->doubleBuffer,
                                config->stereo,
                                _mesa_bitcount(visinfo->red_mask),
@@ -129,294 +142,410 @@
                                config->accumGreenSize,
                                config->accumBlueSize,
                                config->accumAlphaSize,
-                               0 /* num samples */ );
+                               0 /* num samples */
+        );
 }
 
 
-GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis,
-                             __DRIcontextPrivate *driContextPriv)
+GLboolean
+XMesaCreateContext(Display * dpy, GLvisual * mesaVis,
+                   __DRIcontextPrivate * driContextPriv)
 {
-  tdfxContextPrivate *cPriv;
-  __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv;
-  tdfxScreenPrivate *sPriv = (tdfxScreenPrivate *)driScrnPriv->private;
-  TDFXSAREAPriv *saPriv;
-  /*int **fifoPtr;*/
-
-  cPriv = (tdfxContextPrivate *)Xmalloc(sizeof(tdfxContextPrivate));
-  if (!cPriv) {
-    return GL_FALSE;
-  }
-
-  cPriv->hHWContext = driContextPriv->hHWContext;
-  cPriv->tdfxScrnPriv = sPriv;
-  /* deviceID = 0x05 = Voodoo3 */
-  /* deviceID = 0x09 = Voodoo5 (and Voodoo5?) */
-  cPriv->haveHwStencil = sPriv->deviceID == 0x9 && sPriv->cpp == 4;
-
-  cPriv->glVis=mesaVis;
-  cPriv->glBuffer=gl_create_framebuffer(mesaVis,
-                        GL_FALSE,  /* software depth buffer? */
-                        mesaVis->StencilBits > 0 && !cPriv->haveHwStencil,
-                        mesaVis->AccumRedBits > 0,
-                        GL_FALSE   /* software alpha channel */
-                      );
-
-  cPriv->screen_width=sPriv->width;
-  cPriv->screen_height=sPriv->height;
-  cPriv->new_state = ~0;
+    fxMesaContext fxMesa;
+    __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv;
+    tdfxScreenPrivate *sPriv = (tdfxScreenPrivate *) driScrnPriv->private;
+    TDFXSAREAPriv *saPriv;
 
-  cPriv->glCtx = driContextPriv->mesaContext;
-  cPriv->initDone=GL_FALSE;
-
-  saPriv=(TDFXSAREAPriv*)((char*)driScrnPriv->pSAREA+sizeof(XF86DRISAREARec));
-  grDRIOpen(driScrnPriv->pFB, sPriv->regs.map, sPriv->deviceID, 
-	    sPriv->width, sPriv->height, sPriv->mem, sPriv->cpp, sPriv->stride,
-	    sPriv->fifoOffset, sPriv->fifoSize, sPriv->fbOffset,
-	    sPriv->backOffset, sPriv->depthOffset, sPriv->textureOffset, 
-	    sPriv->textureSize, &saPriv->fifoPtr, &saPriv->fifoRead);
-
-  driContextPriv->driverPrivate = (void *) cPriv;
+    fxMesa = (fxMesaContext) Xmalloc(sizeof(struct tfxMesaContext));
+    if (!fxMesa) {
+        return GL_FALSE;
+    }
 
-  return GL_TRUE;
+    fxMesa->hHWContext = driContextPriv->hHWContext;
+    fxMesa->tdfxScrnPriv = sPriv;
+    /* deviceID = 0x05 = Voodoo3 */
+    /* deviceID = 0x09 = Voodoo5 (and Voodoo4?) */
+    fxMesa->isNapalm = sPriv->deviceID == PCI_CHIP_VOODOO5;
+    fxMesa->haveHwStencil = fxMesa->isNapalm && sPriv->cpp == 4;
+
+
+    fxMesa->glVis = mesaVis;
+    fxMesa->screen_width = sPriv->width;
+    fxMesa->screen_height = sPriv->height;
+    fxMesa->new_state = ~0;
+    fxMesa->driContextPriv = driContextPriv;
+    fxMesa->glCtx = driContextPriv->mesaContext;
+    fxMesa->initDone = GL_FALSE;
+
+    saPriv =
+        (TDFXSAREAPriv *) ((char *) driScrnPriv->pSAREA +
+                           sizeof(XF86DRISAREARec));
+    grDRIOpen(driScrnPriv->pFB, sPriv->regs.map, sPriv->deviceID,
+              sPriv->width, sPriv->height, sPriv->mem, sPriv->cpp,
+              sPriv->stride, sPriv->fifoOffset, sPriv->fifoSize,
+              sPriv->fbOffset, sPriv->backOffset, sPriv->depthOffset,
+              sPriv->textureOffset, sPriv->textureSize, &saPriv->fifoPtr,
+              &saPriv->fifoRead);
+
+    driContextPriv->driverPrivate = (void *) fxMesa;
+
+    return GL_TRUE;
 }
 
-void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
-{
-  tdfxContextPrivate *cPriv = (tdfxContextPrivate *) driContextPriv->driverPrivate;
-  if (cPriv) {
-    XFree(cPriv);
-    driContextPriv->driverPrivate = NULL;
-  }
 
-  if (driContextPriv == gCC) {
-    gCC = 0;
-  }
+void
+XMesaDestroyContext(__DRIcontextPrivate * driContextPriv)
+{
+    fxMesaContext fxMesa = (fxMesaContext) driContextPriv->driverPrivate;
+    if (fxMesa) {
+        if (fxMesa->glCtx->Shared->RefCount == 1) {
+           /* This share group is about to go away, free our private
+            * texture object data.
+            */
+            struct gl_texture_object *tObj;
+            tObj = fxMesa->glCtx->Shared->TexObjectList;
+            while (tObj) {
+                fxTMFreeTexture(fxMesa, tObj);
+                tObj = tObj->Next;
+            }
+        }
+        XFree(fxMesa);
+        driContextPriv->driverPrivate = NULL;
+    }
 }
 
 
-GLframebuffer *XMesaCreateWindowBuffer( Display *dpy,
-                                        __DRIscreenPrivate *driScrnPriv,
-                                        __DRIdrawablePrivate *driDrawPriv,
-                                        GLvisual *mesaVis)
-{
-   return gl_create_framebuffer(mesaVis,
-                                GL_FALSE,  /* software depth buffer? */
-                                mesaVis->StencilBits > 0,
-                                mesaVis->AccumRedBits > 0,
-                                GL_FALSE   /* software alpha channel? */
-                                );
+GLframebuffer *
+XMesaCreateWindowBuffer(Display * dpy,
+                        __DRIscreenPrivate * driScrnPriv,
+                        __DRIdrawablePrivate * driDrawPriv,
+                        GLvisual * mesaVis)
+{
+    return gl_create_framebuffer(mesaVis,
+                                 GL_FALSE, /* software depth buffer? */
+                                 mesaVis->StencilBits > 0,
+                                 mesaVis->AccumRedBits > 0,
+                                 GL_FALSE /* software alpha channel? */
+                                 );
 }
 
 
-GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
-                                        __DRIscreenPrivate *driScrnPriv,
-                                        __DRIdrawablePrivate *driDrawPriv,
-                                        GLvisual *mesaVis)
+GLframebuffer *
+XMesaCreatePixmapBuffer(Display * dpy,
+                        __DRIscreenPrivate * driScrnPriv,
+                        __DRIdrawablePrivate * driDrawPriv,
+                        GLvisual * mesaVis)
 {
 #if 0
-   /* Different drivers may have different combinations of hardware and
-    * software ancillary buffers.
-    */
-   return gl_create_framebuffer(mesaVis,
-                                GL_FALSE,  /* software depth buffer? */
-                                mesaVis->StencilBits > 0,
-                                mesaVis->AccumRedBits > 0,
-                                mesaVis->AlphaBits > 0
-                                );
+    /* Different drivers may have different combinations of hardware and
+     * software ancillary buffers.
+     */
+    return gl_create_framebuffer(mesaVis,
+                                 GL_FALSE, /* software depth buffer? */
+                                 mesaVis->StencilBits > 0,
+                                 mesaVis->AccumRedBits > 0,
+                                 mesaVis->AlphaBits > 0);
 #else
-   return NULL;  /* not implemented yet */
+    return NULL;                /* not implemented yet */
 #endif
 }
 
 
-void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
+void
+XMesaSwapBuffers(__DRIdrawablePrivate * driDrawPriv)
 {
-  FxI32 result;
+    GET_CURRENT_CONTEXT(ctx);
+    fxMesaContext fxMesa = 0;
+
+    if (!driDrawPriv->mesaBuffer->Visual->DBflag)
+       return; /* can't swap a single-buffered window */
+
+    /* If the current context's drawable matches the given drawable
+     * we have to do a glFinish (per the GLX spec).
+     */
+    if (ctx) {
+        __DRIdrawablePrivate *curDrawPriv;
+        fxMesa = FX_CONTEXT(ctx);
+        curDrawPriv = fxMesa->driContextPriv->driDrawablePriv;
+        if (curDrawPriv == driDrawPriv) {
+            /* swapping window bound to current context, flush first */
+            FLUSH_VB(ctx, "swap buffers");
+            BEGIN_BOARD_LOCK(fxMesa);
+        }
+        else {
+            /* make fxMesa context current */
+            grGlideGetState((GrState *) fxMesa->state);
+            fxMesa = (fxMesaContext) driDrawPriv->driContextPriv->driverPrivate;
+            BEGIN_BOARD_LOCK(fxMesa);
+            grSstSelect(fxMesa->board);
+            grGlideSetState((GrState *) fxMesa->state);
+        }
+    }
+
+
 #ifdef STATS
-  int stalls;
-  extern int texSwaps;
-  static int prevStalls=0;
+    {
+        int stalls;
+        static int prevStalls = 0;
+        stalls = grFifoGetStalls();
+        if (stalls != prevStalls) {
+            fprintf(stderr, "%d stalls occurred\n", stalls - prevStalls);
+            prevStalls = stalls;
+        }
+        if (fxMesa && fxMesa->texSwaps) {
+            fprintf(stderr, "%d texture swaps occurred\n", fxMesa->texSwaps);
+            fxMesa->texSwaps = 0;
+        }
+    }
 #endif
-  tdfxContextPrivate *gCCPriv;
 
-  /*
-  ** NOT_DONE: This assumes buffer is currently bound to a context.
-  ** This needs to be able to swap buffers when not currently bound.
-  */
-  if (gCC == NULL)
-     return;
 
-  gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate;
+    /* XXX prototype grDRISwapClipRects() function may not be
+     * needed after all
+     */
+#if 0
+    FX_grDRIBufferSwap(fxMesa, fxMesa->swapInterval);
+#elif 1
+    grDRIBufferSwap(fxMesa->swapInterval);
+#else
+    grDRISwapClipRects(fxMesa->swapInterval,
+                       driDrawPriv->numClipRects,
+                       driDrawPriv->pClipRects);
+#endif
 
-  FLUSH_VB( gCCPriv->glCtx, "swap buffers" );
 
-  if (gCC->mesaContext->Visual->DBflag) {
-#ifdef STATS
-    stalls=grFifoGetStalls();
-    if (stalls!=prevStalls) {
-      fprintf(stderr, "%d stalls occurred\n", stalls-prevStalls);
-      prevStalls=stalls;
-    }
-    if (texSwaps) {
-      fprintf(stderr, "%d texture swaps occurred\n", texSwaps);
-      texSwaps=0;
+#if 0
+    {
+        FxI32 result;
+        do {
+            result = FX_grGetInteger(FX_PENDING_BUFFERSWAPS);
+        } while (result > fxMesa->maxPendingSwapBuffers);
     }
 #endif
-    FX_grDRIBufferSwap(gCCPriv->swapInterval);
-    do {
-      result = FX_grGetInteger(FX_PENDING_BUFFERSWAPS);
-    } while (result > gCCPriv->maxPendingSwapBuffers);
-    gCCPriv->stats.swapBuffer++;
-  }
+    fxMesa->stats.swapBuffer++;
+
+
+    if (ctx) {
+        if (ctx->DriverCtx != fxMesa) {
+            /* restore original context */
+           fxMesa = FX_CONTEXT(ctx);
+           grSstSelect(fxMesa->board);
+           grGlideSetState((GrState *) fxMesa->state);
+        }
+        END_BOARD_LOCK(fxMesa);
+    }
 }
+
 
-GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv)
+GLboolean
+XMesaUnbindContext(__DRIcontextPrivate * driContextPriv)
 {
-   if (driContextPriv && driContextPriv == gCC) {
-      tdfxContextPrivate *gCCPriv;
-      gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate;
-      FX_grGlideGetState((GrState*)gCCPriv->state);
-   }
-   return GL_TRUE;
+    GET_CURRENT_CONTEXT(ctx);
+    if (driContextPriv && driContextPriv->mesaContext == ctx) {
+        fxMesaContext fxMesa = FX_CONTEXT(ctx);
+        FX_grGlideGetState(fxMesa, (GrState *) fxMesa->state);
+    }
+    return GL_TRUE;
+}
+
+GLboolean
+XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+    fprintf(stderr,"XMesaOpenFullScreen\n");
+#if 0 /* When new glide3 calls exist */
+    return((GLboolean)grDRISetupFullScreen(GL_TRUE));
+#else
+    return GL_TRUE;
+#endif
 }
 
-GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv,
-                           __DRIdrawablePrivate *driDrawPriv,
-                           __DRIdrawablePrivate *driReadPriv)
+GLboolean
+XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
 {
-  if (driContextPriv) {
-    tdfxContextPrivate *gCCPriv;
+    fprintf(stderr,"***** XMesaCloseFullScreen *****\n");
+#if 0 /* When new glide3 calls exist */
+    return((GLboolean)grDRISetupFullScreen(GL_FALSE));
+#else
+    return GL_TRUE;
+#endif
+}
 
-    gCC = driContextPriv;
-    gCCPriv = (tdfxContextPrivate *)driContextPriv->driverPrivate;
+/*
+ * This function sends the window position and cliprect list to
+ * Glide for the given context.
+ */
+static void
+XMesaWindowMoved(fxMesaContext fxMesa)
+{
+    __DRIdrawablePrivate *dPriv = fxMesa->driContextPriv->driDrawablePriv;
+    GLcontext *ctx = fxMesa->glCtx;
 
-    if (!gCCPriv->initDone) {
-      if (!tdfxInitHW(driDrawPriv, gCCPriv))
-        return GL_FALSE;
-      gCCPriv->width=0;
-      XMesaWindowMoved();
-      FX_grGlideGetState((GrState*)gCCPriv->state);
+    grDRIPosition(dPriv->x, dPriv->y, dPriv->w, dPriv->h,
+                  dPriv->numClipRects, dPriv->pClipRects);
+    fxMesa->numClipRects = dPriv->numClipRects;
+    fxMesa->pClipRects = dPriv->pClipRects;
+    if (dPriv->x != fxMesa->x_offset || dPriv->y != fxMesa->y_offset ||
+        dPriv->w != fxMesa->width || dPriv->h != fxMesa->height) {
+        fxMesa->x_offset = dPriv->x;
+        fxMesa->y_offset = dPriv->y;
+        fxMesa->width = dPriv->w;
+        fxMesa->height = dPriv->h;
+        fxMesa->y_delta =
+            fxMesa->screen_height - fxMesa->y_offset - fxMesa->height;
     }
-    else {
-      FX_grSstSelect(gCCPriv->board);
-      FX_grGlideSetState((GrState*)gCCPriv->state);
-      XMesaWindowMoved();
-    }
-
-    gl_make_current2(gCCPriv->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer);
-
-    fxSetupDDPointers(gCCPriv->glCtx);
-    if (!gCCPriv->glCtx->Viewport.Width)
-      gl_Viewport(gCCPriv->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h);
-  }
-  else {
-    gl_make_current(0,0);
-    gCC = NULL;
-  }
-  return GL_TRUE;
+    switch (dPriv->numClipRects) {
+    case 0:
+        fxMesa->clipMinX = dPriv->x;
+        fxMesa->clipMaxX = dPriv->x + dPriv->w;
+        fxMesa->clipMinY = dPriv->y;
+        fxMesa->clipMaxY = dPriv->y + dPriv->h;
+        fxSetScissorValues(ctx);
+        fxMesa->needClip = 0;
+        break;
+    case 1:
+        fxMesa->clipMinX = dPriv->pClipRects[0].x1;
+        fxMesa->clipMaxX = dPriv->pClipRects[0].x2;
+        fxMesa->clipMinY = dPriv->pClipRects[0].y1;
+        fxMesa->clipMaxY = dPriv->pClipRects[0].y2;
+        fxSetScissorValues(ctx);
+        fxMesa->needClip = 0;
+        break;
+    default:
+        fxMesa->needClip = 1;
+    }
 }
 
+
+GLboolean
+XMesaMakeCurrent(__DRIcontextPrivate * driContextPriv,
+                 __DRIdrawablePrivate * driDrawPriv,
+                 __DRIdrawablePrivate * driReadPriv)
+{
+    if (driContextPriv) {
+        fxMesaContext fxMesa;
+
+        fxMesa = (fxMesaContext) driContextPriv->driverPrivate;
+
+        if (!fxMesa->initDone) {
+            if (!tdfxInitHW(driDrawPriv, fxMesa))
+                return GL_FALSE;
+            fxMesa->width = 0;
+            XMesaWindowMoved(fxMesa);
+            FX_grGlideGetState(fxMesa, (GrState *) fxMesa->state);
+        }
+        else {
+            FX_grSstSelect(fxMesa, fxMesa->board);
+            FX_grGlideSetState(fxMesa, (GrState *) fxMesa->state);
+            XMesaWindowMoved(fxMesa);
+        }
 
-void XMesaWindowMoved(void)
-{
-  __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv;
-  tdfxContextPrivate *gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate;
-  GLcontext *ctx = gCCPriv->glCtx;
-
-  grDRIPosition(dPriv->x, dPriv->y, dPriv->w, dPriv->h,
-		dPriv->numClipRects, dPriv->pClipRects);
-  gCCPriv->numClipRects=dPriv->numClipRects;
-  gCCPriv->pClipRects=dPriv->pClipRects;
-  if (dPriv->x!=gCCPriv->x_offset || dPriv->y!=gCCPriv->y_offset ||
-      dPriv->w!=gCCPriv->width || dPriv->h!=gCCPriv->height) {
-    gCCPriv->x_offset=dPriv->x;
-    gCCPriv->y_offset=dPriv->y;
-    gCCPriv->width=dPriv->w;
-    gCCPriv->height=dPriv->h;
-    gCCPriv->y_delta=gCCPriv->screen_height-gCCPriv->y_offset-gCCPriv->height;
-  }
-  gCCPriv->needClip=1;
-  switch (dPriv->numClipRects) {
-  case 0:
-    gCCPriv->clipMinX=dPriv->x;
-    gCCPriv->clipMaxX=dPriv->x+dPriv->w;
-    gCCPriv->clipMinY=dPriv->y;
-    gCCPriv->clipMaxY=dPriv->y+dPriv->h;
-    fxSetScissorValues(ctx);
-    gCCPriv->needClip=0;
-    break;
-  case 1:
-    gCCPriv->clipMinX=dPriv->pClipRects[0].x1;
-    gCCPriv->clipMaxX=dPriv->pClipRects[0].x2;
-    gCCPriv->clipMinY=dPriv->pClipRects[0].y1;
-    gCCPriv->clipMaxY=dPriv->pClipRects[0].y2;
-    fxSetScissorValues(ctx);
-    gCCPriv->needClip=0;
-    break;
-  default:
-  }
+        assert(fxMesa->glCtx == driContextPriv->mesaContext);
+
+        gl_make_current2(fxMesa->glCtx, driDrawPriv->mesaBuffer,
+                         driReadPriv->mesaBuffer);
+
+        if (!fxMesa->glCtx->Viewport.Width)
+            gl_Viewport(fxMesa->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h);
+    }
+    else {
+        gl_make_current(0, 0);
+    }
+    return GL_TRUE;
 }
 
+
 /* This is called from within the LOCK_HARDWARE routine */
-void XMesaUpdateState(int windowMoved)
+void
+XMesaUpdateState(fxMesaContext fxMesa)
 {
-  __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv;
-  __DRIscreenPrivate *sPriv = dPriv->driScreenPriv;
-  tdfxContextPrivate *gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate;
-  TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec));
-
-  /* fprintf(stderr, "In FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */
-  if (saPriv->fifoOwner!=dPriv->driContextPriv->hHWContext) {
-    grDRIImportFifo(saPriv->fifoPtr, saPriv->fifoRead);
-  }
-  if (saPriv->ctxOwner!=dPriv->driContextPriv->hHWContext) {
-    /* This sequence looks a little odd. Glide mirrors the state, and
-       when you get the state you are forcing the mirror to be up to
-       date, and then getting a copy from the mirror. You can then force
-       that state onto the hardware when you set the state. */
-    void *state;
-    state=malloc(FX_grGetInteger_NoLock(FX_GLIDE_STATE_SIZE));
-    FX_grGlideGetState_NoLock(state);
-    FX_grGlideSetState_NoLock(state);
-    free(state);
-  }
-  if (saPriv->texOwner!=dPriv->driContextPriv->hHWContext) {
-    fxTMRestoreTextures_NoLock(gCCPriv);
-  }
-  if (windowMoved)
-    XMesaWindowMoved();
-}
-
-void XMesaSetSAREA(void)
-{
-  __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv;
-  __DRIscreenPrivate *sPriv = dPriv->driScreenPriv;
-  TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec));
-
-  saPriv->fifoOwner=dPriv->driContextPriv->hHWContext;
-  saPriv->ctxOwner=dPriv->driContextPriv->hHWContext;
-  saPriv->texOwner=dPriv->driContextPriv->hHWContext;
-  grDRIResetSAREA();
-  /* fprintf(stderr, "Out FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */
+    __DRIcontextPrivate *cPriv = fxMesa->driContextPriv;
+    __DRIdrawablePrivate *dPriv = cPriv->driDrawablePriv;
+    __DRIscreenPrivate *sPriv = dPriv->driScreenPriv;
+    TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) (((char *) sPriv->pSAREA) +
+                                               sizeof(XF86DRISAREARec));
+    int stamp;
+    char ret;
+
+    DEBUG_CHECK_LOCK();
+    DRM_CAS(&sPriv->pSAREA->lock, dPriv->driContextPriv->hHWContext,
+            DRM_LOCK_HELD | dPriv->driContextPriv->hHWContext, ret);
+    if (!ret) {
+        DEBUG_LOCK();
+        return;
+    }
+    drmGetLock(sPriv->fd, dPriv->driContextPriv->hHWContext, 0);
+    stamp = dPriv->lastStamp;
+    /* This macro will update dPriv's cliprects if needed */
+    XMESA_VALIDATE_DRAWABLE_INFO(cPriv->display, sPriv, dPriv);
+    /* fprintf(stderr, "In FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */
+    if (saPriv->fifoOwner != dPriv->driContextPriv->hHWContext) {
+        grDRIImportFifo(saPriv->fifoPtr, saPriv->fifoRead);
+    }
+    if (saPriv->ctxOwner != dPriv->driContextPriv->hHWContext) {
+        /* This sequence looks a little odd. Glide mirrors the state, and
+           when you get the state you are forcing the mirror to be up to
+           date, and then getting a copy from the mirror. You can then force
+           that state onto the hardware when you set the state. */
+        void *state;
+        state = malloc(FX_grGetInteger_NoLock(FX_GLIDE_STATE_SIZE));
+        FX_grGlideGetState_NoLock(state);
+        FX_grGlideSetState_NoLock(state);
+        free(state);
+    }
+    if (saPriv->texOwner != dPriv->driContextPriv->hHWContext) {
+        fxTMRestoreTextures_NoLock(fxMesa);
+    }
+#if 0
+    if (*dPriv->pStamp != stamp)
+#else
+    if (*dPriv->pStamp != stamp ||
+        saPriv->ctxOwner != dPriv->driContextPriv->hHWContext)
+#endif
+        XMesaWindowMoved(fxMesa);
+    DEBUG_LOCK();
+}
+
+
+/*
+ * XXX is this used by anyone?
+ */
+#if 000
+static void
+XMesaSetSAREA(void)
+{
+    __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv;
+    __DRIscreenPrivate *sPriv = dPriv->driScreenPriv;
+    TDFXSAREAPriv *saPriv =
+        (TDFXSAREAPriv *) (((char *) sPriv->pSAREA) +
+                           sizeof(XF86DRISAREARec));
+
+    saPriv->fifoOwner = dPriv->driContextPriv->hHWContext;
+    saPriv->ctxOwner = dPriv->driContextPriv->hHWContext;
+    saPriv->texOwner = dPriv->driContextPriv->hHWContext;
+    grDRIResetSAREA();
+    /* fprintf(stderr, "Out FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */
 }
+#endif
 
 
+
 extern void __driRegisterExtensions(void); /* silence compiler warning */
 
 /* This function is called by libGL.so as soon as libGL.so is loaded.
  * This is where we'd register new extension functions with the dispatcher.
  */
-void __driRegisterExtensions(void)
+void
+__driRegisterExtensions(void)
 {
 #if 0
-   /* Example.  Also look in fxdd.c for more details. */
-   {
-      const int _gloffset_FooBarEXT = 555;  /* just an example number! */
-      if (_glapi_add_entrypoint("glFooBarEXT", _gloffset_FooBarEXT)) {
-         void *f = glXGetProcAddressARB("glFooBarEXT");
-         assert(f);
-      }
-   }
+    /* Example.  Also look in fxdd.c for more details. */
+    {
+        const int _gloffset_FooBarEXT = 555; /* just an example number! */
+        if (_glapi_add_entrypoint("glFooBarEXT", _gloffset_FooBarEXT)) {
+            void *f = glXGetProcAddressARB("glFooBarEXT");
+            assert(f);
+        }
+    }
 #endif
 }
 
Index: xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fastpath.S
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fastpath.S:1.2
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fastpath.S	Tue Sep 26 11:56:51 2000
@@ -0,0 +1,84 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fastpath.S,v 1.2 2000/09/26 15:56:51 tsi Exp $ */
+
+#include "../../X86/assyntax.h"
+
+#define SETUP_RGBA  0x1
+#define SETUP_TMU0  0x2
+#define SETUP_TMU1  0x4
+
+
+/* Pack either rgba or texture into the remaining half of a 32 byte vertex.
+ */
+#define CLIP_R  24
+#define CLIP_G  16
+#define CLIP_B  20
+#define CLIP_A  28                      /*  defined inf fxdrv.h              */
+
+#define CLIP_S0 16
+#define CLIP_T0 20
+#define CLIP_S1 24
+#define CLIP_T1 28
+
+#define SIZE 4
+#define TYPE (0)
+#define TAG(x) x
+#include "fx_3dnow_fasttmp.h"
+
+#define SIZE 8
+#define TYPE (SETUP_RGBA)
+#define TAG(x) x##_RGBA
+#include "fx_3dnow_fasttmp.h"
+
+#define SIZE 6
+#define TYPE (SETUP_TMU0)
+#define TAG(x) x##_TMU0
+#include "fx_3dnow_fasttmp.h"
+
+#define SIZE 8
+#define TYPE (SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_TMU0_TMU1
+#include "fx_3dnow_fasttmp.h"
+
+#undef CLIP_S1
+#undef CLIP_T1
+#define CLIP_S1 16
+#define CLIP_T1 20
+
+#define SIZE 6
+#define TYPE (SETUP_TMU1)
+#define TAG(x) x##_TMU1
+#include "fx_3dnow_fasttmp.h"
+
+/* These three need to use a full 64 byte clip-space vertex.
+ */
+#undef CLIP_S0
+#undef CLIP_T0
+#undef CLIP_S1
+#undef CLIP_T1
+
+#define CLIP_S0 32
+#define CLIP_T0 36
+#define CLIP_S1 40
+#define CLIP_T1 44
+
+#define SIZE 10
+#define TYPE (SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_RGBA_TMU0
+#include "fx_3dnow_fasttmp.h"
+
+#define SIZE 12
+#define TYPE (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_RGBA_TMU0_TMU1
+#include "fx_3dnow_fasttmp.h"
+
+#undef CLIP_S1
+#undef CLIP_T1
+#define CLIP_S1 32
+#define CLIP_T1 36
+
+#define SIZE 10
+#define TYPE (SETUP_RGBA|SETUP_TMU1)
+#define TAG(x) x##_RGBA_TMU1
+#include "fx_3dnow_fasttmp.h"
+
+
Index: xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fasttmp.h
diff -u /dev/null xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fasttmp.h:1.2
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fasttmp.h	Tue Sep 26 11:56:51 2000
@@ -0,0 +1,314 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fasttmp.h,v 1.2 2000/09/26 15:56:51 tsi Exp $ */
+
+#if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER)
+#define TAGLLBL(a) TAG(.L##a)
+#else
+#define TAGLLBL(a) TAG(a)
+#endif
+
+#if !GLIDE3
+
+#define GR_VERTEX_X_OFFSET              0
+#define GR_VERTEX_Y_OFFSET              4
+#define GR_VERTEX_Z_OFFSET              8
+#define GR_VERTEX_R_OFFSET              12
+#define GR_VERTEX_G_OFFSET              16
+#define GR_VERTEX_B_OFFSET              20
+#define GR_VERTEX_OOZ_OFFSET            24
+#define GR_VERTEX_A_OFFSET              28
+#define GR_VERTEX_OOW_OFFSET            32
+
+#else /* GLIDE3 */
+
+#define GR_VERTEX_X_OFFSET              0
+#define GR_VERTEX_Y_OFFSET              4
+#define GR_VERTEX_OOZ_OFFSET            8
+#define GR_VERTEX_OOW_OFFSET            12
+#define GR_VERTEX_R_OFFSET              16
+#define GR_VERTEX_G_OFFSET              20
+#define GR_VERTEX_B_OFFSET              24
+#define GR_VERTEX_A_OFFSET              28
+#define GR_VERTEX_Z_OFFSET              32
+
+#endif /* GLIDE3 */
+
+#define GR_VERTEX_SOW_TMU0_OFFSET       36
+#define GR_VERTEX_TOW_TMU0_OFFSET       40
+#define GR_VERTEX_OOW_TMU0_OFFSET       44
+#define GR_VERTEX_SOW_TMU1_OFFSET       48
+#define GR_VERTEX_TOW_TMU1_OFFSET       52
+#define GR_VERTEX_OOW_TMU1_OFFSET       56
+
+
+
+
+/*#define MAT_SX 0        /*  accessed by REGIND !! */
+#define MAT_SY 20
+#define MAT_SZ 40
+#define MAT_TX 48
+#define MAT_TY 52
+#define MAT_TZ 56
+
+
+
+
+/* Do viewport map, device scale and perspective projection.
+ *
+ * void project_verts( GLfloat *first,
+ *		       GLfloat *last,
+ *		       const GLfloat *m,
+ *		       GLuint stride )
+ *
+ *
+ * Rearrange fxVertices to look like grVertices.
+ */
+
+GLOBL GLNAME( TAG(fx_3dnow_project_vertices) )
+GLNAME( TAG(fx_3dnow_project_vertices) ):
+
+    PUSH_L    ( EBP )
+
+    MOV_L     ( REGOFF(8, ESP), ECX )    /* first_vert */
+    MOV_L     ( REGOFF(12, ESP), EDX )     /* last_vert */
+
+    CMP_L     ( ECX, EDX )
+    JE        ( TAGLLBL(FXPV_end) )
+
+    FEMMS
+
+    PREFETCH  ( REGIND(ECX) )         /* fetch the first vertex */
+
+    MOV_L     ( REGOFF(16, ESP), EBP )     /* matrix */
+    MOV_L     ( REGOFF(20, ESP), EAX )     /* stride */
+
+    MOVD      ( REGOFF(MAT_TX, EBP), MM6 )      /*             | tx           */
+    PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 )      /*  ty         | tx           */
+
+#if !defined(FX_V2)
+    MOV_L     ( CONST(0x49400000), REGOFF(-8, ESP) )    /*  snapper           */
+    MOV_L     ( CONST(0x49400000), REGOFF(-4, ESP) )    /*  snapper           */
+#endif
+
+    MOVQ      ( REGOFF(-8, ESP), MM4 )          /*  snapper    | snapper      */
+    PFADD     ( MM4, MM6 )                      /*  ty+snapper | tx+snapper   */
+
+    MOVD      ( REGIND(EBP), MM5 )
+    PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 )      /*  vsy        | vsx          */
+
+    MOVD      ( REGOFF(MAT_SZ, EBP), MM1 )      /*             | vsz          */
+
+
+ALIGNTEXT32
+TAGLLBL(FXPV_loop_start):
+
+    PREFETCH  ( REGOFF(64, ECX) )               /* fetch the next-ish vertex */
+
+
+    MOVD      ( REGOFF(12, ECX), MM0 )          /*              | f[3]        */
+    PFRCP     ( MM0, MM0 )                      /*  oow = 1/f[3]              */
+
+    MOVD      ( REGOFF(12, ECX), MM7 )          /*              | f[3]        */
+    PFRCPIT1  ( MM0, MM7 )
+    PFRCPIT2  ( MM0, MM7 )                      /*  oow         | oow         */
+
+    PUNPCKLDQ ( MM7, MM7 )
+
+
+#if (TYPE & SETUP_RGBA)
+    MOVD      ( REGOFF(CLIP_R, ECX ), MM0 )     /*  f[RCOORD] = f[CLIP_R];    */
+    MOVD      ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) )
+#endif
+
+#if (TYPE & SETUP_TMU1)
+    MOVQ      ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow  */
+    PFMUL     ( MM7, MM0 )                  /* f[T1COORD] = f[CLIP_T1] * oow  */
+    MOVQ      ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) )
+#endif
+
+
+#if (TYPE & SETUP_TMU0)
+    MOVQ      ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow  */
+    PFMUL     ( MM7, MM0 )                  /* f[T0COORD] = f[CLIP_T0] * oow  */
+    MOVQ      ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) )
+#endif
+
+
+
+
+
+/*  DO_SETUP_XYZ */
+
+    MOVQ      ( REGIND(ECX), MM2 )              /*  f[1]        | f[0]        */
+    PFMUL     ( MM7, MM2 )                      /*  f[1] * oow  | f[0] * oow  */
+
+    MOVD      ( REGOFF(8, ECX), MM3 )           /*              | f[2]        */
+    PFMUL     ( MM7, MM3 )                      /*              | f[2] * oow  */
+
+    MOVD      ( REGOFF(MAT_TZ, EBP), MM0 )      /*              | vtz         */
+    PFMUL     ( MM1, MM3 )                      /*              | f[2] *= vsz */
+
+    PFADD     ( MM0, MM3 )                      /*              | f[2] += vtz */
+    PFMUL     ( MM5, MM2 )                      /*  f[1] *= vsy | f[0] *= vsx */
+
+    PFADD     ( MM6, MM2 )                      /*  f[1] += vty | f[0] += vtx */
+
+#if !defined(FX_V2)
+    PFSUB     ( MM4, MM2 )                      /*  f[0,1] -= snapper         */
+#endif
+
+    MOVQ      ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) )
+    MOVD      ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) )
+
+
+/* end of DO_SETUP_XYZ   */
+
+    MOVD      ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */
+    ADD_L     ( EAX, ECX )        /* f += stride */
+
+    CMP_L     ( ECX, EDX )	/* stall??? */
+    JA        ( TAGLLBL(FXPV_loop_start) )
+
+TAGLLBL(FXPV_end):
+    FEMMS
+    POP_L     ( EBP )
+    RET
+
+
+
+
+
+
+
+/* void project_verts( GLfloat *first,
+ *		       GLfloat *last,
+ *		       const GLfloat *m,
+ *		       GLuint stride,
+ *                     const GLubyte *mask )
+ *
+ */
+
+GLOBL GLNAME( TAG(fx_3dnow_project_clipped_vertices) )
+GLNAME( TAG(fx_3dnow_project_clipped_vertices) ):
+
+    PUSH_L    ( EBP )
+
+    MOV_L     ( REGOFF(8, ESP), ECX ) /* first FXDRIVER(VB)->verts*/
+    MOV_L     ( REGOFF(12, ESP), EDX ) /* last FXDRIVER(VB)->last_vert  */
+
+    FEMMS
+
+    PUSH_L    ( EDI )
+    PUSH_L    ( ESI )
+
+    PREFETCH  ( REGIND(ECX) )         /* fetch the first vertex */
+
+    MOV_L     ( REGOFF(24, ESP), EBP ) /* mat ctx->Viewport.WindowMap.M */
+    MOV_L     ( REGOFF(28, ESP), EAX )     /* stride */
+    MOV_L     ( REGOFF(32, ESP), ESI ) /* VB->ClipMask       */
+
+    MOVD      ( REGOFF(MAT_TX, EBP), MM6 )      /*             | tx           */
+    PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 )      /*  ty         | tx           */
+
+#if !defined(FX_V2)
+    MOV_L     ( CONST(0x49400000), REGOFF(-8, ESP) )    /*  snapper           */
+    MOV_L     ( CONST(0x49400000), REGOFF(-4, ESP) )    /*  snapper           */
+#endif
+
+    MOVQ      ( REGOFF(-8, ESP), MM4 )          /*  snapper    | snapper      */
+    PFADD     ( MM4, MM6 )                      /*  ty+snapper | tx+snapper   */
+
+    MOVD      ( REGIND(EBP), MM5 )
+    PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 )      /*  vsy        | vsx          */
+
+    MOVD      ( REGOFF(MAT_SZ, EBP), MM1 )      /*             | vsz          */
+
+
+
+ALIGNTEXT32
+TAGLLBL(FXPCV_loop_start):
+
+    PREFETCH  ( REGOFF(64, ECX) )         /* fetch the next-ish vertex */
+
+    CMP_B     ( CONST(0), REGIND(ESI) )
+    JNE       ( TAGLLBL(FXPCV_skip) )
+
+    MOVD      ( REGOFF(12, ECX), MM0)           /*              | f[3]        */
+    PFRCP     ( MM0, MM0 )                      /*  oow = 1/f[3]              */
+
+    MOVD      ( REGOFF(12, ECX), MM7)           /*              | f[3]        */
+    PFRCPIT1  ( MM0, MM7 )
+    PFRCPIT2  ( MM0, MM7 )                      /*  oow         | oow         */
+
+    PUNPCKLDQ ( MM7, MM7 )
+
+
+#if (TYPE & SETUP_RGBA)
+    MOVD      ( REGOFF(CLIP_R, ECX ), MM0 )     /*  f[RCOORD] = f[CLIP_R];    */
+    MOVD      ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) )
+#endif
+
+#if (TYPE & SETUP_TMU1)
+    MOVQ      ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow  */
+    PFMUL     ( MM7, MM0 )                  /* f[T1COORD] = f[CLIP_T1] * oow  */
+    MOVQ      ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) )
+#endif
+
+
+#if (TYPE & SETUP_TMU0)
+    MOVQ      ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow  */
+    PFMUL     ( MM7, MM0 )                  /* f[T0COORD] = f[CLIP_T0] * oow  */
+    MOVQ      ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) )
+#endif
+
+
+
+
+/*  DO_SETUP_XYZ */
+
+    MOVQ      ( REGIND(ECX), MM2 )              /*  f[1]        | f[0]        */
+    PFMUL     ( MM7, MM2 )                      /*  f[1] * oow  | f[0] * oow  */
+
+    MOVD      ( REGOFF(8, ECX), MM3 )           /*              | f[2]        */
+    PFMUL     ( MM7, MM3 )                      /*              | f[2] * oow  */
+
+    MOVD      ( REGOFF(MAT_TZ, EBP), MM0 )      /*              | vtz         */
+    PFMUL     ( MM1, MM3 )                      /*              | f[2] *= vsz */
+
+    PFADD     ( MM0, MM3 )                      /*              | f[2] += vtz */
+    PFMUL     ( MM5, MM2 )                      /*  f[1] *= vsy | f[0] *= vsx */
+
+    PFADD     ( MM6, MM2 )                      /*  f[1] += vty | f[0] += vtx */
+
+#if !defined(FX_V2)
+    PFSUB     ( MM4, MM2 )                      /*  f[0,1] -= snapper         */
+#endif
+
+    MOVQ      ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) )
+    MOVD      ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) )
+
+
+/* end of DO_SETUP_XYZ   */
+
+    MOVD      ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */
+
+TAGLLBL(FXPCV_skip):
+    ADD_L     ( EAX, ECX )    /* f += stride     */
+
+    INC_L     ( ESI )                           /*  next ClipMask             */
+    CMP_L     ( ECX, EDX )
+    JA        ( TAGLLBL(FXPCV_loop_start) )
+
+    POP_L     ( ESI )
+    POP_L     ( EDI )
+
+TAGLLBL(FXPCV_end):
+    FEMMS
+    POP_L     ( EBP )
+    RET
+
+
+
+#undef TYPE
+#undef TAG
+#undef SIZE
+
Index: xc/lib/GLw/GLwM1DrawA.c
diff -u /dev/null xc/lib/GLw/GLwM1DrawA.c:1.1
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GLw/GLwM1DrawA.c	Thu Nov  2 15:39:07 2000
@@ -0,0 +1,55 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED 
+ * Permission to use, copy, modify, and distribute this software for 
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that 
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. 
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * 
+ * US Government Users Restricted Rights 
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (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 or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States.  Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+/* $XFree86: xc/lib/GLw/GLwM1DrawA.c,v 1.1 2000/11/02 20:39:07 dawes Exp $ */
+
+#define __GLX_MOTIF 1
+
+#define XmVERSION 1
+#define XmREVISION 2
+#define XmVersion (XmVERSION * 1000 + XmREVISION)
+#define XmVERSION_STRING "GLwDrawingArea fake M*tif 1.X"
+#define XmUPDATE_LEVEL 0
+
+/* Include our fake Motif headers */
+#include "GLwXm/Xm.h"
+#include "GLwXm/PrimitiveP.h"
+
+#define __GLX_INCLUDE_XM_H
+#define __GLX_INCLUDE_PRIMITIVE_P_H
+
+#include "GLwDrawA.c"
Index: xc/lib/GLw/GLwM2DrawA.c
diff -u /dev/null xc/lib/GLw/GLwM2DrawA.c:1.1
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GLw/GLwM2DrawA.c	Thu Nov  2 15:39:07 2000
@@ -0,0 +1,55 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED 
+ * Permission to use, copy, modify, and distribute this software for 
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that 
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. 
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * 
+ * US Government Users Restricted Rights 
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (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 or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States.  Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+/* $XFree86: xc/lib/GLw/GLwM2DrawA.c,v 1.1 2000/11/02 20:39:07 dawes Exp $ */
+
+#define __GLX_MOTIF 2
+
+#define XmVERSION 2
+#define XmREVISION 0
+#define XmVersion (XmVERSION * 1000 + XmREVISION)
+#define XmVERSION_STRING "GLwDrawingArea fake M*tif 2.X"
+#define XmUPDATE_LEVEL 0
+
+/* Include our fake Motif headers */
+#include "GLwXm/Xm.h"
+#include "GLwXm/PrimitiveP.h"
+
+#define __GLX_INCLUDE_XM_H
+#define __GLX_INCLUDE_PRIMITIVE_P_H
+
+#include "GLwDrawA.c"
Index: xc/lib/GLw/Imakefile
diff -u /dev/null xc/lib/GLw/Imakefile:1.2
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GLw/Imakefile	Thu Nov  2 16:20:10 2000
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+XCOMM $XFree86: xc/lib/GLw/Imakefile,v 1.2 2000/11/02 21:20:10 dawes Exp $
+
+XCOMM
+XCOMM Imakefile for GLw library - lots of modifications for XFree86 by
+XCOMM Carlos A. M. dos Santos <casantos@cpmet.ufpel.tche.br>
+XCOMM
+
+XCOMM Uncomment this and set the correct values if your Motif installation
+XCOMM is out of the standard X tree and your Imake configuration is not
+XCOMM correct (unfortunatelly, a common mistake).
+
+XCOMM MOTIF_INCLUDES = -I/usr/local/include
+XCOMM MOTIF_LDFLAGS  = -L/usr/local/lib
+
+#define DoNormalLib	NormalLibGLw
+#define DoSharedLib	SharedLibGLw
+#define DoDebugLib	DebugLibGLw
+#define DoProfileLib	ProfileLibGLw
+
+#define HasSharedData	NO
+#define LibName GLw
+#define SoRev SOGLWREV
+#define IncSubdir GL
+
+REQUIREDLIBS = $(LDPRELIBS) $(XLIB)
+
+DEFINES = 
+
+#if GLwUseXmStubs
+SHAREDCODEDEF = SharedCodeDef -DUSE_XM_STUBS
+#endif
+
+GLWSRCDIR = $(OGLSAMPLESRCDIR)/main/gfx/lib/glw
+
+INCLUDES = $(MOTIF_INCLUDES) -I.
+
+LOCAL_LDFLAGS = $(MOTIF_LDFLAGS)
+
+LINTLIBS = $(LINTXLIB) $(LINTXTOOL)
+
+HEADERS = GLwDrawA.h GLwDrawAP.h GLwMDrawA.h GLwMDrawAP.h
+SRCS = GLwDrawA.c GLwM1DrawA.c GLwM2DrawA.c GLwDAUtil.c
+OBJS = GLwDrawA.o GLwM1DrawA.o GLwM2DrawA.o GLwDAUtil.o
+
+#include <Library.tmpl>
+
+LinkSourceFile(GLwDAUtil.c,$(GLWSRCDIR))
+LinkSourceFile(GLwDrawA.c,$(GLWSRCDIR))
+LinkSourceFile(GLwMDrawA.c,$(GLWSRCDIR))
+LinkSourceFile(GLwDrawA.h,$(GLWSRCDIR))
+LinkSourceFile(GLwDrawAP.h,$(GLWSRCDIR))
+LinkSourceFile(GLwMDrawA.h,$(GLWSRCDIR))
+LinkSourceFile(GLwMDrawAP.h,$(GLWSRCDIR))
+
+DependTarget()
Index: xc/lib/GLw/README.html
diff -u /dev/null xc/lib/GLw/README.html:1.2
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GLw/README.html	Mon Nov  6 16:57:10 2000
@@ -0,0 +1,242 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+<HEAD>
+<TITLE>GL widgets for Xt/Motif - XFree86 implementation</TITLE>
+<META NAME="generator" CONTENT="Only VIM and me.">
+</HEAD>
+<BODY BGCOLOR="#FFFFFF">
+
+<!-- $XFree86: xc/lib/GLw/README.html,v 1.2 2000/11/06 21:57:10 dawes Exp $ -->
+
+<H1 ALIGN=CENTER>GL widgets for Xt/Motif</H1>
+<H2 ALIGN=CENTER>XFree86 implementation</H1>
+<P ALIGN=CENTER>by Carlos A. M. dos Santos<BR>casantos@cpmet.ufpel.tche.br</P>
+
+<HR NOSHADE>
+
+<H3>1. Introduction</H3>
+<P>
+This directory contains the source code for SGI's OpenGL Xt/Motif(TM) widgets,
+slightly modified to generate both Motif 1.x and 2.x versions of
+the widget even if Motif is not available, as in the XFree86 distribution of
+the X Window System. This code is based on that distributed by Silicon
+Graphics as part of it's OpenGL Sample Implementation, not on the modified version
+distributed with Mesa.
+
+
+<H3>2. Installation</H3>
+<P>
+This code is intended to be compiled as part of the normal XFree86 building
+process, under the xc/lib/GLw directory. To compile the library out of the X
+source tree, follow instructions below.
+
+<H3>2.1. Requirements</H3>
+<P>
+Gzip and tar are needed to extract the files from the distribution <A
+HREF="http://www.inf.ufrgs.br/~casantos/libGLw/GLw.tar.gz">archive</A>. Tar is
+a standard UNIX utility but if you don't have it use GNU tar, available in
+source form at <A
+HREF="ftp://ftp.gnu.org/pub/gnu/">ftp://ftp.gnu.org/pub/gnu/</A>.  Gzip is not
+a standard UNIX utility, though available in many systems. You may obtain it
+(also source form) at the same FTP server as GNU tar.
+
+<P>
+You need xmkmf and imake too. Depending on your operating system you may need
+to install some kind of X Window System development kit, so check the vendor
+documentation first. I was told that some UNIX systems don't have imake:
+report this as a bug (to your vendor, not me).
+
+<P>
+Of course you will need a C compiler.
+
+<H3>2.2. Steps</H3>
+<P>
+<OL>
+  <LI>Extract the source code from the distribution archive.
+      <P>
+      <CODE>
+       gzip -dc GLw.tar.gz | tar xf -
+      </CODE>
+      <P>
+  <LI>Go to the surce code directory and generate the makefile.
+      <P>
+      <CODE>
+       cd GLw<BR>
+       xmkmf
+      </CODE>
+      <P>For LessTif, use "mxmkmf" instead of "xmkmf". Imake support
+       is much better in recent versions of LessTif (since late july 2000).
+       If your Motif or OpenGL libraries and/or include files are installed in
+       non-standard locations (some UNIX vendors seem to be very creative :-)
+       then edit the file named Imakefile, remove the leading XCOMM of the
+       lines containing MOTIF_INCLUDES and MOTIF_LDFLAGS and set the
+       appropriate values.
+      <P>
+  <LI>Compile the code with
+      <P>
+      <CODE>
+       make includes<BR>
+       make standalone
+      </CODE>
+      <P>
+  <LI>Install the library and manual pages with
+      <P>
+      <CODE>
+       make install<BR>
+       make install.man
+      </CODE>
+      <P>
+  <LI>Optionally, you may compile two test programs: xmdemo and xtdemo. You need OpenGL
+      (or Mesa) for both and Motif (or LessTif) for xmdemo. There are four
+      extra make targers for these programs: demos, stand-demos, stand-xmdemo
+      and stand-xtdemo. You may use them with:
+      <P>
+      <CODE>
+       make stand-demos<BR>
+       ./xmdemo
+       ./xtdemo
+      </CODE>
+</OL>
+
+<H3>2.3. Creating a shared library</H3>
+<P>
+By default only a static library is created because most of the UNIX loaders,
+if not all, complain about unresolved symbols even if the application doesn't
+use the modules in which such symbols are referenced. However, if your system
+supports libraries with weak symbols (e.g. Solaris, FreeBSD and Linux) it is
+possible to fool the loader. All you have to do is edit the Imakefile,
+changing "#define SharedLibGLw" and "#define GLwUseXmStubs" to YES, then
+repeat the compilation process starting from step 2 in the previous section.
+
+<H3>2.4. Problems</H3>
+<P>
+If you have trouble, ask for help in the XFree86 "xperts" mailing list. Look
+at <A HREF="http://www.xfree86.org">http://www.xfree86.org</A> for
+instructions on how to subscribe.  In desperation, send an email to <A
+HREF="mailto:casantos@cpmet.ufpel.tche.br">casantos@cpmet.ufpel.tche.br</A>.
+
+<P>
+PLEASE DO NOT SEND ME EMAIL ASKING HOW TO INSTALL OR CONFIGURE YOUR OPERATING
+SYSTEM, MODEM, NETWORK CARD, BREAD TOASTER, COFEE MAKER OR WHATEVER ELSE!
+
+
+<H3>3. Copyrights</H3>
+<P>
+Most of the code is covered by the following license terms:
+<BLOCKQUOTE>
+<P>
+License Applicability. Except to the extent portions of this file are
+made subject to an alternative license as permitted in the SGI Free
+Software License B, Version 1.1 (the "License"), the contents of this
+file are subject only to the provisions of the License. You may not use
+this file except in compliance with the License. You may obtain a copy
+of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+<P>
+<A
+HREF="http://oss.sgi.com/projects/FreeB">http://oss.sgi.com/projects/FreeB</A>
+<P>
+Note that, as provided in the License, the Software is distributed on an
+"AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+<P>
+Original Code. The Original Code is: OpenGL Sample Implementation,
+Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+Inc. The Original Code is Copyright &copy; 1991-2000 Silicon Graphics, Inc.
+Copyright in any portions created by third parties is as indicated
+elsewhere herein. All Rights Reserved.
+<P>
+Additional Notice Provisions: The application programming interfaces
+established by SGI in conjunction with the Original Code are The
+OpenGL&reg; Graphics System: A Specification (Version 1.2.1), released
+April 1, 1999; The OpenGL&reg; Graphics System Utility Library (Version
+1.3), released November 4, 1998; and OpenGL&reg; Graphics with the X
+Window System&reg; (Version 1.3), released October 19, 1998. This software
+was created using the OpenGL&reg; version 1.2.1 Sample Implementation
+published by SGI, but has not been independently verified as being
+compliant with the OpenGL&reg; version 1.2.1 Specification.
+</BLOCKQUOTE>
+
+<P>
+The demonstration programs are covered by the following license terms:
+
+<BLOCKQUOTE>
+<P>
+Copyright &copy; Mark J. Kilgard, 1995, 1996.
+
+<P>
+NOTICE:  This source code distribution contains source code contained in
+the book "Programming OpenGL for the X Window System" (ISBN:
+0-201-48359-9) published by Addison-Wesley.  The programs and associated
+files contained in the distribution were developed by Mark J. Kilgard and
+are Copyright 1994, 1995, 1996 by Mark J.  Kilgard (unless otherwise
+noted).  The programs are not in the public domain, but they are freely
+distributable without licensing fees.  These programs are provided without
+guarantee or warrantee expressed or implied.
+</BLOCKQUOTE>
+
+<P>
+The files contained in directory GLwXm are fake Motif headers, covered by
+the XFree86 license, they permit us to generate both Motif 1.x and 2.x
+versions of the widget without having Motif.  Notice that they are NOT part of
+a standard Motif distribution and shall not be used to compile any other code.
+
+
+<H3>4. Thanks</H3>
+
+<P>
+Many thanks to Silicon Graphics and Mark J. Kilgard for making their
+software free.
+
+
+<H3>5. No thanks</H3>
+
+<BLOCKQUOTE>
+<P>
+<STRONG>
+THIS SECTION CONTAINS MY PERSONAL OPINIONS AND
+DOESN'T REPRESENT AN OFFICIAL POSITION OF THE XFree86 PROJECT.
+</STRONG>
+</BLOCKQUOTE>
+
+<P>
+The first incarnation of this version of libGLw used eight header files from
+<A HREF="http://www.lesstif.org/">LessTif</A>, four for each Motif version.
+LessTif is covered by the GNU Library General Public License (LGPL) whose
+terms are not compatible with the XFree86 licensing policy.  Since the
+copyright holder of LessTif is the <A HREF="http://www.fsf.org/">Free Software
+Foundation</A> (FSF), I asked Richard Stallman, president of FSF and so called
+"leader of the Free Software movement", permission to redistribute a copy of
+those eight headers under XFree86 terms, still maintaining the FSF copyright.
+
+<P>
+Observe that I was not asking him to change the license of LessTif as a whole,
+but only to allow me to distribute copies of some header files containing
+function prototypes, variable declarations and data type definitions. Even so,
+Stallman said no because the files contained "more than 6000 lines of code".
+Which code? The LessTif headers are mostly copies of the Motif ones and don't
+contain any original GNU "code"! I can't still imagine a reason for Stallman's
+negative answer except for paranoia.  He seems to ignore what Motif is and
+that LessTif's API is simply a copy of Motif's one.
+
+<P>
+After spending some time, I made my own headers, that became much smaller than
+the previous ones because I included only a subset of the Motif API and merged
+everything into four files: 417 lines instead 6000. Humm, perhaps I should be
+grateful to Sallman too :-).
+
+
+<H3>6. Trademarks</H3>
+
+<P>
+<UL>
+  <LI>OpenGL is a trademark of Silicon Graphics, Inc.
+  <LI>Motif is a trademark of the Open Group.
+</UL>
+
+<HR NOSHADE>
+
+</BODY>
+</HTML>
Index: xc/lib/GLw/README.txt
diff -u /dev/null xc/lib/GLw/README.txt:1.2
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GLw/README.txt	Mon Nov  6 16:57:10 2000
@@ -0,0 +1,199 @@
+                           GL widgets for Xt/Motif
+
+                           XFree86 implementation
+
+                         by Carlos A. M. dos Santos
+                        casantos@cpmet.ufpel.tche.br
+
+  ------------------------------------------------------------------------
+
+1. Introduction
+
+This directory contains the source code for SGI's OpenGL Xt/Motif(TM)
+widgets, slightly modified to generate both Motif 1.x and 2.x versions of
+the widget even if Motif is not available, as in the XFree86 distribution of
+the X Window System. This code is based on that distributed by Silicon
+Graphics as part of it's OpenGL Sample Implementation, not on the modified
+version distributed with Mesa.
+
+2. Installation
+
+This code is intended to be compiled as part of the normal XFree86 building
+process, under the xc/lib/GLw directory. To compile the library out of the X
+source tree, follow instructions below.
+
+2.1. Requirements
+
+Gzip and tar are needed to extract the files from the distribution archive.
+Tar is a standard UNIX utility but if you don't have it use GNU tar,
+available in source form at ftp://ftp.gnu.org/pub/gnu/. Gzip is not a
+standard UNIX utility, though available in many systems. You may obtain it
+(also source form) at the same FTP server as GNU tar.
+
+You need xmkmf and imake too. Depending on your operating system you may
+need to install some kind of X Window System development kit, so check the
+vendor documentation first. I was told that some UNIX systems don't have
+imake: report this as a bug (to your vendor, not me).
+
+Of course you will need a C compiler.
+
+2.2. Steps
+
+  1. Extract the source code from the distribution archive.
+
+     gzip -dc GLw.tar.gz | tar xf -
+
+  2. Go to the surce code directory and generate the makefile.
+
+     cd GLw
+     xmkmf
+
+     For LessTif, use "mxmkmf" instead of "xmkmf". Imake support is much
+     better in recent versions of LessTif (since late july 2000). If your
+     Motif or OpenGL libraries and/or include files are installed in
+     non-standard locations (some UNIX vendors seem to be very creative :-)
+     then edit the file named Imakefile, remove the leading XCOMM of the
+     lines containing MOTIF_INCLUDES and MOTIF_LDFLAGS and set the
+     appropriate values.
+
+  3. Compile the code with
+
+     make includes
+     make standalone
+
+  4. Install the library and manual pages with
+
+     make install
+     make install.man
+
+  5. Optionally, you may compile two test programs: xmdemo and xtdemo. You
+     need OpenGL (or Mesa) for both and Motif (or LessTif) for xmdemo. There
+     are four extra make targers for these programs: demos, stand-demos,
+     stand-xmdemo and stand-xtdemo. You may use them with:
+
+     make stand-demos
+     ./xmdemo ./xtdemo
+
+2.3. Creating a shared library
+
+By default only a static library is created because most of the UNIX
+loaders, if not all, complain about unresolved symbols even if the
+application doesn't use the modules in which such symbols are referenced.
+However, if your system supports libraries with weak symbols (e.g. Solaris,
+FreeBSD and Linux) it is possible to fool the loader. All you have to do is
+edit the Imakefile, changing "#define SharedLibGLw" and "#define
+GLwUseXmStubs" to YES, then repeat the compilation process starting from
+step 2 in the previous section.
+
+2.4. Problems
+
+If you have trouble, ask for help in the XFree86 "xperts" mailing list. Look
+at http://www.xfree86.org for instructions on how to subscribe. In
+desperation, send an email to casantos@cpmet.ufpel.tche.br.
+
+PLEASE DO NOT SEND ME EMAIL ASKING HOW TO INSTALL OR CONFIGURE YOUR
+OPERATING SYSTEM, MODEM, NETWORK CARD, BREAD TOASTER, COFEE MAKER OR
+WHATEVER ELSE!
+
+3. Copyrights
+
+Most of the code is covered by the following license terms:
+
+     License Applicability. Except to the extent portions of this file
+     are made subject to an alternative license as permitted in the SGI
+     Free Software License B, Version 1.1 (the "License"), the contents
+     of this file are subject only to the provisions of the License.
+     You may not use this file except in compliance with the License.
+     You may obtain a copy of the License at Silicon Graphics, Inc.,
+     attn: Legal Services, 1600 Amphitheatre Parkway, Mountain View, CA
+     94043-1351, or at:
+
+     http://oss.sgi.com/projects/FreeB
+
+     Note that, as provided in the License, the Software is distributed
+     on an "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND
+     CONDITIONS DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+     WARRANTIES AND CONDITIONS OF MERCHANTABILITY, SATISFACTORY
+     QUALITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+
+     Original Code. The Original Code is: OpenGL Sample Implementation,
+     Version 1.2.1, released January 26, 2000, developed by Silicon
+     Graphics, Inc. The Original Code is Copyright © 1991-2000 Silicon
+     Graphics, Inc. Copyright in any portions created by third parties
+     is as indicated elsewhere herein. All Rights Reserved.
+
+     Additional Notice Provisions: The application programming
+     interfaces established by SGI in conjunction with the Original
+     Code are The OpenGL® Graphics System: A Specification (Version
+     1.2.1), released April 1, 1999; The OpenGL® Graphics System
+     Utility Library (Version 1.3), released November 4, 1998; and
+     OpenGL® Graphics with the X Window System® (Version 1.3), released
+     October 19, 1998. This software was created using the OpenGL®
+     version 1.2.1 Sample Implementation published by SGI, but has not
+     been independently verified as being compliant with the OpenGL®
+     version 1.2.1 Specification.
+
+The demonstration programs are covered by the following license terms:
+
+     Copyright © Mark J. Kilgard, 1995, 1996.
+
+     NOTICE: This source code distribution contains source code
+     contained in the book "Programming OpenGL for the X Window System"
+     (ISBN: 0-201-48359-9) published by Addison-Wesley. The programs
+     and associated files contained in the distribution were developed
+     by Mark J. Kilgard and are Copyright 1994, 1995, 1996 by Mark J.
+     Kilgard (unless otherwise noted). The programs are not in the
+     public domain, but they are freely distributable without licensing
+     fees. These programs are provided without guarantee or warrantee
+     expressed or implied.
+
+The files contained in directory GLwXm are fake Motif headers, covered by
+the XFree86 license, they permit us to generate both Motif 1.x and 2.x
+versions of the widget without having Motif. Notice that they are NOT part
+of a standard Motif distribution and shall not be used to compile any other
+code.
+
+4. Thanks
+
+Many thanks to Silicon Graphics and Mark J. Kilgard for making their
+software free.
+
+5. No thanks
+
+     THIS SECTION CONTAINS MY PERSONAL OPINIONS AND DOESN'T REPRESENT
+     AN OFFICIAL POSITION OF THE XFree86 PROJECT.
+
+The first incarnation of this version of libGLw used eight header files from
+LessTif, four for each Motif version. LessTif is covered by the GNU Library
+General Public License (LGPL) whose terms are not compatible with the
+XFree86 licensing policy. Since the copyright holder of LessTif is the Free
+Software Foundation (FSF), I asked Richard Stallman, president of FSF and so
+called "leader of the Free Software movement", permission to redistribute a
+copy of those eight headers under XFree86 terms, still maintaining the FSF
+copyright.
+
+Observe that I was not asking him to change the license of LessTif as a
+whole, but only to allow me to distribute copies of some header files
+containing function prototypes, variable declarations and data type
+definitions. Even so, Stallman said no because the files contained "more
+than 6000 lines of code". Which code? The LessTif headers are mostly copies
+of the Motif ones and don't contain any original GNU "code"! I can't still
+imagine a reason for Stallman's negative answer except for paranoia. He
+seems to ignore what Motif is and that LessTif's API is simply a copy of
+Motif's one.
+
+After spending some time, I made my own headers, that became much smaller
+than the previous ones because I included only a subset of the Motif API and
+merged everything into four files: 417 lines instead 6000. Humm, perhaps I
+should be grateful to Sallman too :-).
+
+6. Trademarks
+
+   * OpenGL is a trademark of Silicon Graphics, Inc.
+   * Motif is a trademark of the Open Group.
+
+  ------------------------------------------------------------------------
+
+
+
+$XFree86: xc/lib/GLw/README.txt,v 1.2 2000/11/06 21:57:10 dawes Exp $
Index: xc/lib/GLw/GLwXm/PrimitiveP.h
diff -u /dev/null xc/lib/GLw/GLwXm/PrimitiveP.h:1.1
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GLw/GLwXm/PrimitiveP.h	Thu Nov  2 15:39:08 2000
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+/* $XFree86: xc/lib/GLw/GLwXm/PrimitiveP.h,v 1.1 2000/11/02 20:39:08 dawes Exp $ */
+
+/*
+ * This file is a fake Motif(TM) header intended to allow the compilation of
+ * libGLw without having a real Motif.  Do not use this file to compile any
+ * application because it declares only a small subset of the API!
+ */
+
+#ifndef GLWXM_PRIMITIVE_P_H
+#define GLWXM_PRIMITIVE_P_H
+
+#include "GLwXm/XmP.h"
+
+/* primitive instance part */
+typedef struct {
+    Pixel foreground;
+    Dimension shadow_thickness;
+    Pixel top_shadow_color;
+    Pixmap top_shadow_pixmap;
+    Pixel bottom_shadow_color;
+    Pixmap bottom_shadow_pixmap;
+    Dimension highlight_thickness;
+    Pixel highlight_color;
+    Pixmap highlight_pixmap;
+    XtCallbackList help_callback;
+    XtPointer user_data;
+    Boolean traversal_on;
+    Boolean highlight_on_enter;
+    Boolean have_traversal;
+    unsigned char unit_type;
+    XmNavigationType navigation_type;
+    Boolean highlight_drawn;
+    Boolean highlighted;
+    GC highlight_GC;
+    GC top_shadow_GC;
+    GC bottom_shadow_GC;
+#if XmVERSION > 1
+    XtCallbackList convert_callback; 
+    XtCallbackList popup_handler_callback; 
+    XmDirection layout_direction; 
+#endif
+} XmPrimitivePart;
+
+/* primitive class part */
+typedef struct {
+    XtWidgetProc border_highlight;
+    XtWidgetProc border_unhighlight;
+    String translations;
+    XtActionProc arm_and_activate;
+    XmSyntheticResource *syn_resources;
+    int num_syn_resources;
+    XtPointer extension;
+} XmPrimitiveClassPart;
+
+/* class record */
+typedef struct _XmPrimitiveClassRec {
+    CoreClassPart core_class;
+    XmPrimitiveClassPart primitive_class;
+} XmPrimitiveClassRec;
+
+/* declare class record */
+extern XmPrimitiveClassRec xmPrimitiveClassRec;
+
+#endif /* GLWXM_PRIMITIVE_P_H */
Index: xc/lib/GLw/GLwXm/Xm.h
diff -u /dev/null xc/lib/GLw/GLwXm/Xm.h:1.1
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GLw/GLwXm/Xm.h	Thu Nov  2 15:39:08 2000
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+/* $XFree86: xc/lib/GLw/GLwXm/Xm.h,v 1.1 2000/11/02 20:39:08 dawes Exp $ */
+
+/*
+ * This file is a fake Motif(TM) header intended to allow the compilation of
+ * libGLw without having a real Motif.  Do not use this file to compile any
+ * application because it declares only a small subset of the API!
+ */
+
+#ifndef GLWXM_H
+#define GLWXM_H
+
+#include <X11/Intrinsic.h>
+#include <X11/Shell.h>
+#include <X11/Xatom.h>
+#include "GLwXm/XmStrDefs.h"
+
+enum {
+    XmATTACH_NONE,
+    XmATTACH_FORM,
+    XmATTACH_OPPOSITE_FORM,
+    XmATTACH_WIDGET,
+    XmATTACH_OPPOSITE_WIDGET,
+    XmATTACH_POSITION,
+    XmATTACH_SELF
+};
+
+enum {
+    XmCR_NONE,
+    XmCR_HELP,
+    XmCR_VALUE_CHANGED,
+    XmCR_INCREMENT,
+    XmCR_DECREMENT,
+    XmCR_PAGE_INCREMENT,
+    XmCR_PAGE_DECREMENT,
+    XmCR_TO_TOP,
+    XmCR_TO_BOTTOM,
+    XmCR_DRAG,
+    XmCR_ACTIVATE,
+    XmCR_ARM,
+    XmCR_DISARM,
+    XmCR_DUMMY13,
+    XmCR_DUMMY14,
+    XmCR_DUMMY15,
+    XmCR_MAP,
+    XmCR_UNMAP,
+    XmCR_FOCUS,
+    XmCR_LOSING_FOCUS,
+    XmCR_MODIFYING_TEXT_VALUE,
+    XmCR_MOVING_INSERT_CURSOR,
+    XmCR_EXECUTE,
+    XmCR_SINGLE_SELECT,
+    XmCR_MULTIPLE_SELECT,
+    XmCR_EXTENDED_SELECT,
+    XmCR_BROWSE_SELECT,
+    XmCR_DEFAULT_ACTION,
+    XmCR_CLIPBOARD_DATA_REQUEST,
+    XmCR_CLIPBOARD_DATA_DELETE,
+    XmCR_CASCADING,
+    XmCR_OK,
+    XmCR_CANCEL,
+    XmCR_DUMMY33,
+    XmCR_APPLY,
+    XmCR_NO_MATCH,
+    XmCR_COMMAND_ENTERED,
+    XmCR_COMMAND_CHANGED,
+    XmCR_EXPOSE,
+    XmCR_RESIZE,
+    XmCR_INPUT,
+    XmCR_GAIN_PRIMARY,
+    XmCR_LOSE_PRIMARY,
+    XmCR_CREATE,
+    XmCR_TEAR_OFF_ACTIVATE,
+    XmCR_TEAR_OFF_DEACTIVATE,
+    XmCR_OBSCURED_TRAVERSAL,
+#if XmVERSION < 2
+    XmCR_PROTOCOLS
+#else
+    XmCR_FOCUS_MOVED,
+    XmCR_DUMMY48,
+    XmCR_DUMMY49,
+    XmCR_DUMMY50,
+    XmCR_DUMMY51,
+    XmCR_DUMMY52,
+    XmCR_DUMMY53,
+    XmCR_REPOST,
+    XmCR_COLLAPSED,
+    XmCR_EXPANDED,
+    XmCR_SELECT,
+    XmCR_DRAG_START,
+    XmCR_NO_FONT,
+    XmCR_NO_RENDITION,
+    XmCR_POST,
+    XmCR_SPIN_NEXT,
+    XmCR_SPIN_PRIOR,
+    XmCR_SPIN_FIRST,
+    XmCR_SPIN_LAST,
+    XmCR_PAGE_SCROLLER_INCREMENT,
+    XmCR_PAGE_SCROLLER_DECREMENT,
+    XmCR_MAJOR_TAB,
+    XmCR_MINOR_TAB,
+    XmCR_PROTOCOLS = 6666
+#endif
+};
+
+typedef unsigned char XmDirection;
+
+typedef struct {
+    int reason;
+    XEvent *event;
+    Window window;
+} XmDrawingAreaCallbackStruct;
+
+#define XmUNSPECIFIED_PIXMAP 2
+
+typedef unsigned char XmNavigationType;
+
+#endif /* GLWXM_H */
Index: xc/lib/GLw/GLwXm/XmP.h
diff -u /dev/null xc/lib/GLw/GLwXm/XmP.h:1.1
--- /dev/null	Mon Dec 18 14:23:43 2000
+++ xc/lib/GLw/GLwXm/XmP.h	Thu Nov  2 15:39:08 2000
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+/* $XFree86: xc/lib/GLw/GLwXm/XmP.h,v 1.1 2000/11/02 20:39:08 dawes Exp $ */
+
+/*
+ * This file is a fake Motif(TM) header intended to allow the compilation of
+ * libGLw without having a real Motif.  Do not use this file to compile any
+ * application because it declares only a small subset of the API!
+ */
+
+#ifndef GLWXM_P_H
+#define GLWXM_P_H
+
+#include "GLwXm/Xm.h"
+#include <X11/IntrinsicP.h>
+
+#define XmInheritBorderHighlight   ((XtWidgetProc) _XtInherit)
+#define XmInheritBorderUnhighlight ((XtWidgetProc) _XtInherit)
+
+void _XmBackgroundColorDefault(Widget widget, int offset, XrmValue *value);
+void _XmForegroundColorDefault(Widget widget, int offset, XrmValue *value);
+void _XmHighlightColorDefault(Widget widget, int offset, XrmValue *value);
+void _XmPrimitiveHighlightPixmapDefault(Widget widget, int offset,
+					XrmValue *value);
+
+typedef enum { 
+    XmSYNTHETIC_NONE, 
+    XmSYNTHETIC_LOAD 
+} XmImportOperator;
+
+typedef void (*XmExportProc)(Widget, int, XtArgVal *);
+
+typedef XmImportOperator (*XmImportProc)(Widget, int, XtArgVal*);
+
+typedef struct _XmSyntheticResource {
+    String resource_name;
+    Cardinal resource_size;
+    Cardinal resource_offset;
+    XmExportProc export_proc;
+    XmImportProc import_proc;
+} XmSyntheticResource;
+
+#endif /* GLWXM_P_H */
Index: xc/lib/GLw/GLwXm/XmStrDefs.h
diff -u /dev/null xc/lib/GLw/GLwXm/XmStrDefs.h:1.1
--- /dev/null	Mon Dec 18 14:23:44 2000
+++ xc/lib/GLw/GLwXm/XmStrDefs.h	Thu Nov  2 15:39:08 2000
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2000 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+/* $XFree86: xc/lib/GLw/GLwXm/XmStrDefs.h,v 1.1 2000/11/02 20:39:08 dawes Exp $ */
+
+/*
+ * This file is a fake Motif(TM) header intended to allow the compilation of
+ * libGLw without having a real Motif.  Do not use this file to compile any
+ * application because it declares only a small subset of the API!
+ */
+
+#ifndef GLWXM_STRDEFS_H
+#define GLWXM_STRDEFS_H
+
+#ifndef _XmConst
+#define _XmConst /**/
+#endif
+
+#ifdef XMSTRINGDEFINES
+
+#define XmCBackgroundPixmap	"BackgroundPixmap"
+#define XmRBackgroundPixmap	"BackgroundPixmap"
+#define XmRBooleanDimension	"BooleanDimension"
+#define XmNbottomAttachment	"bottomAttachment"
+#define XmNbottomWidget		"bottomWidget"
+#define XmCForegroundThreshold	"ForegroundThreshold"
+#define XmNforegroundThreshold	"foregroundThreshold"
+#define XmCHighlightColor	"HighlightColor"
+#define XmNhighlightColor	"highlightColor"
+#define XmCHighlightOnEnter	"HighlightOnEnter"
+#define XmNhighlightOnEnter	"highlightOnEnter"
+#define XmCHighlightThickness	"HighlightThickness"
+#define XmNhighlightThickness	"highlightThickness"
+#define XmCHighlightPixmap	"HighlightPixmap"
+#define XmNhighlightPixmap	"highlightPixmap"
+#define XmRHighlightPixmap	"HighlightPixmap"
+#define XmRHorizontalDimension	"HorizontalDimension"
+#define XmNleftAttachment	"leftAttachment"
+#define XmNrightAttachment	"rightAttachment"
+#define XmRStringDirection	"StringDirection"
+#define XmNtopAttachment	"topAttachment"
+#define XmCTraversalOn		"TraversalOn"
+#define XmNtraversalOn		"traversalOn"
+#define XmRXmBackgroundPixmap	"XmBackgroundPixmap"
+
+#else /* XMSTRINGDEFINES */
+
+extern _XmConst char _XmStrings[];
+
+#define XmCBackgroundPixmap	((char *)&_XmStrings[299])
+#define XmRBackgroundPixmap	((char *)&_XmStrings[10844])
+#define XmRBooleanDimension	((char *)&_XmStrings[10872])
+#define XmNbottomAttachment	((char *)&_XmStrings[5017])
+#define XmNbottomWidget		((char *)&_XmStrings[5099])
+#define XmCHighlightColor	((char *)&_XmStrings[1844])
+#define XmNhighlightColor	((char *)&_XmStrings[6996])
+#define XmCHighlightOnEnter	((char *)&_XmStrings[1859])
+#define XmNhighlightOnEnter	((char *)&_XmStrings[7011])
+#define XmCHighlightThickness	((char *)&_XmStrings[1892])
+#define XmNhighlightThickness	((char *)&_XmStrings[7044])
+#define XmCForegroundThreshold	((char *)&_XmStrings[1808])
+#define XmNforegroundThreshold	((char *)&_XmStrings[6914])
+#define XmCHighlightPixmap	((char *)&_XmStrings[1876])
+#define XmNhighlightPixmap	((char *)&_XmStrings[7028])
+#define XmRHighlightPixmap	((char *)&_XmStrings[11299])
+#define XmRHorizontalDimension	((char *)&_XmStrings[11315])
+#define XmNleftAttachment	((char *)&_XmStrings[7523])
+#define XmNrightAttachment	((char *)&_XmStrings[9077])
+#define XmRStringDirection	((char *)&_XmStrings[11981])
+#define XmNtopAttachment	((char *)&_XmStrings[10165])
+#define XmCTraversalOn		((char *)&_XmStrings[4318])
+#define XmNtraversalOn		((char *)&_XmStrings[10361])
+#define XmRXmBackgroundPixmap	((char *)&_XmStrings[12210])
+
+#endif /* XMSTRINGDEFINES */
+
+/* copy Xt constant definitions */
+#include <X11/StringDefs.h>
+
+#define XmCBackground		XtCBackground
+#define XmNbackground		XtNbackground
+#define XmNbackgroundPixmap	XtNbackgroundPixmap
+#define XmCBoolean		XtCBoolean
+#define XmRBoolean		XtRBoolean
+#define XmRCallProc		XtRCallProc
+#define XmCForeground		XtCForeground
+#define XmNforeground		XtNforeground
+#define XmRImmediate		XtRImmediate
+#define XmRPixel		XtRPixel
+#define XmCPixmap		XtCPixmap
+#define XmNpixmap		XtNpixmap
+#define XmRPixmap		XtRPixmap
+#define XmRPrimHighlightPixmap	XmRHighlightPixmap
+#define XmRString		XtRString
+#define XmRStringArray		XtRStringArray
+#define XmRStringTable		XtRStringTable
+
+#endif /* GLWXM_STRDEFS_H */
Index: xc/lib/ICE/ICE-def.cpp
diff -u xc/lib/ICE/ICE-def.cpp:1.2 xc/lib/ICE/ICE-def.cpp:1.3
--- xc/lib/ICE/ICE-def.cpp:1.2	Sat Jan 10 22:48:11 1998
+++ xc/lib/ICE/ICE-def.cpp	Wed Aug  9 19:40:12 2000
@@ -61,4 +61,6 @@
  _IceReadSkip
  _IceWrite
  IceListenForWellKnownConnections
+ _IceTransGetHostname
 /* $TOG: ICE-def.cpp /main/7 1998/01/04 12:31:53 kaleb $ */
+/* $XFree86: xc/lib/ICE/ICE-def.cpp,v 1.3 2000/08/09 23:40:12 dawes Exp $ */
Index: xc/lib/X11/AllPlanes.c
diff -u xc/lib/X11/AllPlanes.c:1.1.1.2 xc/lib/X11/AllPlanes.c:1.2
--- xc/lib/X11/AllPlanes.c:1.1.1.2	Sun Sep 27 03:55:06 1998
+++ xc/lib/X11/AllPlanes.c	Tue Sep 26 11:56:51 2000
@@ -20,6 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
+/* $XFree86: xc/lib/X11/AllPlanes.c,v 1.2 2000/09/26 15:56:51 tsi Exp $ */
 
 #define NEED_REPLIES
 #include "Xlibint.h"
@@ -57,7 +58,7 @@
 	*bmask = rep.blueMask;
 
 	/* sizeof(CARD32) = 4 */
-	_XRead32 (dpy, (char *) pixels, (long)(ncolors * 4));
+	_XRead32 (dpy, (long *) pixels, (long)(ncolors * 4));
     }
 
     UnlockDisplay(dpy);
Index: xc/lib/X11/Font.c
diff -u xc/lib/X11/Font.c:1.9 xc/lib/X11/Font.c:1.11
--- xc/lib/X11/Font.c:1.9	Tue Jun 13 19:15:47 2000
+++ xc/lib/X11/Font.c	Tue Sep 26 11:56:51 2000
@@ -28,7 +28,7 @@
 authorization from the X Consortium and the XFree86 Project.
 
 */
-/* $XFree86: xc/lib/X11/Font.c,v 1.9 2000/06/13 23:15:47 dawes Exp $ */
+/* $XFree86: xc/lib/X11/Font.c,v 1.11 2000/09/26 15:56:51 tsi Exp $ */
 
 #define NEED_REPLIES
 #include "Xlibint.h"
@@ -39,9 +39,14 @@
 #ifdef USE_XF86BIGFONT
 #include <sys/types.h>
 #ifdef HAS_SHM
+#ifndef __CYGWIN__
 #include <sys/ipc.h>
+#else
+#include <sys/cygipc.h>
+#endif
 #include <sys/shm.h>
 #endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <X11/extensions/xf86bigfstr.h>
@@ -279,7 +284,7 @@
 			  (nbytes + reply.nCharInfos * SIZEOF(xCharInfo)));
 		return (XFontStruct *)NULL;
 	    }
-	    _XRead32 (dpy, (char *)fs->properties, nbytes);
+	    _XRead32 (dpy, (long *)fs->properties, nbytes);
     }
     /*
      * If no characters in font, then it is a bad font, but
@@ -541,7 +546,7 @@
 		         : 0));
 	    return (XFontStruct *)NULL;
 	}
-	_XRead32 (dpy, (char *)fs->properties, nbytes);
+	_XRead32 (dpy, (long *)fs->properties, nbytes);
     }
 
     fs->per_char = NULL;
Index: xc/lib/X11/FontInfo.c
diff -u xc/lib/X11/FontInfo.c:1.3 xc/lib/X11/FontInfo.c:1.4
--- xc/lib/X11/FontInfo.c:1.3	Tue Jun 13 19:15:47 2000
+++ xc/lib/X11/FontInfo.c	Tue Sep 26 11:56:51 2000
@@ -20,7 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/FontInfo.c,v 1.3 2000/06/13 23:15:47 dawes Exp $ */
+/* $XFree86: xc/lib/X11/FontInfo.c,v 1.4 2000/09/26 15:56:51 tsi Exp $ */
 
 #define NEED_REPLIES
 #include "Xlibint.h"
@@ -171,7 +171,7 @@
 	    if (! (fs->properties = (XFontProp *) Xmalloc((unsigned) nbytes)))
 		goto badmem;
 	    nbytes = reply.nFontProps * SIZEOF(xFontProp);
-	    _XRead32 (dpy, (char *)fs->properties, nbytes);
+	    _XRead32 (dpy, (long *)fs->properties, nbytes);
 
 	} else
 	    fs->properties = NULL;
Index: xc/lib/X11/GetPntMap.c
diff -u xc/lib/X11/GetPntMap.c:1.3 xc/lib/X11/GetPntMap.c:1.4
--- xc/lib/X11/GetPntMap.c:1.3	Sat Oct  3 04:41:18 1998
+++ xc/lib/X11/GetPntMap.c	Tue Sep 26 11:56:51 2000
@@ -21,7 +21,7 @@
 
 */
 
-/* $XFree86: xc/lib/X11/GetPntMap.c,v 1.3 1998/10/03 08:41:18 dawes Exp $ */
+/* $XFree86: xc/lib/X11/GetPntMap.c,v 1.4 2000/09/26 15:56:51 tsi Exp $ */
 
 #define NEED_REPLIES
 #include "Xlibint.h"
@@ -116,7 +116,7 @@
 	    SyncHandle();
 	    return (KeySym *) NULL;
 	}
-	_XRead32 (dpy, (char *) mapping, nbytes);
+	_XRead32 (dpy, (long *) mapping, nbytes);
     }
     *keysyms_per_keycode = rep.keySymsPerKeyCode;
     UnlockDisplay(dpy);
Index: xc/lib/X11/ICWrap.c
diff -u xc/lib/X11/ICWrap.c:1.1.1.2 xc/lib/X11/ICWrap.c:1.3
--- xc/lib/X11/ICWrap.c:1.1.1.2	Sun Sep 27 03:56:08 1998
+++ xc/lib/X11/ICWrap.c	Wed Nov 29 12:40:23 2000
@@ -60,6 +60,7 @@
 from The Open Group.
 
 */
+/* $XFree86: xc/lib/X11/ICWrap.c,v 1.3 2000/11/29 17:40:23 dawes Exp $ */
 
 #define NEED_EVENTS
 #include "Xlibint.h"
@@ -424,7 +425,8 @@
     return ic->core.im;
 }
 
-char *XmbResetIC(ic)
+char *
+XmbResetIC(ic)
     XIC ic;
 {
     if (ic->core.im)
@@ -432,7 +434,8 @@
     return (char *)NULL;
 }
 
-wchar_t *XwcResetIC(ic)
+wchar_t *
+XwcResetIC(ic)
     XIC ic;
 {
     if (ic->core.im)
@@ -440,6 +443,15 @@
     return (wchar_t *)NULL;
 }
 
+char *
+Xutf8ResetIC(ic)
+    XIC ic;
+{
+    if (ic->core.im)
+	return (*ic->methods->utf8_reset)(ic);
+    return (char *)NULL;
+}
+
 int
 XmbLookupString(ic, ev, buffer, nbytes, keysym, status)
     XIC ic;
@@ -467,5 +479,20 @@
     if (ic->core.im)
 	return (*ic->methods->wc_lookup_string) (ic, ev, buffer, nchars,
 						 keysym, status);
+    return XLookupNone;
+}
+
+int
+Xutf8LookupString(ic, ev, buffer, nbytes, keysym, status)
+    XIC ic;
+    register XKeyEvent *ev;
+    char *buffer;
+    int nbytes;
+    KeySym *keysym;
+    Status *status;
+{
+    if (ic->core.im)
+	return (*ic->methods->utf8_lookup_string) (ic, ev, buffer, nbytes,
+						   keysym, status);
     return XLookupNone;
 }
Index: xc/lib/X11/Imakefile
diff -u xc/lib/X11/Imakefile:3.31 xc/lib/X11/Imakefile:3.34
--- xc/lib/X11/Imakefile:3.31	Fri Jun 16 21:40:40 2000
+++ xc/lib/X11/Imakefile	Tue Nov 28 13:49:25 2000
@@ -3,7 +3,7 @@
 
 
 
-XCOMM $XFree86: xc/lib/X11/Imakefile,v 3.31 2000/06/17 01:40:40 dawes Exp $
+XCOMM $XFree86: xc/lib/X11/Imakefile,v 3.34 2000/11/28 18:49:25 dawes Exp $
 #define DoNormalLib NormalLibX11
 #define DoSharedLib SharedLibX11
 #define DoExtraLib SharedLibX11
@@ -677,8 +677,10 @@
 	OMWrap.c \
 	lcWrap.c \
 	mbWMProps.c \
+	utf8WMProps.c \
 	mbWrap.c \
 	wcWrap.c \
+	utf8Wrap.c \
 	FilterEv.c \
 	RegstFlt.c \
 	locking.c \
@@ -758,8 +760,10 @@
 	OMWrap.o \
 	lcWrap.o \
 	mbWMProps.o \
+	utf8WMProps.o \
 	mbWrap.o \
 	wcWrap.o \
+	utf8Wrap.o \
 	FilterEv.o \
 	RegstFlt.o \
 	locking.o \
@@ -768,13 +772,8 @@
 	ximtrans.o \
 	$(XKBOBJS) $(LCOBJS) $(MISCOBJS)
 
-#ifdef RsArchitecture
-LCDEPSYMSRCS = aixlcLoad.c
-#endif
-
 LCSRCS = \
 	SetLocale.c \
-	$(LCDEPSYMSRCS) \
 	imCallbk.c \
 	imConv.c \
 	imDefFlt.c \
@@ -787,6 +786,7 @@
 	imImSw.c \
 	imInsClbk.c \
 	imInt.c \
+	imKStoUCS.c \
 	imLcFlt.c \
 	imLcGIc.c \
 	imLcIc.c \
@@ -820,7 +820,6 @@
 	lcSjis.c \
 	lcStd.c \
 	lcTxtPr.c \
-	lcUTF.c \
 	lcUTF8.c \
 	lcUtil.c \
 	omDefault.c \
@@ -832,18 +831,8 @@
 	omTextPer.c \
 	omXChar.c
 
-/*
-#if defined(SunArchitecture) && defined(HasSharedLibraries)
-LCDEPOBJS = XsunDL.o
-#endif
-*/
-#ifdef RsArchitecture
-LCDEPOBJS = aixlcLoad.o
-#endif
-
 LCOBJS = \
 	SetLocale.o \
-	$(LCDEPOBJS) \
 	imCallbk.o \
 	imConv.o \
 	imDefFlt.o \
@@ -856,6 +845,7 @@
 	imImSw.o \
 	imInsClbk.o \
 	imInt.o \
+	imKStoUCS.o \
 	imLcFlt.o \
 	imLcGIc.o \
 	imLcIc.o \
@@ -889,7 +879,6 @@
 	lcSjis.o \
 	lcStd.o \
 	lcTxtPr.o \
-	lcUTF.o \
 	lcUTF8.o \
 	lcUtil.o \
 	omDefault.o \
Index: xc/lib/X11/KeysymStr.c
diff -u xc/lib/X11/KeysymStr.c:3.3 xc/lib/X11/KeysymStr.c:3.5
--- xc/lib/X11/KeysymStr.c:3.3	Sun May  9 06:49:39 1999
+++ xc/lib/X11/KeysymStr.c	Wed Dec  6 17:00:42 2000
@@ -21,7 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/KeysymStr.c,v 3.3 1999/05/09 10:49:39 dawes Exp $ */
+/* $XFree86: xc/lib/X11/KeysymStr.c,v 3.5 2000/12/06 22:00:42 dawes Exp $ */
 
 #include "Xlibint.h"
 #include <X11/Xresource.h>
@@ -130,7 +130,32 @@
 	data.value = &resval;
 	(void)XrmEnumerateDatabase(keysymdb, &empty, &empty, XrmEnumAllLevels,
 				   SameValue, (XPointer)&data);
-	return data.name;
+        if (data.name)
+	    return data.name;
+    }
+    if ((ks & 0xff000000) == 0x01000000){
+        KeySym val = ks & 0xffffff;
+        char *s;
+        int i;
+        if (val & 0xff0000)
+            i = 10;
+        else
+            i = 6;
+        s = Xmalloc(i);
+        if (s == NULL)
+            return s;
+        i--;
+        s[i--] = '\0';
+        for (; i; i--){
+            val1 = val & 0xf;
+            val >>= 4;
+            if (val1 < 10)
+                s[i] = '0'+ val1;
+            else
+                s[i] = 'A'+ val1 - 10;
+        }
+        s[i] = 'U';
+        return s; 
     }
     return ((char *) NULL);
 }
Index: xc/lib/X11/LiICmaps.c
diff -u xc/lib/X11/LiICmaps.c:1.1.1.2 xc/lib/X11/LiICmaps.c:1.2
--- xc/lib/X11/LiICmaps.c:1.1.1.2	Sun Sep 27 03:56:20 1998
+++ xc/lib/X11/LiICmaps.c	Tue Sep 26 11:56:51 2000
@@ -20,6 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
+/* $XFree86: xc/lib/X11/LiICmaps.c,v 1.2 2000/09/26 15:56:51 tsi Exp $ */
 
 #define NEED_REPLIES
 #include "Xlibint.h"
@@ -54,7 +55,7 @@
 	    SyncHandle();
 	    return((Colormap *) NULL);
 	}
-	_XRead32 (dpy, (char *) cmaps, nbytes);
+	_XRead32 (dpy, (long *) cmaps, nbytes);
     }
     else cmaps = (Colormap *) NULL;
     
Index: xc/lib/X11/LiProps.c
diff -u xc/lib/X11/LiProps.c:1.1.1.2 xc/lib/X11/LiProps.c:1.2
--- xc/lib/X11/LiProps.c:1.1.1.2	Sun Sep 27 03:56:20 1998
+++ xc/lib/X11/LiProps.c	Tue Sep 26 11:56:51 2000
@@ -20,6 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
+/* $XFree86: xc/lib/X11/LiProps.c,v 1.2 2000/09/26 15:56:51 tsi Exp $ */
 
 #define NEED_REPLIES
 #include "Xlibint.h"
@@ -53,7 +54,7 @@
 	    SyncHandle();
 	    return (Atom *) NULL;
 	}
-	_XRead32 (dpy, (char *) properties, nbytes);
+	_XRead32 (dpy, (long *) properties, nbytes);
     }
     else properties = (Atom *) NULL;
 
Index: xc/lib/X11/OpenDis.c
diff -u xc/lib/X11/OpenDis.c:3.7 xc/lib/X11/OpenDis.c:3.8
--- xc/lib/X11/OpenDis.c:3.7	Thu Jun 15 21:50:18 2000
+++ xc/lib/X11/OpenDis.c	Mon Nov 27 00:06:44 2000
@@ -20,7 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/OpenDis.c,v 3.7 2000/06/16 01:50:18 dawes Exp $ */
+/* $XFree86: xc/lib/X11/OpenDis.c,v 3.8 2000/11/27 05:06:44 dawes Exp $ */
 
 #define NEED_REPLIES
 #define NEED_EVENTS
@@ -397,6 +397,11 @@
  * now extract the vendor string...  String must be null terminated,
  * padded to multiple of 4 bytes.
  */
+	/* Check for a sane vendor string length */
+	if (u.setup->nbytesVendor > 256) {
+	    OutOfMemory(dpy, setup);
+	    return (NULL);
+	}
 	dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1));
 	if (dpy->vendor == NULL) {
 	    OutOfMemory(dpy, setup);
Index: xc/lib/X11/QuTree.c
diff -u xc/lib/X11/QuTree.c:1.3 xc/lib/X11/QuTree.c:1.4
--- xc/lib/X11/QuTree.c:1.3	Sat Oct  3 04:41:22 1998
+++ xc/lib/X11/QuTree.c	Tue Sep 26 11:56:51 2000
@@ -20,6 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
+/* $XFree86: xc/lib/X11/QuTree.c,v 1.4 2000/09/26 15:56:51 tsi Exp $ */
 
 #define NEED_REPLIES
 #include "Xlibint.h"
@@ -55,7 +56,7 @@
 	    SyncHandle();
 	    return (0);
 	}
-	_XRead32 (dpy, (char *) *children, nbytes);
+	_XRead32 (dpy, (long *) *children, nbytes);
     }
     *parent = rep.parent;
     *root = rep.root;
Index: xc/lib/X11/SetLocale.c
diff -u xc/lib/X11/SetLocale.c:3.10 xc/lib/X11/SetLocale.c:3.12
--- xc/lib/X11/SetLocale.c:3.10	Sat Oct  3 04:41:23 1998
+++ xc/lib/X11/SetLocale.c	Wed Sep 27 14:51:07 2000
@@ -51,7 +51,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/SetLocale.c,v 3.10 1998/10/03 08:41:23 dawes Exp $ */
+/* $XFree86: xc/lib/X11/SetLocale.c,v 3.12 2000/09/27 18:51:07 keithp Exp $ */
 
 #include "Xlibint.h"
 #include "Xlcint.h"
@@ -144,78 +144,89 @@
     char *osname;
     char *siname;
 {
-#if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) || defined(sgi) || defined(__osf__) || defined(AIXV3) || defined(ultrix) || defined(WIN32) || defined(__EMX__)
-#ifdef hpux
-#ifndef _LastCategory
-/* HPUX 9 and earlier */
-#define SKIPCOUNT 2
-#define STARTCHAR ':'
-#define ENDCHAR ';'
-#else
-/* HPUX 10 */
-#define ENDCHAR ' '
-#endif
-#else
-#ifdef ultrix
-#define SKIPCOUNT 2
-#define STARTCHAR '\001'
-#define ENDCHAR '\001'
-#else
-#if defined(WIN32) || defined(__EMX__)
-#define SKIPCOUNT 1
-#define STARTCHAR '='
-#define ENDCHAR ';'
-#define WHITEFILL
-#else
-#if defined(__osf__) || (defined(AIXV3) && !defined(AIXV4))
-#define STARTCHAR ' '
-#define ENDCHAR ' '
-#else
-#if !defined(sun) || defined(SVR4)
-#define STARTCHAR '/'
-#endif
-#define ENDCHAR '/'
-#endif
-#endif
-#endif
-#endif
+#if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) || defined(sgi) || defined(__osf__) || defined(AIXV3) || defined(ultrix) || defined(WIN32) || defined(__EMX__) || defined(linux)
+# ifdef hpux
+#  ifndef _LastCategory
+   /* HPUX 9 and earlier */
+#   define SKIPCOUNT 2
+#   define STARTCHAR ':'
+#   define ENDCHAR ';'
+#  else
+   /* HPUX 10 */
+#   define ENDCHAR ' '
+#  endif
+# else
+#  ifdef ultrix
+#   define SKIPCOUNT 2
+#   define STARTCHAR '\001'
+#   define ENDCHAR '\001'
+#  else
+#   if defined(WIN32) || defined(__EMX__)
+#    define SKIPCOUNT 1
+#    define STARTCHAR '='
+#    define ENDCHAR ';'
+#    define WHITEFILL
+#   else
+#    if defined(__osf__) || (defined(AIXV3) && !defined(AIXV4))
+#     define STARTCHAR ' '
+#     define ENDCHAR ' '
+#    else
+#     if defined(linux)
+#      define STARTSTR "LC_CTYPE="
+#      define ENDCHAR ';'
+#     else
+#      if !defined(sun) || defined(SVR4)
+#       define STARTCHAR '/'
+#       define ENDCHAR '/'
+#      endif
+#     endif
+#    endif
+#   endif
+#  endif
+# endif
 
     char           *start;
     char           *end;
     int             len;
-#ifdef SKIPCOUNT
+# ifdef SKIPCOUNT
     int		    n;
-#endif
+# endif
 
     start = osname;
-#ifdef SKIPCOUNT
+# ifdef SKIPCOUNT
     for (n = SKIPCOUNT;
 	 --n >= 0 && start && (start = strchr (start, STARTCHAR));
 	 start++)
 	;
     if (!start)
 	start = osname;
-#endif
-#ifdef STARTCHAR
-    if (start && (start = strchr (start, STARTCHAR))) {
+# endif
+# ifdef STARTCHAR
+    if (start && (start = strchr (start, STARTCHAR))) 
+# elif  defined (STARTSTR)
+    if (start && (start = strstr (start,STARTSTR)))
+# endif
+    {
+# ifdef STARTCHAR
 	start++;
-#endif
+# elif defined (STARTSTR)
+	start += strlen(STARTSTR);
+# endif
 	if (end = strchr (start, ENDCHAR)) {
 	    len = end - start;
 	    if (len >= MAXLOCALE)
 		len = MAXLOCALE - 1;
 	    strncpy(siname, start, len);
 	    *(siname + len) = '\0';
-#ifdef WHITEFILL
+# ifdef WHITEFILL
 	    for (start = siname; start = strchr(start, ' '); )
 		*start++ = '-';
-#endif
+# endif
 	    return siname;
-#ifdef STARTCHAR
-	}
-#endif
+	} else  /* if no ENDCHAR is found we are at the end of the line */
+	    return start;
     }
-#ifdef WHITEFILL
+# ifdef WHITEFILL
     if (strchr(osname, ' ')) {
 	len = strlen(osname);
 	if (len >= MAXLOCALE - 1)
@@ -226,10 +237,10 @@
 	    *start++ = '-';
 	return siname;
     }
-#endif
-#undef STARTCHAR
-#undef ENDCHAR
-#undef WHITEFILL
+# endif
+# undef STARTCHAR
+# undef ENDCHAR
+# undef WHITEFILL
 #endif
     return osname;
 }
Index: xc/lib/X11/StrKeysym.c
diff -u xc/lib/X11/StrKeysym.c:3.2 xc/lib/X11/StrKeysym.c:3.3
--- xc/lib/X11/StrKeysym.c:3.2	Sun May  9 06:50:15 1999
+++ xc/lib/X11/StrKeysym.c	Fri Dec  1 20:16:03 2000
@@ -20,7 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/StrKeysym.c,v 3.2 1999/05/09 10:50:15 dawes Exp $ */
+/* $XFree86: xc/lib/X11/StrKeysym.c,v 3.3 2000/12/02 01:16:03 dawes Exp $ */
 
 #include "Xlibint.h"
 #include <X11/Xresource.h>
@@ -121,7 +121,6 @@
 	XrmValue result;
 	XrmRepresentation from_type;
 	char c;
-	KeySym val;
 	XrmQuark names[2];
 
 	names[0] = _XrmInternalStringToQuark(s, p - s - 1, sig, False);
@@ -134,12 +133,27 @@
 	    {
 		c = ((char *)result.addr)[i];
 		if ('0' <= c && c <= '9') val = (val<<4)+c-'0';
-		else if ('a' <= c && c <= 'z') val = (val<<4)+c-'a'+10;
-		else if ('A' <= c && c <= 'Z') val = (val<<4)+c-'A'+10;
+		else if ('a' <= c && c <= 'f') val = (val<<4)+c-'a'+10;
+		else if ('A' <= c && c <= 'F') val = (val<<4)+c-'A'+10;
 		else return NoSymbol;
 	    }
 	    return val;
 	}
+    }
+
+    if (*s == 'U') {
+    	val = 0;
+        for (p = &s[1]; *p; p++) {
+            c = *p;
+	    if ('0' <= c && c <= '9') val = (val<<4)+c-'0';
+	    else if ('a' <= c && c <= 'f') val = (val<<4)+c-'a'+10;
+	    else if ('A' <= c && c <= 'F') val = (val<<4)+c-'A'+10;
+	    else return NoSymbol;
+
+	}
+	if (val >= 0x01000000)
+	    return NoSymbol;
+        return val | 0x01000000;
     }
     return (NoSymbol);
 }
Index: xc/lib/X11/X11-def.cpp
diff -u xc/lib/X11/X11-def.cpp:1.5 xc/lib/X11/X11-def.cpp:1.6
--- xc/lib/X11/X11-def.cpp:1.5	Sat Oct  3 04:41:25 1998
+++ xc/lib/X11/X11-def.cpp	Wed Aug  9 19:40:12 2000
@@ -1,12 +1,36 @@
+#ifndef __CYGWIN__
 LIBRARY X11
+#else
+LIBRARY libX11
+#endif
 VERSION LIBRARY_VERSION
 EXPORTS
+#ifndef __CYGWIN__
  _Xdebug_p=_Xdebug CONSTANT
  _XCreateMutex_fn_p=_XCreateMutex_fn CONSTANT
  _XFreeMutex_fn_p=_XFreeMutex_fn CONSTANT
  _XLockMutex_fn_p=_XLockMutex_fn CONSTANT
  _XUnlockMutex_fn_p=_XUnlockMutex_fn CONSTANT
  _Xglobal_lock_p=_Xglobal_lock CONSTANT
+#else
+ _Xdebug
+ _Xsetlocale
+ _XFlush
+ _Xlcmbtowc
+ _Xlcwctomb
+ _Xlcmbstowcs
+ _Xlcwcstombs
+ _Xmbtowc
+ _Xmblen
+ _Xwctomb
+ _Xmbstowcs
+ _Xwcstombs
+ _Xwcscpy
+ _Xwcsncpy
+ _Xwcslen
+ _Xwcscmp
+ _Xwcsncmp
+#endif
  XActivateScreenSaver
  XAddConnectionWatch
  XAddExtension
@@ -599,14 +623,22 @@
  _XDeqAsyncHandler
  _XEatData
  _XError
+#ifndef __CYGWIN__
  _XFlushIt
+#endif
  _XFlushGCCache
  _XFreeTemp
  _XGetAsyncData
  _XGetAsyncReply
+#ifdef __CYGWIN__
+ _XGetBitsPerPixel
+ _XGetScanlinePad
+#endif
  _XIOError
  _XInitImageFuncPtrs
+#ifndef __CYGWIN__
  _XLockDisplay
+#endif
  _XRead
  _XReadEvents
  _XReadPad
@@ -620,8 +652,10 @@
  _XUnregisterFilter
  _XUnregisterInternalConnection
  _XVIDtoVisual
+#ifndef __CYGWIN__
  _Xthread_init
  _Xthread_waiter
+#endif
  XkbIgnoreExtension
  XkbOpenDisplay
  XkbQueryExtension
@@ -807,3 +841,4 @@
  XkbUpdateMapFromCore
  XkbXlibControlsImplemented
 /* $TOG: X11-def.cpp /main/19 1998/06/16 16:04:58 kaleb $ */
+/* $XFree86: xc/lib/X11/X11-def.cpp,v 1.6 2000/08/09 23:40:12 dawes Exp $ */
Index: xc/lib/X11/XKBBind.c
diff -u xc/lib/X11/XKBBind.c:3.11 xc/lib/X11/XKBBind.c:3.12
--- xc/lib/X11/XKBBind.c:3.11	Fri Jan 21 13:41:48 2000
+++ xc/lib/X11/XKBBind.c	Sat Aug 26 11:11:23 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/XKBBind.c,v 3.11 2000/01/21 18:41:48 dawes Exp $ */
+/* $XFree86: xc/lib/X11/XKBBind.c,v 3.12 2000/08/26 15:11:23 dawes Exp $ */
 
 	/* the new monsters ate the old ones */
 
@@ -583,8 +583,6 @@
     LockDisplay(dpy);
     xkbi->desc = desc;
 
-    _XkbGetConverters(_XkbGetCharset(),&xkbi->cvt);
-    _XkbGetConverters("ISO8859-1",&xkbi->latin1cvt);
     UnlockDisplay(dpy);
     oldEvents= xkbi->selected_events;
     if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards)) {
@@ -670,35 +668,26 @@
     XkbKSToMBFunc cvtr;
     XPointer priv;
     char tmp[4];
-    register struct _XKeytrans *p; 
     int n;
 
+    xkb= dpy->xkb_info;
+    if (!xkb->cvt.KSToMB) {
+        _XkbGetConverters(_XkbGetCharset(),&xkb->cvt);
+        _XkbGetConverters("ISO8859-1",&xkb->latin1cvt);
+    }
+
     if (extra_rtrn)
 	*extra_rtrn= 0;
 
-    if (_XkbUnavailable(dpy))
-        return _XTranslateKeySym(dpy, *sym_rtrn, mods, buffer, nbytes);
-    _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
-
-    xkb= dpy->xkb_info;
     if ((buffer==NULL)||(nbytes==0)) {
 	buffer= tmp;
 	nbytes= 4;
     }
 
     /* see if symbol rebound, if so, return that string. */
-    for (p = dpy->key_bindings; p; p = p->next) {
-	if (((mods & AllMods) == p->state) && (*sym_rtrn == p->key)) {
-	    int tmp = p->len;
-	    if (tmp > nbytes) {
-		if (extra_rtrn)
-		    *extra_rtrn= tmp-nbytes;
-		tmp = nbytes;
-	    }
-	    memcpy (buffer, p->string, tmp);
-	    return tmp;
-	}
-    }
+    n = XkbLookupKeyBinding(dpy,*sym_rtrn,mods,buffer,nbytes,extra_rtrn);
+    if (n)
+        return n;
 
     if ( nbytes>0 )
 	buffer[0]= '\0';
@@ -718,35 +707,23 @@
 
     if ((!xkb->cvt.KSToUpper)&&( mods&LockMask )) {
 	register int i;
-
-	if (!xkb->cvt.KSToUpper) {
-	    int change;
-	    char ch;
-	    for (i=change=0;i<n;i++) {
-		ch= toupper(buffer[i]);
-		change= (change||(buffer[i]!=ch));
-		buffer[i] = ch;
-	    }
-	    if (change) {
-		if (n==1)
-		     *sym_rtrn=(*xkb->cvt.MBToKS)(xkb->cvt.MBToKSPriv,
-								buffer,n,0);
-		else *sym_rtrn= NoSymbol;
-	    }
+	int change;
+	char ch;
+	for (i=change=0;i<n;i++) {
+	    ch= toupper(buffer[i]);
+	    change= (change||(buffer[i]!=ch));
+	    buffer[i] = ch;
+	}
+	if (change) {
+	    if (n==1)
+	        *sym_rtrn=(*xkb->cvt.MBToKS)(xkb->cvt.MBToKSPriv,buffer,n,0);
+	    else *sym_rtrn= NoSymbol;
 	}
     }
 
     if ( mods&ControlMask ) {
 	if ( n==1 ) {
-	    register char c = buffer[0];
-
-	    if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
-	    else if (c == '2') c = '\000';
-	    else if (c >= '3' && c <= '7') c -= ('3' - '\033');
-	    else if (c == '8') c = '\177';
-	    else if (c == '/') c = '_' & 0x1F;
-
-	    buffer[0]= c;
+	    buffer[0]= XkbToControl(buffer[0]);
 	    if ( nbytes>1 )
 		buffer[1]= '\0';
 	    return 1;
@@ -780,14 +757,10 @@
     Display *dpy = event->display;
     XkbDescPtr	xkb;
 
-    if (_XkbUnavailable(dpy))
-	return _XLookupString(event, buffer, nbytes, keysym, status);
-    _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
-
     if (keysym==NULL)
 	keysym= &dummy;
     xkb= dpy->xkb_info->desc;
-    if (!XkbTranslateKeyCode(xkb,event->keycode,event->state, &new_mods,keysym))
+    if (!XkbLookupKeySym(dpy,event->keycode,event->state, &new_mods,keysym))
 	return 0;
     new_mods= (event->state&(~new_mods));
 
@@ -896,15 +869,24 @@
 	return rtrnLen;
 
     rtrnLen = XkbTranslateKeySym(dpy,keysym,new_mods,buffer,nbytes,NULL);
+
     if ((event->state&ControlMask)&&(nbytes>0)&&
 			((rtrnLen==0)||
                         ((rtrnLen==1)&&((unsigned char) buffer[0]>=' ')))&&
-			(XkbGroupForCoreState(event->state)!=XkbGroup1Index)&&
 			(dpy->xkb_info->xlib_ctrls&XkbLC_ControlFallback)) {
 	XKeyEvent	tmp_ev;
 	tmp_ev= *event;
-	tmp_ev.state= XkbBuildCoreState(event->state,XkbGroup1Index);
-	return XLookupString (&tmp_ev, buffer, nbytes, keysym, status);
+        if (_XkbUnavailable(dpy)) {
+            if (event->state & dpy->mode_switch) {
+                tmp_ev.state= event->state & ~dpy->mode_switch;
+	        return XLookupString (&tmp_ev, buffer, nbytes, keysym, status);
+	    }
+        } else {
+            if (XkbGroupForCoreState(event->state) != XkbGroup1Index) {
+                tmp_ev.state= XkbBuildCoreState(event->state,XkbGroup1Index);
+	        return XLookupString (&tmp_ev, buffer, nbytes, keysym, status);
+	    }
+        }
     }
     return rtrnLen;
 }
@@ -950,12 +932,14 @@
 
 char
 #if NeedFunctionPrototypes
-XkbToControl( char c )
+XkbToControl( char ch )
 #else
-XkbToControl( c )
-    char c;
+XkbToControl( ch )
+    char ch;
 #endif
 {
+    register char c = ch;
+ 
     if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
     else if (c == '2') c = '\000';
     else if (c >= '3' && c <= '7') c -= ('3' - '\033');
Index: xc/lib/X11/XKBCtrls.c
diff -u xc/lib/X11/XKBCtrls.c:1.1.1.5 xc/lib/X11/XKBCtrls.c:1.2
--- xc/lib/X11/XKBCtrls.c:1.1.1.5	Sun Feb  4 02:36:31 1996
+++ xc/lib/X11/XKBCtrls.c	Sat Aug 26 11:11:24 2000
@@ -24,6 +24,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
+/* $XFree86: xc/lib/X11/XKBCtrls.c,v 1.2 2000/08/26 15:11:24 dawes Exp $ */
 
 #include <stdio.h>
 #define NEED_REPLIES
@@ -303,6 +304,14 @@
     }
     if (which&XkbAccessXKeysMask)
 	ctrls->ax_options= rep.axOptions;
+    if (which&XkbStickyKeysMask) {
+	ctrls->ax_options &= ~XkbAX_SKOptionsMask;
+	ctrls->ax_options |= rep.axOptions & XkbAX_SKOptionsMask;
+    }
+    if (which&XkbAccessXFeedbackMask) {
+	ctrls->ax_options &= ~XkbAX_FBOptionsMask;
+	ctrls->ax_options |= rep.axOptions & XkbAX_FBOptionsMask;
+    }
     if (which&XkbAccessXTimeoutMask) {
 	ctrls->ax_timeout = rep.axTimeout;
 	ctrls->axt_ctrls_mask = rep.axtCtrlsMask;
Index: xc/lib/X11/XKBCvt.c
diff -u xc/lib/X11/XKBCvt.c:3.26 xc/lib/X11/XKBCvt.c:3.28
--- xc/lib/X11/XKBCvt.c:3.26	Mon Jun 12 22:28:28 2000
+++ xc/lib/X11/XKBCvt.c	Tue Nov 28 12:25:07 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/XKBCvt.c,v 3.26 2000/06/13 02:28:28 dawes Exp $ */
+/* $XFree86: xc/lib/X11/XKBCvt.c,v 3.28 2000/11/28 17:25:07 dawes Exp $ */
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -34,6 +34,7 @@
 #include "Xlibint.h"
 #include "Xlcint.h"
 #include "XlcPubI.h"
+#include "Ximint.h"
 #include <X11/Xutil.h>
 #include <X11/Xmd.h>
 #define XK_LATIN1
@@ -100,24 +101,6 @@
     return 1;
 }
 
-extern int
-_XimGetCharCode (
-#if NeedFunctionPrototypes
-    unsigned long /* locale_code */,
-    KeySym /* keysym */,
-    unsigned char* /* buf */,
-    int /* nbytes */
-#endif
-);
-
-extern unsigned long Const*
-_XimGetLocaleCode (
-#if NeedFunctionPrototypes
-    _Xconst char* /* encoding_name */,
-    XlcCharSet* /* pass NULL here */
-#endif
-);
-
 /*ARGSUSED*/
 static int 
 #if NeedFunctionPrototypes
@@ -135,14 +118,11 @@
     int *extra_rtrn;
 #endif
 {
-    unsigned long keysymSet;
     char tbuf[8],*buf;
 
     if (extra_rtrn)
 	*extra_rtrn= 0;
 
-    keysymSet = *((unsigned long Const *)priv);
-
     /* convert "dead" diacriticals for dumb applications */
     if ( (keysym&0xffffff00)== 0xfe00 ) {
 	switch ( keysym ) {
@@ -173,7 +153,7 @@
     if ((keysym&0xffffff00)==0xff00) {
 	return _XkbHandleSpecialSym(keysym, buf, nbytes, extra_rtrn);
     }
-    return _XimGetCharCode (keysymSet, keysym, (unsigned char *)buf, nbytes);
+    return _XimGetCharCode (priv, keysym, (unsigned char *)buf, nbytes);
 }
 
 typedef struct _XkbToKS {
@@ -263,7 +243,7 @@
     if ( !cvt_rtrn ) return 0;
 
     cvt_rtrn->KSToMB = _XkbKSToKnownSet;
-    cvt_rtrn->KSToMBPriv = (XPointer) _XimGetLocaleCode(encoding_name, NULL);
+    cvt_rtrn->KSToMBPriv = _XimGetLocaleCode(encoding_name);
     cvt_rtrn->MBToKS = _XkbKnownSetToKS;
     cvt_rtrn->MBToKSPriv = NULL;
     cvt_rtrn->KSToUpper = __XkbDefaultToUpper;
@@ -286,7 +266,7 @@
  */
 
 #define	CHARSET_FILE	"/usr/lib/X11/input/charsets"
-static char *_XkbKnownLanguages = "c=ascii:da,de,en,es,fi,fr,is,it,nl,no,pt,sv=iso8859-1:hu,pl,cs=iso8859-2:eo=iso8859-3:lt,lv,ee=iso8859-4:bg,sr=iso8859-5:ar,ara=iso8859-6:el=iso8859-7:he=iso8859-8:tr=iso8859-9:ru=koi8-r:uk=koi8-u:th,th_TH,th_TH.TACTIS=tactis:hy=armscii-8:vi=tcvn-5712:ka=georgian-academy";
+static char *_XkbKnownLanguages = "c=ascii:da,de,en,es,fr,is,it,nl,no,pt,sv=iso8859-1:hu,pl,cs=iso8859-2:eo=iso8859-3:sp=iso8859-5:ar,ara=iso8859-6:el=iso8859-7:he=iso8859-8:tr=iso8859-9:lt,lv=iso8859-13:et,fi=iso8859-15:ru=koi8-r:uk=koi8-u:th,th_TH,th_TH.TACTIS=tactis:hy=armscii-8:vi=tcvn-5712:ka=georgian-academy:be,bg=microsoft-cp1251";
 
 char	*
 _XkbGetCharset()
Index: xc/lib/X11/XKBUse.c
diff -u xc/lib/X11/XKBUse.c:3.2 xc/lib/X11/XKBUse.c:3.3
--- xc/lib/X11/XKBUse.c:3.2	Mon Dec 23 00:59:42 1996
+++ xc/lib/X11/XKBUse.c	Sat Aug 26 11:11:24 2000
@@ -24,6 +24,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
+/* $XFree86: xc/lib/X11/XKBUse.c,v 3.3 2000/08/26 15:11:24 dawes Exp $ */
 
 #include <stdio.h>
 #include <ctype.h>
@@ -672,7 +673,7 @@
     static int debugMsg;
     static int been_here= 0;
 
-    if ( dpy->xkb_info ) {
+    if ( dpy->xkb_info && (!dpy->flags&XlibDisplayNoXkb)) {
 	if (major_rtrn)	*major_rtrn= dpy->xkb_info->srv_major;
 	if (minor_rtrn)	*minor_rtrn= dpy->xkb_info->srv_minor;
 	return True;
@@ -685,8 +686,79 @@
     if (major_rtrn)	*major_rtrn= 0;
     if (minor_rtrn)	*minor_rtrn= 0;
 
+    if (!dpy->xkb_info) {
+        xkbi = _XkbTypedCalloc(1, XkbInfoRec);
+        if ( !xkbi )
+	    return False;
+        dpy->xkb_info = xkbi;
+        dpy->free_funcs->xkb = _XkbFreeInfo;
+
+        xkbi->xlib_ctrls|= 
+	    (XkbLC_BeepOnComposeFail|XkbLC_ComposeLED|XkbLC_ControlFallback);
+        if ((str=getenv("_XKB_OPTIONS_ENABLE"))!=NULL) {
+	    if ((str=getenv("_XKB_LATIN1_LOOKUP"))!=NULL) {
+	        if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+		     xkbi->xlib_ctrls&= ~XkbLC_ForceLatin1Lookup;
+	        else xkbi->xlib_ctrls|= XkbLC_ForceLatin1Lookup;
+	    }
+	    if ((str=getenv("_XKB_CONSUME_LOOKUP_MODS"))!=NULL) {
+	        if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+		     xkbi->xlib_ctrls&= ~XkbLC_ConsumeLookupMods;
+	        else xkbi->xlib_ctrls|= XkbLC_ConsumeLookupMods;
+	    }
+	    if ((str=getenv("_XKB_CONSUME_SHIFT_AND_LOCK"))!=NULL) {
+	        if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+		     xkbi->xlib_ctrls&= ~XkbLC_AlwaysConsumeShiftAndLock;
+	        else xkbi->xlib_ctrls|= XkbLC_AlwaysConsumeShiftAndLock;
+	    }
+	    if ((str=getenv("_XKB_IGNORE_NEW_KEYBOARDS"))!=NULL) {
+	        if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+		     xkbi->xlib_ctrls&= ~XkbLC_IgnoreNewKeyboards;
+	        else xkbi->xlib_ctrls|= XkbLC_IgnoreNewKeyboards;
+	    }
+	    if ((str=getenv("_XKB_CONTROL_FALLBACK"))!=NULL) {
+	        if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+		     xkbi->xlib_ctrls&= ~XkbLC_ControlFallback;
+	        else xkbi->xlib_ctrls|= XkbLC_ControlFallback;
+	    }
+	    if ((str=getenv("_XKB_COMP_LED"))!=NULL) {
+	        if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+		    xkbi->xlib_ctrls&= ~XkbLC_ComposeLED;
+	        else {
+		    xkbi->xlib_ctrls|= XkbLC_ComposeLED;
+		    if (strlen(str)>0)
+		        xkbi->composeLED= XInternAtom(dpy,str,False);
+	        }
+	    }
+	    if ((str=getenv("_XKB_COMP_FAIL_BEEP"))!=NULL) {
+	        if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+		     xkbi->xlib_ctrls&= ~XkbLC_BeepOnComposeFail;
+	        else xkbi->xlib_ctrls|= XkbLC_BeepOnComposeFail;
+	    }
+        }
+        if ((xkbi->composeLED==None)&&((xkbi->xlib_ctrls&XkbLC_ComposeLED)!=0))
+	    xkbi->composeLED= XInternAtom(dpy,"Compose",False);
+#ifdef DEBUG
+        if (debugMsg) {
+	    register unsigned c= xkbi->xlib_ctrls;
+	    fprintf(stderr,"XKEYBOARD compose: beep on failure is %s, LED is %s\n",
+		((c&XkbLC_BeepOnComposeFail)?"on":"off"),
+		((c&XkbLC_ComposeLED)?"on":"off"));
+	    fprintf(stderr,"XKEYBOARD XLookupString: %slatin-1, %s lookup modifiers\n",
+		((c&XkbLC_ForceLatin1Lookup)?"allow non-":"force "),
+		((c&XkbLC_ConsumeLookupMods)?"consume":"re-use"));
+	    fprintf(stderr,
+	        "XKEYBOARD XLookupString: %sconsume shift and lock, %scontrol fallback\n",
+	        ((c&XkbLC_AlwaysConsumeShiftAndLock)?"always ":"don't "),
+	        ((c&XkbLC_ControlFallback)?"":"no "));
+
+        }
+#endif
+    } else
+        xkbi = dpy->xkb_info;
+
     forceIgnore= (dpy->flags&XlibDisplayNoXkb)||dpy->keysyms;
-    forceIgnore= forceIgnore&(major_rtrn==NULL)&&(minor_rtrn==NULL);
+    forceIgnore= forceIgnore&&(major_rtrn==NULL)&&(minor_rtrn==NULL);
     if ( forceIgnore || _XkbIgnoreExtension || getenv("XKB_DISABLE")) {
 	LockDisplay(dpy);
 	dpy->flags |= XlibDisplayNoXkb;
@@ -696,15 +768,10 @@
 	return False;
     }
 
-    xkbi = _XkbTypedCalloc(1, XkbInfoRec);
-    if ( !xkbi )
-	return False;
-
     if ( (codes=XInitExtension(dpy,XkbName))==NULL ) {
 	LockDisplay(dpy);
 	dpy->flags |= XlibDisplayNoXkb;
 	UnlockDisplay(dpy);
-	Xfree(xkbi);
 	if (debugMsg)
 	    fprintf(stderr,"XKEYBOARD extension not present\n");
 	return False;
@@ -746,8 +813,7 @@
 	    dpy->flags |= XlibDisplayNoXkb;
 	    UnlockDisplay(dpy);
 	    SyncHandle();
-	    Xfree(xkbi);
-	    if (major_rtrn)	*major_rtrn= rep.serverMajor;
+	    if (major_rtrn) *major_rtrn= rep.serverMajor;
 	    if (minor_rtrn) *minor_rtrn= rep.serverMinor;
 	    return False;
 	}
@@ -766,70 +832,8 @@
 	fprintf(stderr,"XKEYBOARD (version %d.%02d/%d.%02d) OK!\n",
 				XkbMajorVersion,XkbMinorVersion,
 				rep.serverMajor,rep.serverMinor);
-    dpy->xkb_info = xkbi;
-    dpy->free_funcs->xkb = _XkbFreeInfo;
-    ev_base = codes->first_event;
-    xkbi->xlib_ctrls|= 
-	(XkbLC_BeepOnComposeFail|XkbLC_ComposeLED|XkbLC_ControlFallback);
-    if ((str=getenv("_XKB_OPTIONS_ENABLE"))!=NULL) {
-	if ((str=getenv("_XKB_LATIN1_LOOKUP"))!=NULL) {
-	    if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
-		 xkbi->xlib_ctrls&= ~XkbLC_ForceLatin1Lookup;
-	    else xkbi->xlib_ctrls|= XkbLC_ForceLatin1Lookup;
-	}
-	if ((str=getenv("_XKB_CONSUME_LOOKUP_MODS"))!=NULL) {
-	    if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
-		 xkbi->xlib_ctrls&= ~XkbLC_ConsumeLookupMods;
-	    else xkbi->xlib_ctrls|= XkbLC_ConsumeLookupMods;
-	}
-	if ((str=getenv("_XKB_CONSUME_SHIFT_AND_LOCK"))!=NULL) {
-	    if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
-		 xkbi->xlib_ctrls&= ~XkbLC_AlwaysConsumeShiftAndLock;
-	    else xkbi->xlib_ctrls|= XkbLC_AlwaysConsumeShiftAndLock;
-	}
-	if ((str=getenv("_XKB_IGNORE_NEW_KEYBOARDS"))!=NULL) {
-	    if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
-		 xkbi->xlib_ctrls&= ~XkbLC_IgnoreNewKeyboards;
-	    else xkbi->xlib_ctrls|= XkbLC_IgnoreNewKeyboards;
-	}
-	if ((str=getenv("_XKB_CONTROL_FALLBACK"))!=NULL) {
-	    if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
-		 xkbi->xlib_ctrls&= ~XkbLC_ControlFallback;
-	    else xkbi->xlib_ctrls|= XkbLC_ControlFallback;
-	}
-	if ((str=getenv("_XKB_COMP_LED"))!=NULL) {
-	    if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
-		 xkbi->xlib_ctrls&= ~XkbLC_ComposeLED;
-	    else {
-		xkbi->xlib_ctrls|= XkbLC_ComposeLED;
-		if (strlen(str)>0)
-		    xkbi->composeLED= XInternAtom(dpy,str,False);
-	    }
-	}
-	if ((str=getenv("_XKB_COMP_FAIL_BEEP"))!=NULL) {
-	    if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
-		 xkbi->xlib_ctrls&= ~XkbLC_BeepOnComposeFail;
-	    else xkbi->xlib_ctrls|= XkbLC_BeepOnComposeFail;
-	}
-    }
-    if ((xkbi->composeLED==None)&&((xkbi->xlib_ctrls&XkbLC_ComposeLED)!=0))
-	xkbi->composeLED= XInternAtom(dpy,"Compose",False);
-#ifdef DEBUG
-    if (debugMsg) {
-	register unsigned c= xkbi->xlib_ctrls;
-	fprintf(stderr,"XKEYBOARD compose: beep on failure is %s, LED is %s\n",
-		((c&XkbLC_BeepOnComposeFail)?"on":"off"),
-		((c&XkbLC_ComposeLED)?"on":"off"));
-	fprintf(stderr,"XKEYBOARD XLookupString: %slatin-1, %s lookup modifiers\n",
-		((c&XkbLC_ForceLatin1Lookup)?"allow non-":"force "),
-		((c&XkbLC_ConsumeLookupMods)?"consume":"re-use"));
-	fprintf(stderr,
-	    "XKEYBOARD XLookupString: %sconsume shift and lock, %scontrol fallback\n",
-	    ((c&XkbLC_AlwaysConsumeShiftAndLock)?"always ":"don't "),
-	    ((c&XkbLC_ControlFallback)?"":"no "));
 
-    }
-#endif
+    ev_base = codes->first_event;
     XESetWireToEvent(dpy,ev_base+XkbEventCode,wire_to_event);
     SyncHandle();
     return True;
Index: xc/lib/X11/XKeysymDB
diff -u xc/lib/X11/XKeysymDB:3.4 xc/lib/X11/XKeysymDB:3.6
--- xc/lib/X11/XKeysymDB:3.4	Thu Feb 10 10:48:28 2000
+++ xc/lib/X11/XKeysymDB	Wed Nov  1 21:51:10 2000
@@ -11,7 +11,7 @@
 ! suitability of this software for any purpose.  It is provided "as is"
 ! without express or implied warranty.
 !
-! $XFree86: xc/lib/X11/XKeysymDB,v 3.4 2000/02/10 15:48:28 dawes Exp $
+! $XFree86: xc/lib/X11/XKeysymDB,v 3.6 2000/11/02 02:51:10 dawes Exp $
 
 hpmute_acute		:100000A8
 hpmute_grave		:100000A9
@@ -197,6 +197,7 @@
 XeroxPointerButton4	:10070004
 XeroxPointerButton5	:10070005
 
+! The definitions here should match <X11/XF86keysym.h>
 XF86ModeLock		:1008FF01
 XF86Standby		:1008FF10
 XF86AudioLowerVolume	:1008FF11
@@ -210,6 +211,31 @@
 XF86Mail		:1008FF19
 XF86Start		:1008FF1A
 XF86Search		:1008FF1B
+XF86AudioRecord		:1008FF1C
+XF86Calculator		:1008FF1D
+XF86Memo		:1008FF1E
+XF86ToDoList		:1008FF1F
+XF86Calendar		:1008FF20
+XF86PowerDown		:1008FF21
+XF86ContrastAdjust	:1008FF22
+XF86RockerUp		:1008FF23
+XF86RockerDown		:1008FF24
+XF86RockerEnter		:1008FF25
+XF86Back		:1008FF26
+XF86Forward		:1008FF27
+XF86Stop		:1008FF28
+XF86Refresh		:1008FF29
+XF86PowerOff		:1008FF2A
+XF86WakeUp		:1008FF2B
+! 1008FF2C - 1008FF2F are yet to be assigned
+XF86Favorites		:1008FF30
+XF86AudioPause		:1008FF31
+XF86AudioMedia		:1008FF32
+XF86MyComputer		:1008FF33
+XF86VendorHome		:1008FF34
+XF86LightBulb		:1008FF35
+XF86Shop		:1008FF36
+
 
 usldead_acute		:100000A8
 usldead_grave		:100000A9
Index: xc/lib/X11/Ximint.h
diff -u xc/lib/X11/Ximint.h:3.5 xc/lib/X11/Ximint.h:3.8
--- xc/lib/X11/Ximint.h:3.5	Mon Jun 12 22:28:28 2000
+++ xc/lib/X11/Ximint.h	Mon Dec  4 13:49:19 2000
@@ -30,7 +30,7 @@
 			       makoto@sm.sony.co.jp
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/Ximint.h,v 3.5 2000/06/13 02:28:28 dawes Exp $ */
+/* $XFree86: xc/lib/X11/Ximint.h,v 3.8 2000/12/04 18:49:19 dawes Exp $ */
 
 #ifndef _XIMINT_H
 #define _XIMINT_H
@@ -61,12 +61,15 @@
  */
 
 typedef struct _XimCommonPrivateRec {
+    /* This struct is also inlined in XimLocalPrivateRec, XimProtoPrivateRec. */
     XlcConv		ctom_conv;
     XlcConv		ctow_conv;
+    XlcConv		ctoutf8_conv;
     XlcConv		cstomb_conv;
     XlcConv		cstowc_conv;
-    XlcCharSet		keyboard_charset;
-    unsigned long	locale_code;
+    XlcConv		cstoutf8_conv;
+    XlcConv		ucstoc_conv;
+    XlcConv		ucstoutf8_conv;
 } XimCommonPrivateRec;
 
 typedef union _XIMPrivateRec {
@@ -187,13 +190,27 @@
  * Global symbols
  */
 
-unsigned long Const * _XimGetLocaleCode (
+XPointer _XimGetLocaleCode (
 #if NeedFunctionPrototypes
-    _Xconst char*	encoding_name,
-    XlcCharSet*		cset_ret
+    Const char	*encoding_name
 #endif
 );
 
+int _XimGetCharCode (
+#if NeedFunctionPrototypes
+    XPointer		conv,
+    KeySym		keysym,
+    unsigned char	*buf,
+    int			nbytes
+#endif
+);
+
+unsigned int KeySymToUcs4 (
+#if NeedFunctionPrototypes
+    KeySym		keysym
+#endif
+);
+
 extern Bool _XimSetIMResourceList(
 #if NeedFunctionPrototypes
     XIMResourceList	*res_list,
@@ -751,9 +768,9 @@
 #if NeedFunctionPrototypes
     XIM		 im,
     char	*from,
-    int		from_len,
+    int		 from_len,
     char	*to,
-    int		to_len,
+    int		 to_len,
     Status	*state
 #endif
 );
@@ -769,13 +786,24 @@
 #endif
 );
 
+extern int	_Ximctstoutf8(
+#if NeedFunctionPrototypes
+    XIM		 im,
+    char	*from,
+    int		 from_len,
+    char	*to,
+    int		 to_len,
+    Status	*state
+#endif
+);
+
 extern int	_XimLcctstombs(
 #if NeedFunctionPrototypes
     XIM		 im,
     char	*from,
-    int		from_len,
+    int		 from_len,
     char	*to,
-    int		to_len,
+    int		 to_len,
     Status	*state
 #endif
 );
@@ -791,6 +819,17 @@
 #endif
 );
 
+extern int	_XimLcctstoutf8(
+#if NeedFunctionPrototypes
+    XIM		 im,
+    char	*from,
+    int		 from_len,
+    char	*to,
+    int		 to_len,
+    Status	*state
+#endif
+);
+
 extern void	_XimSetHeader(
 #if NeedFunctionPrototypes
     XPointer	 buf,
@@ -829,6 +868,17 @@
 #endif
 );
 
+extern int	_XimProtoUtf8LookupString(
+#if NeedFunctionPrototypes
+    XIC		 xic,
+    XKeyEvent	*ev,
+    char	*buffer,
+    int		 bytes,
+    KeySym	*keysym,
+    Status	*state
+#endif
+);
+
 extern void	_XimRegisterFilter(
 #if NeedFunctionPrototypes
     Xic		 ic
@@ -895,6 +945,17 @@
 #endif
 );
 
+extern int	_XimLookupUTF8Text(
+#if NeedFunctionPrototypes
+    Xic			 ic,
+    XKeyEvent		*event,
+    char		*buffer,
+    int			 nbytes,
+    KeySym		*keysym,
+    XComposeStatus	*status
+#endif
+);
+
 extern EVENTMASK	_XimGetWindowEventmask(
 #if NeedFunctionPrototypes
     Xic		 ic
@@ -1081,6 +1142,17 @@
     XIC			 ic,
     XKeyEvent		*ev,
     wchar_t		*buffer,
+    int			 bytes,
+    KeySym		*keysym,
+    Status		*status
+#endif
+);
+
+extern int _XimLocalUtf8LookupString(
+#if NeedFunctionPrototypes
+    XIC			 ic,
+    XKeyEvent		*ev,
+    char		*buffer,
     int			 bytes,
     KeySym		*keysym,
     Status		*status
Index: xc/lib/X11/XimintL.h
diff -u xc/lib/X11/XimintL.h:1.3 xc/lib/X11/XimintL.h:1.6
--- xc/lib/X11/XimintL.h:1.3	Wed Jun 14 14:20:33 2000
+++ xc/lib/X11/XimintL.h	Mon Dec  4 13:49:19 2000
@@ -32,7 +32,7 @@
 	                          frankyling@hgrd01.enet.dec.com
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/XimintL.h,v 1.3 2000/06/14 18:20:33 dawes Exp $ */
+/* $XFree86: xc/lib/X11/XimintL.h,v 1.6 2000/12/04 18:49:19 dawes Exp $ */
 
 #ifndef _XIMINTL_H
 #define _XIMINTL_H
@@ -51,18 +51,23 @@
     KeySym           keysym;		/* leaf only */
     char            *mb;
     wchar_t         *wc;		/* make from mb */
+    char            *utf8;		/* make from mb */
     KeySym           ks;
 } DefTree;
 
 typedef struct _XimLocalPrivateRec {
-	XlcConv			 ctom_conv;
-	XlcConv			 ctow_conv;
-	XlcConv			 cstomb_conv;
-	XlcConv			 cstowc_conv;
-	XlcCharSet		 keyboard_charset;
-        unsigned long		 locale_code;
-	XIC			 current_ic;
-	DefTree			*top;
+	/* The first fields are identical with XimCommonPrivateRec. */
+	XlcConv		 ctom_conv;
+	XlcConv		 ctow_conv;
+	XlcConv		 ctoutf8_conv;
+	XlcConv		 cstomb_conv;
+	XlcConv		 cstowc_conv;
+	XlcConv		 cstoutf8_conv;
+	XlcConv		 ucstoc_conv;
+	XlcConv		 ucstoutf8_conv;
+
+	XIC		 current_ic;
+	DefTree		*top;
 } XimLocalPrivateRec;
 
 typedef struct _XicThaiPart {
Index: xc/lib/X11/XimintP.h
diff -u xc/lib/X11/XimintP.h:1.3 xc/lib/X11/XimintP.h:1.6
--- xc/lib/X11/XimintP.h:1.3	Wed Jun 14 14:20:33 2000
+++ xc/lib/X11/XimintP.h	Mon Dec  4 13:49:19 2000
@@ -35,7 +35,7 @@
                                  miyamoto@jrd.dec.com
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/XimintP.h,v 1.3 2000/06/14 18:20:33 dawes Exp $ */
+/* $XFree86: xc/lib/X11/XimintP.h,v 1.6 2000/12/04 18:49:19 dawes Exp $ */
 
 #ifndef _XIMINTP_H
 #define _XIMINTP_H
@@ -102,12 +102,15 @@
  * private part of IM
  */
 typedef struct _XimProtoPrivateRec {
+    /* The first fields are identical with XimCommonPrivateRec. */
     XlcConv			 ctom_conv;
     XlcConv			 ctow_conv;
+    XlcConv			 ctoutf8_conv;
     XlcConv			 cstomb_conv;
     XlcConv			 cstowc_conv;
-    XlcCharSet			 keyboard_charset;
-    unsigned long		 locale_code;
+    XlcConv			 cstoutf8_conv;
+    XlcConv			 ucstoc_conv;
+    XlcConv			 ucstoutf8_conv;
 
     Window			 im_window;
     XIMID			 imid;
Index: xc/lib/X11/XlcPubI.h
diff -u xc/lib/X11/XlcPubI.h:3.5 xc/lib/X11/XlcPubI.h:3.7
--- xc/lib/X11/XlcPubI.h:3.5	Fri Feb 11 21:54:07 2000
+++ xc/lib/X11/XlcPubI.h	Mon Dec  4 13:49:20 2000
@@ -23,7 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/XlcPubI.h,v 3.5 2000/02/12 02:54:07 dawes Exp $ */
+/* $XFree86: xc/lib/X11/XlcPubI.h,v 3.7 2000/12/04 18:49:20 dawes Exp $ */
 
 #ifndef _XLCPUBLICI_H_
 #define _XLCPUBLICI_H_
@@ -41,40 +41,30 @@
 typedef struct _XLCdPublicMethodsRec *XLCdPublicMethods;
 
 typedef XLCd (*XlcPubCreateProc)(
-#if NeedFunctionPrototypes
-    _Xconst char*	/* name */,
-    XLCdMethods		/* methods */
-#endif
+    const char*		name,
+    XLCdMethods		methods
 );
 
 typedef Bool (*XlcPubInitializeProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */
-#endif
+    XLCd		lcd
 );
 
 typedef void (*XlcPubDestroyProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */
-#endif
+    XLCd		lcd
 );
 
 typedef char* (*XlcPubGetValuesProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    XlcArgList		/* args */,
-    int			/* num_args */
-#endif
+    XLCd		lcd,
+    XlcArgList		args,
+    int			num_args
 );
 
 typedef void (*XlcPubGetResourceProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    char*		/* category */,
-    char*		/* class */,
-    char***		/* value */,
-    int*		/* count */
-#endif
+    XLCd		lcd,
+    const char*		category,
+    const char*		_class,
+    char***		value,
+    int*		count
 );
 
 typedef struct _XLCdPublicMethodsPart {
@@ -103,7 +93,7 @@
     char *encoding_name;		/* encoding name */
     int mb_cur_max;			/* ANSI C MB_CUR_MAX */
     Bool is_state_depend;		/* state-depend encoding */
-    char *default_string;		/* for XDefaultString() */
+    const char *default_string;		/* for XDefaultString() */
     XPointer xlocale_db;
 } XLCdPublicPart;
 
@@ -117,65 +107,63 @@
 _XFUNCPROTOBEGIN
 
 extern XLCd _XlcCreateLC(
-#if NeedFunctionPrototypes
-    _Xconst char*	/* name */,
-    XLCdMethods		/* methods */
-#endif
+    const char*		name,
+    XLCdMethods		methods
 );
 
 extern void _XlcDestroyLC(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */
-#endif
+    XLCd		lcd
 );
 
+/* Fills into a freshly created XlcCharSet the fields that can be inferred
+   from the ESC sequence. These are side, char_size, set_size. */
 extern Bool _XlcParseCharSet(
-#if NeedFunctionPrototypes
-    XlcCharSet		/* charset */
-#endif
+    XlcCharSet		charset
 );
 
+/* Creates a new XlcCharSet, given its name (including side suffix) and
+   Compound Text ESC sequence (normally at most 4 bytes). */
 extern XlcCharSet _XlcCreateDefaultCharSet(
-#if NeedFunctionPrototypes
-    _Xconst char*	/* name */,
-    _Xconst char*	/* control_sequence */
-#endif
+    const char*		name,
+    const char*		ct_sequence
 );
 
 extern XlcCharSet _XlcAddCT(
-#if NeedFunctionPrototypes
-    _Xconst char*	/* name */,
-    _Xconst char*	/* control_sequence */
-#endif
+    const char*		name,
+    const char*		ct_sequence
 );
 
+extern Bool _XlcInitCTInfo (void);
+
 extern XrmMethods _XrmDefaultInitParseInfo(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    XPointer*		/* state */
-#endif
+    XLCd		lcd,
+    XPointer*		state
 );
 
 extern int _XmbTextPropertyToTextList(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    Display*		/* dpy */,
-    XTextProperty*	/* text_prop */,
-    char***		/* list_ret */,
-    int*		/* count_ret */
-#endif
+    XLCd		lcd,
+    Display*		dpy,
+    const XTextProperty* text_prop,
+    char***		list_ret,
+    int*		count_ret
 );
 
 extern int _XwcTextPropertyToTextList(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    Display*		/* dpy */,
-    XTextProperty*	/* text_prop */,
-    wchar_t***		/* list_ret */,
-    int*		/* count_ret */
-#endif
+    XLCd		lcd,
+    Display*		dpy,
+    const XTextProperty* text_prop,
+    wchar_t***		list_ret,
+    int*		count_ret
 );
 
+extern int _Xutf8TextPropertyToTextList(
+    XLCd		lcd,
+    Display*		dpy,
+    const XTextProperty* text_prop,
+    char***		list_ret,
+    int*		count_ret
+);
+
 extern int _XmbTextListToTextProperty(
 #if NeedFunctionPrototypes
     XLCd		/* lcd */,
@@ -198,6 +186,17 @@
 #endif
 );
 
+extern int _Xutf8TextListToTextProperty(
+#if NeedFunctionPrototypes
+    XLCd		/* lcd */,
+    Display*		/* dpy */,
+    char**		/* list */,
+    int			/* count */,
+    XICCEncodingStyle	/* style */,
+    XTextProperty*	/* text_prop */
+#endif
+);
+
 extern void _XwcFreeStringList(
 #if NeedFunctionPrototypes
     XLCd		/* lcd */,
@@ -206,39 +205,29 @@
 );
 
 extern int _XlcResolveLocaleName(
-#if NeedFunctionPrototypes
-    char*		/* lc_name */,
-    XLCdPublicPart*	/* pub */
-#endif
+    const char*		lc_name,
+    XLCdPublicPart*	pub
 );
 
 extern int _XlcResolveI18NPath(
-#if NeedFunctionPrototypes
-    char*		/* buf */,
-    int			/* buf_len */
-#endif
+    char*		buf,
+    int			buf_len
 );
 
 extern XPointer _XlcCreateLocaleDataBase(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */
-#endif
+    XLCd		lcd
 );
 
 extern void _XlcDestroyLocaleDataBase(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */
-#endif
+    XLCd		lcd
 );
 
 extern void _XlcGetLocaleDataBase(
-#if NeedFunctionPrototypes
     XLCd		/* lcd */,
-    char*		/* category */,
-    char*		/* name */,
+    const char*		/* category */,
+    const char*		/* name */,
     char***		/* value */,
     int*		/* count */
-#endif
 );
 
 _XFUNCPROTOEND
Index: xc/lib/X11/XlcPublic.h
diff -u xc/lib/X11/XlcPublic.h:1.5 xc/lib/X11/XlcPublic.h:1.8
--- xc/lib/X11/XlcPublic.h:1.5	Mon Feb 28 22:09:03 2000
+++ xc/lib/X11/XlcPublic.h	Mon Dec  4 13:49:20 2000
@@ -31,7 +31,7 @@
  * Modifier: Takanori Tateno   FUJITSU LIMITED
  *
  */
-/* $XFree86: xc/lib/X11/XlcPublic.h,v 1.5 2000/02/29 03:09:03 dawes Exp $ */
+/* $XFree86: xc/lib/X11/XlcPublic.h,v 1.8 2000/12/04 18:49:20 dawes Exp $ */
 /*
  * Most of this API is documented in i18n/Framework.PS
  */
@@ -41,63 +41,127 @@
 
 #include "Xlcint.h"
 
-#define XlcNCharSize 		"charSize"
-#define XlcNCodeset 		"codeset"
-#define XlcNControlSequence 	"controlSequence"
-#define XlcNDefaultString 	"defaultString"
-#define XlcNEncodingName 	"encodingName"
-#define XlcNLanguage 		"language"
-#define XlcNMbCurMax 		"mbCurMax"
-#define XlcNName 		"name"
-#define XlcNSetSize 		"setSize"
-#define XlcNSide 		"side"
-#define XlcNStateDependentEncoding "stateDependentEncoding"
-#define XlcNTerritory 		"territory"
 
+/*
+ * Character sets.
+ */
+
+/* Every character set has a "side". It denotes the range of byte values for
+   which the character set is responsible. This means that the character
+   set's encoded characters will only assumes bytes within the range, and
+   that the character set can be used simultaneously with another character
+   set responsible for a disjoint range. */
 typedef enum {
-    XlcUnknown, XlcC0, XlcGL, XlcC1, XlcGR, XlcGLGR, XlcOther, XlcNONE
+    XlcUnknown,
+    XlcC0,		/* responsible for values 0x00..0x1F */
+    XlcGL,		/* responsible for values 0x00..0x7F or 0x20..0x7F */
+    XlcC1,		/* responsible for values 0x80..0x9F */
+    XlcGR,		/* responsible for values 0x80..0xFF or 0xA0..0xFF */
+    XlcGLGR,		/* responsible for values 0x00..0xFF */
+    XlcOther,		/* unused */
+    XlcNONE
 } XlcSide;
 
-typedef struct _FontScope {
-        unsigned long   start;
-        unsigned long   end;
-        unsigned long   shift;
-        unsigned long   shift_direction;
-} FontScopeRec, *FontScope;
-
+/* Data read from XLC_LOCALE files.
+   XXX Apparently superseded by _XUDCGlyphRegion. */
 typedef struct _UDCArea {
-        unsigned long 	start,end;
+    unsigned long	start;
+    unsigned long	end;
 } UDCAreaRec, *UDCArea;
 
-typedef struct _XlcCharSetRec *XlcCharSet;
-
-typedef char* (*XlcGetCSValuesProc)(
-#if NeedFunctionPrototypes
-    XlcCharSet		/* charset */,
-    XlcArgList		/* args */,
-    int			/* num_args */
-#endif
-);
+/* Where the character set comes from. */
+typedef enum {
+    CSsrcUndef,		/* unused */
+    CSsrcStd,		/* defined in libX11 */
+    CSsrcXLC		/* defined in an XLC_LOCALE file */
+} CSSrc;
 
-typedef enum {CSsrcUndef = 0, CSsrcStd, CSsrcXLC} CSSrc;
+/* These are the supported properties of XlcCharSet. */
+#define XlcNCharSize 		"charSize"
+#define XlcNControlSequence 	"controlSequence"
+#define XlcNEncodingName 	"encodingName"
+#define XlcNName 		"name"
+#define XlcNSetSize 		"setSize"
+#define XlcNSide 		"side"
 
+/* This is the structure of an XlcCharSet.
+   Once allocated, they are never freed. */
 typedef struct _XlcCharSetRec {
-    char 		*name;		/* character set name */
+    /* Character set name, including side suffix */
+    const char 		*name;
     XrmQuark 		xrm_name;
-    char 		*encoding_name;	/* XLFD encoding name */
+
+    /* XLFD encoding name, no side suffix */
+    const char 		*encoding_name;
     XrmQuark 		xrm_encoding_name;
-    XlcSide 		side;		/* GL, GR or others */
-    int 		char_size;	/* number of bytes per character */
-    int 		set_size;	/* graphic character sets */
-    char 		*ct_sequence;	/* control sequence of CT */
-    XlcGetCSValuesProc 	get_values;
-    /* UDC */
+
+    /* Range for which the charset is responsible: XlcGL, XlcGR or XlcGLGR */
+    XlcSide 		side;
+
+    /* Number of bytes per character. 0 means a varying number (e.g. UTF-8) */
+    int 		char_size;
+    /* Classification of the character set according to ISO-2022 */
+    int 		set_size;	/* e.g. 94 or 96 */
+    const char 		*ct_sequence;	/* control sequence of CT */
+					/* (normally at most 4 bytes) */
+
+    /* for UDC */
     Bool        	string_encoding;
     UDCArea 		udc_area;
     int     		udc_area_num;
-    /* CS description source */
+
+    /* Description source */
     CSSrc		source;
-} XlcCharSetRec;
+} XlcCharSetRec, *XlcCharSet;
+
+_XFUNCPROTOBEGIN
+
+/* Returns the charset with the given name (including side suffix).
+   Returns NULL if not found. */
+extern XlcCharSet _XlcGetCharSet(
+    const char*		name
+);
+
+/* Returns the charset with the given encoding (no side suffix) and
+   responsible for at least the given side (XlcGL or XlcGR).
+   Returns NULL if not found. */
+extern XlcCharSet _XlcGetCharSetWithSide(
+    const char*		encoding_name,
+    XlcSide		side
+);
+
+/* Registers an XlcCharSet in the list of character sets.
+   Returns True if successful. */
+extern Bool _XlcAddCharSet(
+    XlcCharSet		charset
+);
+
+/* Retrieves a number of attributes of an XlcCharSet.
+   Return NULL if successful, otherwise the name of the first argument
+   specifiying a nonexistent attribute. */
+extern char *_XlcGetCSValues(
+#if NeedVarargsPrototypes
+    XlcCharSet		charset,
+    ...
+#endif
+);
+
+_XFUNCPROTOEND
+
+
+#define XlcNCodeset 		"codeset"
+#define XlcNDefaultString 	"defaultString"
+#define XlcNLanguage 		"language"
+#define XlcNMbCurMax 		"mbCurMax"
+#define XlcNStateDependentEncoding "stateDependentEncoding"
+#define XlcNTerritory 		"territory"
+
+typedef struct _FontScope {
+        unsigned long   start;
+        unsigned long   end;
+        unsigned long   shift;
+        unsigned long   shift_direction;
+} FontScopeRec, *FontScope;
 
 /*
  * conversion methods
@@ -106,12 +170,10 @@
 typedef struct _XlcConvRec *XlcConv;
 
 typedef XlcConv (*XlcOpenConverterProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* from_lcd */,
-    char*		/* from_type */,
-    XLCd		/* to_lcd */,
-    char*		/* to_type */
-#endif
+    XLCd		from_lcd,
+    const char*		from_type,
+    XLCd		to_lcd,
+    const char*		to_type
 );
 
 typedef void (*XlcCloseConverterProc)(
@@ -155,7 +217,9 @@
 #define XlcNUtf8String 		"utf8String"
 #define XlcNCharSet 		"charSet"
 #define XlcNCTCharSet 		"CTcharSet"
+#define XlcNFontCharSet		"FontCharSet"
 #define XlcNChar 		"char"
+#define XlcNUcsChar 		"UCSchar"
 
 typedef struct _XlcConvRec {
     XlcConvMethods 		methods;
@@ -184,90 +248,50 @@
 #endif
 );
 
-extern XlcCharSet _XlcGetCharSet(
-#if NeedFunctionPrototypes
-    _Xconst char*	/* name */
-#endif
-);
-
-extern XlcCharSet _XlcGetCharSetWithSide(
-#if NeedFunctionPrototypes
-    _Xconst char*	/* encoding_name */,
-    XlcSide		/* side */
-#endif
-);
-
-extern Bool _XlcAddCharSet(
-#if NeedFunctionPrototypes
-    XlcCharSet		/* charset */
-#endif
-);
-
-extern char *_XlcGetCSValues(
-#if NeedVarargsPrototypes
-    XlcCharSet		/* charset */,
-    ...
-#endif
-);
-
 extern XlcConv _XlcOpenConverter(
-#if NeedFunctionPrototypes
-    XLCd		/* from_lcd */,
-    char*		/* from_type */,
-    XLCd		/* to_lcd */,
-    char*		/* to_type */
-#endif
+    XLCd		from_lcd,
+    const char*		from_type,
+    XLCd		to_lcd,
+    const char*		to_type
 );
 
 extern void _XlcCloseConverter(
-#if NeedFunctionPrototypes
-    XlcConv		/* conv */
-#endif
+    XlcConv		conv
 );
 
 extern int _XlcConvert(
-#if NeedFunctionPrototypes
-    XlcConv		/* conv */,
-    XPointer*		/* from */,
-    int*		/* from_left */,
-    XPointer*		/* to */,
-    int*		/* to_left */,
-    XPointer*		/* args */,
-    int			/* num_args */
-#endif
+    XlcConv		conv,
+    XPointer*		from,
+    int*		from_left,
+    XPointer*		to,
+    int*		to_left,
+    XPointer*		args,
+    int			num_args
 );
 
 extern void _XlcResetConverter(
-#if NeedFunctionPrototypes
-    XlcConv		/* conv */
-#endif
+    XlcConv		conv
 );
 
 extern Bool _XlcSetConverter(
-#if NeedFunctionPrototypes
-    XLCd			/* from_lcd */,
-    char*			/* from_type */,
-    XLCd			/* to_lcd */,
-    char*			/* to_type */,
-    XlcOpenConverterProc	/* open_converter */
-#endif
+    XLCd			from_lcd,
+    const char*			from_type,
+    XLCd			to_lcd,
+    const char*			to_type,
+    XlcOpenConverterProc	open_converter
 );
 
 extern void _XlcGetResource(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    char*		/* category */,
-    char*		/* class */,
-    char***		/* value */,
-    int*		/* count */
-#endif
+    XLCd		lcd,
+    const char*		category,
+    const char*		_class,
+    char***		value,
+    int*		count
 );
 
 extern char *_XlcFileName(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    char*		/* category */
-#endif
+    XLCd		lcd,
+    const char*		category
 );
 
 extern int _Xwcslen(
@@ -283,19 +307,19 @@
 #endif
 );
 
+/* Compares two ISO 8859-1 strings, ignoring case of ASCII letters.
+   Like strcasecmp in an ASCII locale. */
 extern int _XlcCompareISOLatin1(
-#if NeedFunctionPrototypes
-    char*		/* str1 */,
-    char*		/* str2 */
-#endif
+    const char*		str1,
+    const char*		str2
 );
 
+/* Compares two ISO 8859-1 strings, at most len bytes of each, ignoring
+   case of ASCII letters. Like strncasecmp in an ASCII locale. */
 extern int _XlcNCompareISOLatin1(
-#if NeedFunctionPrototypes
-    char*		/* str1 */,
-    char*		/* str2 */,
-    int			/* len */
-#endif
+    const char*		str1,
+    const char*		str2,
+    int			len
 );
 
 _XFUNCPROTOEND
Index: xc/lib/X11/XlcUTF.h
diff -u xc/lib/X11/XlcUTF.h:1.6 xc/lib/X11/XlcUTF.h:removed
--- xc/lib/X11/XlcUTF.h:1.6	Sun Jun  6 10:05:52 1999
+++ xc/lib/X11/XlcUTF.h	Mon Dec 18 14:23:49 2000
@@ -1,187 +0,0 @@
-/* $TOG: XlcUTF.h /main/10 1998/05/20 14:47:44 kaleb $ */
-/******************************************************************
-
-              Copyright 1993 by SunSoft, Inc.
-
-Permission to use, copy, modify, distribute, and sell this software
-and its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear
-in supporting documentation, and that the name of SunSoft, Inc.
-not be used in advertising or publicity pertaining to distribution
-of the software without specific, written prior permission.
-SunSoft, Inc. makes no representations about the suitability of
-this software for any purpose.  It is provided "as is" without
-express or implied warranty.
-
-SunSoft Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
-IN NO EVENT SHALL SunSoft, Inc. BE LIABLE FOR ANY SPECIAL, INDIRECT
-OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
-OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
-OR PERFORMANCE OF THIS SOFTWARE.
-
-  Author: Hiromu Inukai (inukai@Japan.Sun.COM) SunSoft, inc.
-
-******************************************************************/
-/* $XFree86: xc/lib/X11/XlcUTF.h,v 1.6 1999/06/06 14:05:52 dawes Exp $ */
-
-#include "Xlibint.h"
-#include "XlcGeneric.h"
-#include <X11/Xos.h>
-#include <stdio.h>
-
-typedef unsigned short Rune;		/* 16 bits */
-#define		Runeerror	0x80	/* decoding error in UTF */
-#define		Runeself	0x80	/* rune and UTF sequences are the same (<) */
-#define		UTFmax		3	/* maximum bytes per rune */
-
-#define		BADMAP	(0xFFFD)
-#define		ESC	033
-#define		NRUNE	65536
-#define		NLATIN	0x6ff
-#define		LATINMAX 256
-#define		KUTENMAX 8407
-#define		KSCMAX	8743
-#define		GBMAX	8795
-#define		tab8859_1	"tab8859_1"
-#define		tab8859_2	"tab8859_2"
-#define		tab8859_3	"tab8859_3"
-#define		tab8859_4	"tab8859_4"
-#define		tab8859_5	"tab8859_5"
-#define		tab8859_6	"tab8859_6"
-#define		tab8859_7	"tab8859_7"
-#define		tab8859_8	"tab8859_8"
-#define		tab8859_9	"tab8859_9"
-#define		tab8859_10	"tab8859_10"
-#define		tab8859_14	"tab8859_14"
-#define		tab8859_15	"tab8859_15"
-#define		jis0208		"jis0208"
-#define		ksc5601		"ksc5601"
-#define		gb2312		"gb2312"
-#define		tabtis620	"tabtis620"
-#define		tabkoi8_r	"tabkoi8_r"
-#define		tabkoi8_u	"tabkoi8_u"
-#define		tabarmscii_8	"tabarmscii_8"
-#define		tabibm_cp1133	"tabibm_cp1133"
-#define		tabmulelao_1	"tabmulelao_1"
-#define		tabviscii	"tabviscii"
-#define		tabtcvn		"tabtcvn"
-#define		tabgeorgian_academy	"tabgeorgian_academy"
-#define		tabgeorgian_ps	"tabgeorgian_ps"
-
-#define emit(x)    *r = (Rune)x;
-
-typedef enum {
-    N11n_none,		/* No need to normalize (1byte) */
-    N11n_ja,		/* Normalize for ja */
-    N11n_ko,		/* Normalize for ko */
-    N11n_zh		/* Normalize for zh */
-} NormalizeType;
-
-typedef struct  _UtfDataRec {
-    XlcCharSet	charset;
-    void		(*initialize)( /* Table Initializer */
-#if NeedNestedPrototypes
-	int*,
-	wchar_t
-#endif
-    );
-    int*		fromtbl;	/* UTF -> CharSet */
-    NormalizeType	type;		/* Normalize type */
-    void		(*cstorune)(	/* CharSet -> UTF */
-#if NeedNestedPrototypes
-	unsigned char,
-	Rune*
-#endif
-    );
-    Bool			already_init;
-    struct _UtfDataRec	*next;		/* next entry     */
-} UtfDataRec, *UtfData;
-
-typedef struct _XlcUTFDataRec {
-    char	*name;
-    XlcSide	side;
-    void	(*initialize)(
-#if NeedNestedPrototypes
-	int*,
-	wchar_t
-#endif
-    );
-    void	(*cstorune)(
-#if NeedNestedPrototypes
-	unsigned char,
-	Rune*
-#endif
-    );
-    NormalizeType	type;
-    wchar_t		fallback_value;
-} XlcUTFDataRec, *XlcUTFData;
-
-#define MAX_UTF_CHARSET	(sizeof(default_utf_data)/sizeof(XlcUTFDataRec))
-
-#define Char1 Runeself
-#define Rune1 Runeself
-#define Char21 0xA1
-#define Rune21 0x0100
-#define Char22 0xF6
-#define Rune22 0x4016
-#define Char3 0xFC
-#define Rune3 0x10000	/* really 0x38E2E */
-#define Esc 0xBE
-#define Bad Runeerror
-
-#define T1	0x00
-#define	Tx	0x80
-#define T2	0xC0
-#define T3	0xE0
-#define T4	0xF0
-#define T5	0xF8
-#define T6	0xFC
-
-#define Bit1	7
-#define Bitx	6
-#define Bit2	5
-#define Bit3	4
-#define Bit4	3
-#define Bit5	2
-#define Bit6	2
-
-#define Mask1	(1<<Bit1)-1
-#define Maskx	(1<<Bitx)-1
-#define Mask2	(1<<Bit2)-1
-#define Mask3	(1<<Bit3)-1
-#define Mask4	(1<<Bit4)-1
-#define Mask5	(1<<Bit5)-1
-#define Mask6	(1<<Bit6)-1
-
-#define Wchar1	(1<<Bit1)-1
-#define Wchar2	(1<<(Bit2+Bitx))-1
-#define Wchar3	(1<<(Bit3+2*Bitx))-1
-#define Wchar4	(1<<(Bit4+3*Bitx))-1
-#define Wchar5	(1<<(Bit5+4*Bitx))-1
-
-#ifndef	EILSEQ
-#define EILSEQ  123
-#endif
-
-#define J2S(_h, _l) { \
-        /* lower: 21-7e >> 40-9d,9e-fb >> 40-7e,(skip 7f),80-fc */ \
-        if (((_l) += (((_h)-- % 2) ? 0x1f : 0x7d)) > 0x7e) (_l)++; \
-        /* upper: 21-7e >> 81-af >> 81-9f,(skip a0-df),e0-ef */ \
-        if (((_h) = ((_h) / 2 + 0x71)) > 0x9f) (_h) += 0x40; \
-}
-#define S2J(_h, _l) { \
-        /* lower: 40-7e,80-fc >> 21-5f,61-dd >> 21-7e,7f-dc */ \
-        if (((_l) -= 0x1f) > 0x60) (_l)--; \
-        /* upper: 81-9f,e0-ef >> 00-1e,5f-6e >> 00-2e >> 21-7d */ \
-        if (((_h) -= 0x81) > 0x5e) (_h) -= 0x40; (_h) *= 2, (_h) += 0x21; \
-        /* upper: ,21-7d >> ,22-7e ; lower: ,7f-dc >> ,21-7e */ \
-        if ((_l) > 0x7e) (_h)++, (_l) -= 0x5e; \
-}
-#define ISJKANA(_b)     (0xa0 <= (_b) && (_b) < 0xe0)
-#define CANS2JH(_h)     ((0x81 <= (_h) && (_h) < 0xf0) && !ISJKANA(_h))
-#define CANS2JL(_l)     (0x40 <= (_l) && (_l) < 0xfd && (_l) != 0x7f)
-#define CANS2J(_h, _l)  (CANS2JH(_h) && CANS2JL(_l))
-
Index: xc/lib/X11/Xlcint.h
diff -u xc/lib/X11/Xlcint.h:3.5 xc/lib/X11/Xlcint.h:3.7
--- xc/lib/X11/Xlcint.h:3.5	Fri Feb 11 21:54:07 2000
+++ xc/lib/X11/Xlcint.h	Sat Dec  2 10:30:22 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/Xlcint.h,v 3.5 2000/02/12 02:54:07 dawes Exp $ */
+/* $XFree86: xc/lib/X11/Xlcint.h,v 3.7 2000/12/02 15:30:22 tsi Exp $ */
 
 /*
  * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
@@ -156,6 +156,7 @@
     XICCallback		draw_callback;
 } ICStatusAttributes, *ICStatusAttributesPtr;
 
+
 /*
  * Methods for Xrm parsing
  */
@@ -166,51 +167,44 @@
 /* Sets the state to the initial state.
    Initiates a sequence of calls to the XmbCharProc. */
 typedef void (*XmbInitProc)(
-#if NeedFunctionPrototypes
-    XPointer		/* state */
-#endif
+    XPointer		state
 );
 
 /* Transforms one multibyte character, starting at str, and return a 'char'
    in the same parsing class (not a wide character!). Returns the number of
    consumed bytes in *lenp. */
 typedef char (*XmbCharProc)(
-#if NeedFunctionPrototypes
-    XPointer		/* state */,
-    char*		/* str */,
-    int*		/* lenp */
-#endif
+    XPointer		state,
+    const char *	str,
+    int*		lenp
 );
 
 /* Terminates a sequence of calls to the XmbCharProc. */
 typedef void (*XmbFinishProc)(
-#if NeedFunctionPrototypes
-    XPointer		/* state */
-#endif
+    XPointer		state
 );
 
 /* Returns the name of the state's locale, as a static string. */
-typedef char* (*XlcNameProc)(
-#if NeedFunctionPrototypes
-    XPointer		/* state */
-#endif
+typedef const char* (*XlcNameProc)(
+    XPointer		state
 );
 
 /* Frees the state, which was allocated by the locale's init_parse_info
    function. */
 typedef void (*XrmDestroyProc)(
-#if NeedFunctionPrototypes
-    XPointer		/* state */
-#endif
+    XPointer		state
 );
 
+/* Set of methods for Xrm parsing. */
 typedef struct {
     XmbInitProc		mbinit;
     XmbCharProc		mbchar;
     XmbFinishProc	mbfinish;
     XlcNameProc		lcname;
     XrmDestroyProc	destroy;
-} XrmMethodsRec, *XrmMethods;
+} XrmMethodsRec;
+typedef const XrmMethodsRec *XrmMethods;
+
 
 typedef struct _XLCd *XLCd; /* need forward reference */
 
@@ -227,8 +221,8 @@
 typedef char* (*XlcMapModifiersProc)(
 #if NeedFunctionPrototypes
     XLCd		/* lcd */,
-    char*		/* user_mods */,
-    char*		/* prog_mods */
+    _Xconst char*	/* user_mods */,
+    _Xconst char*	/* prog_mods */
 #endif
 );
 
@@ -284,58 +278,46 @@
 );
 
 typedef int (*XmbTextPropertyToTextListProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    Display*		/* display */,
-    XTextProperty*	/* text_prop */,
-    char***		/* list_return */,
-    int*		/* count_return */
-#endif
+    XLCd		lcd,
+    Display*		display,
+    const XTextProperty* text_prop,
+    char***		list_return,
+    int*		count_return
 );
 
 typedef int (*XwcTextPropertyToTextListProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    Display*		/* display */,
-    XTextProperty*	/* text_prop */,
-    wchar_t***		/* list_return */,
-    int*		/* count_return */
-#endif
+    XLCd		lcd,
+    Display*		display,
+    const XTextProperty* text_prop,
+    wchar_t***		list_return,
+    int*		count_return
 );
 
 typedef int (*XmbTextListToTextPropertyProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    Display*		/* display */,
-    char**		/* list */,
-    int			/* count */,
-    XICCEncodingStyle	/* style */,
-    XTextProperty*	/* text_prop_return */
-#endif
+    XLCd		lcd,
+    Display*		display,
+    char**		list,
+    int			count,
+    XICCEncodingStyle	style,
+    XTextProperty*	text_prop_return
 );
 
 typedef int (*XwcTextListToTextPropertyProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    Display*		/* display */,
-    wchar_t**		/* list */,
-    int			/* count */,
-    XICCEncodingStyle	/* style */,
-    XTextProperty*	/* text_prop_return */
-#endif
+    XLCd		lcd,
+    Display*		display,
+    wchar_t**		list,
+    int			count,
+    XICCEncodingStyle	style,
+    XTextProperty*	text_prop_return
 );
 
 typedef void (*XwcFreeStringListProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */,
-    wchar_t**		/* list */
-#endif
+    XLCd		lcd,
+    wchar_t**		list
 );
 
-typedef char* (*XDefaultStringProc)(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */
-#endif
+typedef const char* (*XDefaultStringProc)(
+    XLCd		lcd
 );
 
 typedef struct {
@@ -346,8 +328,10 @@
     XrmInitParseInfoProc		init_parse_info;
     XmbTextPropertyToTextListProc	mb_text_prop_to_list;
     XwcTextPropertyToTextListProc	wc_text_prop_to_list;
+    XmbTextPropertyToTextListProc	utf8_text_prop_to_list;
     XmbTextListToTextPropertyProc	mb_text_list_to_prop;
     XwcTextListToTextPropertyProc	wc_text_list_to_prop;
+    XmbTextListToTextPropertyProc	utf8_text_list_to_prop;
     XwcFreeStringListProc		wc_free_string_list;
     XDefaultStringProc			default_string;
     XRegisterIMInstantiateCBProc	register_callback;
@@ -618,6 +602,14 @@
     XwcTextPerCharExtentsProc	wc_extents_per_char;
     XwcDrawStringProc		wc_draw_string;
     XwcDrawImageStringProc	wc_draw_image_string;
+
+    /* UTF-8 text drawing methods */
+
+    XmbTextEscapementProc	utf8_escapement;
+    XmbTextExtentsProc		utf8_extents;
+    XmbTextPerCharExtentsProc	utf8_extents_per_char;
+    XmbDrawStringProc		utf8_draw_string;
+    XmbDrawImageStringProc	utf8_draw_image_string;
 } XOCMethodsRec, *XOCMethods;
 
 
@@ -692,6 +684,11 @@
 	XIM, char*, int, wchar_t*, int, Status *
 #endif
 	);
+    int (*ctstoutf8)(
+#if NeedFunctionPrototypes
+	XIM, char*, int, char*, int, Status *
+#endif
+	);
 } XIMMethodsRec, *XIMMethods;
 
 /*
@@ -775,6 +772,11 @@
 	XIC
 #endif
 	);
+    char* (*utf8_reset)(
+#if NeedFunctionPrototypes
+	XIC
+#endif
+	);
     int (*mb_lookup_string)(
 #if NeedFunctionPrototypes
 	XIC, XKeyEvent*, char*, int, KeySym*, Status*
@@ -785,6 +787,11 @@
 	XIC, XKeyEvent*, wchar_t*, int, KeySym*, Status*
 #endif
 	);
+    int (*utf8_lookup_string)(
+#if NeedFunctionPrototypes
+	XIC, XKeyEvent*, char*, int, KeySym*, Status*
+#endif
+	);
 } XICMethodsRec, *XICMethods;
 
 
@@ -834,44 +841,30 @@
    XLCd object with appropriate locale methods and returns it. May return
    NULL; in this case, the remaining loaders are tried. */
 typedef XLCd (*XLCdLoadProc)(
-#if NeedFunctionPrototypes
-    _Xconst char*	/* name */
-#endif
+    const char*		name
 );
 
 _XFUNCPROTOBEGIN
 
 extern XLCd _XOpenLC(
-#if NeedFunctionPrototypes
-    _Xconst char*	/* name */
-#endif
+    const char*		name
 );
 
 extern void _XCloseLC(
-#if NeedFunctionPrototypes
-    XLCd		/* lcd */
-#endif
+    XLCd		lcd
 );
 
-extern XLCd _XlcCurrentLC(
-#if NeedFunctionPrototypes
-    void
-#endif
-);
+extern XLCd _XlcCurrentLC (void);
 
 extern Bool _XlcValidModSyntax(
-#if NeedFunctionPrototypes
-    char*	/* mods */,
-    char**	/* valid */
-#endif
+    const char*		mods,
+    const char* const *	valid
 );
 
 extern char *_XlcDefaultMapModifiers(
-#if NeedFunctionPrototypes
-    XLCd	/* lcd */,
-    char*	/* user_mods */,
-    char*	/* prog_mods */
-#endif
+    XLCd		lcd,
+    _Xconst char*		user_mods,
+    _Xconst char*		prog_mods
 );
 
 extern void _XIMCompileResourceList(
@@ -897,9 +890,7 @@
 );
 
 extern XrmMethods _XrmInitParseInfo(
-#if NeedFunctionPrototypes
-	XPointer*	/* statep */
-#endif
+	XPointer*	statep
 );
 
 extern void _XRegisterFilterByMask(
@@ -954,70 +945,94 @@
 );
 
 extern void _XlcCountVaList(
-#if NeedFunctionPrototypes
-    va_list		/* var */,
-    int*		/* count_return */
-#endif
+    va_list		var,
+    int*		count_return
 );
 
 extern void _XlcVaToArgList(
-#if NeedFunctionPrototypes
-    va_list		/* var */,
-    int			/* count */,
-    XlcArgList*		/* args_return */
-#endif
+    va_list		var,
+    int			count,
+    XlcArgList*		args_return
 );
 
 extern void _XlcCompileResourceList(
-#if NeedFunctionPrototypes
-    XlcResourceList	/* resources */,
-    int			/* num_resources */
-#endif
+    XlcResourceList	resources,
+    int			num_resources
 );
 
 extern char *_XlcGetValues(
-#if NeedFunctionPrototypes
-    XPointer		/* base */,
-    XlcResourceList	/* resources */,
-    int			/* num_resources */,
-    XlcArgList		/* args */,
-    int			/* num_args */,
-    unsigned long	/* mask */
-#endif
+    XPointer		base,
+    XlcResourceList	resources,
+    int			num_resources,
+    XlcArgList		args,
+    int			num_args,
+    unsigned long	mask
 );
 
 extern char *_XlcSetValues(
-#if NeedFunctionPrototypes
-    XPointer		/* base */,
-    XlcResourceList	/* resources */,
-    int			/* num_resources */,
-    XlcArgList		/* args */,
-    int			/* num_args */,
-    unsigned long	/* mask */
-#endif
+    XPointer		base,
+    XlcResourceList	resources,
+    int			num_resources,
+    XlcArgList		args,
+    int			num_args,
+    unsigned long	mask
 );
 
 /* documented in i18n/Framework.PS */
-extern void _XlcInitLoader(
-#if NeedFunctionPrototypes
-    void
-#endif
-);
+extern void _XlcInitLoader (void);
 
 /* documented in i18n/Framework.PS */
 /* Returns True on success, False on failure. */
 extern Bool _XlcAddLoader(
-#if NeedFunctionPrototypes
-    XLCdLoadProc	/* proc */,
-    XlcPosition		/* position */
-#endif
+    XLCdLoadProc	proc,
+    XlcPosition		position
 );
 
 /* documented in i18n/Framework.PS */
 extern void _XlcRemoveLoader(
-#if NeedFunctionPrototypes
-    XLCdLoadProc	/* proc */
-#endif
+    XLCdLoadProc	proc
+);
+
+/* Registers UTF-8 converters for a non-UTF-8 locale. */
+extern void _XlcAddUtf8Converters(
+    XLCd		lcd
+);
+
+/* The default locale loader. Assumes an ASCII encoding. */
+extern XLCd _XlcDefaultLoader(
+    const char*		name
+);
+
+/* The generic locale loader. Suitable for all encodings except UTF-8.
+   Uses an XLC_LOCALE configuration file. */
+extern XLCd _XlcGenericLoader(
+    const char*		name
+);
+
+/* The UTF-8 locale loader. Suitable for UTF-8 encoding.
+   Uses an XLC_LOCALE configuration file. */
+extern XLCd _XlcUtf8Loader(
+    const char*		name
+);
+
+/* The old EUC locale loader. */
+extern XLCd _XlcEucLoader(
+    const char*		name
+);
+
+/* The old SJIS locale loader. */
+extern XLCd _XlcSjisLoader(
+    const char*		name
+);
+
+/* The old ISO-2022-JP locale loader. */
+extern XLCd _XlcJisLoader(
+    const char*		name
+);
+
+/* The old dynamic loader. */
+extern XLCd _XlcDynamicLoader(
+    const char*		name
 );
 
 _XFUNCPROTOEND
Index: xc/lib/X11/Xlib.h
diff -u xc/lib/X11/Xlib.h:3.16 xc/lib/X11/Xlib.h:3.18
--- xc/lib/X11/Xlib.h:3.16	Sat Jan 29 13:58:11 2000
+++ xc/lib/X11/Xlib.h	Mon Dec  4 13:49:20 2000
@@ -20,7 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/Xlib.h,v 3.16 2000/01/29 18:58:11 dawes Exp $ */
+/* $XFree86: xc/lib/X11/Xlib.h,v 3.18 2000/12/04 18:49:20 dawes Exp $ */
 
 
 /*
@@ -83,6 +83,10 @@
 #endif
 #endif
 
+/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in
+   November 2000. Its presence is indicated through the following macro. */
+#define X_HAVE_UTF8_STRING 1
+
 typedef char *XPointer;
 
 #define Bool int
@@ -4239,16 +4243,10 @@
 #endif
 );
 
-extern Bool XSupportsLocale(
-#if NeedFunctionPrototypes
-    void
-#endif
-);
+extern Bool XSupportsLocale (void);
 
 extern char *XSetLocaleModifiers(
-#if NeedFunctionPrototypes
-    _Xconst char*	/* modifier_list */
-#endif
+    const char*		/* modifier_list */
 );
 
 extern XOM XOpenOM(
@@ -4402,6 +4400,14 @@
 #endif
 );
 
+extern int Xutf8TextEscapement(
+#if NeedFunctionPrototypes
+    XFontSet		/* font_set */,
+    _Xconst char*	/* text */,
+    int			/* bytes_text */
+#endif
+);
+
 extern int XmbTextExtents(
 #if NeedFunctionPrototypes
     XFontSet		/* font_set */,
@@ -4422,6 +4428,16 @@
 #endif
 );
 
+extern int Xutf8TextExtents(
+#if NeedFunctionPrototypes
+    XFontSet		/* font_set */,
+    _Xconst char*	/* text */,
+    int			/* bytes_text */,
+    XRectangle*		/* overall_ink_return */,
+    XRectangle*		/* overall_logical_return */
+#endif
+);
+
 extern Status XmbTextPerCharExtents(
 #if NeedFunctionPrototypes
     XFontSet		/* font_set */,
@@ -4450,6 +4466,20 @@
 #endif
 );
 
+extern Status Xutf8TextPerCharExtents(
+#if NeedFunctionPrototypes
+    XFontSet		/* font_set */,
+    _Xconst char*	/* text */,
+    int			/* bytes_text */,
+    XRectangle*		/* ink_extents_buffer */,
+    XRectangle*		/* logical_extents_buffer */,
+    int			/* buffer_size */,
+    int*		/* num_chars */,
+    XRectangle*		/* overall_ink_return */,
+    XRectangle*		/* overall_logical_return */
+#endif
+);
+
 extern void XmbDrawText(
 #if NeedFunctionPrototypes
     Display*		/* display */,
@@ -4474,6 +4504,18 @@
 #endif
 );
 
+extern void Xutf8DrawText(
+#if NeedFunctionPrototypes
+    Display*		/* display */,
+    Drawable		/* d */,
+    GC			/* gc */,
+    int			/* x */,
+    int			/* y */,
+    XmbTextItem*	/* text_items */,
+    int			/* nitems */
+#endif
+);
+
 extern void XmbDrawString(
 #if NeedFunctionPrototypes
     Display*		/* display */,
@@ -4500,6 +4542,19 @@
 #endif
 );
 
+extern void Xutf8DrawString(
+#if NeedFunctionPrototypes
+    Display*		/* display */,
+    Drawable		/* d */,
+    XFontSet		/* font_set */,
+    GC			/* gc */,
+    int			/* x */,
+    int			/* y */,
+    _Xconst char*	/* text */,
+    int			/* bytes_text */
+#endif
+);
+
 extern void XmbDrawImageString(
 #if NeedFunctionPrototypes
     Display*		/* display */,
@@ -4526,6 +4581,19 @@
 #endif
 );
 
+extern void Xutf8DrawImageString(
+#if NeedFunctionPrototypes
+    Display*		/* display */,
+    Drawable		/* d */,
+    XFontSet		/* font_set */,
+    GC			/* gc */,
+    int			/* x */,
+    int			/* y */,
+    _Xconst char*	/* text */,
+    int			/* bytes_text */
+#endif
+);
+
 extern XIM XOpenIM(
 #if NeedFunctionPrototypes
     Display*			/* dpy */,
@@ -4595,6 +4663,12 @@
 #endif
 );
 
+extern char *Xutf8ResetIC(
+#if NeedFunctionPrototypes
+    XIC /* ic */
+#endif
+);
+
 extern char *XSetICValues(
 #if NeedVarargsPrototypes
     XIC /* ic */, ...
@@ -4637,6 +4711,17 @@
     XKeyPressedEvent*	/* event */,
     wchar_t*		/* buffer_return */,
     int			/* wchars_buffer */,
+    KeySym*		/* keysym_return */,
+    Status*		/* status_return */
+#endif
+);
+
+extern int Xutf8LookupString(
+#if NeedFunctionPrototypes
+    XIC			/* ic */,
+    XKeyPressedEvent*	/* event */,
+    char*		/* buffer_return */,
+    int			/* bytes_buffer */,
     KeySym*		/* keysym_return */,
     Status*		/* status_return */
 #endif
Index: xc/lib/X11/XlibInt.c
diff -u xc/lib/X11/XlibInt.c:3.22 xc/lib/X11/XlibInt.c:3.23
--- xc/lib/X11/XlibInt.c:3.22	Fri Jun 16 20:27:30 2000
+++ xc/lib/X11/XlibInt.c	Thu Nov 30 18:29:59 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/XlibInt.c,v 3.22 2000/06/17 00:27:30 dawes Exp $ */
+/* $XFree86: xc/lib/X11/XlibInt.c,v 3.23 2000/11/30 23:29:59 dawes Exp $ */
 
 /*
  *	XlibInt.c - Internal support routines for the C subroutine
@@ -588,7 +588,10 @@
 	register char *bufindex;
 	_XExtension *ext;
 
-	if (dpy->flags & XlibDisplayIOError) return;
+	if (dpy->flags & XlibDisplayIOError) {
+	    dpy->bufptr = dpy->buffer;  /* reset to avoid buffer overflows */
+	    return;
+	}
 #ifdef XTHREADS
 	while (dpy->flags & XlibDisplayWriting) {
 	    if (dpy->lock) {
Index: xc/lib/X11/XomGeneric.h
diff -u xc/lib/X11/XomGeneric.h:1.1.1.2 xc/lib/X11/XomGeneric.h:1.3
--- xc/lib/X11/XomGeneric.h:1.1.1.2	Sat Dec 21 22:27:13 1996
+++ xc/lib/X11/XomGeneric.h	Wed Nov 29 12:40:23 2000
@@ -31,6 +31,7 @@
  * Modifier: Takanori Tateno   FUJITSU LIMITED
  *
  */
+/* $XFree86: xc/lib/X11/XomGeneric.h,v 1.3 2000/11/29 17:40:23 dawes Exp $ */
 
 #ifndef _XOMGENERIC_H_
 #define _XOMGENERIC_H_
@@ -59,7 +60,8 @@
 
 typedef enum {
     XOMMultiByte,
-    XOMWideChar
+    XOMWideChar,
+    XOMUtf8String
 } XOMTextType;
 
 typedef struct _FontDataRec {
@@ -134,6 +136,7 @@
 typedef struct _XOCGenericPart {
     XlcConv 		mbs_to_cs;
     XlcConv 		wcs_to_cs;
+    XlcConv 		utf8_to_cs;
     int 		font_set_num;
     FontSet 		font_set;
 } XOCGenericPart;
Index: xc/lib/X11/Xresource.h
diff -u xc/lib/X11/Xresource.h:3.2 xc/lib/X11/Xresource.h:3.5
--- xc/lib/X11/Xresource.h:3.2	Sat Oct  3 04:41:30 1998
+++ xc/lib/X11/Xresource.h	Tue Nov 28 13:49:28 2000
@@ -42,7 +42,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/Xresource.h,v 3.2 1998/10/03 08:41:30 dawes Exp $ */
+/* $XFree86: xc/lib/X11/Xresource.h,v 3.5 2000/11/28 18:49:28 dawes Exp $ */
 
 #ifndef _XRESOURCE_H_
 #define _XRESOURCE_H_
@@ -79,7 +79,7 @@
  *
  ****************************************************************/
 
-typedef int     XrmQuark, *XrmQuarkList;
+typedef int       XrmQuark, *XrmQuarkList;
 #define NULLQUARK ((XrmQuark) 0)
 
 typedef char *XrmString;
@@ -358,7 +358,7 @@
 #endif
 );
 
-extern char *XrmLocaleOfDatabase(
+extern const char *XrmLocaleOfDatabase(
 #if NeedFunctionPrototypes
     XrmDatabase 	/* database */
 #endif
Index: xc/lib/X11/Xrm.c
diff -u xc/lib/X11/Xrm.c:3.13 xc/lib/X11/Xrm.c:3.14
--- xc/lib/X11/Xrm.c:3.13	Sat May 29 23:03:19 1999
+++ xc/lib/X11/Xrm.c	Tue Nov 28 13:49:29 2000
@@ -45,7 +45,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/X11/Xrm.c,v 3.13 1999/05/30 03:03:19 dawes Exp $ */
+/* $XFree86: xc/lib/X11/Xrm.c,v 3.14 2000/11/28 18:49:29 dawes Exp $ */
 
 #include	<stdio.h>
 #include	<ctype.h>
@@ -450,37 +450,44 @@
 
 #endif /* DEBUG */
 
-/*ARGSUSED*/
-static void mbnoop(state)
-    XPointer state;
+
+/*
+ * Fallback methods for Xrm parsing.
+ * Simulate a C locale. No state needed here.
+ */
+
+static void
+c_mbnoop(
+    XPointer state)
 {
 }
 
-/*ARGSUSED*/
-static char mbchar(state, str, lenp)
-    XPointer state;
-    char *str;
-    int *lenp;
+static char
+c_mbchar(
+    XPointer state,
+    const char *str,
+    int *lenp)
 {
     *lenp = 1;
     return *str;
 }
 
-/*ARGSUSED*/
-static char *lcname(state)
-    XPointer state;
+static const char *
+c_lcname(
+    XPointer state)
 {
     return "C";
 }
 
-static RConst XrmMethodsRec mb_methods = {
-    mbnoop,
-    mbchar,
-    mbnoop,
-    lcname,
-    mbnoop
+static const XrmMethodsRec mb_methods = {
+    c_mbnoop,	/* mbinit */
+    c_mbchar,	/* mbchar */
+    c_mbnoop,	/* mbfinish */
+    c_lcname,	/* lcname */
+    c_mbnoop	/* destroy */
 };
 
+
 static XrmDatabase NewDatabase()
 {
     register XrmDatabase db;
@@ -492,7 +499,7 @@
 	db->mbstate = (XPointer)NULL;
 	db->methods = _XrmInitParseInfo(&db->mbstate);
 	if (!db->methods)
-	    db->methods = (XrmMethods)&mb_methods;
+	    db->methods = &mb_methods;
     }
     return db;
 }
@@ -2650,10 +2657,11 @@
     Xfree((char *)table);
 }
 
-char *XrmLocaleOfDatabase(db)
+const char *
+XrmLocaleOfDatabase(db)
     XrmDatabase db;
 {
-    char* retval;
+    const char* retval;
     _XLockMutex(&db->linfo);
     retval = (*db->methods->lcname)(db->mbstate);
     _XUnlockMutex(&db->linfo);
Index: xc/lib/X11/Xutil.h
diff -u xc/lib/X11/Xutil.h:3.1 xc/lib/X11/Xutil.h:3.2
--- xc/lib/X11/Xutil.h:3.1	Sat Oct  3 04:41:31 1998
+++ xc/lib/X11/Xutil.h	Tue Nov 28 13:49:29 2000
@@ -42,7 +42,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/Xutil.h,v 3.1 1998/10/03 08:41:31 dawes Exp $ */
+/* $XFree86: xc/lib/X11/Xutil.h,v 3.2 2000/11/28 18:49:29 dawes Exp $ */
 
 #ifndef _XUTIL_H_
 #define _XUTIL_H_
@@ -163,7 +163,9 @@
     XStringStyle,		/* STRING */
     XCompoundTextStyle,		/* COMPOUND_TEXT */
     XTextStyle,			/* text in owner's encoding (current locale)*/
-    XStdICCTextStyle		/* STRING, else COMPOUND_TEXT */
+    XStdICCTextStyle,		/* STRING, else COMPOUND_TEXT */
+    /* The following is an XFree86 extension, introduced in November 2000 */
+    XUTF8StringStyle		/* UTF8_STRING */
 } XICCEncodingStyle;
 
 typedef struct {
@@ -364,11 +366,7 @@
 #endif
 );
 
-extern char *XDefaultString(
-#if NeedFunctionPrototypes
-    void
-#endif
-);
+extern const char *XDefaultString (void);
 
 extern int XDeleteContext(
 #if NeedFunctionPrototypes
@@ -748,6 +746,20 @@
 #endif
 );
 
+extern void Xutf8SetWMProperties(
+#if NeedFunctionPrototypes
+    Display*		/* display */,
+    Window		/* w */,
+    _Xconst char*	/* window_name */,
+    _Xconst char*	/* icon_name */,
+    char**		/* argv */,
+    int			/* argc */,
+    XSizeHints*		/* normal_hints */,
+    XWMHints*		/* wm_hints */,
+    XClassHint*		/* class_hints */
+#endif
+);
+
 extern void XSetWMSizeHints(
 #if NeedFunctionPrototypes
     Display*		/* display */,
@@ -807,29 +819,31 @@
 );
 
 extern int XmbTextListToTextProperty(
-#if NeedFunctionPrototypes
-    Display*		/* display */,
-    char**		/* list */,
-    int			/* count */,
-    XICCEncodingStyle	/* style */,
-    XTextProperty*	/* text_prop_return */
-#endif
+    Display*		display,
+    char**		list,
+    int			count,
+    XICCEncodingStyle	style,
+    XTextProperty*	text_prop_return
 );
 
 extern int XwcTextListToTextProperty(
-#if NeedFunctionPrototypes
-    Display*		/* display */,
-    wchar_t**		/* list */,
-    int			/* count */,
-    XICCEncodingStyle	/* style */,
-    XTextProperty*	/* text_prop_return */
-#endif
+    Display*		display,
+    wchar_t**		list,
+    int			count,
+    XICCEncodingStyle	style,
+    XTextProperty*	text_prop_return
 );
 
+extern int Xutf8TextListToTextProperty(
+    Display*		display,
+    char**		list,
+    int			count,
+    XICCEncodingStyle	style,
+    XTextProperty*	text_prop_return
+);
+
 extern void XwcFreeStringList(
-#if NeedFunctionPrototypes
-    wchar_t**		/* list */
-#endif
+    wchar_t**		list
 );
 
 extern Status XTextPropertyToStringList(
@@ -841,21 +855,24 @@
 );
 
 extern int XmbTextPropertyToTextList(
-#if NeedFunctionPrototypes
-    Display*		/* display */,
-    XTextProperty*	/* text_prop */,
-    char***		/* list_return */,
-    int*		/* count_return */
-#endif
+    Display*		display,
+    const XTextProperty* text_prop,
+    char***		list_return,
+    int*		count_return
 );
 
 extern int XwcTextPropertyToTextList(
-#if NeedFunctionPrototypes
-    Display*		/* display */,
-    XTextProperty*	/* text_prop */,
-    wchar_t***		/* list_return */,
-    int*		/* count_return */
-#endif
+    Display*		display,
+    const XTextProperty* text_prop,
+    wchar_t***		list_return,
+    int*		count_return
+);
+
+extern int Xutf8TextPropertyToTextList(
+    Display*		display,
+    const XTextProperty* text_prop,
+    char***		list_return,
+    int*		count_return
 );
 
 extern int XUnionRectWithRegion(
Index: xc/lib/X11/Xvarargs.h
diff -u xc/lib/X11/Xvarargs.h:1.1.1.2 xc/lib/X11/Xvarargs.h:1.2
--- xc/lib/X11/Xvarargs.h:1.1.1.2	Sun Sep 27 03:57:44 1998
+++ xc/lib/X11/Xvarargs.h	Tue Nov 28 13:49:30 2000
@@ -22,37 +22,11 @@
 from The Open Group.
 
 */
+/* $XFree86: xc/lib/X11/Xvarargs.h,v 1.2 2000/11/28 18:49:30 dawes Exp $ */
 
 #ifndef _XVARARGS_H_
 #define _XVARARGS_H_
 
-#ifdef __HIGHC__
-#ifndef _STDARG_H
-#define _STDARG_H
-
-typedef char *va_list;
-
-/* Amount of space required in an argument list for an arg of type TYPE.
-   TYPE may alternatively be an expression whose type is used.  */
-
-#define __va_rounded_size(TYPE)  \
-  (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
-
-#define va_start(AP, LASTARG)                                           \
- (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)))
-
-#define va_end(AP)
-
-#define va_arg(AP, TYPE)                                                \
- (AP += __va_rounded_size (TYPE),                                       \
-  *((TYPE *) (AP - __va_rounded_size (TYPE))))
-
-#endif /* _STDARG_H */
-
-#define Va_start(a,b) va_start(a,b)
-
-#else /* !__HIGHC__ */
-
 #if NeedVarargsPrototypes
 # include <stdarg.h>
 # define Va_start(a,b) va_start(a,b)
@@ -60,7 +34,5 @@
 # include <varargs.h>
 # define Va_start(a,b) va_start(a)
 #endif
-
-#endif /* __HIGHC__ */
 
 #endif /* _XVARARGS_H_ */
Index: xc/lib/X11/aixlcLoad.c
diff -u xc/lib/X11/aixlcLoad.c:3.3 xc/lib/X11/aixlcLoad.c:removed
--- xc/lib/X11/aixlcLoad.c:3.3	Mon Dec 23 00:59:52 1996
+++ xc/lib/X11/aixlcLoad.c	Mon Dec 18 14:23:53 2000
@@ -1,508 +0,0 @@
-/* $XConsortium: aixlcLoad.c /main/12 1996/09/28 16:36:57 rws $ */
-/*
- *
- * Copyright IBM Corporation 1993
- *
- * All Rights Reserved
- *
- * License to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
- * supporting documentation, and that the name of IBM not be
- * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- *
- * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND 
- * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
- * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- *
-*/
-/************************************************************************/
-/*	XaixlcLoad.c							*/
-/************************************************************************/
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include "Xlibint.h"
-#include "Xaixlcint.h"
-
-/************************************************************************/
-/*	Private defines							*/
-/************************************************************************/
-enum {
-    LDX_INVALID_TYPE,
-    LDX_DYNAMIC,
-    LDX_STATIC_SIM,
-    LDX_STATIC_MIM
-};
-
-enum {
-    LDX_INVALID_VERSION,
-    LDX_R5,
-    LDX_R6
-};
-
-typedef XLCd (*XLCdLoader)();
-typedef _XlcCoreObj (*XdlEntry)();
-
-#define	SECURE_PATH	"/usr/lib/nls/loc/X11"
-#ifndef	LDXDBFILE
-#define	LDXDBFILE	"ldx.dir"
-#endif
-#define	LDXFILE_SUFFIX	".ldx"
-
-#ifndef	_POSIX_PATH_MAX
-#define	_POSIX_PATH_MAX	1024
-#endif
-
-#define	iscomment(ch)	((ch) == '\0' || (ch) == '#')
-
-/* standard AIX interfaces */
-extern void *__lc_load();
-extern int __issetuid();
-
-extern int _XlcParsePath(char*, char**, int);
-
-/************************************************************************/
-/*	Private functions						*/
-/************************************************************************/
-
-static int
-parse_line(line, argv, argsize)
-    char *line;
-    char **argv;
-    int argsize;
-{
-    int argc = 0;
-    char *p = line;
-
-    while(argc < argsize){
-	while(isspace(*p)){
-	    ++p;
-	}
-	if(*p == '\0'){
-	    break;
-	}
-	argv[argc++] = p;
-	while(! isspace(*p)){
-	    ++p;
-	}
-	if(*p == '\0'){
-	    break;
-	}
-	*p++ = '\0';
-    }
-
-    return argc;
-}
-
-static int
-read_ldxdb(lc_name, path, type, option)
-    char *lc_name;
-    char *path;
-    int *type;
-    char *option;
-{
-    char filename[_POSIX_PATH_MAX];
-    FILE *fp;
-    char buf[BUFSIZE];
-    int found = 0;
-
-    sprintf(filename, "%s/%s", path, LDXDBFILE);
-    fp = fopen(filename, "r");
-    if(fp == (FILE *)NULL){
-	return 0;
-    }
-
-    while(fgets(buf, BUFSIZE, fp) != NULL){
-	char *p = buf;
-	int n;
-	char *args[3];
-	while(isspace(*p)){
-	    ++p;
-	}
-	if(iscomment(*p)){
-	    continue;
-	}
-	n = parse_line(p, args, 3);
-	if(n == 0){
-	    continue;
-	}
-	if(! strcmp(args[0], lc_name)){
-	    char *str;
-	    *type = LDX_STATIC_SIM;
-	    if(n > 1){
-		str = args[1];
-		if(! _XlcCompareISOLatin1(str, "LDX_DYNAMIC")){
-		    *type = LDX_DYNAMIC;
-		}else if(! _XlcCompareISOLatin1(str, "LDX_STATIC_MIM")){
-		    *type = LDX_STATIC_MIM;
-		}
-	    }
-	    *option = '\0';
-	    if(n > 2){
-		str = args[2];
-		if(! _XlcCompareISOLatin1(str, "NONE")){
-		    ; /* ignore option */
-		}else{
-		    strcpy(option, str);
-		}
-	    }
-	    found = 1;
-	    break;
-	}
-    }
-    fclose(fp);
-    return found;
-}
-
-static int
-resolve_ldxinfo(lc_name, type, option)
-    char *lc_name;
-    int *type;
-    char *option;
-{
-    char buf[BUFSIZE], *dir;
-    int i, n;
-    char *args[256];
-
-    dir = getenv("LDXDBPATH");
-    if(dir != NULL){
-	strncpy(buf, dir, BUFSIZE);
-	buf[BUFSIZE-1] = '\0';
-    }else{
-	/* Resolve default path for database */
-	_XlcResolveI18NPath(buf, BUFSIZE);
-    }
-    n = _XlcParsePath(buf, args, 256);
-    for(i = 0; i < n; ++i){
-	if(read_ldxdb(lc_name, args[i], type, option)){
-	    if(*type == LDX_DYNAMIC && *option != '/'){
-		/* the option should be absolute path */
-		char tmp[_POSIX_PATH_MAX];
-		sprintf(tmp, "%s/%s", args[i], option);
-		strcpy(option, tmp);
-	    }
-	    return 1;
-	}
-    }
-    return 0;
-}
-
-static int
-get_ldxversion(ldx)
-    _XlcCoreObj ldx;
-{
-    if(ldx == (_XlcCoreObj)NULL){
-	return	LDX_INVALID_VERSION;
-    }
-
-#ifdef AIXV4
-    if(ldx->lc_object_header.__type_id == _LC_LDX_R6 &&
-       ldx->lc_object_header.__magic   == _LC_MAGIC &&
-       ldx->lc_object_header.__version == _LC_VERSION_R6){
-	return	LDX_R6;
-    }
-
-    if(ldx->lc_object_header.__type_id == _LC_LDX &&
-       ldx->lc_object_header.__magic   == _LC_MAGIC &&
-       ldx->lc_object_header.__version == _LC_VERSION){
-	return	LDX_R5;
-    }
-
-#else
-    if(ldx->lc_object_header.type_id == _LC_LDX_R6 &&
-       ldx->lc_object_header.magic   == _LC_MAGIC &&
-       ldx->lc_object_header.version == _LC_VERSION_R6){
-	return	LDX_R6;
-    }
-
-    if(ldx->lc_object_header.type_id == _LC_LDX &&
-       ldx->lc_object_header.magic   == _LC_MAGIC &&
-       ldx->lc_object_header.version == _LC_VERSION){
-	return	LDX_R5;
-    }
-#endif
-
-    return LDX_INVALID_VERSION;
-}
-
-static int
-complete_path(lc_name, path)
-    char *lc_name;
-    char *path;
-{
-    if(path == NULL){
-	return 0;
-    }
-    if(*path == '\0' ||
-#ifdef	never
-       getuid() != geteuid() || getgid() != getegid()
-#else
-       __issetuid()
-#endif
-       ){
-	/* use secure path */
-	sprintf(path, "%s/%s%s", SECURE_PATH, lc_name, LDXFILE_SUFFIX);
-    }else{
-	int i, len;
-	len = strlen(path);
-	i = len - strlen(LDXFILE_SUFFIX);
-	if(i < 0 || strcmp(path + i, LDXFILE_SUFFIX)){
-	    if(path[len - 1] == '/'){
-		strcpy(path + len, lc_name);
-		len += strlen(lc_name);
-	    }
-	    strcpy(path + len, LDXFILE_SUFFIX);
-	}
-    }
-    return (*path != '\0') ? 1 : 0;
-}
-
-/************************************************************************/
-
-typedef struct _ldxList{
-    char *path;
-    XdlEntry entrypoint;
-    _XlcCoreObj obj;
-    int ref_count;
-    struct _ldxList *next;
-} ldxList;
-
-static ldxList	*_ldxlist = (ldxList *)NULL;
-
-static void
-unload_ldx(obj)
-    _XlcCoreObj obj;
-{
-    ldxList *pre, *ptr;
-
-    for(pre = (ldxList *)NULL, ptr = _ldxlist; ptr != (ldxList *)NULL;
-	pre = ptr, ptr = ptr->next){
-	if(ptr->obj == obj){
-	    if((-- ptr->ref_count) < 1){
-		/* free and rechain cache list */
-		Xfree(ptr->path);
-		unload((void *)ptr->entrypoint);
-		if(pre != (ldxList *)NULL){
-		    pre->next = ptr->next;
-		}else{
-		    _ldxlist = ptr->next;
-		}
-		Xfree((char *)ptr);
-	    }
-	    return;
-	}
-    }
-}
-
-static void *
-instantiate(path, p)
-    char *path;
-    void *(*p)();
-{
-    /* return entry point simply */
-    return (void *)p;
-}
-
-static _XlcCoreObj
-load_ldx(path)
-    char *path;
-{
-    ldxList *ptr = (ldxList *)NULL;
-    XdlEntry entry;
-    _XlcCoreObj ldx = (_XlcCoreObj)NULL;
-
-    for(ptr = _ldxlist; ptr != (ldxList *)NULL; ptr = ptr->next){
-	if(! strcmp(path, ptr->path)){
-	    ++ (ptr->ref_count);
-	    return ptr->obj;
-	}
-    }
-
-    /* dynamic load */
-    /* the given path should be absolute path */
-#ifdef	never
-    entry = (XdlEntry)load(path, 1, NULL);
-#else
-    entry = (XdlEntry)__lc_load(path, instantiate);
-#endif
-    if(entry == (XdlEntry)NULL){
-	goto err;
-    }
-    ldx = (*entry)();
-    if(ldx == (_XlcCoreObj)NULL){
-	goto err;
-    }
-
-    /* create cache list */
-    ptr = (ldxList *)Xmalloc(sizeof(ldxList));
-    if(ptr == (ldxList *)NULL){
-	goto err;
-    }
-    ptr->path = Xmalloc(strlen(path) + 1);
-    if(ptr->path == NULL){
-	goto err;
-    }
-    strcpy(ptr->path, path);
-    ptr->entrypoint = entry;
-    ptr->obj = ldx;
-    ptr->ref_count = 1;
-    ptr->next = _ldxlist;
-    _ldxlist = ptr;
-
-    return ldx;
-
- err:;
-    if(entry != (XdlEntry)NULL){
-	unload((void *)entry);
-    }
-    if(ptr != (ldxList *)NULL){
-	Xfree((char *)ptr);
-    }
-    return (_XlcCoreObj)NULL;
-}
-
-/************************************************************************/
-
-typedef struct _lcdList {
-    XLCd lcd;
-    _XlcCoreObj ldx;
-    XCloseLCProc close;
-    struct _lcdList *next;
-} lcdList;
-
-static lcdList *_lcdlist = (lcdList *)NULL;
-
-static void
-close_xlcd(lcd)
-    XLCd lcd;
-{
-    lcdList *pre, *ptr;
-
-    for(pre = (lcdList *)NULL, ptr = _lcdlist; ptr != (lcdList *)NULL;
-	pre = ptr, ptr = ptr->next){
-	if(lcd == ptr->lcd){
-	    /* free and rechain cache list */
-	    (*ptr->close)(lcd);
-	    unload_ldx(ptr->ldx);
-	    if(pre != (lcdList *)NULL){
-		pre->next = ptr->next;
-	    }else{
-		_lcdlist = ptr->next;
-	    }
-	    Xfree((char *)ptr);
-	    return;
-	}
-    }
-}
-
-/************************************************************************/
-
-#ifdef	STATIC_LOAD
-extern XLCd _XaixlcSIMLoader();
-extern XLCd _XaixlcMIMLoader();
-#endif
-
-static XLCd
-instantiate_xlcd(lc_name)
-    char *lc_name;
-{
-    int type;
-    char path[_POSIX_PATH_MAX];
-    _XlcCoreObj ldx = (_XlcCoreObj)NULL;
-    XLCdLoader _XlcInstantiate = (XLCdLoader)NULL;
-    XLCd lcd = (XLCd)NULL;
-
-    if(! resolve_ldxinfo(lc_name, &type, path)){
-	return (XLCd)NULL;
-    }
-
-    switch(type){
-#ifdef	STATIC_LOAD
-    case LDX_STATIC_SIM:
-	_XlcInstantiate = _XaixlcSIMLoader;
-	break;
-    case LDX_STATIC_MIM:
-	_XlcInstantiate = _XaixlcMIMLoader;
-	break;
-#endif
-    case LDX_DYNAMIC:
-	if(! complete_path(lc_name, path)){
-	    break;
-	}
-	ldx = load_ldx(path);
-	if(ldx == (_XlcCoreObj)NULL){
-	    break;
-	}
-	switch(get_ldxversion(ldx)){
-	case LDX_R5:
-	    /* X11.5 LDX is not supported. */
-	    break;
-	case LDX_R6:
-	    _XlcInstantiate = (XLCdLoader)ldx->default_loader;
-	    break;
-	default:
-	    break;
-	}
-	break;
-    }
-
-    if(_XlcInstantiate != (XLCdLoader)NULL){
-	lcd = (*_XlcInstantiate)(lc_name);
-    }
-
-    switch(type){
-    case LDX_STATIC_SIM:
-	break;
-    case LDX_STATIC_MIM:
-	break;
-    case LDX_DYNAMIC:
-	if(ldx != (_XlcCoreObj)NULL){
-	    if(ldx->sticky){
-		break;
-	    }
-	    if(lcd != (XLCd)NULL){
-		lcdList *ptr = (lcdList *)Xmalloc(sizeof(lcdList));
-		if(ptr != (lcdList *)NULL){
-		    ptr->lcd = lcd;
-		    ptr->ldx = ldx;
-		    ptr->close = lcd->methods->close;
-		    lcd->methods->close = (XCloseLCProc)close_xlcd;
-		    ptr->next = _lcdlist;
-		    _lcdlist = ptr;
-		}else{
-		    (*lcd->methods->close)(lcd);
-		    lcd = (XLCd)NULL;
-		}
-	    }
-	    if(lcd == (XLCd)NULL){
-		/* fail to instantiate lcd */
-		unload_ldx(ldx);
-	    }
-	}
-	break;
-    }
-
-    return lcd;
-}
-
-/************************************************************************/
-/*	_XaixOsDynamicLoad()						*/
-/*----------------------------------------------------------------------*/
-/*	This loader creates XLCd with using AIX dynamic loading 	*/
-/*	feature.							*/
-/************************************************************************/
-XLCd
-_XaixOsDynamicLoad(name)
-    char *name;
-{
-    return instantiate_xlcd(name);
-}
Index: xc/lib/X11/cmsTrig.c
diff -u xc/lib/X11/cmsTrig.c:3.3 xc/lib/X11/cmsTrig.c:3.5
--- xc/lib/X11/cmsTrig.c:3.3	Sun May  9 06:50:30 1999
+++ xc/lib/X11/cmsTrig.c	Thu Aug 31 15:03:54 2000
@@ -24,7 +24,7 @@
  * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $XFree86: xc/lib/X11/cmsTrig.c,v 3.3 1999/05/09 10:50:30 dawes Exp $ */
+/* $XFree86: xc/lib/X11/cmsTrig.c,v 3.5 2000/08/31 19:03:54 tsi Exp $ */
 /*
  *	It should be pointed out that for simplicity's sake, the
  *	environment parameters are defined as floating point constants,
@@ -90,13 +90,8 @@
 #ifdef _CRAY
 #define XCMS_DMAXPOWTWO	((double)(1 < 47))
 #else
-#ifdef __alpha__
 #define XCMS_DMAXPOWTWO	((double)(XCMS_LONG_MAX) * \
 	    (1L << ((XCMS_NBITS(double)-XCMS_DEXPLEN) - XCMS_NBITS(int) + 1)))
-#else
-#define XCMS_DMAXPOWTWO	((double)(XCMS_LONG_MAX) * \
-	    (1L << ((XCMS_NBITS(double)-XCMS_DEXPLEN) - XCMS_NBITS(long) + 1)))
-#endif
 #endif
 
 /*
Index: xc/lib/X11/imConv.c
diff -u xc/lib/X11/imConv.c:1.25 xc/lib/X11/imConv.c:1.30
--- xc/lib/X11/imConv.c:1.25	Fri Jun 23 15:50:59 2000
+++ xc/lib/X11/imConv.c	Mon Dec  4 13:49:21 2000
@@ -31,7 +31,9 @@
                                 fujiwara@a80.tech.yk.fujitsu.co.jp
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imConv.c,v 1.25 2000/06/23 19:50:59 dawes Exp $ */
+/* 2000 Modifier: Ivan Pascal	The XFree86 Project.
+ */
+/* $XFree86: xc/lib/X11/imConv.c,v 1.30 2000/12/04 18:49:21 dawes Exp $ */
 
 #define NEED_EVENTS
 #include <stdio.h>
@@ -39,8 +41,6 @@
 #include "Xlcint.h"
 #include "Ximint.h"
 #include "XlcPubI.h"
-#define XK_PUBLISHING
-#include "X11/keysym.h"
 
 #ifdef XKB
 /* 
@@ -53,772 +53,102 @@
 #else
 #define	XLOOKUPSTRING XLookupString
 #endif
-
-#ifdef __STDC__
-#define Const const
-#else
-#define Const /**/
-#endif
-
-/* bit (1<<i) means character is in codeset i */
-unsigned int Const _Xlatin1[128] = {
-0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
-0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
-0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-0xb90ee, 0x88000, 0xa9000, 0xa9084, 0x2902e, 0x89000, 0x29080, 0xb908e,
-0x0908e, 0xa9080, 0x88000, 0xa9080, 0xa9080, 0xb90ee, 0xa9000, 0x89008,
-0xb908e, 0xa9080, 0xa9084, 0xa9084, 0x0908e, 0xa9004, 0xa9000, 0xb9084,
-0x0900c, 0xa9000, 0x88000, 0xa9080, 0x29000, 0x29084, 0x29000, 0x88000,
-0x88004, 0x9800e, 0x9800e, 0x98008, 0xb800e, 0xb8008, 0x98008, 0x88006,
-0x88004, 0xb800e, 0x88004, 0x9800e, 0x88004, 0x9800e, 0x9800e, 0x98004,
-0x90000, 0x88004, 0x88004, 0xb8006, 0x9800e, 0xb8008, 0xb800e, 0xa800e,
-0x98008, 0x88004, 0x9800e, 0x9800c, 0xb800e, 0x90002, 0x90000, 0xb800e,
-0x88004, 0x9800e, 0x9800e, 0x98008, 0xb800e, 0xb8008, 0x98008, 0x88004,
-0x88004, 0xb800e, 0x88004, 0x9800e, 0x88004, 0x9800e, 0x9800e, 0x98004,
-0x90000, 0x88004, 0x88004, 0xb8006, 0x9800e, 0xb8008, 0xb800e, 0xa800e,
-0x98008, 0x88004, 0x9800e, 0x9800c, 0xb800e, 0x90002, 0x90000, 0x88000
-};
-
-/* bit (1<<i) means character is in codeset i */
-unsigned int Const _Xlatin2[128] = {
-0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
-0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
-0x1800c, 0x10008, 0x00004, 0x00000, 0x0800c, 0x00000, 0x00000, 0x1800c,
-0x0800c, 0x00008, 0x00004, 0x00000, 0x00000, 0x1800c, 0x00008, 0x00004,
-0x1800c, 0x10008, 0x00008, 0x00000, 0x0800c, 0x00000, 0x00000, 0x00008,
-0x0800c, 0x00008, 0x00004, 0x00000, 0x00000, 0x00000, 0x00008, 0x00004,
-0x00000, 0x1800c, 0x1800c, 0x00000, 0x1800c, 0x00000, 0x00000, 0x08004,
-0x30008, 0x1800c, 0x10008, 0x1800c, 0x00000, 0x18008, 0x18008, 0x00000,
-0x00008, 0x20000, 0x00000, 0x18004, 0x1800c, 0x00000, 0x1800c, 0x0800c,
-0x00000, 0x00000, 0x0800c, 0x00000, 0x0800c, 0x10000, 0x00000, 0x1800c,
-0x00000, 0x1800c, 0x1800c, 0x00000, 0x1800c, 0x00000, 0x00000, 0x08004,
-0x30008, 0x1800c, 0x10008, 0x1800c, 0x00000, 0x1800c, 0x1800c, 0x00000,
-0x00008, 0x20000, 0x00000, 0x18004, 0x1800c, 0x00000, 0x1800c, 0x0800c,
-0x00000, 0x00000, 0x0800c, 0x00000, 0x0800c, 0x10000, 0x00000, 0x0000c
-};
-
-/* maps Cyrillic keysyms to 8859-5 */
-unsigned char Const _Xcyrillic[] = {
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 - */
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90 - */
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0xf2, 0xf3, 0xf1, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xa0 - */
-    0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0xfe, 0xff,
-    0xf0, 0xa2, 0xa3, 0xa1, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xb0 - */
-    0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf,
-    0xee, 0xd0, 0xd1, 0xe6, 0xd4, 0xd5, 0xe4, 0xd3, /* 0xc0 - */
-    0xe5, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
-    0xdf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xd6, 0xd2, /* 0xd0 - */
-    0xec, 0xeb, 0xd7, 0xe8, 0xed, 0xe9, 0xe7, 0xea,
-    0xce, 0xb0, 0xb1, 0xc6, 0xb4, 0xb5, 0xc4, 0xb3, /* 0xe0 - */
-    0xc5, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe,
-    0xbf, 0xcf, 0xc0, 0xc1, 0xc2, 0xc3, 0xb6, 0xb2, /* 0xf0 - */
-    0xcc, 0xcb, 0xb7, 0xc8, 0xcd, 0xc9, 0xc7, 0xca
-};
-
-/* maps Cyrillic keysyms to KOI8-R */
-unsigned char Const _Xkoi8_r[] =
-   {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, /* 10 */
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, /* 11 */
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 12 */
-    0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
-    0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 13 */
-    0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
-    0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 14 */
-    0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
-    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 15 */
-    0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff};
-
-/* maps Cyrillic keysyms to KOI8-U */
-unsigned char Const _Xkoi8_u[] =
-   {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0xa3, 0xa4, 0x00, 0xa6, 0xa7, /* 10 */
-    0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0xb3, 0xb4, 0x00, 0xb6, 0xb7, /* 11 */
-    0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00,
-    0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 12 */
-    0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
-    0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 13 */
-    0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
-    0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 14 */
-    0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
-    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 15 */
-    0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff};
-
-unsigned short Const _Xkoi8_size = sizeof _Xkoi8_r;
-
-/* maps Greek keysyms to 8859-7 */
-unsigned char Const _Xgreek[] = {
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 - */
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90 - */
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0xb6, 0xb8, 0xb9, 0xba, 0xda, 0x00, 0xbc, /* 0xa0 - */
-    0xbe, 0xdb, 0x00, 0xbf, 0x00, 0x00, 0xb5, 0xaf,
-    0x00, 0xdc, 0xdd, 0xde, 0xdf, 0xfa, 0xc0, 0xfc, /* 0xb0 - */
-    0xfd, 0xfb, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0 - */
-    0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
-    0xd0, 0xd1, 0xd3, 0x00, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0 - */
-    0xd8, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0 - */
-    0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
-    0xf0, 0xf1, 0xf3, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0 - */
-    0xf8, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-
-static unsigned short Const keysym_to_unicode_1a1_1ff[] = {
-            0x0104, 0x02d8, 0x0141, 0x0000, 0x013d, 0x015a, 0x0000, /* 0x01a0-0x01a7 */
-    0x0000, 0x0160, 0x015e, 0x0164, 0x0179, 0x0000, 0x017d, 0x017b, /* 0x01a8-0x01af */
-    0x0000, 0x0105, 0x02db, 0x0142, 0x0000, 0x013e, 0x015b, 0x02c7, /* 0x01b0-0x01b7 */
-    0x0000, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, /* 0x01b8-0x01bf */
-    0x0154, 0x0000, 0x0000, 0x0102, 0x0000, 0x0139, 0x0106, 0x0000, /* 0x01c0-0x01c7 */
-    0x010c, 0x0000, 0x0118, 0x0000, 0x011a, 0x0000, 0x0000, 0x010e, /* 0x01c8-0x01cf */
-    0x0110, 0x0143, 0x0147, 0x0000, 0x0000, 0x0150, 0x0000, 0x0000, /* 0x01d0-0x01d7 */
-    0x0158, 0x016e, 0x0000, 0x0170, 0x0000, 0x0000, 0x0162, 0x0000, /* 0x01d8-0x01df */
-    0x0155, 0x0000, 0x0000, 0x0103, 0x0000, 0x013a, 0x0107, 0x0000, /* 0x01e0-0x01e7 */
-    0x010d, 0x0000, 0x0119, 0x0000, 0x011b, 0x0000, 0x0000, 0x010f, /* 0x01e8-0x01ef */
-    0x0111, 0x0144, 0x0148, 0x0000, 0x0000, 0x0151, 0x0000, 0x0000, /* 0x01f0-0x01f7 */
-    0x0159, 0x016f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0163, 0x02d9  /* 0x01f8-0x01ff */
-};
-
-static unsigned short Const keysym_to_unicode_2a1_2fe[] = {
-            0x0126, 0x0000, 0x0000, 0x0000, 0x0000, 0x0124, 0x0000, /* 0x02a0-0x02a7 */
-    0x0000, 0x0130, 0x0000, 0x011e, 0x0134, 0x0000, 0x0000, 0x0000, /* 0x02a8-0x02af */
-    0x0000, 0x0127, 0x0000, 0x0000, 0x0000, 0x0000, 0x0125, 0x0000, /* 0x02b0-0x02b7 */
-    0x0000, 0x0131, 0x0000, 0x011f, 0x0135, 0x0000, 0x0000, 0x0000, /* 0x02b8-0x02bf */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x010a, 0x0108, 0x0000, /* 0x02c0-0x02c7 */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x02c8-0x02cf */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0120, 0x0000, 0x0000, /* 0x02d0-0x02d7 */
-    0x011c, 0x0000, 0x0000, 0x0000, 0x0000, 0x016c, 0x015c, 0x0000, /* 0x02d8-0x02df */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x010b, 0x0109, 0x0000, /* 0x02e0-0x02e7 */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x02e8-0x02ef */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0121, 0x0000, 0x0000, /* 0x02f0-0x02f7 */
-    0x011d, 0x0000, 0x0000, 0x0000, 0x0000, 0x016c, 0x015d          /* 0x02f8-0x02ff */
-};
 
-static unsigned short Const keysym_to_unicode_3a2_3fe[] = {
-                    0x0138, 0x0156, 0x0000, 0x0128, 0x013b, 0x0000, /* 0x03a0-0x03a7 */
-    0x0000, 0x0000, 0x0112, 0x0122, 0x0166, 0x0000, 0x0000, 0x0000, /* 0x03a8-0x03af */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x013c, 0x0000, /* 0x03b0-0x03b7 */
-    0x0000, 0x0000, 0x0113, 0x0123, 0x0167, 0x014a, 0x0000, 0x014b, /* 0x03b8-0x03bf */
-    0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x012e, /* 0x03c0-0x03c7 */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0116, 0x0000, 0x0000, 0x012a, /* 0x03c8-0x03cf */
-    0x0000, 0x0145, 0x014c, 0x0136, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x03d0-0x03d7 */
-    0x0000, 0x0172, 0x0000, 0x0000, 0x0000, 0x0168, 0x016a, 0x0000, /* 0x03d8-0x03df */
-    0x0101, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x012f, /* 0x03e0-0x03e7 */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0117, 0x0000, 0x0000, 0x012b, /* 0x03e8-0x03ef */
-    0x0000, 0x0146, 0x014d, 0x0137, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x03f0-0x03f7 */
-    0x0000, 0x0173, 0x0000, 0x0000, 0x0000, 0x0169, 0x016b          /* 0x03f8-0x03ff */
-};
-
-static unsigned short Const keysym_to_unicode_4a1_4df[] = {
-            0x3002, 0x3008, 0x3009, 0x3001, 0x30fb, 0x30f2, 0x30a1, /* 0x04a0-0x04a7 */
-    0x30a3, 0x03a5, 0x30a7, 0x30a9, 0x30e3, 0x30e5, 0x30e7, 0x30c3, /* 0x04a8-0x04af */
-    0x30fc, 0x03a2, 0x30a4, 0x30a6, 0x30a8, 0x30aa, 0x30ab, 0x30ad, /* 0x04b0-0x04b7 */
-    0x30af, 0x30b1, 0x30b3, 0x30b5, 0x30b7, 0x30b9, 0x30bb, 0x30bd, /* 0x04b8-0x04bf */
-    0x30bf, 0x30c1, 0x30c4, 0x30c6, 0x30c8, 0x30ca, 0x30cb, 0x30cc, /* 0x04c0-0x04c7 */
-    0x30cd, 0x30ce, 0x30cf, 0x30d2, 0x30d5, 0x30d8, 0x30db, 0x30de, /* 0x04c8-0x04cf */
-    0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e4, 0x30e6, 0x30e8, 0x30e9, /* 0x04d0-0x04d7 */
-    0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ef, 0x30f3, 0x309b, 0x309c  /* 0x04d8-0x04df */
-};
-
-static unsigned short Const keysym_to_unicode_5ac_5f2[] = {
-                                    0x060c, 0x0000, 0x0000, 0x0000, /* 0x05ac-0x05af */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x05b0-0x05b7 */
-    0x0000, 0x0000, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f, /* 0x05b8-0x05bf */
-    0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, /* 0x05c0-0x05c7 */
-    0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f, /* 0x05c8-0x05cf */
-    0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, /* 0x05d0-0x05d7 */
-    0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x05d8-0x05df */
-    0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, /* 0x05e0-0x05e7 */
-    0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, /* 0x05e8-0x05ef */
-    0x0650, 0x0651, 0x0652                                          /* 0x05f0-0x05f7 */
-};
-
-static unsigned short Const keysym_to_unicode_6a1_6ff[] = {
-            0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457, /* 0x06a0-0x06a7 */
-    0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0000, 0x045e, 0x045f, /* 0x06a8-0x06af */
-    0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407, /* 0x06b0-0x06b7 */
-    0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x0000, 0x040e, 0x040f, /* 0x06b8-0x06bf */
-    0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, /* 0x06c0-0x06c7 */
-    0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, /* 0x06c8-0x06cf */
-    0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, /* 0x06d0-0x06d7 */
-    0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, /* 0x06d8-0x06df */
-    0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, /* 0x06e0-0x06e7 */
-    0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, /* 0x06e8-0x06ef */
-    0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, /* 0x06f0-0x06f7 */
-    0x042c, 0x042d, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a  /* 0x06f8-0x06ff */
-};
-
-static unsigned short Const keysym_to_unicode_7a1_7f9[] = {
-            0x0386, 0x0388, 0x0389, 0x038a, 0x03aa, 0x0000, 0x038c, /* 0x07a0-0x07a7 */
-    0x038e, 0x03ab, 0x0000, 0x038f, 0x0000, 0x0000, 0x0385, 0x2015, /* 0x07a8-0x07af */
-    0x0000, 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03ca, 0x0390, 0x03cc, /* 0x07b0-0x07b7 */
-    0x03cd, 0x03cb, 0x03b0, 0x03ce, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x07b8-0x07bf */
-    0x0000, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, /* 0x07c0-0x07c7 */
-    0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, /* 0x07c8-0x07cf */
-    0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, /* 0x07d0-0x07d7 */
-    0x03a8, 0x03a9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x07d8-0x07df */
-    0x0000, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, /* 0x07e0-0x07e7 */
-    0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, /* 0x07e8-0x07ef */
-    0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, /* 0x07f0-0x07f7 */
-    0x03c8, 0x03c9                                                  /* 0x07f8-0x07ff */
-};
+typedef unsigned int ucs4_t;
 
-static unsigned short Const keysym_to_unicode_8a4_8fe[] = {
-                                    0x2320, 0x2321, 0x0000, 0x231c, /* 0x08a0-0x08a7 */
-    0x231d, 0x231e, 0x231f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08a8-0x08af */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08b0-0x08b7 */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x2264, 0x2260, 0x2265, 0x222b, /* 0x08b8-0x08bf */
-    0x2234, 0x0000, 0x221e, 0x0000, 0x0000, 0x2207, 0x0000, 0x0000, /* 0x08c0-0x08c7 */
-    0x2245, 0x2246, 0x0000, 0x0000, 0x0000, 0x0000, 0x22a2, 0x0000, /* 0x08c8-0x08cf */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x221a, 0x0000, /* 0x08d0-0x08d7 */
-    0x0000, 0x0000, 0x2282, 0x2283, 0x2229, 0x222a, 0x2227, 0x2228, /* 0x08d8-0x08df */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08e0-0x08e7 */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08e8-0x08ef */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192, 0x0000, /* 0x08f0-0x08f7 */
-    0x0000, 0x0000, 0x0000, 0x2190, 0x2191, 0x2192, 0x2193          /* 0x08f8-0x08ff */
-};
-
-static unsigned short Const keysym_to_unicode_9df_9f8[] = {
-                                                            0x2422, /* 0x09d8-0x09df */
-    0x2666, 0x25a6, 0x2409, 0x240c, 0x240d, 0x240a, 0x0000, 0x0000, /* 0x09e0-0x09e7 */
-    0x240a, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x2500, /* 0x09e8-0x09ef */
-    0x0000, 0x0000, 0x0000, 0x0000, 0x251c, 0x2524, 0x2534, 0x252c, /* 0x09f0-0x09f7 */
-    0x2502                                                          /* 0x09f8-0x09ff */
-};
-
-static unsigned short Const keysym_to_unicode_aa1_afe[] = {
-            0x2003, 0x2002, 0x2004, 0x2005, 0x2007, 0x2008, 0x2009, /* 0x0aa0-0x0aa7 */
-    0x200a, 0x2014, 0x2013, 0x0000, 0x0000, 0x0000, 0x2026, 0x2025, /* 0x0aa8-0x0aaf */
-    0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a, /* 0x0ab0-0x0ab7 */
-    0x2105, 0x0000, 0x0000, 0x2012, 0x2039, 0x2024, 0x203a, 0x0000, /* 0x0ab8-0x0abf */
-    0x0000, 0x0000, 0x0000, 0x215b, 0x215c, 0x215d, 0x215e, 0x0000, /* 0x0ac0-0x0ac7 */
-    0x0000, 0x2122, 0x2120, 0x00ae, 0x25c1, 0x25b7, 0x25cb, 0x25ad, /* 0x0ac8-0x0acf */
-    0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x0000, 0x2032, 0x2033, /* 0x0ad0-0x0ad7 */
-    0x0000, 0x271d, 0x0000, 0x220e, 0x25c2, 0x2023, 0x25cf, 0x25ac, /* 0x0ad8-0x0adf */
-    0x25e6, 0x25ab, 0x25ae, 0x25b5, 0x25bf, 0x2606, 0x2022, 0x25aa, /* 0x0ae0-0x0ae7 */
-    0x25b4, 0x25be, 0x261a, 0x261b, 0x2663, 0x2666, 0x2665, 0x0000, /* 0x0ae8-0x0aef */
-    0x2720, 0x2020, 0x2021, 0x2713, 0x2612, 0x266f, 0x266d, 0x2642, /* 0x0af0-0x0af7 */
-    0x2640, 0x2121, 0x2315, 0x2117, 0x2038, 0x201a, 0x201e          /* 0x0af8-0x0aff */
-};
-
-/* none of the APL keysyms match the Unicode characters */
-
-static unsigned short Const keysym_to_unicode_cdf_cfa[] = {
-                                                            0x2017, /* 0x0cd8-0x0cdf */
-    0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7, /* 0x0ce0-0x0ce7 */
-    0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df, /* 0x0ce8-0x0cef */
-    0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7, /* 0x0cf0-0x0cf7 */
-    0x05e8, 0x05e9, 0x05ea                                          /* 0x0cf8-0x0cff */
-};
-
-static unsigned short Const keysym_to_unicode_da1_df9[] = {
-            0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, /* 0x0da0-0x0da7 */
-    0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, /* 0x0da8-0x0daf */
-    0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, /* 0x0db0-0x0db7 */
-    0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, /* 0x0db8-0x0dbf */
-    0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, /* 0x0dc0-0x0dc7 */
-    0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, /* 0x0dc8-0x0dcf */
-    0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, /* 0x0dd0-0x0dd7 */
-    0x0e38, 0x0e39, 0x0e3a, 0x0e3b, 0x0e3c, 0x0e3d, 0x0e3e, 0x0e3f, /* 0x0dd8-0x0ddf */
-    0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, /* 0x0de0-0x0de7 */
-    0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0000, 0x0000, /* 0x0de8-0x0def */
-    0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, /* 0x0df0-0x0df7 */
-    0x0e58, 0x0e59                                                  /* 0x0df8-0x0dff */
-};
-
-static unsigned short Const keysym_to_unicode_ea0_eff[] = {
-    0x0000, 0x1101, 0x1101, 0x11aa, 0x1102, 0x11ac, 0x11ad, 0x1103, /* 0x0ea0-0x0ea7 */
-    0x1104, 0x1105, 0x11b0, 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5, /* 0x0ea8-0x0eaf */
-    0x11b6, 0x1106, 0x1107, 0x1108, 0x11b9, 0x1109, 0x110a, 0x110b, /* 0x0eb0-0x0eb7 */
-    0x110c, 0x110d, 0x110e, 0x110f, 0x1110, 0x1111, 0x1112, 0x1161, /* 0x0eb8-0x0ebf */
-    0x1162, 0x1163, 0x1164, 0x1165, 0x1166, 0x1167, 0x1168, 0x1169, /* 0x0ec0-0x0ec7 */
-    0x116a, 0x116b, 0x116c, 0x116d, 0x116e, 0x116f, 0x1170, 0x1171, /* 0x0ec8-0x0ecf */
-    0x1172, 0x1173, 0x1174, 0x1175, 0x11a8, 0x11a9, 0x11aa, 0x11ab, /* 0x0ed0-0x0ed7 */
-    0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3, /* 0x0ed8-0x0edf */
-    0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba, 0x11bb, /* 0x0ee0-0x0ee7 */
-    0x11bc, 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x0000, /* 0x0ee8-0x0eef */
-    0x0000, 0x0000, 0x1140, 0x0000, 0x0000, 0x1159, 0x119e, 0x0000, /* 0x0ef0-0x0ef7 */
-    0x11eb, 0x0000, 0x11f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x20a9, /* 0x0ef8-0x0eff */
-};
-
-static unsigned short Const keysym_to_unicode_13bc_13be[] = {
-                                    0x0152, 0x0153, 0x0178          /* 0x13b8-0x13bf */
-};
-
-static unsigned short Const keysym_to_unicode_20a0_20ac[] = {
-    0x20a0, 0x20a1, 0x20a2, 0x20a3, 0x20a4, 0x20a5, 0x20a6, 0x20a7, /* 0x20a0-0x20a7 */
-    0x20a8, 0x20a9, 0x20aa, 0x20ab, 0x20ac                          /* 0x20a8-0x20af */
-};
+typedef int (*ucstocsConvProc)(
+#if NeedFunctionPrototypes
+    XPointer,
+    unsigned char *,
+    ucs4_t,
+    int
+#endif
+);
 
-static int keysym_to_ucs4(keysym)
-    KeySym keysym;
-{
-    if (keysym > 0 && keysym < 0x100)
-	return keysym;
-    else if (keysym > 0x1a0 && keysym < 0x200)
-	return keysym_to_unicode_1a1_1ff[keysym - 0x1a1];
-    else if (keysym > 0x2a0 && keysym < 0x2ff)
-	return keysym_to_unicode_2a1_2fe[keysym - 0x2a1];
-    else if (keysym > 0x3a1 && keysym < 0x3ff)
-	return keysym_to_unicode_3a2_3fe[keysym - 0x3a2];
-    else if (keysym > 0x4a0 && keysym < 0x4e0)
-	return keysym_to_unicode_4a1_4df[keysym - 0x4a1];
-    else if (keysym > 0x5ab && keysym < 0x5f3)
-	return keysym_to_unicode_5ac_5f2[keysym - 0x5ac];
-    else if (keysym > 0x6a0 && keysym < 0x700)
-	return keysym_to_unicode_6a1_6ff[keysym - 0x6a1];
-    else if (keysym > 0x7a0 && keysym < 0x7fa)
-	return keysym_to_unicode_7a1_7f9[keysym - 0x7a1];
-    else if (keysym > 0x8a3 && keysym < 0x8ff)
-	return keysym_to_unicode_8a4_8fe[keysym - 0x8a4];
-    else if (keysym > 0x9de && keysym < 0x9f9)
-	return keysym_to_unicode_9df_9f8[keysym - 0x9df];
-    else if (keysym > 0xaa0 && keysym < 0xaff)
-	return keysym_to_unicode_aa1_afe[keysym - 0xaa1];
-    else if (keysym > 0xcde && keysym < 0xcfb)
-	return keysym_to_unicode_cdf_cfa[keysym - 0xcdf];
-    else if (keysym > 0xda0 && keysym < 0xdfa)
-	return keysym_to_unicode_da1_df9[keysym - 0xda1];
-    else if (keysym > 0xe9f && keysym < 0xf00)
-	return keysym_to_unicode_ea0_eff[keysym - 0xea0];
-    else if (keysym > 0x13bb && keysym < 0x13bf)
-	return keysym_to_unicode_13bc_13be[keysym - 0x13bc];
-    else if (keysym > 0x209f && keysym < 0x20ad)
-	return keysym_to_unicode_20a0_20ac[keysym - 0x20a0];
-    else 
-	return 0;
-}
+XPointer _Utf8GetConvByName(
+    const char *	name
+);
 
-struct CodesetRec {
-    unsigned long locale_code;
-    char* locale_name;
-    char* charset_name;
+struct SubstRec {
+    char*  encoding_name;
+    char*  charset_name;
 };
 
-#define sLatin1	0L
-#define sLatin2	1L
-#define sLatin3	2L
-#define sLatin4	3L
-#define sKana	4L
-#define sX0201  0x01000004L
-#define sArabic	5L
-#define sCyrillic	6L
-#define sKoi8_r	0x01000006L
-#define sKoi8_u	0x02000006L
-#define sGreek	7L
-#define sHebrew	12L
-#define sThai	13L
-#define sKorean	14L
-#define sLatin5	15L
-#define sLatin6	16L
-#define sLatin7	17L
-#define sLatin8	18L
-#define sLatin9	19L
-#define sArmenian 20L
-#define sGeorgian 21L
-#define sGeorgianPS 0x01000021L
-#define sCurrency 32L
-#define sUTF8	0x02000000L
-
-static struct CodesetRec CodesetTable[] = {
-    {sLatin1,	"ISO8859-1", NULL },
-    {sLatin2,	"ISO8859-2", NULL },
-    {sLatin3,	"ISO8859-3", NULL },
-    {sLatin4,	"ISO8859-4", NULL },
-    {sCyrillic,	"ISO8859-5", NULL },
-    {sArabic,	"ISO8859-6", NULL },
-    {sGreek,	"ISO8859-7", NULL },
-    {sHebrew,	"ISO8859-8", NULL },
-    {sLatin5,	"ISO8859-9", NULL },
-    {sLatin6,	"ISO8859-10",NULL },
-    {sKorean,	"ko.euc",	"KSC5601.1987-0:GL"},
-    {sThai,	"TACTIS",	"TIS620.2533-1:GR" },
-    {sThai,	"ISO8859-11",	"TIS620.2533-1:GR" },
-    {sThai,	"TIS620.2533-1", NULL },
-    {sLatin7,	"ISO8859-13",NULL }, /* Baltic Rim */
-#if 0
-    {sLatin8,	"ISO8859-12",	""},/* Celtic, superceded by -14 */
-    {sLatin8	"ISO8859-14",	""},/* Celtic */
-#endif
-    {sUTF8,	"UTF-8",  "ISO10646-1"},
-    /* Non-standard */
-    {sKoi8_r,	"KOI8-R",      NULL },
-    {sKoi8_u,	"KOI8-U",      NULL },
-    {sLatin9,	"ISO8859-15",  NULL },/* a.k.a. Latin-0 */
-    {sArmenian,	"ARMSCII-8",   NULL },
-    {sGeorgian,	"GEORGIAN-ACADEMY", NULL },
-    {sGeorgian,	"GEORGIAN-PS", NULL },
-	/* TODO find better values for the sLatin1 below */
-    {sLatin1,	"IBM-CP1133",  NULL },
-    {sLatin1,	"MULELAO-1",   NULL },
-    {sLatin1,	"VISCII1.1-1", NULL },
-    {sLatin1,	"TCVN-5712",   NULL },
-
+static struct SubstRec SubstTable[] = {
+    {"STRING", "ISO8859-1"},
+    {"TACTIS", "TIS620.2533-1"},
+    {"UTF-8",  "ISO10646-1"}
 };
+#define num_substitute (sizeof SubstTable / sizeof SubstTable[0])
 
-#define NUM_CODESETS sizeof CodesetTable / sizeof CodesetTable[0]
-
 /*
- * Given the encoding name of a locale, returns the corresponding codeset
- * in two formats:
- *   - If cset_set is not NULL, *cset_ret is set to the corresponding
- *     struct CodesetRec *.
- *   - A pointer to the corresponding constant locale_code is returned.
- * If the encoding name is not known, ISO-8859-1 is used as a fallback;
- * thus the returned pointers are never NULL.
+ * Given the name of a charset, returns the pointer to convertors
+ * from UCS char to specified charset char.
+ * This converter is needed for _XimGetCharCode subroutine.
  */
-unsigned long Const *
+XPointer
 #if NeedFunctionPrototypes
 _XimGetLocaleCode (
-    _Xconst char*	encoding_name,
-    XlcCharSet*		charset_ret)
+    _Xconst char*	encoding_name)
 #else
-_XimGetLocaleCode (encoding_name, charset_ret)
+_XimGetLocaleCode (encoding_name)
     _Xconst char*	encoding_name;
-    XlcCharSet*		charset_ret;
 #endif
 {
-    int i;
-    struct CodesetRec* cset = &CodesetTable[0]; /* ISO8859-1 */
-  
-    if (encoding_name) {
-        for (i = 0; i < NUM_CODESETS; i++) {
-            if (strcmp (encoding_name, CodesetTable[i].locale_name) == 0) {
-                cset = &CodesetTable[i];
-                break;
-            }
-        }
-    }
-  
-    if (charset_ret) {
-    	*charset_ret = NULL;
-    	if (cset->charset_name == NULL) {
-            char *name = Xmalloc(strlen(cset->locale_name) + 4);
-            if (name != NULL) {
-                strcpy(name, cset->locale_name);
-                strcat(name, ":GR");
-                *charset_ret = _XlcGetCharSet(name);
-            }
-        } else {
-            *charset_ret = _XlcGetCharSet(cset->charset_name);
-        }
-        if (*charset_ret == NULL)
-            *charset_ret = _XlcGetCharSet("ISO8859-1:GR");
+    XPointer cvt = _Utf8GetConvByName(encoding_name);
+    if (!cvt && encoding_name) {
+       int i;
+       for (i = 0; i < num_substitute; i++)
+           if (!strcmp(encoding_name, SubstTable[i].encoding_name))
+               return _Utf8GetConvByName(SubstTable[i].charset_name);
     }
-    return &(cset->locale_code);
+    return cvt;
 }
 
-#ifndef XK_emdash
-#define XK_emdash 0xaa9
-#endif
-
 /*
  * Returns the locale dependent representation of a keysym.
- * The locale's encoding is passed in form of its locale_code.
+ * The locale's encoding is passed in form of pointer to UCS convertor.
  * The resulting multi-byte sequence is placed starting at buf (a buffer
  * with nbytes bytes, nbytes should be >= 8) and is NUL terminated.
  * Returns the length of the resulting multi-byte sequence, excluding the
  * terminating NUL byte. Return 0 if the keysym is not representable in the
- * locale,
+ * locale
  */
 /*ARGSUSED*/
 int 
 #if NeedFunctionPrototypes
 _XimGetCharCode (
-    unsigned long locale_code,
+    XPointer            ucs_conv,
     KeySym 		keysym,
     unsigned char*	buf,
     int 		nbytes)
 #else
-_XimGetCharCode (locale_code, keysym, buf, nbytes)
-    unsigned long locale_code;
+_XimGetCharCode (ucs_conv, keysym, buf, nbytes)
+    XPointer ucs_conv;
     KeySym keysym;
     unsigned char *buf;
     int nbytes;
 #endif
 {
-    unsigned long kset;
-    int	count,isLatin1;
-
-    if ( keysym == NoSymbol )
-	return 0;
-
-    if (locale_code == sUTF8) {
-        unsigned int ucs4 = keysym_to_ucs4 (keysym);
-
-        if (!ucs4)
-            return 0;
-        if (ucs4 < 0x80)
-            count = 1;
-        else if (ucs4 < 0x800)
-            count = 2;
-        else if (ucs4 < 0x10000)
-            count = 3;
-        else if (ucs4 < 0x200000)
-            count = 4;
-        else if (ucs4 < 0x4000000)
-            count = 5;
-        else if (ucs4 <= 0x7fffffff)
-            count = 6;
-        else {
-            fprintf(stderr, "bug in keysym_to_ucs4: 0x%04x\n", ucs4);
-            return 0;
-        }
-        if (nbytes <= count) {
-            fprintf(stderr, "_XimGetCharCode buffer too small\n");
-            return 0;
-        }
-        switch (count) { /* note: code falls through cases! */
-            case 6:
-                buf[5] = 0x80 | (ucs4 & 0x3f);
-                ucs4 = ucs4 >> 6; ucs4 |= 0x4000000;
-            case 5:
-                buf[4] = 0x80 | (ucs4 & 0x3f);
-                ucs4 = ucs4 >> 6; ucs4 |= 0x200000;
-            case 4:
-                buf[3] = 0x80 | (ucs4 & 0x3f);
-                ucs4 = ucs4 >> 6; ucs4 |= 0x10000;
-            case 3:
-                buf[2] = 0x80 | (ucs4 & 0x3f);
-                ucs4 = ucs4 >> 6; ucs4 |= 0x800;
-            case 2:
-                buf[1] = 0x80 | (ucs4 & 0x3f);
-                ucs4 = ucs4 >> 6; ucs4 |= 0xc0;
-            case 1:
-                buf[0] = ucs4;
-        }
-	buf[count]= '\0';
-        return count;
+    int count = 0;
+    ucstocsConvProc cvt = (ucstocsConvProc) ucs_conv;
+    ucs4_t ucs4;
+
+    if (keysym < 0x80) {
+        buf[0] = (char) keysym;
+        count = 1;
+    } else if (cvt) {
+        ucs4 = KeySymToUcs4(keysym);
+        if (ucs4)
+            count = (*cvt)((XPointer)NULL, buf, ucs4, nbytes);
     }
-
-    kset = locale_code&0xffffff;
 
-    isLatin1 = ((keysym&0xffffff00)==0);
-    count = 0;
-
-    if ((keysym >> 8) == kset) {
-	count = 1;
-	switch (kset) {
-	case sKana:
-	    *buf = (unsigned char)(keysym & 0xff);
-	    if (buf[0] == 0x7e)
-		count = 0;
-	    break;
-	case sCyrillic:
-	    if (locale_code == sKoi8_r)
-		*buf = _Xkoi8_r[keysym & 0x7f];
-	    else if (locale_code == sKoi8_u)
-		*buf = _Xkoi8_u[keysym & 0x7f];
-	    else
-		*buf = _Xcyrillic[keysym & 0x7f];
-	    if (!buf[0])
-		count = 0;
-	    break;
-	case sGreek:
-	    *buf = _Xgreek[keysym & 0x7f];
-	    if (!buf[0])
-		count = 0;
-	    break;
-	default:
-	    *buf = (unsigned char)(keysym & 0xff);
-	    break;
-	}
-    } else if ((locale_code != 0) && (isLatin1) && (keysym & 0x80)) {
-	if (_Xlatin1[keysym & 0x7f] & (1 << kset)) {
-	    /* Most non-latin1 locales use some latin-1 upper half
-	       keysyms as defined by bitpatterns in array latin1.
-	       Enforce it. */
-	    *buf = (unsigned char)(keysym & 0xff);
-	    count = 1;
-	} else {
-	    count= 1;
-	    if ((locale_code == sHebrew) && (keysym == XK_multiply))
-		*buf = (unsigned char)0xaa;
-	    else if ((locale_code == sHebrew) && (keysym == XK_division))
-		*buf = (unsigned char)0xba;
-	    else if ((locale_code == sCyrillic) && (keysym == XK_section))
-		*buf = (unsigned char)0xfd;
-	    else if ((locale_code == sX0201) && (keysym == XK_yen))
-		*buf = (unsigned char)0x5c;
-	    else if (locale_code == sLatin7) {
-	        switch (keysym) {
-	        case XK_acute:	*buf = (unsigned char)0xff; break;
-	        case XK_AE:	*buf = (unsigned char)0xaf; break;
-	        case XK_ae:	*buf = (unsigned char)0xbf; break;
-	        case XK_Ooblique: *buf = (unsigned char)0xa8; break;
-	        case XK_oslash:	*buf = (unsigned char)0xb8; break;
-	        default: count = 0;
-                }
-            }
-	    else count = 0;
-	}
-    } else if (isLatin1) {
-	if ((locale_code == sX0201) &&
-	    ((keysym == XK_backslash) || (keysym == XK_asciitilde)))
-	    count = 0;
-	if ( (keysym&0x80)==0 ) {
-	    *buf = (unsigned char)(keysym&0x7f);
-	    count = 1;
-	}
-    } else if ((keysym >> 8) == sLatin2) {
-	count = 1;
-	if ((keysym & 0x80) && (_Xlatin2[keysym & 0x7f] & (1 << kset)))
-	    *buf = (unsigned char)(keysym & 0xff);
-	else if (locale_code == sLatin5) {
-	    if (keysym == XK_Scedilla)
-		*buf = (unsigned char)0xde;
-	    else if (keysym == XK_scedilla)
-		*buf = (unsigned char)0xfe;
-	    else count = 0;
-	} else if (locale_code == sLatin9) {
-	    if (keysym == XK_Scaron)
-		*buf = (unsigned char)0xa6;
-	    else if (keysym == XK_scaron)
-		*buf = (unsigned char)0xa8;
-	    else if (keysym == XK_Zcaron)
-		*buf = (unsigned char)0xb4;
-	    else if (keysym == XK_zcaron)
-		*buf = (unsigned char)0xb8;
-	    else count = 0;
-	} else if (locale_code == sLatin7) {
-	    switch (keysym) {
-	    case XK_Aogonek:	*buf = (unsigned char)0xc0; break;
-	    case XK_aogonek:	*buf = (unsigned char)0xe0; break;
-	    case XK_Cacute:	*buf = (unsigned char)0xc3; break;
-	    case XK_cacute:	*buf = (unsigned char)0xe3; break;
-	    case XK_Eogonek:	*buf = (unsigned char)0xc6; break;
-	    case XK_eogonek:	*buf = (unsigned char)0xe6; break;
-	    case XK_Zacute:	*buf = (unsigned char)0xca; break;
-	    case XK_zacute:	*buf = (unsigned char)0xea; break;
-	    case XK_Scaron:	*buf = (unsigned char)0xd0; break;
-	    case XK_scaron:	*buf = (unsigned char)0xf0; break;
-	    case XK_Lstroke:	*buf = (unsigned char)0xd9; break;
-	    case XK_lstroke:	*buf = (unsigned char)0xf9; break;
-	    case XK_Sacute:	*buf = (unsigned char)0xda; break;
-	    case XK_sacute:	*buf = (unsigned char)0xfa; break;
-	    case XK_Zabovedot:	*buf = (unsigned char)0xdd; break;
-	    case XK_zabovedot:	*buf = (unsigned char)0xfd; break;
-	    case XK_Zcaron:	*buf = (unsigned char)0xde; break;
-	    case XK_zcaron:	*buf = (unsigned char)0xfe; break;
-            default: count = 0;
-	    }
-	} else count = 0;
-    } else if ((keysym >> 8) == sLatin3) {
-	if (locale_code == sLatin5) {
-	    count = 1;
-	    switch (keysym) {
-	    case XK_Gbreve:	*buf = (unsigned char)0xd0; break;
-	    case XK_gbreve:	*buf = (unsigned char)0xf0; break;
-	    case XK_Scedilla:	*buf = (unsigned char)0xde; break;
-	    case XK_scedilla:	*buf = (unsigned char)0xfe; break;
-	    case XK_Iabovedot:	*buf = (unsigned char)0xdd; break;
-	    case XK_idotless:	*buf = (unsigned char)0xfd; break;
-	    default:  count = 0;
-	    }
-	}
-    } else if ((keysym >> 8) == sLatin4) {
-	if (locale_code == sLatin6) {
-	    count = 1;
-	    switch (keysym) {
-	    case XK_Emacron:	*buf = (unsigned char)0xa2; break;
-	    case XK_Gcedilla:	*buf = (unsigned char)0xa3; break;
-	    case XK_Imacron:	*buf = (unsigned char)0xa4; break;
-	    case XK_Lcedilla:	*buf = (unsigned char) 0xa8; break;
-	    case XK_Dstroke:	*buf = (unsigned char)0xa9; break;
-	    case XK_Scaron:	*buf = (unsigned char)0xaa; break;
-	    case XK_Tslash:	*buf = (unsigned char)0xab; break;
-	    case XK_Zcaron:	*buf = (unsigned char)0xac; break;
-	    case XK_Umacron:	*buf = (unsigned char)0xae; break;
-	    case XK_Utilde:	*buf = (unsigned char)0xd7; break;
-	    case XK_ENG:	*buf = (unsigned char)0xaf; break;
-	    case XK_emacron:	*buf = (unsigned char)0xb2; break;
-	    case XK_gcedilla:	*buf = (unsigned char)0xb3; break;
-	    case XK_imacron:	*buf = (unsigned char)0xb4; break;
-	    case XK_lcedilla:	*buf = (unsigned char) 0xb8; break;
-	    case XK_dstroke:	*buf = (unsigned char)0xb9; break;
-	    case XK_scaron:	*buf = (unsigned char)0xba; break;
-	    case XK_tslash:	*buf = (unsigned char)0xbb; break;
-	    case XK_zcaron:	*buf = (unsigned char)0xbc; break;
-	    case XK_umacron:	*buf = (unsigned char)0xbe; break;
-	    case XK_utilde:	*buf = (unsigned char)0xf7; break;
-	    case XK_eng:	*buf = (unsigned char)0xbf; break;
-	    case XK_kra:	*buf = (unsigned char)0xff; break;
-	    case XK_Itilde:
-	    case XK_Kcedilla: 
-	    case XK_Iogonek:
-	    case XK_Ncedilla:
-	    case XK_Omacron:
-	    case XK_Uogonek:
-	    case XK_itilde:
-	    case XK_kcedilla: 
-	    case XK_iogonek:
-	    case XK_ncedilla:
-	    case XK_omacron:
-	    case XK_uogonek:	*buf = (unsigned char)(keysym & 0xff); break;
-	    default: count = 0;
-	    }
-	} else if (locale_code == sLatin7) {
-	    count = 1;
-	    switch (keysym) {
- 	    case XK_Emacron:	*buf = (unsigned char)0xc7; break;
-	    case XK_emacron:	*buf = (unsigned char)0xe7; break;
-	    case XK_Gcedilla:	*buf = (unsigned char)0xcc; break;
-	    case XK_gcedilla:	*buf = (unsigned char)0xec; break;
-	    case XK_Rcedilla:	*buf = (unsigned char)0xaa; break;
-	    case XK_rcedilla:	*buf = (unsigned char)0xba; break;
-	    case XK_Imacron:	*buf = (unsigned char)0xce; break;
-	    case XK_imacron:	*buf = (unsigned char)0xee; break;
-	    case XK_Lcedilla:	*buf = (unsigned char)0xcf; break;
-	    case XK_lcedilla:	*buf = (unsigned char)0xef; break;
-	    case XK_Umacron:	*buf = (unsigned char)0xdb; break;
-	    case XK_umacron:	*buf = (unsigned char)0xfb; break;
- 	    case XK_Amacron:	*buf = (unsigned char)0xc2; break;
-	    case XK_amacron:	*buf = (unsigned char)0xe2; break;
-	    case XK_Kcedilla:	*buf = (unsigned char)0xcd; break;
-	    case XK_kcedilla:	*buf = (unsigned char)0xed; break;
-	    case XK_Iogonek:	*buf = (unsigned char)0xc1; break;
-	    case XK_iogonek:	*buf = (unsigned char)0xe1; break;
-	    case XK_Eabovedot:	*buf = (unsigned char)0xcb; break;
-	    case XK_eabovedot:	*buf = (unsigned char)0xeb; break;
-	    case XK_Ncedilla:	*buf = (unsigned char)0xd2; break;
-	    case XK_ncedilla:	*buf = (unsigned char)0xf2; break;
-	    case XK_Omacron:	*buf = (unsigned char)0xd4; break;
-	    case XK_omacron:	*buf = (unsigned char)0xf4; break;
-	    case XK_Uogonek:	*buf = (unsigned char)0xd8; break;
-	    case XK_uogonek:	*buf = (unsigned char)0xf8; break;
-	    default: count = 0;
-	    }
-	}
-    } else if (locale_code == sLatin9 && keysym == XK_EuroSign) {
-	count = 1;
-	*buf = (unsigned char)0xa4;
-    } else if ((locale_code == sGreek) &&
-	       ((keysym == XK_leftsinglequotemark) ||
-		(keysym == XK_rightsinglequotemark))) {
-	*buf = (unsigned char)(keysym - (XK_leftsinglequotemark - 0xa1));
-	count = 1;
-    }
+    if (count < 0)
+       	count = 0;
     if (count>nbytes)
-	return nbytes;
+        return nbytes;
     if (count<nbytes)
-	buf[count]= '\0';
+        buf[count]= '\0';
     return count;
 }
 
@@ -858,6 +188,7 @@
     Xim	im = (Xim)ic->core.im;
     XimCommonPrivateRec* private = &im->private.common;
     unsigned char look[BUF_SIZE];
+    ucs4_t ucs4;
 
     /* force a latin-1 lookup for compatibility */
     count = XLOOKUPSTRING(event, (char *)buffer, nbytes, &symbol, status);
@@ -873,29 +204,39 @@
 	    count = 0;
 	}
     } else if ((count == 0) || 
-	       (count == 1 && (symbol > 0x7f && symbol < 0xff00) && 
-	       private->locale_code != 0)) {
-	if ((count = _XimGetCharCode(private->locale_code, symbol,
-                                     look, sizeof look))) {
-
-            XPointer args[1];
-            unsigned char *from = look;
-            unsigned char *to = (unsigned char*) buffer; 
-            int from_len = count;
-            int to_len = nbytes;
-            args[0] = (XPointer) private->keyboard_charset;
-            
-	    if ((count = _XlcConvert(private->cstomb_conv,
-                                (XPointer*) &from, &from_len,
-                                (XPointer*) &to, &to_len,
-				args, 1 )) != 0) {
+	       (count == 1 && (symbol > 0x7f && symbol < 0xff00))) {
+
+        XPointer from = (XPointer) &ucs4;
+        XPointer to =   (XPointer) look;
+        int from_len = 1;
+        int to_len = BUF_SIZE;
+        XPointer args[1];
+        XlcCharSet charset;
+        args[0] = (XPointer) &charset;
+        ucs4 = (ucs4_t) KeySymToUcs4(symbol);
+        if (!ucs4)
+            return 0;
+
+	if (_XlcConvert(private->ucstoc_conv,
+                        &from, &from_len, &to, &to_len,
+                        args, 1 ) != 0) {
+	    count = 0;
+	} else {
+            from = (XPointer) look;
+            to =   (XPointer) buffer;
+            from_len = BUF_SIZE - to_len;
+            to_len = nbytes;
+            args[0] = (XPointer) charset;
+	    if (_XlcConvert(private->cstomb_conv,
+                            &from, &from_len, &to, &to_len,
+			    args, 1 ) != 0) {
 		count = 0;
 	    } else {
                 count = nbytes - to_len;
 	    }
 	}
     }
-    /* 
+    /* FIXME:
      * we should make sure that if the character is a Latin1 character
      * and it's on the right side, and we're in a non-Latin1 locale
      * that this is a valid Latin1 character for this locale.
@@ -918,6 +259,7 @@
     Xim	im = (Xim)ic->core.im;
     XimCommonPrivateRec* private = &im->private.common;
     unsigned char look[BUF_SIZE];
+    ucs4_t ucs4;
 
     /* force a latin-1 lookup for compatibility */
     count = XLOOKUPSTRING(event, (char *)look, nbytes, &symbol, status);
@@ -931,33 +273,103 @@
 	    count = 0;
 	}
     } else if ((count == 0) ||
-	       (count == 1 && (symbol > 0x7f && symbol < 0xff00) &&
-	       private->locale_code != 0)) {
-	if ((count = _XimGetCharCode(private->locale_code, symbol,
-                                     look, sizeof look))) {
-            XPointer args[1];
-            unsigned char *from = look;
-            wchar_t *to = buffer; 
-            int from_len = count;
-            int to_len = nbytes;
-            args[0] = (XPointer) private->keyboard_charset;
-            
-	    if ((count = _XlcConvert(private->cstowc_conv,
-                                (XPointer*) &from, &from_len,
-                                (XPointer*) &to, &to_len,
-				args, 1 )) != 0) {
+	       (count == 1 && (symbol > 0x7f && symbol < 0xff00))) {
+
+        XPointer from = (XPointer) &ucs4;
+        XPointer to =   (XPointer) look;
+        int from_len = 1;
+        int to_len = BUF_SIZE;
+        XPointer args[1];
+        XlcCharSet charset;
+        args[0] = (XPointer) &charset;
+        ucs4 = (ucs4_t) KeySymToUcs4(symbol);
+        if (!ucs4)
+            return 0;
+
+	if (_XlcConvert(private->ucstoc_conv,
+                        &from, &from_len, &to, &to_len,
+                        args, 1 ) != 0) {
+	    count = 0;
+	} else {
+            from = (XPointer) look;
+            to =   (XPointer) buffer;
+            from_len = BUF_SIZE - to_len;
+            to_len = nbytes;
+            args[0] = (XPointer) charset;
+
+	    if (_XlcConvert(private->cstowc_conv,
+                            &from, &from_len, &to, &to_len,
+			    args, 1 ) != 0) {
 		count = 0;
 	    } else {
                 count = nbytes - to_len;
 	    }
 	}
     } else
-	/* 
+	/* FIXME:
 	 * we should make sure that if the character is a Latin1 character
 	 * and it's on the right side, and we're in a non-Latin1 locale
 	 * that this is a valid Latin1 character for this locale.
 	 */
 	buffer[0] = look[0];
 
+    return count;
+}
+
+int
+_XimLookupUTF8Text(ic, event, buffer, nbytes, keysym, status)
+    Xic			 ic;
+    XKeyEvent*		event;
+    char*		buffer;
+    int			nbytes;
+    KeySym*		keysym;
+    XComposeStatus*	status;
+{
+    int count;
+    KeySym symbol;
+    Status	dummy;
+    Xim	im = (Xim)ic->core.im;
+    XimCommonPrivateRec* private = &im->private.common;
+    unsigned char look[BUF_SIZE];
+    ucs4_t ucs4;
+
+    /* force a latin-1 lookup for compatibility */
+    count = XLOOKUPSTRING(event, (char *)buffer, nbytes, &symbol, status);
+    if (keysym != NULL) *keysym = symbol;
+    if ((nbytes == 0) || (symbol == NoSymbol)) return count;
+
+    if (count > 1) {
+	memcpy(look, (char *)buffer,count);
+	look[count] = '\0';
+	if ((count = im->methods->ctstoutf8(ic->core.im,
+				(char*) look, count, 
+				buffer, nbytes, &dummy)) < 0) {
+	    count = 0;
+	}
+    } else if ((count == 0) || 
+	       (count == 1 && (symbol > 0x7f && symbol < 0xff00))) {
+
+        XPointer from = (XPointer) &ucs4;
+        int from_len = 1;
+        XPointer to = (XPointer) buffer;
+        int to_len = nbytes;
+
+        ucs4 = (ucs4_t) KeySymToUcs4(symbol);
+        if (!ucs4)
+            return 0;
+
+	if (_XlcConvert(private->ucstoutf8_conv,
+                        &from, &from_len, &to, &to_len,
+                        NULL, 0) != 0) {
+	    count = 0;
+	} else {
+            count = nbytes - to_len;
+	}
+    }
+    /* FIXME:
+     * we should make sure that if the character is a Latin1 character
+     * and it's on the right side, and we're in a non-Latin1 locale
+     * that this is a valid Latin1 character for this locale.
+     */
     return count;
 }
Index: xc/lib/X11/imDefIc.c
diff -u xc/lib/X11/imDefIc.c:3.6 xc/lib/X11/imDefIc.c:3.7
--- xc/lib/X11/imDefIc.c:3.6	Sun May  9 06:50:31 1999
+++ xc/lib/X11/imDefIc.c	Tue Nov 28 13:49:35 2000
@@ -28,7 +28,7 @@
                                fujiwara@a80.tech.yk.fujitsu.co.jp
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imDefIc.c,v 3.6 1999/05/09 10:50:31 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imDefIc.c,v 3.7 2000/11/28 18:49:35 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "Xlcint.h"
@@ -187,17 +187,17 @@
     buf_size = BUFSIZE;
     ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
 						 _XimCreateICCheck, 0);
-    if(ret_code == XIM_TRUE) {
+    if (ret_code == XIM_TRUE) {
 	preply = reply;
-    } else if(ret_code == XIM_OVERFLOW) {
-	if(len <= 0) {
+    } else if (ret_code == XIM_OVERFLOW) {
+	if (len <= 0) {
 	    preply = reply;
 	} else {
 	    buf_size = (int)len;
 	    preply = (XPointer)Xmalloc(buf_size);
 	    ret_code = _XimRead(im, &len, preply, buf_size,
 						 _XimCreateICCheck, 0);
-	    if(ret_code != XIM_TRUE) {
+	    if (ret_code != XIM_TRUE) {
 		Xfree(preply);
 		ic->private.proto.waitCallback = False;
 		goto ErrorOnReCreateIC;
@@ -211,13 +211,13 @@
     buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
     if (*((CARD8 *)preply) == XIM_ERROR) {
 	_XimProcError(im, 0, (XPointer)&buf_s[3]);
-	if(reply != preply)
+	if (reply != preply)
 	    Xfree(preply);
 	goto ErrorOnReCreateIC;
     }
 
     ic->private.proto.icid = buf_s[1];		/* icid */
-    if(reply != preply)
+    if (reply != preply)
 	Xfree(preply);
 
     _XimRegisterFilter(ic);
@@ -377,17 +377,17 @@
 	buf_size = BUFSIZE;
 	ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
 				 _XimGetICValuesCheck, (XPointer)ic);
-	if(ret_code == XIM_TRUE) {
+	if (ret_code == XIM_TRUE) {
 	    preply = reply;
-	} else if(ret_code == XIM_OVERFLOW) {
-	    if(len <= 0) {
+	} else if (ret_code == XIM_OVERFLOW) {
+	    if (len <= 0) {
 		preply = reply;
 	    } else {
 		buf_size = (int)len;
 		preply = (XPointer)Xmalloc(len);
 		ret_code = _XimRead(im, &len, preply, buf_size,
 				_XimGetICValuesCheck, (XPointer)ic);
-		if(ret_code != XIM_TRUE) {
+		if (ret_code != XIM_TRUE) {
 		    if (preply != reply)
 		        Xfree(preply);
 		    return arg->name;
@@ -399,7 +399,7 @@
 	buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
 	if (*((CARD8 *)preply) == XIM_ERROR) {
 	    _XimProcError(im, 0, (XPointer)&buf_s[3]);
-	    if(reply != preply)
+	    if (reply != preply)
 		Xfree(preply);
 	    return arg->name;
 	}
@@ -784,14 +784,14 @@
     buf_size = BUFSIZE;
     ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
 					_XimSetICValuesCheck, (XPointer)ic);
-    if(ret_code == XIM_TRUE) {
+    if (ret_code == XIM_TRUE) {
 	preply = reply;
-    } else if(ret_code == XIM_OVERFLOW) {
+    } else if (ret_code == XIM_OVERFLOW) {
 	buf_size = (int)len;
 	preply = (XPointer)Xmalloc(buf_size);
 	ret_code = _XimRead(im, &len, preply, buf_size,
 					_XimSetICValuesCheck, (XPointer)ic);
-	if(ret_code != XIM_TRUE) {
+	if (ret_code != XIM_TRUE) {
 	    Xfree(preply);
 	    ic->private.proto.waitCallback = False;
 	    return tmp_name;
@@ -804,11 +804,11 @@
     buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
     if (*((CARD8 *)preply) == XIM_ERROR) {
 	_XimProcError(im, 0, (XPointer)&buf_s[3]);
-	if(reply != preply)
+	if (reply != preply)
 	    Xfree(preply);
 	return tmp_name;
     }
-    if(reply != preply)
+    if (reply != preply)
 	Xfree(preply);
 
     return name;
@@ -928,7 +928,7 @@
 	buf_size = BUFSIZE;
 	ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
 					_XimDestroyICCheck, (XPointer)ic);
-	if(ret_code == XIM_OVERFLOW) {
+	if (ret_code == XIM_OVERFLOW) {
 	    buf_size = len;
 	    preply = (XPointer)Xmalloc(buf_size);
 	    (void)_XimRead(im, &len, preply, buf_size,
@@ -1069,59 +1069,10 @@
     return False;
 }
 
-Private char *
-_XimCommitedMbString(im, ic, buf)
-    Xim			 im;
-    Xic			 ic;
-    XPointer		 buf;
-{
-    CARD16		*buf_s = (CARD16 *)buf;
-    XimCommitInfo	 info;
-    int			 len;
-    int			 new_len;
-    char		*commit;
-    char		*new_commit = NULL;
-    char		*str;
-    Status		 status;
-
-    len = 0;
-    for (info = ic->private.proto.commit_info; info; info = info->next)
-	len += info->string_len;
-    len += buf_s[0];
-    if( len == 0 )
-	return( NULL );
-
-    if (!(commit = (char *)Xmalloc(len + 1)))
-	goto Error_On_Reset;
-
-    str = commit;
-    for (info = ic->private.proto.commit_info; info; info = info->next) {
-	(void)memcpy(str, info->string, info->string_len);
-	str += info->string_len;
-    }
-    (void)memcpy(str, (char *)&buf_s[1], buf_s[0]);
-    commit[len] = '\0';
-
-    new_len = im->methods->ctstombs((XIM)im, commit, len, NULL, 0, &status);
-    if (status != XLookupNone) {
-	if (!(new_commit = Xmalloc(new_len + 1))) {
-	    Xfree(commit);
-	    goto Error_On_Reset;
-	}
-	(void)im->methods->ctstombs((XIM)im, commit, len,
-						new_commit, new_len, NULL);
-	new_commit[new_len] = '\0';
-    }
-    Xfree(commit);
-
-Error_On_Reset:
-    _XimFreeCommitInfo( ic );
-    return new_commit;
-}
-
 Private char *
-_XimProtoMbReset(xic)
+_XimProtoReset(xic, retfunc)
     XIC		 xic;
+    char *     (*retfunc) (Xim im, Xic ic, XPointer buf);
 {
     Xic		 ic = (Xic)xic;
     Xim	 	 im = (Xim)ic->core.im;
@@ -1153,17 +1104,17 @@
     buf_size = BUFSIZE;
     ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
     					_XimResetICCheck, (XPointer)ic);
-    if(ret_code == XIM_TRUE) {
+    if (ret_code == XIM_TRUE) {
     	preply = reply;
-    } else if(ret_code == XIM_OVERFLOW) {
-    	if(len < 0) {
+    } else if (ret_code == XIM_OVERFLOW) {
+    	if (len < 0) {
     	    preply = reply;
     	} else {
     	    buf_size = len;
     	    preply = (XPointer)Xmalloc(buf_size);
     	    ret_code = _XimRead(im, &len, preply, buf_size,
     					_XimResetICCheck, (XPointer)ic);
-    	    if(ret_code != XIM_TRUE) {
+    	    if (ret_code != XIM_TRUE) {
 		Xfree(preply);
     		ic->private.proto.waitCallback = False;
     		return NULL;
@@ -1177,18 +1128,75 @@
     buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
     if (*((CARD8 *)preply) == XIM_ERROR) {
 	_XimProcError(im, 0, (XPointer)&buf_s[3]);
-    	if(reply != preply)
+    	if (reply != preply)
     	    free(preply);
 	return NULL;
     }
 
-    commit = _XimCommitedMbString(im, ic, (XPointer)&buf_s[2]);
+    commit = retfunc(im, ic, (XPointer)&buf_s[2]);
 
-    if(reply != preply)
+    if (reply != preply)
     	Xfree(preply);
     return commit;
 }
 
+Private char *
+_XimCommitedMbString(im, ic, buf)
+    Xim			 im;
+    Xic			 ic;
+    XPointer		 buf;
+{
+    CARD16		*buf_s = (CARD16 *)buf;
+    XimCommitInfo	 info;
+    int			 len;
+    int			 new_len;
+    char		*commit;
+    char		*new_commit = NULL;
+    char		*str;
+    Status		 status;
+
+    len = 0;
+    for (info = ic->private.proto.commit_info; info; info = info->next)
+	len += info->string_len;
+    len += buf_s[0];
+    if ( len == 0 )
+	return( NULL );
+
+    if (!(commit = (char *)Xmalloc(len + 1)))
+	goto Error_On_Reset;
+
+    str = commit;
+    for (info = ic->private.proto.commit_info; info; info = info->next) {
+	(void)memcpy(str, info->string, info->string_len);
+	str += info->string_len;
+    }
+    (void)memcpy(str, (char *)&buf_s[1], buf_s[0]);
+    commit[len] = '\0';
+
+    new_len = im->methods->ctstombs((XIM)im, commit, len, NULL, 0, &status);
+    if (status != XLookupNone) {
+	if (!(new_commit = Xmalloc(new_len + 1))) {
+	    Xfree(commit);
+	    goto Error_On_Reset;
+	}
+	(void)im->methods->ctstombs((XIM)im, commit, len,
+						new_commit, new_len, NULL);
+	new_commit[new_len] = '\0';
+    }
+    Xfree(commit);
+
+Error_On_Reset:
+    _XimFreeCommitInfo( ic );
+    return new_commit;
+}
+
+Private char *
+_XimProtoMbReset(xic)
+    XIC		 xic;
+{
+    return _XimProtoReset(xic, _XimCommitedMbString);
+}
+
 Private wchar_t *
 _XimCommitedWcString(im, ic, buf)
     Xim		 im;
@@ -1208,7 +1216,7 @@
     for (info = ic->private.proto.commit_info; info; info = info->next)
 	len += info->string_len;
     len += buf_s[0];
-    if( len == 0 )
+    if ( len == 0 )
 	return( (wchar_t *)NULL );
 
     if (!(commit = (char *)Xmalloc(len + 1)))
@@ -1244,69 +1252,65 @@
 _XimProtoWcReset(xic)
     XIC		 xic;
 {
-    Xic		 ic = (Xic)xic;
-    Xim	 	 im = (Xim)ic->core.im;
-    CARD32	 buf32[BUFSIZE/4];
-    CARD8	*buf = (CARD8 *)buf32;
-    CARD16	*buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
-    INT16	 len;
-    CARD32	 reply32[BUFSIZE/4];
-    char	*reply = (char *)reply32;
-    XPointer	 preply;
-    int		 buf_size;
-    int		 ret_code;
-    wchar_t	*commit;
+    return (wchar_t *) _XimProtoReset(xic,
+			(char * (*) (Xim, Xic, XPointer)) _XimCommitedWcString);
+}
 
-    if (!IS_IC_CONNECTED(ic))
-	return (wchar_t *)NULL;
+Private char *
+_XimCommitedUtf8String(im, ic, buf)
+    Xim			 im;
+    Xic			 ic;
+    XPointer		 buf;
+{
+    CARD16		*buf_s = (CARD16 *)buf;
+    XimCommitInfo	 info;
+    int			 len;
+    int			 new_len;
+    char		*commit;
+    char		*new_commit = NULL;
+    char		*str;
+    Status		 status;
 
-    buf_s[0] = im->private.proto.imid;		/* imid */
-    buf_s[1] = ic->private.proto.icid;		/* icid */
+    len = 0;
+    for (info = ic->private.proto.commit_info; info; info = info->next)
+	len += info->string_len;
+    len += buf_s[0];
+    if ( len == 0 )
+	return( NULL );
 
-    len = sizeof(CARD16)			/* sizeof imid */
-	+ sizeof(CARD16);			/* sizeof icid */
+    if (!(commit = (char *)Xmalloc(len + 1)))
+	goto Error_On_Reset;
 
-    _XimSetHeader((XPointer)buf, XIM_RESET_IC, 0, &len);
-    if (!(_XimWrite(im, len, (XPointer)buf)))
-	return NULL;
-    _XimFlush(im);
-    ic->private.proto.waitCallback = True;
-    buf_size = BUFSIZE;
-    ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
-    					_XimResetICCheck, (XPointer)ic);
-    if(ret_code == XIM_TRUE) {
-    	preply = reply;
-    } else if(ret_code == XIM_OVERFLOW) {
-    	if(len <= 0) {
-    	    preply = reply;
-    	} else {
-    	    buf_size = len;
-    	    preply = (XPointer)Xmalloc(buf_size);
-    	    ret_code = _XimRead(im, &len, preply, buf_size,
-    					_XimResetICCheck, (XPointer)ic);
-	    if(ret_code != XIM_TRUE) {
-		Xfree(preply);
-		ic->private.proto.waitCallback = False;
-		return NULL;
-	    }
-    	}
-    } else {
-	ic->private.proto.waitCallback = False;
-	return NULL;
+    str = commit;
+    for (info = ic->private.proto.commit_info; info; info = info->next) {
+	(void)memcpy(str, info->string, info->string_len);
+	str += info->string_len;
     }
-    ic->private.proto.waitCallback = False;
-    buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
-    if (*((CARD8 *)preply) == XIM_ERROR) {
-	_XimProcError(im, 0, (XPointer)&buf_s[3]);
-    	if(reply != preply)
-    	    free(preply);
-	return NULL;
+    (void)memcpy(str, (char *)&buf_s[1], buf_s[0]);
+    commit[len] = '\0';
+
+    new_len = im->methods->ctstoutf8((XIM)im, commit, len, NULL, 0, &status);
+    if (status != XLookupNone) {
+	if (!(new_commit = Xmalloc(new_len + 1))) {
+	    Xfree(commit);
+	    goto Error_On_Reset;
+	}
+	(void)im->methods->ctstoutf8((XIM)im, commit, len,
+						new_commit, new_len, NULL);
+	new_commit[new_len] = '\0';
     }
+    Xfree(commit);
 
-    commit = _XimCommitedWcString(im, ic, (XPointer)&buf_s[2]);
+Error_On_Reset:
+    _XimFreeCommitInfo( ic );
+    return new_commit;
+}
 
-    Xfree(preply);
-    return commit;
+Private char *
+_XimProtoUtf8Reset(xic)
+    XIC		 xic;
+{
+    return _XimProtoReset(xic, _XimCommitedUtf8String);
 }
 
 Private XICMethodsRec ic_methods = {
@@ -1317,8 +1321,10 @@
     _XimProtoGetICValues,	/* get_values */
     _XimProtoMbReset,		/* mb_reset */
     _XimProtoWcReset,		/* wc_reset */
+    _XimProtoUtf8Reset,		/* utf8_reset */
     _XimProtoMbLookupString,	/* mb_lookup_string */
     _XimProtoWcLookupString,	/* wc_lookup_string */
+    _XimProtoUtf8LookupString	/* utf8_lookup_string */
 };
 
 Private Bool
@@ -1357,12 +1363,12 @@
 
     _XimSetICMode(res, num, input_style);
 
-    if(_XimSetICValueData(ic, (XPointer)&ic_values, res, num,
+    if (_XimSetICValueData(ic, (XPointer)&ic_values, res, num,
 					values, XIM_CREATEIC, False)) {
 	return False;
     }
     _XimSetCurrentICValues(ic, &ic_values);
-    if(!_XimSetICDefaults(ic, (XPointer)&ic_values,
+    if (!_XimSetICDefaults(ic, (XPointer)&ic_values,
 					XIM_SETICDEFAULTS, res, num)) {
 	return False;
     }
@@ -1549,17 +1555,17 @@
     buf_size = BUFSIZE;
     ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
 						 _XimCreateICCheck, 0);
-    if(ret_code == XIM_TRUE) {
+    if (ret_code == XIM_TRUE) {
 	preply = reply;
-    } else if(ret_code == XIM_OVERFLOW) {
-	if(len <= 0) {
+    } else if (ret_code == XIM_OVERFLOW) {
+	if (len <= 0) {
 	    preply = reply;
 	} else {
 	    buf_size = (int)len;
 	    preply = (XPointer)Xmalloc(buf_size);
 	    ret_code = _XimRead(im, &len, preply, buf_size,
 						 _XimCreateICCheck, 0);
-	    if(ret_code != XIM_TRUE) {
+	    if (ret_code != XIM_TRUE) {
 		Xfree(preply);
 		ic->private.proto.waitCallback = False;
 		goto ErrorOnCreatingIC;
@@ -1573,14 +1579,14 @@
     buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
     if (*((CARD8 *)preply) == XIM_ERROR) {
 	_XimProcError(im, 0, (XPointer)&buf_s[3]);
-	if(reply != preply)
+	if (reply != preply)
 	    Xfree(preply);
 	goto ErrorOnCreatingIC;
     }
 
     ic->private.proto.icid = buf_s[1];		/* icid */
-    if(reply != preply)
-	    Xfree(preply);
+    if (reply != preply)
+	Xfree(preply);
     MARK_IC_CONNECTED(ic);
     return (XIC)ic;
 
Index: xc/lib/X11/imDefIm.c
diff -u xc/lib/X11/imDefIm.c:1.4 xc/lib/X11/imDefIm.c:1.7
--- xc/lib/X11/imDefIm.c:1.4	Mon Jun 12 22:28:28 2000
+++ xc/lib/X11/imDefIm.c	Mon Dec  4 13:49:22 2000
@@ -31,7 +31,7 @@
                                makoto@sm.sony.co.jp
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imDefIm.c,v 1.4 2000/06/13 02:28:28 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imDefIm.c,v 1.7 2000/12/04 18:49:22 dawes Exp $ */
 
 #include <X11/Xatom.h>
 #define NEED_EVENTS
@@ -1037,6 +1037,10 @@
 	_XlcCloseConverter(im->private.proto.ctow_conv);
 	im->private.proto.ctow_conv = NULL;
     }
+    if (im->private.proto.ctoutf8_conv) {
+	_XlcCloseConverter(im->private.proto.ctoutf8_conv);
+	im->private.proto.ctoutf8_conv = NULL;
+    }
     if (im->private.proto.cstomb_conv) {
 	_XlcCloseConverter(im->private.proto.cstomb_conv);
 	im->private.proto.cstomb_conv = NULL;
@@ -1045,6 +1049,18 @@
 	_XlcCloseConverter(im->private.proto.cstowc_conv);
 	im->private.proto.cstowc_conv = NULL;
     }
+    if (im->private.proto.cstoutf8_conv) {
+	_XlcCloseConverter(im->private.proto.cstoutf8_conv);
+	im->private.proto.cstoutf8_conv = NULL;
+    }
+    if (im->private.proto.ucstoc_conv) {
+	_XlcCloseConverter(im->private.proto.ucstoc_conv);
+	im->private.proto.ucstoc_conv = NULL;
+    }
+    if (im->private.proto.ucstoutf8_conv) {
+	_XlcCloseConverter(im->private.proto.ucstoutf8_conv);
+	im->private.proto.ucstoutf8_conv = NULL;
+    }
 
 #ifdef XIM_CONNECTABLE
     if (!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
@@ -1549,7 +1565,8 @@
     _XimProtoGetIMValues,       /* get_values */
     _XimProtoCreateIC,          /* create_ic */
     _Ximctstombs,		/* ctstombs */
-    _Ximctstowcs		/* ctstowcs */
+    _Ximctstowcs,		/* ctstowcs */
+    _Ximctstoutf8		/* ctstoutf8 */
 };
 
 Private Bool
@@ -1611,6 +1628,7 @@
     int		 len;
     XlcConv	 ctom_conv;
     XlcConv	 ctow_conv;
+    XlcConv	 ctoutf8_conv;
     XlcConv	 conv;
     XimProtoPrivateRec *private = &im->private.proto;
 
@@ -1621,6 +1639,9 @@
 	if (!(ctow_conv = _XlcOpenConverter(lcd,
 				 XlcNCompoundText, lcd, XlcNWideChar)))
 	    return False;
+	if (!(ctoutf8_conv = _XlcOpenConverter(lcd,
+				 XlcNCompoundText, lcd, XlcNUtf8String)))
+	    return False;
     }
 
     if (category == XIM_Encoding_NameCategory) {
@@ -1633,6 +1654,9 @@
 		if (!(ctow_conv = _XlcOpenConverter(lcd,
 				 XlcNCompoundText, lcd, XlcNWideChar)))
 		    return False;
+		if (!(ctoutf8_conv = _XlcOpenConverter(lcd,
+				 XlcNCompoundText, lcd, XlcNUtf8String)))
+		    return False;
 		break;
 	    } else {
 		/*
@@ -1653,6 +1677,8 @@
 
     private->ctom_conv = ctom_conv;
     private->ctow_conv = ctow_conv;
+    private->ctoutf8_conv = ctoutf8_conv;
+
     if (!(conv = _XlcOpenConverter(lcd,	XlcNCharSet, lcd, XlcNMultiByte)))
 	return False;
     private->cstomb_conv = conv;
@@ -1660,9 +1686,19 @@
     if (!(conv = _XlcOpenConverter(lcd,	XlcNCharSet, lcd, XlcNWideChar)))
 	return False;
     private->cstowc_conv = conv;
+
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNCharSet, lcd, XlcNUtf8String)))
+	return False;
+    private->cstoutf8_conv = conv;
+
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNUcsChar, lcd, XlcNChar)))
+	return False;
+    private->ucstoc_conv = conv;
+
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNUcsChar, lcd, XlcNUtf8String)))
+	return False;
+    private->ucstoutf8_conv = conv;
 
-    private->locale_code = * _XimGetLocaleCode(XLC_PUBLIC(lcd,encoding_name),
-                            (XlcCharSet*) &(private->keyboard_charset));
     return True;
 }
 
Index: xc/lib/X11/imDefLkup.c
diff -u xc/lib/X11/imDefLkup.c:3.6 xc/lib/X11/imDefLkup.c:3.7
--- xc/lib/X11/imDefLkup.c:3.6	Sun May  9 06:50:32 1999
+++ xc/lib/X11/imDefLkup.c	Tue Nov 28 13:49:36 2000
@@ -26,7 +26,7 @@
                                fujiwara@a80.tech.yk.fujitsu.co.jp
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imDefLkup.c,v 3.6 1999/05/09 10:50:32 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imDefLkup.c,v 3.7 2000/11/28 18:49:36 dawes Exp $ */
 
 #include <X11/Xatom.h>
 #define  NEED_EVENTS
@@ -827,7 +827,7 @@
     XIMID        imid;
     XICID        icid;
     Xim		 im = (Xim)call_data;
-    Xic		 ic;
+    Xic		 ic = NULL;
 
     if (flag & XIM_IMID_VALID) {
 	imid = buf_s[0];
@@ -902,17 +902,15 @@
 #define MAXINT		(~((unsigned int)1 << ((8 * sizeof(int)) - 1)))
 #endif /* !MAXINT */
 
-Public int
-_Ximctstombs(xim, from, from_len, to, to_len, state)
-    XIM		 xim;
+Private int
+_Ximctsconvert(conv, from, from_len, to, to_len, state)
+    XlcConv	 conv;
     char	*from;
     int		 from_len;
     char	*to;
     int		 to_len;
     Status	*state;
 {
-    Xim		 im = (Xim)xim;
-    XlcConv	 conv = im->private.proto.ctom_conv;
     int		 from_left;
     int		 to_left;
     int		 from_savelen;
@@ -988,6 +986,19 @@
 }
 
 Public int
+_Ximctstombs(xim, from, from_len, to, to_len, state)
+    XIM		 xim;
+    char	*from;
+    int		 from_len;
+    char	*to;
+    int		 to_len;
+    Status	*state;
+{
+    return _Ximctsconvert(((Xim)xim)->private.proto.ctom_conv,
+			  from, from_len, to, to_len, state);
+}
+
+Public int
 _Ximctstowcs(xim, from, from_len, to, to_len, state)
     XIM		 xim;
     char	*from;
@@ -1073,6 +1084,19 @@
 }
 
 Public int
+_Ximctstoutf8(xim, from, from_len, to, to_len, state)
+    XIM		 xim;
+    char	*from;
+    int		 from_len;
+    char	*to;
+    int		 to_len;
+    Status	*state;
+{
+    return _Ximctsconvert(((Xim)xim)->private.proto.ctoutf8_conv,
+			  from, from_len, to, to_len, state);
+}
+
+Public int
 _XimProtoMbLookupString(xic, ev, buffer, bytes, keysym, state)
     XIC			 xic;
     XKeyEvent		*ev;
@@ -1177,6 +1201,68 @@
 
     } else if (ev->type == KeyPress) {
 	ret = _XimLookupWCText(ic, ev, buffer, bytes, keysym, NULL);
+	if (ret > 0) {
+	    if (keysym && *keysym != NoSymbol)
+		*state = XLookupBoth;
+	    else
+		*state = XLookupChars;
+	} else {
+	    if (keysym && *keysym != NoSymbol)
+		*state = XLookupKeySym;
+	    else
+		*state = XLookupNone;
+	}
+    } else {
+	*state = XLookupNone;
+	ret = 0;
+    }
+
+    return ret;
+}
+
+Public int
+_XimProtoUtf8LookupString(xic, ev, buffer, bytes, keysym, state)
+    XIC			 xic;
+    XKeyEvent		*ev;
+    char		*buffer;
+    int			 bytes;
+    KeySym		*keysym;
+    Status		*state;
+{
+    Xic			 ic = (Xic)xic;
+    Xim			 im = (Xim)ic->core.im;
+    int			 ret;
+    Status		 tmp_state;
+    XimCommitInfo	 info;
+
+    if (!IS_SERVER_CONNECTED(im))
+	return 0;
+
+    if (!state)
+	state = &tmp_state;
+
+    if (ev->type == KeyPress && ev->keycode == 0) { /* Filter function */
+	if (!(info = ic->private.proto.commit_info)) {
+	    if (state)
+		*state = XLookupNone;
+	    return 0;
+	}
+
+	ret = im->methods->ctstoutf8((XIM)im, info->string,
+			 	info->string_len, buffer, bytes, state);
+	if (*state == XBufferOverflow)
+	    return 0;
+	if (keysym && (info->keysym && *(info->keysym))) {
+	    *keysym = *(info->keysym);
+	    if (*state == XLookupChars)
+		*state = XLookupBoth;
+	    else
+		*state = XLookupKeySym;
+	}
+	_XimUnregCommitInfo(ic);
+
+    } else if (ev->type == KeyPress) {
+	ret = _XimLookupUTF8Text(ic, ev, buffer, bytes, keysym, NULL);
 	if (ret > 0) {
 	    if (keysym && *keysym != NoSymbol)
 		*state = XLookupBoth;
Index: xc/lib/X11/imKStoUCS.c
diff -u /dev/null xc/lib/X11/imKStoUCS.c:1.1
--- /dev/null	Mon Dec 18 14:23:55 2000
+++ xc/lib/X11/imKStoUCS.c	Tue Nov 28 12:25:08 2000
@@ -0,0 +1,330 @@
+/* $XFree86: xc/lib/X11/imKStoUCS.c,v 1.1 2000/11/28 17:25:08 dawes Exp $ */
+
+#include "Xlibint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+static unsigned short Const keysym_to_unicode_1a1_1ff[] = {
+            0x0104, 0x02d8, 0x0141, 0x0000, 0x013d, 0x015a, 0x0000, /* 0x01a0-0x01a7 */
+    0x0000, 0x0160, 0x015e, 0x0164, 0x0179, 0x0000, 0x017d, 0x017b, /* 0x01a8-0x01af */
+    0x0000, 0x0105, 0x02db, 0x0142, 0x0000, 0x013e, 0x015b, 0x02c7, /* 0x01b0-0x01b7 */
+    0x0000, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, /* 0x01b8-0x01bf */
+    0x0154, 0x0000, 0x0000, 0x0102, 0x0000, 0x0139, 0x0106, 0x0000, /* 0x01c0-0x01c7 */
+    0x010c, 0x0000, 0x0118, 0x0000, 0x011a, 0x0000, 0x0000, 0x010e, /* 0x01c8-0x01cf */
+    0x0110, 0x0143, 0x0147, 0x0000, 0x0000, 0x0150, 0x0000, 0x0000, /* 0x01d0-0x01d7 */
+    0x0158, 0x016e, 0x0000, 0x0170, 0x0000, 0x0000, 0x0162, 0x0000, /* 0x01d8-0x01df */
+    0x0155, 0x0000, 0x0000, 0x0103, 0x0000, 0x013a, 0x0107, 0x0000, /* 0x01e0-0x01e7 */
+    0x010d, 0x0000, 0x0119, 0x0000, 0x011b, 0x0000, 0x0000, 0x010f, /* 0x01e8-0x01ef */
+    0x0111, 0x0144, 0x0148, 0x0000, 0x0000, 0x0151, 0x0000, 0x0000, /* 0x01f0-0x01f7 */
+    0x0159, 0x016f, 0x0000, 0x0171, 0x0000, 0x0000, 0x0163, 0x02d9  /* 0x01f8-0x01ff */
+};
+
+static unsigned short Const keysym_to_unicode_2a1_2fe[] = {
+            0x0126, 0x0000, 0x0000, 0x0000, 0x0000, 0x0124, 0x0000, /* 0x02a0-0x02a7 */
+    0x0000, 0x0130, 0x0000, 0x011e, 0x0134, 0x0000, 0x0000, 0x0000, /* 0x02a8-0x02af */
+    0x0000, 0x0127, 0x0000, 0x0000, 0x0000, 0x0000, 0x0125, 0x0000, /* 0x02b0-0x02b7 */
+    0x0000, 0x0131, 0x0000, 0x011f, 0x0135, 0x0000, 0x0000, 0x0000, /* 0x02b8-0x02bf */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x010a, 0x0108, 0x0000, /* 0x02c0-0x02c7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x02c8-0x02cf */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0120, 0x0000, 0x0000, /* 0x02d0-0x02d7 */
+    0x011c, 0x0000, 0x0000, 0x0000, 0x0000, 0x016c, 0x015c, 0x0000, /* 0x02d8-0x02df */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x010b, 0x0109, 0x0000, /* 0x02e0-0x02e7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x02e8-0x02ef */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0121, 0x0000, 0x0000, /* 0x02f0-0x02f7 */
+    0x011d, 0x0000, 0x0000, 0x0000, 0x0000, 0x016d, 0x015d          /* 0x02f8-0x02ff */
+};
+
+static unsigned short Const keysym_to_unicode_3a2_3fe[] = {
+                    0x0138, 0x0156, 0x0000, 0x0128, 0x013b, 0x0000, /* 0x03a0-0x03a7 */
+    0x0000, 0x0000, 0x0112, 0x0122, 0x0166, 0x0000, 0x0000, 0x0000, /* 0x03a8-0x03af */
+    0x0000, 0x0000, 0x0000, 0x0157, 0x0000, 0x0129, 0x013c, 0x0000, /* 0x03b0-0x03b7 */
+    0x0000, 0x0000, 0x0113, 0x0123, 0x0167, 0x014a, 0x0000, 0x014b, /* 0x03b8-0x03bf */
+    0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x012e, /* 0x03c0-0x03c7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0116, 0x0000, 0x0000, 0x012a, /* 0x03c8-0x03cf */
+    0x0000, 0x0145, 0x014c, 0x0136, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x03d0-0x03d7 */
+    0x0000, 0x0172, 0x0000, 0x0000, 0x0000, 0x0168, 0x016a, 0x0000, /* 0x03d8-0x03df */
+    0x0101, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x012f, /* 0x03e0-0x03e7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0117, 0x0000, 0x0000, 0x012b, /* 0x03e8-0x03ef */
+    0x0000, 0x0146, 0x014d, 0x0137, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x03f0-0x03f7 */
+    0x0000, 0x0173, 0x0000, 0x0000, 0x0000, 0x0169, 0x016b          /* 0x03f8-0x03ff */
+};
+
+static unsigned short Const keysym_to_unicode_4a1_4df[] = {
+            0x3002, 0x3008, 0x3009, 0x3001, 0x30fb, 0x30f2, 0x30a1, /* 0x04a0-0x04a7 */
+    0x30a3, 0x30a5, 0x30a7, 0x30a9, 0x30e3, 0x30e5, 0x30e7, 0x30c3, /* 0x04a8-0x04af */
+    0x30fc, 0x30a2, 0x30a4, 0x30a6, 0x30a8, 0x30aa, 0x30ab, 0x30ad, /* 0x04b0-0x04b7 */
+    0x30af, 0x30b1, 0x30b3, 0x30b5, 0x30b7, 0x30b9, 0x30bb, 0x30bd, /* 0x04b8-0x04bf */
+    0x30bf, 0x30c1, 0x30c4, 0x30c6, 0x30c8, 0x30ca, 0x30cb, 0x30cc, /* 0x04c0-0x04c7 */
+    0x30cd, 0x30ce, 0x30cf, 0x30d2, 0x30d5, 0x30d8, 0x30db, 0x30de, /* 0x04c8-0x04cf */
+    0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e4, 0x30e6, 0x30e8, 0x30e9, /* 0x04d0-0x04d7 */
+    0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ef, 0x30f3, 0x309b, 0x309c  /* 0x04d8-0x04df */
+};
+
+static unsigned short Const keysym_to_unicode_590_5fe[] = {
+    0x06f0, 0x06f1, 0x06f2, 0x06f3, 0x06f4, 0x06f5, 0x06f6, 0x06f7, /* 0x0590-0x0597 */
+    0x06f8, 0x06f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x0598-0x059f */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x066a, 0x0670, 0x0679, /* 0x05a0-0x05a7 */
+	
+    0x067e, 0x0686, 0x0688, 0x0691, 0x060c, 0x0000, 0x06d4, 0x0000, /* 0x05ac-0x05af */
+    0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, /* 0x05b0-0x05b7 */
+    0x0668, 0x0669, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f, /* 0x05b8-0x05bf */
+    0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, /* 0x05c0-0x05c7 */
+    0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f, /* 0x05c8-0x05cf */
+    0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, /* 0x05d0-0x05d7 */
+    0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x05d8-0x05df */
+    0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, /* 0x05e0-0x05e7 */
+    0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, /* 0x05e8-0x05ef */
+    0x0650, 0x0651, 0x0652, 0x0653, 0x0654, 0x0655, 0x0698, 0x06a4, /* 0x05f0-0x05f7 */
+    0x06a9, 0x06af, 0x06ba, 0x06be, 0x06cc, 0x06d2, 0x06c1          /* 0x05f8-0x05fe */
+};
+
+static unsigned short keysym_to_unicode_680_6ff[] = {
+    0x0492, 0x0496, 0x049a, 0x049c, 0x04a2, 0x04ae, 0x04b0, 0x04b2, /* 0x0680-0x0687 */
+    0x04b6, 0x04b8, 0x04ba, 0x0000, 0x04d8, 0x04e2, 0x04e8, 0x04ee, /* 0x0688-0x068f */
+    0x0493, 0x0497, 0x049b, 0x049d, 0x04a3, 0x04af, 0x04b1, 0x04b3, /* 0x0690-0x0697 */
+    0x04b7, 0x04b9, 0x04bb, 0x0000, 0x04d9, 0x04e3, 0x04e9, 0x04ef, /* 0x0698-0x069f */
+    0x0000, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457, /* 0x06a0-0x06a7 */
+    0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0491, 0x045e, 0x045f, /* 0x06a8-0x06af */
+    0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407, /* 0x06b0-0x06b7 */
+    0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x0490, 0x040e, 0x040f, /* 0x06b8-0x06bf */
+    0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, /* 0x06c0-0x06c7 */
+    0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, /* 0x06c8-0x06cf */
+    0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, /* 0x06d0-0x06d7 */
+    0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, /* 0x06d8-0x06df */
+    0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, /* 0x06e0-0x06e7 */
+    0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, /* 0x06e8-0x06ef */
+    0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, /* 0x06f0-0x06f7 */
+    0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a  /* 0x06f8-0x06ff */
+};
+
+static unsigned short Const keysym_to_unicode_7a1_7f9[] = {
+            0x0386, 0x0388, 0x0389, 0x038a, 0x03aa, 0x0000, 0x038c, /* 0x07a0-0x07a7 */
+    0x038e, 0x03ab, 0x0000, 0x038f, 0x0000, 0x0000, 0x0385, 0x2015, /* 0x07a8-0x07af */
+    0x0000, 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03ca, 0x0390, 0x03cc, /* 0x07b0-0x07b7 */
+    0x03cd, 0x03cb, 0x03b0, 0x03ce, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x07b8-0x07bf */
+    0x0000, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, /* 0x07c0-0x07c7 */
+    0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, /* 0x07c8-0x07cf */
+    0x03a0, 0x03a1, 0x03a3, 0x0000, 0x03a4, 0x03a5, 0x03a6, 0x03a7, /* 0x07d0-0x07d7 */
+    0x03a8, 0x03a9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x07d8-0x07df */
+    0x0000, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, /* 0x07e0-0x07e7 */
+    0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, /* 0x07e8-0x07ef */
+    0x03c0, 0x03c1, 0x03c3, 0x03c2, 0x03c4, 0x03c5, 0x03c6, 0x03c7, /* 0x07f0-0x07f7 */
+    0x03c8, 0x03c9                                                  /* 0x07f8-0x07ff */
+};
+
+static unsigned short Const keysym_to_unicode_8a4_8fe[] = {
+                                    0x2320, 0x2321, 0x0000, 0x231c, /* 0x08a0-0x08a7 */
+    0x231d, 0x231e, 0x231f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08a8-0x08af */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08b0-0x08b7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x2264, 0x2260, 0x2265, 0x222b, /* 0x08b8-0x08bf */
+    0x2234, 0x0000, 0x221e, 0x0000, 0x0000, 0x2207, 0x0000, 0x0000, /* 0x08c0-0x08c7 */
+    0x2245, 0x2246, 0x0000, 0x0000, 0x0000, 0x0000, 0x22a2, 0x0000, /* 0x08c8-0x08cf */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x221a, 0x0000, /* 0x08d0-0x08d7 */
+    0x0000, 0x0000, 0x2282, 0x2283, 0x2229, 0x222a, 0x2227, 0x2228, /* 0x08d8-0x08df */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08e0-0x08e7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08e8-0x08ef */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192, 0x0000, /* 0x08f0-0x08f7 */
+    0x0000, 0x0000, 0x0000, 0x2190, 0x2191, 0x2192, 0x2193          /* 0x08f8-0x08ff */
+};
+
+static unsigned short Const keysym_to_unicode_9df_9f8[] = {
+                                                            0x2422, /* 0x09d8-0x09df */
+    0x2666, 0x25a6, 0x2409, 0x240c, 0x240d, 0x240a, 0x0000, 0x0000, /* 0x09e0-0x09e7 */
+    0x240a, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x2500, /* 0x09e8-0x09ef */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x251c, 0x2524, 0x2534, 0x252c, /* 0x09f0-0x09f7 */
+    0x2502                                                          /* 0x09f8-0x09ff */
+};
+
+static unsigned short Const keysym_to_unicode_aa1_afe[] = {
+            0x2003, 0x2002, 0x2004, 0x2005, 0x2007, 0x2008, 0x2009, /* 0x0aa0-0x0aa7 */
+    0x200a, 0x2014, 0x2013, 0x0000, 0x0000, 0x0000, 0x2026, 0x2025, /* 0x0aa8-0x0aaf */
+    0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a, /* 0x0ab0-0x0ab7 */
+    0x2105, 0x0000, 0x0000, 0x2012, 0x2039, 0x2024, 0x203a, 0x0000, /* 0x0ab8-0x0abf */
+    0x0000, 0x0000, 0x0000, 0x215b, 0x215c, 0x215d, 0x215e, 0x0000, /* 0x0ac0-0x0ac7 */
+    0x0000, 0x2122, 0x2120, 0x0000, 0x25c1, 0x25b7, 0x25cb, 0x25ad, /* 0x0ac8-0x0acf */
+    0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x0000, 0x2032, 0x2033, /* 0x0ad0-0x0ad7 */
+    0x0000, 0x271d, 0x0000, 0x220e, 0x25c2, 0x2023, 0x25cf, 0x25ac, /* 0x0ad8-0x0adf */
+    0x25e6, 0x25ab, 0x25ae, 0x25b5, 0x25bf, 0x2606, 0x2022, 0x25aa, /* 0x0ae0-0x0ae7 */
+    0x25b4, 0x25be, 0x261a, 0x261b, 0x2663, 0x2666, 0x2665, 0x0000, /* 0x0ae8-0x0aef */
+    0x2720, 0x2020, 0x2021, 0x2713, 0x2612, 0x266f, 0x266d, 0x2642, /* 0x0af0-0x0af7 */
+    0x2640, 0x2121, 0x2315, 0x2117, 0x2038, 0x201a, 0x201e          /* 0x0af8-0x0aff */
+};
+
+/* none of the APL keysyms match the Unicode characters */
+
+static unsigned short Const keysym_to_unicode_cdf_cfa[] = {
+                                                            0x2017, /* 0x0cd8-0x0cdf */
+    0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7, /* 0x0ce0-0x0ce7 */
+    0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df, /* 0x0ce8-0x0cef */
+    0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7, /* 0x0cf0-0x0cf7 */
+    0x05e8, 0x05e9, 0x05ea                                          /* 0x0cf8-0x0cff */
+};
+
+static unsigned short Const keysym_to_unicode_da1_df9[] = {
+            0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, /* 0x0da0-0x0da7 */
+    0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, /* 0x0da8-0x0daf */
+    0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, /* 0x0db0-0x0db7 */
+    0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, /* 0x0db8-0x0dbf */
+    0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, /* 0x0dc0-0x0dc7 */
+    0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, /* 0x0dc8-0x0dcf */
+    0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, /* 0x0dd0-0x0dd7 */
+    0x0e38, 0x0e39, 0x0e3a, 0x0000, 0x0000, 0x0000, 0x0e3e, 0x0e3f, /* 0x0dd8-0x0ddf */
+    0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, /* 0x0de0-0x0de7 */
+    0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0000, 0x0000, /* 0x0de8-0x0def */
+    0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, /* 0x0df0-0x0df7 */
+    0x0e58, 0x0e59                                                  /* 0x0df8-0x0dff */
+};
+
+static unsigned short Const keysym_to_unicode_ea0_eff[] = {
+    0x0000, 0x1101, 0x1101, 0x11aa, 0x1102, 0x11ac, 0x11ad, 0x1103, /* 0x0ea0-0x0ea7 */
+    0x1104, 0x1105, 0x11b0, 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5, /* 0x0ea8-0x0eaf */
+    0x11b6, 0x1106, 0x1107, 0x1108, 0x11b9, 0x1109, 0x110a, 0x110b, /* 0x0eb0-0x0eb7 */
+    0x110c, 0x110d, 0x110e, 0x110f, 0x1110, 0x1111, 0x1112, 0x1161, /* 0x0eb8-0x0ebf */
+    0x1162, 0x1163, 0x1164, 0x1165, 0x1166, 0x1167, 0x1168, 0x1169, /* 0x0ec0-0x0ec7 */
+    0x116a, 0x116b, 0x116c, 0x116d, 0x116e, 0x116f, 0x1170, 0x1171, /* 0x0ec8-0x0ecf */
+    0x1172, 0x1173, 0x1174, 0x1175, 0x11a8, 0x11a9, 0x11aa, 0x11ab, /* 0x0ed0-0x0ed7 */
+    0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3, /* 0x0ed8-0x0edf */
+    0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba, 0x11bb, /* 0x0ee0-0x0ee7 */
+    0x11bc, 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x0000, /* 0x0ee8-0x0eef */
+    0x0000, 0x0000, 0x1140, 0x0000, 0x0000, 0x1159, 0x119e, 0x0000, /* 0x0ef0-0x0ef7 */
+    0x11eb, 0x0000, 0x11f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x20a9, /* 0x0ef8-0x0eff */
+};
+
+static unsigned short keysym_to_unicode_12a1_12fe[] = {
+            0x1e02, 0x1e03, 0x0000, 0x0000, 0x0000, 0x1e0a, 0x0000, /* 0x12a0-0x12a7 */
+    0x1e80, 0x0000, 0x1e82, 0x1e0b, 0x1ef2, 0x0000, 0x0000, 0x0000, /* 0x12a8-0x12af */
+    0x1e1e, 0x1e1f, 0x0000, 0x0000, 0x1e40, 0x1e41, 0x0000, 0x1e56, /* 0x12b0-0x12b7 */
+    0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61, /* 0x12b8-0x12bf */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x12c0-0x12c7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x12c8-0x12cf */
+    0x0174, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1e6a, /* 0x12d0-0x12d7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0176, 0x0000, /* 0x12d8-0x12df */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x12e0-0x12e7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x12e8-0x12ef */
+    0x0175, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1e6b, /* 0x12f0-0x12f7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0177          /* 0x12f0-0x12ff */
+};
+		
+static unsigned short Const keysym_to_unicode_13bc_13be[] = {
+                                    0x0152, 0x0153, 0x0178          /* 0x13b8-0x13bf */
+};
+
+static unsigned short keysym_to_unicode_14a1_14ff[] = {
+            0x2741, 0x00a7, 0x0589, 0x0029, 0x0028, 0x00bb, 0x00ab, /* 0x14a0-0x14a7 */
+    0x2014, 0x002e, 0x055d, 0x002c, 0x2013, 0x058a, 0x2026, 0x055c, /* 0x14a8-0x14af */
+    0x055b, 0x055e, 0x0531, 0x0561, 0x0532, 0x0562, 0x0533, 0x0563, /* 0x14b0-0x14b7 */
+    0x0534, 0x0564, 0x0535, 0x0565, 0x0536, 0x0566, 0x0537, 0x0567, /* 0x14b8-0x14bf */
+    0x0538, 0x0568, 0x0539, 0x0569, 0x053a, 0x056a, 0x053b, 0x056b, /* 0x14c0-0x14c7 */
+    0x053c, 0x056c, 0x053d, 0x056d, 0x053e, 0x056e, 0x053f, 0x056f, /* 0x14c8-0x14cf */
+    0x0540, 0x0570, 0x0541, 0x0571, 0x0542, 0x0572, 0x0543, 0x0573, /* 0x14d0-0x14d7 */
+    0x0544, 0x0574, 0x0545, 0x0575, 0x0546, 0x0576, 0x0547, 0x0577, /* 0x14d8-0x14df */
+    0x0548, 0x0578, 0x0549, 0x0579, 0x054a, 0x057a, 0x054b, 0x057b, /* 0x14e0-0x14e7 */
+    0x054c, 0x057c, 0x054d, 0x057d, 0x054e, 0x057e, 0x054f, 0x057f, /* 0x14e8-0x14ef */
+    0x0550, 0x0580, 0x0551, 0x0581, 0x0552, 0x0582, 0x0553, 0x0583, /* 0x14f0-0x14f7 */
+    0x0554, 0x0584, 0x0555, 0x0585, 0x0556, 0x0586, 0x2019, 0x0027, /* 0x14f8-0x14ff */
+};
+
+static unsigned short keysym_to_unicode_15d0_15f6[] = {
+    0x10d0, 0x10d1, 0x10d2, 0x10d3, 0x10d4, 0x10d5, 0x10d6, 0x10d7, /* 0x15d0-0x15d7 */
+    0x10d8, 0x10d9, 0x10da, 0x10db, 0x10dc, 0x10dd, 0x10de, 0x10df, /* 0x15d8-0x15df */
+    0x10e0, 0x10e1, 0x10e2, 0x10e3, 0x10e4, 0x10e5, 0x10e6, 0x10e7, /* 0x15e0-0x15e7 */
+    0x10e8, 0x10e9, 0x10ea, 0x10eb, 0x10ec, 0x10ed, 0x10ee, 0x10ef, /* 0x15e8-0x15ef */
+    0x10f0, 0x10f1, 0x10f2, 0x10f3, 0x10f4, 0x10f5, 0x10f6          /* 0x15f0-0x15f7 */
+};
+
+static unsigned short keysym_to_unicode_16a0_16f6[] = {
+    0x0000, 0x0000, 0xf0a2, 0x1e8a, 0x0000, 0xf0a5, 0x012c, 0xf0a7, /* 0x16a0-0x16a7 */
+    0xf0a8, 0x01b5, 0x01e6, 0x0000, 0x0000, 0x0000, 0x0000, 0x019f, /* 0x16a8-0x16af */
+    0x0000, 0x017e, 0xf0b2, 0x1e8b, 0x01d1, 0xf0b5, 0x012d, 0xf0b7, /* 0x16b0-0x16b7 */
+    0xf0b8, 0x01b6, 0x01e7, 0x01d2, 0x0000, 0x0000, 0x0000, 0x0275, /* 0x16b8-0x16bf */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x018f, 0x0000, /* 0x16c0-0x16c7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16c8-0x16cf */
+    0x0000, 0x1e36, 0xf0d2, 0xf0d3, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16d0-0x16d7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16d8-0x16df */
+    0x0000, 0x1e37, 0xf0e2, 0xf0e3, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16e0-0x16e7 */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x16e8-0x16ef */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0259          /* 0x16f0-0x16f6 */
+};
+
+static unsigned short Const keysym_to_unicode_1e9f_1eff[] = {
+                                                            0x0303,
+    0x1ea0, 0x1ea1, 0x1ea2, 0x1ea3, 0x1ea4, 0x1ea5, 0x1ea6, 0x1ea7, /* 0x1ea0-0x1ea7 */
+    0x1ea8, 0x1ea9, 0x1eaa, 0x1eab, 0x1eac, 0x1ead, 0x1eae, 0x1eaf, /* 0x1ea8-0x1eaf */
+    0x1eb0, 0x1eb1, 0x1eb2, 0x1eb3, 0x1eb4, 0x1eb5, 0x1eb6, 0x1eb7, /* 0x1eb0-0x1eb7 */
+    0x1eb8, 0x1eb9, 0x1eba, 0x1ebb, 0x1ebc, 0x1ebd, 0x1ebe, 0x1ebf, /* 0x1eb8-0x1ebf */
+    0x1ec0, 0x1ec1, 0x1ec2, 0x1ec3, 0x1ec4, 0x1ec5, 0x1ec6, 0x1ec7, /* 0x1ec0-0x1ec7 */
+    0x1ec8, 0x1ec9, 0x1eca, 0x1ecb, 0x1ecc, 0x1ecd, 0x1ece, 0x1ecf, /* 0x1ec8-0x1ecf */
+    0x1ed0, 0x1ed1, 0x1ed2, 0x1ed3, 0x1ed4, 0x1ed5, 0x1ed6, 0x1ed7, /* 0x1ed0-0x1ed7 */
+    0x1ed8, 0x1ed9, 0x1eda, 0x1edb, 0x1edc, 0x1edd, 0x1ede, 0x1edf, /* 0x1ed8-0x1edf */
+    0x1ee0, 0x1ee1, 0x1ee2, 0x1ee3, 0x1ee4, 0x1ee5, 0x1ee6, 0x1ee7, /* 0x1ee0-0x1ee7 */
+    0x1ee8, 0x1ee9, 0x1eea, 0x1eeb, 0x1eec, 0x1eed, 0x1eee, 0x1eef, /* 0x1ee8-0x1eef */
+    0x1ef0, 0x1ef1, 0x0300, 0x0301, 0x1ef4, 0x1ef5, 0x1ef6, 0x1ef7, /* 0x1ef0-0x1ef7 */
+    0x1ef8, 0x1ef9, 0x01a0, 0x01a1, 0x01af, 0x01b0, 0x0309, 0x0323  /* 0x1ef8-0x1eff */
+};
+
+static unsigned short Const keysym_to_unicode_20a0_20ac[] = {
+    0x20a0, 0x20a1, 0x20a2, 0x20a3, 0x20a4, 0x20a5, 0x20a6, 0x20a7, /* 0x20a0-0x20a7 */
+    0x20a8, 0x20a9, 0x20aa, 0x20ab, 0x20ac                          /* 0x20a8-0x20af */
+};
+
+unsigned int
+#if NeedFunctionPrototypes
+KeySymToUcs4(KeySym keysym)
+#else
+KeySymToUcs4(keysym)
+    KeySym keysym;
+#endif
+{
+    /* 'Unicode keysym' */
+    if ((keysym & 0xff000000) == 0x01000000)
+        return (keysym & 0x00ffffff);
+
+    if (keysym > 0 && keysym < 0x100)
+	return keysym;
+    else if (keysym > 0x1a0 && keysym < 0x200)
+	return keysym_to_unicode_1a1_1ff[keysym - 0x1a1];
+    else if (keysym > 0x2a0 && keysym < 0x2ff)
+	return keysym_to_unicode_2a1_2fe[keysym - 0x2a1];
+    else if (keysym > 0x3a1 && keysym < 0x3ff)
+	return keysym_to_unicode_3a2_3fe[keysym - 0x3a2];
+    else if (keysym > 0x4a0 && keysym < 0x4e0)
+	return keysym_to_unicode_4a1_4df[keysym - 0x4a1];
+    else if (keysym > 0x589 && keysym < 0x5ff)
+	return keysym_to_unicode_590_5fe[keysym - 0x590];
+    else if (keysym > 0x67f && keysym < 0x700)
+	return keysym_to_unicode_680_6ff[keysym - 0x680];
+    else if (keysym > 0x7a0 && keysym < 0x7fa)
+	return keysym_to_unicode_7a1_7f9[keysym - 0x7a1];
+    else if (keysym > 0x8a3 && keysym < 0x8ff)
+	return keysym_to_unicode_8a4_8fe[keysym - 0x8a4];
+    else if (keysym > 0x9de && keysym < 0x9f9)
+	return keysym_to_unicode_9df_9f8[keysym - 0x9df];
+    else if (keysym > 0xaa0 && keysym < 0xaff)
+	return keysym_to_unicode_aa1_afe[keysym - 0xaa1];
+    else if (keysym > 0xcde && keysym < 0xcfb)
+	return keysym_to_unicode_cdf_cfa[keysym - 0xcdf];
+    else if (keysym > 0xda0 && keysym < 0xdfa)
+	return keysym_to_unicode_da1_df9[keysym - 0xda1];
+    else if (keysym > 0xe9f && keysym < 0xf00)
+	return keysym_to_unicode_ea0_eff[keysym - 0xea0];
+    else if (keysym > 0x12a0 && keysym < 0x12ff)
+	return keysym_to_unicode_12a1_12fe[keysym - 0x12a1];
+    else if (keysym > 0x13bb && keysym < 0x13bf)
+	return keysym_to_unicode_13bc_13be[keysym - 0x13bc];
+    else if (keysym > 0x14a0 && keysym < 0x1500)
+        return keysym_to_unicode_14a1_14ff[keysym - 0x14a1];
+    else if (keysym > 0x15cf && keysym < 0x15f7)
+	return keysym_to_unicode_15d0_15f6[keysym - 0x15d0];
+    else if (keysym > 0x169f && keysym < 0x16f7)
+	return keysym_to_unicode_16a0_16f6[keysym - 0x16a0];
+    else if (keysym > 0x1e9e && keysym < 0x1f00)
+	return keysym_to_unicode_1e9f_1eff[keysym - 0x1ea0];
+    else if (keysym > 0x209f && keysym < 0x20ad)
+	return keysym_to_unicode_20a0_20ac[keysym - 0x20a0];
+    else 
+	return 0;
+}
Index: xc/lib/X11/imLcIc.c
diff -u xc/lib/X11/imLcIc.c:1.2 xc/lib/X11/imLcIc.c:1.3
--- xc/lib/X11/imLcIc.c:1.2	Fri Feb 18 11:23:11 2000
+++ xc/lib/X11/imLcIc.c	Tue Nov 28 13:49:36 2000
@@ -26,7 +26,7 @@
                                fujiwara@a80.tech.yk.fujitsu.co.jp
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imLcIc.c,v 1.2 2000/02/18 16:23:11 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imLcIc.c,v 1.3 2000/11/28 18:49:36 dawes Exp $ */
 
 #include <stdio.h>
 #include <X11/Xlib.h>
@@ -89,24 +89,29 @@
     return;
 }
 
-Private char *
-_XimLocalMbReset(xic)
+Private void
+_XimLocalReset(xic)
     XIC	 xic;
 {
     Xic	 ic = (Xic)xic;
     ic->private.local.composed = (DefTree *)NULL;
     ic->private.local.context  = ((Xim)ic->core.im)->private.local.top;
-    return((char *)NULL);
+}
+
+Private char *
+_XimLocalMbReset(xic)
+    XIC	 xic;
+{
+    _XimLocalReset(xic);
+    return (char *)NULL;
 }
 
 Private wchar_t *
 _XimLocalWcReset(xic)
     XIC	 xic;
 {
-    Xic	 ic = (Xic)xic;
-    ic->private.local.composed = (DefTree *)NULL;
-    ic->private.local.context  = ((Xim)ic->core.im)->private.local.top;
-    return((wchar_t *)NULL);
+    _XimLocalReset(xic);
+    return (wchar_t *)NULL;
 }
 
 Private XICMethodsRec Local_ic_methods = {
@@ -117,8 +122,10 @@
     _XimLocalGetICValues,	/* get_values */
     _XimLocalMbReset,		/* mb_reset */
     _XimLocalWcReset,		/* wc_reset */
+    _XimLocalMbReset,		/* utf8_reset */
     _XimLocalMbLookupString,	/* mb_lookup_string */
     _XimLocalWcLookupString,	/* wc_lookup_string */
+    _XimLocalUtf8LookupString	/* utf8_lookup_string */
 };
 
 Public XIC
Index: xc/lib/X11/imLcIm.c
diff -u xc/lib/X11/imLcIm.c:1.5 xc/lib/X11/imLcIm.c:1.8
--- xc/lib/X11/imLcIm.c:1.5	Wed Jun 14 14:20:33 2000
+++ xc/lib/X11/imLcIm.c	Mon Dec  4 13:49:23 2000
@@ -32,7 +32,7 @@
 	                          frankyling@hgrd01.enet.dec.com
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imLcIm.c,v 1.5 2000/06/14 18:20:33 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imLcIm.c,v 1.8 2000/12/04 18:49:23 dawes Exp $ */
 
 #include <stdio.h>
 /*
@@ -82,6 +82,7 @@
     if (top->next) XimFreeDefaultTree(top->next);
     if (top->mb) Xfree(top->mb);
     if (top->wc) Xfree(top->wc);
+    if (top->utf8) Xfree(top->utf8);
     Xfree(top);
 }
 
@@ -130,6 +131,10 @@
 	_XlcCloseConverter(im->private.local.ctow_conv);
 	im->private.local.ctow_conv = NULL;
     }
+    if (im->private.local.ctoutf8_conv) {
+	_XlcCloseConverter(im->private.local.ctoutf8_conv);
+	im->private.local.ctoutf8_conv = NULL;
+    }
     if (im->private.local.cstomb_conv) {
 	_XlcCloseConverter(im->private.local.cstomb_conv);
         im->private.local.cstomb_conv = NULL;
@@ -138,6 +143,18 @@
 	_XlcCloseConverter(im->private.local.cstowc_conv);
 	im->private.local.cstowc_conv = NULL;
     }
+    if (im->private.local.cstoutf8_conv) {
+	_XlcCloseConverter(im->private.local.cstoutf8_conv);
+	im->private.local.cstoutf8_conv = NULL;
+    }
+    if (im->private.local.ucstoc_conv) {
+	_XlcCloseConverter(im->private.local.ucstoc_conv);
+	im->private.local.ucstoc_conv = NULL;
+    }
+    if (im->private.local.ucstoutf8_conv) {
+	_XlcCloseConverter(im->private.local.ucstoutf8_conv);
+	im->private.local.ucstoutf8_conv = NULL;
+    }
     return;
 }
 
@@ -214,7 +231,8 @@
     _XimLocalGetIMValues,       /* get_values */
     _XimLocalCreateIC,          /* create_ic */
     _XimLcctstombs,		/* ctstombs */
-    _XimLcctstowcs		/* ctstowcs */
+    _XimLcctstowcs,		/* ctstowcs */
+    _XimLcctstoutf8		/* ctstoutf8 */
 };
 
 Public Bool
@@ -255,6 +273,10 @@
 	goto Open_Error;
     private->ctow_conv = conv;
 
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNCompoundText, lcd, XlcNUtf8String)))
+	goto Open_Error;
+    private->ctoutf8_conv = conv;
+
     if (!(conv = _XlcOpenConverter(lcd,	XlcNCharSet, lcd, XlcNMultiByte)))
 	goto Open_Error;
     private->cstomb_conv = conv;
@@ -263,8 +285,17 @@
 	goto Open_Error;
     private->cstowc_conv = conv;
 
-    private->locale_code = * _XimGetLocaleCode(XLC_PUBLIC(lcd,encoding_name),
-                            (XlcCharSet*) &(private->keyboard_charset));
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNCharSet, lcd, XlcNUtf8String)))
+	goto Open_Error;
+    private->cstoutf8_conv = conv;
+
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNUcsChar, lcd, XlcNChar)))
+	goto Open_Error;
+    private->ucstoc_conv = conv;
+
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNUcsChar, lcd, XlcNUtf8String)))
+	goto Open_Error;
+    private->ucstoutf8_conv = conv;
 
     im->methods = &Xim_im_local_methods;
     private->current_ic = (XIC)NULL;
Index: xc/lib/X11/imLcLkup.c
diff -u xc/lib/X11/imLcLkup.c:3.2 xc/lib/X11/imLcLkup.c:3.4
--- xc/lib/X11/imLcLkup.c:3.2	Sun May  9 06:50:36 1999
+++ xc/lib/X11/imLcLkup.c	Mon Dec  4 13:49:24 2000
@@ -29,7 +29,7 @@
                                fujiwara@a80.tech.yk.fujitsu.co.jp
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imLcLkup.c,v 3.2 1999/05/09 10:50:36 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imLcLkup.c,v 3.4 2000/12/04 18:49:24 dawes Exp $ */
 
 #include <stdio.h>
 #include <X11/Xatom.h>
@@ -57,7 +57,7 @@
 	if(status) *status = XLookupNone;
 	return(0);
     }
-    if(ev->keycode == 0) { /* Composed Event */
+    if(ev->keycode == 0 && ic->private.local.composed != NULL) { /* Composed Event */
 	ret = strlen(ic->private.local.composed->mb);
 	if(ret > bytes) {
 	    if(status) *status = XBufferOverflow;
@@ -156,21 +156,76 @@
     return (ret);
 }
 
+Public int
+_XimLocalUtf8LookupString(xic, ev, buffer, bytes, keysym, status)
+    XIC		  xic;
+    XKeyEvent	 *ev;
+    char	 *buffer;
+    int		  bytes;
+    KeySym	 *keysym;
+    Status	 *status;
+{
+    Xic		 ic = (Xic)xic;
+    int		 ret;
+
+    if(ev->type != KeyPress) {
+	if(status) *status = XLookupNone;
+	return(0);
+    }
+    if(ev->keycode == 0) { /* Composed Event */
+	ret = strlen(ic->private.local.composed->utf8);
+	if(ret > bytes) {
+	    if(status) *status = XBufferOverflow;
+	    return (ret);
+	}
+	memcpy(buffer, ic->private.local.composed->utf8, ret);
+	if(keysym) *keysym = ic->private.local.composed->ks;
+	if (ret > 0) {
+	    if(keysym && *keysym != NoSymbol) {
+		if(status) *status = XLookupBoth;
+	    } else {
+		if(status) *status = XLookupChars;
+	    }
+	} else {
+	    if(keysym && *keysym != NoSymbol) {
+		if(status) *status = XLookupKeySym;
+	    } else {
+		if(status) *status = XLookupNone;
+	    }
+	}
+	return (ret);
+    } else { /* Throughed Event */
+	ret = _XimLookupUTF8Text(ic, ev, buffer, bytes, keysym, NULL);
+	if(ret > 0) {
+	    if(keysym && *keysym != NoSymbol) {
+		if(status) *status = XLookupBoth;
+	    } else {
+		if(status) *status = XLookupChars;
+	    }
+	} else {
+	    if(keysym && *keysym != NoSymbol) {
+		if(status) *status = XLookupKeySym;
+	    } else {
+		if(status) *status = XLookupNone;
+	    }
+	}
+    }
+    return (ret);
+}
+
 #ifndef MAXINT
 #define MAXINT		(~((unsigned int)1 << ((8 * sizeof(int)) - 1)))
 #endif /* !MAXINT */
 
-Public int
-_XimLcctstombs(xim, from, from_len, to, to_len, state)
-    XIM		 xim;
+Private int
+_XimLcctsconvert(conv, from, from_len, to, to_len, state)
+    XlcConv	 conv;
     char	*from;
     int		 from_len;
     char	*to;
     int		 to_len;
     Status	*state;
 {
-    Xim		 im = (Xim)xim;
-    XlcConv	 conv = im->private.local.ctom_conv;
     int		 from_left;
     int		 to_left;
     int		 from_savelen;
@@ -246,6 +301,19 @@
 }
 
 Public int
+_XimLcctstombs(xim, from, from_len, to, to_len, state)
+    XIM		 xim;
+    char	*from;
+    int		 from_len;
+    char	*to;
+    int		 to_len;
+    Status	*state;
+{
+    return _XimLcctsconvert(((Xim)xim)->private.local.ctom_conv,
+			    from, from_len, to, to_len, state);
+}
+
+Public int
 _XimLcctstowcs(xim, from, from_len, to, to_len, state)
     XIM		 xim;
     char	*from;
@@ -328,4 +396,17 @@
 	}
     }
     return to_cnvlen;
+}
+
+Public int
+_XimLcctstoutf8(xim, from, from_len, to, to_len, state)
+    XIM		 xim;
+    char	*from;
+    int		 from_len;
+    char	*to;
+    int		 to_len;
+    Status	*state;
+{
+    return _XimLcctsconvert(((Xim)xim)->private.local.ctoutf8_conv,
+			    from, from_len, to, to_len, state);
 }
Index: xc/lib/X11/imLcPrs.c
diff -u xc/lib/X11/imLcPrs.c:1.4 xc/lib/X11/imLcPrs.c:1.5
--- xc/lib/X11/imLcPrs.c:1.4	Sun Oct  4 07:48:07 1998
+++ xc/lib/X11/imLcPrs.c	Tue Nov 28 13:49:38 2000
@@ -30,7 +30,7 @@
 
 ******************************************************************/
 
-/* $XFree86: xc/lib/X11/imLcPrs.c,v 1.4 1998/10/04 11:48:07 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imLcPrs.c,v 1.5 2000/11/28 18:49:38 dawes Exp $ */
 
 #include <X11/Xlib.h>
 #include <X11/Xmd.h>
@@ -49,6 +49,14 @@
 #endif
 );
 
+extern int _Xmbstoutf8(
+#if NeedFunctionPrototypes
+    char	*ustr,
+    const char	*str,
+    int		len
+#endif
+);
+
 /*
  *	Parsing File Format:
  *
@@ -295,6 +303,7 @@
 
 #define AllMask (ShiftMask | LockMask | ControlMask | Mod1Mask) 
 #define LOCAL_WC_BUFSIZE 128
+#define LOCAL_UTF8_BUFSIZE 256
 #define SEQUENCE_MAX	10
 
 static int
@@ -315,6 +324,7 @@
     int l;
     int lastch = 0;
     wchar_t local_wc_buf[LOCAL_WC_BUFSIZE], *rhs_string_wc;
+    char local_utf8_buf[LOCAL_UTF8_BUFSIZE], *rhs_string_utf8;
 
     struct DefBuffer {
 	unsigned modifier_mask;
@@ -445,6 +455,17 @@
     }
     memcpy((char *)rhs_string_wc, (char *)local_wc_buf, (l + 1) * sizeof(wchar_t) );
 
+    l = _Xmbstoutf8(local_utf8_buf, rhs_string_mb, LOCAL_UTF8_BUFSIZE - 1);
+    if (l == LOCAL_UTF8_BUFSIZE - 1) {
+	local_wc_buf[l] = '\0';
+    }
+    if( (rhs_string_utf8 = (char *)Xmalloc(l + 1)) == NULL ) {
+	Xfree( rhs_string_wc );
+	Xfree( rhs_string_mb );
+	return( 0 );
+    }
+    memcpy(rhs_string_utf8, local_utf8_buf, l + 1);
+
     for (i = 0; i < n; i++) {
 	for (p = *top; p; p = p->next) {
 	    if (buf[i].keysym        == p->keysym &&
@@ -467,6 +488,7 @@
 	    p->next          = *top;
 	    p->mb            = NULL;
 	    p->wc            = NULL;
+	    p->utf8          = NULL;
 	    p->ks            = NoSymbol;
 	    *top = p;
 	    top = &p->succession;
@@ -479,6 +501,9 @@
     if( p->wc != NULL )
 	Xfree( p->wc );
     p->wc = rhs_string_wc;
+    if( p->utf8 != NULL )
+	Xfree( p->utf8 );
+    p->utf8 = rhs_string_utf8;
     p->ks = rhs_keysym;
     return(n);
 error:
Index: xc/lib/X11/imRm.c
diff -u xc/lib/X11/imRm.c:3.8 xc/lib/X11/imRm.c:3.9
--- xc/lib/X11/imRm.c:3.8	Sat Jan 29 13:58:15 2000
+++ xc/lib/X11/imRm.c	Tue Sep 26 11:56:51 2000
@@ -30,7 +30,7 @@
 			       makoto@sm.sony.co.jp
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imRm.c,v 3.8 2000/01/29 18:58:15 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imRm.c,v 3.9 2000/09/26 15:56:51 tsi Exp $ */
 
 #include <stdio.h>
 #include <X11/Xlib.h>
@@ -953,7 +953,7 @@
     int			*out;
 
     out = (int *)((char *)top + info->offset);
-    *out = (int)val;
+    *out = (long)val;
     return True;
 }
 
Index: xc/lib/X11/imRmAttr.c
diff -u xc/lib/X11/imRmAttr.c:1.3 xc/lib/X11/imRmAttr.c:1.4
--- xc/lib/X11/imRmAttr.c:1.3	Sun May  9 06:50:37 1999
+++ xc/lib/X11/imRmAttr.c	Tue Sep 26 11:56:52 2000
@@ -26,7 +26,7 @@
                                fujiwara@a80.tech.yk.fujitsu.co.jp
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imRmAttr.c,v 1.3 1999/05/09 10:50:37 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imRmAttr.c,v 1.4 2000/09/26 15:56:52 tsi Exp $ */
 
 #include "Xlibint.h"
 #include "Xlcint.h"
@@ -629,7 +629,7 @@
 	    return False;
 	}
 
-	*((CARD32 *)buf) = (CARD32)value;
+	*((CARD32 *)buf) = (CARD32)(long)value;
 	*len = ret_len;
 	break;
 
Index: xc/lib/X11/imThaiFlt.c
diff -u xc/lib/X11/imThaiFlt.c:3.3 xc/lib/X11/imThaiFlt.c:3.6
--- xc/lib/X11/imThaiFlt.c:3.3	Sat Jan 29 13:58:16 2000
+++ xc/lib/X11/imThaiFlt.c	Sat Dec  2 10:30:22 2000
@@ -41,7 +41,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imThaiFlt.c,v 3.3 2000/01/29 18:58:16 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imThaiFlt.c,v 3.6 2000/12/02 15:30:22 tsi Exp $ */
 
 /*
 **++ 
@@ -75,7 +75,18 @@
 extern int _XKeyInitialize();
 
 /* lcStd.c */
-extern int _Xlcmbstowcs();
+extern int _Xlcmbstowcs(
+    XLCd	lcd,
+    wchar_t	*wstr,
+    char	*str,
+    int		len
+);
+extern int _Xlcmbstoutf8(
+    XLCd	lcd,
+    char	*ustr,
+    const char	*str,
+    int		len
+);
 
 #define SPACE   32
 
@@ -557,9 +568,11 @@
  * Macros to save and recall last input character in XIC
  */
 #define IC_SavePreviousChar(ic,ch) \
-		*((ic)->private.local.context->mb) = (char) (ch)
+		(*((ic)->private.local.context->mb) = (char) (ch))
 #define IC_GetPreviousChar(ic,ch) \
-		(ch) = (unsigned char) *((ic)->private.local.context->mb)
+		((ch) = (unsigned char) *((ic)->private.local.context->mb))
+#define IC_ClearPreviousChar(ic) \
+		(*((ic)->private.local.context->mb) = 0)
 /*
  * Input sequence check mode in XIC
  */
@@ -1161,6 +1174,33 @@
 
     if (!IC_IscMode(ic)) InitIscMode(ic);
 
+    count = XmbLookupString((XIC)ic, &ev->xkey, buf, sizeof(buf), &symbol, NULL);
+
+    if (((symbol >> 8 == 0xFF) &&
+         ((XK_BackSpace <= symbol && symbol <= XK_Clear) ||
+           (symbol == XK_Return) ||
+           (symbol == XK_Pause) ||
+           (symbol == XK_Scroll_Lock) ||
+           (symbol == XK_Sys_Req) ||
+           (symbol == XK_Escape) ||
+           (symbol == XK_Delete) ||
+           (XK_Home <= symbol && symbol <= XK_Begin) ||
+           (XK_Select <= symbol && symbol <= XK_Insert) ||
+           (XK_Undo <= symbol && symbol <= XK_Break) ||
+           (symbol == XK_Num_Lock) ||
+           (symbol == XK_KP_Space) ||
+           (symbol == XK_KP_Tab) ||
+           (symbol == XK_KP_Enter) ||
+           (XK_KP_F1 <= symbol && symbol <= XK_KP_Delete) ||
+           (XK_KP_Multiply <= symbol && symbol <= XK_KP_9) ||
+           (XK_F1 <= symbol && symbol <= XK_F35) ||
+           (symbol == XK_KP_Equal) ||
+           (symbol == NoSymbol))))
+        {
+            IC_ClearPreviousChar(ic); 
+            return False;
+        }
+#if 0
     if (! XThaiTranslateKey(ev->xkey.display, ev->xkey.keycode, ev->xkey.state,
 	 		&modifiers, &symbol, &lsym, &usym))
 	return False;
@@ -1188,17 +1228,17 @@
     /* Return symbol if cannot convert to character */
     if (!count)
 	return False;
+#endif
 
     /*
      *  Thai Input sequence check
      */
     isc_mode = IC_IscMode(ic);
-    if ((IC_GetPreviousChar(ic, previous_char))) {
-	if (!THAI_isaccepted(buf[0],previous_char, isc_mode)) {
-	    /* reject character */
-            XBell(ev->xkey.display, BellVolume);
-    	    return True;
-        }
+    if (!IC_GetPreviousChar(ic, previous_char)) previous_char = ' ';
+    if (!THAI_isaccepted(buf[0],previous_char, isc_mode)) {
+        /* reject character */
+        XBell(ev->xkey.display, BellVolume);
+        return True;
     }
     /* Remember the last character inputted. */
     IC_SavePreviousChar(ic, buf[count-1]);
@@ -1206,9 +1246,12 @@
         ic->private.local.composed->mb[i] = buf[i];
     ic->private.local.composed->mb[count] = '\0';
 
-    i = _Xlcmbstowcs(ic->core.im->core.lcd, ic->private.local.composed->wc,
-			ic->private.local.composed->mb, count);
-    
+    _Xlcmbstowcs(ic->core.im->core.lcd, ic->private.local.composed->wc,
+		 ic->private.local.composed->mb, count);
+
+    _Xlcmbstoutf8(ic->core.im->core.lcd, ic->private.local.composed->utf8,
+		  ic->private.local.composed->mb, count);
+
     if (!((buf[0] > 0 && buf[0] <= 0x1f) || (buf[0] == 0) || (buf[0] == 0x7f)))
         ic->private.local.composed->keysym = NoSymbol;
     else
Index: xc/lib/X11/imThaiIc.c
diff -u xc/lib/X11/imThaiIc.c:1.1.1.3 xc/lib/X11/imThaiIc.c:1.3
--- xc/lib/X11/imThaiIc.c:1.1.1.3	Sat Dec 21 22:27:41 1996
+++ xc/lib/X11/imThaiIc.c	Wed Nov 29 12:40:24 2000
@@ -32,6 +32,7 @@
 	                          frankyling@hgrd01.enet.dec.com
 
 ******************************************************************/
+/* $XFree86: xc/lib/X11/imThaiIc.c,v 1.3 2000/11/29 17:40:24 dawes Exp $ */
 
 #include <stdio.h>
 #include <X11/Xlib.h>
@@ -68,9 +69,11 @@
 
     Xfree(ic->private.local.context->mb);
     Xfree(ic->private.local.context->wc);
+    Xfree(ic->private.local.context->utf8);
     Xfree(ic->private.local.context);
     Xfree(ic->private.local.composed->mb);
     Xfree(ic->private.local.composed->wc);
+    Xfree(ic->private.local.composed->utf8);
     Xfree(ic->private.local.composed);
     return;
 }
@@ -96,8 +99,8 @@
     return;
 }
 
-Private char *
-_XimThaiMbReset(xic)
+Private void
+_XimThaiReset(xic)
     XIC	 xic;
 {
     Xic	 ic = (Xic)xic;
@@ -105,19 +108,23 @@
     ic->private.local.thai.keysym = 0;
     ic->private.local.composed->mb[0] = '\0';
     ic->private.local.composed->wc[0] = 0;
-    return((char *)NULL);
+    ic->private.local.composed->utf8[0] = '\0';
+}
+
+Private char *
+_XimThaiMbReset(xic)
+    XIC	 xic;
+{
+    _XimThaiReset(xic);
+    return (char *)NULL;
 }
 
 Private wchar_t *
 _XimThaiWcReset(xic)
     XIC	 xic;
 {
-    Xic	 ic = (Xic)xic;
-    ic->private.local.thai.comp_state = 0;
-    ic->private.local.thai.keysym = 0;
-    ic->private.local.composed->mb[0] = '\0';
-    ic->private.local.composed->wc[0] = 0;
-    return((wchar_t *)NULL);
+    _XimThaiReset(xic);
+    return (wchar_t *)NULL;
 }
 
 Private XICMethodsRec Thai_ic_methods = {
@@ -128,8 +135,10 @@
     _XimLocalGetICValues,	/* get_values */
     _XimThaiMbReset,		/* mb_reset */
     _XimThaiWcReset,		/* wc_reset */
+    _XimThaiMbReset,		/* utf8_reset */
     _XimLocalMbLookupString,	/* mb_lookup_string */
     _XimLocalWcLookupString,	/* wc_lookup_string */
+    _XimLocalUtf8LookupString	/* utf8_lookup_string */
 };
 
 XIC
@@ -160,6 +169,9 @@
     if ((ic->private.local.context->wc = (wchar_t *)Xmalloc(10*sizeof(wchar_t)))
 		== (wchar_t *)NULL)
 	goto Set_Error;
+    if ((ic->private.local.context->utf8 = (char *)Xmalloc(10))
+		== (char *)NULL)
+	goto Set_Error;
     if ((ic->private.local.composed = (DefTree *)Xmalloc(sizeof(DefTree)))
 	    == (DefTree *)NULL)
 	goto Set_Error;
@@ -168,6 +180,9 @@
 	goto Set_Error;
     if ((ic->private.local.composed->wc = (wchar_t *)Xmalloc(10*sizeof(wchar_t)))
 		== (wchar_t *)NULL)
+	goto Set_Error;
+    if ((ic->private.local.composed->utf8 = (char *)Xmalloc(10))
+		== (char *)NULL)
 	goto Set_Error;
 
     ic->private.local.thai.comp_state = 0;
Index: xc/lib/X11/imThaiIm.c
diff -u xc/lib/X11/imThaiIm.c:1.3 xc/lib/X11/imThaiIm.c:1.6
--- xc/lib/X11/imThaiIm.c:1.3	Wed Jun 14 14:20:33 2000
+++ xc/lib/X11/imThaiIm.c	Mon Dec  4 13:49:24 2000
@@ -32,7 +32,7 @@
 	                          frankyling@hgrd01.enet.dec.com
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/imThaiIm.c,v 1.3 2000/06/14 18:20:33 dawes Exp $ */
+/* $XFree86: xc/lib/X11/imThaiIm.c,v 1.6 2000/12/04 18:49:24 dawes Exp $ */
 
 #include <stdio.h>
 #include <X11/Xlib.h>
@@ -51,7 +51,8 @@
     _XimLocalGetIMValues,      /* get_values */
     _XimThaiCreateIC,          /* create_ic */
     _XimLcctstombs,            /* ctstombs */
-    _XimLcctstowcs             /* ctstowcs */
+    _XimLcctstowcs,            /* ctstowcs */
+    _XimLcctstoutf8            /* ctstoutf8 */
 };
 
 #define THAI_LANGUAGE_NAME 	"th"
@@ -104,7 +105,11 @@
     if (!(conv = _XlcOpenConverter(lcd,	XlcNCompoundText, lcd, XlcNWideChar)))
 	goto Open_Error;
     private->ctow_conv = conv;
-    
+
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNCompoundText, lcd, XlcNUtf8String)))
+	goto Open_Error;
+    private->ctoutf8_conv = conv;
+
     if (!(conv = _XlcOpenConverter(lcd,	XlcNCharSet, lcd, XlcNMultiByte)))
 	goto Open_Error;
     private->cstomb_conv = conv;
@@ -112,9 +117,18 @@
     if (!(conv = _XlcOpenConverter(lcd,	XlcNCharSet, lcd, XlcNWideChar)))
 	goto Open_Error;
     private->cstowc_conv = conv;
+
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNCharSet, lcd, XlcNUtf8String)))
+	goto Open_Error;
+    private->cstoutf8_conv = conv;
 
-    private->locale_code = * _XimGetLocaleCode(XLC_PUBLIC(lcd,encoding_name),
-                            (XlcCharSet*) &(private->keyboard_charset));
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNUcsChar, lcd, XlcNChar)))
+	goto Open_Error;
+    private->ucstoc_conv = conv;
+
+    if (!(conv = _XlcOpenConverter(lcd,	XlcNUcsChar, lcd, XlcNUtf8String)))
+	goto Open_Error;
+    private->ucstoutf8_conv = conv;
 
     im->methods = &Xim_im_thai_methods;
     private->current_ic = (XIC)NULL;
@@ -170,6 +184,10 @@
 	_XlcCloseConverter(im->private.local.ctow_conv);
 	im->private.local.ctow_conv = NULL;
     }
+    if (im->private.local.ctoutf8_conv) {
+	_XlcCloseConverter(im->private.local.ctoutf8_conv);
+	im->private.local.ctoutf8_conv = NULL;
+    }
     if (im->private.local.cstomb_conv) {
 	_XlcCloseConverter(im->private.local.cstomb_conv);
 	im->private.local.cstomb_conv = NULL;
@@ -177,6 +195,18 @@
     if (im->private.local.cstowc_conv) {
 	_XlcCloseConverter(im->private.local.cstowc_conv);
 	im->private.local.cstowc_conv = NULL;
+    }
+    if (im->private.local.cstoutf8_conv) {
+	_XlcCloseConverter(im->private.local.cstoutf8_conv);
+	im->private.local.cstoutf8_conv = NULL;
+    }
+    if (im->private.local.ucstoc_conv) {
+	_XlcCloseConverter(im->private.local.ucstoc_conv);
+	im->private.local.ucstoc_conv = NULL;
+    }
+    if (im->private.local.ucstoutf8_conv) {
+	_XlcCloseConverter(im->private.local.ucstoutf8_conv);
+	im->private.local.ucstoutf8_conv = NULL;
     }
     return;
 }
Index: xc/lib/X11/lcCT.c
diff -u xc/lib/X11/lcCT.c:3.17 xc/lib/X11/lcCT.c:3.22
--- xc/lib/X11/lcCT.c:3.17	Thu May 18 12:29:51 2000
+++ xc/lib/X11/lcCT.c	Thu Dec  7 15:26:11 2000
@@ -36,7 +36,7 @@
  *  Modifier: Ivan Pascal     The XFree86 Project
  *  Modifier: Bruno Haible    The XFree86 Project
  */
-/* $XFree86: xc/lib/X11/lcCT.c,v 3.17 2000/05/18 16:29:51 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcCT.c,v 3.22 2000/12/07 20:26:11 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XlcPubI.h"
@@ -50,8 +50,8 @@
  * Static representation of a character set that can be used in Compound Text.
  */
 typedef struct _CTDataRec {
-    _Xconst char *name;
-    _Xconst char *encoding;	/* Compound Text encoding, ESC sequence */
+    const char *name;
+    const char *ct_sequence;	/* Compound Text encoding, ESC sequence */
 } CTDataRec, *CTData;
 
 static CTDataRec default_ct_data[] =
@@ -109,27 +109,23 @@
     /* Registered encodings with a varying number of bytes per character */
     { "ISO10646-1",         /* UTF-8               196   */ "\033%G"  },
 
-    /* Encodings without ISO-IR assigned escape sequence */
-    { "KOI8-R:GR",           "\033%/1\200\210koi8-r\002"},
-    { "KOI8-U:GR",           "\033%/1\200\211koi8-u\002"},
-    { "ARMSCII-8:GR",        "\033%/1\200\210armscii-8\002"},
-    { "IBM-CP1133:GR",       "\033%/1\200\210ibm-cp1133\002"},
-    { "MULELAO-1:GR",        "\033%/1\200\210mulelao-1\002"},
-    { "VISCII1.1-1:GR",      "\033%/1\200\210viscii1.1-1\002"},
-    { "TCVN-5712:GR",        "\033%/1\200\210tcvn-5712\002"},
-    { "GEORGIAN-ACADEMY:GR", "\033%/1\200\210georgian-academy\002"},
-    { "GEORGIAN-PS:GR",      "\033%/1\200\210georgian-ps\002"},
+    /* Encodings without ISO-IR assigned escape sequence must be
+       defined in XLC_LOCALE files, using "\033%/1" or "\033%/2". */
+
     /* Backward compatibility with XFree86 3.x */
-    { "ISO8859-14:GR",       "\033%/1\200\213iso8859-14\002"},
-    { "ISO8859-15:GR",       "\033%/1\200\213iso8859-15\002"},
-#ifdef notdef /* used by Emacs, but not backed by ISO-IR */
+    { "ISO8859-14:GR",                                      "\033%/1" },
+    { "ISO8859-15:GR",                                      "\033%/1" },
+    /* used by Emacs, but not backed by ISO-IR */
     { "BIG5-0:GL", "\033$(0" },
     { "BIG5-0:GR", "\033$)0" },
     { "BIG5-1:GL", "\033$(1" },
     { "BIG5-1:GR", "\033$)1" },
-#endif
-}; 
 
+};
+
+/* We represent UTF-8 as an XlcGLGR charset, not in extended segments. */
+#define UTF8_IN_EXTSEQ 0
+
 /* ======================= Parsing ESC Sequences ======================= */
 
 #define XctC0		0x0000
@@ -159,49 +155,67 @@
 #define XctGL94MB	0x2428
 #define XctGR94MB	0x2429
 #define XctExtSeg	0x252f
-#define XctOtherSeg	0x2f00
-
-#define XctESCSeq	0x1b00
-#define XctCSISeq	0x9b00
+#define XctReturn	0x2540
 
 /*
  * Parses the header of a Compound Text segment, i.e. the charset designator.
+ * The string starts at *text and has *length bytes.
+ * Return value is one of:
+ *   0 (no valid charset designator),
+ *   XctGL94, XctGR94, XctGR96, XctGL94MB, XctGR94MB,
+ *   XctLeftToRight, XctRightToLeft, XctDirectionEnd,
+ *   XctExtSeg, XctOtherCoding, XctReturn, XctIgnoreExt, XctNotIgnoreExt.
+ * If the return value is not 0, *text is incremented and *length decremented,
+ * to point past the charset designator. If the return value is one of
+ *   XctGL94, XctGR94, XctGR96, XctGL94MB, XctGR94MB,
+ *   XctExtSeg, XctOtherCoding, XctIgnoreExt, XctNotIgnoreExt,
+ * *final_byte is set to the "final byte" of the charset designator.
  */
 static unsigned int
-_XlcParseCT(text, length, extra_data)
-    _Xconst char **text;
-    int *length;
-    unsigned int *extra_data;
+_XlcParseCT(
+    const char **text,
+    int *length,
+    unsigned char *final_byte)
 {
-    unsigned int ret = 0, dummy, *data = extra_data;
+    unsigned int ret = 0;
     unsigned char ch;
-    register _Xconst unsigned char *str = (_Xconst unsigned char *) *text;
+    const unsigned char *str = (const unsigned char *) *text;
 
-    if (data == NULL)
-       data = &dummy;
-    *data = 0;
+    *final_byte = 0;
 
+    if (*length < 1)
+        return 0;
     switch (ch = *str++) {
         case XctESC:
+            if (*length < 2)
+                return 0;
             switch (ch = *str++) {
                 case XctOtherCoding:             /* % */
+                    if (*length < 3)
+                        return 0;
                     ch = *str++;
-                    if (ch == XctNonStandard) {
+                    if (ch == XctNonStandard) {  /* / */
+                        if (*length < 4)
+                            return 0;
                         ret = XctExtSeg;
                         ch = *str++;
+                    } else if (ch == '@') {
+                        ret = XctReturn;
                     } else {
                         ret = XctOtherCoding;
                     }
-                    *data = (unsigned int) ch;
+                    *final_byte = ch;
                     break;
 
                 case XctCntrlFunc:               /* # */
-                    *data = (unsigned int) *str++;
-                    switch (*str++){
-                        case XctIgnoreExt:
+                    if (*length < 4)
+                        return 0;
+                    *final_byte = *str++;
+                    switch (*str++) {
+                        case XctIgnoreExt:       /* 0 */
                             ret = XctIgnoreExt;
                             break;
-                        case XctNotIgnoreExt:
+                        case XctNotIgnoreExt:    /* 1 */
                             ret = XctNotIgnoreExt;
                             break;
                         default:
@@ -211,120 +225,145 @@
                     break;
 
                 case XctMB:                      /* $ */
+                    if (*length < 4)
+                        return 0;
                     ch = *str++;
                     switch (ch) {
-                        case XctGL94:
+                        case XctGL94:            /* ( */
                             ret = XctGL94MB;
                             break;
-                        case XctGR94:
+                        case XctGR94:            /* ) */
                             ret = XctGR94MB;
                             break;
                         default:
                             ret = 0;
                             break;
                     }
-                    *data = (unsigned int) *str++;
+                    *final_byte = *str++;
                     break;
 
-                case XctGL94:
+                case XctGL94:                    /* ( */
+                    if (*length < 3)
+                        return 0;
                     ret = XctGL94;
-                    *data = (unsigned int) *str++;
+                    *final_byte = *str++;
                     break;
-                case XctGR94:
+                case XctGR94:                    /* ) */
+                    if (*length < 3)
+                        return 0;
                     ret = XctGR94;
-                    *data = (unsigned int) *str++;
+                    *final_byte = *str++;
                     break;
-                case XctGR96:
+                case XctGR96:                    /* - */
+                    if (*length < 3)
+                        return 0;
                     ret = XctGR96;
-                    *data = (unsigned int) *str++;
+                    *final_byte = *str++;
                     break;
             }
             break;
         case XctCSI:
 	    /* direction */
-	    if (*str == XctLeftToRight && *(str + 1) == XctDirection) {
-                ret = XctLeftToRight;
-                str += 2;
-            } else if (*str == XctRightToLeft && *(str + 1) == XctDirection) {
-                ret = XctRightToLeft;
-                str += 2;
-            } else if (*str == XctDirectionEnd) {
-	       ret = XctDirectionEnd;
-               str++;
-            } else {
-               ret = 0;
+            if (*length < 2)
+                return 0;
+            switch (*str++) {
+                case XctLeftToRight:
+                    if (*length < 3)
+                        return 0;
+                    if (*str++ == XctDirection)
+                        ret = XctLeftToRight;
+                    break;
+                case XctRightToLeft:
+                    if (*length < 3)
+                        return 0;
+                    if (*str++ == XctDirection)
+                        ret = XctRightToLeft;
+                    break;
+                case XctDirectionEnd:
+                    ret = XctDirectionEnd;
+                    break;
             }
             break;
     }
 
     if (ret) {
-        *length -= (char *) str - *text;
-        *text = (char *) str;
+        *length -= (const char *) str - *text;
+        *text = (const char *) str;
     }
     return ret;
 }
 
 /*
  * Fills into a freshly created XlcCharSet the fields that can be inferred
- * from the ESC sequence.
+ * from the ESC sequence. These are side, char_size, set_size.
+ * Returns True if the charset can be used with Compound Text.
  *
  * Used by _XlcCreateDefaultCharSet.
  */
 Bool
-_XlcParseCharSet(charset)
-    XlcCharSet charset;
+_XlcParseCharSet(
+    XlcCharSet charset)
 {
-    unsigned int type, final_byte;
-    _Xconst char *ptr = charset->ct_sequence;
+    unsigned int type;
+    unsigned char final_byte;
+    const char *ptr = charset->ct_sequence;
     int length;
-    int char_size = 1;
+    int char_size;
     
-    if (ptr == NULL || *ptr == '\0')
+    if (*ptr == '\0')
     	return False;
 
     length = strlen(ptr);
 
     type = _XlcParseCT(&ptr, &length, &final_byte);
 
-    if (type == XctGR94MB || type == XctGL94MB) {
-       if (final_byte < 0x60) {
-          char_size = 2;
-       } else if (final_byte < 0x70) {
-          char_size = 3;
-       } else {
-          char_size = 4;
-       }
+    /* Check for validity and determine char_size.
+       char_size = 0 means varying number of bytes per character. */
+    switch (type) {
+        case XctGL94:
+        case XctGR94:
+        case XctGR96:
+            char_size = 1;
+            break;
+        case XctGL94MB:
+        case XctGR94MB:
+            char_size = (final_byte < 0x60 ? 2 : final_byte < 0x70 ? 3 : 4);
+            break;
+        case XctExtSeg:
+            char_size = final_byte - '0';
+            if (!(char_size >= 0 && char_size <= 4))
+                return False;
+            break;
+        case XctOtherCoding:
+            char_size = 0;
+            break;
+        default:
+            return False;
     }
 
-    if (type == XctExtSeg) {
-       char_size = final_byte - '0';
-       if ((char_size < 1) || (char_size > 4))
-          char_size = 1;
-    }
+    charset->char_size = char_size;
 
+    /* Fill in other values. */
     switch (type) {
-       case XctGR94MB :
-       case XctGR94 :
-          charset->side = XlcGR;
-          charset->set_size = 94;
-          charset->char_size = char_size;
-          break;
-       case XctGL94MB :
-       case XctGL94 :
-          charset->side = XlcGL;
-          charset->set_size = 94;
-          charset->char_size = char_size;
-          break;
-       case XctGR96:
-          charset->side = XlcGR;
-          charset->set_size = 96;
-          charset->char_size = char_size;
-          break;
-       case XctOtherCoding:
-       case XctExtSeg:
-          charset->side = XlcGLGR;
-          charset->char_size = char_size;
-          break;
+        case XctGL94:
+        case XctGL94MB:
+            charset->side = XlcGL;
+            charset->set_size = 94;
+            break;
+        case XctGR94:
+        case XctGR94MB:
+            charset->side = XlcGR;
+            charset->set_size = 94;
+            break;
+        case XctGR96:
+            charset->side = XlcGR;
+            charset->set_size = 96;
+            break;
+        case XctExtSeg:
+        case XctOtherCoding:
+            charset->side = XlcGLGR;
+            charset->set_size = 0;
+            break;
     }
     return True;
 }
@@ -335,13 +374,18 @@
 /*
  * Representation of a character set that can be used for Compound Text,
  * at run time.
+ * Note: This information is not contained in the XlcCharSet, because
+ * multiple ESC sequences may be used for the same XlcCharSet.
  */
 typedef struct _CTInfoRec {
     XlcCharSet charset;
+    const char *ct_sequence;	/* Compound Text ESC sequence */
     unsigned int type;
     unsigned char final_byte;
-    int ext_segment_len;
-    char *ext_segment;		/* extended segment */
+				/* If type == XctExtSeg: */
+    const char *ext_segment;	/* extended segment name, then '\002' */
+    int ext_segment_len;	/* length of above, including final '\002' */
+
     struct _CTInfoRec *next;
 } CTInfoRec, *CTInfo;
 
@@ -351,106 +395,160 @@
  * at runtime through _XlcAddCT.
  */
 static CTInfo ct_list = NULL;
+static CTInfo *ct_list_end = &ct_list;
 
+/*
+ * Returns a Compound Text info record for an ESC sequence.
+ * The first part of the ESC sequence has already been parsed into 'type'
+ * and 'final_byte'. The remainder starts at 'text', at least 'text_len'
+ * bytes (only used if type == XctExtSeg).
+ */
 static CTInfo
-_XlcGetCTInfo(text, type, final_byte)
-   _Xconst char *text;
-   unsigned int type;
-   unsigned char final_byte;
-{
-   CTInfo ct_info;
-
-   for (ct_info = ct_list; ct_info; ct_info = ct_info->next) {
-      if (ct_info->type == type && ct_info->final_byte == final_byte) {
-         if (ct_info->ext_segment) {
-            if (text &&
-                !strncmp(text, ct_info->ext_segment, ct_info->ext_segment_len))
-               return ct_info;
-         } else {
+_XlcGetCTInfo(
+    unsigned int type,
+    unsigned char final_byte,
+    const char *text,
+    int text_len)
+{
+    CTInfo ct_info;
+
+    for (ct_info = ct_list; ct_info; ct_info = ct_info->next)
+        if (ct_info->type == type
+            && ct_info->final_byte == final_byte
+            && (type != XctExtSeg
+                || (text_len >= ct_info->ext_segment_len
+                    && memcmp(text, ct_info->ext_segment,
+                              ct_info->ext_segment_len) == 0)))
             return ct_info;
-         }
-      }
-   }
-   return (CTInfo) NULL;
+
+    return (CTInfo) NULL;
 }
 
-XlcCharSet
-_XlcAddCT(name, ct_sequence)
-    _Xconst char *name;
-    _Xconst char *ct_sequence;
+/* Returns the Compound Text info for a given XlcCharSet.
+   Returns NULL if none is found. */
+static CTInfo
+_XlcGetCTInfoFromCharSet(
+    XlcCharSet charset)
 {
     CTInfo ct_info;
+
+    for (ct_info = ct_list; ct_info; ct_info = ct_info->next)
+	if (ct_info->charset == charset)
+	    return ct_info;
+
+    return (CTInfo) NULL;
+}
+
+/* Creates a new XlcCharSet, given its name (including side suffix) and
+   Compound Text ESC sequence (normally at most 4 bytes), and makes it
+   eligible for Compound Text processing. */
+XlcCharSet
+_XlcAddCT(
+    const char *name,
+    const char *ct_sequence)
+{
+    CTInfo ct_info, existing_info;
     XlcCharSet charset;
-    _Xconst char *ct_ptr = ct_sequence;
+    const char *ct_ptr;
     int length;
-    unsigned int type, final_byte;
-
-    length = strlen(ct_sequence);
+    unsigned int type;
+    unsigned char final_byte;
 
     charset = _XlcGetCharSet(name);
-    if (charset == NULL) {
+    if (charset != NULL) {
+        /* Even if the charset already exists, it is OK to register a second
+           Compound Text sequence for it. */
+    } else {
+        /* Attempt to create the charset. */
         charset = _XlcCreateDefaultCharSet(name, ct_sequence);
         if (charset == NULL)
 	    return (XlcCharSet) NULL;
         _XlcAddCharSet(charset);
     }
 
-    ct_info = (CTInfo) Xmalloc(sizeof(CTInfoRec));
+    /* Allocate a CTinfo record. */
+    length = strlen(ct_sequence);
+    ct_info = (CTInfo) Xmalloc(sizeof(CTInfoRec) + length+1);
     if (ct_info == NULL)
-	return (XlcCharSet) NULL;
+	return charset;
 
-    ct_info->ext_segment = NULL;
-    ct_info->ext_segment_len = 0;
- 
+    ct_info->charset = charset;
+    ct_info->ct_sequence = strcpy((char *) (ct_info + 1), ct_sequence);
+
+    /* Parse the Compound Text sequence. */
+    ct_ptr = ct_sequence;
     type = _XlcParseCT(&ct_ptr, &length, &final_byte);
 
+    ct_info->type = type;
+    ct_info->final_byte = final_byte;
+
     switch (type) {
-	case XctExtSeg:
-            if (strlen(charset->ct_sequence) > 6) {
-                ct_info->ext_segment = charset->ct_sequence + 6;
-                ct_info->ext_segment_len = strlen(ct_info->ext_segment) - 1;
-            } else {
-                ct_info->ext_segment = charset->encoding_name;
-                ct_info->ext_segment_len = strlen(ct_info->ext_segment);
-            }
 	case XctGL94:
-	case XctGL94MB:
 	case XctGR94:
-	case XctGR94MB:
 	case XctGR96:
+	case XctGL94MB:
+	case XctGR94MB:
 	case XctOtherCoding:
-            ct_info->type = type;
-            ct_info->final_byte = (unsigned char) final_byte;
-            ct_info->charset = charset;
+            ct_info->ext_segment = NULL;
+            ct_info->ext_segment_len = 0;
             break;
+	case XctExtSeg: {
+            /* By convention, the extended segment name is the encoding_name
+               in lowercase. */
+            const char *q = charset->encoding_name;
+            int n = strlen(q);
+            char *p;
+
+            /* Ensure ct_info->ext_segment_len <= 0x3fff - 6. */
+            if (n > 0x3fff - 6 - 1) {
+                Xfree(ct_info);
+                return charset;
+            }
+            p = (char *) Xmalloc(n+1);
+            if (p == NULL) {
+                Xfree(ct_info);
+                return charset;
+            }
+            ct_info->ext_segment = p;
+            ct_info->ext_segment_len = n+1;
+            for ( ; n > 0; p++, q++, n--)
+                *p = (*q >= 'A' && *q <= 'Z' ? *q - 'A' + 'a' : *q);
+            *p = XctSTX;
+            break;
+        }
 	default:
             Xfree(ct_info);
             return (XlcCharSet) NULL;
     }
 
-    if (!_XlcGetCTInfo( ct_info->ext_segment, type, ct_info->final_byte)) {
-        ct_info->next = ct_list;
-        ct_list = ct_info;
+    /* Insert it into the list, if not already present. */
+    existing_info =
+        _XlcGetCTInfo(type, ct_info->final_byte,
+                      ct_info->ext_segment, ct_info->ext_segment_len);
+    if (existing_info == NULL) {
+        /* Insert it at the end. If there are duplicates CTinfo entries
+           for the same XlcCharSet, we want the first (standard) one to
+           override the second (user defined) one. */
+        ct_info->next = *ct_list_end;
+        *ct_list_end = ct_info;
     } else {
+        if (existing_info->charset != charset
+            /* We have a conflict, with one exception: JISX0208.1983-0 and
+               JISX0208.1990-0 are the same for all practical purposes. */
+            && !(strncmp(existing_info->charset->name, "JISX0208", 8) == 0
+                 && strncmp(charset->name, "JISX0208", 8) == 0)) {
+            fprintf(stderr,
+                    "Xlib: charsets %s and %s have the same CT sequence\n",
+                    charset->name, existing_info->charset->name);
+            if (strcmp(charset->ct_sequence, ct_sequence) == 0)
+                charset->ct_sequence = "";
+        }
         Xfree(ct_info);
     }
 
     return charset;
 }
 
-static CTInfo
-_XlcGetCTInfoFromCharSet(charset)
-    register XlcCharSet charset;
-{
-    register CTInfo ct_info;
-
-    for (ct_info = ct_list; ct_info; ct_info = ct_info->next)
-	if (ct_info->charset == charset)
-	    return ct_info;
-
-    return (CTInfo) NULL;
-}
-
 
 /* ========== Converters String <--> CharSet <--> Compound Text ========== */
 
@@ -458,184 +556,328 @@
  * Structure representing the parse state of a Compound Text string.
  */
 typedef struct _StateRec {
-    XlcCharSet charset;
-    XlcCharSet GL_charset;
-    XlcCharSet GR_charset;
-    XlcCharSet ext_seg_charset;
-    int ext_seg_left;
+    XlcCharSet charset;		/* The charset of the current segment */
+    XlcCharSet GL_charset;	/* The charset responsible for 0x00..0x7F */
+    XlcCharSet GR_charset;	/* The charset responsible for 0x80..0xFF */
+    XlcCharSet Other_charset;	/* != NULL if currently in an other segment */
+    int ext_seg_left;		/* > 0 if currently in an extended segment */
 } StateRec, *State;
 
+
+/* Subroutine for parsing an ESC sequence. */
 
-typedef enum { resOK, resNotCTSeq, resNotInList } CheckResult;
-/*  resNotCTSeq - EscSeq not recognized, pointers not changed
-*   resNotInList - EscSeq recognized but charset not found,
-*                  sequence skiped
-*   resOK - OK. Charset saved in 'state', sequence skiped
-*/  
+typedef enum {
+    resOK,		/* Charset saved in 'state', sequence skipped */
+    resNotInList,	/* Charset not found, sequence skipped */
+    resNotCTSeq		/* EscSeq not recognized, pointers not changed */
+} CheckResult;
 
 static CheckResult
-_XlcCheckCTSequence(state, ctext, ctext_len)
-    State state;
-    _Xconst char **ctext;
-    int *ctext_len;
+_XlcCheckCTSequence(
+    State state,
+    const char **ctext,
+    int *ctext_len)
 {
     XlcCharSet charset;
     CTInfo ct_info;
-    unsigned int type, final_byte;
-    unsigned int ext_seg_left;
-
-    type = _XlcParseCT(ctext, ctext_len, &final_byte);
+    const char *tmp_ctext = *ctext;
+    int tmp_ctext_len = *ctext_len;
+    unsigned int type;
+    unsigned char final_byte;
+    int ext_seg_left = 0;
 
-    if (!type)
-        return resNotCTSeq;
+    /* Check for validity. */
+    type = _XlcParseCT(&tmp_ctext, &tmp_ctext_len, &final_byte);
 
-    if ((type == XctExtSeg) && (*ctext_len > 2)) {
-        int msb = *(*ctext)++ & 0x7f;
-        int lsb = *(*ctext)++ & 0x7f;
-    	ext_seg_left = (msb << 7) + lsb - 2;
-        *ctext_len -= 2;
+    switch (type) {
+	case XctGL94:
+	case XctGR94:
+	case XctGR96:
+	case XctGL94MB:
+	case XctGR94MB:
+	case XctOtherCoding:
+            *ctext = tmp_ctext;
+            *ctext_len = tmp_ctext_len;
+            break;
+        case XctReturn:
+            *ctext = tmp_ctext;
+            *ctext_len = tmp_ctext_len;
+            state->Other_charset = NULL;
+            return resOK;
+        case XctExtSeg:
+            if (tmp_ctext_len > 2
+                && (tmp_ctext[0] & 0x80) && (tmp_ctext[0] & 0x80)) {
+                unsigned int msb = tmp_ctext[0] & 0x7f;
+                unsigned int lsb = tmp_ctext[1] & 0x7f;
+                ext_seg_left = (msb << 7) + lsb;
+                if (ext_seg_left <= tmp_ctext_len - 2) {
+                    *ctext = tmp_ctext + 2;
+                    *ctext_len = tmp_ctext_len - 2;
+                    break;
+                }
+            }
+            return resNotCTSeq;
+        default:
+            return resNotCTSeq;
     }
 
-    ct_info = _XlcGetCTInfo(*ctext, type, (unsigned char) final_byte);
+    ct_info = _XlcGetCTInfo(type, final_byte, *ctext, ext_seg_left);
 
     if (ct_info) {
         charset = ct_info->charset;
-        if (ct_info->ext_segment_len) {
-            *ctext += ct_info->ext_segment_len + 1;
-            *ctext_len -= ct_info->ext_segment_len + 1;
-        }
-        if (charset->side == XlcGL) {
-            state->GL_charset = charset;
-        } else if (charset->side == XlcGR) {
-            state->GR_charset = charset;
+        state->ext_seg_left = ext_seg_left;
+        if (type == XctExtSeg) {
+            state->charset = charset;
+            /* Skip past the extended segment name and the separator. */
+            *ctext += ct_info->ext_segment_len;
+            *ctext_len -= ct_info->ext_segment_len;
+            state->ext_seg_left -= ct_info->ext_segment_len;
+        } else if (type == XctOtherCoding) {
+            state->Other_charset = charset;
         } else {
-            state->GL_charset = charset;
-            state->GR_charset = charset;
+            if (charset->side == XlcGL) {
+                state->GL_charset = charset;
+            } else if (charset->side == XlcGR) {
+                state->GR_charset = charset;
+            } else {
+                state->GL_charset = charset;
+                state->GR_charset = charset;
+            }
         }
+        return resOK;
     } else {
+        state->ext_seg_left = 0;
         if (type == XctExtSeg) {
+            /* Skip the entire extended segment. */
             *ctext += ext_seg_left;
             *ctext_len -= ext_seg_left;
         }
         return resNotInList;
     }
-    return resOK;
 }
 
 static void
-init_state(conv)
-    XlcConv conv;
+init_state(
+    XlcConv conv)
 {
     State state = (State) conv->state;
-    static XlcCharSet GL_charset = NULL;
-    static XlcCharSet GR_charset = NULL;
+    static XlcCharSet default_GL_charset = NULL;
+    static XlcCharSet default_GR_charset = NULL;
 
-    if (GL_charset == NULL) {
-	GL_charset = _XlcGetCharSet("ISO8859-1:GL");
-	GR_charset = _XlcGetCharSet("ISO8859-1:GR");
+    if (default_GL_charset == NULL) {
+	default_GL_charset = _XlcGetCharSet("ISO8859-1:GL");
+	default_GR_charset = _XlcGetCharSet("ISO8859-1:GR");
     }
 
-    state->GL_charset = state->charset = GL_charset;
-    state->GR_charset = GR_charset;
-    state->ext_seg_charset = NULL;
+    /* The initial state is ISO-8859-1 on both sides. */
+    state->GL_charset = state->charset = default_GL_charset;
+    state->GR_charset = default_GR_charset;
+
+    state->Other_charset = NULL;
+
     state->ext_seg_left = 0;
 }
 
 /* from XlcNCompoundText to XlcNCharSet */
 
 static int
-cttocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
-{
-    register State state = (State) conv->state;
-    register unsigned char ch;
-    CheckResult ret;
+cttocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
+{
+    State state = (State) conv->state;
     XlcCharSet charset = NULL;
-    _Xconst char *ctptr;
+    const char *ctptr;
     char *bufptr;
     int ctext_len, buf_len;
+    int unconv_num = 0;
 
-    ctptr = (char *) *from;
+    ctptr = (const char *) *from;
     bufptr = (char *) *to;
     ctext_len = *from_left;
     buf_len = *to_left;
 
     while (ctext_len > 0 && buf_len > 0) {
-        ch = *ctptr;
-#ifdef notdef
-        if (ch == XctCSI) {
-            /* do nothing except skip sequence if not recognized */
-            if (_XlcParseCT(&ctptr, &ctext_len, NULL))
-                continue;
-        }
-#endif
-        if (ch == XctESC) {
-            ret = _XlcCheckCTSequence(state, &ctptr, &ctext_len);
-            if (ret == resOK || ret == resNotInList)
-                continue;
-        }
-        if (charset) {
-            if (charset != (ch & 0x80 ? state->GR_charset : state->GL_charset))
-                break; 
+        if (state->ext_seg_left == 0) {
+            /* Not in the middle of an extended segment; look at next byte. */
+            unsigned char ch = *ctptr;
+            XlcCharSet ch_charset;
+
+            if (ch == XctESC) {
+                CheckResult ret =
+                    _XlcCheckCTSequence(state, &ctptr, &ctext_len);
+                if (ret == resOK)
+                    /* state has been modified. */
+                    continue;
+                if (ret == resNotInList) {
+                    /* XXX Just continue with previous charset. */
+                    unconv_num++;
+                    continue;
+                }
+            } else if (ch == XctCSI) {
+                /* XXX Simply ignore the XctLeftToRight, XctRightToLeft,
+                   XctDirectionEnd sequences for the moment. */
+                unsigned char dummy;
+                if (_XlcParseCT(&ctptr, &ctext_len, &dummy)) {
+                    unconv_num++;
+                    continue;
+                }
+            }
+
+            /* Find the charset which is responsible for this byte. */
+            ch_charset = (state->Other_charset != NULL ? state->Other_charset :
+                          (ch & 0x80 ? state->GR_charset : state->GL_charset));
+
+            /* Set the charset of this run, or continue the current run,
+               or stop the current run. */
+            if (charset) {
+                if (charset != ch_charset)
+                    break; 
+            } else {
+                state->charset = charset = ch_charset;
+            }
+
+            /* We don't want to split a character into multiple pieces. */
+            if (buf_len < 6) {
+                if (charset->char_size > 0) {
+                    if (buf_len < charset->char_size)
+                        break;
+                } else {
+                    /* char_size == 0 is tricky. The code here is good only
+                       for valid UTF-8 input. */
+                    if (charset->ct_sequence[0] == XctESC
+                        && charset->ct_sequence[1] == XctOtherCoding
+                        && charset->ct_sequence[2] == 'G') {
+                        int char_size = (ch < 0xc0 ? 1 :
+                                         ch < 0xe0 ? 2 :
+                                         ch < 0xf0 ? 3 :
+                                         ch < 0xf8 ? 4 :
+                                         ch < 0xfc ? 5 :
+                                                     6);
+                        if (buf_len < char_size)
+                            break;
+                    }
+                }
+            }
+
+            *bufptr++ = *ctptr++;
+            ctext_len--;
+            buf_len--;
         } else {
-            charset = (ch & 0x80 ? state->GR_charset : state->GL_charset);
-        }
+            /* Copy as much as possible from the current extended segment
+               to the buffer. */
+            int char_size;
+
+            /* Set the charset of this run, or continue the current run,
+               or stop the current run. */
+            if (charset) {
+                if (charset != state->charset)
+                    break; 
+            } else {
+                charset = state->charset;
+            }
+
+            char_size = charset->char_size;
 
-        *bufptr++ = *ctptr++;
-        ctext_len--;
-        buf_len--;
+            if (state->ext_seg_left <= buf_len || char_size > 0) {
+                int n = (state->ext_seg_left <= buf_len
+                         ? state->ext_seg_left
+                         : (buf_len / char_size) * char_size);
+                memcpy(bufptr, ctptr, n);
+                ctptr += n; ctext_len -= n;
+                bufptr += n; buf_len -= n;
+                state->ext_seg_left -= n;
+            } else {
+#if UTF8_IN_EXTSEQ
+                /* char_size == 0 is tricky. The code here is good only
+                   for valid UTF-8 input. */
+                if (strcmp(charset->name, "ISO10646-1") == 0) {
+                    unsigned char ch = *ctptr;
+                    int char_size = (ch < 0xc0 ? 1 :
+                                     ch < 0xe0 ? 2 :
+                                     ch < 0xf0 ? 3 :
+                                     ch < 0xf8 ? 4 :
+                                     ch < 0xfc ? 5 :
+                                                 6);
+                    int i;
+                    if (buf_len < char_size)
+                        break;
+                    /* A small loop is faster than calling memcpy. */
+                    for (i = char_size; i > 0; i--)
+                        *bufptr++ = *ctptr++;
+                    ctext_len -= char_size;
+                    buf_len -= char_size;
+                    state->ext_seg_left -= char_size;
+                } else
+#endif
+                {
+                    /* Here ctext_len >= state->ext_seg_left > buf_len.
+                       We may be splitting a character into multiple pieces.
+                       Oh well. */
+                    int n = buf_len;
+                    memcpy(bufptr, ctptr, n);
+                    ctptr += n; ctext_len -= n;
+                    bufptr += n; buf_len -= n;
+                    state->ext_seg_left -= n;
+                }
+            }
+        }
     }
 
-    if (charset)
-	state->charset = charset;
+    /* 'charset' is the charset for the current run. In some cases,
+       'state->charset' contains the charset for the next run. Therefore,
+       return 'charset'.
+       'charset' may still be NULL only if no output was produced. */
     if (num_args > 0)
-	*((XlcCharSet *) args[0]) = state->charset;
+	*((XlcCharSet *) args[0]) = charset;
 
-    *from_left -= ctptr - *((char **) from);
+    *from_left -= ctptr - *((const char **) from);
     *from = (XPointer) ctptr;
 
     *to_left -= bufptr - *((char **) to);
     *to = (XPointer) bufptr;
 
-    return 0;
+    return unconv_num;
 }
 
 /* from XlcNCharSet to XlcNCompoundText */
 
 static int
-cstoct(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstoct(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XlcSide side;
     unsigned char min_ch, max_ch;
-    register unsigned char ch;
-    int length;
+    int length, unconv_num;
     CTInfo ct_info;
     XlcCharSet charset;
-    char *csptr, *ctptr;
+    const char *csptr;
+    char *ctptr;
     int csstr_len, ct_len;
+    char *ext_segment_start;
+    int char_size;
 
+    /* One argument is required, of type XlcCharSet. */
     if (num_args < 1)
 	return -1;
-    
-    csptr = *((char **) from);
+
+    csptr = *((const char **) from);
     ctptr = *((char **) to);
     csstr_len = *from_left;
     ct_len = *to_left;
-    
+
     charset = (XlcCharSet) args[0];
 
     ct_info = _XlcGetCTInfoFromCharSet(charset);
@@ -643,78 +885,170 @@
 	return -1;
 
     side = charset->side;
-    length = strlen(charset->ct_sequence);
+    length = strlen(ct_info->ct_sequence);
 
-    if (((side == XlcGR || side == XlcGLGR) &&
-          charset != state->GR_charset) ||
-        ((side == XlcGL || side == XlcGLGR) &&
-          charset != state->GL_charset) ) {
-
-        /* output esc-sequence */
-        if ((ct_info->type == XctExtSeg) && (length < 7)) {
-            int comp_len = length + strlen(ct_info->ext_segment) + 3;
+    ext_segment_start = NULL;
 
-            if (ct_len < comp_len)
+    if (ct_info->type == XctOtherCoding) {
+        /* Output the Escape sequence for switching to the charset, and
+           reserve room now for the XctReturn sequence at the end. */
+        if (ct_len < length + 3)
+            return -1;
+
+        memcpy(ctptr, ct_info->ct_sequence, length);
+        ctptr += length;
+        ct_len -= length + 3;
+    } else
+    /* Test whether the charset is already active. */
+    if (((side == XlcGR || side == XlcGLGR)
+	 && charset != state->GR_charset)
+	|| ((side == XlcGL || side == XlcGLGR)
+	    && charset != state->GL_charset)) {
+
+        /* Output the Escape sequence for switching to the charset. */
+        if (ct_info->type == XctExtSeg) {
+            if (ct_len < length + 2 + ct_info->ext_segment_len)
                 return -1;
 
-            strcpy(ctptr, ct_info->charset->ct_sequence);
+            memcpy(ctptr, ct_info->ct_sequence, length);
             ctptr += length;
-
-            length = ct_info->ext_segment_len;
-            *ctptr++ = ((length + 3) / 128) | 0x80;
-            *ctptr++ = ((length + 3) % 128) | 0x80;	   
-            strncpy(ctptr, ct_info->ext_segment, length);
-            ctptr += length;
-            *ctptr++ = XctSTX;
-            ct_len -= comp_len;
+            ct_len -= length;
 
+            ctptr += 2;
+            ct_len -= 2;
+            ext_segment_start = ctptr;
+
+            /* The size of an extended segment must fit in 14 bits. */
+            if (ct_len > 0x3fff)
+                ct_len = 0x3fff;
+
+            memcpy(ctptr, ct_info->ext_segment, ct_info->ext_segment_len);
+            ctptr += ct_info->ext_segment_len;
+            ct_len -= ct_info->ext_segment_len;
         } else {
             if (ct_len < length)
                 return -1;
 
-            strcpy(ctptr, ct_info->charset->ct_sequence);
+            memcpy(ctptr, ct_info->ct_sequence, length);
             ctptr += length;
             ct_len -= length;
         }
     }
+
+    /* If the charset has side GL or GR, prepare remapping the characters
+       to the correct side. */
     if (charset->set_size) {
         min_ch = 0x20;
         max_ch = 0x7f;
-
         if (charset->set_size == 94) {
             max_ch--;
-        if (charset->char_size > 1 || side == XlcGR)
-            min_ch++;
+	    if (charset->char_size > 1 || side == XlcGR)
+		min_ch++;
         }
     }
 
-    while (csstr_len > 0 && ct_len > 0) {
-        if (charset->set_size) {
-            ch = *((unsigned char *) csptr) & 0x7f;
-            if (ch < min_ch || ch > max_ch)
-                if (ch != 0x00 && ch != 0x09 && ch != 0x0a && ch != 0x1b) {
+    /* Actually copy the contents. */
+    unconv_num = 0;
+    char_size = charset->char_size;
+    if (char_size == 1) {
+	while (csstr_len > 0 && ct_len > 0) {
+	    if (charset->set_size) {
+		/* The CompoundText specification says that the only
+		   control characters allowed are 0x09, 0x0a, 0x1b, 0x9b.
+		   Therefore here we eliminate other control characters. */
+		unsigned char ch = *((unsigned char *) csptr) & 0x7f;
+		if (!((ch >= min_ch && ch <= max_ch)
+		      || (side == XlcGL
+			  && (ch == 0x00 || ch == 0x09 || ch == 0x0a))
+		      || ((side == XlcGL || side == XlcGR)
+			  && (ch == 0x1b)))) {
                     csptr++;
                     csstr_len--;
-                    continue;	/* XXX */
-                }
+		    unconv_num++;
+                    continue;
+ 		}
+	    }
+
+	    if (side == XlcGL)
+		*ctptr++ = *csptr++ & 0x7f;
+	    else if (side == XlcGR)
+		*ctptr++ = *csptr++ | 0x80;
+	    else
+		*ctptr++ = *csptr++;
+	    csstr_len--;
+	    ct_len--;
+	}
+    } else if (char_size > 1) {
+	while (csstr_len >= char_size && ct_len >= char_size) {
+	    if (side == XlcGL) {
+		int i;
+		for (i = char_size; i > 0; i--)
+		    *ctptr++ = *csptr++ & 0x7f;
+	    } else if (side == XlcGR) {
+		int i;
+		for (i = char_size; i > 0; i--)
+		    *ctptr++ = *csptr++ | 0x80;
+	    } else {
+		int i;
+		for (i = char_size; i > 0; i--)
+		    *ctptr++ = *csptr++;
+	    }
+	    csstr_len -= char_size;
+	    ct_len -= char_size;
+	}
+    } else {
+        /* char_size = 0. The code here is good only for valid UTF-8 input. */
+        if ((charset->ct_sequence[0] == XctESC
+             && charset->ct_sequence[1] == XctOtherCoding
+             && charset->ct_sequence[2] == 'G')
+#if UTF8_IN_EXTSEQ
+            || strcmp(charset->name, "ISO10646-1") == 0
+#endif
+           ) {
+            while (csstr_len > 0 && ct_len > 0) {
+                unsigned char ch = * (unsigned char *) csptr;
+                int char_size = (ch < 0xc0 ? 1 :
+                                 ch < 0xe0 ? 2 :
+                                 ch < 0xf0 ? 3 :
+                                 ch < 0xf8 ? 4 :
+                                 ch < 0xfc ? 5 :
+                                             6);
+                int i;
+                if (!(csstr_len >= char_size && ct_len >= char_size))
+                    break;
+                for (i = char_size; i > 0; i--)
+                    *ctptr++ = *csptr++;
+                csstr_len -= char_size;
+                ct_len -= char_size;
+            }
+        } else {
+            while (csstr_len > 0 && ct_len > 0) {
+                *ctptr++ = *csptr++;
+                csstr_len--;
+                ct_len--;
+            }
         }
+    }
 
-        if (side == XlcGL)
-            *ctptr++ = *csptr++ & 0x7f;
-        else if (side == XlcGR)
-            *ctptr++ = *csptr++ | 0x80;
-        else
-            *ctptr++ = *csptr++;
-        csstr_len--;
-        ct_len--;
-    }
-
-    if (side == XlcGR || side == XlcGLGR)
-        state->GR_charset = charset;
-    if (side == XlcGL || side == XlcGLGR)
-        state->GL_charset = charset;
+    if (ct_info->type == XctOtherCoding) {
+        /* Terminate with an XctReturn sequence. */
+        ctptr[0] = XctESC;
+        ctptr[1] = XctOtherCoding;
+        ctptr[2] = '@';
+        ctptr += 3;
+    } else if (ext_segment_start != NULL) {
+        /* Backpatch the extended segment's length. */
+        int ext_segment_length = ctptr - ext_segment_start;
+        *(ext_segment_start - 2) = (ext_segment_length >> 7) | 0x80;
+        *(ext_segment_start - 1) = (ext_segment_length & 0x7f) | 0x80;
+    } else {
+        if (side == XlcGR || side == XlcGLGR)
+            state->GR_charset = charset;
+        if (side == XlcGL || side == XlcGLGR)
+            state->GL_charset = charset;
+    }
 
-    *from_left -= csptr - *((char **) from);
+    *from_left -= csptr - *((const char **) from);
     *from = (XPointer) csptr;
 
     *to_left -= ctptr - *((char **) to);
@@ -726,21 +1060,22 @@
 /* from XlcNString to XlcNCharSet */
 
 static int
-strtocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+strtocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
-    register char *src, *dst;
+    const char *src;
+    char *dst;
     unsigned char side;
-    register int length;
+    int length;
 
-    src = (char *) *from;
+    src = (const char *) *from;
     dst = (char *) *to;
 
     length = min(*from_left, *to_left);
@@ -749,7 +1084,7 @@
     while (side == (*((unsigned char *) src) & 0x80) && length-- > 0)
 	*dst++ = *src++;
     
-    *from_left -= src - (char *) *from;
+    *from_left -= src - (const char *) *from;
     *from = (XPointer) src;
     *to_left -= dst - (char *) *to;
     *to = (XPointer) dst;
@@ -763,34 +1098,40 @@
 /* from XlcNCharSet to XlcNString */
 
 static int
-cstostr(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstostr(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
-    char *csptr, *string_ptr;
+    const char *csptr;
+    char *string_ptr;
     int csstr_len, str_len;
     unsigned char ch;
     int unconv_num = 0;
 
-    if (num_args < 1 || (state->GL_charset != (XlcCharSet) args[0] &&
-	state->GR_charset != (XlcCharSet) args[0]))
+    /* This converter can only convert from ISO8859-1:GL and ISO8859-1:GR. */
+    if (num_args < 1
+	|| !((XlcCharSet) args[0] == state->GL_charset
+	     || (XlcCharSet) args[0] == state->GR_charset))
 	return -1;
     
-    csptr = *((char **) from);
+    csptr = *((const char **) from);
     string_ptr = *((char **) to);
     csstr_len = *from_left;
     str_len = *to_left;
 
-    while (csstr_len-- > 0 && str_len > 0) {
+    while (csstr_len > 0 && str_len > 0) {
 	ch = *((unsigned char *) csptr++);
-	if ((ch < 0x20 && ch != 0x00 && ch != 0x09 && ch != 0x0a) ||
-	    ch == 0x7f || ((ch & 0x80) && ch < 0xa0)) {
+	csstr_len--;
+	/* Citing ICCCM: "STRING as a type specifies the ISO Latin-1 character
+	   set plus the control characters TAB and NEWLINE." */
+	if ((ch < 0x20 && ch != 0x00 && ch != 0x09 && ch != 0x0a)
+	    || (ch >= 0x7f && ch < 0xa0)) {
 	    unconv_num++;
 	    continue;
 	}
@@ -798,7 +1139,7 @@
 	str_len--;
     }
 
-    *from_left -= csptr - *((char **) from);
+    *from_left -= csptr - *((const char **) from);
     *from = (XPointer) csptr;
 
     *to_left -= string_ptr - *((char **) to);
@@ -809,10 +1150,10 @@
 
 
 static XlcConv
-create_conv(methods)
-    XlcConvMethods methods;
+create_conv(
+    XlcConvMethods methods)
 {
-    register XlcConv conv;
+    XlcConv conv;
 
     conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + sizeof(StateRec));
     if (conv == NULL)
@@ -828,8 +1169,8 @@
 }
 
 static void
-close_converter(conv)
-    XlcConv conv;
+close_converter(
+    XlcConv conv)
 {
     /* conv->state is allocated together with conv, free both at once.  */
     Xfree((char *) conv);
@@ -840,14 +1181,14 @@
     close_converter,
     cttocs,
     init_state
-} ;
+};
 
 static XlcConv
-open_cttocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cttocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(&cttocs_methods);
 }
@@ -857,14 +1198,14 @@
     close_converter,
     cstoct,
     init_state
-} ;
+};
 
 static XlcConv
-open_cstoct(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstoct(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(&cstoct_methods);
 }
@@ -874,14 +1215,14 @@
     close_converter,
     strtocs,
     init_state
-} ;
+};
 
 static XlcConv
-open_strtocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_strtocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(&strtocs_methods);
 }
@@ -891,14 +1232,14 @@
     close_converter,
     cstostr,
     init_state
-} ;
+};
 
 static XlcConv
-open_cstostr(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstostr(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(&cstostr_methods);
 }
@@ -918,11 +1259,12 @@
 
 	num = sizeof(default_ct_data) / sizeof(CTDataRec);
 	for (ct_data = default_ct_data; num > 0; ct_data++, num--) {
-	    charset = _XlcAddCT(ct_data->name, ct_data->encoding);
+	    charset = _XlcAddCT(ct_data->name, ct_data->ct_sequence);
             if (charset == NULL)
                 continue;
             charset->source = CSsrcStd;
 	}
+
         /* Register CompoundText and CharSet converters.  */
 
         _XlcSetConverter((XLCd) NULL, XlcNCompoundText,
Index: xc/lib/X11/lcCharSet.c
diff -u xc/lib/X11/lcCharSet.c:3.5 xc/lib/X11/lcCharSet.c:3.7
--- xc/lib/X11/lcCharSet.c:3.5	Mon Feb 28 22:09:04 2000
+++ xc/lib/X11/lcCharSet.c	Mon Dec  4 13:49:26 2000
@@ -23,56 +23,15 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/lcCharSet.c,v 3.5 2000/02/29 03:09:04 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcCharSet.c,v 3.7 2000/12/04 18:49:26 dawes Exp $ */
 
 #include <stdio.h>
 #include "Xlibint.h"
 #include "XlcPublic.h"
+#include "XlcPubI.h"
 
-/* EXTERNS */
-/* lcCt.c */
-extern Bool _XlcParseCharSet(
-#if NeedFunctionPrototypes
-    XlcCharSet /* charset */
-#endif
-);
-
-#if NeedVarargsPrototypes
-char *
-_XlcGetCSValues(XlcCharSet charset, ...)
-#else
-char *
-_XlcGetCSValues(charset, va_alist)
-    XlcCharSet charset;
-    va_dcl
-#endif
-{
-    va_list var;
-    XlcArgList args;
-    char *ret;
-    int num_args;
+/* The list of all known XlcCharSets. They are identified by their name. */
 
-    Va_start(var, charset);
-    _XlcCountVaList(var, &num_args);
-    va_end(var);
-
-    Va_start(var, charset);
-    _XlcVaToArgList(var, num_args, &args);
-    va_end(var);
-
-    if (args == (XlcArgList) NULL)
-	return (char *) NULL;
-    
-    if (charset->get_values)
-	ret = (*charset->get_values)(charset, args, num_args);
-    else
-	ret = args->name;
-
-    Xfree(args);
-
-    return ret;
-}
-
 typedef struct _XlcCharSetListRec {
     XlcCharSet charset;
     struct _XlcCharSetListRec *next;
@@ -80,9 +39,11 @@
 
 static XlcCharSetList charset_list = NULL;
 
+/* Returns the charset with the given name (including side suffix).
+   Returns NULL if not found. */
 XlcCharSet
-_XlcGetCharSet(name)
-    _Xconst char *name;
+_XlcGetCharSet(
+    const char *name)
 {
     XlcCharSetList list;
     XrmQuark xrm_name;
@@ -97,10 +58,13 @@
     return (XlcCharSet) NULL;
 }
 
+/* Returns the charset with the given encoding (no side suffix) and
+   responsible for at least the given side (XlcGL or XlcGR).
+   Returns NULL if not found. */
 XlcCharSet
-_XlcGetCharSetWithSide(encoding_name, side)
-    _Xconst char *encoding_name;
-    XlcSide side;
+_XlcGetCharSetWithSide(
+    const char *encoding_name,
+    XlcSide side)
 {
     XlcCharSetList list;
     XrmQuark xrm_encoding_name;
@@ -116,9 +80,11 @@
     return (XlcCharSet) NULL;
 }
 
+/* Registers an XlcCharSet in the list of character sets.
+   Returns True if successful. */
 Bool
-_XlcAddCharSet(charset)
-    XlcCharSet charset;
+_XlcAddCharSet(
+    XlcCharSet charset)
 {
     XlcCharSetList list;
 
@@ -136,6 +102,7 @@
     return True;
 }
 
+/* List of resources for XlcCharSet. */
 static XlcResource resources[] = {
     { XlcNName, NULLQUARK, sizeof(char *),
       XOffsetOf(XlcCharSetRec, name), XlcGetMask },
@@ -151,11 +118,14 @@
       XOffsetOf(XlcCharSetRec, ct_sequence), XlcGetMask }
 };
 
+/* Retrieves a number of attributes of an XlcCharSet.
+   Return NULL if successful, otherwise the name of the first argument
+   specifiying a nonexistent attribute. */
 static char *
-get_values(charset, args, num_args)
-    register XlcCharSet charset;
-    register XlcArgList args;
-    register int num_args;
+get_values(
+    XlcCharSet charset,
+    XlcArgList args,
+    int num_args)
 {
     if (resources[0].xrm_name == NULLQUARK)
 	_XlcCompileResourceList(resources, XlcNumber(resources));
@@ -164,39 +134,84 @@
 			 args, num_args, XlcGetMask);
 }
 
+/* Retrieves a number of attributes of an XlcCharSet.
+   Return NULL if successful, otherwise the name of the first argument
+   specifiying a nonexistent attribute. */
+#if NeedVarargsPrototypes
+char *
+_XlcGetCSValues(XlcCharSet charset, ...)
+#else
+char *
+_XlcGetCSValues(charset, va_alist)
+    XlcCharSet charset;
+    va_dcl
+#endif
+{
+    va_list var;
+    XlcArgList args;
+    char *ret;
+    int num_args;
+
+    Va_start(var, charset);
+    _XlcCountVaList(var, &num_args);
+    va_end(var);
+
+    Va_start(var, charset);
+    _XlcVaToArgList(var, num_args, &args);
+    va_end(var);
+
+    if (args == (XlcArgList) NULL)
+	return (char *) NULL;
+    
+    ret = get_values(charset, args, num_args);
+
+    Xfree(args);
+
+    return ret;
+}
+
+/* Creates a new XlcCharSet, given its name (including side suffix) and
+   Compound Text ESC sequence (normally at most 4 bytes). */
 XlcCharSet
-_XlcCreateDefaultCharSet(name, ct_sequence)
-    _Xconst char *name;
-    _Xconst char *ct_sequence;
+_XlcCreateDefaultCharSet(
+    const char *name,
+    const char *ct_sequence)
 {
     XlcCharSet charset;
-    _Xconst char *colon;
+    int name_len, ct_sequence_len;
+    const char *colon;
+    char *tmp;
 
     charset = (XlcCharSet) Xmalloc(sizeof(XlcCharSetRec));
     if (charset == NULL)
 	return (XlcCharSet) NULL;
     bzero((char *) charset, sizeof(XlcCharSetRec));
 
+    name_len = strlen(name);
+    ct_sequence_len = strlen(ct_sequence);
+
     /* Fill in name and xrm_name.  */
-    charset->name = (char *) Xmalloc(strlen(name) + strlen(ct_sequence) + 2);
-    if (charset->name == NULL) {
+    tmp = (char *) Xmalloc(name_len + 1 + ct_sequence_len + 1);
+    if (tmp == NULL) {
 	Xfree((char *) charset);
 	return (XlcCharSet) NULL;
     }
-    strcpy(charset->name, name);
+    memcpy(tmp, name, name_len+1);
+    charset->name = tmp;
     charset->xrm_name = XrmStringToQuark(charset->name);
 
     /* Fill in encoding_name and xrm_encoding_name.  */
     if ((colon = strchr(charset->name, ':')) != NULL) {
         unsigned int length = colon - charset->name;
-        charset->encoding_name = (char *) Xmalloc(length + 1);
-        if (charset->encoding_name == NULL) {
+        char *encoding_tmp = (char *) Xmalloc(length + 1);
+        if (encoding_tmp == NULL) {
             Xfree((char *) charset->name);
             Xfree((char *) charset);
             return (XlcCharSet) NULL;
         }
-        strncpy(charset->encoding_name, charset->name, length);
-        charset->encoding_name[length] = '\0';
+        memcpy(encoding_tmp, charset->name, length);
+        encoding_tmp[length] = '\0';
+        charset->encoding_name = encoding_tmp;
         charset->xrm_encoding_name = XrmStringToQuark(charset->encoding_name);
     } else {
         charset->encoding_name = charset->name;
@@ -204,12 +219,14 @@
     }
 
     /* Fill in ct_sequence.  */
-    charset->ct_sequence = charset->name + strlen(name) + 1;
-    strcpy(charset->ct_sequence, ct_sequence);
-
-    charset->get_values = get_values;
-
-    _XlcParseCharSet(charset);
+    tmp += name_len + 1;
+    memcpy(tmp, ct_sequence, ct_sequence_len+1);
+    charset->ct_sequence = tmp;
+
+    /* Fill in side, char_size, set_size. */
+    if (!_XlcParseCharSet(charset))
+        /* If ct_sequence is not usable in Compound Text, remove it. */
+        charset->ct_sequence = "";
 
     return (XlcCharSet) charset;
 }
Index: xc/lib/X11/lcConv.c
diff -u xc/lib/X11/lcConv.c:1.3 xc/lib/X11/lcConv.c:1.5
--- xc/lib/X11/lcConv.c:1.3	Fri Feb 11 21:54:10 2000
+++ xc/lib/X11/lcConv.c	Mon Dec  4 13:49:26 2000
@@ -23,46 +23,40 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/lcConv.c,v 1.3 2000/02/12 02:54:10 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcConv.c,v 1.5 2000/12/04 18:49:26 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XlcPubI.h"
 #include <stdio.h>
 
-#if NeedFunctionPrototypes
-typedef XlcConv (*XlcConverter)(XLCd, char *, XLCd, char *);
-#else
-typedef XlcConv (*XlcConverter)();
-#endif
-
 typedef struct _XlcConverterListRec {
     XLCd from_lcd;
-    char *from;
+    const char *from;
     XrmQuark from_type;
     XLCd to_lcd;
-    char *to;
+    const char *to;
     XrmQuark to_type;
-    XlcConverter converter;
+    XlcOpenConverterProc converter;
     struct _XlcConverterListRec *next;
 } XlcConverterListRec, *XlcConverterList;
 
 static XlcConverterList conv_list = NULL;
 
 static void
-close_converter(conv)
-    XlcConv conv;
+close_converter(
+    XlcConv conv)
 {
     (*conv->methods->close)(conv);
 }
 
 static XlcConv
-get_converter(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    XrmQuark from_type;
-    XLCd to_lcd;
-    XrmQuark to_type;
+get_converter(
+    XLCd from_lcd,
+    XrmQuark from_type,
+    XLCd to_lcd,
+    XrmQuark to_type)
 {
-    register XlcConverterList list, prev = NULL;
+    XlcConverterList list, prev = NULL;
 
     for (list = conv_list; list; list = list->next) {
 	if (list->from_lcd == from_lcd && list->to_lcd == to_lcd 
@@ -79,20 +73,20 @@
 
 	prev = list;
     }
-    
+
     return (XlcConv) NULL;
 }
 
 Bool
-_XlcSetConverter(from_lcd, from, to_lcd, to, converter)
-    XLCd from_lcd;
-    char *from;
-    XLCd to_lcd;
-    char *to;
-    XlcOpenConverterProc converter;
+_XlcSetConverter(
+    XLCd from_lcd,
+    const char *from,
+    XLCd to_lcd,
+    const char *to,
+    XlcOpenConverterProc converter)
 {
-    register XlcConverterList list;
-    register XrmQuark from_type, to_type;
+    XlcConverterList list;
+    XrmQuark from_type, to_type;
 
     from_type = XrmStringToQuark(from);
     to_type = XrmStringToQuark(to);
@@ -109,7 +103,7 @@
     list = (XlcConverterList) Xmalloc(sizeof(XlcConverterListRec));
     if (list == NULL)
 	return False;
-    
+
     list->from_lcd = from_lcd;
     list->from = from;
     list->from_type = from_type;
@@ -129,14 +123,14 @@
 } ConvRec, *Conv;
 
 static int
-indirect_convert(lc_conv, from, from_left, to, to_left, args, num_args)
-    XlcConv lc_conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+indirect_convert(
+    XlcConv lc_conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     Conv conv = (Conv) lc_conv->state;
     XlcConv from_conv = conv->from_conv;
@@ -166,28 +160,35 @@
 	if (ret < 0)
 	    break;
 
-	length = cs_left = cs - buf;
-	cs = buf;
+	unconv_num += ret;
 
-	tmp_args[0] = (XPointer) charset;
+	length = cs - buf;
+	if (length > 0) {
+	    cs_left = length;
+	    cs = buf;
+
+	    tmp_args[0] = (XPointer) charset;
+
+	    ret = (*to_conv->methods->convert)(to_conv, &cs, &cs_left, to, to_left,
+					       tmp_args, 1);
+	    if (ret < 0) {
+		unconv_num += length / (charset->char_size > 0 ? charset->char_size : 1);
+		continue;
+	    }
+
+	    unconv_num += ret;
 
-	ret = (*to_conv->methods->convert)(to_conv, &cs, &cs_left, to, to_left,
-					   tmp_args, 1);
-	if (ret < 0) {
-	    unconv_num += length / charset->char_size;
-	    continue;
+	    if (*to_left < 1)
+		break;
 	}
-	
-	if (*to_left < 1)
-	    break;
     }
 
     return unconv_num;
 }
 
 static void
-close_indirect_converter(lc_conv)
-    XlcConv lc_conv;
+close_indirect_converter(
+    XlcConv lc_conv)
 {
     Conv conv = (Conv) lc_conv->state;
 
@@ -204,8 +205,8 @@
 }
 
 static void
-reset_indirect_converter(lc_conv)
-    XlcConv lc_conv;
+reset_indirect_converter(
+    XlcConv lc_conv)
 {
     Conv conv = (Conv) lc_conv->state;
 
@@ -224,11 +225,11 @@
 } ;
 
 static XlcConv
-open_indirect_converter(from_lcd, from, to_lcd, to)
-    XLCd from_lcd;
-    char *from;
-    XLCd to_lcd;
-    char *to;
+open_indirect_converter(
+    XLCd from_lcd,
+    const char *from,
+    XLCd to_lcd,
+    const char *to)
 {
     XlcConv lc_conv, from_conv, to_conv;
     Conv conv;
@@ -251,13 +252,13 @@
     lc_conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
     if (lc_conv == NULL)
 	return (XlcConv) NULL;
-    
+
     lc_conv->methods = &conv_methods;
 
     lc_conv->state = (XPointer) Xcalloc(1, sizeof(ConvRec));
     if (lc_conv->state == NULL)
 	goto err;
-    
+
     conv = (Conv) lc_conv->state;
 
     from_conv = get_converter(from_lcd, from_type, from_lcd, QCTCharSet);
@@ -289,11 +290,11 @@
 }
 
 XlcConv
-_XlcOpenConverter(from_lcd, from, to_lcd, to)
-    XLCd from_lcd;
-    char *from;
-    XLCd to_lcd;
-    char *to;
+_XlcOpenConverter(
+    XLCd from_lcd,
+    const char *from,
+    XLCd to_lcd,
+    const char *to)
 {
     XlcConv conv;
     XrmQuark from_type, to_type;
@@ -301,36 +302,36 @@
     from_type = XrmStringToQuark(from);
     to_type = XrmStringToQuark(to);
 
-    if ((conv = get_converter(from_lcd, from_type, to_lcd, to_type)))
+    if ((conv = get_converter(from_lcd, from_type, to_lcd, to_type)) != NULL)
 	return conv;
-    
+
     return open_indirect_converter(from_lcd, from, to_lcd, to);
 }
 
 void
-_XlcCloseConverter(conv)
-    XlcConv conv;
+_XlcCloseConverter(
+    XlcConv conv)
 {
     close_converter(conv);
 }
 
 int
-_XlcConvert(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+_XlcConvert(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     return (*conv->methods->convert)(conv, from, from_left, to, to_left, args,
 				     num_args);
 }
 
 void
-_XlcResetConverter(conv)
-    XlcConv conv;
+_XlcResetConverter(
+    XlcConv conv)
 {
     if (conv->methods->reset)
 	(*conv->methods->reset)(conv);
Index: xc/lib/X11/lcDB.c
diff -u xc/lib/X11/lcDB.c:3.11 xc/lib/X11/lcDB.c:3.12
--- xc/lib/X11/lcDB.c:3.11	Sat Jan 29 13:58:16 2000
+++ xc/lib/X11/lcDB.c	Tue Nov 28 13:49:41 2000
@@ -28,7 +28,7 @@
  *  This is source code modified by FUJITSU LIMITED under the Joint
  *  Development Agreement for the CDE/Motif PST.
  */
-/* $XFree86: xc/lib/X11/lcDB.c,v 3.11 2000/01/29 18:58:16 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcDB.c,v 3.12 2000/11/28 18:49:41 dawes Exp $ */
 
 
 
@@ -96,21 +96,22 @@
 
 typedef struct {
     Token token;	/* token id */
-    char *name;		/* token sequence */
+    const char *name;	/* token sequence */
     int len;		/* length of token sequence */
-    int (*parse_proc)(); /* parsing procedure */
+    int (*parse_proc)(const char *str, Token token, Database *db);
+			/* parsing procedure */
 } TokenTable;
 
-static int f_newline();
-static int f_comment();
-static int f_semicolon();
-static int f_double_quote();
-static int f_left_brace();
-static int f_right_brace();
-static int f_white();
-static int f_backslash();
-static int f_numeric();
-static int f_default();
+static int f_newline (const char *str, Token token, Database *db);
+static int f_comment (const char *str, Token token, Database *db);
+static int f_semicolon (const char *str, Token token, Database *db);
+static int f_double_quote (const char *str, Token token, Database *db);
+static int f_left_brace (const char *str, Token token, Database *db);
+static int f_right_brace (const char *str, Token token, Database *db);
+static int f_white (const char *str, Token token, Database *db);
+static int f_backslash (const char *str, Token token, Database *db);
+static int f_numeric (const char *str, Token token, Database *db);
+static int f_default (const char *str, Token token, Database *db);
 
 static TokenTable token_tbl[] = {
     { T_NEWLINE,	"\n",	1,	f_newline },
@@ -159,11 +160,12 @@
 
 static DBParseInfo parse_info;
 
-static void init_parse_info()
+static void
+init_parse_info (void)
 {
     static int allocated /* = 0 */;
     char *ptr;
-    int  size;
+    int size;
     if (!allocated) {
 	bzero(&parse_info, sizeof(DBParseInfo));
 	parse_info.buf = (char *)Xmalloc(BUFSIZE);
@@ -179,22 +181,22 @@
 }
 
 static void
-clear_parse_info()
+clear_parse_info (void)
 {
     int i;
     char *ptr;
     int size;
     parse_info.pre_state = S_NULL;
-    if(parse_info.category != NULL){
+    if (parse_info.category != NULL) {
 	Xfree(parse_info.category);
     }
-    for(i = 0; i <= parse_info.nest_depth; ++i){
-	if(parse_info.name[i]){
+    for (i = 0; i <= parse_info.nest_depth; ++i) {
+	if (parse_info.name[i]) {
 	    Xfree(parse_info.name[i]);
 	}
     }
-    if(parse_info.value){
-	if(*parse_info.value){
+    if (parse_info.value) {
+	if (*parse_info.value) {
 	    Xfree(*parse_info.value);
 	}
 	Xfree((char *)parse_info.value);
@@ -207,23 +209,22 @@
 }
 
 static Bool
-realloc_parse_info(len)
-int len;
+realloc_parse_info(
+    int len)
 {
     char *p;
 
-
-    parse_info.bufMaxSize = BUFSIZE * 
-	    ((parse_info.bufsize + len)/BUFSIZE + 1);
+    parse_info.bufMaxSize = BUFSIZE * ((parse_info.bufsize + len)/BUFSIZE + 1);
     p = (char *)Xrealloc(parse_info.buf, parse_info.bufMaxSize);
-    if(p == NULL){
-        return(False);
-    }
+    if (p == NULL)
+        return False;
     parse_info.buf = p;
 
-    return(True);
+    return True;
 }
+
 /************************************************************************/
+
 typedef struct _Line {
     char *str;
     int cursize;
@@ -232,28 +233,28 @@
 } Line;
 
 static void
-free_line(line)
-    Line *line;
+free_line(
+    Line *line)
 {
-    if(line->str != NULL){
+    if (line->str != NULL) {
 	Xfree(line->str);
     }
     bzero(line, sizeof(Line));
 }
 
 static int
-realloc_line(line, size)
-    Line *line;
-    int size;
+realloc_line(
+    Line *line,
+    int size)
 {
     char *str = line->str;
 
-    if(str != NULL){
+    if (str != NULL) {
 	str = (char *)Xrealloc(str, size);
-    }else{
+    } else {
 	str = (char *)Xmalloc(size);
     }
-    if(str == NULL){
+    if (str == NULL) {
 	/* malloc error */
 	if (line->str != NULL) {
 	    Xfree(line->str);
@@ -269,34 +270,34 @@
 #define	iswhite(ch)	((ch) == SYM_SPACE   || (ch) == SYM_TAB)
 
 static void
-zap_comment(str, quoted)
-    char *str;
-    int *quoted;
+zap_comment(
+    char *str,
+    int *quoted)
 {
     char *p = str;
 #ifdef	never
     *quoted = 0;
-    if(*p == SYM_COMMENT){
+    if (*p == SYM_COMMENT) {
 	int len = strlen(str);
-	if(p[len - 1] == SYM_NEWLINE || p[len - 1] == SYM_CR){
+	if (p[len - 1] == SYM_NEWLINE || p[len - 1] == SYM_CR) {
 	    *p++ = SYM_NEWLINE;
 	}
 	*p = '\0';
     }
 #else
-    while(*p){
-	if(*p == SYM_DOUBLE_QUOTE){
-	    if(p == str || p[-1] != SYM_BACKSLASH){
+    while (*p) {
+	if (*p == SYM_DOUBLE_QUOTE) {
+	    if (p == str || p[-1] != SYM_BACKSLASH) {
 		/* unescaped double quote changes quoted state. */
 		*quoted = *quoted ? 0 : 1;
 	    }
 	}
-	if(*p == SYM_COMMENT && !*quoted){
+	if (*p == SYM_COMMENT && !*quoted) {
 	    int pos = p - str;
-	    if(pos == 0 ||
-	       (iswhite(p[-1]) && (pos == 1 || p[-2] != SYM_BACKSLASH))) {
+	    if (pos == 0 ||
+	        (iswhite(p[-1]) && (pos == 1 || p[-2] != SYM_BACKSLASH))) {
 		int len = strlen(p);
-		if(len > 0 && (p[len - 1] == SYM_NEWLINE || p[len-1] == SYM_CR)) {
+		if (len > 0 && (p[len - 1] == SYM_NEWLINE || p[len-1] == SYM_CR)) {
 		    /* newline is the identifier for finding end of value.
 		       therefore, it should not be removed. */
 		    *p++ = SYM_NEWLINE;
@@ -311,9 +312,9 @@
 }
 
 static int
-read_line(fd, line)
-    FILE *fd;
-    Line *line;
+read_line(
+    FILE *fd,
+    Line *line)
 {
     char buf[BUFSIZE], *p;
     int len;
@@ -324,19 +325,19 @@
     str = line->str;
     cur = line->cursize = 0;
 
-    while((p = fgets(buf, BUFSIZE, fd)) != NULL){
+    while ((p = fgets(buf, BUFSIZE, fd)) != NULL) {
 	++line->seq;
 	zap_comment(p, &quoted);	/* remove comment line */
 	len = strlen(p);
-	if(len == 0){
-	    if(cur > 0){
+	if (len == 0) {
+	    if (cur > 0) {
 		break;
 	    }
 	    continue;
 	}
-	if(cur + len + 1 > line->maxsize){
+	if (cur + len + 1 > line->maxsize) {
 	    /* need to reallocate buffer. */
-	    if(! realloc_line(line, line->maxsize + BUFSIZE)){
+	    if (! realloc_line(line, line->maxsize + BUFSIZE)) {
 		return -1;	/* realloc error. */
 	    }
 	    str = line->str;
@@ -346,27 +347,27 @@
 	cur += len;
 	str[cur] = '\0';
 #ifdef __EMX__  /* Take out carriage returns under OS/2 */
-	if(cur>1) {
-	   if(str[cur-2] == '\r' && str[cur-1] == '\n'){
+	if (cur>1) {
+	   if (str[cur-2] == '\r' && str[cur-1] == '\n') {
 	      str[cur-2] = '\n';
 	      str[cur-1] = '\0';
 	      cur--;
 	   }
 	}
 #endif
-	if(!quoted){
-	    if(cur > 1 && str[cur - 2] == SYM_BACKSLASH &&
-	       (str[cur - 1] == SYM_NEWLINE || str[cur-1] == SYM_CR)){
+	if (!quoted) {
+	    if (cur > 1 && str[cur - 2] == SYM_BACKSLASH &&
+	       (str[cur - 1] == SYM_NEWLINE || str[cur-1] == SYM_CR)) {
 		/* the line is ended backslash followed by newline.
 		   need to concatinate the next line. */
 		cur -= 2;
 		str[cur] = '\0';
-	    }else{
+	    } else {
 		break;
 	    }
 	}
     }
-    if(quoted){
+    if (quoted) {
 	/* error.  still in quoted state. */
 	return -1;
     }
@@ -376,21 +377,21 @@
 /************************************************************************/
 
 static Token
-get_token(str)
-    char *str;
+get_token(
+    const char *str)
 {
-    switch(*str){
+    switch (*str) {
     case SYM_NEWLINE:
-    case SYM_CR:	return T_NEWLINE;
-    case SYM_COMMENT:	return T_COMMENT;
-    case SYM_SEMICOLON:	return T_SEMICOLON;
+    case SYM_CR:		return T_NEWLINE;
+    case SYM_COMMENT:		return T_COMMENT;
+    case SYM_SEMICOLON:		return T_SEMICOLON;
     case SYM_DOUBLE_QUOTE:	return T_DOUBLE_QUOTE;
     case SYM_LEFT_BRACE:	return T_LEFT_BRACE;
     case SYM_RIGHT_BRACE:	return T_RIGHT_BRACE;
-    case SYM_SPACE:	return T_SPACE;
-    case SYM_TAB:	return T_TAB;
+    case SYM_SPACE:		return T_SPACE;
+    case SYM_TAB:		return T_TAB;
     case SYM_BACKSLASH:
-	switch(str[1]){
+	switch (str[1]) {
 	case 'x': return T_NUMERIC_HEX;
 	case 'd': return T_NUMERIC_DEC;
 	case 'o': return T_NUMERIC_OCT;
@@ -402,26 +403,25 @@
 }
 
 static int
-get_word(str, word)
-    char *str;
-    char *word;
+get_word(
+    const char *str,
+    char *word)
 {
-    char *p = str, *w = word;
+    const char *p = str;
+    char *w = word;
     Token token;
     int token_len;
 
-    while(*p != '\0'){
+    while (*p != '\0') {
 	token = get_token(p);
 	token_len = token_tbl[token].len;
-	if(token == T_BACKSLASH){
+	if (token == T_BACKSLASH) {
 	    p += token_len;
-	    if(*p == '\0'){
+	    if (*p == '\0')
 		break;
-	    }
 	    token = get_token(p);
 	    token_len = token_tbl[token].len;
-	}else if(token != T_COMMENT &&
-		 token != T_DEFAULT){
+	} else if (token != T_COMMENT && token != T_DEFAULT) {
 	    break;
 	}
 	strncpy(w, p, token_len);
@@ -432,27 +432,28 @@
 }
 
 static int
-get_quoted_word(str, word)
-    char *str;
-    char *word;
+get_quoted_word(
+    const char *str,
+    char *word)
 {
-    char *p = str, *w = word;
+    const char *p = str;
+    char *w = word;
     Token token;
     int token_len;
 
-    if(*p == SYM_DOUBLE_QUOTE){
+    if (*p == SYM_DOUBLE_QUOTE) {
 	++p;
     }
-    while(*p != '\0'){
+    while (*p != '\0') {
 	token = get_token(p);
 	token_len = token_tbl[token].len;
-	if(token == T_DOUBLE_QUOTE){
+	if (token == T_DOUBLE_QUOTE) {
 	    p += token_len;
 	    goto found;
 	}
-	if(token == T_BACKSLASH){
+	if (token == T_BACKSLASH) {
 	    p += token_len;
-	    if(*p == '\0'){
+	    if (*p == '\0') {
 		break;
 	    }
 	    token = get_token(p);
@@ -472,7 +473,7 @@
 /************************************************************************/
 
 static int
-append_value_list()
+append_value_list (void)
 {
     char **value_list = parse_info.value;
     char *value;
@@ -482,45 +483,44 @@
     int len = parse_info.bufsize;
     char *p;
 
-    if(len < 1){
+    if (len < 1) {
 	return 1; /* return with no error */
     }
 
-    if(value_list == (char **)NULL){
+    if (value_list == (char **)NULL) {
 	value_list = (char **)Xmalloc(sizeof(char *) * 2);
 	*value_list = NULL;
-    }else{
+    } else {
 	char **prev_list = value_list;
 
 	value_list = (char **)
 	    Xrealloc(value_list, sizeof(char *) * (value_num + 2));
-	if (value_list == NULL){
+	if (value_list == NULL) {
 	    Xfree(prev_list);
 	}
-    }
-    if(value_list == (char **)NULL){
-	goto err;
     }
+    if (value_list == (char **)NULL)
+	goto err2;
 
     value = *value_list;
-    if(value == NULL){
+    if (value == NULL) {
 	value = (char *)Xmalloc(value_len + len + 1);
-    }else{
+    } else {
 	char *prev_value = value;
 
 	value = (char *)Xrealloc(value, value_len + len + 1);
-	if (value == NULL){
+	if (value == NULL) {
 	    Xfree(prev_value);
 	}
     }
-    if(value == NULL){
-	goto err;
+    if (value == NULL) {
+	goto err1;
     }
-    if(value != *value_list){
+    if (value != *value_list) {
 	int delta, i;
 	delta = value - *value_list;
 	*value_list = value;
-	for(i = 1; i < value_num; ++i){
+	for (i = 1; i < value_num; ++i) {
 	    value_list[i] += delta;
 	}
     }
@@ -536,13 +536,14 @@
     parse_info.bufsize = 0;
     return 1;
 
- err:
-    if(value_list){
+ err1:
+    if (value_list) {
 	Xfree((char **)value_list);
     }
-    if(value){
+    if (value) {
 	Xfree(value);
     }
+ err2:
     parse_info.value = (char **)NULL;
     parse_info.value_num = 0;
     parse_info.value_len = 0;
@@ -551,14 +552,15 @@
 }
 
 static int 
-construct_name(name, size)
-    char *name;
-    int size;
+construct_name(
+    char *name,
+    int size)
 {
-    register int i, len = 0;
+    int i;
+    int len = 0;
     char *p = name;
 
-    for(i = 0; i <= parse_info.nest_depth; ++i){
+    for (i = 0; i <= parse_info.nest_depth; ++i) {
 	len += strlen(parse_info.name[i]) + 1;
     }
     if (len >= size)
@@ -566,7 +568,7 @@
 
     strcpy(p, parse_info.name[0]);
     p += strlen(parse_info.name[0]);
-    for(i = 1; i <= parse_info.nest_depth; ++i){
+    for (i = 1; i <= parse_info.nest_depth; ++i) {
 	*p++ = '.';
 	strcpy(p, parse_info.name[i]);
 	p += strlen(parse_info.name[i]);
@@ -575,39 +577,39 @@
 }
 
 static int
-store_to_database(db)
-    Database *db;
+store_to_database(
+    Database *db)
 {
     Database new = (Database)NULL;
     char name[BUFSIZE];
 
-    if(parse_info.pre_state == S_VALUE){
-	if(! append_value_list()){
+    if (parse_info.pre_state == S_VALUE) {
+	if (! append_value_list()) {
 	    goto err;
 	}
     }
 
-    if(parse_info.name[parse_info.nest_depth] == NULL){
+    if (parse_info.name[parse_info.nest_depth] == NULL) {
 	goto err;
     }
 
     new = (Database)Xmalloc(sizeof(DatabaseRec));
-    if(new == (Database)NULL){
+    if (new == (Database)NULL) {
 	goto err;
     }
     bzero(new, sizeof(DatabaseRec));
 
     new->category = (char *)Xmalloc(strlen(parse_info.category) + 1);
-    if(new->category == NULL){
+    if (new->category == NULL) {
 	goto err;
     }
     strcpy(new->category, parse_info.category);
 
-    if(! construct_name(name, sizeof(name))){
+    if (! construct_name(name, sizeof(name))) {
 	goto err;
     }
     new->name = (char *)Xmalloc(strlen(name) + 1);
-    if(new->name == NULL){
+    if (new->name == NULL) {
 	goto err;
     }
     strcpy(new->name, name);
@@ -626,16 +628,16 @@
     return 1;
 
  err:
-    if(new){
-	if(new->category){
+    if (new) {
+	if (new->category) {
 	    Xfree(new->category);
 	}
-	if(new->name){
+	if (new->name) {
 	    Xfree(new->name);
 	}
     }
-    if(parse_info.value){
-	if(*parse_info.value){
+    if (parse_info.value) {
+	if (*parse_info.value) {
 	    Xfree(*parse_info.value);
 	}
 	Xfree((char **)parse_info.value);
@@ -650,23 +652,23 @@
 #define	END_MARK_LEN	3 /*strlen(END_MARK)*/
 
 static int
-check_category_end(str)
-    char *str;
+check_category_end(
+    const char *str)
 {
-    char *p;
+    const char *p;
     int len;
 
     p = str;
-    if(strncmp(p, END_MARK, END_MARK_LEN)){
+    if (strncmp(p, END_MARK, END_MARK_LEN)) {
 	return 0;
     }
     p += END_MARK_LEN;
 
-    while(iswhite(*p)){
+    while (iswhite(*p)) {
 	++p;
     }
     len = strlen(parse_info.category);
-    if(strncmp(p, parse_info.category, len)){
+    if (strncmp(p, parse_info.category, len)) {
 	return 0;
     }
     p += len;
@@ -676,19 +678,19 @@
 /************************************************************************/
 
 static int
-f_newline(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_newline(
+    const char *str,
+    Token token,
+    Database *db)
 {
-    switch(parse_info.pre_state){
+    switch (parse_info.pre_state) {
     case S_NULL:
     case S_CATEGORY:
 	break;
     case S_NAME:
 	return 0; /* no value */
     case S_VALUE:
-	if(!store_to_database(db))
+	if (!store_to_database(db))
 	    return 0;
 	parse_info.pre_state = S_CATEGORY;
 	break;
@@ -699,49 +701,49 @@
 }
 
 static int
-f_comment(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_comment(
+    const char *str,
+    Token token,
+    Database *db)
 {
     /* NOTE: comment is already handled in read_line(),
        so this function is not necessary. */
 
-    char *p = str;
+    const char *p = str;
 
-    while(*p != SYM_NEWLINE && *p != SYM_CR && *p != '\0'){
+    while (*p != SYM_NEWLINE && *p != SYM_CR && *p != '\0') {
 	++p;	/* zap to the end of line */
     }
     return p - str;
 }
 
 static int
-f_white(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_white(
+    const char *str,
+    Token token,
+    Database *db)
 {
-    char *p = str;
+    const char *p = str;
 
-    while(iswhite(*p)){
+    while (iswhite(*p)) {
 	++p;
     }
     return p - str;
 }
 
 static int
-f_semicolon(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_semicolon(
+    const char *str,
+    Token token,
+    Database *db)
 {
-    switch(parse_info.pre_state){
+    switch (parse_info.pre_state) {
     case S_NULL:
     case S_CATEGORY:
     case S_NAME:
 	return 0;
     case S_VALUE:
-	if(! append_value_list())
+	if (! append_value_list())
 	    return 0;
 	parse_info.pre_state = S_VALUE;
 	break;
@@ -752,19 +754,19 @@
 }
 
 static int
-f_left_brace(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_left_brace(
+    const char *str,
+    Token token,
+    Database *db)
 {
-    switch(parse_info.pre_state){
+    switch (parse_info.pre_state) {
     case S_NULL:
     case S_CATEGORY:
     case S_VALUE:
 	return 0;
     case S_NAME:
-	if(parse_info.name[parse_info.nest_depth] == NULL ||
-	   parse_info.nest_depth + 1 > MAX_NAME_NEST)
+	if (parse_info.name[parse_info.nest_depth] == NULL
+	    || parse_info.nest_depth + 1 > MAX_NAME_NEST)
 	    return 0;
 	++parse_info.nest_depth;
 	parse_info.pre_state = S_CATEGORY;
@@ -776,24 +778,24 @@
 }
 
 static int
-f_right_brace(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_right_brace(
+    const char *str,
+    Token token,
+    Database *db)
 {
-    if(parse_info.nest_depth < 1)
+    if (parse_info.nest_depth < 1)
 	return 0;
 
-    switch(parse_info.pre_state){
+    switch (parse_info.pre_state) {
     case S_NULL:
     case S_NAME:
 	return 0;
     case S_VALUE:
-	if(! store_to_database(db))
+	if (! store_to_database(db))
 	    return 0;
 	/* fall into next case */
     case S_CATEGORY:
-	if(parse_info.name[parse_info.nest_depth] != NULL){
+	if (parse_info.name[parse_info.nest_depth] != NULL) {
 	    Xfree(parse_info.name[parse_info.nest_depth]);
 	    parse_info.name[parse_info.nest_depth] = NULL;
 	}
@@ -807,10 +809,10 @@
 }
 
 static int
-f_double_quote(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_double_quote(
+    const char *str,
+    Token token,
+    Database *db)
 {
     char word[BUFSIZE];
     char* wordp;
@@ -824,18 +826,18 @@
 	return 0;
 
     len = 0;
-    switch(parse_info.pre_state){
+    switch (parse_info.pre_state) {
     case S_NULL:
     case S_CATEGORY:
 	goto err;
     case S_NAME:
     case S_VALUE:
 	len = get_quoted_word(str, wordp);
-	if(len < 1)
+	if (len < 1)
 	    goto err;
-	if( (parse_info.bufsize + (int)strlen(wordp) +1) 
-					>= parse_info.bufMaxSize){
-	    if(realloc_parse_info(strlen(wordp) +1) == False){
+	if ((parse_info.bufsize + (int)strlen(wordp) + 1) 
+					>= parse_info.bufMaxSize) {
+	    if (realloc_parse_info(strlen(wordp)+1) == False) {
 		goto err;
 	    }
 	}
@@ -846,30 +848,33 @@
     default:
 	goto err;
     }
-    if (wordp != word) Xfree (wordp);
+    if (wordp != word)
+	Xfree (wordp);
     return len;	/* including length of token */
 
 err:
-    if (wordp != word) Xfree (wordp);
+    if (wordp != word)
+	Xfree (wordp);
     return 0;
 }
 
 static int
-f_backslash(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_backslash(
+    const char *str,
+    Token token,
+    Database *db)
 {
     return f_default(str, token, db);
 }
 
 static int
-f_numeric(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_numeric(
+    const char *str,
+    Token token,
+    Database *db)
 {
-    char word[BUFSIZE], *p;
+    char word[BUFSIZE];
+    const char *p;
     char* wordp;
     int len;
     int token_len;
@@ -881,7 +886,7 @@
     if (wordp == NULL)
 	return 0;
 
-    switch(parse_info.pre_state){
+    switch (parse_info.pre_state) {
     case S_NULL:
     case S_CATEGORY:
 	goto err;
@@ -890,11 +895,11 @@
 	token_len = token_tbl[token].len;
 	p = str + token_len;
 	len = get_word(p, wordp);
-	if(len < 1)
+	if (len < 1)
 	    goto err;
-	if( (parse_info.bufsize + token_len + (int)strlen(wordp) +1) 
-					>= parse_info.bufMaxSize){
-	    if(realloc_parse_info(token_len + strlen(wordp) +1) == False)
+	if ((parse_info.bufsize + token_len + (int)strlen(wordp) + 1) 
+					>= parse_info.bufMaxSize) {
+	    if (realloc_parse_info(token_len + strlen(wordp) + 1) == False)
 		goto err;
 	}
 	strncpy(&parse_info.buf[parse_info.bufsize], str, token_len);
@@ -905,19 +910,21 @@
     default:
 	goto err;
     }
-    if (wordp != word) Xfree (wordp);
+    if (wordp != word)
+	Xfree (wordp);
     return len + token_len;
 
 err:
-    if (wordp != word) Xfree (wordp);
+    if (wordp != word)
+	Xfree (wordp);
     return 0;
 }
 
 static int
-f_default(str, token, db)
-    char *str;
-    Token token;
-    Database *db;
+f_default(
+    const char *str,
+    Token token,
+    Database *db)
 {
     char word[BUFSIZE], *p;
     char* wordp;
@@ -931,23 +938,23 @@
 	return 0;
 
     len = get_word(str, wordp);
-    if(len < 1)
+    if (len < 1)
 	goto err;
 
-    switch(parse_info.pre_state){
+    switch (parse_info.pre_state) {
     case S_NULL:
-	if(parse_info.category != NULL)
+	if (parse_info.category != NULL)
 	    goto err;
 	p = (char *)Xmalloc(strlen(wordp) + 1);
-	if(p == NULL)
+	if (p == NULL)
 	    goto err;
 	strcpy(p, wordp);
 	parse_info.category = p;
 	parse_info.pre_state = S_CATEGORY;
 	break;
     case S_CATEGORY:
-	if(parse_info.nest_depth == 0){
-	    if(check_category_end(str)){
+	if (parse_info.nest_depth == 0) {
+	    if (check_category_end(str)) {
 		/* end of category is detected.
 		   clear context and zap to end of this line */
 		clear_parse_info();
@@ -956,10 +963,10 @@
 	    }
 	}
 	p = (char *)Xmalloc(strlen(wordp) + 1);
-	if(p == NULL)
+	if (p == NULL)
 	    goto err;
 	strcpy(p, wordp);
-	if(parse_info.name[parse_info.nest_depth] != NULL){
+	if (parse_info.name[parse_info.nest_depth] != NULL) {
 	    Xfree(parse_info.name[parse_info.nest_depth]);
 	}
 	parse_info.name[parse_info.nest_depth] = p;
@@ -967,9 +974,9 @@
 	break;
     case S_NAME:
     case S_VALUE:
-	if( (parse_info.bufsize + (int)strlen(wordp) +1 ) 
-					>= parse_info.bufMaxSize){
-	    if(realloc_parse_info(strlen(wordp) +1) == False)
+	if ((parse_info.bufsize + (int)strlen(wordp) + 1) 
+					>= parse_info.bufMaxSize) {
+	    if (realloc_parse_info(strlen(wordp) + 1) == False)
 		goto err;
 	}
 	strcpy(&parse_info.buf[parse_info.bufsize], wordp);
@@ -979,30 +986,32 @@
     default:
 	goto err;
     }
-    if (wordp != word) Xfree (wordp);
+    if (wordp != word)
+	Xfree (wordp);
     return len;
 
 err:
-    if (wordp != word) Xfree (wordp);
+    if (wordp != word)
+	Xfree (wordp);
     return 0;
 }
 
 /************************************************************************/
 
-#ifdef	DEBUG
+#ifdef DEBUG
 static void
-PrintDatabase(db)
-    Database db;
+PrintDatabase(
+    Database db)
 {
     Database p = db;
     int i = 0, j;
 
     printf("***\n*** BEGIN Database\n***\n");
-    while(p){
+    while (p) {
 	printf("%3d: ", i++);
 	printf("%s, %s, ", p->category, p->name);
 	printf("\t[%d: ", p->value_num);
-	for(j = 0; j < p->value_num; ++j){
+	for (j = 0; j < p->value_num; ++j) {
 	    printf("%s, ", p->value[j]);
 	}
 	printf("]\n");
@@ -1013,20 +1022,20 @@
 #endif
 
 static void
-DestroyDatabase(db)
-    Database db;
+DestroyDatabase(
+    Database db)
 {
     Database p = db;
 
-    while(p){
-	if(p->category != NULL){
+    while (p) {
+	if (p->category != NULL) {
 	    Xfree(p->category);
 	}
-	if(p->name != NULL){
+	if (p->name != NULL) {
 	    Xfree(p->name);
 	}
-	if(p->value != (char **)NULL){
-	    if(*p->value != NULL){
+	if (p->value != (char **)NULL) {
+	    if (*p->value != NULL) {
 		Xfree(*p->value);
 	    }
 	    Xfree((char *)p->value);
@@ -1038,13 +1047,13 @@
 }
 
 static int
-CountDatabase(db)
-    Database db;
+CountDatabase(
+    Database db)
 {
     Database p = db;
     int cnt = 0;
 
-    while(p){
+    while (p) {
 	++cnt;
 	p = p->next;
     }
@@ -1052,8 +1061,8 @@
 }
 
 static Database
-CreateDatabase(dbfile)
-    char *dbfile;
+CreateDatabase(
+    char *dbfile)
 {
     Database db = (Database)NULL;
     FILE *fd;
@@ -1064,26 +1073,25 @@
     int error = 0;
 
     fd = _XFopenFile(dbfile, "r");
-    if(fd == (FILE *)NULL){
+    if (fd == (FILE *)NULL)
 	return NULL;
-    }
 
     bzero(&line, sizeof(Line));
     init_parse_info();
 
     do {
 	int rc = read_line(fd, &line);
-	if(rc < 0){
+	if (rc < 0) {
 	    error = 1;
 	    break;
-	}else if(rc == 0){
+	} else if (rc == 0) {
 	    break;
 	}
 	p = line.str;
-	while(*p){
+	while (*p) {
 	    token = get_token(p);
 	    len = (*token_tbl[token].parse_proc)(p, token, &db);
-	    if(len < 1){
+	    if (len < 1) {
 		error = 1;
 		break;
 	    }
@@ -1091,11 +1099,11 @@
 	}
     } while (!error);
 
-    if(parse_info.pre_state != S_NULL){
+    if (parse_info.pre_state != S_NULL) {
 	clear_parse_info();
 	error = 1;
     }
-    if(error){
+    if (error) {
 #ifdef	DEBUG
 	fprintf(stderr, "database format error at line %d.\n", line.seq);
 #endif
@@ -1143,12 +1151,12 @@
 /*	This function retrieves XLocale database information.		*/
 /************************************************************************/
 void
-_XlcGetResource(lcd, category, class, value, count)
-    XLCd lcd;
-    char *category;
-    char *class;
-    char ***value;
-    int *count;
+_XlcGetResource(
+    XLCd lcd,
+    const char *category,
+    const char *class,
+    char ***value,
+    int *count)
 {
     XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
 
@@ -1162,20 +1170,20 @@
 /*	This function retrieves XLocale database information.		*/
 /************************************************************************/
 void
-_XlcGetLocaleDataBase(lcd, category, name, value, count)
-    XLCd lcd;
-    char *category;
-    char *name;
-    char ***value;
-    int *count;
+_XlcGetLocaleDataBase(
+    XLCd lcd,
+    const char *category,
+    const char *name,
+    char ***value,
+    int *count)
 {
     XlcDatabase lc_db = (XlcDatabase)XLC_PUBLIC(lcd, xlocale_db);
     XrmQuark category_q, name_q;
 
     category_q = XrmStringToQuark(category);
     name_q = XrmStringToQuark(name);
-    for(; lc_db->db; ++lc_db){
-	if(category_q == lc_db->category_q && name_q == lc_db->name_q){
+    for (; lc_db->db; ++lc_db) {
+	if (category_q == lc_db->category_q && name_q == lc_db->name_q) {
 	    *value = lc_db->db->value;
 	    *count = lc_db->db->value_num;
 	    return;
@@ -1195,23 +1203,23 @@
 /*	remove it from the cache list and free work area.		*/
 /************************************************************************/
 void
-_XlcDestroyLocaleDataBase(lcd)
-    XLCd lcd;
+_XlcDestroyLocaleDataBase(
+    XLCd lcd)
 {
     XlcDatabase lc_db = (XlcDatabase)XLC_PUBLIC(lcd, xlocale_db);
     XlcDatabaseList p, prev;
 
-    for(p = _db_list, prev = (XlcDatabaseList)NULL; p;
-	prev = p, p = p->next){
-	if(p->lc_db == lc_db){
-	    if((-- p->ref_count) < 1){
-		if(p->lc_db != (XlcDatabase)NULL){
+    for (p = _db_list, prev = (XlcDatabaseList)NULL; p;
+	 prev = p, p = p->next) {
+	if (p->lc_db == lc_db) {
+	    if ((-- p->ref_count) < 1) {
+		if (p->lc_db != (XlcDatabase)NULL) {
 		    Xfree((char *)p->lc_db);
 		}
 		DestroyDatabase(p->database);
-		if(prev == (XlcDatabaseList)NULL){
+		if (prev == (XlcDatabaseList)NULL) {
 		    _db_list = p->next;
-		}else{
+		} else {
 		    prev->next = p->next;
 		}
 		Xfree((char*)p);
@@ -1229,8 +1237,8 @@
 /*	the specified XLCd.						*/
 /************************************************************************/
 XPointer
-_XlcCreateLocaleDataBase(lcd)
-    XLCd lcd;
+_XlcCreateLocaleDataBase(
+    XLCd lcd)
 {
     XlcDatabaseList list, new;
     Database p, database = (Database)NULL;
@@ -1240,17 +1248,16 @@
     int i, n;
 
     name = _XlcFileName(lcd, "locale");
-    if(name == NULL){
+    if (name == NULL)
 	return (XPointer)NULL;
-    }
 
 #ifndef __EMX__
     name_q = XrmStringToQuark(name);
 #else
     name_q = XrmStringToQuark((char*)__XOS2RedirRoot(name));
 #endif
-    for(list = _db_list; list; list = list->next){
-	if(name_q == list->name_q){
+    for (list = _db_list; list; list = list->next) {
+	if (name_q == list->name_q) {
 	    list->ref_count++;
 	    Xfree (name);
 	    return XLC_PUBLIC(lcd, xlocale_db) = (XPointer)list->lc_db;
@@ -1258,24 +1265,23 @@
     }
 
     database = CreateDatabase(name);
-    if(database == (Database)NULL){
+    if (database == (Database)NULL) {
 	Xfree (name);
 	return (XPointer)NULL;
     }
     n = CountDatabase(database);
     lc_db = (XlcDatabase)Xmalloc(sizeof(XlcDatabaseRec) * (n + 1));
-    if(lc_db == (XlcDatabase)NULL){
+    if (lc_db == (XlcDatabase)NULL)
 	goto err;
-    }
     bzero(lc_db, sizeof(XlcDatabaseRec) * (n + 1));
-    for(p = database, i = 0; p && i < n; p = p->next, ++i){
+    for (p = database, i = 0; p && i < n; p = p->next, ++i) {
 	lc_db[i].category_q = XrmStringToQuark(p->category);
 	lc_db[i].name_q = XrmStringToQuark(p->name);
 	lc_db[i].db = p;
     }
 
     new = (XlcDatabaseList)Xmalloc(sizeof(XlcDatabaseListRec));
-    if(new == (XlcDatabaseList)NULL){
+    if (new == (XlcDatabaseList)NULL) {
 	goto err;
     }
     new->name_q = name_q;
@@ -1290,7 +1296,7 @@
 
  err:
     DestroyDatabase(database);
-    if(lc_db != (XlcDatabase)NULL){
+    if (lc_db != (XlcDatabase)NULL) {
 	Xfree((char *)lc_db);
     }
     Xfree (name);
Index: xc/lib/X11/lcDefConv.c
diff -u xc/lib/X11/lcDefConv.c:1.4 xc/lib/X11/lcDefConv.c:1.5
--- xc/lib/X11/lcDefConv.c:1.4	Fri Feb 25 13:27:54 2000
+++ xc/lib/X11/lcDefConv.c	Tue Nov 28 13:49:42 2000
@@ -27,7 +27,7 @@
  * 2000
  * Modifier: Ivan Pascal        The XFree86 Project
  */
-/* $XFree86: xc/lib/X11/lcDefConv.c,v 1.4 2000/02/25 18:27:54 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcDefConv.c,v 1.5 2000/11/28 18:49:42 dawes Exp $ */
 
 /*
  * The default locale loader.
@@ -43,12 +43,6 @@
 #define MB_LEN_MAX 6
 #endif
 
-extern void _XlcAddUtf8Converters(
-#if NeedFunctionPrototypes
-    XLCd
-#endif
-);
-
 #if !defined(X_NOT_STDC_ENV) && !defined(macII) && !defined(Lynx_22) && !defined(X_LOCALE)
 #define STDCVT
 #endif
@@ -56,47 +50,47 @@
 #define GR	0x80
 #define GL	0x7f
 
+typedef struct _StateRec *State;
 typedef struct _StateRec {
     CodeSet     GL_codeset;
     CodeSet     GR_codeset;
     wchar_t     wc_mask;
     wchar_t     wc_encode_mask;
-    Bool        (*MBtoWC)();
-    Bool        (*WCtoMB)();
-} StateRec, *State;
+    Bool        (*MBtoWC) (State state, const char *ch, wchar_t *wc);
+    Bool        (*WCtoMB) (State state, wchar_t wc, char *ch);
+} StateRec;
 
 static
-Bool MBtoWCdef(state, ch, wc)
-    State    state;
-    char     *ch;
-    wchar_t  *wc;
+Bool MBtoWCdef(
+    State    state,
+    const char *ch,
+    wchar_t  *wc)
 {
     wchar_t wc_encoding;
-    CodeSet codeset = (*ch & GR) ? state->GR_codeset :
-                                   state->GL_codeset;
+    CodeSet codeset = (*ch & GR) ? state->GR_codeset : state->GL_codeset;
     if (!codeset)
 	return False;
     wc_encoding = codeset->wc_encoding;
-    *wc = ((wchar_t) * ch & state->wc_mask) | wc_encoding;
+    *wc = ((wchar_t) *ch & state->wc_mask) | wc_encoding;
     return True;
 }
 
 #ifdef STDCVT
 static
-Bool MBtoWCstd(state, ch, wc)
-    State   state;
-    char    *ch;
-    wchar_t *wc;
+Bool MBtoWCstd(
+    State   state,
+    const char *ch,
+    wchar_t *wc)
 {
     return (mbtowc(wc, ch, 1) == 1);
 }
 #endif
 
 static
-Bool WCtoMBdef(state, wc, ch)
-    State   state;
-    wchar_t wc;
-    char    *ch;
+Bool WCtoMBdef(
+    State   state,
+    wchar_t wc,
+    char    *ch)
 {
     wchar_t wc_encoding = wc & state->wc_encode_mask;
     CodeSet codeset;
@@ -116,19 +110,19 @@
 
 #ifdef STDCVT
 static
-Bool WCtoMBstd(state, wc, ch)
-    State   state;
-    wchar_t wc;
-    char    *ch;
+Bool WCtoMBstd(
+    State   state,
+    wchar_t wc,
+    char    *ch)
 {
     return (wctomb(ch, wc) == 1);
 }
 #endif
 
 static
-XlcCharSet get_charset(state, side)
-    State  state;
-    char   side;
+XlcCharSet get_charset(
+    State  state,
+    char   side)
 {
     CodeSet codeset = side ? state->GR_codeset : state->GL_codeset;
     if (codeset) {
@@ -145,17 +139,17 @@
 }
 
 static int
-def_mbstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+def_mbstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register char  *src = (char *) *from;
-    register wchar_t *dst = (wchar_t *) * to;
+    const char *src = (const char *) *from;
+    wchar_t *dst = (wchar_t *) * to;
     State state = (State) conv->state;
     int unconv = 0;
 
@@ -164,7 +158,7 @@
 
     while (*from_left && *to_left) {
 	(*from_left)--;
-	if ((state->MBtoWC) (state, src++, dst)) {
+	if (state->MBtoWC (state, src++, dst)) {
 	    dst++;
 	    (*to_left)--;
 	} else {
@@ -177,17 +171,17 @@
 }
 
 static int
-def_wcstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+def_wcstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register wchar_t *src = (wchar_t *) * from;
-    register char  *dst = (char *) *to;
+    const wchar_t *src = (const wchar_t *) * from;
+    char  *dst = (char *) *to;
     State state = (State) conv->state;
     char ch[MB_LEN_MAX];
     int unconv = 0;
@@ -197,7 +191,7 @@
 
     while (*from_left && *to_left) {
 	(*from_left)--;
-	if ((state->WCtoMB) (state, *src++, ch)) {
+	if (state->WCtoMB (state, *src++, ch)) {
 	    *dst++ = *ch;
 	    (*to_left)--;
 	} else {
@@ -210,17 +204,17 @@
 }
 
 static int
-mbstostr(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+mbstostr(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register char *src = (char *) *from;
-    register char *dst = (char *) *to;
+    const char *src = (const char *) *from;
+    char *dst = (char *) *to;
     CodeSet codeset;
     State state = (State) conv->state;
     char ch;
@@ -247,17 +241,17 @@
 }
 
 static int
-wcstostr(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstostr(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register wchar_t *src = (wchar_t *) * from;
-    register char *dst = (char *) *to;
+    const wchar_t *src = (const wchar_t *) *from;
+    char *dst = (char *) *to;
     CodeSet codeset;
     State state = (State) conv->state;
     char ch[MB_LEN_MAX];
@@ -268,7 +262,7 @@
 
     while (*from_left && *to_left) {
 	(*from_left)--;
-	if ((state->WCtoMB) (state, *src++, ch)) {
+	if (state->WCtoMB (state, *src++, ch)) {
 	    codeset = (*ch & GR) ? state->GR_codeset : state->GL_codeset;
 	    if (codeset && codeset->string_encoding) {
 		*dst++ = *ch;
@@ -286,18 +280,18 @@
 }
 
 static int
-mbstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
-{
-    register char *src = (char *) *from;
-    register char *dst = (char *) *to;
-    register int length;
+mbstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
+{
+    const char *src = (const char *) *from;
+    char *dst = (char *) *to;
+    int length;
     State state = (State) conv->state;
     char cur_side;
     int unconv = 0;
@@ -332,17 +326,17 @@
 }
 
 static int
-wcstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register wchar_t *src = (wchar_t *) * from;
-    register char *dst = (char *) *to;
+    const wchar_t *src = (const wchar_t *) * from;
+    char *dst = (char *) *to;
     State state = (State) conv->state;
     char cur_side = 0, ch[MB_LEN_MAX];
     int unconv = 0;
@@ -352,7 +346,7 @@
 	return 0;
 
     while (*from_left) {
-	if (found = (state->WCtoMB)(state, *src, ch))
+	if ((found = state->WCtoMB (state, *src, ch)))
 	    break;
 	unconv++;
 	src++;
@@ -363,7 +357,7 @@
 	cur_side = *ch & GR;
 	while (*from_left && *to_left) {
 	    (*from_left)--;
-	    if ((state->WCtoMB)(state, *src++, ch)) {
+	    if (state->WCtoMB (state, *src++, ch)) {
 		if ((char) (*ch & GR) != cur_side) {
 		    src--;
 		    (*from_left)++;
@@ -381,7 +375,7 @@
     }
 
     if (num_args > 0) {
-	XlcCharSet      charset = get_charset(state, cur_side);
+	XlcCharSet charset = get_charset(state, cur_side);
 	if (charset) {
 	    *((XlcCharSet *) args[0]) = charset;
 	} else {
@@ -394,17 +388,17 @@
 }
 
 static int
-cstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register char *src = (char *) *from;
-    register char *dst = (char *) *to;
+    const char *src = (const char *) *from;
+    char *dst = (char *) *to;
     CodeSet codeset;
     XlcCharSet charset;
     State state = (State) conv->state;
@@ -446,7 +440,7 @@
 	}
     }
     if (found) {
-	register int    length = min(*from_left, *to_left);
+	int length = min(*from_left, *to_left);
 	while (length) {
 	    *dst++ = *src++ | cur_side;
 	    length--;
@@ -463,17 +457,17 @@
 }
 
 static int
-cstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register char *src = (char *) *from;
-    register wchar_t *dst = (wchar_t *) * to;
+    const char *src = (const char *) *from;
+    wchar_t *dst = (wchar_t *) * to;
     CodeSet codeset;
     XlcCharSet charset;
     State state = (State) conv->state;
@@ -519,7 +513,7 @@
 	while (*from_left && *to_left) {
 	    ch = *src++ | cur_side;
 	    (*from_left)--;
-	    if ((state->MBtoWC) (state, &ch, dst)) {
+	    if (state->MBtoWC (state, &ch, dst)) {
 		dst++;
 		(*to_left)--;
 	    } else {
@@ -535,18 +529,18 @@
 }
 
 static int
-strtombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
-{
-    register char *src = (char *) *from;
-    register char *dst = (char *) *to;
-    register int length;
+strtombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
+{
+    const char *src = (const char *) *from;
+    char *dst = (char *) *to;
+    int length;
 
     if (from == NULL || *from == NULL)
 	return 0;
@@ -565,8 +559,8 @@
 }
 
 static void
-close_converter(conv)
-    XlcConv conv;
+close_converter(
+    XlcConv conv)
 {
     if (conv->state)
 	Xfree((char *) conv->state);
@@ -575,11 +569,11 @@
 }
 
 static XlcConv
-create_conv(lcd, methods)
-    XLCd lcd;
-    XlcConvMethods methods;
+create_conv(
+    XLCd lcd,
+    XlcConvMethods methods)
 {
-    register XlcConv conv;
+    XlcConv conv;
     State state;
 
     conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
@@ -623,11 +617,11 @@
 };
 
 static XlcConv
-open_mbstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbstowcs_methods);
 }
@@ -639,11 +633,11 @@
 };
 
 static XlcConv
-open_mbstostr(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstostr(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbstostr_methods);
 }
@@ -655,11 +649,11 @@
 };
 
 static XlcConv
-open_mbstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbstocs_methods);
 }
@@ -671,11 +665,11 @@
 };
 
 static XlcConv
-open_wcstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &wcstombs_methods);
 }
@@ -687,11 +681,11 @@
 };
 
 static XlcConv
-open_wcstostr(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstostr(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &wcstostr_methods);
 }
@@ -703,11 +697,11 @@
 };
 
 static XlcConv
-open_wcstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &wcstocs_methods);
 }
@@ -719,11 +713,11 @@
 };
 
 static XlcConv
-open_strtombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_strtombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &strtombs_methods);
 }
@@ -735,11 +729,11 @@
 };
 
 static XlcConv
-open_cstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &cstombs_methods);
 }
@@ -751,18 +745,18 @@
 };
 
 static XlcConv
-open_cstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &cstowcs_methods);
 }
 
 XLCd
-_XlcDefaultLoader(name)
-    _Xconst char *name;
+_XlcDefaultLoader(
+    const char *name)
 {
     XLCd lcd;
 
Index: xc/lib/X11/lcDynamic.c
diff -u xc/lib/X11/lcDynamic.c:1.2 xc/lib/X11/lcDynamic.c:1.3
--- xc/lib/X11/lcDynamic.c:1.2	Fri Feb 11 21:54:11 2000
+++ xc/lib/X11/lcDynamic.c	Tue Nov 28 13:49:42 2000
@@ -28,7 +28,7 @@
  * Modifier: Takanori Tateno   FUJITSU LIMITED
  *
  */
-/* $XFree86: xc/lib/X11/lcDynamic.c,v 1.2 2000/02/12 02:54:11 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcDynamic.c,v 1.3 2000/11/28 18:49:42 dawes Exp $ */
 
 /*
  * A dynamically loaded locale.
@@ -43,6 +43,7 @@
 #include <dlfcn.h>
 
 #include "Xlibint.h"
+#include "Xlcint.h"
 
 #ifndef XLOCALEDIR
 #define XLOCALEDIR "/usr/lib/X11/locale"
@@ -51,8 +52,8 @@
 #define LCLIBNAME    "xi18n.so"
 
 XLCd
-_XlcDynamicLoader(name)
-    char *name;
+_XlcDynamicLoader(
+    const char *name)
 {
     char libpath[1024];
     XLCdMethods _XlcGenericMethods;
@@ -62,11 +63,11 @@
     sprintf(libpath,"%s/%s/%s",
 		XLOCALEDIR,name,LCLIBNAME);
     nlshandler = dlopen(libpath,LAZY);
-    _XlcGenericMethods = (XLCdMethods)dlsym(nlshandler,
-				"genericMethods");
+    _XlcGenericMethods = (XLCdMethods)dlsym(nlshandler,"genericMethods");
     lcd = _XlcCreateLC(name,_XlcGenericMethods);
-    
 
     return lcd;
 }
+#else
+typedef int dummy;
 #endif /* USE_DYNAMIC_LOADER */
Index: xc/lib/X11/lcEuc.c
diff -u xc/lib/X11/lcEuc.c:3.7 xc/lib/X11/lcEuc.c:3.8
--- xc/lib/X11/lcEuc.c:3.7	Fri Feb 11 21:54:11 2000
+++ xc/lib/X11/lcEuc.c	Tue Nov 28 13:49:43 2000
@@ -30,7 +30,7 @@
              Yoshiyuki Segawa		(segawa@ossi.com)
 
 *****************************************************************/
-/* $XFree86: xc/lib/X11/lcEuc.c,v 3.7 2000/02/12 02:54:11 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcEuc.c,v 3.8 2000/11/28 18:49:43 dawes Exp $ */
 
 /*
  * An EUC locale.
@@ -76,8 +76,8 @@
 typedef unsigned long   Ulong;
 typedef unsigned int	Uint;
 
-static CodeSet GetCodeSetFromCharSet();
-static CodeSet wc_codeset();
+static CodeSet GetCodeSetFromCharSet (XLCd lcd, XlcCharSet charset);
+static CodeSet wc_codeset (XLCd lcd, wchar_t wch);
 
 #define BADCHAR(min_ch, c)  (BIT8OFF(c) < (char)min_ch && BIT8OFF(c) != 0x0 && \
 			     BIT8OFF(c) != '\t' && BIT8OFF(c) != '\n' && \
@@ -92,23 +92,22 @@
  */
 
 static int
-euc_mbstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+euc_mbstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-
     XLCd lcd = (XLCd)conv->state;
 
-    register Uchar ch;
-    register int chr_len = 0;
-    register int sshift =  False;
-    register int shift_mult = 0;
-    register Uint chrcode;
+    Uchar ch;
+    int chr_len = 0;
+    int sshift =  False;
+    int shift_mult = 0;
+    Uint chrcode;
 
     Uint wc_encode = 0;
     Uint wc_tmp = 0;
@@ -121,7 +120,7 @@
 
     Bool new_char;
 
-    XPointer inbufptr = *from;
+    const char *inbufptr = *from;
     wchar_t *outbufptr = (wchar_t *) *to;
     wchar_t *outbuf_base = outbufptr;
 
@@ -129,7 +128,6 @@
     int codeset_num = XLC_GENERIC(lcd, codeset_num);
     Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
 
-
     if (*from_left > *to_left)
 	*from_left = *to_left;
 
@@ -246,20 +244,20 @@
 
 
 static int
-euc_wcstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+euc_wcstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    wchar_t *inbufptr = (wchar_t *) *from;
-    register XPointer outbufptr = *to;
+    const wchar_t *inbufptr = (const wchar_t *) *from;
+    XPointer outbufptr = *to;
     XPointer outbuf_base = outbufptr;
     wchar_t  wch;
-    register int length;
+    int length;
     Uchar tmp;
     int num_conv;
     int unconv_num = 0;
@@ -268,7 +266,6 @@
     CodeSet codeset;
     Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
 
-
     if (*from_left > *to_left)
         *from_left = *to_left;
 
@@ -309,14 +306,14 @@
 
 
 static int
-euc_mbtocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+euc_mbtocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd)conv->state;
     XlcCharSet charset;
@@ -325,8 +322,8 @@
     int length;
     int unconv_num = 0;
     int min_ch = 0;
-    register char *src = *from, *dst = *to;
-
+    const char *src = *from;
+    char *dst = *to;
 
     if (isleftside(*src)) { 			/* 7-bit (CS0) */
 	if (ASCII_CODESET >= codeset_num)
@@ -382,7 +379,7 @@
     } while (--length);
 
     *to = dst;
-    *from = src;
+    *from = (XPointer) src;
     *from_left -= charset->char_size;
     *to_left -= charset->char_size - length;
 
@@ -394,22 +391,22 @@
 
 
 static int
-euc_mbstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+euc_mbstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    char *tmp_from, *tmp_to;
+    const char *tmp_from;
+    char *tmp_to;
     int tmp_from_left, tmp_to_left;
     XlcCharSet charset, tmp_charset;
     XPointer tmp_args[1];
     int unconv_num = 0, ret;
 
-
 /* Determine the charset of the segment and convert one characater: */
 
     tmp_args[0] = (XPointer) &charset; /* charset from euc_mbtocs() */
@@ -424,12 +421,11 @@
     tmp_to_left = *to_left;
     tmp_to = *to;
 
-
 /* Convert remainder of the segment: */
 
     tmp_args[0] = (XPointer) &tmp_charset;
-    while( (ret = euc_mbtocs(conv, &tmp_from, &tmp_from_left, &tmp_to,
-      &tmp_to_left, tmp_args, 1)) >= 0 ) {
+    while( (ret = euc_mbtocs(conv, (XPointer *) &tmp_from, &tmp_from_left,
+		     (XPointer *) &tmp_to, &tmp_to_left, tmp_args, 1)) >= 0 ) {
 
 	if (ret > 0) {
 	    unconv_num += ret;
@@ -439,9 +435,9 @@
 	if (tmp_charset != charset)  /* quit on end of segment */
 	    break;
 
-	*from = tmp_from;
+	*from = (XPointer) tmp_from;
 	*from_left = tmp_from_left;
-	*to = tmp_to;
+	*to = (XPointer) tmp_to;
 	*to_left = tmp_to_left;
     } 
 
@@ -453,26 +449,25 @@
 
 
 static int
-euc_wcstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+euc_wcstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd)conv->state;
-    wchar_t *wcptr = (wchar_t *) *from;
-    register char *bufptr = (char *) *to;
+    const wchar_t *wcptr = (const wchar_t *) *from;
+    char *bufptr = (char *) *to;
     wchar_t wch;
     char *tmpptr;
-    register int length;
+    int length;
     CodeSet codeset;
     Ulong wc_encoding;
     int wcstr_len = *from_left, buf_len = *to_left;
 
-
     if (!(codeset = wc_codeset(lcd, *wcptr)))
 	return -1;
 
@@ -514,25 +509,24 @@
 
 
 static int
-euc_cstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+euc_cstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd)conv->state;
-    register char *csptr = *from;
-    register char *bufptr = *to;
+    const char *csptr = *from;
+    char *bufptr = *to;
     int csstr_len = *from_left;
-    register int buf_len = *to_left;
+    int buf_len = *to_left;
     int length;
     CodeSet codeset;
     int cvt_length;
 
-
     if (num_args < 1)
 	return -1;
     
@@ -564,7 +558,7 @@
     }
 
     *from_left -= csptr - *from;
-    *from = csptr;
+    *from = (XPointer) csptr;
     if (bufptr)
 	*to += cvt_length;
     *to_left -= cvt_length;
@@ -574,26 +568,25 @@
 
 
 static int
-euc_cstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+euc_cstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd)conv->state;
-    register char *csptr = *from;
+    const char *csptr = *from;
     wchar_t *bufptr = (wchar_t *) *to;
     wchar_t *toptr = (wchar_t *) *to;
     int csstr_len = *from_left;
-    register int buf_len = *to_left;
+    int buf_len = *to_left;
     wchar_t wch;
     int length;
     Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
     CodeSet codeset;
-
     
     if (num_args < 1)
 	return -1;
@@ -625,21 +618,20 @@
         }
     }
     *from_left -= csptr - *from;
-    *from = csptr;
+    *from = (XPointer) csptr;
 
     return 0;
 }
 
 
 static CodeSet
-wc_codeset(lcd, wch)
-    XLCd lcd;
-    wchar_t wch;
+wc_codeset(
+    XLCd lcd,
+    wchar_t wch)
 {
-
-    register CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
-    register int end = XLC_GENERIC(lcd, codeset_num);
-    register Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
+    CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+    int end = XLC_GENERIC(lcd, codeset_num);
+    Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
 
     for (; --end >= 0; codesets++)
 	if ( widech == (*codesets)->wc_encoding )
@@ -650,13 +642,13 @@
 
 
 static CodeSet
-GetCodeSetFromCharSet(lcd, charset)
-    XLCd lcd;
-    XlcCharSet charset;
-{
-    register CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
-    register XlcCharSet *charset_list;
-    register int codeset_num, num_charsets;
+GetCodeSetFromCharSet(
+    XLCd lcd,
+    XlcCharSet charset)
+{
+    CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
+    XlcCharSet *charset_list;
+    int codeset_num, num_charsets;
 
     codeset_num = XLC_GENERIC(lcd, codeset_num);
 
@@ -674,9 +666,9 @@
 
 
 static XlcConv
-create_conv(lcd, methods)
-    XLCd lcd;
-    XlcConvMethods methods;
+create_conv(
+    XLCd lcd,
+    XlcConvMethods methods)
 {
     XlcConv conv;
 
@@ -764,8 +756,8 @@
  * initCTptr(): Set ctdptr[] to point at ctdata[], indexed by codeset_num.
  */
 static void
-initCTptr(lcd)
-    XLCd lcd;
+initCTptr(
+    XLCd lcd)
 {
     int num_codesets = XLC_GENERIC(lcd, codeset_num);
     int num_charsets;
@@ -818,27 +810,26 @@
 #define SKIP_P(str)     while (*(str) >= 0x30 && *(str) <=  0x3f) (str)++;
 
 static int
-euc_ctstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+euc_ctstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd)conv->state;
     Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
-    register XPointer inbufptr = *from;
-    XPointer inbuf_base;
-    register wchar_t *outbufptr = (wchar_t *) *to;
+    const char *inbufptr = *from;
+    const char *inbuf_base;
+    wchar_t *outbufptr = (wchar_t *) *to;
     wchar_t *outbuf_base = outbufptr;
-    register int clen, length;
-    int num_conv;
+    int clen, length;
     int unconv_num = 0;
     unsigned int ct_seglen = 0;
     Uchar ct_type = 0;
-    register int shift_mult;
+    int shift_mult;
     wchar_t wc_tmp;
     wchar_t wch;
     Ulong wc_encoding;
@@ -947,22 +938,22 @@
 #define userdef			(codeset->cs_num == 3)
 
 static int
-euc_wcstocts(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
-{
-    register int ct_len = *to_left;
-    register wchar_t *inbufptr = (wchar_t *) *from;
-    register char *ctptr = *to;
+euc_wcstocts(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
+{
+    int ct_len = *to_left;
+    const wchar_t *inbufptr = (const wchar_t *) *from;
+    char *ctptr = *to;
     XPointer ct_base = ctptr;
     wchar_t  wch;
-    register int length;
-    register int unconv_num = 0;
+    int length;
+    int unconv_num = 0;
     Uchar tmp;
     Uchar t1 = 0;
     int num_conv;
@@ -973,7 +964,6 @@
     CodeSet codeset;
     Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
 
-
 /* Initial State: */
     ct_state.GL_charset = ctdptr[0]; /* Codeset 0 */
     ct_state.GR_charset = NULL;
@@ -1085,22 +1075,21 @@
 #define userdef (ctdp == ctdptr[Userdef])
 
 static int
-euc_ctstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
-{
-    register XPointer inbufptr = *from;
-    register XPointer outbufptr = *to;
-    XPointer inbuf_base;
+euc_ctstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
+{
+    const char *inbufptr = *from;
+    XPointer outbufptr = *to;
+    const char *inbuf_base;
     XPointer outbuf_base = outbufptr;
-    register int clen, length;
+    int clen, length;
     int unconv_num = 0;
-    int num_conv;
     unsigned int ct_seglen = 0;
     Uchar ct_type = 0;
     CTData ctdp = &ctdata[0];	/* default */
@@ -1176,8 +1165,9 @@
 	clen = length;
 	do {
 
-	    if (byte1)
+	    if (byte1) {
 		if (kanji) {
+		    /* FIXME: assignment of read-only location */
 		    *inbufptr = BIT8ON(*inbufptr);
 		    *(inbufptr+1) = BIT8ON(*(inbufptr+1));
 		}
@@ -1187,6 +1177,7 @@
 		    }
 		    (*to_left)--;
 		}
+	    }
 	    if (save_outbuf == True) {
 		*outbufptr++ = *inbufptr;
 	    }
@@ -1213,22 +1204,22 @@
 
 
 static int
-euc_mbstocts(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+euc_mbstocts(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register int ct_len = *to_left;
+    int ct_len = *to_left;
     int cs_num;
     int clen, length;
     int unconv_num = 0;
     int num_conv;
-    XPointer inbufptr = *from;
-    register char *ctptr = *to;
+    const char *inbufptr = *from;
+    char *ctptr = *to;
     XPointer ct_base = ctptr;
 
     StateRec ct_state;
@@ -1236,7 +1227,6 @@
     XLCd lcd = (XLCd) conv->state;
     int codeset_num = XLC_GENERIC(lcd, codeset_num);
 
-
 /* Initial State: */
     ct_state.GL_charset = NULL;
     ct_state.GR_charset = NULL;
@@ -1333,8 +1323,8 @@
 
 
 static void
-close_converter(conv)
-    XlcConv conv;
+close_converter(
+    XlcConv conv)
 {
 	Xfree((char *) conv);
 }
@@ -1358,125 +1348,124 @@
 
 
 static XlcConv
-open_mbstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[MBSTOCS]);
 }
 
 static XlcConv
-open_wcstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[WCSTOCS]);
 }
 
 static XlcConv
-open_mbtocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbtocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[MBTOCS]);
 }
 
 static XlcConv
-open_cstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[CSTOMBS]);
 }
 
 static XlcConv
-open_cstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[CSTOWCS]);
 }
 
 static XlcConv
-open_mbstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[MBSTOWCS]);
 }
 
 static XlcConv
-open_wcstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[WCSTOMBS]);
 }
 
 static XlcConv
-open_ctstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_ctstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[CTSTOWCS]);
 }
 
 static XlcConv
-open_ctstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_ctstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[CTSTOMBS]);
 }
 
 static XlcConv
-open_wcstocts(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocts(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[WCSTOCTS]);
 }
 
 static XlcConv
-open_mbstocts(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstocts(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[MBSTOCTS]);
 }
 
 XLCd
-_XlcEucLoader(name)
-    _Xconst char *name;
+_XlcEucLoader(
+    const char *name)
 {
     XLCd lcd;
 
     lcd = _XlcCreateLC(name, _XlcGenericMethods);
     if (lcd == NULL)
 	return lcd;
-
 
     if (!XLC_PUBLIC_PART(lcd)->codeset ||
 	(_XlcNCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "euc", 3))) {
Index: xc/lib/X11/lcFile.c
diff -u xc/lib/X11/lcFile.c:3.18 xc/lib/X11/lcFile.c:3.19
--- xc/lib/X11/lcFile.c:3.18	Sat Jan 29 13:58:17 2000
+++ xc/lib/X11/lcFile.c	Tue Nov 28 13:49:43 2000
@@ -23,16 +23,14 @@
  * SOFTWARE.
  *
 */
-/* $XFree86: xc/lib/X11/lcFile.c,v 3.18 2000/01/29 18:58:17 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcFile.c,v 3.19 2000/11/28 18:49:43 dawes Exp $ */
 
+#include <stdlib.h>
 #include <stdio.h>
 #include <ctype.h>
 #include "Xlibint.h"
 #include "XlcPubI.h"
 #include <X11/Xos.h>
-#ifdef X_NOT_STDC_ENV
-extern char *getenv();
-#endif
 
 /************************************************************************/
 
@@ -77,27 +75,32 @@
 
 #define NUM_LOCALEDIR	64
 
+/* Splits a NUL terminated line into constituents, at colons and newline
+   characters. Leading whitespace is removed from constituents. The
+   constituents are stored at argv[0..argsize-1]. The number of stored
+   constituents (<= argsize) is returned. The line is destructively
+   modified. */
 static int
-parse_line(line, argv, argsize)
-    char *line;
-    char **argv;
-    int argsize;
+parse_line(
+    char *line,
+    char **argv,
+    int argsize)
 {
     int argc = 0;
     char *p = line;
 
-    while(argc < argsize){
-	while(isspace(*p)){
+    while (argc < argsize) {
+	while (isspace(*p)) {
 	    ++p;
 	}
-	if(*p == '\0'){
+	if (*p == '\0') {
 	    break;
 	}
 	argv[argc++] = p;
-	while(*p != ':' && *p != '\n' && *p != '\0'){
+	while (*p != ':' && *p != '\n' && *p != '\0') {
 	    ++p;
 	}
-	if(*p == '\0'){
+	if (*p == '\0') {
 	    break;
 	}
 	*p++ = '\0';
@@ -106,31 +109,25 @@
     return argc;
 }
 
-/* parse the colon separated list in path into argv */
-int
-_XlcParsePath(path, argv, argsize)
-    char *path;
-    char **argv;
-    int argsize;
+/* Splits a colon separated list of directories, and returns the constituent
+   paths (without trailing slash). At most argsize constituents are stored
+   at argv[0..argsize-1]. The number of stored constituents is returned. */
+static int
+_XlcParsePath(
+    char *path,
+    char **argv,
+    int argsize)
 {
     char *p = path;
-    int i, n;
+    int n, i;
 
-#if 0
-    while((p = strchr(p, LC_PATHDELIM)) != NULL){
-	*p = ' ';	/* place space on delimter */
-    }
-#endif
     n = parse_line(path, argv, argsize);
-    if(n == 0){
-	return 0;
-    }
-    for(i = 0; i < n; ++i){
+    for (i = 0; i < n; ++i) {
 	int len;
 	p = argv[i];
 	len = strlen(p);
-	if(p[len - 1] == '/'){
-	    /* eliminate slash */
+	if (len > 0 && p[len - 1] == '/') {
+	    /* eliminate trailing slash */
 	    p[len - 1] = '\0';
 	}
     }
@@ -142,15 +139,15 @@
 #endif
 
 static void
-xlocaledir(buf, buf_len)
-    char *buf;
-    int buf_len;
+xlocaledir(
+    char *buf,
+    int buf_len)
 {
     char *dir, *p = buf;
     int len = 0;
 
     dir = getenv("XLOCALEDIR");
-    if(dir != NULL){
+    if (dir != NULL) {
 	len = strlen(dir);
 	strncpy(p, dir, buf_len);
 	if (len < buf_len) {
@@ -167,89 +164,88 @@
     buf[buf_len-1] = '\0';
 }
 
-enum { LtoR, RtoL };
+/* Mapping direction */
+typedef enum {
+  LtoR,		/* Map first field to second field */
+  RtoL		/* Map second field to first field */
+} MapDirection;
 
 static char *
-resolve_name(lc_name, file_name, direction)
-    char *lc_name;
-    char *file_name;
-    int direction;	/* mapping direction */
+resolve_name(
+    const char *lc_name,
+    char *file_name,
+    MapDirection direction)
 {
     FILE *fp;
     char buf[XLC_BUFSIZE], *name = NULL;
 
     fp = _XFopenFile (file_name, "r");
-    if(fp == (FILE *)NULL){
+    if (fp == NULL)
 	return NULL;
-    }
 
-    while(fgets(buf, XLC_BUFSIZE, fp) != NULL){
+    while (fgets(buf, XLC_BUFSIZE, fp) != NULL) {
 	char *p = buf;
 	int n;
 	char *args[2], *from, *to;
 #ifdef __EMX__  /* Take out CR under OS/2 */
 	int len;
 
-	len=strlen(p);
-	if (len>1) {
-	  if (*(p+len-2) == '\r' && *(p+len-1) == '\n') {
+	len = strlen(p);
+	if (len > 1) {
+	    if (*(p+len-2) == '\r' && *(p+len-1) == '\n') {
 		*(p+len-2) = '\n';
 		*(p+len-1) = '\0';
-	  }
+	    }
 	}
 #endif
-	while(isspace(*p)){
+	while (isspace(*p)) {
 	    ++p;
 	}
-	if(iscomment(*p)){
+	if (iscomment(*p)) {
 	    continue;
 	}
 	n = parse_line(p, args, 2);		/* get first 2 fields */
-	if(n != 2){
+	if (n != 2) {
 	    continue;
 	}
-	if(direction == LtoR){
+	if (direction == LtoR) {
 	    from = args[0], to = args[1];	/* left to right */
-	}else{
+	} else {
 	    from = args[1], to = args[0];	/* right to left */
 	}
-	if(! strcmp(from, lc_name)){
+	if (! strcmp(from, lc_name)) {
 	    name = Xmalloc(strlen(to) + 1);
-	    if(name != NULL){
+	    if (name != NULL) {
 		strcpy(name, to);
 	    }
 	    break;
 	}
-    }
-    if(fp != (FILE *)NULL){
-	fclose(fp);
     }
+    fclose(fp);
     return name;
 }
 
-/*
-#define	isupper(ch)	('A' <= (ch) && (ch) <= 'Z')
-#define	tolower(ch)	((ch) - 'A' + 'a')
-*/
+#define	c_tolower(ch)	((ch) >= 'A' && (ch) <= 'Z' ? (ch) - 'A' + 'a' : (ch))
+
 static char *
-lowercase(dst, src)
-    char *dst;
-    char *src;
+lowercase(
+    char *dst,
+    const char *src)
 {
-    char *s, *t;
+    const char *s;
+    char *t;
 
-    for(s = src, t = dst; *s; ++s, ++t){
-	*t = isupper(*s) ? tolower(*s) : *s;
-    }
+    for (s = src, t = dst; *s; ++s, ++t)
+	*t = c_tolower(*s);
     *t = '\0';
     return dst;
 }
 
 /************************************************************************/
 char *
-_XlcFileName(lcd, category)
-    XLCd lcd;
-    char *category;
+_XlcFileName(
+    XLCd lcd,
+    const char *category)
 {
     char *siname;
     char cat[XLC_BUFSIZE], dir[XLC_BUFSIZE];
@@ -257,16 +253,15 @@
     char *args[NUM_LOCALEDIR];
     char *file_name = NULL;
 
-    if(lcd == (XLCd)NULL){
+    if (lcd == (XLCd)NULL)
 	return NULL;
-    }
 
     siname = XLC_PUBLIC(lcd, siname);
 
     lowercase(cat, category);
     xlocaledir(dir,XLC_BUFSIZE);
     n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
-    for(i = 0; i < n; ++i){
+    for (i = 0; i < n; ++i) {
 	char buf[PATH_MAX], *name;
 
 	name = NULL;
@@ -275,20 +270,20 @@
 	    sprintf(buf, "%s/%s.dir", args[i], cat);
 	    name = resolve_name(siname, buf, RtoL);
 	}
-	if(name == NULL){
+	if (name == NULL) {
 	    continue;
 	}
-	if(*name == '/'){
+	if (*name == '/') {
 	    /* supposed to be absolute path name */
 	    file_name = name;
-	}else{
+	} else {
 	    file_name = Xmalloc(2 + (args[i] ? strlen (args[i]) : 0) +
 				(name ? strlen (name) : 0));
 	    if (file_name != NULL)
 		sprintf(file_name, "%s/%s", args[i], name);
 	    Xfree(name);
 	}
-	if(isreadable(file_name)){
+	if (isreadable(file_name)) {
 	    break;
 	}
 	Xfree(file_name);
@@ -304,9 +299,9 @@
 #endif
 
 int
-_XlcResolveLocaleName(lc_name, pub)
-    char* lc_name;
-    XLCdPublicPart* pub;
+_XlcResolveLocaleName(
+    const char* lc_name,
+    XLCdPublicPart* pub)
 {
     char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
     char *dst;
@@ -317,13 +312,13 @@
 
     xlocaledir (dir, PATH_MAX);
     n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
-    for(i = 0; i < n; ++i){
+    for (i = 0; i < n; ++i) {
 	if ((2 + (args[i] ? strlen (args[i]) : 0) + 
 	    strlen (locale_alias)) < PATH_MAX) {
 	    sprintf (buf, "%s/%s", args[i], locale_alias);
 	    name = resolve_name (lc_name, buf, LtoR);
 	}
-	if(name != NULL){
+	if (name != NULL) {
 	    break;
 	}
     }
@@ -383,7 +378,7 @@
     char *buf;
     int buf_len;
 {
-    if(buf != NULL){
+    if (buf != NULL) {
 	xlocaledir(buf, buf_len);
     }
     return 1;
Index: xc/lib/X11/lcGenConv.c
diff -u xc/lib/X11/lcGenConv.c:3.14 xc/lib/X11/lcGenConv.c:3.17
--- xc/lib/X11/lcGenConv.c:3.14	Fri Feb 25 13:27:55 2000
+++ xc/lib/X11/lcGenConv.c	Mon Dec  4 13:49:27 2000
@@ -35,7 +35,7 @@
  *  2000  
  *  Modifier: Ivan Pascal      The XFree86 Project
  */
-/* $XFree86: xc/lib/X11/lcGenConv.c,v 3.14 2000/02/25 18:27:55 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcGenConv.c,v 3.17 2000/12/04 18:49:27 dawes Exp $ */
 
 /*
  * A generic locale loader for all kinds of ISO-2022 based codesets.
@@ -56,11 +56,9 @@
 #define STDCVT
 #endif
 
-extern void _XlcAddUtf8Converters(
-#if NeedFunctionPrototypes
-    XLCd
+#ifdef __CYGWIN__
+int __mb_cur_max = 1;
 #endif
-);
 
 typedef struct _CTDataRec {
     char *name;
@@ -95,21 +93,24 @@
 #define isleftside(c)  (!isrightside(c))
 
 /* Forward declarations for local routines. */
-static int mbstocts();
-static int ctstombs();
-static int cstombs();
+static int mbstocts (XlcConv conv, XPointer *from, int *from_left,
+		     XPointer *to, int *to_left, XPointer *args, int num_args);
+static int ctstombs (XlcConv conv, XPointer *from, int *from_left,
+		     XPointer *to, int *to_left, XPointer *args, int num_args);
+static int cstombs (XlcConv conv, XPointer *from, int *from_left,
+		    XPointer *to, int *to_left, XPointer *args, int num_args);
 
 /* ------------------------------------------------------------------------- */
 /*				Misc                                         */
 /* ------------------------------------------------------------------------- */
 
 static int
-compare(src, encoding, length)
-    register char *src;
-    register char *encoding;
-    register int length;
+compare(
+    const char *src,
+    const char *encoding,
+    int length)
 {
-    char *start = src;
+    const char *start = src;
 
     while (length-- > 0) {
 	if (*src++ != *encoding++)
@@ -122,9 +123,9 @@
 }
 
 static unsigned long
-conv_to_dest(conv, code)
-    Conversion conv;
-    unsigned long code;
+conv_to_dest(
+    Conversion conv,
+    unsigned long code)
 {
     int i;
     int conv_num = conv->conv_num;
@@ -147,9 +148,9 @@
 }
 
 static unsigned long
-conv_to_source(conv, code)
-    Conversion conv;
-    unsigned long code;
+conv_to_source(
+    Conversion conv,
+    unsigned long code)
 {
     int i;
     int conv_num;
@@ -188,9 +189,9 @@
 }
 
 static unsigned long
-mb_to_gi(mb, codeset)
-    unsigned long mb;
-    CodeSet codeset;
+mb_to_gi(
+    unsigned long mb,
+    CodeSet codeset)
 {
     int i;
     unsigned long mb_tmp, mask = 0;
@@ -213,9 +214,9 @@
 }
 
 static unsigned long
-gi_to_mb(glyph_index, codeset)
-    unsigned long glyph_index;
-    CodeSet codeset;
+gi_to_mb(
+    unsigned long glyph_index,
+    CodeSet codeset)
 {
     int i;
     unsigned long mask = 0;
@@ -233,11 +234,11 @@
 }
 
 static Bool
-gi_to_wc(lcd, glyph_index, codeset, wc)
-    XLCd lcd;
-    unsigned long glyph_index;
-    CodeSet codeset;
-    wchar_t *wc;
+gi_to_wc(
+    XLCd lcd,
+    unsigned long glyph_index,
+    CodeSet codeset,
+    wchar_t *wc)
 {
     unsigned char mask = 0;
     unsigned long wc_encoding = codeset->wc_encoding;
@@ -255,11 +256,11 @@
 }
 
 static Bool
-wc_to_gi(lcd, wc, glyph_index, codeset)
-    XLCd lcd;
-    wchar_t wc;
-    unsigned long *glyph_index;
-    CodeSet *codeset;
+wc_to_gi(
+    XLCd lcd,
+    wchar_t wc,
+    unsigned long *glyph_index,
+    CodeSet *codeset)
 {
     int i;
     unsigned char mask = 0;
@@ -290,20 +291,20 @@
 }
 
 static CodeSet
-mb_parse_codeset(state, num, inbufptr, from_left)
-    State state;
-    int num;
-    char **inbufptr;
-    int *from_left;
+mb_parse_codeset(
+    State state,
+    int num,
+    const char **inbufptr,
+    int *from_left)
 {
     int len;
     int from_len = (*from_left) + 1;
-    char *src = (*inbufptr) - 1;
+    const char *src = (*inbufptr) - 1;
     ParseInfo *mb_parse_list = XLC_GENERIC(state->lcd, mb_parse_list);
     ParseInfo parse_info;
     CodeSet codeset;
     
-    for (--num ; parse_info = mb_parse_list[num]; num++) {
+    for (--num ; (parse_info = mb_parse_list[num]) != NULL; num++) {
        len = compare(src, parse_info->encoding, from_len);
        if (len > 0) {
            codeset = parse_info->codeset;
@@ -321,9 +322,9 @@
 }
 
 static CodeSet
-byteM_parse_codeset(lcd, inbufptr)
-    XLCd lcd;
-    XPointer inbufptr;
+byteM_parse_codeset(
+    XLCd lcd,
+    const char *inbufptr)
 {
     unsigned char ch;
     CodeSet codeset;
@@ -348,7 +349,7 @@
 	    byteM_rec = byteM[j];
 	    byteinfo = byteM_rec.byteinfo;
 
-	    for (hit=False,k=0; k < byteM_rec.byteinfo_num; k++) {
+	    for (hit = False, k = 0; k < byteM_rec.byteinfo_num; k++) {
 	        byteinfo_rec = byteinfo[k];
 	        if (byteinfo_rec.start <= ch && ch <= byteinfo_rec.end) {
 	            hit = True;
@@ -372,9 +373,9 @@
                         (state->GL_codeset) )
 
 static XlcCharSet
-gi_parse_charset(glyph_index, codeset)
-    unsigned long glyph_index;
-    CodeSet codeset;
+gi_parse_charset(
+    unsigned long glyph_index,
+    CodeSet codeset)
 {
     int i;
     XlcCharSet *charset_list = codeset->charset_list;
@@ -419,9 +420,9 @@
 }
 
 static Bool
-ct_parse_csi(inbufptr, ctr_seq_len)
-    XPointer inbufptr;
-    int *ctr_seq_len;
+ct_parse_csi(
+    const char *inbufptr,
+    int *ctr_seq_len)
 {
     int i;
     int num = sizeof(directionality_data) / sizeof(directionality_data[0]);
@@ -439,14 +440,14 @@
 }
 
 static int
-cmp_esc_sequence(inbufptr, charset)
-    XPointer inbufptr;
-    XlcCharSet charset;
+cmp_esc_sequence(
+    const char *inbufptr,
+    XlcCharSet charset)
 {
     int seq_len, name_len, total_len;
     unsigned char byte_m, byte_l;
-    char *ct_sequence =  charset->ct_sequence;
-    char *encoding_name = charset->encoding_name;
+    const char *ct_sequence =  charset->ct_sequence;
+    const char *encoding_name = charset->encoding_name;
 
     /* check esc sequence */
     if ( !(seq_len = strlen(ct_sequence) ) )
@@ -455,19 +456,19 @@
 	return(0);
 
     /* Standard Character Set Encoding ? */
-    if(charset->source == CSsrcStd)
+    if (charset->source == CSsrcStd)
         return(seq_len);
 
     /*
      *   Non-Standard Character Set Encoding
      *
-     * +-----+-----+-----+-----+-----+-----+-----+----   ----+-----+-----+
-     * |     esc sequence      |  M  |  L  |     encoding name     | STX |
-     * +-----+-----+-----+-----+-----+-----+-----+----   ----+-----+-----+
-     *           4bytes         1byte 1byte     variable length     1byte 
-     * 	                   |                                         |
-     * 	                   +-----------------------------------------+
-     * 	                     name length  = ((M - 128) * 128) + (L - 128)
+     * +--- ---+-----+-----+-----+----   ----+-----+-----+-------   ------+
+     * | ctseq |  M  |  L  |     encoding name     | STX |     contents   |
+     * +--- ---+-----+-----+-----+----   ----+-----+-----+-------   ------+
+     *  4bytes  1byte 1byte     variable length     1byte  variable length
+     * 	                   |                                              |
+     * 	                   +----------------------------------------------+
+     * 	                     rest length  = ((M - 128) * 128) + (L - 128)
      */
 
     /* get length of encoding name */
@@ -490,11 +491,11 @@
 }
 
 static Bool
-ct_parse_charset(lcd, inbufptr, charset, ctr_seq_len)
-    XLCd lcd;
-    XPointer inbufptr;
-    XlcCharSet *charset;
-    int *ctr_seq_len;
+ct_parse_charset(
+    XLCd lcd,
+    const char *inbufptr,
+    XlcCharSet *charset,
+    int *ctr_seq_len)
 {
     int i, j;
     ExtdSegment ctextseg;
@@ -506,7 +507,6 @@
     int segment_conv_num  = XLC_GENERIC(lcd, segment_conv_num);
     SegConv segment_conv  = XLC_GENERIC(lcd, segment_conv);
 
-
     /* get charset from XLC_XLOCALE by escape sequence */
 
     for (i = 0; i < codeset_num; i++) {
@@ -518,13 +518,13 @@
 
 	for (j = 0; j < num_charsets; j++) {
 	    *charset = charset_list[j];
-            if ( *ctr_seq_len = cmp_esc_sequence(inbufptr, *charset) )
+            if ((*ctr_seq_len = cmp_esc_sequence(inbufptr, *charset)))
 		return(True);
 	}
 
 	if (ctextseg) {
 	    *charset = ctextseg->charset;
-            if ( *ctr_seq_len = cmp_esc_sequence(inbufptr, *charset) )
+            if ((*ctr_seq_len = cmp_esc_sequence(inbufptr, *charset)))
 		return(True);
 	}
     }
@@ -536,10 +536,10 @@
 
     for (i = 0; i < segment_conv_num; i++) {
 	*charset = segment_conv[i].source;
-        if ( *ctr_seq_len = cmp_esc_sequence(inbufptr, *charset) )
+        if ((*ctr_seq_len = cmp_esc_sequence(inbufptr, *charset)))
 	    return(True);
 	*charset = segment_conv[i].dest;
-        if ( *ctr_seq_len = cmp_esc_sequence(inbufptr, *charset) )
+        if ((*ctr_seq_len = cmp_esc_sequence(inbufptr, *charset)))
 	    return(True);
     }
 
@@ -547,10 +547,10 @@
 }
 
 static Bool
-segment_conversion(lcd, charset, glyph_index)
-    XLCd lcd;
-    XlcCharSet *charset;
-    unsigned long *glyph_index;
+segment_conversion(
+    XLCd lcd,
+    XlcCharSet *charset,
+    unsigned long *glyph_index)
 {
     int i;
     int segment_conv_num = XLC_GENERIC(lcd, segment_conv_num);
@@ -581,10 +581,10 @@
     return(True);
 }
 
-CodeSet
-_XlcGetCodeSetFromName(lcd, name)
-    XLCd lcd;
-    char *name;
+static CodeSet
+_XlcGetCodeSetFromName(
+    XLCd lcd,
+    const char *name)
 {
     int i, j;
     XlcCharSet charset;
@@ -615,11 +615,11 @@
 }
 
 static Bool
-_XlcGetCodeSetFromCharSet(lcd, charset, codeset, glyph_index)
-    XLCd lcd;
-    XlcCharSet charset;
-    CodeSet *codeset;
-    unsigned long *glyph_index;
+_XlcGetCodeSetFromCharSet(
+    XLCd lcd,
+    XlcCharSet charset,
+    CodeSet *codeset,
+    unsigned long *glyph_index)
 {
     int j, num;
     CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
@@ -641,7 +641,7 @@
 
         glyph_index_tmp = conv_to_source(ctconv, *glyph_index);
 
-        if(charset->source == CSsrcStd) {
+        if (charset->source == CSsrcStd) {
 
             /* Standard Character Set Encoding */
 	    if (glyph_index_tmp == *glyph_index) {
@@ -683,11 +683,11 @@
 #define check_string_encoding(codeset)	(codeset->string_encoding)
 
 static void
-output_ulong_value(outbufptr, code, length, side)
-    XPointer outbufptr;
-    unsigned long code;
-    int length;
-    XlcSide side;
+output_ulong_value(
+    char *outbufptr,
+    unsigned long code,
+    int length,
+    XlcSide side)
 {
     int i;
 
@@ -712,10 +712,10 @@
 static XlcCharSet default_GR_charset = 0;
 
 static void
-init_state(conv)
-    XlcConv conv;
+init_state(
+    XlcConv conv)
 {
-    register State state = (State) conv->state;
+    State state = (State) conv->state;
 
     /* for CT */
     state->charset = NULL;
@@ -732,14 +732,14 @@
 /* -------------------------------------------------------------------------- */
 
 static int
-mbstowcs_org(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+mbstowcs_org(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -754,7 +754,7 @@
 
     CodeSet codeset = NULL;
 
-    XPointer inbufptr = *from;
+    const char *inbufptr = *from;
     wchar_t *outbufptr = (wchar_t *) *to;
     int from_size = *from_left;
 
@@ -793,7 +793,8 @@
 
         /* next mb char data for single shift ? */
 	if (mb_parse_table && (num = mb_parse_table[ch]) ) {
-            if( codeset = mb_parse_codeset(state, num, &inbufptr, from_left)) {
+	    codeset = mb_parse_codeset(state, num, &inbufptr, from_left);
+            if (codeset != NULL) {
 		length = len_left = codeset->length;
 		mb = 0;
 		continue;
@@ -836,24 +837,24 @@
 	unconv_num += (length - len_left);
     }
 
-    *from = *from + from_size;
+    *from = (XPointer) ((const char *) *from + from_size);
     *from_left = 0;
-    *to = (XPointer)outbufptr;
+    *to = (XPointer) outbufptr;
 
     return unconv_num;
 }
 
 static int
-stdc_mbstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_mbstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    char *src = *((char **) from);
+    const char *src = *((const char **) from);
     wchar_t *dst = *((wchar_t **) to);
     int src_left = *from_left;
     int dst_left = *to_left;
@@ -892,14 +893,14 @@
 }
 
 static int
-wcstombs_org(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstombs_org(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -913,11 +914,11 @@
 
     CodeSet codeset;
 
-    wchar_t *inbufptr = (wchar_t *) *from;
-    XPointer outbufptr = *to;
+    const wchar_t *inbufptr = (const wchar_t *) *from;
+    char *outbufptr = *to;
     int from_size = *from_left;
     
-    char *default_string = XLC_PUBLIC(lcd, default_string);
+    const char *default_string = XLC_PUBLIC(lcd, default_string);
     int defstr_len = strlen(default_string);
 
 
@@ -1002,24 +1003,24 @@
 
     } /* end of while */
 
-    *from = *from + from_size;
+    *from = (XPointer) ((const char *) *from + from_size);
     *from_left = 0;
-    *to = outbufptr;
+    *to = (XPointer) outbufptr;
 
     return unconv_num;
 }
 
 static int
-stdc_wcstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_wcstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    wchar_t *src = *((wchar_t **) from);
+    const wchar_t *src = *((const wchar_t **) from);
     char *dst = *((char **) to);
     int src_left = *from_left;
     int dst_left = *to_left;
@@ -1051,14 +1052,14 @@
 }
 
 static int
-wcstocts(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstocts(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -1073,10 +1074,10 @@
 
     CodeSet codeset;
     XlcCharSet charset, old_charset = NULL;
-    char *ct_sequence;
+    const char *ct_sequence;
 
-    wchar_t *inbufptr = (wchar_t *) *from;
-    XPointer outbufptr = *to;
+    const wchar_t *inbufptr = (const wchar_t *) *from;
+    char *outbufptr = *to;
     int from_size = *from_left;
 
 
@@ -1180,27 +1181,27 @@
 
     } /* end of while */
 
-    *from = *from + from_size;
+    *from = (XPointer) ((const char *) *from + from_size);
     *from_left = 0;
-    *to = outbufptr;
+    *to = (XPointer) outbufptr;
 
     return unconv_num;
 }
 
 static int
-stdc_wcstocts(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_wcstocts(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
-    XPointer buf_ptr1 = buf;
+    char *buf_ptr1 = buf;
     int buf_left1 = (*from_left) * MB_CUR_MAX;
-    XPointer buf_ptr2 = buf_ptr1;
+    char *buf_ptr2 = buf_ptr1;
     int buf_left2;
     int unconv_num1 = 0, unconv_num2 = 0;
 
@@ -1224,14 +1225,14 @@
 }
 
 static int
-ctstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+ctstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -1246,11 +1247,10 @@
     CodeSet codeset = NULL;
     XlcCharSet charset_tmp;
 
-    XPointer inbufptr = *from;
+    const char *inbufptr = *from;
     wchar_t *outbufptr = (wchar_t *) *to;
     int from_size = *from_left;
 
-
     _XlcResetConverter(conv); /* ??? */
 
     if (from == NULL || *from == NULL) {
@@ -1405,22 +1405,22 @@
 	unconv_num += (gi_len - gi_len_left);
     }
 
-    *from = *from + from_size;
+    *from = (XPointer) ((const char *) *from + from_size);
     *from_left = 0;
-    *to = (XPointer)outbufptr;
+    *to = (XPointer) outbufptr;
 
     return unconv_num;
 }
 
 static int
-cstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -1435,7 +1435,7 @@
     CodeSet codeset = NULL;
     XlcCharSet charset, charset_tmp;
 
-    XPointer inbufptr = *from;
+    const char *inbufptr = *from;
     wchar_t *outbufptr = (wchar_t *) *to;
     int from_size = *from_left;
 
@@ -1504,27 +1504,27 @@
 	unconv_num += (gi_len - gi_len_left);
     }
 
-    *from = *from + from_size;
+    *from = (XPointer) ((const char *) *from + from_size);
     *from_left = 0;
-    *to = (XPointer)outbufptr;
+    *to = (XPointer) outbufptr;
 
     return unconv_num;
 }
 
 static int
-stdc_ctstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_ctstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
-    XPointer buf_ptr1 = buf;
+    char *buf_ptr1 = buf;
     int buf_left1 = (*from_left) * MB_CUR_MAX;
-    XPointer buf_ptr2 = buf_ptr1;
+    char *buf_ptr2 = buf_ptr1;
     int buf_left2;
     int unconv_num1 = 0, unconv_num2 = 0;
 
@@ -1548,19 +1548,19 @@
 }
 
 static int
-stdc_cstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_cstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
-    XPointer buf_ptr1 = buf;
+    char *buf_ptr1 = buf;
     int buf_left1 = (*from_left) * MB_CUR_MAX;
-    XPointer buf_ptr2 = buf_ptr1;
+    char *buf_ptr2 = buf_ptr1;
     int buf_left2;
     int unconv_num1 = 0, unconv_num2 = 0;
 
@@ -1584,19 +1584,19 @@
 }
 
 static int
-mbstocts(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+mbstocts(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t));
-    XPointer buf_ptr1 = buf;
+    char *buf_ptr1 = buf;
     int buf_left1 = (*from_left);
-    XPointer buf_ptr2 = buf_ptr1;
+    char *buf_ptr2 = buf_ptr1;
     int buf_left2;
     int unconv_num1 = 0, unconv_num2 = 0;
 
@@ -1620,14 +1620,14 @@
 }
 
 static int
-mbstostr(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+mbstostr(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -1641,8 +1641,8 @@
 
     CodeSet codeset = NULL;
 
-    XPointer inbufptr = *from;
-    XPointer outbufptr = *to;
+    const char *inbufptr = *from;
+    char *outbufptr = *to;
     int from_size = *from_left;
 
     unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
@@ -1680,7 +1680,8 @@
 
         /* next mb char data for single shift ? */
 	if (mb_parse_table && (num = mb_parse_table[ch]) ) {
-            if( codeset = mb_parse_codeset(state, num, &inbufptr, from_left)) {
+	    codeset = mb_parse_codeset(state, num, &inbufptr, from_left);
+            if (codeset != NULL) {
 		length = len_left = codeset->length;
 		mb = 0;
 		continue;
@@ -1726,22 +1727,22 @@
         unconv_num += (length - len_left);
     }
 
-    *from = *from + from_size;
+    *from = (XPointer) ((const char *) *from + from_size);
     *from_left = 0;
-    *to = (XPointer)outbufptr;
+    *to = (XPointer) outbufptr;
 
     return unconv_num;
 }
 
 static int
-mbtocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+mbtocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -1758,8 +1759,8 @@
     CodeSet codeset = NULL;
     XlcCharSet charset;
 
-    XPointer inbufptr = *from;
-    XPointer outbufptr = *to;
+    const char *inbufptr = *from;
+    char *outbufptr = *to;
     int from_size = *from_left;
 
     unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
@@ -1791,7 +1792,8 @@
 
         /* next mb char data for single shift ? */
 	if (mb_parse_table && (num = mb_parse_table[ch]) ) {
-            if( codeset = mb_parse_codeset(state, num, &inbufptr, from_left)) {
+	    codeset = mb_parse_codeset(state, num, &inbufptr, from_left);
+            if (codeset != NULL) {
 		length = len_left = codeset->length;
 		mb = 0;
 		continue;
@@ -1850,15 +1852,15 @@
 
     /* error end */
     if (unconv_num) {
-        *from = *from + from_size;
+        *from = (XPointer) ((const char *) *from + from_size);
         *from_left = 0;
-        *to = outbufptr;
+        *to = (XPointer) outbufptr;
 	return -1;
     }
 
     /* nomal end */
-    *from = inbufptr;
-    *to = outbufptr;
+    *from = (XPointer) inbufptr;
+    *to = (XPointer) outbufptr;
 
     if (num_args > 0)
         *((XlcCharSet *) args[0]) = charset;
@@ -1867,22 +1869,22 @@
 }
 
 static int
-mbstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+mbstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     int ret;
     XlcCharSet charset_old, charset = NULL;
     XPointer tmp_args[1];
 
-    XPointer inbufptr;
+    const char *inbufptr;
     int	in_left;
-    XPointer outbufptr;
+    char *outbufptr;
     int	out_left;
     tmp_args[0] = (XPointer) &charset;
 
@@ -1896,9 +1898,9 @@
 	out_left = *to_left;
         ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1);
         if (charset_old != charset) {
-           *from = inbufptr;
+           *from = (XPointer) inbufptr;
            *from_left = in_left;
-           *to = outbufptr;
+           *to = (XPointer) outbufptr;
            *to_left = out_left;
            break;
         }
@@ -1915,14 +1917,14 @@
 }
 
 static int
-wcstostr(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstostr(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -1936,11 +1938,11 @@
 
     CodeSet codeset;
 
-    wchar_t *inbufptr = (wchar_t *) *from;
-    XPointer outbufptr = *to;
+    const wchar_t *inbufptr = (const wchar_t *) *from;
+    char *outbufptr = *to;
     int from_size = *from_left;
     
-    char *default_string = XLC_PUBLIC(lcd, default_string);
+    const char *default_string = XLC_PUBLIC(lcd, default_string);
     int defstr_len = strlen(default_string);
 
 
@@ -2031,27 +2033,27 @@
 
     } /* end of while */
 
-    *from = *from + from_size;
+    *from = (XPointer) ((const char *) *from + from_size);
     *from_left = 0;
-    *to = outbufptr;
+    *to = (XPointer) outbufptr;
 
     return unconv_num;
 }
 
 static int
-stdc_wcstostr(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_wcstostr(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
-    XPointer buf_ptr1 = buf;
+    char *buf_ptr1 = buf;
     int buf_left1 = (*from_left) * MB_CUR_MAX;
-    XPointer buf_ptr2 = buf_ptr1;
+    char *buf_ptr2 = buf_ptr1;
     int buf_left2;
     int unconv_num1 = 0, unconv_num2 = 0;
 
@@ -2075,14 +2077,14 @@
 }
 
 static int
-wctocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wctocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -2097,8 +2099,8 @@
     CodeSet codeset;
     XlcCharSet charset;
 
-    wchar_t *inbufptr = (wchar_t *) *from;
-    XPointer outbufptr = *to;
+    const wchar_t *inbufptr = (const wchar_t *) *from;
+    char *outbufptr = *to;
     int from_size = *from_left;
 
     if (*from_left > *to_left)
@@ -2149,15 +2151,15 @@
 
      /* error end */
     if (unconv_num) {
-        *from = *from + from_size;
+        *from = (XPointer) ((const char *) *from + from_size);
         *from_left = 0;
-        *to = outbufptr;
+        *to = (XPointer) outbufptr;
         return -1;
     }
 
     /* nomal end */
-    *from = (XPointer)inbufptr;
-    *to = outbufptr;
+    *from = (XPointer) inbufptr;
+    *to = (XPointer) outbufptr;
 
     if (num_args > 0)
         *((XlcCharSet *) args[0]) = charset;
@@ -2166,16 +2168,17 @@
 }
 
 static int
-stdc_wctocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_wctocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    wchar_t wch, *src = *((wchar_t **) from);
+    const wchar_t *src = *((const wchar_t **) from);
+    wchar_t wch;
     XPointer tmp_from, save_from = *from;
     char tmp[32];
     int length, ret, src_left = *from_left;
@@ -2203,7 +2206,7 @@
 end:
      /* error end */
     if (save_from == (XPointer) src) {
-        *from = *from + from_size;
+        *from = (XPointer) ((const char *) *from + from_size);
         *from_left = 0;
 	return -1;
     }
@@ -2216,20 +2219,20 @@
 }
 
 static int
-wcstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     int ret;
     XlcCharSet charset_old, charset = NULL;
     XPointer tmp_args[1];
 
-    wchar_t *inbufptr;
+    const wchar_t *inbufptr;
     int	in_left;
     XPointer outbufptr;
     int	out_left;
@@ -2239,15 +2242,15 @@
     charset_old = charset;
 
     while ( ret == 0 && *from_left && *to_left) {
-	inbufptr = (wchar_t *)(*from);
+	inbufptr = (const wchar_t *) *from;
 	in_left = *from_left;
 	outbufptr = *to;
 	out_left = *to_left;
         ret = wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
         if (charset_old != charset) {
-           *from = (XPointer)inbufptr;
+           *from = (XPointer) inbufptr;
            *from_left = in_left;
-           *to = outbufptr;
+           *to = (XPointer) outbufptr;
            *to_left = out_left;
            break;
         }
@@ -2264,20 +2267,20 @@
 }
 
 static int
-stdc_wcstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_wcstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     int ret;
     XlcCharSet charset_old, charset = NULL;
     XPointer tmp_args[1];
 
-    wchar_t *inbufptr;
+    const wchar_t *inbufptr;
     int	in_left;
     XPointer outbufptr;
     int	out_left;
@@ -2287,15 +2290,15 @@
     charset_old = charset;
 
     while ( ret == 0 && *from_left && *to_left ) {
-	inbufptr = (wchar_t *)(*from);
+	inbufptr = (const wchar_t *) *from;
 	in_left = *from_left;
 	outbufptr = *to;
 	out_left = *to_left;
         ret = stdc_wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
         if (charset_old != charset) {
-           *from = (XPointer)inbufptr;
+           *from = (XPointer) inbufptr;
            *from_left = in_left;
-           *to = outbufptr;
+           *to = (XPointer) outbufptr;
            *to_left = out_left;
            break;
         }
@@ -2312,19 +2315,19 @@
 }
 
 static int
-ctstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+ctstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t));
-    XPointer buf_ptr1 = buf;
+    char *buf_ptr1 = buf;
     int buf_left1 = (*from_left);
-    XPointer buf_ptr2 = buf_ptr1;
+    char *buf_ptr2 = buf_ptr1;
     int buf_left2;
     int unconv_num1 = 0, unconv_num2 = 0;
 
@@ -2348,19 +2351,19 @@
 }
 
 static int
-cstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t));
-    XPointer buf_ptr1 = buf;
+    char *buf_ptr1 = buf;
     int buf_left1 = (*from_left);
-    XPointer buf_ptr2 = buf_ptr1;
+    char *buf_ptr2 = buf_ptr1;
     int buf_left2;
     int unconv_num1 = 0, unconv_num2 = 0;
 
@@ -2384,14 +2387,14 @@
 }
 
 static int
-strtombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+strtombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -2405,8 +2408,8 @@
 
     CodeSet codeset;
 
-    XPointer inbufptr = *from;
-    XPointer outbufptr = *to;
+    const char *inbufptr = *from;
+    char *outbufptr = *to;
     int from_size = *from_left;
 
     if (*from_left > *to_left)
@@ -2488,22 +2491,22 @@
 
     } /* end of while */
 
-    *from = *from + from_size;
+    *from = (XPointer) ((const char *) *from + from_size);
     *from_left = 0;
-    *to = outbufptr;
+    *to = (XPointer) outbufptr;
 
     return unconv_num;
 }
 
 static int
-strtowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+strtowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
@@ -2515,7 +2518,7 @@
     int unconv_num = 0;
     CodeSet codeset;
 
-    XPointer inbufptr = *from;
+    const char *inbufptr = *from;
     wchar_t *outbufptr = (wchar_t *)*to;
     int from_size = *from_left;
 
@@ -2555,27 +2558,27 @@
 
     } /* end of while */
 
-    *from = *from + from_size;
+    *from = (XPointer) ((const char *) *from + from_size);
     *from_left = 0;
-    *to = (XPointer)outbufptr;
+    *to = (XPointer) outbufptr;
 
     return unconv_num;
 }
 
 static int
-stdc_strtowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_strtowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
-    XPointer buf_ptr1 = buf;
+    char *buf_ptr1 = buf;
     int buf_left1 = (*from_left) * MB_CUR_MAX;
-    XPointer buf_ptr2 = buf_ptr1;
+    char *buf_ptr2 = buf_ptr1;
     int buf_left2;
     int unconv_num1 = 0, unconv_num2 = 0;
 
@@ -2603,8 +2606,8 @@
 /* -------------------------------------------------------------------------- */
 
 static void
-close_converter(conv)
-    XlcConv conv;
+close_converter(
+    XlcConv conv)
 {
     if (conv->state) {
 	Xfree((char *) conv->state);
@@ -2622,9 +2625,9 @@
 /* -------------------------------------------------------------------------- */
 
 static XlcConv
-create_conv(lcd, methods)
-    XLCd lcd;
-    XlcConvMethods methods;
+create_conv(
+    XLCd lcd,
+    XlcConvMethods methods)
 {
     XlcConv conv;
     State state;
@@ -2661,14 +2664,14 @@
     close_converter,
     mbstocts,
     NULL
-} ;
+};
 
 static XlcConv
-open_mbstocts(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstocts(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbstocts_methods);
 }
@@ -2677,14 +2680,14 @@
     close_converter,
     mbstostr,
     NULL
-} ;
+};
 
 static XlcConv
-open_mbstostr(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstostr(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbstostr_methods);
 }
@@ -2693,14 +2696,14 @@
     close_converter,
     mbstocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_mbstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbstocs_methods);
 }
@@ -2709,14 +2712,14 @@
     close_converter,
     mbtocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_mbtocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbtocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbtocs_methods);
 }
@@ -2725,14 +2728,14 @@
     close_converter,
     ctstombs,
     NULL
-} ;
+};
 
 static XlcConv
-open_ctstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_ctstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &ctstombs_methods);
 }
@@ -2741,14 +2744,14 @@
     close_converter,
     cstombs,
     NULL
-} ;
+};
 
 static XlcConv
-open_cstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &cstombs_methods);
 }
@@ -2757,14 +2760,14 @@
     close_converter,
     strtombs,
     NULL
-} ;
+};
 
 static XlcConv
-open_strtombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_strtombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &strtombs_methods);
 }
@@ -2775,14 +2778,14 @@
     close_converter,
     stdc_mbstowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_mbstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_mbstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_mbstowcs_methods);
 }
@@ -2791,14 +2794,14 @@
     close_converter,
     stdc_wcstombs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_wcstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_wcstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_wcstombs_methods);
 }
@@ -2807,14 +2810,14 @@
     close_converter,
     stdc_wcstocts,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_wcstocts(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_wcstocts(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_wcstocts_methods);
 }
@@ -2823,14 +2826,14 @@
     close_converter,
     stdc_wcstostr,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_wcstostr(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_wcstostr(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_wcstostr_methods);
 }
@@ -2839,14 +2842,14 @@
     close_converter,
     stdc_wcstocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_wcstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_wcstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_wcstocs_methods);
 }
@@ -2855,14 +2858,14 @@
     close_converter,
     stdc_wctocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_wctocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_wctocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_wctocs_methods);
 }
@@ -2871,14 +2874,14 @@
     close_converter,
     stdc_ctstowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_ctstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_ctstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_ctstowcs_methods);
 }
@@ -2887,14 +2890,14 @@
     close_converter,
     stdc_cstowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_cstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_cstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_cstowcs_methods);
 }
@@ -2903,14 +2906,14 @@
     close_converter,
     stdc_strtowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_strtowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_strtowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_strtowcs_methods);
 }
@@ -2921,14 +2924,14 @@
     close_converter,
     mbstowcs_org,
     NULL
-} ;
+};
 
 static XlcConv
-open_mbstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbstowcs_methods);
 }
@@ -2937,14 +2940,14 @@
     close_converter,
     wcstombs_org,
     NULL
-} ;
+};
 
 static XlcConv
-open_wcstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &wcstombs_methods);
 }
@@ -2953,14 +2956,14 @@
     close_converter,
     wcstocts,
     NULL
-} ;
+};
 
 static XlcConv
-open_wcstocts(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocts(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &wcstocts_methods);
 }
@@ -2969,14 +2972,14 @@
     close_converter,
     wcstostr,
     NULL
-} ;
+};
 
 static XlcConv
-open_wcstostr(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstostr(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &wcstostr_methods);
 }
@@ -2985,14 +2988,14 @@
     close_converter,
     wcstocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_wcstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &wcstocs_methods);
 }
@@ -3001,14 +3004,14 @@
     close_converter,
     wctocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_wctocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wctocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &wctocs_methods);
 }
@@ -3017,14 +3020,14 @@
     close_converter,
     ctstowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_ctstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_ctstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &ctstowcs_methods);
 }
@@ -3033,14 +3036,14 @@
     close_converter,
     cstowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_cstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &cstowcs_methods);
 }
@@ -3049,14 +3052,14 @@
     close_converter,
     strtowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_strtowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_strtowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &strtowcs_methods);
 }
@@ -3066,8 +3069,8 @@
 /* -------------------------------------------------------------------------- */
 
 XLCd
-_XlcGenericLoader(name)
-    _Xconst char *name;
+_XlcGenericLoader(
+    const char *name)
 {
     XLCd lcd;
     XLCdGenericPart *gen;
Index: xc/lib/X11/lcGeneric.c
diff -u xc/lib/X11/lcGeneric.c:3.9 xc/lib/X11/lcGeneric.c:3.13
--- xc/lib/X11/lcGeneric.c:3.9	Fri Feb 25 13:27:56 2000
+++ xc/lib/X11/lcGeneric.c	Wed Dec  6 17:00:42 2000
@@ -28,15 +28,15 @@
  *  This is source code modified by FUJITSU LIMITED under the Joint
  *  Development Agreement for the CDE/Motif PST.
  */
-/* $XFree86: xc/lib/X11/lcGeneric.c,v 3.9 2000/02/25 18:27:56 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcGeneric.c,v 3.13 2000/12/06 22:00:42 dawes Exp $ */
 
 #include <stdio.h>
 #include "Xlibint.h"
 #include "XlcGeneric.h"
 
-static XLCd create();
-static Bool initialize();
-static void destroy();
+static XLCd create (const char *name, XLCdMethods methods);
+static Bool initialize (XLCd lcd);
+static void destroy (XLCd lcd);
 
 static XLCdPublicMethodsRec genericMethods = {
     { NULL },                   /* use default methods */
@@ -52,9 +52,9 @@
 XLCdMethods _XlcGenericMethods = (XLCdMethods) &genericMethods;
 
 static XLCd
-create(name, methods)
-    char *name;
-    XLCdMethods methods;
+create(
+    const char *name,
+    XLCdMethods methods)
 {
     XLCd lcd;
     XLCdPublicMethods new;
@@ -72,7 +72,7 @@
     new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
     if (new == NULL)
 	goto err;
-    *new = *((XLCdPublicMethods) methods);
+    memcpy(new,methods,sizeof(XLCdPublicMethodsRec));
     lcd->methods = (XLCdMethods) new;
 
     return lcd;
@@ -83,9 +83,9 @@
 }
 
 static Bool
-string_to_encoding(str, encoding)
-    char *str;
-    char *encoding;
+string_to_encoding(
+    const char *str,
+    char *encoding)
 {
     char *next;
     long value;
@@ -118,18 +118,18 @@
 }
 
 static Bool
-string_to_ulong(str, value)
-char	*str;
-unsigned long	*value;
+string_to_ulong(
+    const char *str,
+    unsigned long *value)
 {
-     char	*tmp1 = str;
-     int	 base;
+     const char *tmp1 = str;
+     int base;
 
-     if(*tmp1++ != '\\'){
+     if (*tmp1++ != '\\') {
 	  tmp1--;
 	  base = 10;
-     }else{
-	  switch(*tmp1++){
+     } else {
+	  switch (*tmp1++) {
 	  case 'x':
 	       base = 16;
 	       break;
@@ -143,15 +143,15 @@
 	       return(False);
 	  }
      }
-    *value = (unsigned) strtol(tmp1, NULL, base);
+     *value = (unsigned long) strtol(tmp1, NULL, base);
      return(True);
 }
 
 
 static Bool
-add_charset(codeset, charset)
-    CodeSet codeset;
-    XlcCharSet charset;
+add_charset(
+    CodeSet codeset,
+    XlcCharSet charset)
 {
     XlcCharSet *new_list;
     int num;
@@ -173,8 +173,8 @@
 }
 
 static CodeSet
-add_codeset(gen)
-    XLCdGenericPart *gen;
+add_codeset(
+    XLCdGenericPart *gen)
 {
     CodeSet new, *new_list;
     int num;
@@ -206,11 +206,11 @@
 }
 
 static Bool
-add_parse_list(gen, type, encoding, codeset)
-    XLCdGenericPart *gen;
-    EncodingType type;
-    char *encoding;
-    CodeSet codeset;
+add_parse_list(
+    XLCdGenericPart *gen,
+    EncodingType type,
+    const char *encoding,
+    CodeSet codeset)
 {
     ParseInfo new, *new_list;
     char *str;
@@ -271,8 +271,8 @@
 }
 
 static void
-free_charset(lcd)
-    XLCd lcd;
+free_charset(
+    XLCd lcd)
 {
     XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);
     ParseInfo *parse_info;
@@ -280,7 +280,7 @@
 
     if (gen->mb_parse_table)
         Xfree(gen->mb_parse_table);
-    if ((num = gen->mb_parse_list_num)) {
+    if ((num = gen->mb_parse_list_num) > 0) {
         for (parse_info = gen->mb_parse_list; num-- > 0; parse_info++) {
             if ((*parse_info)->encoding)
                 Xfree((*parse_info)->encoding);
@@ -289,23 +289,28 @@
         Xfree(gen->mb_parse_list);
     }
 
-    if ((num = gen->codeset_num))
+    if ((num = gen->codeset_num) > 0)
         Xfree(gen->codeset_list);
 }
+
 /* For VW/UDC */
 
 #define FORWARD  (unsigned long)'+'
 #define BACKWARD (unsigned long)'-'
 
-static char *getscope(str,scp)
-char *str;
-FontScope scp;
-{
-    char* next;
-    unsigned long start=0,end=0,dest=0,shift=0,direction=0;
-    sscanf(str,"[\\x%lx,\\x%lx]->\\x%lx", &start, &end,&dest);
-    if( dest ){
-        if(dest >= start ){
+static const char *
+getscope(
+    const char *str,
+    FontScope scp)
+{
+    unsigned long start = 0;
+    unsigned long end = 0;
+    unsigned long dest = 0;
+    unsigned long shift = 0;
+    unsigned long direction = 0;
+    sscanf(str,"[\\x%lx,\\x%lx]->\\x%lx", &start, &end, &dest);
+    if (dest) {
+        if (dest >= start) {
             shift = dest - start;
             direction = FORWARD ;
         } else {
@@ -319,86 +324,88 @@
     scp->shift_direction
                = direction  ;
     /* .......... */
-    while(*str){
-        if(*str == ',' && *(str+1) == '['){
+    while (*str) {
+        if (*str == ',' && *(str+1) == '[')
             break;
-        }
         str++;
     }
-    next = str+1 ;
-    return(next);
+    return str+1;
 }
 
-static int count_scopemap(str)
-char *str;
+static int
+count_scopemap(
+    const char *str)
 {
-    char *ptr;
+    const char *ptr;
     int num=0;
-    for(ptr=str;*ptr;ptr++){
-        if(*ptr == ']'){
-            num ++;
+    for (ptr=str; *ptr; ptr++) {
+        if (*ptr == ']') {
+            num++;
         }
     }
-    return(num);
+    return num;
 }
 
-FontScope _XlcParse_scopemaps(str,size)
-char *str;
-int *size;
+FontScope
+_XlcParse_scopemaps(
+    const char *str,
+    int *size)
 {
-        int num=0,i;
-        FontScope scope,sc_ptr;
-        char *str_sc;
-        num = count_scopemap(str);
-        scope = (FontScope )Xmalloc(num * sizeof(FontScopeRec));
-        if(scope == NULL) {
-                return (NULL);
-        }
-        for (i=0,str_sc=str,sc_ptr=scope;
-                        i < num; i++,sc_ptr++){
-                str_sc = getscope(str_sc,sc_ptr);
-        }
-        *size = num;
-        return (scope);
+    int num=0,i;
+    FontScope scope,sc_ptr;
+    const char *str_sc;
+
+    num = count_scopemap(str);
+    scope = (FontScope) Xmalloc(num * sizeof(FontScopeRec));
+    if (scope == NULL)
+	return NULL;
+
+    for (i=0, str_sc=str, sc_ptr=scope; i < num; i++, sc_ptr++) {
+	str_sc = getscope(str_sc, sc_ptr);
+    }
+    *size = num;
+    return scope;
 }
 
-void _XlcDbg_printValue(str,value,num)
-char *str;
-char **value;
-int num;
+void
+_XlcDbg_printValue(
+    const char *str,
+    char **value,
+    int num)
 {
 /*
     int i;
-    for(i=0;i<num;i++){
-        fprintf(stderr,"%s value[%d] = %s\n",str,i,value[i]);
-    }
+    for (i = 0; i < num; i++)
+        fprintf(stderr, "%s value[%d] = %s\n", str, i, value[i]);
 */
 }
 
-static void dmpscope(name,sc,num)
-char* name;
-FontScope sc;
-int num;
+static void
+dmpscope(
+    const char* name,
+    FontScope sc,
+    int num)
 {
 /*
     int i;
-    fprintf(stderr,"dmpscope %s\n",name);
-    for(i=0;i<num;i++){
+    fprintf(stderr, "dmpscope %s\n", name);
+    for (i=0; i<num; i++)
         fprintf(stderr,"%x %x %x %x \n",
                 sc[i].start,
                 sc[i].end,
                 sc[i].shift,
                 sc[i].shift_direction);
-    }
-    fprintf(stderr,"dmpscope end\n");
+    fprintf(stderr, "dmpscope end\n");
 */
 }
 
-static XlcCharSet srch_charset_define(name,new)
-char *name;
-int *new;
+static XlcCharSet
+srch_charset_define(
+    const char *name,
+    int *new)
 {
-    XlcCharSet charset = NULL;
+    XlcCharSet charset;
+
     *new = 0;
     charset = _XlcGetCharSet(name);
     if (charset == NULL &&
@@ -407,28 +414,29 @@
         *new = 1;
         charset->source = CSsrcXLC;
     }
-    return(charset);
+    return charset;
 }
 
-static void read_charset_define(lcd,gen)
-XLCd lcd;
-XLCdGenericPart *gen;
+static void
+read_charset_define(
+    XLCd lcd,
+    XLCdGenericPart *gen)
 {
-    int i=0;
-    char csd[16],cset_name[256];
+    int i;
+    char csd[16], cset_name[256];
     char name[BUFSIZ];
     XlcCharSet charsetd;
     char **value;
-    int num,new;
+    int num, new;
     XlcSide side = XlcUnknown;
     char *tmp;
 
-    for(i=0;;i++){ /* loop start */
+    for (i=0; ; i++) { /* loop start */
         charsetd = 0;
         sprintf(csd, "csd%d", i);
 
-        /* charset_name   */
-        sprintf(name, "%s.%s", csd , "charset_name");
+        /* charset_name  */
+        sprintf(name, "%s.%s", csd, "charset_name");
         _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
         _XlcDbg_printValue(name,value,num);
         if (num > 0) {
@@ -439,109 +447,102 @@
             _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
             if (num > 0) {
                 _XlcDbg_printValue(name,value,num);
-                if( !_XlcNCompareISOLatin1(value[0], "none", 4) ){
-                    side =  XlcNONE ;
-                    strcat(cset_name,":none");
-                } else
-                if( !_XlcNCompareISOLatin1(value[0], "GL", 2) ){
-                    side =  XlcGL ;
+                if (!_XlcNCompareISOLatin1(value[0], "none", 4)) {
+                    side =  XlcGLGR;
+                } else if (!_XlcNCompareISOLatin1(value[0], "GL", 2)) {
+                    side =  XlcGL;
                     strcat(cset_name,":GL");
                 } else {
-                    side =  XlcGR ;
+                    side =  XlcGR;
                     strcat(cset_name,":GR");
                 }
                 if (charsetd == NULL &&
                     (charsetd = srch_charset_define(cset_name,&new)) == NULL)
-                    return ;
+                    return;
             }
         } else {
-            if(i == 0){
-                continue ;
-            } else {
-                break ;
-            }
+            if (i == 0)
+                continue;
+            else
+                break;
         }
-        if(new){
+        if (new) {
             tmp = (char *)Xmalloc(strlen(cset_name)+1);
-            if(tmp == NULL){
-                return ;
-            }
+            if (tmp == NULL)
+                return;
             strcpy(tmp,cset_name);
             charsetd->name = tmp;
         }
         /* side   */
-        charsetd->side =  side ;
+        charsetd->side = side ;
         /* length */
-        sprintf(name, "%s.%s", csd , "length");
+        sprintf(name, "%s.%s", csd, "length");
         _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
         if (num > 0) {
             _XlcDbg_printValue(name,value,num);
             charsetd->char_size = atoi(value[0]);
         }
         /* gc_number */
-        sprintf(name, "%s.%s", csd , "gc_number");
+        sprintf(name, "%s.%s", csd, "gc_number");
         _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
         if (num > 0) {
             _XlcDbg_printValue(name,value,num);
             charsetd->set_size = atoi(value[0]);
         }
         /* string_encoding */
-        sprintf(name, "%s.%s", csd , "string_encoding");
+        sprintf(name, "%s.%s", csd, "string_encoding");
         _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
         if (num > 0) {
             _XlcDbg_printValue(name,value,num);
-            if(!strcmp("False",value[0])){
+            if (!strcmp("False",value[0])) {
                 charsetd->string_encoding = False;
             } else {
                 charsetd->string_encoding = True;
             }
         }
         /* sequence */
-        sprintf(name, "%s.%s", csd , "sequence");
+        sprintf(name, "%s.%s", csd, "sequence");
         _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
         if (num > 0) {
             _XlcDbg_printValue(name,value,num);
 /*
-            if(charsetd->ct_sequence){
+            if (charsetd->ct_sequence) {
                 Xfree(charsetd->ct_sequence);
             }
 */
             tmp = (char *)Xmalloc(strlen(value[0])+1);
-            if(tmp == NULL){
+            if (tmp == NULL)
                 return;
-            }
             charsetd->ct_sequence = tmp;
             string_to_encoding(value[0],tmp);
         }
         /* encoding_name */
-        sprintf(name, "%s.%s", csd , "encoding_name");
+        sprintf(name, "%s.%s", csd, "encoding_name");
         _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
         if (num > 0) {
             _XlcDbg_printValue(name,value,num);
 /*
-            if(charsetd->encoding_name){
+            if (charsetd->encoding_name) {
                 Xfree(charsetd->encoding_name);
             }
 */
             tmp = (char *)Xmalloc(strlen(value[0]+1));
             strcpy(tmp,value[0]);
             charsetd->encoding_name = tmp;
-            charsetd->xrm_encoding_name =
-                XrmStringToQuark(tmp);
+            charsetd->xrm_encoding_name = XrmStringToQuark(tmp);
         }
-        _XlcAddCT(name, charsetd->ct_sequence);
+        _XlcAddCT(charsetd->name, charsetd->ct_sequence);
     }
-
 }
 
-SegConv
-add_conversion(gen)
-XLCdGenericPart *gen;
+static SegConv
+add_conversion(
+    XLCdGenericPart *gen)
 {
     SegConv new_list;
     int num;
 
-    if ((num = gen->segment_conv_num)) {
+    if ((num = gen->segment_conv_num) > 0) {
         new_list = (SegConv) Xrealloc(gen->segment_conv,
                                         (num + 1) * sizeof(SegConvRec));
     } else {
@@ -549,102 +550,83 @@
     }
 
     if (new_list == NULL)
-        return False;
+        return NULL;
 
     gen->segment_conv = new_list;
     gen->segment_conv_num = num + 1;
 
-    return (&new_list[num]);
+    return &new_list[num];
 
 }
-static void read_segmentconversion(lcd,gen)
-XLCd lcd;
-XLCdGenericPart *gen;
+
+static void
+read_segmentconversion(
+    XLCd lcd,
+    XLCdGenericPart *gen)
 {
-    int i=0;
+    int i;
     char conv[16];
     char name[BUFSIZ];
     char **value;
     int num,new;
     SegConv conversion;
-    for(i=0 ; ; i++){ /* loop start */
+    for (i=0 ; ; i++) { /* loop start */
         conversion = 0;
         sprintf(conv, "conv%d", i);
 
         /* length                */
-        sprintf(name, "%s.%s", conv , "length");
+        sprintf(name, "%s.%s", conv, "length");
         _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
         if (num > 0) {
             if (conversion == NULL &&
                 (conversion = add_conversion(gen)) == NULL) {
-                return ;
+                return;
             }
             _XlcDbg_printValue(name,value,num);
         } else {
-            if(i == 0){
+            if (i == 0)
                 continue;
-            } else {
-                break ;
-            }
+            else
+                break;
         }
         conversion->length = atoi(value[0]);
 
         /* source_encoding       */
-        sprintf(name, "%s.%s", conv , "source_encoding");
+        sprintf(name, "%s.%s", conv, "source_encoding");
         _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
         if (num > 0) {
             char *tmp;
             _XlcDbg_printValue(name,value,num);
             tmp = (char *)Xmalloc(strlen(value[0])+1);
-            if(tmp == NULL){
+            if (tmp == NULL)
                 return;
-            }
             strcpy(tmp,value[0]);
             conversion->source_encoding = tmp;
             conversion->source = srch_charset_define(tmp,&new);
-            if(new){
-                tmp = (char *)Xmalloc(strlen(conversion->source_encoding)+1);
-                if(tmp == NULL){
-                    return ;
-                }
-                strcpy(tmp,conversion->source_encoding);
-                conversion->source->name = tmp;
-            }
         }
         /* destination_encoding  */
-        sprintf(name, "%s.%s", conv , "destination_encoding");
+        sprintf(name, "%s.%s", conv, "destination_encoding");
         _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
         if (num > 0) {
             char *tmp;
             _XlcDbg_printValue(name,value,num);
             tmp = (char *)Xmalloc(strlen(value[0])+1);
-            if(tmp == NULL){
+            if (tmp == NULL)
                 return;
-            }
             strcpy(tmp,value[0]);
             conversion->destination_encoding = tmp;
             conversion->dest = srch_charset_define(tmp,&new);
-            if(new){
-                tmp = (char *)Xmalloc(
-                    strlen(conversion->destination_encoding)+1);
-                if(tmp == NULL){
-                    return ;
-                }
-                strcpy(tmp,conversion->destination_encoding);
-                conversion->dest->name = tmp;
-            }
         }
         /* range                 */
-        sprintf(name, "%s.%s", conv , "range");
+        sprintf(name, "%s.%s", conv, "range");
         _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
         if (num > 0) {
             _XlcDbg_printValue(name,value,num);
             sscanf(value[0],"\\x%lx,\\x%lx",
-                &(conversion->range.start),
-                &(conversion->range.end));
+                   &(conversion->range.start), &(conversion->range.end));
         }
         /* conversion            */
-        sprintf(name, "%s.%s", conv , "conversion");
+        sprintf(name, "%s.%s", conv, "conversion");
         _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
         if (num > 0) {
             _XlcDbg_printValue(name,value,num);
@@ -654,9 +636,10 @@
     }  /* loop end */
 }
 
-static ExtdSegment create_ctextseg(value,num)
-char **value;
-int num;
+static ExtdSegment
+create_ctextseg(
+    char **value,
+    int num)
 {
     ExtdSegment ret;
     char* ptr;
@@ -664,69 +647,58 @@
     int i,new;
     FontScope scope;
     ret = (ExtdSegment)Xmalloc(sizeof(ExtdSegmentRec));
-    if(ret == NULL){
+    if (ret == NULL)
+        return NULL;
+    ret->name = (char *)Xmalloc(strlen(value[0]) + 1);
+    if (ret->name == NULL) {
+        Xfree (ret);
         return NULL;
     }
-    if(strchr(value[0],':')){
-        ret->name = (char *)Xmalloc(strlen(value[0])+1);
-        if(ret->name == NULL){
-	    Xfree (ret);
-            return NULL;
-        }
-        strcpy(ret->name,value[0]);
+    strcpy(ret->name,value[0]);
+    cset_name = (char*) Xmalloc (strlen(ret->name) + 1);
+    if (cset_name == NULL) {
+        Xfree (ret->name);
+        Xfree (ret);
+        return NULL;
+    }
+    if (strchr(value[0],':')) {
         ptr = strchr(ret->name,':');
         *ptr = '\0';
         ptr++;
-	cset_name = (char*) Xmalloc (strlen (ret->name) + 6);
-	if (cset_name == NULL) {
-	    Xfree (ret->name);
-	    Xfree (ret);
-	    return NULL;
-	}
-        if( !_XlcNCompareISOLatin1(ptr, "none", 4) ){
-            ret->side =  XlcNONE ;
-            sprintf(cset_name,"%s:%s",ret->name,"none");
-        } else
-        if( !_XlcNCompareISOLatin1(ptr, "GL", 2) ){
-            ret->side =  XlcGL ;
+        if (!_XlcNCompareISOLatin1(ptr, "GL", 2)) {
+            ret->side =  XlcGL;
             sprintf(cset_name,"%s:%s",ret->name,"GL");
         } else {
-            ret->side =  XlcGR ;
+            ret->side =  XlcGR;
             sprintf(cset_name,"%s:%s",ret->name,"GR");
         }
     } else {
-        ret->name = (char *)Xmalloc(strlen(value[0])+1);
-        if(ret->name == NULL){
-	    Xfree (ret);
-            return NULL;
-        }
-        strcpy(ret->name,value[0]);
+        ret->side =  XlcGLGR;
+        strcpy(cset_name,ret->name);
     }
     ret->area = (FontScope)Xmalloc((num - 1)*sizeof(FontScopeRec));
-    if(ret->area == NULL){
+    if (ret->area == NULL) {
+	Xfree (cset_name);
 	Xfree (ret->name);
 	Xfree (ret);
         return NULL;
     }
-    ret->area_num  = num - 1;
+    ret->area_num = num - 1;
     scope = ret->area ;
-    for(i=1;i<num;i++){
+    for (i = 1; i < num; i++) {
         sscanf(value[i],"\\x%lx,\\x%lx",
-                &scope[i-1].start,&scope[i-1].end);
+               &scope[i-1].start, &scope[i-1].end);
     }
     ret->charset = srch_charset_define(cset_name,&new);
-    if (new)
-        ret->charset->name = cset_name;
-    else
-	Xfree (cset_name);
+    Xfree (cset_name);
 
     return ret;
 }
 /* For VW/UDC end */
 
 static Bool
-load_generic(lcd)
-    XLCd lcd;
+load_generic(
+    XLCd lcd)
 {
     XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);
     char **value;
@@ -783,13 +755,12 @@
 		goto err;
 
             /* 3.4.1 side */
-            if( !_XlcNCompareISOLatin1(value[0], "none", 4) ){
-                codeset->side =  XlcNONE ;
-            } else
-            if( !_XlcNCompareISOLatin1(value[0], "GL", 2) ){
-                codeset->side =  XlcGL ;
+            if (!_XlcNCompareISOLatin1(value[0], "none", 4)) {
+                codeset->side =  XlcNONE;
+            } else if (!_XlcNCompareISOLatin1(value[0], "GL", 2)) {
+                codeset->side =  XlcGL;
             } else {
-                codeset->side =  XlcGR ;
+                codeset->side =  XlcGR;
             }
 
 	    tmp = strrchr(value[0], ':');
@@ -817,7 +788,7 @@
 	_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
 	if (num > 0) {
 	    static struct { 
-		char *str;
+		const char *str;
 		int type;
 	    } shifts[] = {
 		{"<SS>", E_SS},
@@ -898,33 +869,33 @@
 	codeset->cs_num = i;
         /* For VW/UDC */
         /***** 3.4.2 byteM (1 <= M <= length)*****/
-        for(M=1; M-1  < codeset->length; M++){
+        for (M=1; M-1  < codeset->length; M++) {
             long start,end;
             ByteInfo tmpb;
 
             sprintf(name,"%s.%s%d",cs,"byte",M);
             _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
 
-            if( M == 1){
-                if(num < 1) {
-                    codeset->byteM = NULL ;
+            if (M == 1) {
+                if (num < 1) {
+                    codeset->byteM = NULL;
                     break ;
                 }
                 codeset->byteM =
                     (ByteInfoListRec *)Xmalloc(
                          (codeset->length)*sizeof(ByteInfoListRec));
-                if(codeset->byteM == NULL){
+                if (codeset->byteM == NULL) {
                     goto err;
                 }
             }
 
-            if(num > 0){
+            if (num > 0) {
                 _XlcDbg_printValue(name,value,num);
                 (codeset->byteM)[M-1].M = M;
                 (codeset->byteM)[M-1].byteinfo_num = num;
                 (codeset->byteM)[M-1].byteinfo =
                     (ByteInfo)Xmalloc( num * sizeof(ByteInfoRec));
-                for(ii = 0 ; ii < num ; ii++){
+                for (ii = 0 ; ii < num ; ii++) {
                     tmpb = (codeset->byteM)[M-1].byteinfo ;
                     /* default 0x00 - 0xff */
                     sscanf(value[ii],"\\x%lx,\\x%lx",&start,&end);
@@ -945,7 +916,7 @@
                 codeset->mbconv->convlist =
                 _XlcParse_scopemaps(value[0],&(codeset->mbconv->conv_num));
                 dmpscope("mb_conv",codeset->mbconv->convlist,
-                        codeset->mbconv->conv_num);
+                         codeset->mbconv->conv_num);
                 /* [\x%x,\x%x]->\x%x,... */
         }
         /***** codeset.ct_conversion *****/
@@ -957,7 +928,7 @@
                 codeset->ctconv->convlist =
                 _XlcParse_scopemaps(value[0],&(codeset->ctconv->conv_num));
                 dmpscope("ctconv",codeset->ctconv->convlist,
-                        codeset->ctconv->conv_num);
+                         codeset->ctconv->conv_num);
                 /* [\x%x,\x%x]->\x%x,... */
         }
         /***** codeset.ct_conversion_file *****/
@@ -984,7 +955,7 @@
 
     if (gen->initial_state_GL == NULL) {
        CodeSetRec *codeset;
-       for (i = 0; i < gen->codeset_num; i++){
+       for (i = 0; i < gen->codeset_num; i++) {
           codeset = gen->codeset_list[i];
           if (codeset->side == XlcGL)
              gen->initial_state_GL = codeset;
@@ -993,16 +964,16 @@
 
     if (gen->initial_state_GR == NULL) {
        CodeSetRec *codeset;
-       for (i = 0; i < gen->codeset_num; i++){
+       for (i = 0; i < gen->codeset_num; i++) {
           codeset = gen->codeset_list[i];
           if (codeset->side == XlcGR)
              gen->initial_state_GR = codeset;
        }
     }
 
-    for (i = 0; i < gen->codeset_num; i++){
+    for (i = 0; i < gen->codeset_num; i++) {
        CodeSetRec *codeset = gen->codeset_list[i];
-       for (ii = 0; ii < codeset->num_charsets; ii++){
+       for (ii = 0; ii < codeset->num_charsets; ii++) {
           charset = codeset->charset_list[ii];
           if (! strcmp(charset->encoding_name, "ISO8859-1"))
               charset->string_encoding = True;
@@ -1031,24 +1002,25 @@
 	    return False;
     }
 
-    if(load_generic(lcd) == False)
+    if (load_generic(lcd) == False)
 	return False;
 
     return True;
 }
+
 /* VW/UDC start 95.01.08 */
 static void 
-freeByteM(codeset)
-    CodeSet codeset;
+freeByteM(
+    CodeSet codeset)
 {
     int i;
     ByteInfoList blst;
-    if(codeset->byteM == NULL) {
+    if (codeset->byteM == NULL) {
 	return ;
     }
     blst = codeset->byteM;
-    for(i=0;i<codeset->length;i++){
-	if(blst[i].byteinfo){
+    for (i = 0; i < codeset->length; i++) {
+	if (blst[i].byteinfo) {
 	    Xfree(blst[i].byteinfo);
 	    blst[i].byteinfo = NULL;
 	}
@@ -1056,25 +1028,26 @@
     Xfree(codeset->byteM); 
     codeset->byteM = NULL;
 }
+
 static void 
-freeConversion(codeset)
-    CodeSet codeset;
+freeConversion(
+    CodeSet codeset)
 {
     Conversion mbconv,ctconv;
-    if( codeset->mbconv ) {
+    if (codeset->mbconv) {
 	mbconv = codeset->mbconv;
 	/*  ...  */
-	if(mbconv->convlist){
+	if (mbconv->convlist) {
 	    Xfree(mbconv->convlist);
 	    mbconv->convlist = NULL;
 	}
 	Xfree(mbconv);
 	codeset->mbconv = NULL;
     }
-    if( codeset->ctconv ) {
+    if (codeset->ctconv) {
 	ctconv = codeset->ctconv;
 	/*  ...  */
-	if(ctconv->convlist){
+	if (ctconv->convlist) {
 	    Xfree(ctconv->convlist);
 	    ctconv->convlist = NULL;
 	}
@@ -1082,57 +1055,60 @@
 	codeset->ctconv = NULL;
     }
 }
+
 static void 
-freeExtdSegment(codeset)
-    CodeSet codeset;
+freeExtdSegment(
+    CodeSet codeset)
 {
     ExtdSegment ctextseg;
-    if(codeset->ctextseg == NULL) {
-	return ;
+    if (codeset->ctextseg == NULL) {
+	return;
     }
     ctextseg = codeset->ctextseg;
-    if(ctextseg->name){
+    if (ctextseg->name) {
 	Xfree(ctextseg->name);
 	ctextseg->name = NULL;
     }
-    if(ctextseg->area){
+    if (ctextseg->area) {
 	Xfree(ctextseg->area);
 	ctextseg->area = NULL;
     }
     Xfree(codeset->ctextseg); 
     codeset->ctextseg = NULL;
 }
+
 static void 
-freeParseInfo(codeset)
-    CodeSet codeset;
+freeParseInfo(
+    CodeSet codeset)
 {
     ParseInfo parse_info;
-    if(codeset->parse_info == NULL) {
-	return ;
+    if (codeset->parse_info == NULL) {
+	return;
     }
     parse_info = codeset->parse_info;
-    if(parse_info->encoding){
+    if (parse_info->encoding) {
 	Xfree(parse_info->encoding);
 	parse_info->encoding = NULL;
     }
     Xfree(codeset->parse_info); 
     codeset->parse_info = NULL;
 }
+
 static void
-destroy_CodeSetList(gen)
-    XLCdGenericPart *gen ;
+destroy_CodeSetList(
+    XLCdGenericPart *gen)
 {
     CodeSet *codeset = gen->codeset_list;
     int i;
-    if(gen->codeset_num == 0) {
+    if (gen->codeset_num == 0) {
 	return;
     }
-    for(i=0;i<gen->codeset_num;i++){
+    for (i=0;i<gen->codeset_num;i++) {
         freeByteM(codeset[i]);
 	freeConversion(codeset[i]);
 	freeExtdSegment(codeset[i]);
 	freeParseInfo(codeset[i]);
-	if(codeset[i]->charset_list){
+	if (codeset[i]->charset_list) {
 	    Xfree(codeset[i]->charset_list);
 	    codeset[i]->charset_list = NULL;
 	}
@@ -1140,26 +1116,26 @@
     }
     Xfree(codeset); gen->codeset_list = NULL;
 }
-/*  */
+
 static void
-destroy_SegConv(gen)
-    XLCdGenericPart *gen ;
+destroy_SegConv(
+    XLCdGenericPart *gen)
 {
     SegConv seg = gen->segment_conv;
     int i;
-    if(gen->segment_conv_num == 0) {
+    if (gen->segment_conv_num == 0) {
 	return;
     }
-    for(i=0;i<gen->segment_conv_num;i++){
-	if(seg[i].source_encoding){
+    for (i=0;i<gen->segment_conv_num;i++) {
+	if (seg[i].source_encoding) {
 	    Xfree(seg[i].source_encoding);
 	    seg[i].source_encoding = NULL;
 	}
-	if(seg[i].destination_encoding){
+	if (seg[i].destination_encoding) {
 	    Xfree(seg[i].destination_encoding); 
 	    seg[i].destination_encoding = NULL;
 	}
-	if(seg[i].conv){
+	if (seg[i].conv) {
 	    Xfree(seg[i].conv); seg[i].conv = NULL;
 	}
     }
@@ -1167,25 +1143,26 @@
 }
 
 static void
-destroy_gen(lcd)
-    XLCd lcd;
+destroy_gen(
+    XLCd lcd)
 {
     XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);
     destroy_SegConv(gen);
     destroy_CodeSetList(gen);
-    if(gen->mb_parse_table){
+    if (gen->mb_parse_table) {
 	Xfree(gen->mb_parse_table);
 	gen->mb_parse_table = NULL;
     }
-    if(gen->mb_parse_list){
+    if (gen->mb_parse_list) {
 	Xfree(gen->mb_parse_list);
 	gen->mb_parse_list = NULL;
     }
 }
 /* VW/UDC end 95.01.08 */
+
 static void
-destroy(lcd)
-    XLCd lcd;
+destroy(
+    XLCd lcd)
 {
     XLCdPublicMethods superclass = XLC_PUBLIC_METHODS(lcd)->superclass;
 
Index: xc/lib/X11/lcInit.c
diff -u xc/lib/X11/lcInit.c:3.5 xc/lib/X11/lcInit.c:3.7
--- xc/lib/X11/lcInit.c:3.5	Fri Feb 11 21:54:13 2000
+++ xc/lib/X11/lcInit.c	Tue Nov 28 13:49:46 2000
@@ -31,7 +31,7 @@
  *   Modifier: Masayoshi Shimamura      FUJITSU LIMITED 
  *
  */
-/* $XFree86: xc/lib/X11/lcInit.c,v 3.5 2000/02/12 02:54:13 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcInit.c,v 3.7 2000/11/28 18:49:46 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "Xlcint.h"
@@ -43,89 +43,8 @@
 # define USE_EUC_LOADER
 # define USE_SJIS_LOADER
 # define USE_JIS_LOADER
-# define USE_UTF_LOADER
 #endif
 
-extern XLCd _XlcDefaultLoader(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-
-#ifdef DYNAMIC_LOAD
-#ifdef sun
-extern XLCd _XsunOsDynamicLoad(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-#endif /* sun */
-
-#ifdef AIXV3
-extern XLCd _XaixOsDynamicLoad(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-#endif /* AIXV3 */
-#endif
-
-#ifdef USE_GENERIC_LOADER
-extern XLCd _XlcGenericLoader(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-#endif
-
-#ifdef USE_UTF8_LOADER
-extern XLCd _XlcUtf8Loader(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-#endif
-
-#ifdef USE_UTF_LOADER
-extern XLCd _XlcUtfLoader(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-#endif
-
-#ifdef USE_EUC_LOADER
-extern XLCd _XlcEucLoader(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-#endif
-
-#ifdef USE_SJIS_LOADER
-extern XLCd _XlcSjisLoader(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-#endif
-
-#ifdef USE_JIS_LOADER
-extern XLCd _XlcJisLoader(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-#endif
-
-#ifdef USE_DYNAMIC_LOADER
-extern XLCd _XlcDynamicLoader(
-#if NeedFunctionPrototypes
-    _Xconst char*
-#endif
-);
-#endif
-
 /*
  * The _XlcInitLoader function initializes the locale object loader list
  * with vendor specific manner.
@@ -157,20 +76,6 @@
 #ifdef USE_JIS_LOADER
     _XlcAddLoader(_XlcJisLoader, XlcHead);
 #endif
-
-#ifdef USE_UTF_LOADER
-    _XlcAddLoader(_XlcUtfLoader, XlcHead);
-#endif
-
-#ifdef DYNAMIC_LOAD
-#ifdef sun
-    _XlcAddLoader(_XsunOsDynamicLoad, XlcHead);
-#endif /* sun */
-
-#ifdef AIXV3
-    _XlcAddLoader(_XaixOsDynamicLoad, XlcHead);
-#endif /* AIXV3 */
-#endif /* DYNAMIC_LOAD */
 
 #ifdef USE_DYNAMIC_LOADER
     _XlcAddLoader(_XlcDynamicLoader, XlcHead);
Index: xc/lib/X11/lcJis.c
diff -u xc/lib/X11/lcJis.c:1.5 xc/lib/X11/lcJis.c:1.6
--- xc/lib/X11/lcJis.c:1.5	Fri Feb 11 21:54:13 2000
+++ xc/lib/X11/lcJis.c	Tue Nov 28 13:49:46 2000
@@ -23,7 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/lcJis.c,v 1.5 2000/02/12 02:54:13 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcJis.c,v 1.6 2000/11/28 18:49:46 dawes Exp $ */
 
 /*
  * A Japanese JIS locale.
@@ -50,12 +50,12 @@
 } StateRec, *State;
 
 static void
-init_state(conv)
-    XlcConv conv;
+init_state(
+    XlcConv conv)
 {
-    register State state = (State) conv->state;
-    register XLCdGenericPart *gen = XLC_GENERIC_PART(state->lcd);
-    register CodeSet codeset;
+    State state = (State) conv->state;
+    XLCdGenericPart *gen = XLC_GENERIC_PART(state->lcd);
+    CodeSet codeset;
 
     codeset = gen->initial_state_GL;
     if (codeset && codeset->charset_list)
@@ -65,17 +65,17 @@
 	state->GR_charset = *codeset->charset_list;
 
     if (state->GL_charset == NULL)
-	if (codeset = *gen->codeset_list)
+	if ((codeset = *gen->codeset_list) != NULL)
 	    state->GL_charset = *codeset->charset_list;
 }
 
 static int
-compare(src, encoding, length)
-    register char *src;
-    register char *encoding;
-    register int length;
+compare(
+    const char *src,
+    const char *encoding,
+    int length)
 {
-    char *start = src;
+    const char *start = src;
 
     while (length-- > 0) {
 	if (*src++ != *encoding++)
@@ -88,32 +88,34 @@
 }
 
 static int
-mbtocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+mbtocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
-    register char *src, *dst;
-    unsigned char ch, *mb_parse_table;
+    const char *src;
+    char *dst;
+    unsigned char *mb_parse_table;
     ParseInfo *parse_list, parse_info;
     XlcCharSet charset;
     int length, number, encoding_len = 0;
-    register int i;
+    int i;
 
-    src = *((char **) from);
+    src = *((const char **) from);
     dst = *((char **) to);
 
-    if (mb_parse_table = XLC_GENERIC(lcd, mb_parse_table)) {
+    mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
+    if (mb_parse_table != NULL) {
 	number = mb_parse_table[(unsigned char) *src];
 	if (number > 0) {
 	    parse_list = XLC_GENERIC(lcd, mb_parse_list) + number - 1;
-	    for ( ; parse_info = *parse_list; parse_list++) {
+	    for ( ; (parse_info = *parse_list) != NULL; parse_list++) {
 		encoding_len = compare(src, parse_info->encoding, *from_left);
 		if (encoding_len > 0) {
 		    switch (parse_info->type) {
@@ -184,14 +186,14 @@
 }
 
 static int
-mbstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+mbstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XlcCharSet charset = NULL;
     XPointer tmp_args[2], save_from = *from;
@@ -220,13 +222,13 @@
 }
 
 static CodeSet
-wc_parse_codeset(lcd, wcstr)
-    XLCd lcd;
-    wchar_t *wcstr;
+wc_parse_codeset(
+    XLCd lcd,
+    const wchar_t *wcstr)
 {
-    register CodeSet *codeset;
+    CodeSet *codeset;
     unsigned long wc_encoding;
-    register int num;
+    int num;
 
     wc_encoding = *wcstr & XLC_GENERIC(lcd, wc_encode_mask);
     num = XLC_GENERIC(lcd, codeset_num);
@@ -241,22 +243,22 @@
 }
 
 static int
-wcstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
-    wchar_t *wcptr;
-    register char *bufptr;
-    register wchar_t wch;
+    const wchar_t *wcptr;
+    char *bufptr;
+    wchar_t wch;
     char *tmpptr;
-    register int length;
+    int length;
     CodeSet codeset;
     unsigned long wc_encoding;
     int wcstr_len, buf_len;
@@ -264,7 +266,7 @@
     if (from == NULL || *from == NULL)
 	return 0;
 
-    wcptr = *((wchar_t **) from);
+    wcptr = *((const wchar_t **) from);
     bufptr = *((char **) to);
     wcstr_len = *from_left;
     buf_len = *to_left;
@@ -317,13 +319,13 @@
 }
 
 static CodeSet
-GetCodeSetFromCharSet(lcd, charset)
-    XLCd lcd;
-    XlcCharSet charset;
-{
-    register CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
-    register XlcCharSet *charset_list;
-    register int codeset_num, num_charsets;
+GetCodeSetFromCharSet(
+    XLCd lcd,
+    XlcCharSet charset)
+{
+    CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
+    XlcCharSet *charset_list;
+    int codeset_num, num_charsets;
 
     codeset_num = XLC_GENERIC(lcd, codeset_num);
 
@@ -340,27 +342,27 @@
 }
 
 static int
-cstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
-    register char *csptr;
-    register char *bufptr;
+    const char *csptr;
+    char *bufptr;
     int csstr_len;
-    register int buf_len;
+    int buf_len;
     int num, encoding_len = 0;
     CodeSet codeset;
     XlcCharSet charset;
     EncodingType type;
     int cvt_length;
 
-    csptr = *((char **) from);
+    csptr = *((const char **) from);
     bufptr = *((char **) to);
     csstr_len = *from_left;
     buf_len = *to_left;
@@ -444,27 +446,27 @@
 }
 
 static int
-cstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     State state = (State) conv->state;
     XLCd lcd = state->lcd;
-    register char *csptr;
+    const char *csptr;
     wchar_t *bufptr;
     int csstr_len;
-    register int buf_len;
-    register wchar_t wch;
+    int buf_len;
+    wchar_t wch;
     unsigned long code_mask, wc_encoding;
     int num, length, wc_shift_bits;
     CodeSet codeset;
 
-    csptr = *((char **) from);
+    csptr = *((const char **) from);
     bufptr = *((wchar_t **) to);
     csstr_len = *from_left;
     buf_len = *to_left;
@@ -509,8 +511,8 @@
 
 
 static void
-close_converter(conv)
-    XlcConv conv;
+close_converter(
+    XlcConv conv)
 {
     if (conv->state) {
 	Xfree((char *) conv->state);
@@ -520,9 +522,9 @@
 }
 
 static XlcConv
-create_conv(lcd, methods)
-    XLCd lcd;
-    XlcConvMethods methods;
+create_conv(
+    XLCd lcd,
+    XlcConvMethods methods)
 {
     XlcConv conv;
     State state;
@@ -559,14 +561,14 @@
     close_converter,
     mbstocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_mbstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbstocs_methods);
 }
@@ -575,14 +577,14 @@
     close_converter,
     wcstocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_wcstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &wcstocs_methods);
 }
@@ -591,14 +593,14 @@
     close_converter,
     mbtocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_mbtocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbtocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &mbtocs_methods);
 }
@@ -607,14 +609,14 @@
     close_converter,
     cstombs,
     NULL
-} ;
+};
 
 static XlcConv
-open_cstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &cstombs_methods);
 }
@@ -623,30 +625,30 @@
     close_converter,
     cstowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_cstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &cstowcs_methods);
 }
 
 #ifdef STDCVT
 static int
-stdc_mbstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_mbstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    char *src = *((char **) from);
+    const char *src = *((const char **) from);
     wchar_t *dst = *((wchar_t **) to);
     int src_left = *from_left;
     int dst_left = *to_left;
@@ -683,16 +685,16 @@
 }
 
 static int
-stdc_wcstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_wcstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    wchar_t *src = *((wchar_t **) from);
+    const wchar_t *src = *((const wchar_t **) from);
     char *dst = *((char **) to);
     int src_left = *from_left;
     int dst_left = *to_left;
@@ -727,16 +729,17 @@
 }
 
 static int
-stdc_wcstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_wcstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    wchar_t wch, *src = *((wchar_t **) from);
+    const wchar_t *src = *((const wchar_t **) from);
+    wchar_t wch;
     XlcCharSet charset = NULL;
     XPointer tmp_args[2], tmp_from, save_from = *from;
     char tmp[32];
@@ -787,14 +790,14 @@
 #define FreeLocalBuf(ptr)	if (ptr != local_buf) Xfree(ptr)
 
 static int
-stdc_cstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+stdc_cstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = ((State) conv->state)->lcd;
     DefineLocalBuf;
@@ -825,14 +828,14 @@
     close_converter,
     stdc_mbstowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_mbstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_mbstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_mbstowcs_methods);
 }
@@ -841,14 +844,14 @@
     close_converter,
     stdc_wcstombs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_wcstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_wcstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_wcstombs_methods);
 }
@@ -857,14 +860,14 @@
     close_converter,
     stdc_wcstocs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_wcstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_wcstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_wcstocs_methods);
 }
@@ -873,25 +876,27 @@
     close_converter,
     stdc_cstowcs,
     NULL
-} ;
+};
 
 static XlcConv
-open_stdc_cstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_stdc_cstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &stdc_cstowcs_methods);
 }
 #endif /* STDCVT */
 
 XLCd
-_XlcJisLoader(name)
-    _Xconst char *name;
+_XlcJisLoader(
+    const char *name)
 {
     XLCd lcd;
+#ifdef STDCVT
     XLCdGenericPart *gen;
+#endif
 
     lcd = _XlcCreateLC(name, _XlcGenericMethods);
     if (lcd == NULL)
Index: xc/lib/X11/lcPrTxt.c
diff -u xc/lib/X11/lcPrTxt.c:1.3 xc/lib/X11/lcPrTxt.c:1.5
--- xc/lib/X11/lcPrTxt.c:1.3	Sun Jan 30 13:35:19 2000
+++ xc/lib/X11/lcPrTxt.c	Fri Dec 15 17:48:39 2000
@@ -23,7 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/lcPrTxt.c,v 1.3 2000/01/30 18:35:19 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcPrTxt.c,v 1.5 2000/12/15 22:48:39 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XlcPubI.h"
@@ -31,10 +31,10 @@
 #include <X11/Xatom.h>
 
 static XPointer *
-alloc_list(is_wide_char, count, nitems)
-    Bool is_wide_char;
-    int count;
-    int nitems;
+alloc_list(
+    Bool is_wide_char,
+    int count,
+    int nitems)
 {
     if (is_wide_char) {
 	wchar_t **wstr_list;
@@ -68,11 +68,11 @@
 }
 
 static void
-copy_list(is_wide_char, text, list, count)
-    Bool is_wide_char;
-    XPointer text;
-    XPointer *list;
-    int count;
+copy_list(
+    Bool is_wide_char,
+    XPointer text,
+    XPointer *list,
+    int count)
 {
     int length;
 
@@ -106,16 +106,16 @@
 }
 
 static int
-_XTextPropertyToTextList(lcd, dpy, text_prop, to_type, list_ret, count_ret)
-    XLCd lcd;
-    Display *dpy;
-    XTextProperty *text_prop;
-    char *to_type;
-    XPointer **list_ret;
-    int *count_ret;
+_XTextPropertyToTextList(
+    XLCd lcd,
+    Display *dpy,
+    const XTextProperty *text_prop,
+    const char *to_type,
+    XPointer **list_ret,
+    int *count_ret)
 {
     XlcConv conv;
-    char *from_type;
+    const char *from_type;
     XPointer from, to, buf;
     char *str_ptr, *last_ptr;
     Atom encoding;
@@ -138,6 +138,8 @@
     encoding = text_prop->encoding;
     if (encoding == XA_STRING)
 	from_type = XlcNString;
+    else if (encoding == XInternAtom(dpy, "UTF8_STRING", False))
+	from_type = XlcNUtf8String;
     else if (encoding == XInternAtom(dpy, "COMPOUND_TEXT", False))
 	from_type = XlcNCompoundText;
     else if (encoding == XInternAtom(dpy, XLC_PUBLIC(lcd, encoding_name), False))
@@ -149,7 +151,10 @@
 	buf_len = text_prop->nitems + 1;
 	buf = (XPointer) Xmalloc(buf_len * sizeof(wchar_t));
     } else {
-	buf_len = text_prop->nitems * XLC_PUBLIC(lcd, mb_cur_max) + 1;
+	if (strcmp(to_type, XlcNUtf8String) == 0)
+	    buf_len = text_prop->nitems * 6 + 1;
+	else
+	    buf_len = text_prop->nitems * XLC_PUBLIC(lcd, mb_cur_max) + 1;
 	buf = (XPointer) Xmalloc(buf_len);
     }
     if (buf == NULL)
@@ -157,7 +162,8 @@
     to = buf;
     to_left = buf_len;
 
-    /* can be XlcNMultiByte to XlcNMultiByte */
+    /* can be XlcNMultiByte to XlcNMultiByte,
+       or XlcNUtf8String to XlcNUtf8String */
     if (!strcmp(from_type, to_type)) {
         do_strcpy = True;
     } else {
@@ -233,33 +239,45 @@
 }
 
 int
-_XmbTextPropertyToTextList(lcd, dpy, text_prop, list_ret, count_ret)
-    XLCd lcd;
-    Display *dpy;
-    XTextProperty *text_prop;
-    char ***list_ret;
-    int *count_ret;
+_XmbTextPropertyToTextList(
+    XLCd lcd,
+    Display *dpy,
+    const XTextProperty *text_prop,
+    char ***list_ret,
+    int *count_ret)
 {
     return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNMultiByte,
 				    (XPointer **) list_ret, count_ret);
 }
 
 int
-_XwcTextPropertyToTextList(lcd, dpy, text_prop, list_ret, count_ret)
-    XLCd lcd;
-    Display *dpy;
-    XTextProperty *text_prop;
-    wchar_t ***list_ret;
-    int *count_ret;
+_XwcTextPropertyToTextList(
+    XLCd lcd,
+    Display *dpy,
+    const XTextProperty *text_prop,
+    wchar_t ***list_ret,
+    int *count_ret)
 {
     return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNWideChar,
 				    (XPointer **) list_ret, count_ret);
 }
 
+int
+_Xutf8TextPropertyToTextList(
+    XLCd lcd,
+    Display *dpy,
+    const XTextProperty *text_prop,
+    char ***list_ret,
+    int *count_ret)
+{
+    return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNUtf8String,
+				    (XPointer **) list_ret, count_ret);
+}
+
 void
-_XwcFreeStringList(lcd, list)
-    XLCd lcd;
-    wchar_t **list;
+_XwcFreeStringList(
+    XLCd lcd,
+    wchar_t **list)
 {
     if (list) {
         if (*list)
Index: xc/lib/X11/lcPubWrap.c
diff -u xc/lib/X11/lcPubWrap.c:1.2 xc/lib/X11/lcPubWrap.c:1.3
--- xc/lib/X11/lcPubWrap.c:1.2	Sat Nov 22 07:50:11 1997
+++ xc/lib/X11/lcPubWrap.c	Tue Nov 28 13:49:47 2000
@@ -23,7 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/lcPubWrap.c,v 1.2 1997/11/22 12:50:11 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcPubWrap.c,v 1.3 2000/11/28 18:49:47 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XlcPubI.h"
@@ -63,8 +63,8 @@
 }
 
 void
-_XlcDestroyLC(lcd)
-    XLCd lcd;
+_XlcDestroyLC(
+    XLCd lcd)
 {
     XLCdPublicMethods methods = (XLCdPublicMethods) lcd->methods;
 
@@ -72,9 +72,9 @@
 }
 
 XLCd
-_XlcCreateLC(name, methods)
-    _Xconst char *name;
-    XLCdMethods methods;
+_XlcCreateLC(
+    const char *name,
+    XLCdMethods methods)
 {
     XLCdPublicMethods pub_methods = (XLCdPublicMethods) methods;
     XLCd lcd;
Index: xc/lib/X11/lcPublic.c
diff -u xc/lib/X11/lcPublic.c:1.6 xc/lib/X11/lcPublic.c:1.8
--- xc/lib/X11/lcPublic.c:1.6	Sat Feb 12 00:43:16 2000
+++ xc/lib/X11/lcPublic.c	Wed Dec  6 17:00:42 2000
@@ -23,18 +23,23 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/lcPublic.c,v 1.6 2000/02/12 05:43:16 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcPublic.c,v 1.8 2000/12/06 22:00:42 dawes Exp $ */
 
 #include <stdio.h>
 #include "Xlibint.h"
 #include "XlcPubI.h"
 
-static char *default_string();
+static const char *
+default_string(
+    XLCd lcd)
+{
+    return XLC_PUBLIC(lcd, default_string);
+}
 
-static XLCd create();
-static Bool initialize();
-static void destroy();
-static char *get_values();
+static XLCd create (const char *name, XLCdMethods methods);
+static Bool initialize (XLCd lcd);
+static void destroy (XLCd lcd);
+static char *get_values (XLCd lcd, XlcArgList args, int num_args);
 
 static XLCdPublicMethodsRec publicMethods = {
     {
@@ -45,8 +50,10 @@
 	_XrmDefaultInitParseInfo,
 	_XmbTextPropertyToTextList,
 	_XwcTextPropertyToTextList,
+	_Xutf8TextPropertyToTextList,
 	_XmbTextListToTextProperty,
 	_XwcTextListToTextProperty,
+	_Xutf8TextListToTextProperty,
 	_XwcFreeStringList,
 	default_string,
 	NULL,
@@ -64,17 +71,10 @@
 
 XLCdMethods _XlcPublicMethods = (XLCdMethods) &publicMethods;
 
-static char *
-default_string(lcd)
-    XLCd lcd;
-{
-    return XLC_PUBLIC(lcd, default_string);
-}
-
 static XLCd
-create(name, methods)
-    char *name;
-    XLCdMethods methods;
+create(
+    const char *name,
+    XLCdMethods methods)
 {
     XLCd lcd;
     XLCdPublicMethods new;
@@ -92,7 +92,7 @@
     new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
     if (new == NULL)
 	goto err;
-    *new = *((XLCdPublicMethods) methods);
+    memcpy(new,methods,sizeof(XLCdPublicMethodsRec));
     lcd->methods = (XLCdMethods) new;
 
     return lcd;
@@ -103,8 +103,8 @@
 }
 
 static Bool
-load_public(lcd)
-    XLCd lcd;
+load_public(
+    XLCd lcd)
 {
     XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
     char **values, *str;
@@ -138,8 +138,8 @@
 }
 
 static Bool
-initialize_core(lcd)
-    XLCd lcd;
+initialize_core(
+    XLCd lcd)
 {
     XLCdMethods methods = lcd->methods;
     XLCdMethods core = &publicMethods.core;
@@ -165,12 +165,18 @@
     if (methods->wc_text_prop_to_list == NULL)
 	methods->wc_text_prop_to_list = core->wc_text_prop_to_list;
 
+    if (methods->utf8_text_prop_to_list == NULL)
+	methods->utf8_text_prop_to_list = core->utf8_text_prop_to_list;
+
     if (methods->mb_text_list_to_prop == NULL)
 	methods->mb_text_list_to_prop = core->mb_text_list_to_prop;
 
     if (methods->wc_text_list_to_prop == NULL)
 	methods->wc_text_list_to_prop = core->wc_text_list_to_prop;
 
+    if (methods->utf8_text_list_to_prop == NULL)
+	methods->utf8_text_list_to_prop = core->utf8_text_list_to_prop;
+
     if (methods->wc_free_string_list == NULL)
 	methods->wc_free_string_list = core->wc_free_string_list;
 
@@ -180,11 +186,9 @@
     return True;
 }
 
-extern Bool _XlcInitCTInfo();
-
 static Bool
-initialize(lcd)
-    XLCd lcd;
+initialize(
+    XLCd lcd)
 {
     XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
     XLCdPublicMethodsPart *pub_methods = &publicMethods.pub;
@@ -241,8 +245,8 @@
 }
 
 static void
-destroy_core(lcd)
-	XLCd	lcd;
+destroy_core(
+    XLCd lcd)
 {
     if (lcd->core) {
 	if (lcd->core->name)
@@ -257,8 +261,8 @@
 }
 
 static void
-destroy(lcd)
-    XLCd lcd;
+destroy(
+    XLCd lcd)
 {
     XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
 
@@ -290,10 +294,10 @@
 };
 
 static char *
-get_values(lcd, args, num_args)
-    register XLCd lcd;
-    register XlcArgList args;
-    register int num_args;
+get_values(
+    XLCd lcd,
+    XlcArgList args,
+    int num_args)
 {
     XLCdPublic pub = (XLCdPublic) lcd->core;
 
Index: xc/lib/X11/lcRM.c
diff -u xc/lib/X11/lcRM.c:1.3 xc/lib/X11/lcRM.c:1.4
--- xc/lib/X11/lcRM.c:1.3	Sat Feb 12 00:43:16 2000
+++ xc/lib/X11/lcRM.c	Tue Nov 28 13:49:48 2000
@@ -24,46 +24,113 @@
  *			   	mopi@osa.ilab.toshiba.co.jp
  * Bug fixes: Bruno Haible	XFree86 Inc.
  */
-/* $XFree86: xc/lib/X11/lcRM.c,v 1.3 2000/02/12 05:43:16 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcRM.c,v 1.4 2000/11/28 18:49:48 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XlcPubI.h"
 #include <stdio.h>
 
-typedef struct _StateRec {
-    XLCd lcd;
-    XlcConv conv;
-} StateRec, *State;
+/*
+ * Default implementation of methods for Xrm parsing.
+ */
 
+/* ======================= Unibyte implementation ======================= */
+
+/* Only for efficiency, to speed up things. */
+
+/* This implementation must keep the locale, for lcname. */
+typedef struct _UbStateRec {
+    XLCd	lcd;
+} UbStateRec, *UbState;
+
+/* Sets the state to the initial state.
+   Initiates a sequence of calls to mbchar. */
 static void
-mbinit(state)
-    XPointer state;
+ub_mbinit(
+    XPointer state)
 {
-    _XlcResetConverter(((State) state)->conv);
 }
 
 /* Transforms one multibyte character, and return a 'char' in the same
    parsing class. Returns the number of consumed bytes in *lenp. */
 static char
-mbchar(state, str, lenp)
-    XPointer state;
-    char *str;
-    int *lenp;
+ub_mbchar(
+    XPointer state,
+    const char *str,
+    int	*lenp)
+{
+    *lenp = 1;
+    return *str;
+}
+
+/* Terminates a sequence of calls to mbchar. */
+static void
+ub_mbfinish(
+    XPointer state)
+{
+}
+
+/* Returns the name of the state's locale, as a static string. */
+static const char *
+ub_lcname(
+    XPointer state)
+{
+    return ((UbState) state)->lcd->core->name;
+}
+
+/* Frees the state, which was allocated by _XrmDefaultInitParseInfo. */
+static void
+ub_destroy(
+    XPointer state)
 {
-    XlcConv conv = ((State) state)->conv;
-    char *from;
+    _XCloseLC(((UbState) state)->lcd);
+    Xfree((char *) state);
+}
+
+static const XrmMethodsRec ub_methods = {
+    ub_mbinit,
+    ub_mbchar,
+    ub_mbfinish,
+    ub_lcname,
+    ub_destroy
+};
+
+/* ======================= Multibyte implementation ======================= */
+
+/* This implementation uses an XlcConv from XlcNMultiByte to XlcNWideChar. */
+typedef struct _MbStateRec {
+    XLCd	lcd;
+    XlcConv	conv;
+} MbStateRec, *MbState;
+
+/* Sets the state to the initial state.
+   Initiates a sequence of calls to mbchar. */
+static void
+mb_mbinit(
+    XPointer state)
+{
+    _XlcResetConverter(((MbState) state)->conv);
+}
+
+/* Transforms one multibyte character, and return a 'char' in the same
+   parsing class. Returns the number of consumed bytes in *lenp. */
+static char
+mb_mbchar(
+    XPointer state,
+    const char *str,
+    int	*lenp)
+{
+    XlcConv conv = ((MbState) state)->conv;
+    const char *from;
     wchar_t *to, wc;
     int cur_max, i, from_left, to_left, ret;
 
-    cur_max = XLC_PUBLIC(((State) state)->lcd, mb_cur_max);
-    if (cur_max == 1) {
-	*lenp = 1;
-	return *str;
-    }
+    cur_max = XLC_PUBLIC(((MbState) state)->lcd, mb_cur_max);
 
     from = str;
+    /* Determine from_left. Avoid overrun error which could occur if
+       from_left > strlen(str). */
     from_left = cur_max;
-    /* Avoid overrun error which could occur if from_left > strlen(str). */
     for (i = 0; i < cur_max; i++)
 	if (str[i] == '\0') {
 	    from_left = i;
@@ -87,55 +154,70 @@
     return (wc >= 0 && wc <= 0x7f ? wc : 0x7f);
 }
 
+/* Terminates a sequence of calls to mbchar. */
 static void
-mbfinish(state)
-    XPointer state;
+mb_mbfinish(
+    XPointer state)
 {
 }
 
-static char *
-lcname(state)
-    XPointer state;
+/* Returns the name of the state's locale, as a static string. */
+static const char *
+mb_lcname(
+    XPointer state)
 {
-    return ((State) state)->lcd->core->name;
+    return ((MbState) state)->lcd->core->name;
 }
 
+/* Frees the state, which was allocated by _XrmDefaultInitParseInfo. */
 static void
-destroy(state)
-    XPointer state;
+mb_destroy(
+    XPointer state)
 {
-    _XlcCloseConverter(((State) state)->conv);
-    _XCloseLC(((State) state)->lcd);
+    _XlcCloseConverter(((MbState) state)->conv);
+    _XCloseLC(((MbState) state)->lcd);
     Xfree((char *) state);
 }
 
-static XrmMethodsRec rm_methods = {
-    mbinit,
-    mbchar,
-    mbfinish,
-    lcname,
-    destroy
-} ;
+static const XrmMethodsRec mb_methods = {
+    mb_mbinit,
+    mb_mbchar,
+    mb_mbfinish,
+    mb_lcname,
+    mb_destroy
+};
 
+/* ======================= Exported function ======================= */
+
 XrmMethods
-_XrmDefaultInitParseInfo(lcd, rm_state)
-    XLCd lcd;
-    XPointer *rm_state;
-{
-    State state;
-
-    state = (State) Xmalloc(sizeof(StateRec));
-    if (state == NULL)
-	return (XrmMethods) NULL;
-
-    state->lcd = lcd;
-    state->conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
-    if (state->conv == NULL) {
-	Xfree((char *) state);
-	return (XrmMethods) NULL;
+_XrmDefaultInitParseInfo(
+    XLCd lcd,
+    XPointer *rm_state)
+{
+    if (XLC_PUBLIC(lcd, mb_cur_max) == 1) {
+	/* Unibyte case. */
+	UbState state = (UbState) Xmalloc(sizeof(UbStateRec));
+	if (state == NULL)
+	    return (XrmMethods) NULL;
+
+	state->lcd = lcd;
+
+	*rm_state = (XPointer) state;
+	return &ub_methods;
+    } else {
+	/* Multibyte case. */
+	MbState state = (MbState) Xmalloc(sizeof(MbStateRec));
+	if (state == NULL)
+	    return (XrmMethods) NULL;
+
+	state->lcd = lcd;
+	state->conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
+	if (state->conv == NULL) {
+	    Xfree((char *) state);
+	    return (XrmMethods) NULL;
+	}
+
+	*rm_state = (XPointer) state;
+	return &mb_methods;
     }
-    
-    *rm_state = (XPointer) state;
-    
-    return &rm_methods;
 }
Index: xc/lib/X11/lcSjis.c
diff -u xc/lib/X11/lcSjis.c:3.6 xc/lib/X11/lcSjis.c:3.7
--- xc/lib/X11/lcSjis.c:3.6	Fri Feb 11 21:54:14 2000
+++ xc/lib/X11/lcSjis.c	Tue Nov 28 13:49:48 2000
@@ -35,7 +35,7 @@
 				makoto@sm.sony.co.jp
 
 *****************************************************************/
-/* $XFree86: xc/lib/X11/lcSjis.c,v 3.6 2000/02/12 02:54:14 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcSjis.c,v 3.7 2000/11/28 18:49:48 dawes Exp $ */
 
 /*
  * A Japanese SJIS locale.
@@ -100,9 +100,9 @@
 #define BIT8ON(c)	((c) | GR)
 
 
-static void jis_to_sjis();
-static void sjis_to_jis();
-static CodeSet wc_codeset();
+static void jis_to_sjis (Uchar *p1, Uchar *p2);
+static void sjis_to_jis (Uchar *p1, Uchar *p2);
+static CodeSet wc_codeset (XLCd lcd, wchar_t wch);
 
 
 /*
@@ -122,21 +122,21 @@
 
 
 static int
-sjis_mbstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+sjis_mbstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
 
     XLCd lcd = (XLCd)conv->state;
 
-    register int chr_len = 0;
-    register int shift_mult = 0;
-    register Uint chrcode = 0;
+    int chr_len = 0;
+    int shift_mult = 0;
+    Uint chrcode = 0;
 
     Uchar ch, ch2;
     Uint wc_encode = 0;
@@ -149,7 +149,7 @@
     int num_conv;
     int unconv_num = 0;
 
-    XPointer inbufptr = *from;
+    const char *inbufptr = *from;
     wchar_t *outbufptr = (wchar_t *) *to;
     wchar_t *outbuf_base = outbufptr;
 
@@ -157,7 +157,6 @@
     int codeset_num = XLC_GENERIC(lcd, codeset_num);
     Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
 
-
     if (*from_left > *to_left)
 	*from_left = *to_left;
 
@@ -262,20 +261,20 @@
 #define byte2		(byte1 == 0)
 
 static int
-sjis_wcstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+sjis_wcstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register wchar_t *inbufptr = (wchar_t *) *from;
-    register XPointer outbufptr = *to;
+    const wchar_t *inbufptr = (const wchar_t *) *from;
+    XPointer outbufptr = *to;
     XPointer outbuf_base = outbufptr;
     wchar_t  wch;
-    register int length;
+    int length;
     Uchar tmp;
     Uchar t1, t2;
     int num_conv;
@@ -285,8 +284,6 @@
     CodeSet codeset;
     Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
 
-
-
     if (*from_left > *to_left)
 	*from_left = *to_left;
 
@@ -341,43 +338,43 @@
  * sjis<->jis conversion for widechar kanji (See Note at top of file)
  */
 static void
-sjis_to_jis(p1, p2)
-    Uchar *p1;
-    Uchar *p2;
-{
-  register Uchar c1 = *p1;
-  register Uchar c2 = *p2;
-  register Uchar adjust = c2 < 0x9f;
-  register Uchar rowOffset = c1 < 0xa0 ? 0x70 : 0xb0;
-  register Uchar cellOffset = adjust ? (0x1f + (c2 > 0x7f)) : 0x7e;
+sjis_to_jis(
+    Uchar *p1,
+    Uchar *p2)
+{
+  Uchar c1 = *p1;
+  Uchar c2 = *p2;
+  Uchar adjust = c2 < 0x9f;
+  Uchar rowOffset = c1 < 0xa0 ? 0x70 : 0xb0;
+  Uchar cellOffset = adjust ? (0x1f + (c2 > 0x7f)) : 0x7e;
 
   *p1 = ((c1 - rowOffset) << 1) - adjust;
   *p2 -= cellOffset;
 }
 
 static void
-jis_to_sjis(p1, p2)
-    Uchar *p1;
-    Uchar *p2;
-{
-  register Uchar c1 = *p1;
-  register Uchar c2 = *p2;
-  register Uchar rowOffset = c1 < 0x5f ? 0x70 : 0xb0;
-  register Uchar cellOffset = c1 % 2 ? 0x1f + (c2 > 0x5f) : 0x7e;
+jis_to_sjis(
+    Uchar *p1,
+    Uchar *p2)
+{
+  Uchar c1 = *p1;
+  Uchar c2 = *p2;
+  Uchar rowOffset = c1 < 0x5f ? 0x70 : 0xb0;
+  Uchar cellOffset = c1 % 2 ? 0x1f + (c2 > 0x5f) : 0x7e;
 
   *p1 = ((Uchar)(c1 + 1) >> 1) + rowOffset;
   *p2 = c2 + cellOffset;
 }
 
 static CodeSet
-wc_codeset(lcd, wch)
-    XLCd lcd;
-    wchar_t wch;
+wc_codeset(
+    XLCd lcd,
+    wchar_t wch)
 {
-    register CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+    CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
 #if !defined(__sony_news)  ||  defined(SVR4)
-    register int end = XLC_GENERIC(lcd, codeset_num);
-    register Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
+    int end = XLC_GENERIC(lcd, codeset_num);
+    Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
 
     for (; --end >= 0; codesets++)
 	if ( widech == (*codesets)->wc_encoding )
@@ -395,24 +392,24 @@
     
 
 static int
-sjis_mbtocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+sjis_mbtocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd)conv->state;
     XlcCharSet charset = NULL;
     int char_size = 0;
     int unconv_num = 0;
-    register char *src = *from, *dst = *to;
+    const char *src = *from;
+    char *dst = *to;
     CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
     int codeset_num = XLC_GENERIC(lcd, codeset_num);
 
-
     if (iskanji(*src)) {
 	if (KANJI_CODESET >= codeset_num)
 	    return -1;
@@ -471,8 +468,8 @@
     *from_left -= char_size;
     *to_left -= char_size;
 
-    *to = dst;
-    *from = src;
+    *to = (XPointer) dst;
+    *from = (XPointer) src;
 
     if (num_args > 0)
 	*((XlcCharSet *) args[0]) = charset;
@@ -482,23 +479,22 @@
 
 
 static int
-sjis_mbstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+sjis_mbstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    char *tmp_from, *tmp_to;
+    const char *tmp_from;
+    char *tmp_to;
     int tmp_from_left, tmp_to_left;
     XlcCharSet charset, tmp_charset;
     XPointer tmp_args[1];
     int unconv_num = 0, ret;
 
-
-
 /* Determine the charset of the segment and convert one character: */
 
     tmp_args[0] = (XPointer) &charset; /* charset from sjis_mbtocs() */
@@ -516,8 +512,8 @@
 /* Convert remainder of the segment: */
 
     tmp_args[0] = (XPointer) &tmp_charset;
-    while( (ret = sjis_mbtocs(conv, &tmp_from, &tmp_from_left, &tmp_to,
-      &tmp_to_left, tmp_args, 1)) >= 0 ) {
+    while( (ret = sjis_mbtocs(conv, (XPointer *) &tmp_from, &tmp_from_left,
+		     (XPointer *) &tmp_to, &tmp_to_left, tmp_args, 1)) >= 0 ) {
 
 	if (ret > 0) {
 	    unconv_num += ret;
@@ -527,9 +523,9 @@
 	if (tmp_charset != charset)  /* quit on end of segment */
 	    break;
 
-	*from = tmp_from;
+	*from = (XPointer) tmp_from;
 	*from_left = tmp_from_left;
-	*to = tmp_to;
+	*to = (XPointer) tmp_to;
 	*to_left = tmp_to_left;
     } 
 
@@ -540,27 +536,26 @@
 }
 
 static int
-sjis_wcstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+sjis_wcstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd) conv->state;
-    wchar_t *wcptr = *((wchar_t **)from);
-    register char *bufptr = *((char **) to);
+    const wchar_t *wcptr = *((const wchar_t **)from);
+    char *bufptr = *((char **) to);
     wchar_t wch;
     char *tmpptr;
-    register int length;
+    int length;
     CodeSet codeset;
     Ulong wc_encoding;
     int buf_len = *to_left;
     int wcstr_len = *from_left;
 
-
     if (!(codeset = wc_codeset(lcd, *wcptr)))
 	return -1;
 
@@ -620,13 +615,13 @@
 }
 
 static CodeSet
-GetCodeSetFromCharSet(lcd, charset)
-    XLCd lcd;
-    XlcCharSet charset;
-{
-    register CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
-    register XlcCharSet *charset_list;
-    register int codeset_num, num_charsets;
+GetCodeSetFromCharSet(
+    XLCd lcd,
+    XlcCharSet charset)
+{
+    CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
+    XlcCharSet *charset_list;
+    int codeset_num, num_charsets;
 
     codeset_num = XLC_GENERIC(lcd, codeset_num);
 
@@ -644,26 +639,24 @@
 
 
 static int
-sjis_cstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    char **from;
-    int *from_left;
-    char **to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+sjis_cstombs(
+    XlcConv conv,
+    char **from,
+    int *from_left,
+    char **to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd) conv->state;
-    register char *csptr = *from;
-    register char *bufptr = *to;
+    const char *csptr = *from;
+    char *bufptr = *to;
     int csstr_len = *from_left;
-    register int buf_len = *to_left;
+    int buf_len = *to_left;
     int length;
     CodeSet codeset;
-    EncodingType type;
     int cvt_length = 0;
 
-
     if (num_args < 1)
 	return -1;
     
@@ -690,7 +683,7 @@
     }
 
     *from_left -= csptr - *from;
-    *from = csptr;
+    *from = (XPointer) csptr;
 
     if (bufptr)
 	*to += cvt_length;
@@ -701,27 +694,26 @@
 }
 
 static int
-sjis_cstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+sjis_cstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd) conv->state;
-    register char *csptr = (char *) *from;
+    const char *csptr = (const char *) *from;
     wchar_t *bufptr = (wchar_t *) *to;
     wchar_t *toptr = (wchar_t *) *to;
     int csstr_len = *from_left;
-    register int buf_len = *to_left;
+    int buf_len = *to_left;
     wchar_t wch;
     int length;
     Ulong wc_shift_bits = (int)XLC_GENERIC(lcd, wc_shift_bits);
     CodeSet codeset;
 
-
     if (num_args < 1)
 	return -1;
 
@@ -753,7 +745,7 @@
     }
 
     *from_left -= csptr - *from;
-    *from = csptr;
+    *from = (XPointer) csptr;
 
     return 0;
 }
@@ -836,8 +828,8 @@
  * initCTptr(): Set ctptr[] to point at ctdata[], indexed by codeset_num.
  */
 static void
-initCTptr(lcd)
-    XLCd lcd;
+initCTptr(
+    XLCd lcd)
 {
     int num_codesets = XLC_GENERIC(lcd, codeset_num);
     int num_charsets;
@@ -882,22 +874,22 @@
 
 
 static int
-sjis_mbstocts(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+sjis_mbstocts(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
-    register int ct_len = *to_left;
+    int ct_len = *to_left;
     int cs_num;
     int clen;
     int unconv_num = 0;
     int num_conv;
-    XPointer inbufptr = *from;
-    register char *ctptr = *to;
+    const char *inbufptr = *from;
+    char *ctptr = *to;
     XPointer ct_base = ctptr;
 
     StateRec ct_state;
@@ -905,13 +897,11 @@
     XLCd lcd = (XLCd) conv->state;
     int codeset_num = XLC_GENERIC(lcd, codeset_num);
 
-
 /* Initial State: */
 
     ct_state.GL_charset = ctdptr[Ascii];
     ct_state.GR_charset = NULL;
 
-
     if (*from_left > *to_left)
         *from_left = *to_left;
 
@@ -1017,21 +1007,21 @@
 #define byte2		(byte1 == 0)
 
 static int
-sjis_wcstocts(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
-{
-    register int ct_len = *to_left;
-    register wchar_t *inbufptr = (wchar_t *) *from;
-    register char *ctptr = *to;
+sjis_wcstocts(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
+{
+    int ct_len = *to_left;
+    const wchar_t *inbufptr = (const wchar_t *) *from;
+    char *ctptr = *to;
     XPointer ct_base = ctptr;
     wchar_t  wch;
-    register int length;
+    int length;
     Uchar tmp;
     Uchar t1 = 0;
     int num_conv;
@@ -1138,27 +1128,26 @@
 #define SKIP_P(str)	while (*(str) >= 0x30 && *(str) <=  0x3f) (str)++;
 
 static int
-sjis_ctstombs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
-{
-    register XPointer inbufptr =  *from;
-    register XPointer outbufptr =  *to;
-    XPointer inbuf_base;
+sjis_ctstombs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
+{
+    const char *inbufptr =  *from;
+    XPointer outbufptr =  *to;
+    const char *inbuf_base;
     XPointer outbuf_base = outbufptr;
-    register int clen, length;
+    int clen, length;
     int unconv_num = 0;
     int num_conv;
     unsigned int ct_seglen = 0;
     Uchar ct_type;
     CTData ctdp = ctdata;	/* default */
 
-
     if (*from_left > *to_left)
 	*from_left = *to_left;
 
@@ -1251,33 +1240,32 @@
 
 
 static int
-sjis_ctstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+sjis_ctstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XLCd lcd = (XLCd)conv->state;
     Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
-    register XPointer inbufptr = *from;
-    XPointer inbuf_base;
-    register wchar_t *outbufptr = (wchar_t *) *to;
+    const char *inbufptr = *from;
+    const char *inbuf_base;
+    wchar_t *outbufptr = (wchar_t *) *to;
     wchar_t *outbuf_base = outbufptr;
-    register int clen, length;
+    int clen, length;
     int num_conv;
     int unconv_num = 0;
     unsigned int ct_seglen = 0;
     Uchar ct_type = 0;
-    register int shift_mult;
+    int shift_mult;
     wchar_t wc_tmp;
     wchar_t wch;
     Ulong wc_encoding;
     CTData ctdp = ctdata;
 
-
     if (*from_left > *to_left)
 	*from_left = *to_left;
   
@@ -1383,17 +1371,17 @@
 #undef BADCHAR
 
 static void
-close_converter(conv)
-    XlcConv conv;
+close_converter(
+    XlcConv conv)
 {
 	Xfree((char *) conv);
 }
 
 
 static XlcConv
-create_conv(lcd, methods)
-    XLCd lcd;
-    XlcConvMethods methods;
+create_conv(
+    XLCd lcd,
+    XlcConvMethods methods)
 {
     XlcConv conv;
 
@@ -1426,118 +1414,118 @@
 
 
 static XlcConv
-open_mbstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[MBSTOCS]);
 }
 
 static XlcConv
-open_wcstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[WCSTOCS]);
 }
 
 static XlcConv
-open_mbtocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbtocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[MBTOCS]);
 }
 
 static XlcConv
-open_cstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[CSTOMBS]);
 }
 
 static XlcConv
-open_cstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[CSTOWCS]);
 }
 
 static XlcConv
-open_mbstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[MBSTOWCS]);
 }
 
 static XlcConv
-open_wcstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[WCSTOMBS]);
 }
 
 static XlcConv
-open_wcstocts(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocts(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[WCSTOCTS]);
 }
 
 static XlcConv
-open_mbstocts(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_mbstocts(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[MBSTOCTS]);
 }
 
 static XlcConv
-open_ctstombs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_ctstombs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[CTSTOMBS]);
 }
 
 static XlcConv
-open_ctstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_ctstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &conv_methods[CTSTOWCS]);
 }
 
 XLCd
-_XlcSjisLoader(name)
-    _Xconst char *name;
+_XlcSjisLoader(
+    const char *name)
 {
     XLCd lcd;
 
Index: xc/lib/X11/lcStd.c
diff -u xc/lib/X11/lcStd.c:1.3 xc/lib/X11/lcStd.c:1.4
--- xc/lib/X11/lcStd.c:1.3	Sun May  9 06:50:41 1999
+++ xc/lib/X11/lcStd.c	Tue Nov 28 13:49:49 2000
@@ -23,7 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/lcStd.c,v 1.3 1999/05/09 10:50:41 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcStd.c,v 1.4 2000/11/28 18:49:49 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XlcPubI.h"
@@ -313,4 +313,53 @@
 	return 0;
 
     return *wstr1 - *wstr2;
+}
+
+
+int
+_Xlcmbstoutf8(lcd, ustr, str, len)
+    XLCd lcd;
+    char *ustr;
+    const char *str;
+    int len;
+{
+    XlcConv conv;
+    XPointer from, to;
+    int from_left, to_left, ret;
+
+    if (lcd == NULL) {
+	lcd = _XlcCurrentLC();
+	if (lcd == NULL)
+	    return -1;
+    }
+
+    conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNUtf8String);
+    if (conv == NULL)
+	return -1;
+
+    from = (XPointer) str;
+    from_left = strlen(str);
+    to = (XPointer) ustr;
+    to_left = len;
+
+    if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+	ret = -1;
+    else {
+	ret = len - to_left;
+	if (ustr && to_left > 0)
+	    ustr[ret] = '\0';
+    }
+
+    _XlcCloseConverter(conv);
+
+    return ret;
+}
+
+int
+_Xmbstoutf8(ustr, str, len)
+    char *ustr;
+    const char *str;
+    int len;
+{
+    return _Xlcmbstoutf8((XLCd) NULL, ustr, str, len);
 }
Index: xc/lib/X11/lcTxtPr.c
diff -u xc/lib/X11/lcTxtPr.c:3.1 xc/lib/X11/lcTxtPr.c:3.2
--- xc/lib/X11/lcTxtPr.c:3.1	Mon Dec 23 01:00:07 1996
+++ xc/lib/X11/lcTxtPr.c	Tue Nov 28 13:49:49 2000
@@ -23,6 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
+/* $XFree86: xc/lib/X11/lcTxtPr.c,v 3.2 2000/11/28 18:49:49 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XlcPubI.h"
@@ -31,14 +32,14 @@
 #include <stdio.h>
 
 static int
-get_buf_size(is_wide_char, list, count)
-    Bool is_wide_char;
-    XPointer list;
-    int count;
+get_buf_size(
+    Bool is_wide_char,
+    XPointer list,
+    int count)
 {
-    register int length = 0;
-    register char **mb_list;
-    register wchar_t **wc_list;
+    int length = 0;
+    char **mb_list;
+    wchar_t **wc_list;
 
     if (list == NULL)
 	return 0;
@@ -64,18 +65,18 @@
 }
 
 static int
-_XTextListToTextProperty(lcd, dpy, from_type, list, count, style, text_prop)
-    XLCd lcd;
-    Display *dpy;
-    char *from_type;
-    XPointer list;
-    int count;
-    XICCEncodingStyle style;
-    XTextProperty *text_prop;
+_XTextListToTextProperty(
+    XLCd lcd,
+    Display *dpy,
+    const char *from_type,
+    XPointer list,
+    int count,
+    XICCEncodingStyle style,
+    XTextProperty *text_prop)
 {
     Atom encoding;
     XlcConv conv;
-    char *to_type;
+    const char *to_type;
     char **mb_list;
     wchar_t **wc_list;
     XPointer from;
@@ -96,6 +97,10 @@
 	    encoding = XA_STRING;
 	    to_type = XlcNString;
 	    break;
+	case XUTF8StringStyle:
+	    encoding = XInternAtom(dpy, "UTF8_STRING", False);
+	    to_type = XlcNUtf8String;
+	    break;
 	case XCompoundTextStyle:
 	    encoding = XInternAtom(dpy, "COMPOUND_TEXT", False);
 	    to_type = XlcNCompoundText;
@@ -209,27 +214,40 @@
 }
 
 int
-_XmbTextListToTextProperty(lcd, dpy, list, count, style, text_prop)
-    XLCd lcd;
-    Display *dpy;
-    char **list;
-    int count;
-    XICCEncodingStyle style;
-    XTextProperty *text_prop;
+_XmbTextListToTextProperty(
+    XLCd lcd,
+    Display *dpy,
+    char **list,
+    int count,
+    XICCEncodingStyle style,
+    XTextProperty *text_prop)
 {
     return _XTextListToTextProperty(lcd, dpy, XlcNMultiByte, (XPointer) list,
 				    count, style, text_prop);
 }
 
 int
-_XwcTextListToTextProperty(lcd, dpy, list, count, style, text_prop)
-    XLCd lcd;
-    Display *dpy;
-    wchar_t **list;
-    int count;
-    XICCEncodingStyle style;
-    XTextProperty *text_prop;
+_XwcTextListToTextProperty(
+    XLCd lcd,
+    Display *dpy,
+    wchar_t **list,
+    int count,
+    XICCEncodingStyle style,
+    XTextProperty *text_prop)
 {
     return _XTextListToTextProperty(lcd, dpy, XlcNWideChar, (XPointer) list,
+				    count, style, text_prop);
+}
+
+int
+_Xutf8TextListToTextProperty(
+    XLCd lcd,
+    Display *dpy,
+    char **list,
+    int count,
+    XICCEncodingStyle style,
+    XTextProperty *text_prop)
+{
+    return _XTextListToTextProperty(lcd, dpy, XlcNUtf8String, (XPointer) list,
 				    count, style, text_prop);
 }
Index: xc/lib/X11/lcUTF.c
diff -u xc/lib/X11/lcUTF.c:3.14 xc/lib/X11/lcUTF.c:removed
--- xc/lib/X11/lcUTF.c:3.14	Sat Feb 12 15:45:04 2000
+++ xc/lib/X11/lcUTF.c	Mon Dec 18 14:23:59 2000
@@ -1,1740 +0,0 @@
-/* $TOG: lcUTF.c /main/25 1998/05/20 14:47:50 kaleb $ */
-/******************************************************************
-
-              Copyright 1993 by SunSoft, Inc.
-
-Permission to use, copy, modify, distribute, and sell this software
-and its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear
-in supporting documentation, and that the name of SunSoft, Inc.
-not be used in advertising or publicity pertaining to distribution
-of the software without specific, written prior permission.
-SunSoft, Inc. makes no representations about the suitability of
-this software for any purpose.  It is provided "as is" without
-express or implied warranty.
-
-SunSoft Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
-IN NO EVENT SHALL SunSoft, Inc. BE LIABLE FOR ANY SPECIAL, INDIRECT
-OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
-OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
-OR PERFORMANCE OF THIS SOFTWARE.
-
-  Author: Hiromu Inukai (inukai@Japan.Sun.COM) SunSoft, inc.
-
-******************************************************************/
-/* $XFree86: xc/lib/X11/lcUTF.c,v 3.14 2000/02/12 20:45:04 dawes Exp $ */
-
-/*
- * An UTF-1 locale loader.
- * Supports: all locales with codeset "utf".
- * How: Provides converters for UTF-1.
- * Platforms: Only those defining X_LOCALE (only Lynx, Linux-libc5, OS/2).
- */
-
-#ifdef X_LOCALE
-
-#include "Xlibint.h"
-#include "XlcPubI.h"
-#include "XlcUTF.h"
-
-static int getutfrune(
-#if NeedFunctionPrototypes
-    char**,
-    int*
-#endif
-);
-static void our_wctomb(
-#if NeedFunctionPrototypes
-    wchar_t, 
-    char **, 
-    int *
-#endif
-);
-static int our_mbtowc(
-#if NeedFunctionPrototypes   
-    wchar_t*, 
-    char*, 
-    size_t
-#endif
-);
-static void	latin2rune(
-#if NeedFunctionPrototypes
-    unsigned char, 
-    Rune*
-#endif
-);
-static void	jis02012rune(
-#if NeedFunctionPrototypes
-    unsigned char, 
-    Rune*
-#endif
-);
-static void	jis02082rune(
-#if NeedFunctionPrototypes
-    unsigned char, 
-    Rune*
-#endif
-);
-static void	ksc2rune(
-#if NeedFunctionPrototypes
-    unsigned char, 
-    Rune*
-#endif
-);
-static void	gb2rune(
-#if NeedFunctionPrototypes
-    unsigned char, 
-    Rune*
-#endif
-);
-static void	init_latin1tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_latin2tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_latin3tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_latin4tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_cyrillictab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_koi8rtab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_koi8utab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_arabictab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_greektab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_hebrewtab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_latin5tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_latin6tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_latin8tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_latin9tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_tis620tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_armscii8tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_ibmcp1133tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_mulelao1tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_visciitab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_tcvn5712tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_georgianacademytab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_georgianpstab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-
-
-static void	init_jis0201tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_jis0208tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_ksc5601tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-static void	init_gb2312tab(
-#if NeedFunctionPrototypes
-    int*,
-    wchar_t
-#endif
-);
-
-static int*	tabkuten = NULL;
-static int*	tabksc = NULL;
-static int*	tabgb = NULL;
-
-static UtfData utfdata_list = (UtfData)NULL;
-
-static XlcUTFDataRec default_utf_data[] = 
-{
-    {"ISO8859-1", XlcGL, init_latin1tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-1", XlcGR, init_latin1tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-2", XlcGL, init_latin2tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-2", XlcGR, init_latin2tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-3", XlcGL, init_latin3tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-3", XlcGR, init_latin3tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-4", XlcGL, init_latin4tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-4", XlcGR, init_latin4tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-5", XlcGL, init_cyrillictab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-5", XlcGR, init_cyrillictab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-6", XlcGL, init_arabictab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-6", XlcGR, init_arabictab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-7", XlcGL, init_greektab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-7", XlcGR, init_greektab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-8", XlcGL, init_hebrewtab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-8", XlcGR, init_hebrewtab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-9", XlcGL, init_latin5tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-9", XlcGR, init_latin5tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-10", XlcGL, init_latin6tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-10", XlcGR, init_latin6tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-14", XlcGL, init_latin8tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-14", XlcGR, init_latin8tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-15", XlcGL, init_latin9tab, latin2rune, N11n_none, 0x20},
-    {"ISO8859-15", XlcGR, init_latin9tab, latin2rune, N11n_none, 0x20},
-    {"JISX0201.1976-0", XlcGL, init_jis0201tab, jis02012rune, N11n_none, 0x20},
-    {"JISX0201.1976-0", XlcGR, init_jis0201tab, jis02012rune, N11n_none, 0x20},
-    {"JISX0208.1983-0", XlcGL, init_jis0208tab, jis02082rune, N11n_ja, 0x2222},
-    {"JISX0208.1983-0", XlcGR, init_jis0208tab, jis02082rune, N11n_ja, 0x2222},
-    {"KSC5601.1987-0", XlcGL, init_ksc5601tab, ksc2rune, N11n_ko, 0x2160},
-    {"KSC5601.1987-0", XlcGR, init_ksc5601tab, ksc2rune, N11n_ko, 0x2160},
-    {"GB2312.1980-0", XlcGL, init_gb2312tab, gb2rune, N11n_zh, 0x2175},
-    {"GB2312.1980-0", XlcGR, init_gb2312tab, gb2rune, N11n_zh, 0x2175},
-    {"TIS620.2533-1", XlcGL, init_tis620tab, latin2rune, N11n_none, 0x20},
-    {"TIS620.2533-1", XlcGR, init_tis620tab, latin2rune, N11n_none, 0x20},
-    {"KOI8-R", XlcGL, init_koi8rtab, latin2rune, N11n_none, 0x20},
-    {"KOI8-R", XlcGR, init_koi8rtab, latin2rune, N11n_none, 0x20},
-    {"KOI8-U", XlcGL, init_koi8utab, latin2rune, N11n_none, 0x20},
-    {"KOI8-U", XlcGR, init_koi8utab, latin2rune, N11n_none, 0x20},
-    {"ARMSCII-8", XlcGL, init_armscii8tab, latin2rune, N11n_none, 0x20},
-    {"ARMSCII-8", XlcGR, init_armscii8tab, latin2rune, N11n_none, 0x20},
-    {"IBM-CP1133", XlcGL, init_ibmcp1133tab, latin2rune, N11n_none, 0x20},
-    {"IBM-CP1133", XlcGR, init_ibmcp1133tab, latin2rune, N11n_none, 0x20},
-    {"MULELAO-1", XlcGL, init_mulelao1tab, latin2rune, N11n_none, 0x20},
-    {"MULELAO-1", XlcGR, init_mulelao1tab, latin2rune, N11n_none, 0x20},
-    {"VISCII1.1-1", XlcGL, init_visciitab, latin2rune, N11n_none, 0x20},
-    {"VISCII1.1-1", XlcGR, init_visciitab, latin2rune, N11n_none, 0x20},
-    {"TCVN-5712", XlcGL, init_tcvn5712tab, latin2rune, N11n_none, 0x20},
-    {"TCVN-5712", XlcGR, init_tcvn5712tab, latin2rune, N11n_none, 0x20},
-    {"GEORGIAN-ACADEMY", XlcGL, init_georgianacademytab, latin2rune, N11n_none, 0x20},
-    {"GEORGIAN-ACADEMY", XlcGR, init_georgianacademytab, latin2rune, N11n_none, 0x20},
-    {"GEORGIAN-PS", XlcGL, init_georgianpstab, latin2rune, N11n_none, 0x20},
-    {"GEORGIAN-PS", XlcGR, init_georgianpstab, latin2rune, N11n_none, 0x20},
-
-};
-
-
-static void
-set_latin_nop(table, default_val)
-    int*	table;
-    wchar_t	default_val;
-{
-    register int i;
-    for(i = 0; i < LATINMAX; i++)
-	table[i] = (int) default_val;
-    return;
-}
-
-static void
-set_cjk_nop(to_tbl, to_max, default_val)
-    int*	to_tbl;
-    wchar_t	default_val;
-    int	to_max;
-{
-    register int i;
-    for(i = 0; i < to_max; i++)
-	to_tbl[i] = default_val;
-    return;
-}
-
-static void
-set_latin_tab(fptr, table, fb_default)
-    FILE*	fptr;
-    int*	table;
-    wchar_t	fb_default;
-{
-    int		j = 0;
-    int		rv;
-    long	value;
-
-    while((rv = fscanf(fptr, "%lx", &value)) != EOF) {
-	if(rv != 0)
-	    table[j++] = (wchar_t) value;
-    }
-}
-
-static void
-set_cjk_tab(fptr, to_tbl, from_tbl, to_max, fb_default)
-    FILE*	fptr;
-    int*	to_tbl;
-    int*	from_tbl;
-    int		to_max;
-    wchar_t	fb_default;
-{
-    int		j = 0;
-    int		rv;
-    long	value;
-
-    while((rv = fscanf(fptr, "%lx", &value)) != EOF) {
-	if(rv != 0)
-	    to_tbl[j++] = value;
-    }
-    for(j = 0; j < to_max; j++) {
-	if((value = to_tbl[j]) != -1)
-	    from_tbl[abs(value)] = j;
-    }
-}
-
-static char TBL_DATA_DIR[] = "tbl_data";
-
-static void
-#if NeedFunctionPrototypes
-init_8859_tab(
-    int*	tbl,
-    wchar_t	fb_default,
-    char*	which)
-#else
-init_8859_tab(tbl, fb_default, which)
-    int*	tbl;
-    wchar_t	fb_default;
-    char*	which;
-#endif
-{
-    FILE*	fp = NULL;
-    char	dirname[BUFSIZE];
-    char	filename[BUFSIZE];
-    char*	p;
-    char*	q;
-
-    _XlcResolveI18NPath(dirname, BUFSIZE);
-    p = dirname;
-    while(p) {
-	q = strchr(p, ':');
-	if(q) {
-	    *q = '\0';
-	}
-
-	if ((3 + (p ? strlen(p) : 0) + 
-	    strlen (TBL_DATA_DIR) + strlen (which)) < BUFSIZE) {
-	    sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, which);
-	    fp = _XFopenFile (filename, "r");
-	}
-	if(fp) {
-	    set_latin_tab(fp, tbl, fb_default);
-	    fclose(fp);
-	    return;
-	}
-	if(q) {
-	    p = q + 1;
-	} else {
-	    p = q;
-	}
-    }
-    if(!fp) {
-	set_latin_nop(tbl, fb_default);
-    }
-}
-
-static void
-#if NeedFunctionPrototypes
-init_cjk_tab(
-    int*	tbl,
-    wchar_t	fb_default,
-    char*	which,
-    int**	tab,
-    long	max)
-#else
-init_cjk_tab(tbl, fb_default, which, tab, max)
-    int*	tbl;
-    wchar_t	fb_default;
-    char*	which;
-    int**	tab;
-    long	max;
-#endif
-{
-    FILE*	fp = NULL;
-    char	dirname[BUFSIZE];
-    char	filename[BUFSIZE];
-    char*	p;
-    char*	q;
-
-    if((*tab = (int*)Xmalloc(max * sizeof(int))) == NULL) {
-	return;
-    }
-    _XlcResolveI18NPath(dirname, BUFSIZE);
-    p = dirname;
-    while(p) {
-	q = strchr(p, ':');
-	if(q) {
-	    *q = '\0';
-	}
-	if ((3 + (p ? strlen(p) : 0) + 
-	    strlen (TBL_DATA_DIR) + strlen (which)) < BUFSIZE) {
-	    sprintf(filename, "%s/%s/%s", p, TBL_DATA_DIR, which);
-	    fp = _XFopenFile (filename, "r");
-	}
-	if(fp) {
-	    set_cjk_tab(fp, *tab, tbl, max, fb_default);
-	    fclose(fp);
-	    return;
-	}
-	if(q) {
-	    p = q + 1;
-	} else {
-	    p = q;
-	}
-    }
-    if(!fp) {
-	set_cjk_nop(*tab, max, fb_default);
-    }
-}
-
-static void
-#if NeedFunctionPrototypes
-init_latin1tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_latin1tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_1);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_latin2tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_latin2tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_2);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_latin3tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_latin3tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_3);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_latin4tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_latin4tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_4);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_cyrillictab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_cyrillictab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_5);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_koi8rtab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_koi8rtab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabkoi8_r);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_koi8utab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_koi8utab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabkoi8_u);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_arabictab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_arabictab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_6);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_greektab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_greektab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_7);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_hebrewtab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_hebrewtab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_8);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_latin5tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_latin5tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_9);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_latin6tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_latin6tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_10);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_latin8tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_latin8tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_14);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_latin9tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_latin9tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tab8859_15);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_tis620tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_tis620tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabtis620);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_armscii8tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_armscii8tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabarmscii_8);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_ibmcp1133tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_ibmcp1133tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabibm_cp1133);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_mulelao1tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_mulelao1tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabmulelao_1);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_visciitab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_visciitab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabviscii);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_tcvn5712tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_tcvn5712tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabtcvn);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_georgianacademytab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_georgianacademytab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabgeorgian_academy);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_georgianpstab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_georgianpstab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_8859_tab (tbl, fb_default, tabgeorgian_ps);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_jis0201tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_jis0201tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-	int i;
-	for(i = 0; i < NRUNE; i++)
-	    tbl[i] = -1;
-}
-
-static void
-#if NeedFunctionPrototypes
-init_jis0208tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_jis0208tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_cjk_tab (tbl, fb_default, jis0208, &tabkuten, KUTENMAX);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_ksc5601tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_ksc5601tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_cjk_tab (tbl, fb_default, ksc5601, &tabksc, KSCMAX);
-}
-
-static void
-#if NeedFunctionPrototypes
-init_gb2312tab(
-    int*	tbl,
-    wchar_t	fb_default)
-#else
-init_gb2312tab(tbl, fb_default)
-    int*	tbl;
-    wchar_t	fb_default;
-#endif
-{
-    init_cjk_tab (tbl, fb_default, gb2312, &tabgb, GBMAX);
-}
-
-static UtfData
-make_entry()
-{
-    UtfData tmp = (UtfData)Xmalloc(sizeof(UtfDataRec));
-    bzero(tmp, sizeof(UtfDataRec));
-    return tmp;
-}
-
-static int	once = 0;
-
-static int
-InitUTFInfo(lcd)
-XLCd	lcd;
-{
-    if(!once) {
-	int	i;
-	CodeSet	*codeset_list = XLC_GENERIC(lcd, codeset_list);
-	int	codeset_num = XLC_GENERIC(lcd, codeset_num);
-	UtfData	pdata;
-
-	if(!utfdata_list) {
-	    utfdata_list = make_entry();
-	}
-	pdata = utfdata_list;
-	for(i=0; i < codeset_num; i++) {
-	    XlcCharSet	charset = *codeset_list[i]->charset_list;
-	    while(pdata->next) {
-		if(charset == pdata->charset) {
-		    break;
-		}
-		pdata = pdata->next;
-	    }
-	    if(pdata->next) {
-		continue;
-	    } else {
-		int j;
-		for(j = 0; j < MAX_UTF_CHARSET; j++) {
-		    if(_XlcCompareISOLatin1(charset->encoding_name, default_utf_data[j].name) ||
-		       charset->side != default_utf_data[j].side) {
-			continue;
-		    } else {
- 			pdata->initialize = default_utf_data[j].initialize;
-			pdata->fromtbl = (int *)Xmalloc(LATINMAX * sizeof(int));
-			(*pdata->initialize)(pdata->fromtbl, default_utf_data[j].fallback_value);
-			pdata->already_init = True;
-			pdata->charset = charset;
-			pdata->cstorune = default_utf_data[j].cstorune;
-			pdata->type = default_utf_data[j].type;
-			pdata->next = make_entry();
-			break;
-		    }
-		}
-	    }
-	}
-	once = 1;
-    }
-    return 1;
-}
-
-static int
-utftocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv	conv;
-    char	**from;
-    int		*from_left;
-    char	**to;
-    int		*to_left;
-    XPointer	*args;
-    int		num_args;
-{
-    char	*utfptr;
-    char 	*bufptr;
-    int		utf_len, buf_len;
-    wchar_t	wc;
-    XlcCharSet	tmpcharset = (XlcCharSet)NULL;
-    UtfData	pdata = utfdata_list;
-
-    if (from == NULL || *from == NULL)
-	return 0;
-
-    utfptr = *from;
-    bufptr = *to;
-    utf_len = *from_left;
-    buf_len = *to_left;
-
-    while(utf_len > 0 && buf_len > 0) {
-	char *p = utfptr;
-        int rune = getutfrune(&p, &utf_len);
-	if(rune == -1) {
-	    return -1;
-	} else {
-	    wc = (wchar_t) rune;
-	    while(pdata->next) {
-		wchar_t		r;
-		int*		tbl;
-
-		tbl = pdata->fromtbl;
-		tbl += wc;
-		if (*tbl == -1) {
-		    if(tmpcharset) {
-			    goto end;
-		    } else {
-			pdata = pdata->next;
-			continue;
-		    }
-		} else {
-		    r = *tbl;
-		    utfptr = p;
-		    if(!tmpcharset) tmpcharset = pdata->charset;
-		}
-		if(r < 128) {
-		    *bufptr++ = r;
-		    buf_len--;
-		} else {
-		    switch(pdata->type) {
-			case N11n_ja:
-			    *bufptr++ = (r/100 + ' ');
-			    *bufptr++ = (r%100 + ' ');
-			    break;
-			case N11n_ko:
-			    *bufptr++ = (r/94 + 0x21);
-			    *bufptr++ = (r%94 + 0x21);
-			    break;
-			case N11n_zh:
-			    *bufptr++ = 0x20 + (r/100);
-			    *bufptr++ = 0x20 + (r%100);
-			    break;
-			default:
-			    break;
-		    }
-		    buf_len -= 2;
-		}
-		break;
-	    }
-	    if(!tmpcharset) return -1; /* Unknown Codepoint */
-	}
-    }
-end:
-    if((num_args > 0) && tmpcharset)
-	*((XlcCharSet *) args[0]) = tmpcharset;
-
-    *from_left -= utfptr - *from;
-    *from = utfptr;
-
-    *to_left -= bufptr - *to;
-    *to = bufptr;
-
-    return 0;
-}
-
-static int
-utf1tocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv	conv;
-    char	**from;
-    int		*from_left;
-    char	**to;
-    int		*to_left;
-    XPointer	*args;
-    int		num_args;
-{
-    char	**ptr = NULL;
-    char	char_ptr[UTFmax];
-    int		i = 0;
-    wchar_t	dummy = (wchar_t)0;
-
-    if (from == NULL || *from == NULL)
-	return utftocs(conv, from, from_left, to, to_left, args, num_args);
-
-    ptr = from;
-    for(i = 0; i < UTFmax; char_ptr[i++] = *(*ptr)++);
-    i=0;
-    while(our_mbtowc(&dummy, (char*)&char_ptr[0], i) <= 0)
-	i++;
-    return utftocs(conv, from, &i, to, to_left, args, num_args);
-}
-
-static int
-ucstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv	conv;
-    XPointer	*from;
-    int		*from_left;
-    char	**to;
-    int		*to_left;
-    XPointer	*args;
-    int		num_args;
-{
-    wchar_t	*ucsptr;
-    char 	*bufptr;
-    int		ucs_len, buf_len;
-    XlcCharSet	tmpcharset = (XlcCharSet)NULL;
-    UtfData	pdata = utfdata_list;
-
-    if (from == NULL || *from == NULL)
-	return 0;
-
-    ucsptr = (wchar_t *)*from;
-    bufptr = *to;
-    ucs_len = *from_left;
-    buf_len = *to_left;
-
-    while(ucs_len > 0 && buf_len > 0) {
-	while(pdata->next) {
-	    wchar_t	r;
-	    int*	tbl;
-
-	    tbl = pdata->fromtbl;
-	    tbl += *ucsptr;
-	    if(*tbl == -1) {
-		if(tmpcharset) {
-		    goto end;
-		} else {
-		    pdata = pdata->next;
-		    continue;
-		}
-	    } else {
-		r = *tbl;
-		if(!tmpcharset) tmpcharset = pdata->charset;
-	    }
-	    ucsptr++;
-	    if(r < 128) {
-		*bufptr++ = r;
-		ucs_len--;
-		buf_len--;
-	    } else {
-		switch(pdata->type) {
-		case N11n_ja:
-		    *bufptr++ = (r/100 + ' ');
-		    *bufptr++ = (r%100 + ' ');
-		    break;
-		case N11n_ko:
-		    *bufptr++ = (r/94 + 0x21);
-		    *bufptr++ = (r%94 + 0x21);
-		    break;
-		case N11n_zh:
-		    *bufptr++ = 0x20 + (r/100);
-		    *bufptr++ = 0x20 + (r%100);
-		    break;
-		default:
-		    break;
-		}
-		ucs_len--;
-		buf_len -= 2;
-	    }
-	    break;
-	}
-	if(!tmpcharset) return  -1; /* Unknown Codepoint */
-    }
-end:
-    if((num_args > 0) && tmpcharset)
-	*((XlcCharSet *) args[0]) = tmpcharset;
-
-    *from_left -= ucsptr - (wchar_t *)*from;
-    *from = (XPointer)ucsptr;
-
-    *to_left -= bufptr - *to;
-    *to = bufptr;
-
-    return 0;
-}
-
-static int
-#if NeedFunctionPrototypes
-getutfrune(char **read_from, int *from_len)
-#else
-getutfrune(read_from, from_len)
-char **read_from;
-int *from_len;
-#endif
-{
-    int c, i;
-    char str[UTFmax]; /* MB_LEN_MAX really */
-    wchar_t wc;
-    int n;
-
-    str[0] = '\0';
-    for(i = 0; i <= UTFmax;) {
-	c = **read_from;
-	(*read_from)++;
-	str[i++] = c;
-	n = our_mbtowc(&wc, str, i);
-	if(n == -1)
-	    return -1;
-	if(n > 0) {
-	    *from_len -= n;
-	    return wc;
-	}
-    }
-    return -1;
-}
-
-static int
-cstoutf(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    char **from;
-    int *from_left;
-    char **to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
-{
-    XlcCharSet charset;
-    char *csptr, *utfptr;
-    int csstr_len, utf_len;
-    int               cmp_len = 0;
-    void	(*putrune)(
-#if NeedFunctionPrototypes
-                            unsigned char c,
-                            Rune *r
-#endif
-			   ) = NULL;
-    Rune	r = (Rune)0;
-    UtfData	pdata = utfdata_list;
-
-    if (from == NULL || *from == NULL)
-	return 0;
-    
-    if (num_args < 1)
-        return -1;
-
-    csptr = *from;
-    utfptr = *to;
-    csstr_len = *from_left;
-    utf_len = *to_left;
-
-    charset = (XlcCharSet)args[0];
-    cmp_len = strchr(charset->name, ':') - charset->name;
-    while(pdata->next) {
-        if(!_XlcNCompareISOLatin1(charset->name, pdata->charset->name, cmp_len)) {
-	    putrune = pdata->cstorune;
-	    break;
-	} else {
-	    pdata = pdata->next;
-	}
-    }
-    if(!putrune)
-	return -1;
-
-    while(csstr_len-- > 0 && utf_len > 0) {
-	(*putrune)(*csptr++, &r);
-	if(!r) {
-	    continue;
-	}
-	our_wctomb(r, &utfptr, &utf_len);
-	r = 0;
-    }
- 
-    *from_left -= csptr - *from;
-    *from = csptr;
- 
-    *to_left -= utfptr - *to;
-    *to = utfptr;
- 
-    return 0;
-}
-
-static int
-cstoucs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    char **from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
-{
-    XlcCharSet charset;
-    char *csptr;
-    wchar_t *ucsptr;
-    int csstr_len, ucs_len;
-    int               cmp_len = 0;
-    void	(*putrune)(
-#if NeedFunctionPrototypes
-                            unsigned char c,
-                            Rune *r
-#endif
-			   ) = NULL;
-    Rune	r = (Rune)0;
-    UtfData	pdata = utfdata_list;
-
-    if (from == NULL || *from == NULL)
-	return 0;
-    
-    if (num_args < 1)
-        return -1;
-
-    csptr = *from;
-    ucsptr = (wchar_t *)*to;
-    csstr_len = *from_left;
-    ucs_len = *to_left;
-    charset = (XlcCharSet)args[0];
-    cmp_len = strchr(charset->name, ':') - charset->name;
-
-    while(pdata->next) {
-        if(!_XlcNCompareISOLatin1(charset->name, pdata->charset->name, cmp_len)) {
-	    putrune = pdata->cstorune;
-	    break;
-	} else {
-	    pdata = pdata->next;
-	}
-    }
-    if(!putrune)
-	return -1;
-
-    while(csstr_len-- > 0 && ucs_len > 0) {
-	(*putrune)(*csptr++, &r);
-	if(!r) {
-	    continue;
-	}
-	*ucsptr = (wchar_t)r;
-	ucsptr++;
-	ucs_len--;
-	r = 0;
-    }
- 
-    *from_left -= csptr - *from;
-    *from = csptr;
- 
-    *to_left -= ucsptr - (wchar_t *)*to;
-    *to = (XPointer)ucsptr;
- 
-    return 0;
-}
-
-static void
-#if NeedFunctionPrototypes
-our_wctomb(wchar_t r, char **utfptr, int *utf_len)
-#else
-our_wctomb(r, utfptr, utf_len)
-wchar_t r;
-char **utfptr;
-int *utf_len;
-#endif
-{
-    if(!utfptr || !*utfptr)
-	return;               /* no shift states */
-    if(r & ~Wchar2) {
-	if(r & ~Wchar4) {
-	    if(r & ~Wchar5) {
-		/* 6 bytes */
-		*(*utfptr)++ = T6 | ((r >> 5*Bitx) & Mask6);
-		*(*utfptr)++ = Tx | ((r >> 4*Bitx) & Maskx);
-		*(*utfptr)++  = Tx | ((r >> 3*Bitx) & Maskx);
-		*(*utfptr)++  = Tx | ((r >> 2*Bitx) & Maskx);
-		*(*utfptr)++  = Tx | ((r >> 1*Bitx) & Maskx);
-		*(*utfptr)++  = Tx |  (r & Maskx);
-		*utf_len -= 6;
-		return;
-	    }
-	    /* 5 bytes */
-	    *(*utfptr)++ = T5 |  (r >> 4*Bitx);
-	    *(*utfptr)++ = Tx | ((r >> 3*Bitx) & Maskx);
-	    *(*utfptr)++ = Tx | ((r >> 2*Bitx) & Maskx);
-	    *(*utfptr)++ = Tx | ((r >> 1*Bitx) & Maskx);
-	    *(*utfptr)++ = Tx |  (r & Maskx);
-	    *utf_len -= 5;
-	    return;
-	}
-	if(r & ~Wchar3) {
-	    /* 4 bytes */
-	    *(*utfptr)++ = T4 |  (r >> 3*Bitx);
-	    *(*utfptr)++ = Tx | ((r >> 2*Bitx) & Maskx);
-	    *(*utfptr)++ = Tx | ((r >> 1*Bitx) & Maskx);
-	    *(*utfptr)++ = Tx |  (r & Maskx);
-	    *utf_len -= 4;
-	    return;
-	}
-	/* 3 bytes */
-	*(*utfptr)++ = T3 |  (r >> 2*Bitx);
-	*(*utfptr)++ = Tx | ((r >> 1*Bitx) & Maskx);
-	*(*utfptr)++ = Tx |  (r & Maskx);
-	*utf_len -= 3;
-	return;
-    }
-    if(r & ~Wchar1) {
-	/* 2 bytes */
-	*(*utfptr)++ = T2 | (r >> 1*Bitx);
-	*(*utfptr)++ = Tx | (r & Maskx);
-	*utf_len -= 2;
-	return;
-    }
-    /* 1 byte */
-    *(*utfptr)++ = T1 | r;
-    *utf_len -= 1;
-    return;
-}
-
-static void
-#if NeedFunctionPrototypes
-latin2rune(unsigned char c, Rune *r)
-#else
-latin2rune(c, r)
-unsigned char c;
-Rune *r;
-#endif
-{
-    *r = (Rune)c;
-    return;
-}
-
-static void
-#if NeedFunctionPrototypes
-ksc2rune(unsigned char c, Rune *r)
-#else
-ksc2rune(c, r)
-unsigned char c;
-Rune *r;
-#endif
-{
-    static enum { init, cs1last} state = init;
-    static int korean646 = 1; /* fixed to 1 for now. */
-    static int lastc;
-    unsigned char	ch = (c|0x80); /* XXX */
-    int n;
-    wchar_t l;
-
-    switch(state) {
-    case init:
-	if (ch < 128){
-	    if(korean646 && (ch=='\\')){
-		emit(0x20A9);
-	    } else {
-		emit(ch);
-	    }
-	}else{
-	    lastc = ch;
-	    state = cs1last;
-	}
-	return;
-        
-    case cs1last: /* 2nd byte of codeset 1 (KSC 5601) */
-	n = ((lastc&0x7f)-33)*94 + (ch&0x7f)-33;
-	if((l = tabksc[n]) == 0){
-	    emit(BADMAP);
-	} else {
-	    emit(l);
-	}
-	state = init;
-	return;
-    }
-}
-
-static void
-#if NeedFunctionPrototypes
-jis02012rune(unsigned char c, Rune *r)
-#else
-jis02012rune(c, r)
-    unsigned char c;
-    Rune *r;
-#endif
-{
-/* To Be Implemented */
-}
-
-static void
-#if NeedFunctionPrototypes
-gb2rune(unsigned char c, Rune *r)
-#else
-gb2rune(c, r)
-    unsigned char c;
-    Rune *r;
-#endif
-{
-    static enum { state0, state1 } state = state0;
-    static int lastc;
-    long n;
-    unsigned char	ch1 = (c|0x80); /* XXX */
-
-    switch(state) {
-    case state0:    /* idle state */
-	if(ch1 >= 0xA1){
-	    lastc = ch1;
-	    state = state1;
-	    return;
-	}
-        emit(ch1);
-        return;
-
-    case state1:    /* seen a font spec */
-	if(ch1 >= 0xA1)
-	    n = (lastc-0xA0)*100 + (ch1-0xA0);
-        else {
-	    emit(BADMAP);
-	    state = state0;
-	    return;
-        }
-        if(tabgb[n] < 0){
-	    emit(BADMAP);
-        } else
-	    emit(tabgb[n]);
-        state = state0;
-    }
-}
-
-static void
-#if NeedFunctionPrototypes
-jis02082rune(unsigned char c, Rune *r)
-#else
-jis02082rune(c, r)
-    unsigned char c;
-    Rune *r;
-#endif
-{
-    static enum { state0, state1} state = state0;
-    static int lastc;
-    unsigned char	ch = (c|0x80); /* XXX */
-    int n;
-    wchar_t l;
-
-again:
-    switch(state) {
-    case state0:    /* idle state */
-	lastc = ch;
-	state = state1;
-	return;
-
-    case state1:    /* two part char */
-	if((lastc&0x80) != (ch&0x80)){
-	    emit(lastc);
-	    state = state0;
-	    goto again;
-	}
-	if(CANS2J(lastc, ch)){
-	    int h = lastc, l = ch;
-	    S2J(h, l);
-	    n = h*100 + l - 3232;
-	} else
-	    n = (lastc&0x7F)*100 + (ch&0x7f) - 3232; /* kuten */
-	if(tabkuten[n] == -1){
-	    emit(BADMAP);
-	} else {          
-	    emit(tabkuten[n]);
-	}        
-	state = state0;
-    }
-}
-
-static int
-#if NeedFunctionPrototypes
-our_mbtowc(wchar_t *p, char *s, size_t n)
-#else
-our_mbtowc(p, s, n)
-    wchar_t *p;
-    char *s;
-    size_t n;
-#endif
-{
-    unsigned char *us;
-    int c0, c1, c2, c3, c4, c5;
-    wchar_t wc;
-
-    if(s == 0)
-	return 0;		/* no shift states */
-
-    if(n < 1)
-	goto badlen;
-    us = (unsigned char*)s;
-    c0 = us[0];
-    if(c0 >= T3) {
-	if(n < 3)
-	    goto badlen;
-	c1 = us[1] ^ Tx;
-	c2 = us[2] ^ Tx;
-	if((c1|c2) & T2) {
-	    goto bad;
-	}
-	if(c0 >= T5) {
-	    if(n < 5)
-		goto badlen;
-	    c3 = us[3] ^ Tx;
-	    c4 = us[4] ^ Tx;
-	    if((c3|c4) & T2) {
-		goto bad;
-	    }
-	    if(c0 >= T6) {
-		/* 6 bytes */
-		if(n < 6)
-		    goto badlen;
-		c5 = us[5] ^ Tx;
-		if(c5 & T2) {
-		    goto bad;
-		}
-		wc = ((((((((((c0 & Mask6) << Bitx) | c1) 
-					   << Bitx) | c2) 
-					   << Bitx) | c3) 
-					   << Bitx) | c4) 
-					   << Bitx) | c5;
-		if(wc <= Wchar5) {
-		    goto bad;
-		}
-		*p = wc;
-		return 6;
-	    }
-	    /* 5 bytes */
-	    wc = ((((((((c0 & Mask5) << Bitx) | c1) 
-				     << Bitx) | c2) 
-				     << Bitx) | c3) 
-				     << Bitx) | c4;
-	    if(wc <= Wchar4) {
-				goto bad;
-	    }
-	    *p = wc;
-	    return 5;
-	}
-	if(c0 >= T4) {
-	    /* 4 bytes */
-	    if(n < 4)
-		goto badlen;
-	    c3 = us[3] ^ Tx;
-	    if(c3 & T2) {
-		goto bad;
-	    }
-	    wc = ((((((c0 & Mask4) << Bitx) | c1) 
-				   << Bitx) | c2) 
-				   << Bitx) | c3;
-	    if(wc <= Wchar3) {
-		goto bad;
-	    }
-	    *p = wc;
-	    return 4;
-	}
-	/* 3 bytes */
-	wc = ((((c0 & Mask3) << Bitx) | c1) 
-			     << Bitx) | c2;
-	if(wc <= Wchar2) {
-	    goto bad;
-	}
-	*p = wc;
-	return 3;
-    }
-    if(c0 >= T2) {
-	/* 2 bytes */
-	if(n < 2)
-	    goto badlen;
-	c1 = us[1] ^ Tx;
-	if(c1 & T2) {
-	    goto bad;
-	}
-	wc = ((c0 & Mask2) << Bitx) | c1;
-	if(wc <= Wchar1) {
-	    goto bad;
-	}
-	*p = wc;
-	return 2;
-    }
-    /* 1 byte */
-    if(c0 >= Tx) {
-	goto bad;
-    }
-    *p = c0;
-    return 1;
-
-bad:
-    errno = EILSEQ;
-    return -1;
-badlen:
-    return -2;
-}
-
-static void
-close_converter(conv)
-    XlcConv conv;
-{
-    Xfree((char *) conv);
-}
-
-static XlcConv
-create_conv(lcd, methods)
-    XLCd	lcd;
-    XlcConvMethods	methods;
-{
-    XlcConv conv;
-
-    conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
-    if (conv == (XlcConv) NULL)
-	return (XlcConv) NULL;
-
-    conv->methods = methods;
-
-    conv->state = NULL;
-    InitUTFInfo(lcd);
-
-    return conv;
-}
-
-static XlcConvMethodsRec mbtocs_methods = {
-    close_converter,
-    utf1tocs,
-    NULL
-};
-
-static XlcConv
-open_mbtocs(from_lcd, from, to_lcd, to)
-    XLCd from_lcd;
-    char *from;
-    XLCd to_lcd;
-    char *to;
-{
-    return create_conv(from_lcd, &mbtocs_methods);
-}
-
-static XlcConvMethodsRec mbstocs_methods = {
-    close_converter,
-    utftocs,
-    NULL
-};
-
-static XlcConv
-open_mbstocs(from_lcd, from, to_lcd, to)
-    XLCd from_lcd;
-    char *from;
-    XLCd to_lcd;
-    char *to;
-{
-    return create_conv(from_lcd, &mbstocs_methods);
-}
-
-static XlcConvMethodsRec wcstocs_methods = {
-    close_converter,
-    ucstocs,
-    NULL
-};
-
-static XlcConv
-open_wcstocs(from_lcd, from, to_lcd, to)
-    XLCd from_lcd;
-    char *from;
-    XLCd to_lcd;
-    char *to;
-{
-    return create_conv(from_lcd, &wcstocs_methods);
-}
-
-static XlcConvMethodsRec cstombs_methods = {
-    close_converter,
-    cstoutf,
-    NULL
-};
-
-static XlcConv
-open_cstombs(from_lcd, from, to_lcd, to)
-    XLCd from_lcd;
-    char *from;
-    XLCd to_lcd;
-    char *to;
-{
-    return create_conv(from_lcd, &cstombs_methods);
-}
-
-static XlcConvMethodsRec cstowcs_methods = {
-    close_converter,
-    cstoucs,
-    NULL
-};
-
-static XlcConv
-open_cstowcs(from_lcd, from, to_lcd, to)
-    XLCd from_lcd;
-    char *from;
-    XLCd to_lcd;
-    char *to;
-{
-    return create_conv(from_lcd, &cstowcs_methods);
-}
-
-
-XLCd
-_XlcUtfLoader(name)
-    _Xconst char *name;
-{
-    XLCd lcd;
-
-    lcd = _XlcCreateLC(name, _XlcGenericMethods);
-    if (lcd == (XLCd) NULL)
-	return lcd;
-    
-    if (!XLC_PUBLIC_PART(lcd)->codeset ||
-	(_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "utf"))) {
-	_XlcDestroyLC(lcd);
-	return (XLCd) NULL;
-    }
-
-    _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
-    _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
-
-    _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
-
-    _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
-    _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
-
-    return lcd;
-}
-
-#else
-typedef int dummy;
-#endif /* X_LOCALE */
Index: xc/lib/X11/lcUTF8.c
diff -u xc/lib/X11/lcUTF8.c:1.5 xc/lib/X11/lcUTF8.c:1.11
--- xc/lib/X11/lcUTF8.c:1.5	Fri Jun 30 14:27:00 2000
+++ xc/lib/X11/lcUTF8.c	Thu Dec  7 15:26:11 2000
@@ -24,17 +24,18 @@
 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/X11/lcUTF8.c,v 1.5 2000/06/30 18:27:00 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcUTF8.c,v 1.11 2000/12/07 20:26:11 dawes Exp $ */
 
 /*
  * This file contains:
  *
  * I. Conversion routines CompoundText/CharSet <--> Unicode/UTF-8.
  *
- *    Used for two purposes:
+ *    Used for three purposes:
  *      1. The UTF-8 locales, see below.
  *      2. Unicode aware applications for which the use of 8-bit character
  *         sets is an anachronism.
+ *      3. For conversion from keysym to locale encoding.
  *
  * II. An UTF-8 locale loader.
  *     Supports: all locales with codeset UTF-8.
@@ -70,14 +71,15 @@
  * without first going through the list of predefined character sets.
  */
 
+#include <stdio.h>
 #include "Xlibint.h"
 #include "XlcPubI.h"
 #include "XlcGeneric.h"
 
 static XlcConv
-create_conv(lcd, methods)
-    XLCd lcd;
-    XlcConvMethods methods;
+create_conv(
+    XLCd lcd,
+    XlcConvMethods methods)
 {
     XlcConv conv;
 
@@ -92,21 +94,21 @@
 }
 
 static void
-close_converter(conv)
-    XlcConv conv;
+close_converter(
+    XlcConv conv)
 {
     Xfree((char *) conv);
 }
 
 /* Replacement character for invalid multibyte sequence or wide character. */
-#define BAD_WCHAR ((wchar_t) 0xfffd)
+#define BAD_WCHAR ((ucs4_t) 0xfffd)
 #define BAD_CHAR '?'
 
 /***************************************************************************/
 /* Part I: Conversion routines CompoundText/CharSet <--> Unicode/UTF-8.
  *
  * Note that this code works in any locale. We store Unicode values in
- * `wchar_t' variables, but don't pass them to the user.
+ * `ucs4_t' variables, but don't pass them to the user.
  *
  * This code has to support all character sets that are used for CompoundText,
  * nothing more, nothing less. See the table in lcCT.c.
@@ -119,34 +121,32 @@
  * libX11 shared library share the "text" and read-only "data" sections.
  */
 
-typedef wchar_t original_wchar_t;
-typedef unsigned int local_wchar_t;
-#define wchar_t local_wchar_t
+typedef unsigned int ucs4_t;
 #define conv_t XlcConv
 
 typedef struct _Utf8ConvRec {
     const char *name;
     XrmQuark xrm_name;
 #if NeedFunctionPrototypes
-    int (* cstowc) (XlcConv, wchar_t *, unsigned char const *, int);
+    int (* cstowc) (XlcConv, ucs4_t *, unsigned char const *, int);
 #else
     int (* cstowc) ();
 #endif
 #if NeedFunctionPrototypes
-    int (* wctocs) (XlcConv, unsigned char *, wchar_t, int);
+    int (* wctocs) (XlcConv, unsigned char *, ucs4_t, int);
 #else
     int (* wctocs) ();
 #endif
 } Utf8ConvRec, *Utf8Conv;
 
 /*
- * int xxx_cstowc (XlcConv conv, wchar_t *pwc, unsigned char const *s, int n)
+ * int xxx_cstowc (XlcConv conv, ucs4_t *pwc, unsigned char const *s, int n)
  * converts the byte sequence starting at s to a wide character. Up to n bytes
  * are available at s. n is >= 1.
  * Result is number of bytes consumed (if a wide character was read),
  * or 0 if invalid, or -1 if n too small.
  *
- * int xxx_wctocs (XlcConv conv, unsigned char *r, wchar_t wc, int n)
+ * int xxx_wctocs (XlcConv conv, unsigned char *r, ucs4_t wc, int n)
  * converts the wide character wc to the character set xxx, and stores the
  * result beginning at r. Up to n bytes may be written at r. n is >= 1.
  * Result is number of bytes written, or 0 if invalid, or -1 if n too small.
@@ -167,6 +167,7 @@
  */
 
 #include "lcUniConv/utf8.h"
+#include "lcUniConv/ucs2be.h"
 #ifdef notused
 #include "lcUniConv/ascii.h"
 #endif
@@ -184,10 +185,12 @@
 #include "lcUniConv/iso8859_14.h"
 #include "lcUniConv/iso8859_15.h"
 #include "lcUniConv/iso8859_16.h"
+#include "lcUniConv/iso8859_9e.h"
 #include "lcUniConv/jisx0201.h"
 #include "lcUniConv/tis620.h"
 #include "lcUniConv/koi8_r.h"
 #include "lcUniConv/koi8_u.h"
+#include "lcUniConv/koi8_c.h"
 #include "lcUniConv/armscii_8.h"
 #include "lcUniConv/cp1133.h"
 #include "lcUniConv/mulelao.h"
@@ -195,6 +198,10 @@
 #include "lcUniConv/tcvn.h"
 #include "lcUniConv/georgian_academy.h"
 #include "lcUniConv/georgian_ps.h"
+#include "lcUniConv/cp1251.h"
+#include "lcUniConv/cp1255.h"
+#include "lcUniConv/cp1256.h"
+#include "lcUniConv/tatar_cyr.h"
 
 typedef struct {
     unsigned short indx; /* index into big table */
@@ -205,9 +212,8 @@
 #include "lcUniConv/jisx0208.h"
 #include "lcUniConv/jisx0212.h"
 #include "lcUniConv/ksc5601.h"
-#ifdef notdef
 #include "lcUniConv/big5.h"
-#endif
+#include "lcUniConv/big5_emacs.h"
 
 static Utf8ConvRec all_charsets[] = {
     /* The ISO10646-1/UTF-8 entry occurs twice, once at the beginning
@@ -261,27 +267,36 @@
     { "JISX0201.1976-0", NULLQUARK,
 	jisx0201_mbtowc, jisx0201_wctomb
     },
+    { "TIS620.2533-1", NULLQUARK,
+	tis620_mbtowc, tis620_wctomb
+    },
     { "GB2312.1980-0", NULLQUARK,
 	gb2312_mbtowc, gb2312_wctomb
     },
     { "JISX0208.1983-0", NULLQUARK,
 	jisx0208_mbtowc, jisx0208_wctomb
     },
+    { "JISX0208.1990-0", NULLQUARK,
+	jisx0208_mbtowc, jisx0208_wctomb
+    },
     { "JISX0212.1990-0", NULLQUARK,
 	jisx0212_mbtowc, jisx0212_wctomb
     },
     { "KSC5601.1987-0", NULLQUARK,
 	ksc5601_mbtowc, ksc5601_wctomb
     },
-    { "TIS620.2533-1", NULLQUARK,
-	tis620_mbtowc, tis620_wctomb
-    },
     { "KOI8-R", NULLQUARK,
 	koi8_r_mbtowc, koi8_r_wctomb
     },
     { "KOI8-U", NULLQUARK,
 	koi8_u_mbtowc, koi8_u_wctomb
     },
+    { "KOI8-C", NULLQUARK,
+	koi8_c_mbtowc, koi8_c_wctomb
+    },
+    { "TATAR-CYR", NULLQUARK,
+	tatar_cyr_mbtowc, tatar_cyr_wctomb
+    },
     { "ARMSCII-8", NULLQUARK,
 	armscii_8_mbtowc, armscii_8_wctomb
     },
@@ -303,28 +318,49 @@
     { "GEORGIAN-PS", NULLQUARK,
 	georgian_ps_mbtowc, georgian_ps_wctomb
     },
-#ifdef notdef
-    { "BIG-5", NULLQUARK,
-	big5_mbtowc, big5_wctomb
+    { "ISO8859-9E", NULLQUARK,
+	iso8859_9e_mbtowc, iso8859_9e_wctomb
     },
-#endif
+    { "MICROSOFT-CP1251", NULLQUARK,
+	cp1251_mbtowc, cp1251_wctomb
+    },
+    { "MICROSOFT-CP1255", NULLQUARK,
+	cp1255_mbtowc, cp1255_wctomb
+    },
+    { "MICROSOFT-CP1256", NULLQUARK,
+	cp1256_mbtowc, cp1256_wctomb
+    },
+    { "BIG5-0", NULLQUARK,
+	big5_0_mbtowc, big5_0_wctomb
+    },
+    { "BIG5-1", NULLQUARK,
+	big5_1_mbtowc, big5_1_wctomb
+    },
 
     /* The ISO10646-1/UTF-8 entry occurs twice, once at the beginning
        (for lookup speed), once at the end (as a fallback).  */
     { "ISO10646-1", NULLQUARK,
 	utf8_mbtowc, utf8_wctomb
     },
+
+    /* Encoding ISO10646-1 for fonts means UCS2-like encoding
+       so for conversion to FontCharSet we need this record */
+    { "ISO10646-1", NULLQUARK,
+	ucs2be_mbtowc, ucs2be_wctomb
+    }
 };
 
-#define all_charsets_count (sizeof(all_charsets)/sizeof(all_charsets[0]))
+#define charsets_table_size (sizeof(all_charsets)/sizeof(all_charsets[0]))
+#define all_charsets_count  (charsets_table_size - 1)
+#define ucs2_conv_index     (charsets_table_size - 1)
 
 static void
-init_all_charsets()
+init_all_charsets (void)
 {
     Utf8Conv convptr;
     int i;
 
-    for (convptr = all_charsets, i = all_charsets_count; i > 0; convptr++, i--)
+    for (convptr = all_charsets, i = charsets_table_size; i > 0; convptr++, i--)
 	convptr->xrm_name = XrmStringToQuark(convptr->name);
 }
 
@@ -337,17 +373,17 @@
 /* from XlcNCharSet to XlcNUtf8String */
 
 static int
-cstoutf8(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstoutf8(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XlcCharSet charset;
-    char *name;
+    const char *name;
     Utf8Conv convptr;
     int i;
     unsigned char const *src;
@@ -379,7 +415,7 @@
     unconv_num = 0;
 
     while (src < srcend) {
-	wchar_t wc;
+	ucs4_t wc;
 	int consumed;
 	int count;
 
@@ -417,11 +453,11 @@
 };
 
 static XlcConv
-open_cstoutf8(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstoutf8(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     lazy_init_all_charsets();
     return create_conv(from_lcd, &methods_cstoutf8);
@@ -430,9 +466,9 @@
 /* from XlcNUtf8String to XlcNCharSet */
 
 static XlcConv
-create_tocs_conv(lcd, methods)
-    XLCd lcd;
-    XlcConvMethods methods;
+create_tocs_conv(
+    XLCd lcd,
+    XlcConvMethods methods)
 {
     XlcConv conv;
     CodeSet *codeset_list;
@@ -441,10 +477,6 @@
     int i, j, k;
     Utf8Conv *preferred;
 
-    conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
-    if (conv == (XlcConv) NULL)
-	return (XlcConv) NULL;
-
     lazy_init_all_charsets();
 
     codeset_list = XLC_GENERIC(lcd, codeset_list);
@@ -455,11 +487,12 @@
 	charset_num += codeset_list[i]->num_charsets;
     if (charset_num > all_charsets_count-1)
 	charset_num = all_charsets_count-1;
-    preferred = (Utf8Conv *) Xmalloc((charset_num + 1) * sizeof(Utf8Conv));
-    if (preferred == (Utf8Conv *) NULL) {
-	Xfree((char *) conv);
+
+    conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)
+			     + (charset_num + 1) * sizeof(Utf8Conv));
+    if (conv == (XlcConv) NULL)
 	return (XlcConv) NULL;
-    }
+    preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
 
     /* Loop through all codesets mentioned in the locale. */
     charset_num = 0;
@@ -467,7 +500,7 @@
 	XlcCharSet *charsets = codeset_list[i]->charset_list;
 	int num_charsets = codeset_list[i]->num_charsets;
 	for (j = 0; j < num_charsets; j++) {
-	    char *name = charsets[j]->encoding_name;
+	    const char *name = charsets[j]->encoding_name;
 	    /* If it wasn't already encountered... */
 	    for (k = charset_num-1; k >= 0; k--)
 		if (!strcmp(preferred[k]->name, name))
@@ -492,9 +525,10 @@
 }
 
 static void
-close_tocs_converter(conv)
-    XlcConv conv;
+close_tocs_converter(
+    XlcConv conv)
 {
+    /* conv->state is allocated together with conv, free both at once.  */
     Xfree((char *) conv);
 }
 
@@ -505,14 +539,14 @@
  * *sidep is set to the character set side (XlcGL or XlcGR).
  */
 static int
-charset_wctocs(preferred, charsetp, sidep, conv, r, wc, n)
-    Utf8Conv *preferred;
-    Utf8Conv *charsetp;
-    XlcSide *sidep;
-    XlcConv conv;
-    unsigned char *r;
-    wchar_t wc;
-    int n;
+charset_wctocs(
+    Utf8Conv *preferred,
+    Utf8Conv *charsetp,
+    XlcSide *sidep,
+    XlcConv conv,
+    unsigned char *r,
+    ucs4_t wc,
+    int n)
 {
     int count;
     Utf8Conv convptr;
@@ -543,14 +577,14 @@
 }
 
 static int
-utf8tocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+utf8tocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     Utf8Conv *preferred_charsets;
     XlcCharSet last_charset = NULL;
@@ -573,7 +607,7 @@
     while (src < srcend && dst < dstend) {
 	Utf8Conv chosen_charset = NULL;
 	XlcSide chosen_side = XlcNONE;
-	wchar_t wc;
+	ucs4_t wc;
 	int consumed;
 	int count;
 
@@ -634,11 +668,11 @@
 };
 
 static XlcConv
-open_utf8tocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_utf8tocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_tocs_conv(from_lcd, &methods_utf8tocs);
 }
@@ -646,14 +680,14 @@
 /* from XlcNUtf8String to XlcNChar */
 
 static int
-utf8tocs1(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+utf8tocs1(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     Utf8Conv *preferred_charsets;
     XlcCharSet last_charset = NULL;
@@ -676,7 +710,7 @@
     while (src < srcend && dst < dstend) {
 	Utf8Conv chosen_charset = NULL;
 	XlcSide chosen_side = XlcNONE;
-	wchar_t wc;
+	ucs4_t wc;
 	int consumed;
 	int count;
 
@@ -738,11 +772,11 @@
 };
 
 static XlcConv
-open_utf8tocs1(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_utf8tocs1(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_tocs_conv(from_lcd, &methods_utf8tocs1);
 }
@@ -750,14 +784,14 @@
 /* from XlcNUtf8String to XlcNString */
 
 static int
-utf8tostr(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+utf8tostr(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     unsigned char const *src;
     unsigned char const *srcend;
@@ -776,7 +810,7 @@
 
     while (src < srcend) {
 	unsigned char c;
-	wchar_t wc;
+	ucs4_t wc;
 	int consumed;
 
 	consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
@@ -789,7 +823,7 @@
 	    c = BAD_CHAR;
 	    unconv_num++;
 	} else {
-	    if ((wc & ~(wchar_t)0xff) != 0) {
+	    if ((wc & ~(ucs4_t)0xff) != 0) {
 		c = BAD_CHAR;
 		unconv_num++;
 	    } else
@@ -814,11 +848,11 @@
 };
 
 static XlcConv
-open_utf8tostr(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_utf8tostr(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &methods_utf8tostr);
 }
@@ -826,14 +860,14 @@
 /* from XlcNString to XlcNUtf8String */
 
 static int
-strtoutf8(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+strtoutf8(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     unsigned char const *src;
     unsigned char const *srcend;
@@ -871,30 +905,231 @@
 };
 
 static XlcConv
-open_strtoutf8(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_strtoutf8(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &methods_strtoutf8);
 }
 
+/* Support for the input methods. */
+
+XPointer
+_Utf8GetConvByName(
+    const char *name)
+{
+    XrmQuark xrm_name;
+    Utf8Conv convptr;
+    int i;
+
+    if (name == NULL)
+        return (XPointer) NULL;
+
+    lazy_init_all_charsets();
+    xrm_name = XrmStringToQuark(name);
+
+    for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
+	if (convptr->xrm_name == xrm_name)
+	    return (XPointer) convptr->wctocs;
+    return (XPointer) NULL;
+}
+
+/* from XlcNUcsChar to XlcNChar, needed for input methods */
+
+static XlcConv
+create_ucstocs_conv(
+    XLCd lcd,
+    XlcConvMethods methods)
+{
+
+    if (XLC_PUBLIC_PART(lcd)->codeset
+	&& _XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8") == 0) {
+	XlcConv conv;
+	Utf8Conv *preferred;
+
+	lazy_init_all_charsets();
+
+	conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + 2 * sizeof(Utf8Conv));
+	if (conv == (XlcConv) NULL)
+	    return (XlcConv) NULL;
+	preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
+
+	preferred[0] = &all_charsets[0]; /* ISO10646 */
+	preferred[1] = (Utf8Conv) NULL;
+
+	conv->methods = methods;
+	conv->state = (XPointer) preferred;
+
+	return conv;
+    } else {
+	return create_tocs_conv(lcd, methods);
+    }
+}
+
+static int
+charset_wctocs_exactly(
+    Utf8Conv *preferred,
+    Utf8Conv *charsetp,
+    XlcSide *sidep,
+    XlcConv conv,
+    unsigned char *r,
+    ucs4_t wc,
+    int n)
+{
+    int count;
+    Utf8Conv convptr;
+
+    for (; *preferred != (Utf8Conv) NULL; preferred++) {
+	convptr = *preferred;
+	count = convptr->wctocs(conv, r, wc, n);
+	if (count == RET_TOOSMALL)
+	    return RET_TOOSMALL;
+	if (count != RET_ILSEQ) {
+	    *charsetp = convptr;
+	    *sidep = (*r < 0x80 ? XlcGL : XlcGR);
+	    return count;
+	}
+    }
+    return RET_ILSEQ;
+}
+
+static int
+ucstocs1(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
+{
+    ucs4_t const *src = (ucs4_t const *) *from;
+    unsigned char *dst = (unsigned char *) *to;
+    int unconv_num = 0;
+    Utf8Conv *preferred_charsets = (Utf8Conv *) conv->state;
+    Utf8Conv chosen_charset = NULL;
+    XlcSide chosen_side = XlcNONE;
+    XlcCharSet charset = NULL;
+    int count;
+
+    if (from == NULL || *from == NULL)
+	return 0;
+
+    count = charset_wctocs_exactly(preferred_charsets, &chosen_charset,
+                                   &chosen_side, conv, dst, *src, *to_left);
+    if (count < 1) {
+        unconv_num++;
+        count = 0;
+    } else {
+        charset = _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+    }
+    if (charset == NULL)
+	return -1;
+
+    *from = (XPointer) ++src;
+    (*from_left)--;
+    *to = (XPointer) dst;
+    *to_left -= count;
+
+    if (num_args >= 1)
+	*((XlcCharSet *)args[0]) = charset;
+
+    return unconv_num;
+}
+
+static XlcConvMethodsRec methods_ucstocs1 = {
+    close_tocs_converter,
+    ucstocs1,
+    NULL
+};
+
+static XlcConv
+open_ucstocs1(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
+{
+    return create_ucstocs_conv(from_lcd, &methods_ucstocs1);
+}
+
+/* from XlcNUcsChar to XlcNUtf8String, needed for input methods */
+
+static int
+ucstoutf8(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
+{
+    const ucs4_t *src;
+    const ucs4_t *srcend;
+    unsigned char *dst;
+    unsigned char *dstend;
+    int unconv_num;
+
+    if (from == NULL || *from == NULL)
+	return 0;
+
+    src = (const ucs4_t *) *from;
+    srcend = src + *from_left;
+    dst = (unsigned char *) *to;
+    dstend = dst + *to_left;
+    unconv_num = 0;
+
+    while (src < srcend) {
+	int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
+	if (count == RET_TOOSMALL)
+	    break;
+	if (count == RET_ILSEQ)
+	    unconv_num++;
+	src++;
+	dst += count;
+    }
+
+    *from = (XPointer) src;
+    *from_left = srcend - src;
+    *to = (XPointer) dst;
+    *to_left = dstend - dst;
+
+    return unconv_num;
+}
+
+static XlcConvMethodsRec methods_ucstoutf8 = {
+    close_converter,
+    ucstoutf8,
+    NULL
+};
+
+static XlcConv
+open_ucstoutf8(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
+{
+    return create_conv(from_lcd, &methods_ucstoutf8);
+}
+
 /* Registers UTF-8 converters for a non-UTF-8 locale. */
 void
-_XlcAddUtf8Converters(lcd)
-    XLCd lcd;
+_XlcAddUtf8Converters(
+    XLCd lcd)
 {
     _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String, open_cstoutf8);
     _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNCharSet, open_utf8tocs);
     _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNChar, open_utf8tocs1);
     _XlcSetConverter(lcd, XlcNString, lcd, XlcNUtf8String, open_strtoutf8);
     _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNString, open_utf8tostr);
+    _XlcSetConverter(lcd, XlcNUcsChar,    lcd, XlcNChar, open_ucstocs1);
+    _XlcSetConverter(lcd, XlcNUcsChar,    lcd, XlcNUtf8String, open_ucstoutf8);
 }
 
-#undef wchar_t
-#define wchar_t original_wchar_t
-
 /***************************************************************************/
 /* Part II: An UTF-8 locale loader.
  *
@@ -904,14 +1139,14 @@
 /* from XlcNMultiByte to XlcNWideChar */
 
 static int
-utf8towcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+utf8towcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     unsigned char const *src;
     unsigned char const *srcend;
@@ -929,7 +1164,7 @@
     unconv_num = 0;
 
     while (src < srcend && dst < dstend) {
-	local_wchar_t wc;
+	ucs4_t wc;
 	int consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
 	if (consumed == RET_TOOFEW(0))
 	    break;
@@ -959,11 +1194,11 @@
 };
 
 static XlcConv
-open_utf8towcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_utf8towcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &methods_utf8towcs);
 }
@@ -971,14 +1206,14 @@
 /* from XlcNWideChar to XlcNMultiByte */
 
 static int
-wcstoutf8(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstoutf8(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     wchar_t const *src;
     wchar_t const *srcend;
@@ -1024,11 +1259,11 @@
 };
 
 static XlcConv
-open_wcstoutf8(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstoutf8(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &methods_wcstoutf8);
 }
@@ -1036,14 +1271,14 @@
 /* from XlcNString to XlcNWideChar */
 
 static int
-our_strtowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+our_strtowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     unsigned char const *src;
     unsigned char const *srcend;
@@ -1076,11 +1311,11 @@
 };
 
 static XlcConv
-open_strtowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_strtowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &methods_strtowcs);
 }
@@ -1088,14 +1323,14 @@
 /* from XlcNWideChar to XlcNString */
 
 static int
-our_wcstostr(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+our_wcstostr(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     wchar_t const *src;
     wchar_t const *srcend;
@@ -1138,11 +1373,11 @@
 };
 
 static XlcConv
-open_wcstostr(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstostr(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &methods_wcstostr);
 }
@@ -1150,17 +1385,17 @@
 /* from XlcNCharSet to XlcNWideChar */
 
 static int
-cstowcs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+cstowcs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     XlcCharSet charset;
-    char *name;
+    const char *name;
     Utf8Conv convptr;
     int i;
     unsigned char const *src;
@@ -1220,11 +1455,11 @@
 };
 
 static XlcConv
-open_cstowcs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_cstowcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     lazy_init_all_charsets();
     return create_conv(from_lcd, &methods_cstowcs);
@@ -1233,14 +1468,14 @@
 /* from XlcNWideChar to XlcNCharSet */
 
 static int
-wcstocs(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstocs(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     Utf8Conv *preferred_charsets;
     XlcCharSet last_charset = NULL;
@@ -1314,11 +1549,11 @@
 };
 
 static XlcConv
-open_wcstocs(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_tocs_conv(from_lcd, &methods_wcstocs);
 }
@@ -1326,14 +1561,14 @@
 /* from XlcNWideChar to XlcNChar */
 
 static int
-wcstocs1(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+wcstocs1(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     Utf8Conv *preferred_charsets;
     XlcCharSet last_charset = NULL;
@@ -1408,11 +1643,11 @@
 };
 
 static XlcConv
-open_wcstocs1(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_wcstocs1(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_tocs_conv(from_lcd, &methods_wcstocs1);
 }
@@ -1420,14 +1655,14 @@
 /* trivial, no conversion */
 
 static int
-identity(conv, from, from_left, to, to_left, args, num_args)
-    XlcConv conv;
-    XPointer *from;
-    int *from_left;
-    XPointer *to;
-    int *to_left;
-    XPointer *args;
-    int num_args;
+identity(
+    XlcConv conv,
+    XPointer *from,
+    int *from_left,
+    XPointer *to,
+    int *to_left,
+    XPointer *args,
+    int num_args)
 {
     unsigned char const *src;
     unsigned char const *srcend;
@@ -1460,18 +1695,112 @@
 };
 
 static XlcConv
-open_identity(from_lcd, from_type, to_lcd, to_type)
-    XLCd from_lcd;
-    char *from_type;
-    XLCd to_lcd;
-    char *to_type;
+open_identity(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
 {
     return create_conv(from_lcd, &methods_identity);
 }
 
+/* from MultiByte/WideChar to FontCharSet. */
+/* They really use converters to CharSet
+ * but with different create_conv procedure. */
+
+static XlcConv
+create_tofontcs_conv(
+    XLCd lcd,
+    XlcConvMethods methods)
+{
+    XlcConv conv;
+    int i, num, k, count;
+    char **value, buf[20];
+    Utf8Conv *preferred;
+
+    lazy_init_all_charsets();
+
+    for (i = 0, num = 0;; i++) {
+	sprintf(buf, "fs%d.charset.name", i);
+	_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+	if (count < 1) {
+	    sprintf(buf, "fs%d.charset", i);
+	    _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+	    if (count < 1)
+		break;
+	}
+	num += count;
+    }
+
+    conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + (num + 1) * sizeof(Utf8Conv));
+    if (conv == (XlcConv) NULL)
+	return (XlcConv) NULL;
+    preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
+
+    /* Loop through all fontsets mentioned in the locale. */
+    for (i = 0, num = 0;; i++) {
+        sprintf(buf, "fs%d.charset.name", i);
+        _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+        if (count < 1) {
+            sprintf(buf, "fs%d.charset", i);
+            _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+            if (count < 1)
+                break;
+        }
+	while (count-- > 0) {
+	    XlcCharSet charset = _XlcGetCharSet(*value++);
+	    const char *name = charset->encoding_name;
+	    /* If it wasn't already encountered... */
+	    for (k = num - 1; k >= 0; k--)
+		if (!strcmp(preferred[k]->name, name))
+		    break;
+	    if (k < 0) {
+                /* For fonts "ISO10646-1" means not utf8 but ucs2.*/
+                if (!strcmp("ISO10646-1", name)) {
+                    preferred[num++] = &all_charsets[ucs2_conv_index];
+                    continue;
+                }
+		/* Look it up in all_charsets[]. */
+		for (k = 0; k < all_charsets_count-1; k++)
+		    if (!strcmp(all_charsets[k].name, name)) {
+			/* Add it to the preferred set. */
+			preferred[num++] = &all_charsets[k];
+			break;
+		    }
+	    }
+        }
+    }
+    preferred[num] = (Utf8Conv) NULL;
+
+    conv->methods = methods;
+    conv->state = (XPointer) preferred;
+
+    return conv;
+}
+
+static XlcConv
+open_wcstofcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
+{
+    return create_tofontcs_conv(from_lcd, &methods_wcstocs);
+}
+
+static XlcConv
+open_utf8tofcs(
+    XLCd from_lcd,
+    const char *from_type,
+    XLCd to_lcd,
+    const char *to_type)
+{
+    return create_tofontcs_conv(from_lcd, &methods_utf8tocs);
+}
+
 XLCd
-_XlcUtf8Loader(name)
-    _Xconst char *name;
+_XlcUtf8Loader(
+    const char *name)
 {
     XLCd lcd;
 
@@ -1510,6 +1839,10 @@
     _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_utf8tostr);
     _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNMultiByte, open_identity);
     _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNUtf8String, open_identity);
+
+    /* Register converters for XlcNFontCharSet */
+    _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNFontCharSet, open_utf8tofcs);
+    _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNFontCharSet, open_wcstofcs);
 
     _XlcAddUtf8Converters(lcd);
 
Index: xc/lib/X11/lcUtil.c
diff -u xc/lib/X11/lcUtil.c:1.1.1.1 xc/lib/X11/lcUtil.c:1.3
--- xc/lib/X11/lcUtil.c:1.1.1.1	Wed Apr 27 03:11:43 1994
+++ xc/lib/X11/lcUtil.c	Wed Nov 29 12:40:24 2000
@@ -22,57 +22,64 @@
  *
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
+ * Bug fixes: Bruno Haible	XFree86 Inc.
  */
+/* $XFree86: xc/lib/X11/lcUtil.c,v 1.3 2000/11/29 17:40:24 dawes Exp $ */
 
-#include <stdio.h>
-#include <ctype.h>
-#include <X11/Xos.h>
-#include "Xlibint.h"
-
-#ifdef X_NOT_STDC_ENV
-#ifndef toupper
-#define toupper(c)      ((int)(c) - 'a' + 'A')
-#endif
-#endif
+#include <X11/Xlib.h>
+#include "XlcPublic.h"
 
+/* Don't use <ctype.h> here because it is locale dependent. */
+
+#define set_toupper(ch) \
+  if (ch >= 'a' && ch <= 'z') \
+    ch = ch - 'a' + 'A';
+
+/* Compares two ISO 8859-1 strings, ignoring case of ASCII letters.
+   Like strcasecmp in an ASCII locale. */
 int 
-_XlcCompareISOLatin1(str1, str2)
-    char *str1, *str2;
+_XlcCompareISOLatin1(
+    const char *str1,
+    const char *str2)
 {
-    register char ch1, ch2;
-
-    for ( ; (ch1 = *str1) && (ch2 = *str2); str1++, str2++) {
-        if (islower(ch1))
-            ch1 = toupper(ch1);
-        if (islower(ch2))
-            ch2 = toupper(ch2);
+    unsigned char ch1, ch2;
 
-        if (ch1 != ch2)
-            break;
+    for ( ; ; str1++, str2++) {
+	ch1 = *str1;
+	ch2 = *str2;
+	if (ch1 == '\0' || ch2 == '\0')
+	    break;
+	set_toupper(ch1);
+	set_toupper(ch2);
+	if (ch1 != ch2)
+	    break;
     }
 
-    return *str1 - *str2;
+    return ch1 - ch2;
 }
 
+/* Compares two ISO 8859-1 strings, at most len bytes of each, ignoring
+   case of ASCII letters. Like strncasecmp in an ASCII locale. */
 int 
-_XlcNCompareISOLatin1(str1, str2, len)
-    char *str1, *str2;
-    int len;
+_XlcNCompareISOLatin1(
+    const char *str1,
+    const char *str2,
+    int len)
 {
-    register char ch1, ch2;
+    unsigned char ch1, ch2;
 
-    for ( ; (ch1 = *str1) && (ch2 = *str2) && len; str1++, str2++, len--) {
-        if (islower(ch1))
-            ch1 = toupper(ch1);
-        if (islower(ch2))
-            ch2 = toupper(ch2);
-
-        if (ch1 != ch2)
-            break;
+    for ( ; ; str1++, str2++, len--) {
+	if (len == 0)
+	    return 0;
+	ch1 = *str1;
+	ch2 = *str2;
+	if (ch1 == '\0' || ch2 == '\0')
+	    break;
+	set_toupper(ch1);
+	set_toupper(ch2);
+	if (ch1 != ch2)
+	    break;
     }
-
-    if (len == 0)
-        return 0;
 
-    return *str1 - *str2;
+    return ch1 - ch2;
 }
Index: xc/lib/X11/lcWrap.c
diff -u xc/lib/X11/lcWrap.c:3.7 xc/lib/X11/lcWrap.c:3.9
--- xc/lib/X11/lcWrap.c:3.7	Fri Feb 11 21:54:15 2000
+++ xc/lib/X11/lcWrap.c	Tue Nov 28 13:49:51 2000
@@ -49,8 +49,9 @@
  *
  *		 Katsuhisa Yano		TOSHIBA Corp.
  */				
-/* $XFree86: xc/lib/X11/lcWrap.c,v 3.7 2000/02/12 02:54:15 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcWrap.c,v 3.9 2000/11/28 18:49:51 dawes Exp $ */
 
+#include <stdlib.h>
 #include "Xlibint.h"
 #include "Xlcint.h"
 #include <X11/Xlocale.h>
@@ -60,30 +61,13 @@
 #endif
 #include <X11/Xutil.h>
 
-#ifdef __STDC__
-#define Const const
-#else
-#define Const /**/
-#endif
-
-#ifdef X_NOT_STDC_ENV
-extern char *getenv();
-#endif
-
 #ifdef XTHREADS
 LockInfoPtr _Xi18n_lock;
 #endif
 
-#if NeedFunctionPrototypes
 char *
 XSetLocaleModifiers(
-    _Xconst char   *modifiers
-)
-#else
-char *
-XSetLocaleModifiers(modifiers)
-    char        *modifiers;
-#endif
+    const char *modifiers)
 {
     XLCd lcd = _XlcCurrentLC();
     char *user_mods;
@@ -109,12 +93,12 @@
     return _XlcCurrentLC() != (XLCd)NULL;
 }
 
-Bool _XlcValidModSyntax(mods, valid_mods)
-    char *mods;
-    char **valid_mods;
+Bool _XlcValidModSyntax(
+    const char * mods,
+    const char * const *valid_mods)
 {
     int i;
-    char **ptr;
+    const char * const *ptr;
 
     while (mods && (*mods == '@')) {
 	mods++;
@@ -135,21 +119,21 @@
     return !mods || !*mods;
 }
 
-static Const char *im_valid[] = {"im", (char *)NULL};
+static const char *im_valid[] = {"im", (const char *)NULL};
 
 /*ARGSUSED*/
 char *
-_XlcDefaultMapModifiers (lcd, user_mods, prog_mods)
-    XLCd lcd;
-    char *user_mods;
-    char *prog_mods;
+_XlcDefaultMapModifiers(
+    XLCd lcd,
+    const char *user_mods,
+    const char *prog_mods)
 {
     int i;
     char *mods;
 
-    if (!_XlcValidModSyntax(prog_mods, (char **)im_valid))
+    if (!_XlcValidModSyntax(prog_mods, im_valid))
 	return (char *)NULL;
-    if (!_XlcValidModSyntax(user_mods, (char **)im_valid))
+    if (!_XlcValidModSyntax(user_mods, im_valid))
 	return (char *)NULL;
     i = strlen(prog_mods) + 1;
     if (user_mods)
@@ -192,8 +176,8 @@
 static XlcLoaderList loader_list = NULL;
 
 void
-_XlcRemoveLoader(proc)
-    XLCdLoadProc proc;
+_XlcRemoveLoader(
+    XLCdLoadProc proc)
 {
     XlcLoaderList loader, prev;
 
@@ -220,9 +204,9 @@
 }
 
 Bool
-_XlcAddLoader(proc, position)
-    XLCdLoadProc proc;
-    XlcPosition position;
+_XlcAddLoader(
+    XLCdLoadProc proc,
+    XlcPosition position)
 {
     XlcLoaderList loader, last;
 
@@ -253,8 +237,8 @@
 }
 
 XLCd
-_XOpenLC(name)
-    _Xconst char *name;
+_XOpenLC(
+    const char *name)
 {
     XLCd lcd;
     XlcLoaderList loader;
@@ -314,10 +298,12 @@
 		(*lcd->methods->close)(lcd);
 		lcd = (XLCd) NULL;
 	    }
-	    break;
+	    goto found;
 	}
     }
 
+    lcd = NULL;
+
 found:
     _XUnlockMutex(_Xi18n_lock);
 
@@ -329,8 +315,8 @@
 }
 
 void
-_XCloseLC(lcd)
-    XLCd lcd;
+_XCloseLC(
+    XLCd lcd)
 {
     XLCdList cur, *prev;
 
@@ -367,8 +353,8 @@
 }
 
 XrmMethods
-_XrmInitParseInfo(state)
-    XPointer *state;
+_XrmInitParseInfo(
+    XPointer *state)
 {
     XLCd lcd = _XOpenLC((char *) NULL);
     
@@ -379,11 +365,11 @@
 }
 
 int
-XmbTextPropertyToTextList(dpy, text_prop, list_ret, count_ret)
-    Display *dpy;
-    XTextProperty *text_prop;
-    char ***list_ret;
-    int *count_ret;
+XmbTextPropertyToTextList(
+    Display *dpy,
+    const XTextProperty *text_prop,
+    char ***list_ret,
+    int *count_ret)
 {
     XLCd lcd = _XlcCurrentLC();
     
@@ -395,11 +381,11 @@
 }
 
 int
-XwcTextPropertyToTextList(dpy, text_prop, list_ret, count_ret)
-    Display *dpy;
-    XTextProperty *text_prop;
-    wchar_t ***list_ret;
-    int *count_ret;
+XwcTextPropertyToTextList(
+    Display *dpy,
+    const XTextProperty *text_prop,
+    wchar_t ***list_ret,
+    int *count_ret)
 {
     XLCd lcd = _XlcCurrentLC();
     
@@ -411,29 +397,45 @@
 }
 
 int
-XmbTextListToTextProperty(dpy, list, count, style, text_prop)
-    Display *dpy;
-    char **list;
-    int count;
-    XICCEncodingStyle style;
-    XTextProperty *text_prop;
+Xutf8TextPropertyToTextList(
+    Display *dpy,
+    const XTextProperty *text_prop,
+    char ***list_ret,
+    int *count_ret)
 {
     XLCd lcd = _XlcCurrentLC();
     
     if (lcd == NULL)
 	return XLocaleNotSupported;
 
+    return (*lcd->methods->utf8_text_prop_to_list)(lcd, dpy, text_prop,
+						   list_ret, count_ret);
+}
+
+int
+XmbTextListToTextProperty(
+    Display *dpy,
+    char **list,
+    int count,
+    XICCEncodingStyle style,
+    XTextProperty *text_prop)
+{
+    XLCd lcd = _XlcCurrentLC();
+    
+    if (lcd == NULL)
+	return XLocaleNotSupported;
+
     return (*lcd->methods->mb_text_list_to_prop)(lcd, dpy, list, count, style,
 						 text_prop);
 }
 
 int
-XwcTextListToTextProperty(dpy, list, count, style, text_prop)
-    Display *dpy;
-    wchar_t **list;
-    int count;
-    XICCEncodingStyle style;
-    XTextProperty *text_prop;
+XwcTextListToTextProperty(
+    Display *dpy,
+    wchar_t **list,
+    int count,
+    XICCEncodingStyle style,
+    XTextProperty *text_prop)
 {
     XLCd lcd = _XlcCurrentLC();
     
@@ -444,9 +446,26 @@
 						 text_prop);
 }
 
+int
+Xutf8TextListToTextProperty(
+    Display *dpy,
+    char **list,
+    int count,
+    XICCEncodingStyle style,
+    XTextProperty *text_prop)
+{
+    XLCd lcd = _XlcCurrentLC();
+    
+    if (lcd == NULL)
+	return XLocaleNotSupported;
+
+    return (*lcd->methods->utf8_text_list_to_prop)(lcd, dpy, list, count,
+						   style, text_prop);
+}
+
 void
-XwcFreeStringList(list)
-    wchar_t **list;
+XwcFreeStringList(
+    wchar_t **list)
 {
     XLCd lcd = _XlcCurrentLC();
     
@@ -456,7 +475,7 @@
     (*lcd->methods->wc_free_string_list)(lcd, list);
 }
 
-char *
+const char *
 XDefaultString()
 {
     XLCd lcd = _XlcCurrentLC();
@@ -468,16 +487,16 @@
 }
 
 void
-_XlcCopyFromArg(src, dst, size)
-    char *src;
-    register char *dst;
-    register int size;
+_XlcCopyFromArg(
+    char *src,
+    char *dst,
+    int size)
 {
     if (size == sizeof(long))
 	*((long *) dst) = (long) src;
 #ifdef LONG64
     else if (size == sizeof(int))
-	*((int *) dst) = (int) src;
+	*((int *) dst) = (int)(long) src;
 #endif
     else if (size == sizeof(short))
 	*((short *) dst) = (short)(long) src;
@@ -492,13 +511,19 @@
 }
 
 void
-_XlcCopyToArg(src, dst, size)
-    register char *src;
-    register char **dst;
-    register int size;
+_XlcCopyToArg(
+    char *src,
+    char **dst,
+    int size)
 {
+    /* FIXME:
+       On Big Endian machines, this behaves differently than _XCopyToArg. */
     if (size == sizeof(long))
 	*((long *) *dst) = *((long *) src);
+#ifdef LONG64
+    else if (size == sizeof(int))
+	*((int *) *dst) = *((int *) src);
+#endif
     else if (size == sizeof(short))
 	*((short *) *dst) = *((short *) src);
     else if (size == sizeof(char))
@@ -510,11 +535,11 @@
 }
 
 void
-_XlcCountVaList(var, count_ret)
-    va_list var;
-    int *count_ret;
+_XlcCountVaList(
+    va_list var,
+    int *count_ret)
 {
-    register int count;
+    int count;
 
     for (count = 0; va_arg(var, char *); count++)
 	va_arg(var, XPointer);
@@ -523,12 +548,12 @@
 }
 
 void
-_XlcVaToArgList(var, count, args_ret)
-    va_list var;
-    register int count;
-    XlcArgList *args_ret;
+_XlcVaToArgList(
+    va_list var,
+    int count,
+    XlcArgList *args_ret)
 {
-    register XlcArgList args;
+    XlcArgList args;
 
     *args_ret = args = (XlcArgList) Xmalloc(sizeof(XlcArg) * count);
     if (args == (XlcArgList) NULL)
@@ -541,22 +566,22 @@
 }
 
 void
-_XlcCompileResourceList(resources, num_resources)
-    register XlcResourceList resources;
-    register int num_resources;
+_XlcCompileResourceList(
+    XlcResourceList resources,
+    int num_resources)
 {
     for ( ; num_resources-- > 0; resources++)
 	resources->xrm_name = XrmPermStringToQuark(resources->name);
 }
 
 char *
-_XlcGetValues(base, resources, num_resources, args, num_args, mask)
-    XPointer base;
-    XlcResourceList resources;
-    int num_resources;
-    XlcArgList args;
-    int num_args;
-    unsigned long mask;
+_XlcGetValues(
+    XPointer base,
+    XlcResourceList resources,
+    int num_resources,
+    XlcArgList args,
+    int num_args,
+    unsigned long mask)
 {
     XlcResourceList res;
     XrmQuark xrm_name;
@@ -582,13 +607,13 @@
 }
 
 char *
-_XlcSetValues(base, resources, num_resources, args, num_args, mask)
-    XPointer base;
-    XlcResourceList resources;
-    int num_resources;
-    XlcArgList args;
-    int num_args;
-    unsigned long mask;
+_XlcSetValues(
+    XPointer base,
+    XlcResourceList resources,
+    int num_resources,
+    XlcArgList args,
+    int num_args,
+    unsigned long mask)
 {
     XlcResourceList res;
     XrmQuark xrm_name;
Index: xc/lib/X11/mbWMProps.c
diff -u xc/lib/X11/mbWMProps.c:1.1.1.2 xc/lib/X11/mbWMProps.c:1.3
--- xc/lib/X11/mbWMProps.c:1.1.1.2	Sun Sep 27 03:58:17 1998
+++ xc/lib/X11/mbWMProps.c	Wed Nov 29 12:40:24 2000
@@ -22,6 +22,7 @@
 from The Open Group.
 
 */
+/* $XFree86: xc/lib/X11/mbWMProps.c,v 1.3 2000/11/29 17:40:24 dawes Exp $ */
 
 #include <X11/Xlibint.h>
 #include <X11/Xutil.h>
@@ -44,8 +45,8 @@
 			 wmHints, classHints)
      Display *dpy;
      Window w;			/* window to decorate */
-     char *windowName;		/* name of application */
-     char *iconName;		/* name string for icon */
+     _Xconst char *windowName;	/* name of application */
+     _Xconst char *iconName;	/* name string for icon */
      char **argv;		/* command line */
      int argc;			/* size of command line */
      XSizeHints *sizeHints;	/* size hints for window in its normal state */
@@ -56,15 +57,14 @@
     XTextProperty wname, iname;
     XTextProperty *wprop = NULL;
     XTextProperty *iprop = NULL;
-    char *locale;
 
     if (windowName &&
 	XmbTextListToTextProperty(dpy, (char**)&windowName, 1,
-				   XStdICCTextStyle, &wname) >= Success)
+				  XStdICCTextStyle, &wname) >= Success)
 	wprop = &wname;
     if (iconName &&
 	XmbTextListToTextProperty(dpy, (char**)&iconName, 1,
-				   XStdICCTextStyle, &iname) >= Success)
+				  XStdICCTextStyle, &iname) >= Success)
 	iprop = &iname;
     XSetWMProperties(dpy, w, wprop, iprop, argv, argc,
 		     sizeHints, wmHints, classHints);
@@ -72,9 +72,6 @@
 	Xfree((char *)wname.value);
     if (iprop)
 	Xfree((char *)iname.value);
-    locale = setlocale(LC_CTYPE, (char *)NULL);
-    if (locale)
-	XChangeProperty (dpy, w, XInternAtom(dpy, "WM_LOCALE_NAME", False),
-			 XA_STRING, 8, PropModeReplace,
-			 (unsigned char *)locale, strlen(locale));
+
+    /* Note: The WM_LOCALE_NAME property is set by XSetWMProperties. */
 }
Index: xc/lib/X11/mbWrap.c
diff -u xc/lib/X11/mbWrap.c:1.1.1.2 xc/lib/X11/mbWrap.c:1.3
--- xc/lib/X11/mbWrap.c:1.1.1.2	Sun Sep 27 03:58:20 1998
+++ xc/lib/X11/mbWrap.c	Wed Nov 29 12:40:25 2000
@@ -46,11 +46,23 @@
  * 
  *		 M. Collins		OSF  
  */				
+/* $XFree86: xc/lib/X11/mbWrap.c,v 1.3 2000/11/29 17:40:25 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "Xlcint.h"
 
+#if NeedFunctionPrototypes
 void
+XmbDrawText(
+    Display            *dpy,
+    Drawable            d,
+    GC                  gc,
+    int                 x,
+    int                 y,
+    XmbTextItem        *text_items,
+    int                 nitems)
+#else
+void
 XmbDrawText(dpy, d, gc, x, y, text_items, nitems)
     Display            *dpy;
     Drawable            d;
@@ -58,6 +70,7 @@
     int                 x, y;
     XmbTextItem        *text_items;
     int                 nitems;
+#endif
 {
     register XFontSet fs;
     register XmbTextItem *p = text_items;
@@ -101,7 +114,7 @@
     XFontSet            font_set;
     GC                  gc;
     int                 x, y;
-    char               *text;
+    _Xconst char       *text;
     int                 text_len;
 #endif
 {
@@ -129,7 +142,7 @@
     XFontSet            font_set;
     GC                  gc;
     int                 x, y;
-    char               *text;
+    _Xconst char       *text;
     int                 text_len;
 #endif
 {
@@ -147,7 +160,7 @@
 int 
 XmbTextEscapement(font_set, text, text_len)
     XFontSet        font_set;
-    char           *text;
+    _Xconst char   *text;
     int             text_len;
 #endif
 {
@@ -168,7 +181,7 @@
 XmbTextExtents(font_set, text, text_len,
 	       overall_ink_extents, overall_logical_extents)
     XFontSet        font_set;
-    char           *text;
+    _Xconst char   *text;
     int             text_len;
     XRectangle     *overall_ink_extents;
     XRectangle     *overall_logical_extents;
@@ -199,7 +212,7 @@
 		      buffer_size, num_chars,
 		      max_ink_extents, max_logical_extents)
     XFontSet        font_set;
-    char           *text;
+    _Xconst char   *text;
     int             text_len;
     XRectangle     *ink_extents_buffer;
     XRectangle     *logical_extents_buffer;
Index: xc/lib/X11/omDefault.c
diff -u xc/lib/X11/omDefault.c:1.2 xc/lib/X11/omDefault.c:1.4
--- xc/lib/X11/omDefault.c:1.2	Sun Jun 29 03:54:24 1997
+++ xc/lib/X11/omDefault.c	Wed Nov 29 12:40:25 2000
@@ -28,6 +28,7 @@
  *  This is source code modified by FUJITSU LIMITED under the Joint
  *  Development Agreement for the CDE/Motif PST.
  */
+/* $XFree86: xc/lib/X11/omDefault.c,v 1.4 2000/11/29 17:40:25 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XomGeneric.h"
@@ -43,37 +44,55 @@
 wcs_to_mbs(oc, to, from, length)
     XOC oc;
     char *to;
-    wchar_t *from;
+    _Xconst wchar_t *from;
     int length;
 {
-    XlcConv conv = XOC_GENERIC(oc)->wcs_to_cs;
-    XLCd lcd;
-    int ret, to_left = length;
-
-    if (conv == NULL) {
-	lcd = oc->core.om->core.lcd;
-	conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
-	if (conv == NULL)
-	    return False;
-	XOC_GENERIC(oc)->wcs_to_cs = conv;
-    } else
-	_XlcResetConverter(conv);
+    XlcConv conv;
+    int to_left, ret;
 
+    conv = _XomInitConverter(oc, XOMWideChar);
+    if (conv == NULL)
+	return False;
+
+    to_left = length;
     ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
 		      &to_left, NULL, 0);
     if (ret != 0 || length > 0)
 	return False;
-    
+
     return True;
 }
 
+static Bool
+utf8_to_mbs(oc, to, from, length)
+    XOC oc;
+    char *to;
+    _Xconst char *from;
+    int length;
+{
+    XlcConv conv;
+    int to_left, ret;
+
+    conv = _XomInitConverter(oc, XOMUtf8String);
+    if (conv == NULL)
+	return False;
+
+    to_left = length;
+    ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
+		      &to_left, NULL, 0);
+    if (ret != 0 || length > 0)
+	return False;
+
+    return True;
+}
+
 int
 #if NeedFunctionPrototypes
 _XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length)
 #else
 _XmbDefaultTextEscapement(oc, text, length)
     XOC oc;
-    char *text;
+    _Xconst char *text;
     int length;
 #endif
 {
@@ -86,7 +105,7 @@
 #else
 _XwcDefaultTextEscapement(oc, text, length)
     XOC oc;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
 #endif
 {
@@ -97,8 +116,10 @@
     if (buf == NULL)
 	return 0;
 
-    if (wcs_to_mbs(oc, buf, text, length) == False)
+    if (wcs_to_mbs(oc, buf, text, length) == False) {
+	ret = 0;
 	goto err;
+    }
 
     ret = _XmbDefaultTextEscapement(oc, buf, length);
 
@@ -110,12 +131,42 @@
 
 int
 #if NeedFunctionPrototypes
+_Xutf8DefaultTextEscapement(XOC oc, _Xconst char *text, int length)
+#else
+_Xutf8DefaultTextEscapement(oc, text, length)
+    XOC oc;
+    _Xconst char *text;
+    int length;
+#endif
+{
+    DefineLocalBuf;
+    char *buf = AllocLocalBuf(length);
+    int ret;
+
+    if (buf == NULL)
+	return 0;
+
+    if (utf8_to_mbs(oc, buf, text, length) == False) {
+	ret = 0;
+	goto err;
+    }
+
+    ret = _XmbDefaultTextEscapement(oc, buf, length);
+
+err:
+    FreeLocalBuf(buf);
+
+    return ret;
+}
+
+int
+#if NeedFunctionPrototypes
 _XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
 		       XRectangle *overall_ink, XRectangle *overall_logical)
 #else
 _XmbDefaultTextExtents(oc, text, length, overall_ink, overall_logical)
     XOC oc;
-    char *text;
+    _Xconst char *text;
     int length;
     XRectangle *overall_ink;
     XRectangle *overall_logical;
@@ -151,7 +202,7 @@
 #else
 _XwcDefaultTextExtents(oc, text, length, overall_ink, overall_logical)
     XOC oc;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
     XRectangle *overall_ink;
     XRectangle *overall_logical;
@@ -164,8 +215,10 @@
     if (buf == NULL)
 	return 0;
 
-    if (wcs_to_mbs(oc, buf, text, length) == False)
+    if (wcs_to_mbs(oc, buf, text, length) == False) {
+	ret = 0;
 	goto err;
+    }
 
     ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
 
@@ -175,6 +228,39 @@
     return ret;
 }
 
+int
+#if NeedFunctionPrototypes
+_Xutf8DefaultTextExtents(XOC oc, _Xconst char *text, int length,
+			 XRectangle *overall_ink, XRectangle *overall_logical)
+#else
+_Xutf8DefaultTextExtents(oc, text, length, overall_ink, overall_logical)
+    XOC oc;
+    _Xconst char *text;
+    int length;
+    XRectangle *overall_ink;
+    XRectangle *overall_logical;
+#endif
+{
+    DefineLocalBuf;
+    char *buf = AllocLocalBuf(length);
+    int ret;
+
+    if (buf == NULL)
+	return 0;
+
+    if (utf8_to_mbs(oc, buf, text, length) == False) {
+	ret = 0;
+	goto err;
+    }
+
+    ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
+
+err:
+    FreeLocalBuf(buf);
+
+    return ret;
+}
+
 Status
 #if NeedFunctionPrototypes
 _XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
@@ -186,7 +272,7 @@
 _XmbDefaultTextPerCharExtents(oc, text, length, ink_buf, logical_buf, buf_size,
 			      num_chars, overall_ink, overall_logical)
     XOC oc;
-    char *text;	
+    _Xconst char *text;	
     int length;
     XRectangle *ink_buf;
     XRectangle *logical_buf;
@@ -270,7 +356,7 @@
 _XwcDefaultTextPerCharExtents(oc, text, length, ink_buf, logical_buf, buf_size,
 			      num_chars, overall_ink, overall_logical)
     XOC oc;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
     XRectangle *ink_buf;
     XRectangle *logical_buf;
@@ -287,8 +373,10 @@
     if (buf == NULL)
 	return 0;
 
-    if (wcs_to_mbs(oc, buf, text, length) == False)
+    if (wcs_to_mbs(oc, buf, text, length) == False) {
+	ret = 0;
 	goto err;
+    }
 
     ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
 					buf_size, num_chars, overall_ink,
@@ -300,6 +388,50 @@
     return ret;
 }
 
+Status
+#if NeedFunctionPrototypes
+_Xutf8DefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+				XRectangle *ink_buf, XRectangle *logical_buf,
+				int buf_size, int *num_chars,
+				XRectangle *overall_ink,
+				XRectangle *overall_logical)
+#else
+_Xutf8DefaultTextPerCharExtents(oc, text, length, ink_buf, logical_buf,
+				buf_size, num_chars, overall_ink,
+				overall_logical)
+    XOC oc;
+    _Xconst char *text;
+    int length;
+    XRectangle *ink_buf;
+    XRectangle *logical_buf;
+    int buf_size;
+    int *num_chars;
+    XRectangle *overall_ink;
+    XRectangle *overall_logical;
+#endif
+{
+    DefineLocalBuf;
+    char *buf = AllocLocalBuf(length);
+    Status ret;
+
+    if (buf == NULL)
+	return 0;
+
+    if (utf8_to_mbs(oc, buf, text, length) == False) {
+	ret = 0;
+	goto err;
+    }
+
+    ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
+					buf_size, num_chars, overall_ink,
+					overall_logical);
+
+err:
+    FreeLocalBuf(buf);
+
+    return ret;
+}
+
 int
 #if NeedFunctionPrototypes
 _XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
@@ -311,7 +443,7 @@
     XOC oc;
     GC gc;
     int x, y;
-    char *text;
+    _Xconst char *text;
     int length;
 #endif
 {
@@ -334,7 +466,7 @@
     XOC oc;
     GC gc;
     int x, y;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
 #endif
 {
@@ -345,8 +477,45 @@
     if (buf == NULL)
 	return 0;
 
-    if (wcs_to_mbs(oc, buf, text, length) == False)
+    if (wcs_to_mbs(oc, buf, text, length) == False) {
+	ret = 0;
+	goto err;
+    }
+
+    ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+    FreeLocalBuf(buf);
+
+    return ret;
+}
+
+int
+#if NeedFunctionPrototypes
+_Xutf8DefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+			_Xconst char *text, int length)
+#else
+_Xutf8DefaultDrawString(dpy, d, oc, gc, x, y, text, length)
+    Display *dpy;
+    Drawable d;
+    XOC oc;
+    GC gc;
+    int x, y;
+    _Xconst char *text;
+    int length;
+#endif
+{
+    DefineLocalBuf;
+    char *buf = AllocLocalBuf(length);
+    int ret;
+
+    if (buf == NULL)
+	return 0;
+
+    if (utf8_to_mbs(oc, buf, text, length) == False) {
+	ret = 0;
 	goto err;
+    }
 
     ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
 
@@ -367,7 +536,7 @@
     XOC oc;
     GC gc;
     int x, y;
-    char *text;
+    _Xconst char *text;
     int length;
 #endif
 {
@@ -386,7 +555,7 @@
     XOC oc;
     GC gc;
     int x, y;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
 #endif
 {
@@ -397,6 +566,36 @@
 	return;
 
     if (wcs_to_mbs(oc, buf, text, length) == False)
+	goto err;
+
+    _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+    FreeLocalBuf(buf);
+}
+
+void
+#if NeedFunctionPrototypes
+_Xutf8DefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+			     int y, _Xconst char *text, int length)
+#else
+_Xutf8DefaultDrawImageString(dpy, d, oc, gc, x, y, text, length)
+    Display *dpy;
+    Drawable d;
+    XOC oc;
+    GC gc;
+    int x, y;
+    _Xconst char *text;
+    int length;
+#endif
+{
+    DefineLocalBuf;
+    char *buf = AllocLocalBuf(length);
+
+    if (buf == NULL)
+	return;
+
+    if (utf8_to_mbs(oc, buf, text, length) == False)
 	goto err;
 
     _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
Index: xc/lib/X11/omGeneric.c
diff -u xc/lib/X11/omGeneric.c:3.14 xc/lib/X11/omGeneric.c:3.17
--- xc/lib/X11/omGeneric.c:3.14	Mon Feb 28 22:09:04 2000
+++ xc/lib/X11/omGeneric.c	Tue Nov 28 13:49:52 2000
@@ -31,7 +31,7 @@
  * Modifier:  Takanori Tateno   FUJITSU LIMITED
  *
  */
-/* $XFree86: xc/lib/X11/omGeneric.c,v 3.14 2000/02/29 03:09:04 dawes Exp $ */
+/* $XFree86: xc/lib/X11/omGeneric.c,v 3.17 2000/11/28 18:49:52 dawes Exp $ */
 
 /*
  * Fixed the algorithms in parse_fontname() and parse_fontdata()
@@ -57,19 +57,29 @@
 #define	POINT_SIZE_FIELD	 8
 #define	CHARSET_ENCODING_FIELD	14
 
-extern int _XmbDefaultTextEscapement(), _XwcDefaultTextEscapement();
-extern int _XmbDefaultTextExtents(), _XwcDefaultTextExtents();
-extern Status _XmbDefaultTextPerCharExtents(), _XwcDefaultTextPerCharExtents();
-extern int _XmbDefaultDrawString(), _XwcDefaultDrawString();
-extern void _XmbDefaultDrawImageString(), _XwcDefaultDrawImageString();
-
-extern int _XmbGenericTextEscapement(), _XwcGenericTextEscapement();
-extern int _XmbGenericTextExtents(), _XwcGenericTextExtents();
-extern Status _XmbGenericTextPerCharExtents(), _XwcGenericTextPerCharExtents();
-extern int _XmbGenericDrawString(), _XwcGenericDrawString();
-extern void _XmbGenericDrawImageString(), _XwcGenericDrawImageString();
+extern int _XmbDefaultTextEscapement(), _XwcDefaultTextEscapement(),
+	   _Xutf8DefaultTextEscapement();
+extern int _XmbDefaultTextExtents(), _XwcDefaultTextExtents(),
+	   _Xutf8DefaultTextExtents();
+extern Status _XmbDefaultTextPerCharExtents(), _XwcDefaultTextPerCharExtents(),
+	      _Xutf8DefaultTextPerCharExtents();
+extern int _XmbDefaultDrawString(), _XwcDefaultDrawString(),
+	   _Xutf8DefaultDrawString();
+extern void _XmbDefaultDrawImageString(), _XwcDefaultDrawImageString(),
+	    _Xutf8DefaultDrawImageString();
+
+extern int _XmbGenericTextEscapement(), _XwcGenericTextEscapement(),
+	   _Xutf8GenericTextEscapement();
+extern int _XmbGenericTextExtents(), _XwcGenericTextExtents(),
+	   _Xutf8GenericTextExtents();
+extern Status _XmbGenericTextPerCharExtents(), _XwcGenericTextPerCharExtents(),
+	      _Xutf8GenericTextPerCharExtents();
+extern int _XmbGenericDrawString(), _XwcGenericDrawString(),
+	   _Xutf8GenericDrawString();
+extern void _XmbGenericDrawImageString(), _XwcGenericDrawImageString(),
+	    _Xutf8GenericDrawImageString();
 
-extern void _XlcDbg_printValue();
+extern void _XlcDbg_printValue (const char *str, char **value, int num);
 
 /* For VW/UDC start */
 
@@ -543,8 +553,8 @@
 
 /* For VW/UDC start*/
 
-static char
-*get_rotate_fontname(font_name)
+static char *
+get_rotate_fontname(font_name)
     char *font_name;
 {
     char *pattern = NULL, *ptr = NULL;
@@ -1031,6 +1041,16 @@
 
 	    found_num++;
 	    is_found = True;
+	    /* We almost certainly should have 'break' here and should ignore
+	     * the rest of the patterns. The problem is that we'll overwrite
+	     * font_data->font and font_data->xlfd_name with later matches.
+	     * But the general expectation would be that font_data->xlfd_name
+	     * would correspond to to the returned value. (It's not clear
+	     * why this routine modifies font_data and has a
+	     * font_data_return...)
+	     *
+	     * Owen Taylor <otaylor@redhat.com>     12 Jul 2000
+	     */
 	}
 
 	switch(class) {
@@ -1128,7 +1148,8 @@
 						(sizeof(VRotateRec) * sub_num);
 		if(font_set->vrotate == (VRotate)NULL)
 		    return (-1);
-
+		memset(font_set->vrotate, 0x00, sizeof(VRotateRec) * sub_num);
+		
 		for(i = 0 ; i < sub_num ; i++) {
 		    vrotate[i].charset_name = font_set->substitute[i].name;
 		    vrotate[i].side = font_set->substitute[i].side;
@@ -1495,6 +1516,9 @@
     if (gen->wcs_to_cs)
 	_XlcCloseConverter(gen->wcs_to_cs);
 
+    if (gen->utf8_to_cs)
+	_XlcCloseConverter(gen->utf8_to_cs);
+
 /* For VW/UDC start */ /* Change 1996.01.8 */
     destroy_fontdata(gen,dpy); 
 /*
@@ -1586,7 +1610,12 @@
     _XwcDefaultTextExtents,
     _XwcDefaultTextPerCharExtents,
     _XwcDefaultDrawString,
-    _XwcDefaultDrawImageString
+    _XwcDefaultDrawImageString,
+    _Xutf8DefaultTextEscapement,
+    _Xutf8DefaultTextExtents,
+    _Xutf8DefaultTextPerCharExtents,
+    _Xutf8DefaultDrawString,
+    _Xutf8DefaultDrawImageString
 };
 
 static XOCMethodsRec oc_generic_methods = {
@@ -1602,7 +1631,12 @@
     _XwcGenericTextExtents,
     _XwcGenericTextPerCharExtents,
     _XwcGenericDrawString,
-    _XwcGenericDrawImageString
+    _XwcGenericDrawImageString,
+    _Xutf8GenericTextEscapement,
+    _Xutf8GenericTextExtents,
+    _Xutf8GenericTextPerCharExtents,
+    _Xutf8GenericDrawString,
+    _Xutf8GenericDrawImageString
 };
 
 typedef struct _XOCMethodsListRec {
@@ -1899,9 +1933,9 @@
 extern FontScope _XlcParse_scopemaps();
 
 FontData
-read_EncodingInfo(count,value)
-int count;
-char **value;
+read_EncodingInfo(count, value)
+    int count;
+    char **value;
 {
     FontData font_data,ret;
     char *buf, *bufptr,*scp;
@@ -1941,11 +1975,11 @@
     return(ret);
 }
 
-static CodeRange read_vrotate(count,value,type,vrotate_num)
-int count;
-char **value;
-int *type;
-int *vrotate_num;
+static CodeRange read_vrotate(count, value, type, vrotate_num)
+    int count;
+    char **value;
+    int *type;
+    int *vrotate_num;
 {
     CodeRange   range;
     if(!strcmp(value[0],"all")){
@@ -1963,10 +1997,10 @@
     }
 }
 
-static void read_vw(lcd,font_set,num)
-XLCd    lcd;
-OMData  font_set;
-int num;
+static void read_vw(lcd, font_set,num)
+    XLCd    lcd;
+    OMData  font_set;
+    int num;
 {
     char **value, buf[BUFSIZ];
     int count;
Index: xc/lib/X11/omImText.c
diff -u xc/lib/X11/omImText.c:1.1.1.1 xc/lib/X11/omImText.c:1.3
--- xc/lib/X11/omImText.c:1.1.1.1	Wed Apr 27 03:11:43 1994
+++ xc/lib/X11/omImText.c	Wed Nov 29 12:40:26 2000
@@ -23,6 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
+/* $XFree86: xc/lib/X11/omImText.c,v 1.3 2000/11/29 17:40:26 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XomGeneric.h"
@@ -72,7 +73,7 @@
     XOC oc;
     GC gc;
     int x, y;
-    char *text;
+    _Xconst char *text;
     int length;
 #endif
 {
@@ -91,10 +92,29 @@
     XOC oc;
     GC gc;
     int x, y;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
 #endif
 {
     _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMWideChar,
+			       (XPointer) text, length);
+}
+
+void
+#if NeedFunctionPrototypes
+_Xutf8GenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+			     int y, _Xconst char *text, int length)
+#else
+_Xutf8GenericDrawImageString(dpy, d, oc, gc, x, y, text, length)
+    Display *dpy;
+    Drawable d;
+    XOC oc;
+    GC gc;
+    int x, y;
+    _Xconst char *text;
+    int length;
+#endif
+{
+    _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMUtf8String,
 			       (XPointer) text, length);
 }
Index: xc/lib/X11/omText.c
diff -u xc/lib/X11/omText.c:1.2 xc/lib/X11/omText.c:1.3
--- xc/lib/X11/omText.c:1.2	Sun May  9 06:50:42 1999
+++ xc/lib/X11/omText.c	Tue Nov 28 13:49:53 2000
@@ -23,7 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/omText.c,v 1.2 1999/05/09 10:50:42 dawes Exp $ */
+/* $XFree86: xc/lib/X11/omText.c,v 1.3 2000/11/28 18:49:53 dawes Exp $ */
 /*
  * Copyright 1995 by FUJITSU LIMITED
  * This is source code modified by FUJITSU LIMITED under the Joint
@@ -357,7 +357,7 @@
     XOC oc;
     GC gc;
     int x, y;
-    char *text;
+    _Xconst char *text;
     int length;
 #endif
 {
@@ -376,10 +376,29 @@
     XOC oc;
     GC gc;
     int x, y;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
 #endif
 {
     return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMWideChar,
+				 (XPointer) text, length);
+}
+
+int
+#if NeedFunctionPrototypes
+_Xutf8GenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+			_Xconst char *text, int length)
+#else
+_Xutf8GenericDrawString(dpy, d, oc, gc, x, y, text, length)
+    Display *dpy;
+    Drawable d;
+    XOC oc;
+    GC gc;
+    int x, y;
+    _Xconst char *text;
+    int length;
+#endif
+{
+    return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMUtf8String,
 				 (XPointer) text, length);
 }
Index: xc/lib/X11/omTextEsc.c
diff -u xc/lib/X11/omTextEsc.c:1.2 xc/lib/X11/omTextEsc.c:1.4
--- xc/lib/X11/omTextEsc.c:1.2	Sun May  9 06:50:42 1999
+++ xc/lib/X11/omTextEsc.c	Tue Nov 28 13:49:54 2000
@@ -23,7 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
-/* $XFree86: xc/lib/X11/omTextEsc.c,v 1.2 1999/05/09 10:50:42 dawes Exp $ */
+/* $XFree86: xc/lib/X11/omTextEsc.c,v 1.4 2000/11/28 18:49:54 dawes Exp $ */
 /*
  * Copyright 1995 by FUJITSU LIMITED
  * This is source code modified by FUJITSU LIMITED under the Joint
@@ -151,10 +151,29 @@
 					       is_xchar2b, FONTSCOPE);
 	if(ptr_len <= 0)
 	    break;
+
+	/*
+	 * First, see if the "Best Match" font for the FontSet was set.
+	 * If it was, use that font.  If it was not set, then use the
+	 * font defined by font_set->font_data[0] (which is what
+	 * _XomGetFontDataFromFontSet() always seems to return for
+	 * non-VW text).  Note that given the new algorithm in
+	 * parse_fontname() and parse_fontdata(), fs->font will
+	 * *always* contain good data.   We should probably remove
+	 * the check for "fd->font", but we won't :-) -- jjw/pma (HP)
+	 *
+	 * Above comment and way this is done propagated from omText.c
+	 * Note that fd->font is junk so using the result of the
+	 * above call /needs/ to be ignored.
+	 *
+	 * Owen Taylor <otaylor@redhat.com>     12 Jul 2000
+	 *
+	 */
+
 	if(fd == (FontData) NULL ||
-	   (font = fd->font) == (XFontStruct *) NULL) {
+	   (font = font_set->font) == (XFontStruct *) NULL) {
 
-	    if((font = font_set->font) == (XFontStruct *) NULL)
+	    if((font = fd->font) == (XFontStruct *) NULL)
 		break;
 	}
 
@@ -268,7 +287,7 @@
 #else
 _XmbGenericTextEscapement(oc, text, length)
     XOC oc;
-    char *text;
+    _Xconst char *text;
     int length;
 #endif
 {
@@ -281,9 +300,23 @@
 #else
 _XwcGenericTextEscapement(oc, text, length)
     XOC oc;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
 #endif
 {
     return _XomGenericTextEscapement(oc, XOMWideChar, (XPointer) text, length);
+}
+
+int
+#if NeedFunctionPrototypes
+_Xutf8GenericTextEscapement(XOC oc, _Xconst char *text, int length)
+#else
+_Xutf8GenericTextEscapement(oc, text, length)
+    XOC oc;
+    _Xconst char *text;
+    int length;
+#endif
+{
+    return _XomGenericTextEscapement(oc, XOMUtf8String, (XPointer) text,
+				     length);
 }
Index: xc/lib/X11/omTextExt.c
diff -u xc/lib/X11/omTextExt.c:1.1.1.1 xc/lib/X11/omTextExt.c:1.3
--- xc/lib/X11/omTextExt.c:1.1.1.1	Wed Apr 27 03:11:44 1994
+++ xc/lib/X11/omTextExt.c	Wed Nov 29 12:40:26 2000
@@ -23,6 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
+/* $XFree86: xc/lib/X11/omTextExt.c,v 1.3 2000/11/29 17:40:26 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XomGeneric.h"
@@ -116,7 +117,7 @@
 #else
 _XmbGenericTextExtents(oc, text, length, overall_ink, overall_logical)
     XOC oc;
-    char *text;
+    _Xconst char *text;
     int length;
     XRectangle *overall_ink;
     XRectangle *overall_logical;
@@ -133,12 +134,29 @@
 #else
 _XwcGenericTextExtents(oc, text, length, overall_ink, overall_logical)
     XOC oc;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
     XRectangle *overall_ink;
     XRectangle *overall_logical;
 #endif
 {
     return _XomGenericTextExtents(oc, XOMWideChar, (XPointer) text, length,
+				  overall_ink, overall_logical);
+}
+
+int
+#if NeedFunctionPrototypes
+_Xutf8GenericTextExtents(XOC oc, _Xconst char *text, int length,
+			 XRectangle *overall_ink, XRectangle *overall_logical)
+#else
+_Xutf8GenericTextExtents(oc, text, length, overall_ink, overall_logical)
+    XOC oc;
+    _Xconst char *text;
+    int length;
+    XRectangle *overall_ink;
+    XRectangle *overall_logical;
+#endif
+{
+    return _XomGenericTextExtents(oc, XOMUtf8String, (XPointer) text, length,
 				  overall_ink, overall_logical);
 }
Index: xc/lib/X11/omTextPer.c
diff -u xc/lib/X11/omTextPer.c:1.1.1.1 xc/lib/X11/omTextPer.c:1.3
--- xc/lib/X11/omTextPer.c:1.1.1.1	Wed Apr 27 03:11:45 1994
+++ xc/lib/X11/omTextPer.c	Wed Nov 29 12:40:26 2000
@@ -23,6 +23,7 @@
  * Author: Katsuhisa Yano	TOSHIBA Corp.
  *			   	mopi@osa.ilab.toshiba.co.jp
  */
+/* $XFree86: xc/lib/X11/omTextPer.c,v 1.3 2000/11/29 17:40:26 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XomGeneric.h"
@@ -172,7 +173,7 @@
 _XmbGenericTextPerCharExtents(oc, text, length, ink_buf, logical_buf,
 			      buf_size, num_chars, overall_ink, overall_logical)
     XOC oc;
-    char *text;	
+    _Xconst char *text;	
     int length;
     XRectangle *ink_buf;
     XRectangle *logical_buf;
@@ -199,7 +200,7 @@
 _XwcGenericTextPerCharExtents(oc, text, length, ink_buf, logical_buf,
 			      buf_size, num_chars, overall_ink, overall_logical)
     XOC oc;
-    wchar_t *text;
+    _Xconst wchar_t *text;
     int length;
     XRectangle *ink_buf;
     XRectangle *logical_buf;
@@ -210,6 +211,34 @@
 #endif
 {
     return _XomGenericTextPerCharExtents(oc, XOMWideChar, (XPointer) text,
+					 length, ink_buf, logical_buf, buf_size,
+					 num_chars, overall_ink,
+					 overall_logical);
+}
+
+Status
+#if NeedFunctionPrototypes
+_Xutf8GenericTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+				XRectangle *ink_buf, XRectangle *logical_buf,
+				int buf_size, int *num_chars,
+				XRectangle *overall_ink,
+				XRectangle *overall_logical)
+#else
+_Xutf8GenericTextPerCharExtents(oc, text, length, ink_buf, logical_buf,
+				buf_size, num_chars, overall_ink,
+				overall_logical)
+    XOC oc;
+    _Xconst char *text;	
+    int length;
+    XRectangle *ink_buf;
+    XRectangle *logical_buf;
+    int buf_size;
+    int *num_chars;
+    XRectangle *overall_ink;
+    XRectangle *overall_logical;
+#endif
+{
+    return _XomGenericTextPerCharExtents(oc, XOMUtf8String, (XPointer) text,
 					 length, ink_buf, logical_buf, buf_size,
 					 num_chars, overall_ink,
 					 overall_logical);
Index: xc/lib/X11/omXChar.c
diff -u xc/lib/X11/omXChar.c:1.1.1.3 xc/lib/X11/omXChar.c:1.4
--- xc/lib/X11/omXChar.c:1.1.1.3	Sun Sep 27 07:05:13 1998
+++ xc/lib/X11/omXChar.c	Wed Nov 29 12:40:26 2000
@@ -34,6 +34,7 @@
 /*
  * Modifiers: Jeff Walls, Paul Anderson (HEWLETT-PACKARD)
  */
+/* $XFree86: xc/lib/X11/omXChar.c,v 1.4 2000/11/29 17:40:26 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "XlcPublic.h"
@@ -113,13 +114,13 @@
 #define FONTSCOPE     2
 
 FontData
-_XomGetFontDataFromFontSet(fs,str,len,len_ret,is2b,type)
-FontSet fs;
-unsigned char *str;
-int len;
-int *len_ret;
-int is2b;     
-int type;          /* VMAP , VROTATE , else */
+_XomGetFontDataFromFontSet(fs, str,len, len_ret, is2b, type)
+    FontSet fs;
+    unsigned char *str;
+    int len;
+    int *len_ret;
+    int is2b;     
+    int type;          /* VMAP , VROTATE , else */
 {
     unsigned long value;
     int num,i,hit,csize;
@@ -435,18 +436,29 @@
     XOMTextType type;
 {
     XOCGenericPart *gen = XOC_GENERIC(oc);
-    XlcConv conv;
+    XlcConv *convp;
     char *conv_type;
+    XlcConv conv;
     XLCd lcd;
 
-    if (type == XOMWideChar) {
-	conv = gen->wcs_to_cs;
+    switch (type) {
+    case XOMWideChar:
+	convp = &gen->wcs_to_cs;
 	conv_type = XlcNWideChar;
-    } else {
-	conv = gen->mbs_to_cs;
+	break;
+    case XOMMultiByte:
+	convp = &gen->mbs_to_cs;
 	conv_type = XlcNMultiByte;
+	break;
+    case XOMUtf8String:
+	convp = &gen->utf8_to_cs;
+	conv_type = XlcNUtf8String;
+	break;
+    default:
+	return (XlcConv) NULL;
     }
 
+    conv = *convp;
     if (conv) {
 	_XlcResetConverter(conv);
 	return conv;
@@ -454,14 +466,13 @@
 
     lcd = oc->core.om->core.lcd;
 
-    conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNCharSet);
-    if (conv == (XlcConv) NULL)
-	return (XlcConv) NULL;
-
-    if (type == XOMWideChar)
-	gen->wcs_to_cs = conv;
-    else
-	gen->mbs_to_cs = conv;
+    conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNFontCharSet);
+    if (conv == (XlcConv) NULL) {
+        conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNCharSet);
+        if (conv == (XlcConv) NULL)
+	    return (XlcConv) NULL;
+    }
 
+    *convp = conv;
     return conv;
 }
Index: xc/lib/X11/udcInf.c
diff -u xc/lib/X11/udcInf.c:1.4 xc/lib/X11/udcInf.c:1.5
--- xc/lib/X11/udcInf.c:1.4	Sat Oct  3 04:41:45 1998
+++ xc/lib/X11/udcInf.c	Mon Dec  4 13:49:28 2000
@@ -29,7 +29,7 @@
  *
  */
 
-/* $XFree86: xc/lib/X11/udcInf.c,v 1.4 1998/10/03 08:41:45 dawes Exp $ */
+/* $XFree86: xc/lib/X11/udcInf.c,v 1.5 2000/12/04 18:49:28 dawes Exp $ */
 
 #include <stdio.h>
 #include <locale.h>
@@ -385,14 +385,15 @@
 char *src;
 int size;
 {
-    int name_len,seq_len,i;
+    int name_len,seq_len,rest_len,i;
     name_len = 2 + strlen(charset->encoding_name) + 1;
     seq_len = strlen(charset->ct_sequence);
-    if (name_len + seq_len + strlen(src) >= size)
+    rest_len = strlen(charset->encoding_name) + 1 + strlen(src);
+    if (name_len + seq_len + strlen(src) >= size || rest_len >= 0x4000)
 	return False;
     strcpy(from,charset->ct_sequence);
-    from[seq_len]    = name_len / 128 + 128;
-    from[seq_len+1]  = name_len % 128 + 128;
+    from[seq_len]    = (rest_len >> 7) + 128;
+    from[seq_len+1]  = (rest_len & 0x7f) + 128;
     strcpy(&from[seq_len + 2],charset->encoding_name);
     from[seq_len+name_len-1]  = 0x02;  /* STX */
     strcpy(&from[seq_len + name_len],src);
Index: xc/lib/X11/utf8WMProps.c
diff -u /dev/null xc/lib/X11/utf8WMProps.c:1.1
--- /dev/null	Mon Dec 18 14:24:01 2000
+++ xc/lib/X11/utf8WMProps.c	Tue Nov 28 13:49:58 2000
@@ -0,0 +1,99 @@
+/* $TOG: mbWMProps.c /main/6 1998/02/06 17:44:24 kaleb $ */
+/*
+
+Copyright 1991, 1998  The Open Group
+
+All Rights Reserved.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/*
+ * Copyright 2000 by Bruno Haible
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation, and that the name of Bruno Haible not
+ * be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  Bruno Haible
+ * makes no representations about the suitability of this software for
+ * any purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * Bruno Haible DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL Bruno Haible BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+ * OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/lib/X11/utf8WMProps.c,v 1.1 2000/11/28 18:49:58 dawes Exp $ */
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xlocale.h>
+
+#if NeedFunctionPrototypes
+void Xutf8SetWMProperties (
+    Display *dpy,
+    Window w,
+    _Xconst char *windowName,
+    _Xconst char *iconName,
+    char **argv,
+    int argc,
+    XSizeHints *sizeHints,
+    XWMHints *wmHints,
+    XClassHint *classHints)
+#else
+void Xutf8SetWMProperties (dpy, w, windowName, iconName, argv, argc, sizeHints,
+			   wmHints, classHints)
+     Display *dpy;
+     Window w;			/* window to decorate */
+     _Xconst char *windowName;	/* name of application */
+     _Xconst char *iconName;	/* name string for icon */
+     char **argv;		/* command line */
+     int argc;			/* size of command line */
+     XSizeHints *sizeHints;	/* size hints for window in its normal state */
+     XWMHints *wmHints;		/* miscelaneous window manager hints */
+     XClassHint *classHints;	/* resource name and class */
+#endif
+{
+    XTextProperty wname, iname;
+    XTextProperty *wprop = NULL;
+    XTextProperty *iprop = NULL;
+
+    if (windowName &&
+	Xutf8TextListToTextProperty(dpy, (char**)&windowName, 1,
+				    XStdICCTextStyle, &wname) >= Success)
+	wprop = &wname;
+    if (iconName &&
+	Xutf8TextListToTextProperty(dpy, (char**)&iconName, 1,
+				    XStdICCTextStyle, &iname) >= Success)
+	iprop = &iname;
+    XSetWMProperties(dpy, w, wprop, iprop, argv, argc,
+		     sizeHints, wmHints, classHints);
+    if (wprop)
+	Xfree((char *)wname.value);
+    if (iprop)
+	Xfree((char *)iname.value);
+
+    /* Note: The WM_LOCALE_NAME property is set by XSetWMProperties. */
+}
Index: xc/lib/X11/utf8Wrap.c
diff -u /dev/null xc/lib/X11/utf8Wrap.c:1.1
--- /dev/null	Mon Dec 18 14:24:01 2000
+++ xc/lib/X11/utf8Wrap.c	Tue Nov 28 13:49:58 2000
@@ -0,0 +1,251 @@
+/* $TOG: mbWrap.c /main/7 1998/02/06 17:44:30 kaleb $ */
+/*
+
+Copyright 1991, 1998  The Open Group
+
+All Rights Reserved.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/*
+ * Copyright 1991 by the Open Software Foundation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Open Software Foundation 
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  Open Software
+ * Foundation makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OPEN SOFTWARE FOUNDATION DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN BE
+ * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ *		 M. Collins		OSF  
+ */				
+/*
+ * Copyright 2000 by Bruno Haible
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation, and that the name of Bruno Haible not
+ * be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  Bruno Haible
+ * makes no representations about the suitability of this software for
+ * any purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * Bruno Haible DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL Bruno Haible BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+ * OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* $XFree86: xc/lib/X11/utf8Wrap.c,v 1.1 2000/11/28 18:49:58 dawes Exp $ */
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+#if NeedFunctionPrototypes
+void
+Xutf8DrawText(
+    Display            *dpy,
+    Drawable            d,
+    GC                  gc,
+    int                 x,
+    int                 y,
+    XmbTextItem        *text_items,
+    int                 nitems)
+#else
+void
+Xutf8DrawText(dpy, d, gc, x, y, text_items, nitems)
+    Display            *dpy;
+    Drawable            d;
+    GC                  gc;
+    int                 x, y;
+    XmbTextItem        *text_items;
+    int                 nitems;
+#endif
+{
+    register XFontSet fs;
+    register XmbTextItem *p = text_items;
+    register int i = nitems;
+    register int esc;
+
+    /* ignore leading items with no fontset */
+    while (i && !p->font_set) {
+	i--;
+	p++;
+    }
+
+    for (; --i >= 0; p++) {
+	if (p->font_set)
+	    fs = p->font_set;
+	x += p->delta;
+	esc = (*fs->methods->utf8_draw_string) (dpy, d, fs, gc, x, y,
+						p->chars, p->nchars);
+	if (!esc)
+	    esc = fs->methods->utf8_escapement (fs, p->chars, p->nchars);
+	x += esc;
+    }
+}
+
+#if NeedFunctionPrototypes
+void
+Xutf8DrawString(
+    Display            *dpy,
+    Drawable            d,
+    XFontSet            font_set,
+    GC                  gc,
+    int                 x,
+    int                 y,
+    _Xconst char       *text,
+    int                 text_len)
+#else
+void
+Xutf8DrawString(dpy, d, font_set, gc, x, y, text, text_len)
+    Display            *dpy;
+    Drawable            d;
+    XFontSet            font_set;
+    GC                  gc;
+    int                 x, y;
+    _Xconst char        *text;
+    int                 text_len;
+#endif
+{
+    (void)(*font_set->methods->utf8_draw_string) (dpy, d, font_set, gc, x, y,
+						  (char *)text, text_len);
+}
+
+
+#if NeedFunctionPrototypes
+void
+Xutf8DrawImageString(
+    Display            *dpy,
+    Drawable            d,
+    XFontSet            font_set,
+    GC                  gc,
+    int                 x,
+    int                 y,
+    _Xconst char       *text,
+    int                 text_len)
+#else
+void
+Xutf8DrawImageString(dpy, d, font_set, gc, x, y, text, text_len)
+    Display            *dpy;
+    Drawable            d;
+    XFontSet            font_set;
+    GC                  gc;
+    int                 x, y;
+    _Xconst char       *text;
+    int                 text_len;
+#endif
+{
+    (*font_set->methods->utf8_draw_image_string) (dpy, d, font_set, gc, x, y,
+						  (char *)text, text_len);
+}
+
+#if NeedFunctionPrototypes
+int 
+Xutf8TextEscapement(
+    XFontSet        font_set,
+    _Xconst char   *text,
+    int             text_len)
+#else
+int 
+Xutf8TextEscapement(font_set, text, text_len)
+    XFontSet        font_set;
+    _Xconst char   *text;
+    int             text_len;
+#endif
+{
+    return (*font_set->methods->utf8_escapement) (font_set,
+						  (char *)text, text_len);
+}
+
+#if NeedFunctionPrototypes
+int
+Xutf8TextExtents(
+    XFontSet        font_set,
+    _Xconst char   *text,
+    int             text_len,
+    XRectangle     *overall_ink_extents,
+    XRectangle     *overall_logical_extents)
+#else
+int
+Xutf8TextExtents(font_set, text, text_len,
+	       overall_ink_extents, overall_logical_extents)
+    XFontSet        font_set;
+    _Xconst char   *text;
+    int             text_len;
+    XRectangle     *overall_ink_extents;
+    XRectangle     *overall_logical_extents;
+#endif
+{
+    return (*font_set->methods->utf8_extents) (font_set,
+					       (char *)text, text_len,
+					       overall_ink_extents,
+					       overall_logical_extents);
+}
+
+#if NeedFunctionPrototypes
+Status
+Xutf8TextPerCharExtents(
+    XFontSet        font_set,
+    _Xconst char   *text,
+    int             text_len,
+    XRectangle     *ink_extents_buffer,
+    XRectangle     *logical_extents_buffer,
+    int             buffer_size,
+    int            *num_chars,
+    XRectangle     *max_ink_extents,
+    XRectangle     *max_logical_extents)
+#else
+Status
+Xutf8TextPerCharExtents(font_set, text, text_len,
+		      ink_extents_buffer, logical_extents_buffer,
+		      buffer_size, num_chars,
+		      max_ink_extents, max_logical_extents)
+    XFontSet        font_set;
+    _Xconst char   *text;
+    int             text_len;
+    XRectangle     *ink_extents_buffer;
+    XRectangle     *logical_extents_buffer;
+    int             buffer_size;
+    int            *num_chars;
+    XRectangle     *max_ink_extents;
+    XRectangle     *max_logical_extents;
+#endif
+{
+    return (*font_set->methods->utf8_extents_per_char)
+	     (font_set, (char *)text, text_len, 
+	      ink_extents_buffer, logical_extents_buffer,
+	      buffer_size, num_chars, max_ink_extents, max_logical_extents);
+}
Index: xc/lib/X11/wcWrap.c
diff -u xc/lib/X11/wcWrap.c:1.1.1.2 xc/lib/X11/wcWrap.c:1.3
--- xc/lib/X11/wcWrap.c:1.1.1.2	Sun Sep 27 03:58:26 1998
+++ xc/lib/X11/wcWrap.c	Wed Nov 29 12:40:27 2000
@@ -47,11 +47,23 @@
  * 
  *		 M. Collins		OSF  
  */				
+/* $XFree86: xc/lib/X11/wcWrap.c,v 1.3 2000/11/29 17:40:27 dawes Exp $ */
 
 #include "Xlibint.h"
 #include "Xlcint.h"
 
+#if NeedFunctionPrototypes
 void
+XwcDrawText(
+    Display            *dpy,
+    Drawable            d,
+    GC                  gc,
+    int                 x,
+    int                 y,
+    XwcTextItem        *text_items,
+    int                 nitems)
+#else
+void
 XwcDrawText(dpy, d, gc, x, y, text_items, nitems)
     Display            *dpy;
     Drawable            d;
@@ -59,6 +71,7 @@
     int                 x, y;
     XwcTextItem        *text_items;
     int                 nitems;
+#endif
 {
     register XFontSet fs;
     register XwcTextItem *p = text_items;
@@ -102,7 +115,7 @@
     XFontSet            font_set;
     GC                  gc;
     int                 x, y;
-    wchar_t            *text;
+    _Xconst wchar_t    *text;
     int                 text_len;
 #endif
 {
@@ -129,7 +142,7 @@
     XFontSet            font_set;
     GC                  gc;
     int                 x, y;
-    wchar_t            *text;
+    _Xconst wchar_t    *text;
     int                 text_len;
 #endif
 {
@@ -147,7 +160,7 @@
 int 
 XwcTextEscapement(font_set, text, text_len)
     XFontSet            font_set;
-    wchar_t            *text;
+    _Xconst wchar_t    *text;
     int                 text_len;
 #endif
 {
@@ -167,7 +180,7 @@
 XwcTextExtents(font_set, text, text_len,
 	       overall_ink_extents, overall_logical_extents)
     XFontSet            font_set;
-    wchar_t            *text;
+    _Xconst wchar_t    *text;
     int                 text_len;
     XRectangle         *overall_ink_extents;
     XRectangle         *overall_logical_extents;
@@ -197,7 +210,7 @@
 		      buffer_size, num_chars,
 		      max_ink_extents, max_logical_extents)
     XFontSet            font_set;
-    wchar_t            *text;
+    _Xconst wchar_t    *text;
     int                 text_len;
     XRectangle         *ink_extents_buffer;
     XRectangle         *logical_extents_buffer;
Index: xc/lib/X11/lcUniConv/8bit_tab_to_h.c
diff -u xc/lib/X11/lcUniConv/8bit_tab_to_h.c:1.1 xc/lib/X11/lcUniConv/8bit_tab_to_h.c:1.2
--- xc/lib/X11/lcUniConv/8bit_tab_to_h.c:1.1	Fri Feb 11 21:54:20 2000
+++ xc/lib/X11/lcUniConv/8bit_tab_to_h.c	Mon Dec  4 13:49:30 2000
@@ -1,3 +1,5 @@
+/* $XFree86: xc/lib/X11/lcUniConv/8bit_tab_to_h.c,v 1.2 2000/12/04 18:49:30 dawes Exp $ */
+
 /*
  * Generates an 8-bit character set table from a .TXT table as found on
  * ftp.unicode.org or from a table containing the 256 Unicode values as
@@ -197,7 +199,7 @@
         fprintf(f, "\n");
       }
       final_ret_reached = false;
-      fprintf(f, "static int\n%s_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)\n", c_charsetname);
+      fprintf(f, "static int\n%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", c_charsetname);
       fprintf(f, "{\n");
       fprintf(f, "  unsigned char c = *s;\n");
       if (some_invalid) {
@@ -221,7 +223,7 @@
           if (t == -2) {
             final_ret_reached = true;
           } else if (t == -1) {
-            fprintf(f, "%s*pwc = (wchar_t) c;\n", indent);
+            fprintf(f, "%s*pwc = (ucs4_t) c;\n", indent);
             fprintf(f, "%sreturn 1;\n", indent);
           } else {
             fprintf(f, "%s", indent);
@@ -232,7 +234,7 @@
             if (some_invalid)
               fprintf(f, "unsigned short wc = ");
             else
-              fprintf(f, "*pwc = (wchar_t) ");
+              fprintf(f, "*pwc = (ucs4_t) ");
             fprintf(f, "%s_2uni", c_charsetname);
             if (tableno > 1)
               fprintf(f, "_%d", t+1);
@@ -242,7 +244,7 @@
             fprintf(f, "];\n");
             if (some_invalid) {
               fprintf(f, "%sif (wc != 0xfffd) {\n", indent);
-              fprintf(f, "%s  *pwc = (wchar_t) wc;\n", indent);
+              fprintf(f, "%s  *pwc = (ucs4_t) wc;\n", indent);
               fprintf(f, "%s  return 1;\n", indent);
               fprintf(f, "%s}\n", indent);
               final_ret_reached = true;
@@ -274,9 +276,9 @@
             }
           }
           if (t == -1)
-            fprintf(f, "*pwc = (wchar_t) c;\n");
+            fprintf(f, "*pwc = (ucs4_t) c;\n");
           else {
-            fprintf(f, "*pwc = (wchar_t) %s_2uni", c_charsetname);
+            fprintf(f, "*pwc = (ucs4_t) %s_2uni", c_charsetname);
             if (tableno > 1)
               fprintf(f, "_%d", t+1);
             fprintf(f, "[c");
@@ -403,7 +405,7 @@
         j1 = j2;
       }
       fix_0000 = false;
-      fprintf(f, "static int\n%s_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)\n", c_charsetname);
+      fprintf(f, "static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", c_charsetname);
       fprintf(f, "{\n");
       if (need_c)
         fprintf(f, "  unsigned char c = 0;\n");
Index: xc/lib/X11/lcUniConv/armscii_8.h
diff -u xc/lib/X11/lcUniConv/armscii_8.h:1.1 xc/lib/X11/lcUniConv/armscii_8.h:1.3
--- xc/lib/X11/lcUniConv/armscii_8.h:1.1	Fri Feb 11 21:54:20 2000
+++ xc/lib/X11/lcUniConv/armscii_8.h	Wed Nov 29 12:40:28 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/armscii_8.h,v 1.3 2000/11/29 17:40:28 dawes Exp $ */
 
 /*
  * ARMSCII-8
@@ -25,13 +26,13 @@
 };
 
 static int
-armscii_8_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+armscii_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) armscii_8_2uni[c-0xa0];
+    *pwc = (ucs4_t) armscii_8_2uni[c-0xa0];
   return 1;
 }
 
@@ -66,7 +67,7 @@
 };
 
 static int
-armscii_8_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+armscii_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x0020) {
Index: xc/lib/X11/lcUniConv/ascii.h
diff -u xc/lib/X11/lcUniConv/ascii.h:1.1 xc/lib/X11/lcUniConv/ascii.h:1.3
--- xc/lib/X11/lcUniConv/ascii.h:1.1	Fri Feb 11 21:54:21 2000
+++ xc/lib/X11/lcUniConv/ascii.h	Wed Nov 29 12:40:28 2000
@@ -1,21 +1,22 @@
+/* $XFree86: xc/lib/X11/lcUniConv/ascii.h,v 1.3 2000/11/29 17:40:28 dawes Exp $ */
 
 /*
  * ASCII
  */
 
 static int
-ascii_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+ascii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
     return 1;
   }
   return RET_ILSEQ;
 }
 
 static int
-ascii_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+ascii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   if (wc < 0x0080) {
     *r = wc;
Index: xc/lib/X11/lcUniConv/big5.h
diff -u /dev/null xc/lib/X11/lcUniConv/big5.h:1.1
--- /dev/null	Mon Dec 18 14:24:01 2000
+++ xc/lib/X11/lcUniConv/big5.h	Tue Nov 28 13:50:03 2000
@@ -0,0 +1,4142 @@
+/* $XFree86: xc/lib/X11/lcUniConv/big5.h,v 1.1 2000/11/28 18:50:03 dawes Exp $ */
+
+/*
+ * BIG5
+ */
+
+static const unsigned short big5_2uni_pagea1[6121] = {
+  /* 0xa1 */
+  0x3000, 0xff0c, 0x3001, 0x3002, 0xff0e, 0x2022, 0xff1b, 0xff1a,
+  0xff1f, 0xff01, 0xfe30, 0x2026, 0x2025, 0xfe50, 0xff64, 0xfe52,
+  0x00b7, 0xfe54, 0xfe55, 0xfe56, 0xfe57, 0xff5c, 0x2013, 0xfe31,
+  0x2014, 0xfe33, 0xfffd, 0xfe34, 0xfe4f, 0xff08, 0xff09, 0xfe35,
+  0xfe36, 0xff5b, 0xff5d, 0xfe37, 0xfe38, 0x3014, 0x3015, 0xfe39,
+  0xfe3a, 0x3010, 0x3011, 0xfe3b, 0xfe3c, 0x300a, 0x300b, 0xfe3d,
+  0xfe3e, 0x3008, 0x3009, 0xfe3f, 0xfe40, 0x300c, 0x300d, 0xfe41,
+  0xfe42, 0x300e, 0x300f, 0xfe43, 0xfe44, 0xfe59, 0xfe5a, 0xfe5b,
+  0xfe5c, 0xfe5d, 0xfe5e, 0x2018, 0x2019, 0x201c, 0x201d, 0x301d,
+  0x301e, 0x2035, 0x2032, 0xff03, 0xff06, 0xff0a, 0x203b, 0x00a7,
+  0x3003, 0x25cb, 0x25cf, 0x25b3, 0x25b2, 0x25ce, 0x2606, 0x2605,
+  0x25c7, 0x25c6, 0x25a1, 0x25a0, 0x25bd, 0x25bc, 0x32a3, 0x2105,
+  0x203e, 0xfffd, 0xff3f, 0xfffd, 0xfe49, 0xfe4a, 0xfe4d, 0xfe4e,
+  0xfe4b, 0xfe4c, 0xfe5f, 0xfe60, 0xfe61, 0xff0b, 0xff0d, 0x00d7,
+  0x00f7, 0x00b1, 0x221a, 0xff1c, 0xff1e, 0xff1d, 0x2266, 0x2267,
+  0x2260, 0x221e, 0x2252, 0x2261, 0xfe62, 0xfe63, 0xfe64, 0xfe65,
+  0xfe66, 0x223c, 0x2229, 0x222a, 0x22a5, 0x2220, 0x221f, 0x22bf,
+  0x33d2, 0x33d1, 0x222b, 0x222e, 0x2235, 0x2234, 0x2640, 0x2642,
+  0x2641, 0x2609, 0x2191, 0x2193, 0x2190, 0x2192, 0x2196, 0x2197,
+  0x2199, 0x2198, 0x2225, 0x2223, 0xfffd,
+  /* 0xa2 */
+  0xfffd, 0xff0f, 0xff3c, 0xff04, 0x00a5, 0x3012, 0x00a2, 0x00a3,
+  0xff05, 0xff20, 0x2103, 0x2109, 0xfe69, 0xfe6a, 0xfe6b, 0x33d5,
+  0x339c, 0x339d, 0x339e, 0x33ce, 0x33a1, 0x338e, 0x338f, 0x33c4,
+  0x00b0, 0x5159, 0x515b, 0x515e, 0x515d, 0x5161, 0x5163, 0x55e7,
+  0x74e9, 0x7cce, 0x2581, 0x2582, 0x2583, 0x2584, 0x2585, 0x2586,
+  0x2587, 0x2588, 0x258f, 0x258e, 0x258d, 0x258c, 0x258b, 0x258a,
+  0x2589, 0x253c, 0x2534, 0x252c, 0x2524, 0x251c, 0x2594, 0x2500,
+  0x2502, 0x2595, 0x250c, 0x2510, 0x2514, 0x2518, 0x256d, 0x256e,
+  0x2570, 0x256f, 0x2550, 0x255e, 0x256a, 0x2561, 0x25e2, 0x25e3,
+  0x25e5, 0x25e4, 0x2571, 0x2572, 0x2573, 0xff10, 0xff11, 0xff12,
+  0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0x2160,
+  0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168,
+  0x2169, 0x3021, 0x3022, 0x3023, 0x3024, 0x3025, 0x3026, 0x3027,
+  0x3028, 0x3029, 0xfffd, 0x5344, 0xfffd, 0xff21, 0xff22, 0xff23,
+  0xff24, 0xff25, 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a, 0xff2b,
+  0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33,
+  0xff34, 0xff35, 0xff36, 0xff37, 0xff38, 0xff39, 0xff3a, 0xff41,
+  0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49,
+  0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51,
+  0xff52, 0xff53, 0xff54, 0xff55, 0xff56,
+  /* 0xa3 */
+  0xff57, 0xff58, 0xff59, 0xff5a, 0x0391, 0x0392, 0x0393, 0x0394,
+  0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c,
+  0x039d, 0x039e, 0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4, 0x03a5,
+  0x03a6, 0x03a7, 0x03a8, 0x03a9, 0x03b1, 0x03b2, 0x03b3, 0x03b4,
+  0x03b5, 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc,
+  0x03bd, 0x03be, 0x03bf, 0x03c0, 0x03c1, 0x03c3, 0x03c4, 0x03c5,
+  0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x3105, 0x3106, 0x3107, 0x3108,
+  0x3109, 0x310a, 0x310b, 0x310c, 0x310d, 0x310e, 0x310f, 0x3110,
+  0x3111, 0x3112, 0x3113, 0x3114, 0x3115, 0x3116, 0x3117, 0x3118,
+  0x3119, 0x311a, 0x311b, 0x311c, 0x311d, 0x311e, 0x311f, 0x3120,
+  0x3121, 0x3122, 0x3123, 0x3124, 0x3125, 0x3126, 0x3127, 0x3128,
+  0x3129, 0x02d9, 0x02c9, 0x02ca, 0x02c7, 0x02cb, 0xfffd, 0xfffd,
+  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  /* 0xa4 */
+  0x4e00, 0x4e59, 0x4e01, 0x4e03, 0x4e43, 0x4e5d, 0x4e86, 0x4e8c,
+  0x4eba, 0x513f, 0x5165, 0x516b, 0x51e0, 0x5200, 0x5201, 0x529b,
+  0x5315, 0x5341, 0x535c, 0x53c8, 0x4e09, 0x4e0b, 0x4e08, 0x4e0a,
+  0x4e2b, 0x4e38, 0x51e1, 0x4e45, 0x4e48, 0x4e5f, 0x4e5e, 0x4e8e,
+  0x4ea1, 0x5140, 0x5203, 0x52fa, 0x5343, 0x53c9, 0x53e3, 0x571f,
+  0x58eb, 0x5915, 0x5927, 0x5973, 0x5b50, 0x5b51, 0x5b53, 0x5bf8,
+  0x5c0f, 0x5c22, 0x5c38, 0x5c71, 0x5ddd, 0x5de5, 0x5df1, 0x5df2,
+  0x5df3, 0x5dfe, 0x5e72, 0x5efe, 0x5f0b, 0x5f13, 0x624d, 0x4e11,
+  0x4e10, 0x4e0d, 0x4e2d, 0x4e30, 0x4e39, 0x4e4b, 0x5c39, 0x4e88,
+  0x4e91, 0x4e95, 0x4e92, 0x4e94, 0x4ea2, 0x4ec1, 0x4ec0, 0x4ec3,
+  0x4ec6, 0x4ec7, 0x4ecd, 0x4eca, 0x4ecb, 0x4ec4, 0x5143, 0x5141,
+  0x5167, 0x516d, 0x516e, 0x516c, 0x5197, 0x51f6, 0x5206, 0x5207,
+  0x5208, 0x52fb, 0x52fe, 0x52ff, 0x5316, 0x5339, 0x5348, 0x5347,
+  0x5345, 0x535e, 0x5384, 0x53cb, 0x53ca, 0x53cd, 0x58ec, 0x5929,
+  0x592b, 0x592a, 0x592d, 0x5b54, 0x5c11, 0x5c24, 0x5c3a, 0x5c6f,
+  0x5df4, 0x5e7b, 0x5eff, 0x5f14, 0x5f15, 0x5fc3, 0x6208, 0x6236,
+  0x624b, 0x624e, 0x652f, 0x6587, 0x6597, 0x65a4, 0x65b9, 0x65e5,
+  0x66f0, 0x6708, 0x6728, 0x6b20, 0x6b62, 0x6b79, 0x6bcb, 0x6bd4,
+  0x6bdb, 0x6c0f, 0x6c34, 0x706b, 0x722a, 0x7236, 0x723b, 0x7247,
+  0x7259, 0x725b, 0x72ac, 0x738b, 0x4e19,
+  /* 0xa5 */
+  0x4e16, 0x4e15, 0x4e14, 0x4e18, 0x4e3b, 0x4e4d, 0x4e4f, 0x4e4e,
+  0x4ee5, 0x4ed8, 0x4ed4, 0x4ed5, 0x4ed6, 0x4ed7, 0x4ee3, 0x4ee4,
+  0x4ed9, 0x4ede, 0x5145, 0x5144, 0x5189, 0x518a, 0x51ac, 0x51f9,
+  0x51fa, 0x51f8, 0x520a, 0x52a0, 0x529f, 0x5305, 0x5306, 0x5317,
+  0x531d, 0x4edf, 0x534a, 0x5349, 0x5361, 0x5360, 0x536f, 0x536e,
+  0x53bb, 0x53ef, 0x53e4, 0x53f3, 0x53ec, 0x53ee, 0x53e9, 0x53e8,
+  0x53fc, 0x53f8, 0x53f5, 0x53eb, 0x53e6, 0x53ea, 0x53f2, 0x53f1,
+  0x53f0, 0x53e5, 0x53ed, 0x53fb, 0x56db, 0x56da, 0x5916, 0x592e,
+  0x5931, 0x5974, 0x5976, 0x5b55, 0x5b83, 0x5c3c, 0x5de8, 0x5de7,
+  0x5de6, 0x5e02, 0x5e03, 0x5e73, 0x5e7c, 0x5f01, 0x5f18, 0x5f17,
+  0x5fc5, 0x620a, 0x6253, 0x6254, 0x6252, 0x6251, 0x65a5, 0x65e6,
+  0x672e, 0x672c, 0x672a, 0x672b, 0x672d, 0x6b63, 0x6bcd, 0x6c11,
+  0x6c10, 0x6c38, 0x6c41, 0x6c40, 0x6c3e, 0x72af, 0x7384, 0x7389,
+  0x74dc, 0x74e6, 0x7518, 0x751f, 0x7528, 0x7529, 0x7530, 0x7531,
+  0x7532, 0x7533, 0x758b, 0x767d, 0x76ae, 0x76bf, 0x76ee, 0x77db,
+  0x77e2, 0x77f3, 0x793a, 0x79be, 0x7a74, 0x7acb, 0x4e1e, 0x4e1f,
+  0x4e52, 0x4e53, 0x4e69, 0x4e99, 0x4ea4, 0x4ea6, 0x4ea5, 0x4eff,
+  0x4f09, 0x4f19, 0x4f0a, 0x4f15, 0x4f0d, 0x4f10, 0x4f11, 0x4f0f,
+  0x4ef2, 0x4ef6, 0x4efb, 0x4ef0, 0x4ef3, 0x4efd, 0x4f01, 0x4f0b,
+  0x5149, 0x5147, 0x5146, 0x5148, 0x5168,
+  /* 0xa6 */
+  0x5171, 0x518d, 0x51b0, 0x5217, 0x5211, 0x5212, 0x520e, 0x5216,
+  0x52a3, 0x5308, 0x5321, 0x5320, 0x5370, 0x5371, 0x5409, 0x540f,
+  0x540c, 0x540a, 0x5410, 0x5401, 0x540b, 0x5404, 0x5411, 0x540d,
+  0x5408, 0x5403, 0x540e, 0x5406, 0x5412, 0x56e0, 0x56de, 0x56dd,
+  0x5733, 0x5730, 0x5728, 0x572d, 0x572c, 0x572f, 0x5729, 0x5919,
+  0x591a, 0x5937, 0x5938, 0x5984, 0x5978, 0x5983, 0x597d, 0x5979,
+  0x5982, 0x5981, 0x5b57, 0x5b58, 0x5b87, 0x5b88, 0x5b85, 0x5b89,
+  0x5bfa, 0x5c16, 0x5c79, 0x5dde, 0x5e06, 0x5e76, 0x5e74, 0x5f0f,
+  0x5f1b, 0x5fd9, 0x5fd6, 0x620e, 0x620c, 0x620d, 0x6210, 0x6263,
+  0x625b, 0x6258, 0x6536, 0x65e9, 0x65e8, 0x65ec, 0x65ed, 0x66f2,
+  0x66f3, 0x6709, 0x673d, 0x6734, 0x6731, 0x6735, 0x6b21, 0x6b64,
+  0x6b7b, 0x6c16, 0x6c5d, 0x6c57, 0x6c59, 0x6c5f, 0x6c60, 0x6c50,
+  0x6c55, 0x6c61, 0x6c5b, 0x6c4d, 0x6c4e, 0x7070, 0x725f, 0x725d,
+  0x767e, 0x7af9, 0x7c73, 0x7cf8, 0x7f36, 0x7f8a, 0x7fbd, 0x8001,
+  0x8003, 0x800c, 0x8012, 0x8033, 0x807f, 0x8089, 0x808b, 0x808c,
+  0x81e3, 0x81ea, 0x81f3, 0x81fc, 0x820c, 0x821b, 0x821f, 0x826e,
+  0x8272, 0x827e, 0x866b, 0x8840, 0x884c, 0x8863, 0x897f, 0x9621,
+  0x4e32, 0x4ea8, 0x4f4d, 0x4f4f, 0x4f47, 0x4f57, 0x4f5e, 0x4f34,
+  0x4f5b, 0x4f55, 0x4f30, 0x4f50, 0x4f51, 0x4f3d, 0x4f3a, 0x4f38,
+  0x4f43, 0x4f54, 0x4f3c, 0x4f46, 0x4f63,
+  /* 0xa7 */
+  0x4f5c, 0x4f60, 0x4f2f, 0x4f4e, 0x4f36, 0x4f59, 0x4f5d, 0x4f48,
+  0x4f5a, 0x514c, 0x514b, 0x514d, 0x5175, 0x51b6, 0x51b7, 0x5225,
+  0x5224, 0x5229, 0x522a, 0x5228, 0x52ab, 0x52a9, 0x52aa, 0x52ac,
+  0x5323, 0x5373, 0x5375, 0x541d, 0x542d, 0x541e, 0x543e, 0x5426,
+  0x544e, 0x5427, 0x5446, 0x5443, 0x5433, 0x5448, 0x5442, 0x541b,
+  0x5429, 0x544a, 0x5439, 0x543b, 0x5438, 0x542e, 0x5435, 0x5436,
+  0x5420, 0x543c, 0x5440, 0x5431, 0x542b, 0x541f, 0x542c, 0x56ea,
+  0x56f0, 0x56e4, 0x56eb, 0x574a, 0x5751, 0x5740, 0x574d, 0x5747,
+  0x574e, 0x573e, 0x5750, 0x574f, 0x573b, 0x58ef, 0x593e, 0x599d,
+  0x5992, 0x59a8, 0x599e, 0x59a3, 0x5999, 0x5996, 0x598d, 0x59a4,
+  0x5993, 0x598a, 0x59a5, 0x5b5d, 0x5b5c, 0x5b5a, 0x5b5b, 0x5b8c,
+  0x5b8b, 0x5b8f, 0x5c2c, 0x5c40, 0x5c41, 0x5c3f, 0x5c3e, 0x5c90,
+  0x5c91, 0x5c94, 0x5c8c, 0x5deb, 0x5e0c, 0x5e8f, 0x5e87, 0x5e8a,
+  0x5ef7, 0x5f04, 0x5f1f, 0x5f64, 0x5f62, 0x5f77, 0x5f79, 0x5fd8,
+  0x5fcc, 0x5fd7, 0x5fcd, 0x5ff1, 0x5feb, 0x5ff8, 0x5fea, 0x6212,
+  0x6211, 0x6284, 0x6297, 0x6296, 0x6280, 0x6276, 0x6289, 0x626d,
+  0x628a, 0x627c, 0x627e, 0x6279, 0x6273, 0x6292, 0x626f, 0x6298,
+  0x626e, 0x6295, 0x6293, 0x6291, 0x6286, 0x6539, 0x653b, 0x6538,
+  0x65f1, 0x66f4, 0x675f, 0x674e, 0x674f, 0x6750, 0x6751, 0x675c,
+  0x6756, 0x675e, 0x6749, 0x6746, 0x6760,
+  /* 0xa8 */
+  0x6753, 0x6757, 0x6b65, 0x6bcf, 0x6c42, 0x6c5e, 0x6c99, 0x6c81,
+  0x6c88, 0x6c89, 0x6c85, 0x6c9b, 0x6c6a, 0x6c7a, 0x6c90, 0x6c70,
+  0x6c8c, 0x6c68, 0x6c96, 0x6c92, 0x6c7d, 0x6c83, 0x6c72, 0x6c7e,
+  0x6c74, 0x6c86, 0x6c76, 0x6c8d, 0x6c94, 0x6c98, 0x6c82, 0x7076,
+  0x707c, 0x707d, 0x7078, 0x7262, 0x7261, 0x7260, 0x72c4, 0x72c2,
+  0x7396, 0x752c, 0x752b, 0x7537, 0x7538, 0x7682, 0x76ef, 0x77e3,
+  0x79c1, 0x79c0, 0x79bf, 0x7a76, 0x7cfb, 0x7f55, 0x8096, 0x8093,
+  0x809d, 0x8098, 0x809b, 0x809a, 0x80b2, 0x826f, 0x8292, 0x828b,
+  0x828d, 0x898b, 0x89d2, 0x8a00, 0x8c37, 0x8c46, 0x8c55, 0x8c9d,
+  0x8d64, 0x8d70, 0x8db3, 0x8eab, 0x8eca, 0x8f9b, 0x8fb0, 0x8fc2,
+  0x8fc6, 0x8fc5, 0x8fc4, 0x5de1, 0x9091, 0x90a2, 0x90aa, 0x90a6,
+  0x90a3, 0x9149, 0x91c6, 0x91cc, 0x9632, 0x962e, 0x9631, 0x962a,
+  0x962c, 0x4e26, 0x4e56, 0x4e73, 0x4e8b, 0x4e9b, 0x4e9e, 0x4eab,
+  0x4eac, 0x4f6f, 0x4f9d, 0x4f8d, 0x4f73, 0x4f7f, 0x4f6c, 0x4f9b,
+  0x4f8b, 0x4f86, 0x4f83, 0x4f70, 0x4f75, 0x4f88, 0x4f69, 0x4f7b,
+  0x4f96, 0x4f7e, 0x4f8f, 0x4f91, 0x4f7a, 0x5154, 0x5152, 0x5155,
+  0x5169, 0x5177, 0x5176, 0x5178, 0x51bd, 0x51fd, 0x523b, 0x5238,
+  0x5237, 0x523a, 0x5230, 0x522e, 0x5236, 0x5241, 0x52be, 0x52bb,
+  0x5352, 0x5354, 0x5353, 0x5351, 0x5366, 0x5377, 0x5378, 0x5379,
+  0x53d6, 0x53d4, 0x53d7, 0x5473, 0x5475,
+  /* 0xa9 */
+  0x5496, 0x5478, 0x5495, 0x5480, 0x547b, 0x5477, 0x5484, 0x5492,
+  0x5486, 0x547c, 0x5490, 0x5471, 0x5476, 0x548c, 0x549a, 0x5462,
+  0x5468, 0x548b, 0x547d, 0x548e, 0x56fa, 0x5783, 0x5777, 0x576a,
+  0x5769, 0x5761, 0x5766, 0x5764, 0x577c, 0x591c, 0x5949, 0x5947,
+  0x5948, 0x5944, 0x5954, 0x59be, 0x59bb, 0x59d4, 0x59b9, 0x59ae,
+  0x59d1, 0x59c6, 0x59d0, 0x59cd, 0x59cb, 0x59d3, 0x59ca, 0x59af,
+  0x59b3, 0x59d2, 0x59c5, 0x5b5f, 0x5b64, 0x5b63, 0x5b97, 0x5b9a,
+  0x5b98, 0x5b9c, 0x5b99, 0x5b9b, 0x5c1a, 0x5c48, 0x5c45, 0x5c46,
+  0x5cb7, 0x5ca1, 0x5cb8, 0x5ca9, 0x5cab, 0x5cb1, 0x5cb3, 0x5e18,
+  0x5e1a, 0x5e16, 0x5e15, 0x5e1b, 0x5e11, 0x5e78, 0x5e9a, 0x5e97,
+  0x5e9c, 0x5e95, 0x5e96, 0x5ef6, 0x5f26, 0x5f27, 0x5f29, 0x5f80,
+  0x5f81, 0x5f7f, 0x5f7c, 0x5fdd, 0x5fe0, 0x5ffd, 0x5ff5, 0x5fff,
+  0x600f, 0x6014, 0x602f, 0x6035, 0x6016, 0x602a, 0x6015, 0x6021,
+  0x6027, 0x6029, 0x602b, 0x601b, 0x6216, 0x6215, 0x623f, 0x623e,
+  0x6240, 0x627f, 0x62c9, 0x62cc, 0x62c4, 0x62bf, 0x62c2, 0x62b9,
+  0x62d2, 0x62db, 0x62ab, 0x62d3, 0x62d4, 0x62cb, 0x62c8, 0x62a8,
+  0x62bd, 0x62bc, 0x62d0, 0x62d9, 0x62c7, 0x62cd, 0x62b5, 0x62da,
+  0x62b1, 0x62d8, 0x62d6, 0x62d7, 0x62c6, 0x62ac, 0x62ce, 0x653e,
+  0x65a7, 0x65bc, 0x65fa, 0x6614, 0x6613, 0x660c, 0x6606, 0x6602,
+  0x660e, 0x6600, 0x660f, 0x6615, 0x660a,
+  /* 0xaa */
+  0x6607, 0x670d, 0x670b, 0x676d, 0x678b, 0x6795, 0x6771, 0x679c,
+  0x6773, 0x6777, 0x6787, 0x679d, 0x6797, 0x676f, 0x6770, 0x677f,
+  0x6789, 0x677e, 0x6790, 0x6775, 0x679a, 0x6793, 0x677c, 0x676a,
+  0x6772, 0x6b23, 0x6b66, 0x6b67, 0x6b7f, 0x6c13, 0x6c1b, 0x6ce3,
+  0x6ce8, 0x6cf3, 0x6cb1, 0x6ccc, 0x6ce5, 0x6cb3, 0x6cbd, 0x6cbe,
+  0x6cbc, 0x6ce2, 0x6cab, 0x6cd5, 0x6cd3, 0x6cb8, 0x6cc4, 0x6cb9,
+  0x6cc1, 0x6cae, 0x6cd7, 0x6cc5, 0x6cf1, 0x6cbf, 0x6cbb, 0x6ce1,
+  0x6cdb, 0x6cca, 0x6cac, 0x6cef, 0x6cdc, 0x6cd6, 0x6ce0, 0x7095,
+  0x708e, 0x7092, 0x708a, 0x7099, 0x722c, 0x722d, 0x7238, 0x7248,
+  0x7267, 0x7269, 0x72c0, 0x72ce, 0x72d9, 0x72d7, 0x72d0, 0x73a9,
+  0x73a8, 0x739f, 0x73ab, 0x73a5, 0x753d, 0x759d, 0x7599, 0x759a,
+  0x7684, 0x76c2, 0x76f2, 0x76f4, 0x77e5, 0x77fd, 0x793e, 0x7940,
+  0x7941, 0x79c9, 0x79c8, 0x7a7a, 0x7a79, 0x7afa, 0x7cfe, 0x7f54,
+  0x7f8c, 0x7f8b, 0x8005, 0x80ba, 0x80a5, 0x80a2, 0x80b1, 0x80a1,
+  0x80ab, 0x80a9, 0x80b4, 0x80aa, 0x80af, 0x81e5, 0x81fe, 0x820d,
+  0x82b3, 0x829d, 0x8299, 0x82ad, 0x82bd, 0x829f, 0x82b9, 0x82b1,
+  0x82ac, 0x82a5, 0x82af, 0x82b8, 0x82a3, 0x82b0, 0x82be, 0x82b7,
+  0x864e, 0x8671, 0x521d, 0x8868, 0x8ecb, 0x8fce, 0x8fd4, 0x8fd1,
+  0x90b5, 0x90b8, 0x90b1, 0x90b6, 0x91c7, 0x91d1, 0x9577, 0x9580,
+  0x961c, 0x9640, 0x963f, 0x963b, 0x9644,
+  /* 0xab */
+  0x9642, 0x96b9, 0x96e8, 0x9752, 0x975e, 0x4e9f, 0x4ead, 0x4eae,
+  0x4fe1, 0x4fb5, 0x4faf, 0x4fbf, 0x4fe0, 0x4fd1, 0x4fcf, 0x4fdd,
+  0x4fc3, 0x4fb6, 0x4fd8, 0x4fdf, 0x4fca, 0x4fd7, 0x4fae, 0x4fd0,
+  0x4fc4, 0x4fc2, 0x4fda, 0x4fce, 0x4fde, 0x4fb7, 0x5157, 0x5192,
+  0x5191, 0x51a0, 0x524e, 0x5243, 0x524a, 0x524d, 0x524c, 0x524b,
+  0x5247, 0x52c7, 0x52c9, 0x52c3, 0x52c1, 0x530d, 0x5357, 0x537b,
+  0x539a, 0x53db, 0x54ac, 0x54c0, 0x54a8, 0x54ce, 0x54c9, 0x54b8,
+  0x54a6, 0x54b3, 0x54c7, 0x54c2, 0x54bd, 0x54aa, 0x54c1, 0x54c4,
+  0x54c8, 0x54af, 0x54ab, 0x54b1, 0x54bb, 0x54a9, 0x54a7, 0x54bf,
+  0x56ff, 0x5782, 0x578b, 0x57a0, 0x57a3, 0x57a2, 0x57ce, 0x57ae,
+  0x5793, 0x5955, 0x5951, 0x594f, 0x594e, 0x5950, 0x59dc, 0x59d8,
+  0x59ff, 0x59e3, 0x59e8, 0x5a03, 0x59e5, 0x59ea, 0x59da, 0x59e6,
+  0x5a01, 0x59fb, 0x5b69, 0x5ba3, 0x5ba6, 0x5ba4, 0x5ba2, 0x5ba5,
+  0x5c01, 0x5c4e, 0x5c4f, 0x5c4d, 0x5c4b, 0x5cd9, 0x5cd2, 0x5df7,
+  0x5e1d, 0x5e25, 0x5e1f, 0x5e7d, 0x5ea0, 0x5ea6, 0x5efa, 0x5f08,
+  0x5f2d, 0x5f65, 0x5f88, 0x5f85, 0x5f8a, 0x5f8b, 0x5f87, 0x5f8c,
+  0x5f89, 0x6012, 0x601d, 0x6020, 0x6025, 0x600e, 0x6028, 0x604d,
+  0x6070, 0x6068, 0x6062, 0x6046, 0x6043, 0x606c, 0x606b, 0x606a,
+  0x6064, 0x6241, 0x62dc, 0x6316, 0x6309, 0x62fc, 0x62ed, 0x6301,
+  0x62ee, 0x62fd, 0x6307, 0x62f1, 0x62f7,
+  /* 0xac */
+  0x62ef, 0x62ec, 0x62fe, 0x62f4, 0x6311, 0x6302, 0x653f, 0x6545,
+  0x65ab, 0x65bd, 0x65e2, 0x6625, 0x662d, 0x6620, 0x6627, 0x662f,
+  0x661f, 0x6628, 0x6631, 0x6624, 0x66f7, 0x67ff, 0x67d3, 0x67f1,
+  0x67d4, 0x67d0, 0x67ec, 0x67b6, 0x67af, 0x67f5, 0x67e9, 0x67ef,
+  0x67c4, 0x67d1, 0x67b4, 0x67da, 0x67e5, 0x67b8, 0x67cf, 0x67de,
+  0x67f3, 0x67b0, 0x67d9, 0x67e2, 0x67dd, 0x67d2, 0x6b6a, 0x6b83,
+  0x6b86, 0x6bb5, 0x6bd2, 0x6bd7, 0x6c1f, 0x6cc9, 0x6d0b, 0x6d32,
+  0x6d2a, 0x6d41, 0x6d25, 0x6d0c, 0x6d31, 0x6d1e, 0x6d17, 0x6d3b,
+  0x6d3d, 0x6d3e, 0x6d36, 0x6d1b, 0x6cf5, 0x6d39, 0x6d27, 0x6d38,
+  0x6d29, 0x6d2e, 0x6d35, 0x6d0e, 0x6d2b, 0x70ab, 0x70ba, 0x70b3,
+  0x70ac, 0x70af, 0x70ad, 0x70b8, 0x70ae, 0x70a4, 0x7230, 0x7272,
+  0x726f, 0x7274, 0x72e9, 0x72e0, 0x72e1, 0x73b7, 0x73ca, 0x73bb,
+  0x73b2, 0x73cd, 0x73c0, 0x73b3, 0x751a, 0x752d, 0x754f, 0x754c,
+  0x754e, 0x754b, 0x75ab, 0x75a4, 0x75a5, 0x75a2, 0x75a3, 0x7678,
+  0x7686, 0x7687, 0x7688, 0x76c8, 0x76c6, 0x76c3, 0x76c5, 0x7701,
+  0x76f9, 0x76f8, 0x7709, 0x770b, 0x76fe, 0x76fc, 0x7707, 0x77dc,
+  0x7802, 0x7814, 0x780c, 0x780d, 0x7946, 0x7949, 0x7948, 0x7947,
+  0x79b9, 0x79ba, 0x79d1, 0x79d2, 0x79cb, 0x7a7f, 0x7a81, 0x7aff,
+  0x7afd, 0x7c7d, 0x7d02, 0x7d05, 0x7d00, 0x7d09, 0x7d07, 0x7d04,
+  0x7d06, 0x7f38, 0x7f8e, 0x7fbf, 0x8004,
+  /* 0xad */
+  0x8010, 0x800d, 0x8011, 0x8036, 0x80d6, 0x80e5, 0x80da, 0x80c3,
+  0x80c4, 0x80cc, 0x80e1, 0x80db, 0x80ce, 0x80de, 0x80e4, 0x80dd,
+  0x81f4, 0x8222, 0x82e7, 0x8303, 0x8305, 0x82e3, 0x82db, 0x82e6,
+  0x8304, 0x82e5, 0x8302, 0x8309, 0x82d2, 0x82d7, 0x82f1, 0x8301,
+  0x82dc, 0x82d4, 0x82d1, 0x82de, 0x82d3, 0x82df, 0x82ef, 0x8306,
+  0x8650, 0x8679, 0x867b, 0x867a, 0x884d, 0x886b, 0x8981, 0x89d4,
+  0x8a08, 0x8a02, 0x8a03, 0x8c9e, 0x8ca0, 0x8d74, 0x8d73, 0x8db4,
+  0x8ecd, 0x8ecc, 0x8ff0, 0x8fe6, 0x8fe2, 0x8fea, 0x8fe5, 0x8fed,
+  0x8feb, 0x8fe4, 0x8fe8, 0x90ca, 0x90ce, 0x90c1, 0x90c3, 0x914b,
+  0x914a, 0x91cd, 0x9582, 0x9650, 0x964b, 0x964c, 0x964d, 0x9762,
+  0x9769, 0x97cb, 0x97ed, 0x97f3, 0x9801, 0x98a8, 0x98db, 0x98df,
+  0x9996, 0x9999, 0x4e58, 0x4eb3, 0x500c, 0x500d, 0x5023, 0x4fef,
+  0x5026, 0x5025, 0x4ff8, 0x5029, 0x5016, 0x5006, 0x503c, 0x501f,
+  0x501a, 0x5012, 0x5011, 0x4ffa, 0x5000, 0x5014, 0x5028, 0x4ff1,
+  0x5021, 0x500b, 0x5019, 0x5018, 0x4ff3, 0x4fee, 0x502d, 0x502a,
+  0x4ffe, 0x502b, 0x5009, 0x517c, 0x51a4, 0x51a5, 0x51a2, 0x51cd,
+  0x51cc, 0x51c6, 0x51cb, 0x5256, 0x525c, 0x5254, 0x525b, 0x525d,
+  0x532a, 0x537f, 0x539f, 0x539d, 0x53df, 0x54e8, 0x5510, 0x5501,
+  0x5537, 0x54fc, 0x54e5, 0x54f2, 0x5506, 0x54fa, 0x5514, 0x54e9,
+  0x54ed, 0x54e1, 0x5509, 0x54ee, 0x54ea,
+  /* 0xae */
+  0x54e6, 0x5527, 0x5507, 0x54fd, 0x550f, 0x5703, 0x5704, 0x57c2,
+  0x57d4, 0x57cb, 0x57c3, 0x5809, 0x590f, 0x5957, 0x5958, 0x595a,
+  0x5a11, 0x5a18, 0x5a1c, 0x5a1f, 0x5a1b, 0x5a13, 0x59ec, 0x5a20,
+  0x5a23, 0x5a29, 0x5a25, 0x5a0c, 0x5a09, 0x5b6b, 0x5c58, 0x5bb0,
+  0x5bb3, 0x5bb6, 0x5bb4, 0x5bae, 0x5bb5, 0x5bb9, 0x5bb8, 0x5c04,
+  0x5c51, 0x5c55, 0x5c50, 0x5ced, 0x5cfd, 0x5cfb, 0x5cea, 0x5ce8,
+  0x5cf0, 0x5cf6, 0x5d01, 0x5cf4, 0x5dee, 0x5e2d, 0x5e2b, 0x5eab,
+  0x5ead, 0x5ea7, 0x5f31, 0x5f92, 0x5f91, 0x5f90, 0x6059, 0x6063,
+  0x6065, 0x6050, 0x6055, 0x606d, 0x6069, 0x606f, 0x6084, 0x609f,
+  0x609a, 0x608d, 0x6094, 0x608c, 0x6085, 0x6096, 0x6247, 0x62f3,
+  0x6308, 0x62ff, 0x634e, 0x633e, 0x632f, 0x6355, 0x6342, 0x6346,
+  0x634f, 0x6349, 0x633a, 0x6350, 0x633d, 0x632a, 0x632b, 0x6328,
+  0x634d, 0x634c, 0x6548, 0x6549, 0x6599, 0x65c1, 0x65c5, 0x6642,
+  0x6649, 0x664f, 0x6643, 0x6652, 0x664c, 0x6645, 0x6641, 0x66f8,
+  0x6714, 0x6715, 0x6717, 0x6821, 0x6838, 0x6848, 0x6846, 0x6853,
+  0x6839, 0x6842, 0x6854, 0x6829, 0x68b3, 0x6817, 0x684c, 0x6851,
+  0x683d, 0x67f4, 0x6850, 0x6840, 0x683c, 0x6843, 0x682a, 0x6845,
+  0x6813, 0x6818, 0x6841, 0x6b8a, 0x6b89, 0x6bb7, 0x6c23, 0x6c27,
+  0x6c28, 0x6c26, 0x6c24, 0x6cf0, 0x6d6a, 0x6d95, 0x6d88, 0x6d87,
+  0x6d66, 0x6d78, 0x6d77, 0x6d59, 0x6d93,
+  /* 0xaf */
+  0x6d6c, 0x6d89, 0x6d6e, 0x6d5a, 0x6d74, 0x6d69, 0x6d8c, 0x6d8a,
+  0x6d79, 0x6d85, 0x6d65, 0x6d94, 0x70ca, 0x70d8, 0x70e4, 0x70d9,
+  0x70c8, 0x70cf, 0x7239, 0x7279, 0x72fc, 0x72f9, 0x72fd, 0x72f8,
+  0x72f7, 0x7386, 0x73ed, 0x7409, 0x73ee, 0x73e0, 0x73ea, 0x73de,
+  0x7554, 0x755d, 0x755c, 0x755a, 0x7559, 0x75be, 0x75c5, 0x75c7,
+  0x75b2, 0x75b3, 0x75bd, 0x75bc, 0x75b9, 0x75c2, 0x75b8, 0x768b,
+  0x76b0, 0x76ca, 0x76cd, 0x76ce, 0x7729, 0x771f, 0x7720, 0x7728,
+  0x77e9, 0x7830, 0x7827, 0x7838, 0x781d, 0x7834, 0x7837, 0x7825,
+  0x782d, 0x7820, 0x781f, 0x7832, 0x7955, 0x7950, 0x7960, 0x795f,
+  0x7956, 0x795e, 0x795d, 0x7957, 0x795a, 0x79e4, 0x79e3, 0x79e7,
+  0x79df, 0x79e6, 0x79e9, 0x79d8, 0x7a84, 0x7a88, 0x7ad9, 0x7b06,
+  0x7b11, 0x7c89, 0x7d21, 0x7d17, 0x7d0b, 0x7d0a, 0x7d20, 0x7d22,
+  0x7d14, 0x7d10, 0x7d15, 0x7d1a, 0x7d1c, 0x7d0d, 0x7d19, 0x7d1b,
+  0x7f3a, 0x7f5f, 0x7f94, 0x7fc5, 0x7fc1, 0x8006, 0x8018, 0x8015,
+  0x8019, 0x8017, 0x803d, 0x803f, 0x80f1, 0x8102, 0x80f0, 0x8105,
+  0x80ed, 0x80f4, 0x8106, 0x80f8, 0x80f3, 0x8108, 0x80fd, 0x810a,
+  0x80fc, 0x80ef, 0x81ed, 0x81ec, 0x8200, 0x8210, 0x822a, 0x822b,
+  0x8228, 0x822c, 0x82bb, 0x832b, 0x8352, 0x8354, 0x834a, 0x8338,
+  0x8350, 0x8349, 0x8335, 0x8334, 0x834f, 0x8332, 0x8339, 0x8336,
+  0x8317, 0x8340, 0x8331, 0x8328, 0x8343,
+  /* 0xb0 */
+  0x8654, 0x868a, 0x86aa, 0x8693, 0x86a4, 0x86a9, 0x868c, 0x86a3,
+  0x869c, 0x8870, 0x8877, 0x8881, 0x8882, 0x887d, 0x8879, 0x8a18,
+  0x8a10, 0x8a0e, 0x8a0c, 0x8a15, 0x8a0a, 0x8a17, 0x8a13, 0x8a16,
+  0x8a0f, 0x8a11, 0x8c48, 0x8c7a, 0x8c79, 0x8ca1, 0x8ca2, 0x8d77,
+  0x8eac, 0x8ed2, 0x8ed4, 0x8ecf, 0x8fb1, 0x9001, 0x9006, 0x8ff7,
+  0x9000, 0x8ffa, 0x8ff4, 0x9003, 0x8ffd, 0x9005, 0x8ff8, 0x9095,
+  0x90e1, 0x90dd, 0x90e2, 0x9152, 0x914d, 0x914c, 0x91d8, 0x91dd,
+  0x91d7, 0x91dc, 0x91d9, 0x9583, 0x9662, 0x9663, 0x9661, 0x965b,
+  0x965d, 0x9664, 0x9658, 0x965e, 0x96bb, 0x98e2, 0x99ac, 0x9aa8,
+  0x9ad8, 0x9b25, 0x9b32, 0x9b3c, 0x4e7e, 0x507a, 0x507d, 0x505c,
+  0x5047, 0x5043, 0x504c, 0x505a, 0x5049, 0x5065, 0x5076, 0x504e,
+  0x5055, 0x5075, 0x5074, 0x5077, 0x504f, 0x500f, 0x506f, 0x506d,
+  0x515c, 0x5195, 0x51f0, 0x526a, 0x526f, 0x52d2, 0x52d9, 0x52d8,
+  0x52d5, 0x5310, 0x530f, 0x5319, 0x533f, 0x5340, 0x533e, 0x53c3,
+  0x66fc, 0x5546, 0x556a, 0x5566, 0x5544, 0x555e, 0x5561, 0x5543,
+  0x554a, 0x5531, 0x5556, 0x554f, 0x5555, 0x552f, 0x5564, 0x5538,
+  0x552e, 0x555c, 0x552c, 0x5563, 0x5533, 0x5541, 0x5557, 0x5708,
+  0x570b, 0x5709, 0x57df, 0x5805, 0x580a, 0x5806, 0x57e0, 0x57e4,
+  0x57fa, 0x5802, 0x5835, 0x57f7, 0x57f9, 0x5920, 0x5962, 0x5a36,
+  0x5a41, 0x5a49, 0x5a66, 0x5a6a, 0x5a40,
+  /* 0xb1 */
+  0x5a3c, 0x5a62, 0x5a5a, 0x5a46, 0x5a4a, 0x5b70, 0x5bc7, 0x5bc5,
+  0x5bc4, 0x5bc2, 0x5bbf, 0x5bc6, 0x5c09, 0x5c08, 0x5c07, 0x5c60,
+  0x5c5c, 0x5c5d, 0x5d07, 0x5d06, 0x5d0e, 0x5d1b, 0x5d16, 0x5d22,
+  0x5d11, 0x5d29, 0x5d14, 0x5d19, 0x5d24, 0x5d27, 0x5d17, 0x5de2,
+  0x5e38, 0x5e36, 0x5e33, 0x5e37, 0x5eb7, 0x5eb8, 0x5eb6, 0x5eb5,
+  0x5ebe, 0x5f35, 0x5f37, 0x5f57, 0x5f6c, 0x5f69, 0x5f6b, 0x5f97,
+  0x5f99, 0x5f9e, 0x5f98, 0x5fa1, 0x5fa0, 0x5f9c, 0x607f, 0x60a3,
+  0x6089, 0x60a0, 0x60a8, 0x60cb, 0x60b4, 0x60e6, 0x60bd, 0x60c5,
+  0x60bb, 0x60b5, 0x60dc, 0x60bc, 0x60d8, 0x60d5, 0x60c6, 0x60df,
+  0x60b8, 0x60da, 0x60c7, 0x621a, 0x621b, 0x6248, 0x63a0, 0x63a7,
+  0x6372, 0x6396, 0x63a2, 0x63a5, 0x6377, 0x6367, 0x6398, 0x63aa,
+  0x6371, 0x63a9, 0x6389, 0x6383, 0x639b, 0x636b, 0x63a8, 0x6384,
+  0x6388, 0x6399, 0x63a1, 0x63ac, 0x6392, 0x638f, 0x6380, 0x637b,
+  0x6369, 0x6368, 0x637a, 0x655d, 0x6556, 0x6551, 0x6559, 0x6557,
+  0x555f, 0x654f, 0x6558, 0x6555, 0x6554, 0x659c, 0x659b, 0x65ac,
+  0x65cf, 0x65cb, 0x65cc, 0x65ce, 0x665d, 0x665a, 0x6664, 0x6668,
+  0x6666, 0x665e, 0x66f9, 0x52d7, 0x671b, 0x6881, 0x68af, 0x68a2,
+  0x6893, 0x68b5, 0x687f, 0x6876, 0x68b1, 0x68a7, 0x6897, 0x68b0,
+  0x6883, 0x68c4, 0x68ad, 0x6886, 0x6885, 0x6894, 0x689d, 0x68a8,
+  0x689f, 0x68a1, 0x6882, 0x6b32, 0x6bba,
+  /* 0xb2 */
+  0x6beb, 0x6bec, 0x6c2b, 0x6d8e, 0x6dbc, 0x6df3, 0x6dd9, 0x6db2,
+  0x6de1, 0x6dcc, 0x6de4, 0x6dfb, 0x6dfa, 0x6e05, 0x6dc7, 0x6dcb,
+  0x6daf, 0x6dd1, 0x6dae, 0x6dde, 0x6df9, 0x6db8, 0x6df7, 0x6df5,
+  0x6dc5, 0x6dd2, 0x6e1a, 0x6db5, 0x6dda, 0x6deb, 0x6dd8, 0x6dea,
+  0x6df1, 0x6dee, 0x6de8, 0x6dc6, 0x6dc4, 0x6daa, 0x6dec, 0x6dbf,
+  0x6de6, 0x70f9, 0x7109, 0x710a, 0x70fd, 0x70ef, 0x723d, 0x727d,
+  0x7281, 0x731c, 0x731b, 0x7316, 0x7313, 0x7319, 0x7387, 0x7405,
+  0x740a, 0x7403, 0x7406, 0x73fe, 0x740d, 0x74e0, 0x74f6, 0x74f7,
+  0x751c, 0x7522, 0x7565, 0x7566, 0x7562, 0x7570, 0x758f, 0x75d4,
+  0x75d5, 0x75b5, 0x75ca, 0x75cd, 0x768e, 0x76d4, 0x76d2, 0x76db,
+  0x7737, 0x773e, 0x773c, 0x7736, 0x7738, 0x773a, 0x786b, 0x7843,
+  0x784e, 0x7965, 0x7968, 0x796d, 0x79fb, 0x7a92, 0x7a95, 0x7b20,
+  0x7b28, 0x7b1b, 0x7b2c, 0x7b26, 0x7b19, 0x7b1e, 0x7b2e, 0x7c92,
+  0x7c97, 0x7c95, 0x7d46, 0x7d43, 0x7d71, 0x7d2e, 0x7d39, 0x7d3c,
+  0x7d40, 0x7d30, 0x7d33, 0x7d44, 0x7d2f, 0x7d42, 0x7d32, 0x7d31,
+  0x7f3d, 0x7f9e, 0x7f9a, 0x7fcc, 0x7fce, 0x7fd2, 0x801c, 0x804a,
+  0x8046, 0x812f, 0x8116, 0x8123, 0x812b, 0x8129, 0x8130, 0x8124,
+  0x8202, 0x8235, 0x8237, 0x8236, 0x8239, 0x838e, 0x839e, 0x8398,
+  0x8378, 0x83a2, 0x8396, 0x83bd, 0x83ab, 0x8392, 0x838a, 0x8393,
+  0x8389, 0x83a0, 0x8377, 0x837b, 0x837c,
+  /* 0xb3 */
+  0x8386, 0x83a7, 0x8655, 0x5f6a, 0x86c7, 0x86c0, 0x86b6, 0x86c4,
+  0x86b5, 0x86c6, 0x86cb, 0x86b1, 0x86af, 0x86c9, 0x8853, 0x889e,
+  0x8888, 0x88ab, 0x8892, 0x8896, 0x888d, 0x888b, 0x8993, 0x898f,
+  0x8a2a, 0x8a1d, 0x8a23, 0x8a25, 0x8a31, 0x8a2d, 0x8a1f, 0x8a1b,
+  0x8a22, 0x8c49, 0x8c5a, 0x8ca9, 0x8cac, 0x8cab, 0x8ca8, 0x8caa,
+  0x8ca7, 0x8d67, 0x8d66, 0x8dbe, 0x8dba, 0x8edb, 0x8edf, 0x9019,
+  0x900d, 0x901a, 0x9017, 0x9023, 0x901f, 0x901d, 0x9010, 0x9015,
+  0x901e, 0x9020, 0x900f, 0x9022, 0x9016, 0x901b, 0x9014, 0x90e8,
+  0x90ed, 0x90fd, 0x9157, 0x91ce, 0x91f5, 0x91e6, 0x91e3, 0x91e7,
+  0x91ed, 0x91e9, 0x9589, 0x966a, 0x9675, 0x9673, 0x9678, 0x9670,
+  0x9674, 0x9676, 0x9677, 0x966c, 0x96c0, 0x96ea, 0x96e9, 0x7ae0,
+  0x7adf, 0x9802, 0x9803, 0x9b5a, 0x9ce5, 0x9e75, 0x9e7f, 0x9ea5,
+  0x9ebb, 0x50a2, 0x508d, 0x5085, 0x5099, 0x5091, 0x5080, 0x5096,
+  0x5098, 0x509a, 0x6700, 0x51f1, 0x5272, 0x5274, 0x5275, 0x5269,
+  0x52de, 0x52dd, 0x52db, 0x535a, 0x53a5, 0x557b, 0x5580, 0x55a7,
+  0x557c, 0x558a, 0x559d, 0x5598, 0x5582, 0x559c, 0x55aa, 0x5594,
+  0x5587, 0x558b, 0x5583, 0x55b3, 0x55ae, 0x559f, 0x553e, 0x55b2,
+  0x559a, 0x55bb, 0x55ac, 0x55b1, 0x557e, 0x5589, 0x55ab, 0x5599,
+  0x570d, 0x582f, 0x582a, 0x5834, 0x5824, 0x5830, 0x5831, 0x5821,
+  0x581d, 0x5820, 0x58f9, 0x58fa, 0x5960,
+  /* 0xb4 */
+  0x5a77, 0x5a9a, 0x5a7f, 0x5a92, 0x5a9b, 0x5aa7, 0x5b73, 0x5b71,
+  0x5bd2, 0x5bcc, 0x5bd3, 0x5bd0, 0x5c0a, 0x5c0b, 0x5c31, 0x5d4c,
+  0x5d50, 0x5d34, 0x5d47, 0x5dfd, 0x5e45, 0x5e3d, 0x5e40, 0x5e43,
+  0x5e7e, 0x5eca, 0x5ec1, 0x5ec2, 0x5ec4, 0x5f3c, 0x5f6d, 0x5fa9,
+  0x5faa, 0x5fa8, 0x60d1, 0x60e1, 0x60b2, 0x60b6, 0x60e0, 0x611c,
+  0x6123, 0x60fa, 0x6115, 0x60f0, 0x60fb, 0x60f4, 0x6168, 0x60f1,
+  0x610e, 0x60f6, 0x6109, 0x6100, 0x6112, 0x621f, 0x6249, 0x63a3,
+  0x638c, 0x63cf, 0x63c0, 0x63e9, 0x63c9, 0x63c6, 0x63cd, 0x63d2,
+  0x63e3, 0x63d0, 0x63e1, 0x63d6, 0x63ed, 0x63ee, 0x6376, 0x63f4,
+  0x63ea, 0x63db, 0x6452, 0x63da, 0x63f9, 0x655e, 0x6566, 0x6562,
+  0x6563, 0x6591, 0x6590, 0x65af, 0x666e, 0x6670, 0x6674, 0x6676,
+  0x666f, 0x6691, 0x667a, 0x667e, 0x6677, 0x66fe, 0x66ff, 0x671f,
+  0x671d, 0x68fa, 0x68d5, 0x68e0, 0x68d8, 0x68d7, 0x6905, 0x68df,
+  0x68f5, 0x68ee, 0x68e7, 0x68f9, 0x68d2, 0x68f2, 0x68e3, 0x68cb,
+  0x68cd, 0x690d, 0x6912, 0x690e, 0x68c9, 0x68da, 0x696e, 0x68fb,
+  0x6b3e, 0x6b3a, 0x6b3d, 0x6b98, 0x6b96, 0x6bbc, 0x6bef, 0x6c2e,
+  0x6c2f, 0x6c2c, 0x6e2f, 0x6e38, 0x6e54, 0x6e21, 0x6e32, 0x6e67,
+  0x6e4a, 0x6e20, 0x6e25, 0x6e23, 0x6e1b, 0x6e5b, 0x6e58, 0x6e24,
+  0x6e56, 0x6e6e, 0x6e2d, 0x6e26, 0x6e6f, 0x6e34, 0x6e4d, 0x6e3a,
+  0x6e2c, 0x6e43, 0x6e1d, 0x6e3e, 0x6ecb,
+  /* 0xb5 */
+  0x6e89, 0x6e19, 0x6e4e, 0x6e63, 0x6e44, 0x6e72, 0x6e69, 0x6e5f,
+  0x7119, 0x711a, 0x7126, 0x7130, 0x7121, 0x7136, 0x716e, 0x711c,
+  0x724c, 0x7284, 0x7280, 0x7336, 0x7325, 0x7334, 0x7329, 0x743a,
+  0x742a, 0x7433, 0x7422, 0x7425, 0x7435, 0x7436, 0x7434, 0x742f,
+  0x741b, 0x7426, 0x7428, 0x7525, 0x7526, 0x756b, 0x756a, 0x75e2,
+  0x75db, 0x75e3, 0x75d9, 0x75d8, 0x75de, 0x75e0, 0x767b, 0x767c,
+  0x7696, 0x7693, 0x76b4, 0x76dc, 0x774f, 0x77ed, 0x785d, 0x786c,
+  0x786f, 0x7a0d, 0x7a08, 0x7a0b, 0x7a05, 0x7a00, 0x7a98, 0x7a97,
+  0x7a96, 0x7ae5, 0x7ae3, 0x7b49, 0x7b56, 0x7b46, 0x7b50, 0x7b52,
+  0x7b54, 0x7b4d, 0x7b4b, 0x7b4f, 0x7b51, 0x7c9f, 0x7ca5, 0x7d5e,
+  0x7d50, 0x7d68, 0x7d55, 0x7d2b, 0x7d6e, 0x7d72, 0x7d61, 0x7d66,
+  0x7d62, 0x7d70, 0x7d73, 0x5584, 0x7fd4, 0x7fd5, 0x800b, 0x8052,
+  0x8085, 0x8155, 0x8154, 0x814b, 0x8151, 0x814e, 0x8139, 0x8146,
+  0x813e, 0x814c, 0x8153, 0x8174, 0x8212, 0x821c, 0x83e9, 0x8403,
+  0x83f8, 0x840d, 0x83e0, 0x83c5, 0x840b, 0x83c1, 0x83ef, 0x83f1,
+  0x83f4, 0x8457, 0x840a, 0x83f0, 0x840c, 0x83cc, 0x83fd, 0x83f2,
+  0x83ca, 0x8438, 0x840e, 0x8404, 0x83dc, 0x8407, 0x83d4, 0x83df,
+  0x865b, 0x86df, 0x86d9, 0x86ed, 0x86d4, 0x86db, 0x86e4, 0x86d0,
+  0x86de, 0x8857, 0x88c1, 0x88c2, 0x88b1, 0x8983, 0x8996, 0x8a3b,
+  0x8a60, 0x8a55, 0x8a5e, 0x8a3c, 0x8a41,
+  /* 0xb6 */
+  0x8a54, 0x8a5b, 0x8a50, 0x8a46, 0x8a34, 0x8a3a, 0x8a36, 0x8a56,
+  0x8c61, 0x8c82, 0x8caf, 0x8cbc, 0x8cb3, 0x8cbd, 0x8cc1, 0x8cbb,
+  0x8cc0, 0x8cb4, 0x8cb7, 0x8cb6, 0x8cbf, 0x8cb8, 0x8d8a, 0x8d85,
+  0x8d81, 0x8dce, 0x8ddd, 0x8dcb, 0x8dda, 0x8dd1, 0x8dcc, 0x8ddb,
+  0x8dc6, 0x8efb, 0x8ef8, 0x8efc, 0x8f9c, 0x902e, 0x9035, 0x9031,
+  0x9038, 0x9032, 0x9036, 0x9102, 0x90f5, 0x9109, 0x90fe, 0x9163,
+  0x9165, 0x91cf, 0x9214, 0x9215, 0x9223, 0x9209, 0x921e, 0x920d,
+  0x9210, 0x9207, 0x9211, 0x9594, 0x958f, 0x958b, 0x9591, 0x9593,
+  0x9592, 0x958e, 0x968a, 0x968e, 0x968b, 0x967d, 0x9685, 0x9686,
+  0x968d, 0x9672, 0x9684, 0x96c1, 0x96c5, 0x96c4, 0x96c6, 0x96c7,
+  0x96ef, 0x96f2, 0x97cc, 0x9805, 0x9806, 0x9808, 0x98e7, 0x98ea,
+  0x98ef, 0x98e9, 0x98f2, 0x98ed, 0x99ae, 0x99ad, 0x9ec3, 0x9ecd,
+  0x9ed1, 0x4e82, 0x50ad, 0x50b5, 0x50b2, 0x50b3, 0x50c5, 0x50be,
+  0x50ac, 0x50b7, 0x50bb, 0x50af, 0x50c7, 0x527f, 0x5277, 0x527d,
+  0x52df, 0x52e6, 0x52e4, 0x52e2, 0x52e3, 0x532f, 0x55df, 0x55e8,
+  0x55d3, 0x55e6, 0x55ce, 0x55dc, 0x55c7, 0x55d1, 0x55e3, 0x55e4,
+  0x55ef, 0x55da, 0x55e1, 0x55c5, 0x55c6, 0x55e5, 0x55c9, 0x5712,
+  0x5713, 0x585e, 0x5851, 0x5858, 0x5857, 0x585a, 0x5854, 0x586b,
+  0x584c, 0x586d, 0x584a, 0x5862, 0x5852, 0x584b, 0x5967, 0x5ac1,
+  0x5ac9, 0x5acc, 0x5abe, 0x5abd, 0x5abc,
+  /* 0xb7 */
+  0x5ab3, 0x5ac2, 0x5ab2, 0x5d69, 0x5d6f, 0x5e4c, 0x5e79, 0x5ec9,
+  0x5ec8, 0x5f12, 0x5f59, 0x5fac, 0x5fae, 0x611a, 0x610f, 0x6148,
+  0x611f, 0x60f3, 0x611b, 0x60f9, 0x6101, 0x6108, 0x614e, 0x614c,
+  0x6144, 0x614d, 0x613e, 0x6134, 0x6127, 0x610d, 0x6106, 0x6137,
+  0x6221, 0x6222, 0x6413, 0x643e, 0x641e, 0x642a, 0x642d, 0x643d,
+  0x642c, 0x640f, 0x641c, 0x6414, 0x640d, 0x6436, 0x6416, 0x6417,
+  0x6406, 0x656c, 0x659f, 0x65b0, 0x6697, 0x6689, 0x6687, 0x6688,
+  0x6696, 0x6684, 0x6698, 0x668d, 0x6703, 0x6994, 0x696d, 0x695a,
+  0x6977, 0x6960, 0x6954, 0x6975, 0x6930, 0x6982, 0x694a, 0x6968,
+  0x696b, 0x695e, 0x6953, 0x6979, 0x6986, 0x695d, 0x6963, 0x695b,
+  0x6b47, 0x6b72, 0x6bc0, 0x6bbf, 0x6bd3, 0x6bfd, 0x6ea2, 0x6eaf,
+  0x6ed3, 0x6eb6, 0x6ec2, 0x6e90, 0x6e9d, 0x6ec7, 0x6ec5, 0x6ea5,
+  0x6e98, 0x6ebc, 0x6eba, 0x6eab, 0x6ed1, 0x6e96, 0x6e9c, 0x6ec4,
+  0x6ed4, 0x6eaa, 0x6ea7, 0x6eb4, 0x714e, 0x7159, 0x7169, 0x7164,
+  0x7149, 0x7167, 0x715c, 0x716c, 0x7166, 0x714c, 0x7165, 0x715e,
+  0x7146, 0x7168, 0x7156, 0x723a, 0x7252, 0x7337, 0x7345, 0x733f,
+  0x733e, 0x746f, 0x745a, 0x7455, 0x745f, 0x745e, 0x7441, 0x743f,
+  0x7459, 0x745b, 0x745c, 0x7576, 0x7578, 0x7600, 0x75f0, 0x7601,
+  0x75f2, 0x75f1, 0x75fa, 0x75ff, 0x75f4, 0x75f3, 0x76de, 0x76df,
+  0x775b, 0x776b, 0x7766, 0x775e, 0x7763,
+  /* 0xb8 */
+  0x7779, 0x776a, 0x776c, 0x775c, 0x7765, 0x7768, 0x7762, 0x77ee,
+  0x788e, 0x78b0, 0x7897, 0x7898, 0x788c, 0x7889, 0x787c, 0x7891,
+  0x7893, 0x787f, 0x797a, 0x797f, 0x7981, 0x842c, 0x79bd, 0x7a1c,
+  0x7a1a, 0x7a20, 0x7a14, 0x7a1f, 0x7a1e, 0x7a9f, 0x7aa0, 0x7b77,
+  0x7bc0, 0x7b60, 0x7b6e, 0x7b67, 0x7cb1, 0x7cb3, 0x7cb5, 0x7d93,
+  0x7d79, 0x7d91, 0x7d81, 0x7d8f, 0x7d5b, 0x7f6e, 0x7f69, 0x7f6a,
+  0x7f72, 0x7fa9, 0x7fa8, 0x7fa4, 0x8056, 0x8058, 0x8086, 0x8084,
+  0x8171, 0x8170, 0x8178, 0x8165, 0x816e, 0x8173, 0x816b, 0x8179,
+  0x817a, 0x8166, 0x8205, 0x8247, 0x8482, 0x8477, 0x843d, 0x8431,
+  0x8475, 0x8466, 0x846b, 0x8449, 0x846c, 0x845b, 0x843c, 0x8435,
+  0x8461, 0x8463, 0x8469, 0x846d, 0x8446, 0x865e, 0x865c, 0x865f,
+  0x86f9, 0x8713, 0x8708, 0x8707, 0x8700, 0x86fe, 0x86fb, 0x8702,
+  0x8703, 0x8706, 0x870a, 0x8859, 0x88df, 0x88d4, 0x88d9, 0x88dc,
+  0x88d8, 0x88dd, 0x88e1, 0x88ca, 0x88d5, 0x88d2, 0x899c, 0x89e3,
+  0x8a6b, 0x8a72, 0x8a73, 0x8a66, 0x8a69, 0x8a70, 0x8a87, 0x8a7c,
+  0x8a63, 0x8aa0, 0x8a71, 0x8a85, 0x8a6d, 0x8a62, 0x8a6e, 0x8a6c,
+  0x8a79, 0x8a7b, 0x8a3e, 0x8a68, 0x8c62, 0x8c8a, 0x8c89, 0x8cca,
+  0x8cc7, 0x8cc8, 0x8cc4, 0x8cb2, 0x8cc3, 0x8cc2, 0x8cc5, 0x8de1,
+  0x8ddf, 0x8de8, 0x8def, 0x8df3, 0x8dfa, 0x8dea, 0x8de4, 0x8de6,
+  0x8eb2, 0x8f03, 0x8f09, 0x8efe, 0x8f0a,
+  /* 0xb9 */
+  0x8f9f, 0x8fb2, 0x904b, 0x904a, 0x9053, 0x9042, 0x9054, 0x903c,
+  0x9055, 0x9050, 0x9047, 0x904f, 0x904e, 0x904d, 0x9051, 0x903e,
+  0x9041, 0x9112, 0x9117, 0x916c, 0x916a, 0x9169, 0x91c9, 0x9237,
+  0x9257, 0x9238, 0x923d, 0x9240, 0x923e, 0x925b, 0x924b, 0x9264,
+  0x9251, 0x9234, 0x9249, 0x924d, 0x9245, 0x9239, 0x923f, 0x925a,
+  0x9598, 0x9698, 0x9694, 0x9695, 0x96cd, 0x96cb, 0x96c9, 0x96ca,
+  0x96f7, 0x96fb, 0x96f9, 0x96f6, 0x9756, 0x9774, 0x9776, 0x9810,
+  0x9811, 0x9813, 0x980a, 0x9812, 0x980c, 0x98fc, 0x98f4, 0x98fd,
+  0x98fe, 0x99b3, 0x99b1, 0x99b4, 0x9ae1, 0x9ce9, 0x9e82, 0x9f0e,
+  0x9f13, 0x9f20, 0x50e7, 0x50ee, 0x50e5, 0x50d6, 0x50ed, 0x50da,
+  0x50d5, 0x50cf, 0x50d1, 0x50f1, 0x50ce, 0x50e9, 0x5162, 0x51f3,
+  0x5283, 0x5282, 0x5331, 0x53ad, 0x55fe, 0x5600, 0x561b, 0x5617,
+  0x55fd, 0x5614, 0x5606, 0x5609, 0x560d, 0x560e, 0x55f7, 0x5616,
+  0x561f, 0x5608, 0x5610, 0x55f6, 0x5718, 0x5716, 0x5875, 0x587e,
+  0x5883, 0x5893, 0x588a, 0x5879, 0x5885, 0x587d, 0x58fd, 0x5925,
+  0x5922, 0x5924, 0x596a, 0x5969, 0x5ae1, 0x5ae6, 0x5ae9, 0x5ad7,
+  0x5ad6, 0x5ad8, 0x5ae3, 0x5b75, 0x5bde, 0x5be7, 0x5be1, 0x5be5,
+  0x5be6, 0x5be8, 0x5be2, 0x5be4, 0x5bdf, 0x5c0d, 0x5c62, 0x5d84,
+  0x5d87, 0x5e5b, 0x5e63, 0x5e55, 0x5e57, 0x5e54, 0x5ed3, 0x5ed6,
+  0x5f0a, 0x5f46, 0x5f70, 0x5fb9, 0x6147,
+  /* 0xba */
+  0x613f, 0x614b, 0x6177, 0x6162, 0x6163, 0x615f, 0x615a, 0x6158,
+  0x6175, 0x622a, 0x6487, 0x6458, 0x6454, 0x64a4, 0x6478, 0x645f,
+  0x647a, 0x6451, 0x6467, 0x6434, 0x646d, 0x647b, 0x6572, 0x65a1,
+  0x65d7, 0x65d6, 0x66a2, 0x66a8, 0x669d, 0x699c, 0x69a8, 0x6995,
+  0x69c1, 0x69ae, 0x69d3, 0x69cb, 0x699b, 0x69b7, 0x69bb, 0x69ab,
+  0x69b4, 0x69d0, 0x69cd, 0x69ad, 0x69cc, 0x69a6, 0x69c3, 0x69a3,
+  0x6b49, 0x6b4c, 0x6c33, 0x6f33, 0x6f14, 0x6efe, 0x6f13, 0x6ef4,
+  0x6f29, 0x6f3e, 0x6f20, 0x6f2c, 0x6f0f, 0x6f02, 0x6f22, 0x6eff,
+  0x6eef, 0x6f06, 0x6f31, 0x6f38, 0x6f32, 0x6f23, 0x6f15, 0x6f2b,
+  0x6f2f, 0x6f88, 0x6f2a, 0x6eec, 0x6f01, 0x6ef2, 0x6ecc, 0x6ef7,
+  0x7194, 0x7199, 0x717d, 0x718a, 0x7184, 0x7192, 0x723e, 0x7292,
+  0x7296, 0x7344, 0x7350, 0x7464, 0x7463, 0x746a, 0x7470, 0x746d,
+  0x7504, 0x7591, 0x7627, 0x760d, 0x760b, 0x7609, 0x7613, 0x76e1,
+  0x76e3, 0x7784, 0x777d, 0x777f, 0x7761, 0x78c1, 0x789f, 0x78a7,
+  0x78b3, 0x78a9, 0x78a3, 0x798e, 0x798f, 0x798d, 0x7a2e, 0x7a31,
+  0x7aaa, 0x7aa9, 0x7aed, 0x7aef, 0x7ba1, 0x7b95, 0x7b8b, 0x7b75,
+  0x7b97, 0x7b9d, 0x7b94, 0x7b8f, 0x7bb8, 0x7b87, 0x7b84, 0x7cb9,
+  0x7cbd, 0x7cbe, 0x7dbb, 0x7db0, 0x7d9c, 0x7dbd, 0x7dbe, 0x7da0,
+  0x7dca, 0x7db4, 0x7db2, 0x7db1, 0x7dba, 0x7da2, 0x7dbf, 0x7db5,
+  0x7db8, 0x7dad, 0x7dd2, 0x7dc7, 0x7dac,
+  /* 0xbb */
+  0x7f70, 0x7fe0, 0x7fe1, 0x7fdf, 0x805e, 0x805a, 0x8087, 0x8150,
+  0x8180, 0x818f, 0x8188, 0x818a, 0x817f, 0x8182, 0x81e7, 0x81fa,
+  0x8207, 0x8214, 0x821e, 0x824b, 0x84c9, 0x84bf, 0x84c6, 0x84c4,
+  0x8499, 0x849e, 0x84b2, 0x849c, 0x84cb, 0x84b8, 0x84c0, 0x84d3,
+  0x8490, 0x84bc, 0x84d1, 0x84ca, 0x873f, 0x871c, 0x873b, 0x8722,
+  0x8725, 0x8734, 0x8718, 0x8755, 0x8737, 0x8729, 0x88f3, 0x8902,
+  0x88f4, 0x88f9, 0x88f8, 0x88fd, 0x88e8, 0x891a, 0x88ef, 0x8aa6,
+  0x8a8c, 0x8a9e, 0x8aa3, 0x8a8d, 0x8aa1, 0x8a93, 0x8aa4, 0x8aaa,
+  0x8aa5, 0x8aa8, 0x8a98, 0x8a91, 0x8a9a, 0x8aa7, 0x8c6a, 0x8c8d,
+  0x8c8c, 0x8cd3, 0x8cd1, 0x8cd2, 0x8d6b, 0x8d99, 0x8d95, 0x8dfc,
+  0x8f14, 0x8f12, 0x8f15, 0x8f13, 0x8fa3, 0x9060, 0x9058, 0x905c,
+  0x9063, 0x9059, 0x905e, 0x9062, 0x905d, 0x905b, 0x9119, 0x9118,
+  0x911e, 0x9175, 0x9178, 0x9177, 0x9174, 0x9278, 0x9280, 0x9285,
+  0x9298, 0x9296, 0x927b, 0x9293, 0x929c, 0x92a8, 0x927c, 0x9291,
+  0x95a1, 0x95a8, 0x95a9, 0x95a3, 0x95a5, 0x95a4, 0x9699, 0x969c,
+  0x969b, 0x96cc, 0x96d2, 0x9700, 0x977c, 0x9785, 0x97f6, 0x9817,
+  0x9818, 0x98af, 0x98b1, 0x9903, 0x9905, 0x990c, 0x9909, 0x99c1,
+  0x9aaf, 0x9ab0, 0x9ae6, 0x9b41, 0x9b42, 0x9cf4, 0x9cf6, 0x9cf3,
+  0x9ebc, 0x9f3b, 0x9f4a, 0x5104, 0x5100, 0x50fb, 0x50f5, 0x50f9,
+  0x5102, 0x5108, 0x5109, 0x5105, 0x51dc,
+  /* 0xbc */
+  0x5287, 0x5288, 0x5289, 0x528d, 0x528a, 0x52f0, 0x53b2, 0x562e,
+  0x563b, 0x5639, 0x5632, 0x563f, 0x5634, 0x5629, 0x5653, 0x564e,
+  0x5657, 0x5674, 0x5636, 0x562f, 0x5630, 0x5880, 0x589f, 0x589e,
+  0x58b3, 0x589c, 0x58ae, 0x58a9, 0x58a6, 0x596d, 0x5b09, 0x5afb,
+  0x5b0b, 0x5af5, 0x5b0c, 0x5b08, 0x5bee, 0x5bec, 0x5be9, 0x5beb,
+  0x5c64, 0x5c65, 0x5d9d, 0x5d94, 0x5e62, 0x5e5f, 0x5e61, 0x5ee2,
+  0x5eda, 0x5edf, 0x5edd, 0x5ee3, 0x5ee0, 0x5f48, 0x5f71, 0x5fb7,
+  0x5fb5, 0x6176, 0x6167, 0x616e, 0x615d, 0x6155, 0x6182, 0x617c,
+  0x6170, 0x616b, 0x617e, 0x61a7, 0x6190, 0x61ab, 0x618e, 0x61ac,
+  0x619a, 0x61a4, 0x6194, 0x61ae, 0x622e, 0x6469, 0x646f, 0x6479,
+  0x649e, 0x64b2, 0x6488, 0x6490, 0x64b0, 0x64a5, 0x6493, 0x6495,
+  0x64a9, 0x6492, 0x64ae, 0x64ad, 0x64ab, 0x649a, 0x64ac, 0x6499,
+  0x64a2, 0x64b3, 0x6575, 0x6577, 0x6578, 0x66ae, 0x66ab, 0x66b4,
+  0x66b1, 0x6a23, 0x6a1f, 0x69e8, 0x6a01, 0x6a1e, 0x6a19, 0x69fd,
+  0x6a21, 0x6a13, 0x6a0a, 0x69f3, 0x6a02, 0x6a05, 0x69ed, 0x6a11,
+  0x6b50, 0x6b4e, 0x6ba4, 0x6bc5, 0x6bc6, 0x6f3f, 0x6f7c, 0x6f84,
+  0x6f51, 0x6f66, 0x6f54, 0x6f86, 0x6f6d, 0x6f5b, 0x6f78, 0x6f6e,
+  0x6f8e, 0x6f7a, 0x6f70, 0x6f64, 0x6f97, 0x6f58, 0x6ed5, 0x6f6f,
+  0x6f60, 0x6f5f, 0x719f, 0x71ac, 0x71b1, 0x71a8, 0x7256, 0x729b,
+  0x734e, 0x7357, 0x7469, 0x748b, 0x7483,
+  /* 0xbd */
+  0x747e, 0x7480, 0x757f, 0x7620, 0x7629, 0x761f, 0x7624, 0x7626,
+  0x7621, 0x7622, 0x769a, 0x76ba, 0x76e4, 0x778e, 0x7787, 0x778c,
+  0x7791, 0x778b, 0x78cb, 0x78c5, 0x78ba, 0x78ca, 0x78be, 0x78d5,
+  0x78bc, 0x78d0, 0x7a3f, 0x7a3c, 0x7a40, 0x7a3d, 0x7a37, 0x7a3b,
+  0x7aaf, 0x7aae, 0x7bad, 0x7bb1, 0x7bc4, 0x7bb4, 0x7bc6, 0x7bc7,
+  0x7bc1, 0x7ba0, 0x7bcc, 0x7cca, 0x7de0, 0x7df4, 0x7def, 0x7dfb,
+  0x7dd8, 0x7dec, 0x7ddd, 0x7de8, 0x7de3, 0x7dda, 0x7dde, 0x7de9,
+  0x7d9e, 0x7dd9, 0x7df2, 0x7df9, 0x7f75, 0x7f77, 0x7faf, 0x7fe9,
+  0x8026, 0x819b, 0x819c, 0x819d, 0x81a0, 0x819a, 0x8198, 0x8517,
+  0x853d, 0x851a, 0x84ee, 0x852c, 0x852d, 0x8513, 0x8511, 0x8523,
+  0x8521, 0x8514, 0x84ec, 0x8525, 0x84ff, 0x8506, 0x8782, 0x8774,
+  0x8776, 0x8760, 0x8766, 0x8778, 0x8768, 0x8759, 0x8757, 0x874c,
+  0x8753, 0x885b, 0x885d, 0x8910, 0x8907, 0x8912, 0x8913, 0x8915,
+  0x890a, 0x8abc, 0x8ad2, 0x8ac7, 0x8ac4, 0x8a95, 0x8acb, 0x8af8,
+  0x8ab2, 0x8ac9, 0x8ac2, 0x8abf, 0x8ab0, 0x8ad6, 0x8acd, 0x8ab6,
+  0x8ab9, 0x8adb, 0x8c4c, 0x8c4e, 0x8c6c, 0x8ce0, 0x8cde, 0x8ce6,
+  0x8ce4, 0x8cec, 0x8ced, 0x8ce2, 0x8ce3, 0x8cdc, 0x8cea, 0x8ce1,
+  0x8d6d, 0x8d9f, 0x8da3, 0x8e2b, 0x8e10, 0x8e1d, 0x8e22, 0x8e0f,
+  0x8e29, 0x8e1f, 0x8e21, 0x8e1e, 0x8eba, 0x8f1d, 0x8f1b, 0x8f1f,
+  0x8f29, 0x8f26, 0x8f2a, 0x8f1c, 0x8f1e,
+  /* 0xbe */
+  0x8f25, 0x9069, 0x906e, 0x9068, 0x906d, 0x9077, 0x9130, 0x912d,
+  0x9127, 0x9131, 0x9187, 0x9189, 0x918b, 0x9183, 0x92c5, 0x92bb,
+  0x92b7, 0x92ea, 0x92ac, 0x92e4, 0x92c1, 0x92b3, 0x92bc, 0x92d2,
+  0x92c7, 0x92f0, 0x92b2, 0x95ad, 0x95b1, 0x9704, 0x9706, 0x9707,
+  0x9709, 0x9760, 0x978d, 0x978b, 0x978f, 0x9821, 0x982b, 0x981c,
+  0x98b3, 0x990a, 0x9913, 0x9912, 0x9918, 0x99dd, 0x99d0, 0x99df,
+  0x99db, 0x99d1, 0x99d5, 0x99d2, 0x99d9, 0x9ab7, 0x9aee, 0x9aef,
+  0x9b27, 0x9b45, 0x9b44, 0x9b77, 0x9b6f, 0x9d06, 0x9d09, 0x9d03,
+  0x9ea9, 0x9ebe, 0x9ece, 0x58a8, 0x9f52, 0x5112, 0x5118, 0x5114,
+  0x5110, 0x5115, 0x5180, 0x51aa, 0x51dd, 0x5291, 0x5293, 0x52f3,
+  0x5659, 0x566b, 0x5679, 0x5669, 0x5664, 0x5678, 0x566a, 0x5668,
+  0x5665, 0x5671, 0x566f, 0x566c, 0x5662, 0x5676, 0x58c1, 0x58be,
+  0x58c7, 0x58c5, 0x596e, 0x5b1d, 0x5b34, 0x5b78, 0x5bf0, 0x5c0e,
+  0x5f4a, 0x61b2, 0x6191, 0x61a9, 0x618a, 0x61cd, 0x61b6, 0x61be,
+  0x61ca, 0x61c8, 0x6230, 0x64c5, 0x64c1, 0x64cb, 0x64bb, 0x64bc,
+  0x64da, 0x64c4, 0x64c7, 0x64c2, 0x64cd, 0x64bf, 0x64d2, 0x64d4,
+  0x64be, 0x6574, 0x66c6, 0x66c9, 0x66b9, 0x66c4, 0x66c7, 0x66b8,
+  0x6a3d, 0x6a38, 0x6a3a, 0x6a59, 0x6a6b, 0x6a58, 0x6a39, 0x6a44,
+  0x6a62, 0x6a61, 0x6a4b, 0x6a47, 0x6a35, 0x6a5f, 0x6a48, 0x6b59,
+  0x6b77, 0x6c05, 0x6fc2, 0x6fb1, 0x6fa1,
+  /* 0xbf */
+  0x6fc3, 0x6fa4, 0x6fc1, 0x6fa7, 0x6fb3, 0x6fc0, 0x6fb9, 0x6fb6,
+  0x6fa6, 0x6fa0, 0x6fb4, 0x71be, 0x71c9, 0x71d0, 0x71d2, 0x71c8,
+  0x71d5, 0x71b9, 0x71ce, 0x71d9, 0x71dc, 0x71c3, 0x71c4, 0x7368,
+  0x749c, 0x74a3, 0x7498, 0x749f, 0x749e, 0x74e2, 0x750c, 0x750d,
+  0x7634, 0x7638, 0x763a, 0x76e7, 0x76e5, 0x77a0, 0x779e, 0x779f,
+  0x77a5, 0x78e8, 0x78da, 0x78ec, 0x78e7, 0x79a6, 0x7a4d, 0x7a4e,
+  0x7a46, 0x7a4c, 0x7a4b, 0x7aba, 0x7bd9, 0x7c11, 0x7bc9, 0x7be4,
+  0x7bdb, 0x7be1, 0x7be9, 0x7be6, 0x7cd5, 0x7cd6, 0x7e0a, 0x7e11,
+  0x7e08, 0x7e1b, 0x7e23, 0x7e1e, 0x7e1d, 0x7e09, 0x7e10, 0x7f79,
+  0x7fb2, 0x7ff0, 0x7ff1, 0x7fee, 0x8028, 0x81b3, 0x81a9, 0x81a8,
+  0x81fb, 0x8208, 0x8258, 0x8259, 0x854a, 0x8559, 0x8548, 0x8568,
+  0x8569, 0x8543, 0x8549, 0x856d, 0x856a, 0x855e, 0x8783, 0x879f,
+  0x879e, 0x87a2, 0x878d, 0x8861, 0x892a, 0x8932, 0x8925, 0x892b,
+  0x8921, 0x89aa, 0x89a6, 0x8ae6, 0x8afa, 0x8aeb, 0x8af1, 0x8b00,
+  0x8adc, 0x8ae7, 0x8aee, 0x8afe, 0x8b01, 0x8b02, 0x8af7, 0x8aed,
+  0x8af3, 0x8af6, 0x8afc, 0x8c6b, 0x8c6d, 0x8c93, 0x8cf4, 0x8e44,
+  0x8e31, 0x8e34, 0x8e42, 0x8e39, 0x8e35, 0x8f3b, 0x8f2f, 0x8f38,
+  0x8f33, 0x8fa8, 0x8fa6, 0x9075, 0x9074, 0x9078, 0x9072, 0x907c,
+  0x907a, 0x9134, 0x9192, 0x9320, 0x9336, 0x92f8, 0x9333, 0x932f,
+  0x9322, 0x92fc, 0x932b, 0x9304, 0x931a,
+  /* 0xc0 */
+  0x9310, 0x9326, 0x9321, 0x9315, 0x932e, 0x9319, 0x95bb, 0x96a7,
+  0x96a8, 0x96aa, 0x96d5, 0x970e, 0x9711, 0x9716, 0x970d, 0x9713,
+  0x970f, 0x975b, 0x975c, 0x9766, 0x9798, 0x9830, 0x9838, 0x983b,
+  0x9837, 0x982d, 0x9839, 0x9824, 0x9910, 0x9928, 0x991e, 0x991b,
+  0x9921, 0x991a, 0x99ed, 0x99e2, 0x99f1, 0x9ab8, 0x9abc, 0x9afb,
+  0x9aed, 0x9b28, 0x9b91, 0x9d15, 0x9d23, 0x9d26, 0x9d28, 0x9d12,
+  0x9d1b, 0x9ed8, 0x9ed4, 0x9f8d, 0x9f9c, 0x512a, 0x511f, 0x5121,
+  0x5132, 0x52f5, 0x568e, 0x5680, 0x5690, 0x5685, 0x5687, 0x568f,
+  0x58d5, 0x58d3, 0x58d1, 0x58ce, 0x5b30, 0x5b2a, 0x5b24, 0x5b7a,
+  0x5c37, 0x5c68, 0x5dbc, 0x5dba, 0x5dbd, 0x5db8, 0x5e6b, 0x5f4c,
+  0x5fbd, 0x61c9, 0x61c2, 0x61c7, 0x61e6, 0x61cb, 0x6232, 0x6234,
+  0x64ce, 0x64ca, 0x64d8, 0x64e0, 0x64f0, 0x64e6, 0x64ec, 0x64f1,
+  0x64e2, 0x64ed, 0x6582, 0x6583, 0x66d9, 0x66d6, 0x6a80, 0x6a94,
+  0x6a84, 0x6aa2, 0x6a9c, 0x6adb, 0x6aa3, 0x6a7e, 0x6a97, 0x6a90,
+  0x6aa0, 0x6b5c, 0x6bae, 0x6bda, 0x6c08, 0x6fd8, 0x6ff1, 0x6fdf,
+  0x6fe0, 0x6fdb, 0x6fe4, 0x6feb, 0x6fef, 0x6f80, 0x6fec, 0x6fe1,
+  0x6fe9, 0x6fd5, 0x6fee, 0x6ff0, 0x71e7, 0x71df, 0x71ee, 0x71e6,
+  0x71e5, 0x71ed, 0x71ec, 0x71f4, 0x71e0, 0x7235, 0x7246, 0x7370,
+  0x7372, 0x74a9, 0x74b0, 0x74a6, 0x74a8, 0x7646, 0x7642, 0x764c,
+  0x76ea, 0x77b3, 0x77aa, 0x77b0, 0x77ac,
+  /* 0xc1 */
+  0x77a7, 0x77ad, 0x77ef, 0x78f7, 0x78fa, 0x78f4, 0x78ef, 0x7901,
+  0x79a7, 0x79aa, 0x7a57, 0x7abf, 0x7c07, 0x7c0d, 0x7bfe, 0x7bf7,
+  0x7c0c, 0x7be0, 0x7ce0, 0x7cdc, 0x7cde, 0x7ce2, 0x7cdf, 0x7cd9,
+  0x7cdd, 0x7e2e, 0x7e3e, 0x7e46, 0x7e37, 0x7e32, 0x7e43, 0x7e2b,
+  0x7e3d, 0x7e31, 0x7e45, 0x7e41, 0x7e34, 0x7e39, 0x7e48, 0x7e35,
+  0x7e3f, 0x7e2f, 0x7f44, 0x7ff3, 0x7ffc, 0x8071, 0x8072, 0x8070,
+  0x806f, 0x8073, 0x81c6, 0x81c3, 0x81ba, 0x81c2, 0x81c0, 0x81bf,
+  0x81bd, 0x81c9, 0x81be, 0x81e8, 0x8209, 0x8271, 0x85aa, 0x8584,
+  0x857e, 0x859c, 0x8591, 0x8594, 0x85af, 0x859b, 0x8587, 0x85a8,
+  0x858a, 0x8667, 0x87c0, 0x87d1, 0x87b3, 0x87d2, 0x87c6, 0x87ab,
+  0x87bb, 0x87ba, 0x87c8, 0x87cb, 0x893b, 0x8936, 0x8944, 0x8938,
+  0x893d, 0x89ac, 0x8b0e, 0x8b17, 0x8b19, 0x8b1b, 0x8b0a, 0x8b20,
+  0x8b1d, 0x8b04, 0x8b10, 0x8c41, 0x8c3f, 0x8c73, 0x8cfa, 0x8cfd,
+  0x8cfc, 0x8cf8, 0x8cfb, 0x8da8, 0x8e49, 0x8e4b, 0x8e48, 0x8e4a,
+  0x8f44, 0x8f3e, 0x8f42, 0x8f45, 0x8f3f, 0x907f, 0x907d, 0x9084,
+  0x9081, 0x9082, 0x9080, 0x9139, 0x91a3, 0x919e, 0x919c, 0x934d,
+  0x9382, 0x9328, 0x9375, 0x934a, 0x9365, 0x934b, 0x9318, 0x937e,
+  0x936c, 0x935b, 0x9370, 0x935a, 0x9354, 0x95ca, 0x95cb, 0x95cc,
+  0x95c8, 0x95c6, 0x96b1, 0x96b8, 0x96d6, 0x971c, 0x971e, 0x97a0,
+  0x97d3, 0x9846, 0x98b6, 0x9935, 0x9a01,
+  /* 0xc2 */
+  0x99ff, 0x9bae, 0x9bab, 0x9baa, 0x9bad, 0x9d3b, 0x9d3f, 0x9e8b,
+  0x9ecf, 0x9ede, 0x9edc, 0x9edd, 0x9edb, 0x9f3e, 0x9f4b, 0x53e2,
+  0x5695, 0x56ae, 0x58d9, 0x58d8, 0x5b38, 0x5f5d, 0x61e3, 0x6233,
+  0x64f4, 0x64f2, 0x64fe, 0x6506, 0x64fa, 0x64fb, 0x64f7, 0x65b7,
+  0x66dc, 0x6726, 0x6ab3, 0x6aac, 0x6ac3, 0x6abb, 0x6ab8, 0x6ac2,
+  0x6aae, 0x6aaf, 0x6b5f, 0x6b78, 0x6baf, 0x7009, 0x700b, 0x6ffe,
+  0x7006, 0x6ffa, 0x7011, 0x700f, 0x71fb, 0x71fc, 0x71fe, 0x71f8,
+  0x7377, 0x7375, 0x74a7, 0x74bf, 0x7515, 0x7656, 0x7658, 0x7652,
+  0x77bd, 0x77bf, 0x77bb, 0x77bc, 0x790e, 0x79ae, 0x7a61, 0x7a62,
+  0x7a60, 0x7ac4, 0x7ac5, 0x7c2b, 0x7c27, 0x7c2a, 0x7c1e, 0x7c23,
+  0x7c21, 0x7ce7, 0x7e54, 0x7e55, 0x7e5e, 0x7e5a, 0x7e61, 0x7e52,
+  0x7e59, 0x7f48, 0x7ff9, 0x7ffb, 0x8077, 0x8076, 0x81cd, 0x81cf,
+  0x820a, 0x85cf, 0x85a9, 0x85cd, 0x85d0, 0x85c9, 0x85b0, 0x85ba,
+  0x85b9, 0x85a6, 0x87ef, 0x87ec, 0x87f2, 0x87e0, 0x8986, 0x89b2,
+  0x89f4, 0x8b28, 0x8b39, 0x8b2c, 0x8b2b, 0x8c50, 0x8d05, 0x8e59,
+  0x8e63, 0x8e66, 0x8e64, 0x8e5f, 0x8e55, 0x8ec0, 0x8f49, 0x8f4d,
+  0x9087, 0x9083, 0x9088, 0x91ab, 0x91ac, 0x91d0, 0x9394, 0x938a,
+  0x9396, 0x93a2, 0x93b3, 0x93ae, 0x93ac, 0x93b0, 0x9398, 0x939a,
+  0x9397, 0x95d4, 0x95d6, 0x95d0, 0x95d5, 0x96e2, 0x96dc, 0x96d9,
+  0x96db, 0x96de, 0x9724, 0x97a3, 0x97a6,
+  /* 0xc3 */
+  0x97ad, 0x97f9, 0x984d, 0x984f, 0x984c, 0x984e, 0x9853, 0x98ba,
+  0x993e, 0x993f, 0x993d, 0x992e, 0x99a5, 0x9a0e, 0x9ac1, 0x9b03,
+  0x9b06, 0x9b4f, 0x9b4e, 0x9b4d, 0x9bca, 0x9bc9, 0x9bfd, 0x9bc8,
+  0x9bc0, 0x9d51, 0x9d5d, 0x9d60, 0x9ee0, 0x9f15, 0x9f2c, 0x5133,
+  0x56a5, 0x58de, 0x58df, 0x58e2, 0x5bf5, 0x9f90, 0x5eec, 0x61f2,
+  0x61f7, 0x61f6, 0x61f5, 0x6500, 0x650f, 0x66e0, 0x66dd, 0x6ae5,
+  0x6add, 0x6ada, 0x6ad3, 0x701b, 0x701f, 0x7028, 0x701a, 0x701d,
+  0x7015, 0x7018, 0x7206, 0x720d, 0x7258, 0x72a2, 0x7378, 0x737a,
+  0x74bd, 0x74ca, 0x74e3, 0x7587, 0x7586, 0x765f, 0x7661, 0x77c7,
+  0x7919, 0x79b1, 0x7a6b, 0x7a69, 0x7c3e, 0x7c3f, 0x7c38, 0x7c3d,
+  0x7c37, 0x7c40, 0x7e6b, 0x7e6d, 0x7e79, 0x7e69, 0x7e6a, 0x7f85,
+  0x7e73, 0x7fb6, 0x7fb9, 0x7fb8, 0x81d8, 0x85e9, 0x85dd, 0x85ea,
+  0x85d5, 0x85e4, 0x85e5, 0x85f7, 0x87fb, 0x8805, 0x880d, 0x87f9,
+  0x87fe, 0x8960, 0x895f, 0x8956, 0x895e, 0x8b41, 0x8b5c, 0x8b58,
+  0x8b49, 0x8b5a, 0x8b4e, 0x8b4f, 0x8b46, 0x8b59, 0x8d08, 0x8d0a,
+  0x8e7c, 0x8e72, 0x8e87, 0x8e76, 0x8e6c, 0x8e7a, 0x8e74, 0x8f54,
+  0x8f4e, 0x8fad, 0x908a, 0x908b, 0x91b1, 0x91ae, 0x93e1, 0x93d1,
+  0x93df, 0x93c3, 0x93c8, 0x93dc, 0x93dd, 0x93d6, 0x93e2, 0x93cd,
+  0x93d8, 0x93e4, 0x93d7, 0x93e8, 0x95dc, 0x96b4, 0x96e3, 0x972a,
+  0x9727, 0x9761, 0x97dc, 0x97fb, 0x985e,
+  /* 0xc4 */
+  0x9858, 0x985b, 0x98bc, 0x9945, 0x9949, 0x9a16, 0x9a19, 0x9b0d,
+  0x9be8, 0x9be7, 0x9bd6, 0x9bdb, 0x9d89, 0x9d61, 0x9d72, 0x9d6a,
+  0x9d6c, 0x9e92, 0x9e97, 0x9e93, 0x9eb4, 0x52f8, 0x56a8, 0x56b7,
+  0x56b6, 0x56b4, 0x56bc, 0x58e4, 0x5b40, 0x5b43, 0x5b7d, 0x5bf6,
+  0x5dc9, 0x61f8, 0x61fa, 0x6518, 0x6514, 0x6519, 0x66e6, 0x6727,
+  0x6aec, 0x703e, 0x7030, 0x7032, 0x7210, 0x737b, 0x74cf, 0x7662,
+  0x7665, 0x7926, 0x792a, 0x792c, 0x792b, 0x7ac7, 0x7af6, 0x7c4c,
+  0x7c43, 0x7c4d, 0x7cef, 0x7cf0, 0x8fae, 0x7e7d, 0x7e7c, 0x7e82,
+  0x7f4c, 0x8000, 0x81da, 0x8266, 0x85fb, 0x85f9, 0x8611, 0x85fa,
+  0x8606, 0x860b, 0x8607, 0x860a, 0x8814, 0x8815, 0x8964, 0x89ba,
+  0x89f8, 0x8b70, 0x8b6c, 0x8b66, 0x8b6f, 0x8b5f, 0x8b6b, 0x8d0f,
+  0x8d0d, 0x8e89, 0x8e81, 0x8e85, 0x8e82, 0x91b4, 0x91cb, 0x9418,
+  0x9403, 0x93fd, 0x95e1, 0x9730, 0x98c4, 0x9952, 0x9951, 0x99a8,
+  0x9a2b, 0x9a30, 0x9a37, 0x9a35, 0x9c13, 0x9c0d, 0x9e79, 0x9eb5,
+  0x9ee8, 0x9f2f, 0x9f5f, 0x9f63, 0x9f61, 0x5137, 0x5138, 0x56c1,
+  0x56c0, 0x56c2, 0x5914, 0x5c6c, 0x5dcd, 0x61fc, 0x61fe, 0x651d,
+  0x651c, 0x6595, 0x66e9, 0x6afb, 0x6b04, 0x6afa, 0x6bb2, 0x704c,
+  0x721b, 0x72a7, 0x74d6, 0x74d4, 0x7669, 0x77d3, 0x7c50, 0x7e8f,
+  0x7e8c, 0x7fbc, 0x8617, 0x862d, 0x861a, 0x8823, 0x8822, 0x8821,
+  0x881f, 0x896a, 0x896c, 0x89bd, 0x8b74,
+  /* 0xc5 */
+  0x8b77, 0x8b7d, 0x8d13, 0x8e8a, 0x8e8d, 0x8e8b, 0x8f5f, 0x8faf,
+  0x91ba, 0x942e, 0x9433, 0x9435, 0x943a, 0x9438, 0x9432, 0x942b,
+  0x95e2, 0x9738, 0x9739, 0x9732, 0x97ff, 0x9867, 0x9865, 0x9957,
+  0x9a45, 0x9a43, 0x9a40, 0x9a3e, 0x9acf, 0x9b54, 0x9b51, 0x9c2d,
+  0x9c25, 0x9daf, 0x9db4, 0x9dc2, 0x9db8, 0x9e9d, 0x9eef, 0x9f19,
+  0x9f5c, 0x9f66, 0x9f67, 0x513c, 0x513b, 0x56c8, 0x56ca, 0x56c9,
+  0x5b7f, 0x5dd4, 0x5dd2, 0x5f4e, 0x61ff, 0x6524, 0x6b0a, 0x6b61,
+  0x7051, 0x7058, 0x7380, 0x74e4, 0x758a, 0x766e, 0x766c, 0x79b3,
+  0x7c60, 0x7c5f, 0x807e, 0x807d, 0x81df, 0x8972, 0x896f, 0x89fc,
+  0x8b80, 0x8d16, 0x8d17, 0x8e91, 0x8e93, 0x8f61, 0x9148, 0x9444,
+  0x9451, 0x9452, 0x973d, 0x973e, 0x97c3, 0x97c1, 0x986b, 0x9955,
+  0x9a55, 0x9a4d, 0x9ad2, 0x9b1a, 0x9c49, 0x9c31, 0x9c3e, 0x9c3b,
+  0x9dd3, 0x9dd7, 0x9f34, 0x9f6c, 0x9f6a, 0x9f94, 0x56cc, 0x5dd6,
+  0x6200, 0x6523, 0x652b, 0x652a, 0x66ec, 0x6b10, 0x74da, 0x7aca,
+  0x7c64, 0x7c63, 0x7c65, 0x7e93, 0x7e96, 0x7e94, 0x81e2, 0x8638,
+  0x863f, 0x8831, 0x8b8a, 0x9090, 0x908f, 0x9463, 0x9460, 0x9464,
+  0x9768, 0x986f, 0x995c, 0x9a5a, 0x9a5b, 0x9a57, 0x9ad3, 0x9ad4,
+  0x9ad1, 0x9c54, 0x9c57, 0x9c56, 0x9de5, 0x9e9f, 0x9ef4, 0x56d1,
+  0x58e9, 0x652c, 0x705e, 0x7671, 0x7672, 0x77d7, 0x7f50, 0x7f88,
+  0x8836, 0x8839, 0x8862, 0x8b93, 0x8b92,
+  /* 0xc6 */
+  0x8b96, 0x8277, 0x8d1b, 0x91c0, 0x946a, 0x9742, 0x9748, 0x9744,
+  0x97c6, 0x9870, 0x9a5f, 0x9b22, 0x9b58, 0x9c5f, 0x9df9, 0x9dfa,
+  0x9e7c, 0x9e7d, 0x9f07, 0x9f77, 0x9f72, 0x5ef3, 0x6b16, 0x7063,
+  0x7c6c, 0x7c6e, 0x883b, 0x89c0, 0x8ea1, 0x91c1, 0x9472, 0x9470,
+  0x9871, 0x995e, 0x9ad6, 0x9b23, 0x9ecc, 0x7064, 0x77da, 0x8b9a,
+  0x9477, 0x97c9, 0x9a62, 0x9a65, 0x7e9c, 0x8b9c, 0x8eaa, 0x91c5,
+  0x947d, 0x947e, 0x947c, 0x9c77, 0x9c78, 0x9ef7, 0x8c54, 0x947f,
+  0x9e1a, 0x7228, 0x9a6a, 0x9b31, 0x9e1b, 0x9e1e, 0x7c72, 0x30fe,
+  0x309d, 0x309e, 0x3005, 0x3041, 0x3042, 0x3043, 0x3044, 0x3045,
+  0x3046, 0x3047, 0x3048, 0x3049, 0x304a, 0x304b, 0x304c, 0x304d,
+  0x304e, 0x304f, 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055,
+  0x3056, 0x3057, 0x3058, 0x3059, 0x305a, 0x305b, 0x305c, 0x305d,
+  0x305e, 0x305f, 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065,
+  0x3066, 0x3067, 0x3068, 0x3069, 0x306a, 0x306b, 0x306c, 0x306d,
+  0x306e, 0x306f, 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075,
+  0x3076, 0x3077, 0x3078, 0x3079, 0x307a, 0x307b, 0x307c, 0x307d,
+  0x307e, 0x307f, 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085,
+  0x3086, 0x3087, 0x3088, 0x3089, 0x308a, 0x308b, 0x308c, 0x308d,
+  0x308e, 0x308f, 0x3090, 0x3091, 0x3092, 0x3093, 0x30a1, 0x30a2,
+  0x30a3, 0x30a4, 0x30a5, 0x30a6, 0x30a7,
+  /* 0xc7 */
+  0x30a8, 0x30a9, 0x30aa, 0x30ab, 0x30ac, 0x30ad, 0x30ae, 0x30af,
+  0x30b0, 0x30b1, 0x30b2, 0x30b3, 0x30b4, 0x30b5, 0x30b6, 0x30b7,
+  0x30b8, 0x30b9, 0x30ba, 0x30bb, 0x30bc, 0x30bd, 0x30be, 0x30bf,
+  0x30c0, 0x30c1, 0x30c2, 0x30c3, 0x30c4, 0x30c5, 0x30c6, 0x30c7,
+  0x30c8, 0x30c9, 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf,
+  0x30d0, 0x30d1, 0x30d2, 0x30d3, 0x30d4, 0x30d5, 0x30d6, 0x30d7,
+  0x30d8, 0x30d9, 0x30da, 0x30db, 0x30dc, 0x30dd, 0x30de, 0x30df,
+  0x30e0, 0x30e1, 0x30e2, 0x30e3, 0x30e4, 0x30e5, 0x30e6, 0x30e7,
+  0x30e8, 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ee, 0x30ef,
+  0x30f0, 0x30f1, 0x30f2, 0x30f3, 0x30f4, 0x30f5, 0x30f6, 0x0414,
+  0x0415, 0x0401, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b,
+  0x041c, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429,
+  0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, 0x0430, 0x0431,
+  0x0432, 0x0433, 0x0434, 0x0435, 0x0451, 0x0436, 0x0437, 0x0438,
+  0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, 0x0440,
+  0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448,
+  0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, 0x2460,
+  0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468,
+  0x2469, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, 0x247a,
+  0x247b, 0x247c, 0x247d,
+};
+static const unsigned short big5_2uni_pagec9[7652] = {
+  /* 0xc9 */
+  0x4e42, 0x4e5c, 0x51f5, 0x531a, 0x5382, 0x4e07, 0x4e0c, 0x4e47,
+  0x4e8d, 0x56d7, 0xfa0c, 0x5c6e, 0x5f73, 0x4e0f, 0x5187, 0x4e0e,
+  0x4e2e, 0x4e93, 0x4ec2, 0x4ec9, 0x4ec8, 0x5198, 0x52fc, 0x536c,
+  0x53b9, 0x5720, 0x5903, 0x592c, 0x5c10, 0x5dff, 0x65e1, 0x6bb3,
+  0x6bcc, 0x6c14, 0x723f, 0x4e31, 0x4e3c, 0x4ee8, 0x4edc, 0x4ee9,
+  0x4ee1, 0x4edd, 0x4eda, 0x520c, 0x531c, 0x534c, 0x5722, 0x5723,
+  0x5917, 0x592f, 0x5b81, 0x5b84, 0x5c12, 0x5c3b, 0x5c74, 0x5c73,
+  0x5e04, 0x5e80, 0x5e82, 0x5fc9, 0x6209, 0x6250, 0x6c15, 0x6c36,
+  0x6c43, 0x6c3f, 0x6c3b, 0x72ae, 0x72b0, 0x738a, 0x79b8, 0x808a,
+  0x961e, 0x4f0e, 0x4f18, 0x4f2c, 0x4ef5, 0x4f14, 0x4ef1, 0x4f00,
+  0x4ef7, 0x4f08, 0x4f1d, 0x4f02, 0x4f05, 0x4f22, 0x4f13, 0x4f04,
+  0x4ef4, 0x4f12, 0x51b1, 0x5213, 0x5209, 0x5210, 0x52a6, 0x5322,
+  0x531f, 0x534d, 0x538a, 0x5407, 0x56e1, 0x56df, 0x572e, 0x572a,
+  0x5734, 0x593c, 0x5980, 0x597c, 0x5985, 0x597b, 0x597e, 0x5977,
+  0x597f, 0x5b56, 0x5c15, 0x5c25, 0x5c7c, 0x5c7a, 0x5c7b, 0x5c7e,
+  0x5ddf, 0x5e75, 0x5e84, 0x5f02, 0x5f1a, 0x5f74, 0x5fd5, 0x5fd4,
+  0x5fcf, 0x625c, 0x625e, 0x6264, 0x6261, 0x6266, 0x6262, 0x6259,
+  0x6260, 0x625a, 0x6265, 0x65ef, 0x65ee, 0x673e, 0x6739, 0x6738,
+  0x673b, 0x673a, 0x673f, 0x673c, 0x6733, 0x6c18, 0x6c46, 0x6c52,
+  0x6c5c, 0x6c4f, 0x6c4a, 0x6c54, 0x6c4b,
+  /* 0xca */
+  0x6c4c, 0x7071, 0x725e, 0x72b4, 0x72b5, 0x738e, 0x752a, 0x767f,
+  0x7a75, 0x7f51, 0x8278, 0x827c, 0x8280, 0x827d, 0x827f, 0x864d,
+  0x897e, 0x9099, 0x9097, 0x9098, 0x909b, 0x9094, 0x9622, 0x9624,
+  0x9620, 0x9623, 0x4f56, 0x4f3b, 0x4f62, 0x4f49, 0x4f53, 0x4f64,
+  0x4f3e, 0x4f67, 0x4f52, 0x4f5f, 0x4f41, 0x4f58, 0x4f2d, 0x4f33,
+  0x4f3f, 0x4f61, 0x518f, 0x51b9, 0x521c, 0x521e, 0x5221, 0x52ad,
+  0x52ae, 0x5309, 0x5363, 0x5372, 0x538e, 0x538f, 0x5430, 0x5437,
+  0x542a, 0x5454, 0x5445, 0x5419, 0x541c, 0x5425, 0x5418, 0x543d,
+  0x544f, 0x5441, 0x5428, 0x5424, 0x5447, 0x56ee, 0x56e7, 0x56e5,
+  0x5741, 0x5745, 0x574c, 0x5749, 0x574b, 0x5752, 0x5906, 0x5940,
+  0x59a6, 0x5998, 0x59a0, 0x5997, 0x598e, 0x59a2, 0x5990, 0x598f,
+  0x59a7, 0x59a1, 0x5b8e, 0x5b92, 0x5c28, 0x5c2a, 0x5c8d, 0x5c8f,
+  0x5c88, 0x5c8b, 0x5c89, 0x5c92, 0x5c8a, 0x5c86, 0x5c93, 0x5c95,
+  0x5de0, 0x5e0a, 0x5e0e, 0x5e8b, 0x5e89, 0x5e8c, 0x5e88, 0x5e8d,
+  0x5f05, 0x5f1d, 0x5f78, 0x5f76, 0x5fd2, 0x5fd1, 0x5fd0, 0x5fed,
+  0x5fe8, 0x5fee, 0x5ff3, 0x5fe1, 0x5fe4, 0x5fe3, 0x5ffa, 0x5fef,
+  0x5ff7, 0x5ffb, 0x6000, 0x5ff4, 0x623a, 0x6283, 0x628c, 0x628e,
+  0x628f, 0x6294, 0x6287, 0x6271, 0x627b, 0x627a, 0x6270, 0x6281,
+  0x6288, 0x6277, 0x627d, 0x6272, 0x6274, 0x6537, 0x65f0, 0x65f4,
+  0x65f3, 0x65f2, 0x65f5, 0x6745, 0x6747,
+  /* 0xcb */
+  0x6759, 0x6755, 0x674c, 0x6748, 0x675d, 0x674d, 0x675a, 0x674b,
+  0x6bd0, 0x6c19, 0x6c1a, 0x6c78, 0x6c67, 0x6c6b, 0x6c84, 0x6c8b,
+  0x6c8f, 0x6c71, 0x6c6f, 0x6c69, 0x6c9a, 0x6c6d, 0x6c87, 0x6c95,
+  0x6c9c, 0x6c66, 0x6c73, 0x6c65, 0x6c7b, 0x6c8e, 0x7074, 0x707a,
+  0x7263, 0x72bf, 0x72bd, 0x72c3, 0x72c6, 0x72c1, 0x72ba, 0x72c5,
+  0x7395, 0x7397, 0x7393, 0x7394, 0x7392, 0x753a, 0x7539, 0x7594,
+  0x7595, 0x7681, 0x793d, 0x8034, 0x8095, 0x8099, 0x8090, 0x8092,
+  0x809c, 0x8290, 0x828f, 0x8285, 0x828e, 0x8291, 0x8293, 0x828a,
+  0x8283, 0x8284, 0x8c78, 0x8fc9, 0x8fbf, 0x909f, 0x90a1, 0x90a5,
+  0x909e, 0x90a7, 0x90a0, 0x9630, 0x9628, 0x962f, 0x962d, 0x4e33,
+  0x4f98, 0x4f7c, 0x4f85, 0x4f7d, 0x4f80, 0x4f87, 0x4f76, 0x4f74,
+  0x4f89, 0x4f84, 0x4f77, 0x4f4c, 0x4f97, 0x4f6a, 0x4f9a, 0x4f79,
+  0x4f81, 0x4f78, 0x4f90, 0x4f9c, 0x4f94, 0x4f9e, 0x4f92, 0x4f82,
+  0x4f95, 0x4f6b, 0x4f6e, 0x519e, 0x51bc, 0x51be, 0x5235, 0x5232,
+  0x5233, 0x5246, 0x5231, 0x52bc, 0x530a, 0x530b, 0x533c, 0x5392,
+  0x5394, 0x5487, 0x547f, 0x5481, 0x5491, 0x5482, 0x5488, 0x546b,
+  0x547a, 0x547e, 0x5465, 0x546c, 0x5474, 0x5466, 0x548d, 0x546f,
+  0x5461, 0x5460, 0x5498, 0x5463, 0x5467, 0x5464, 0x56f7, 0x56f9,
+  0x576f, 0x5772, 0x576d, 0x576b, 0x5771, 0x5770, 0x5776, 0x5780,
+  0x5775, 0x577b, 0x5773, 0x5774, 0x5762,
+  /* 0xcc */
+  0x5768, 0x577d, 0x590c, 0x5945, 0x59b5, 0x59ba, 0x59cf, 0x59ce,
+  0x59b2, 0x59cc, 0x59c1, 0x59b6, 0x59bc, 0x59c3, 0x59d6, 0x59b1,
+  0x59bd, 0x59c0, 0x59c8, 0x59b4, 0x59c7, 0x5b62, 0x5b65, 0x5b93,
+  0x5b95, 0x5c44, 0x5c47, 0x5cae, 0x5ca4, 0x5ca0, 0x5cb5, 0x5caf,
+  0x5ca8, 0x5cac, 0x5c9f, 0x5ca3, 0x5cad, 0x5ca2, 0x5caa, 0x5ca7,
+  0x5c9d, 0x5ca5, 0x5cb6, 0x5cb0, 0x5ca6, 0x5e17, 0x5e14, 0x5e19,
+  0x5f28, 0x5f22, 0x5f23, 0x5f24, 0x5f54, 0x5f82, 0x5f7e, 0x5f7d,
+  0x5fde, 0x5fe5, 0x602d, 0x6026, 0x6019, 0x6032, 0x600b, 0x6034,
+  0x600a, 0x6017, 0x6033, 0x601a, 0x601e, 0x602c, 0x6022, 0x600d,
+  0x6010, 0x602e, 0x6013, 0x6011, 0x600c, 0x6009, 0x601c, 0x6214,
+  0x623d, 0x62ad, 0x62b4, 0x62d1, 0x62be, 0x62aa, 0x62b6, 0x62ca,
+  0x62ae, 0x62b3, 0x62af, 0x62bb, 0x62a9, 0x62b0, 0x62b8, 0x653d,
+  0x65a8, 0x65bb, 0x6609, 0x65fc, 0x6604, 0x6612, 0x6608, 0x65fb,
+  0x6603, 0x660b, 0x660d, 0x6605, 0x65fd, 0x6611, 0x6610, 0x66f6,
+  0x670a, 0x6785, 0x676c, 0x678e, 0x6792, 0x6776, 0x677b, 0x6798,
+  0x6786, 0x6784, 0x6774, 0x678d, 0x678c, 0x677a, 0x679f, 0x6791,
+  0x6799, 0x6783, 0x677d, 0x6781, 0x6778, 0x6779, 0x6794, 0x6b25,
+  0x6b80, 0x6b7e, 0x6bde, 0x6c1d, 0x6c93, 0x6cec, 0x6ceb, 0x6cee,
+  0x6cd9, 0x6cb6, 0x6cd4, 0x6cad, 0x6ce7, 0x6cb7, 0x6cd0, 0x6cc2,
+  0x6cba, 0x6cc3, 0x6cc6, 0x6ced, 0x6cf2,
+  /* 0xcd */
+  0x6cd2, 0x6cdd, 0x6cb4, 0x6c8a, 0x6c9d, 0x6c80, 0x6cde, 0x6cc0,
+  0x6d30, 0x6ccd, 0x6cc7, 0x6cb0, 0x6cf9, 0x6ccf, 0x6ce9, 0x6cd1,
+  0x7094, 0x7098, 0x7085, 0x7093, 0x7086, 0x7084, 0x7091, 0x7096,
+  0x7082, 0x709a, 0x7083, 0x726a, 0x72d6, 0x72cb, 0x72d8, 0x72c9,
+  0x72dc, 0x72d2, 0x72d4, 0x72da, 0x72cc, 0x72d1, 0x73a4, 0x73a1,
+  0x73ad, 0x73a6, 0x73a2, 0x73a0, 0x73ac, 0x739d, 0x74dd, 0x74e8,
+  0x753f, 0x7540, 0x753e, 0x758c, 0x7598, 0x76af, 0x76f3, 0x76f1,
+  0x76f0, 0x76f5, 0x77f8, 0x77fc, 0x77f9, 0x77fb, 0x77fa, 0x77f7,
+  0x7942, 0x793f, 0x79c5, 0x7a78, 0x7a7b, 0x7afb, 0x7c75, 0x7cfd,
+  0x8035, 0x808f, 0x80ae, 0x80a3, 0x80b8, 0x80b5, 0x80ad, 0x8220,
+  0x82a0, 0x82c0, 0x82ab, 0x829a, 0x8298, 0x829b, 0x82b5, 0x82a7,
+  0x82ae, 0x82bc, 0x829e, 0x82ba, 0x82b4, 0x82a8, 0x82a1, 0x82a9,
+  0x82c2, 0x82a4, 0x82c3, 0x82b6, 0x82a2, 0x8670, 0x866f, 0x866d,
+  0x866e, 0x8c56, 0x8fd2, 0x8fcb, 0x8fd3, 0x8fcd, 0x8fd6, 0x8fd5,
+  0x8fd7, 0x90b2, 0x90b4, 0x90af, 0x90b3, 0x90b0, 0x9639, 0x963d,
+  0x963c, 0x963a, 0x9643, 0x4fcd, 0x4fc5, 0x4fd3, 0x4fb2, 0x4fc9,
+  0x4fcb, 0x4fc1, 0x4fd4, 0x4fdc, 0x4fd9, 0x4fbb, 0x4fb3, 0x4fdb,
+  0x4fc7, 0x4fd6, 0x4fba, 0x4fc0, 0x4fb9, 0x4fec, 0x5244, 0x5249,
+  0x52c0, 0x52c2, 0x533d, 0x537c, 0x5397, 0x5396, 0x5399, 0x5398,
+  0x54ba, 0x54a1, 0x54ad, 0x54a5, 0x54cf,
+  /* 0xce */
+  0x54c3, 0x830d, 0x54b7, 0x54ae, 0x54d6, 0x54b6, 0x54c5, 0x54c6,
+  0x54a0, 0x5470, 0x54bc, 0x54a2, 0x54be, 0x5472, 0x54de, 0x54b0,
+  0x57b5, 0x579e, 0x579f, 0x57a4, 0x578c, 0x5797, 0x579d, 0x579b,
+  0x5794, 0x5798, 0x578f, 0x5799, 0x57a5, 0x579a, 0x5795, 0x58f4,
+  0x590d, 0x5953, 0x59e1, 0x59de, 0x59ee, 0x5a00, 0x59f1, 0x59dd,
+  0x59fa, 0x59fd, 0x59fc, 0x59f6, 0x59e4, 0x59f2, 0x59f7, 0x59db,
+  0x59e9, 0x59f3, 0x59f5, 0x59e0, 0x59fe, 0x59f4, 0x59ed, 0x5ba8,
+  0x5c4c, 0x5cd0, 0x5cd8, 0x5ccc, 0x5cd7, 0x5ccb, 0x5cdb, 0x5cde,
+  0x5cda, 0x5cc9, 0x5cc7, 0x5cca, 0x5cd6, 0x5cd3, 0x5cd4, 0x5ccf,
+  0x5cc8, 0x5cc6, 0x5cce, 0x5cdf, 0x5cf8, 0x5df9, 0x5e21, 0x5e22,
+  0x5e23, 0x5e20, 0x5e24, 0x5eb0, 0x5ea4, 0x5ea2, 0x5e9b, 0x5ea3,
+  0x5ea5, 0x5f07, 0x5f2e, 0x5f56, 0x5f86, 0x6037, 0x6039, 0x6054,
+  0x6072, 0x605e, 0x6045, 0x6053, 0x6047, 0x6049, 0x605b, 0x604c,
+  0x6040, 0x6042, 0x605f, 0x6024, 0x6044, 0x6058, 0x6066, 0x606e,
+  0x6242, 0x6243, 0x62cf, 0x630d, 0x630b, 0x62f5, 0x630e, 0x6303,
+  0x62eb, 0x62f9, 0x630f, 0x630c, 0x62f8, 0x62f6, 0x6300, 0x6313,
+  0x6314, 0x62fa, 0x6315, 0x62fb, 0x62f0, 0x6541, 0x6543, 0x65aa,
+  0x65bf, 0x6636, 0x6621, 0x6632, 0x6635, 0x661c, 0x6626, 0x6622,
+  0x6633, 0x662b, 0x663a, 0x661d, 0x6634, 0x6639, 0x662e, 0x670f,
+  0x6710, 0x67c1, 0x67f2, 0x67c8, 0x67ba,
+  /* 0xcf */
+  0x67dc, 0x67bb, 0x67f8, 0x67d8, 0x67c0, 0x67b7, 0x67c5, 0x67eb,
+  0x67e4, 0x67df, 0x67b5, 0x67cd, 0x67b3, 0x67f7, 0x67f6, 0x67ee,
+  0x67e3, 0x67c2, 0x67b9, 0x67ce, 0x67e7, 0x67f0, 0x67b2, 0x67fc,
+  0x67c6, 0x67ed, 0x67cc, 0x67ae, 0x67e6, 0x67db, 0x67fa, 0x67c9,
+  0x67ca, 0x67c3, 0x67ea, 0x67cb, 0x6b28, 0x6b82, 0x6b84, 0x6bb6,
+  0x6bd6, 0x6bd8, 0x6be0, 0x6c20, 0x6c21, 0x6d28, 0x6d34, 0x6d2d,
+  0x6d1f, 0x6d3c, 0x6d3f, 0x6d12, 0x6d0a, 0x6cda, 0x6d33, 0x6d04,
+  0x6d19, 0x6d3a, 0x6d1a, 0x6d11, 0x6d00, 0x6d1d, 0x6d42, 0x6d01,
+  0x6d18, 0x6d37, 0x6d03, 0x6d0f, 0x6d40, 0x6d07, 0x6d20, 0x6d2c,
+  0x6d08, 0x6d22, 0x6d09, 0x6d10, 0x70b7, 0x709f, 0x70be, 0x70b1,
+  0x70b0, 0x70a1, 0x70b4, 0x70b5, 0x70a9, 0x7241, 0x7249, 0x724a,
+  0x726c, 0x7270, 0x7273, 0x726e, 0x72ca, 0x72e4, 0x72e8, 0x72eb,
+  0x72df, 0x72ea, 0x72e6, 0x72e3, 0x7385, 0x73cc, 0x73c2, 0x73c8,
+  0x73c5, 0x73b9, 0x73b6, 0x73b5, 0x73b4, 0x73eb, 0x73bf, 0x73c7,
+  0x73be, 0x73c3, 0x73c6, 0x73b8, 0x73cb, 0x74ec, 0x74ee, 0x752e,
+  0x7547, 0x7548, 0x75a7, 0x75aa, 0x7679, 0x76c4, 0x7708, 0x7703,
+  0x7704, 0x7705, 0x770a, 0x76f7, 0x76fb, 0x76fa, 0x77e7, 0x77e8,
+  0x7806, 0x7811, 0x7812, 0x7805, 0x7810, 0x780f, 0x780e, 0x7809,
+  0x7803, 0x7813, 0x794a, 0x794c, 0x794b, 0x7945, 0x7944, 0x79d5,
+  0x79cd, 0x79cf, 0x79d6, 0x79ce, 0x7a80,
+  /* 0xd0 */
+  0x7a7e, 0x7ad1, 0x7b00, 0x7b01, 0x7c7a, 0x7c78, 0x7c79, 0x7c7f,
+  0x7c80, 0x7c81, 0x7d03, 0x7d08, 0x7d01, 0x7f58, 0x7f91, 0x7f8d,
+  0x7fbe, 0x8007, 0x800e, 0x800f, 0x8014, 0x8037, 0x80d8, 0x80c7,
+  0x80e0, 0x80d1, 0x80c8, 0x80c2, 0x80d0, 0x80c5, 0x80e3, 0x80d9,
+  0x80dc, 0x80ca, 0x80d5, 0x80c9, 0x80cf, 0x80d7, 0x80e6, 0x80cd,
+  0x81ff, 0x8221, 0x8294, 0x82d9, 0x82fe, 0x82f9, 0x8307, 0x82e8,
+  0x8300, 0x82d5, 0x833a, 0x82eb, 0x82d6, 0x82f4, 0x82ec, 0x82e1,
+  0x82f2, 0x82f5, 0x830c, 0x82fb, 0x82f6, 0x82f0, 0x82ea, 0x82e4,
+  0x82e0, 0x82fa, 0x82f3, 0x82ed, 0x8677, 0x8674, 0x867c, 0x8673,
+  0x8841, 0x884e, 0x8867, 0x886a, 0x8869, 0x89d3, 0x8a04, 0x8a07,
+  0x8d72, 0x8fe3, 0x8fe1, 0x8fee, 0x8fe0, 0x90f1, 0x90bd, 0x90bf,
+  0x90d5, 0x90c5, 0x90be, 0x90c7, 0x90cb, 0x90c8, 0x91d4, 0x91d3,
+  0x9654, 0x964f, 0x9651, 0x9653, 0x964a, 0x964e, 0x501e, 0x5005,
+  0x5007, 0x5013, 0x5022, 0x5030, 0x501b, 0x4ff5, 0x4ff4, 0x5033,
+  0x5037, 0x502c, 0x4ff6, 0x4ff7, 0x5017, 0x501c, 0x5020, 0x5027,
+  0x5035, 0x502f, 0x5031, 0x500e, 0x515a, 0x5194, 0x5193, 0x51ca,
+  0x51c4, 0x51c5, 0x51c8, 0x51ce, 0x5261, 0x525a, 0x5252, 0x525e,
+  0x525f, 0x5255, 0x5262, 0x52cd, 0x530e, 0x539e, 0x5526, 0x54e2,
+  0x5517, 0x5512, 0x54e7, 0x54f3, 0x54e4, 0x551a, 0x54ff, 0x5504,
+  0x5508, 0x54eb, 0x5511, 0x5505, 0x54f1,
+  /* 0xd1 */
+  0x550a, 0x54fb, 0x54f7, 0x54f8, 0x54e0, 0x550e, 0x5503, 0x550b,
+  0x5701, 0x5702, 0x57cc, 0x5832, 0x57d5, 0x57d2, 0x57ba, 0x57c6,
+  0x57bd, 0x57bc, 0x57b8, 0x57b6, 0x57bf, 0x57c7, 0x57d0, 0x57b9,
+  0x57c1, 0x590e, 0x594a, 0x5a19, 0x5a16, 0x5a2d, 0x5a2e, 0x5a15,
+  0x5a0f, 0x5a17, 0x5a0a, 0x5a1e, 0x5a33, 0x5b6c, 0x5ba7, 0x5bad,
+  0x5bac, 0x5c03, 0x5c56, 0x5c54, 0x5cec, 0x5cff, 0x5cee, 0x5cf1,
+  0x5cf7, 0x5d00, 0x5cf9, 0x5e29, 0x5e28, 0x5ea8, 0x5eae, 0x5eaa,
+  0x5eac, 0x5f33, 0x5f30, 0x5f67, 0x605d, 0x605a, 0x6067, 0x6041,
+  0x60a2, 0x6088, 0x6080, 0x6092, 0x6081, 0x609d, 0x6083, 0x6095,
+  0x609b, 0x6097, 0x6087, 0x609c, 0x608e, 0x6219, 0x6246, 0x62f2,
+  0x6310, 0x6356, 0x632c, 0x6344, 0x6345, 0x6336, 0x6343, 0x63e4,
+  0x6339, 0x634b, 0x634a, 0x633c, 0x6329, 0x6341, 0x6334, 0x6358,
+  0x6354, 0x6359, 0x632d, 0x6347, 0x6333, 0x635a, 0x6351, 0x6338,
+  0x6357, 0x6340, 0x6348, 0x654a, 0x6546, 0x65c6, 0x65c3, 0x65c4,
+  0x65c2, 0x664a, 0x665f, 0x6647, 0x6651, 0x6712, 0x6713, 0x681f,
+  0x681a, 0x6849, 0x6832, 0x6833, 0x683b, 0x684b, 0x684f, 0x6816,
+  0x6831, 0x681c, 0x6835, 0x682b, 0x682d, 0x682f, 0x684e, 0x6844,
+  0x6834, 0x681d, 0x6812, 0x6814, 0x6826, 0x6828, 0x682e, 0x684d,
+  0x683a, 0x6825, 0x6820, 0x6b2c, 0x6b2f, 0x6b2d, 0x6b31, 0x6b34,
+  0x6b6d, 0x8082, 0x6b88, 0x6be6, 0x6be4,
+  /* 0xd2 */
+  0x6be8, 0x6be3, 0x6be2, 0x6be7, 0x6c25, 0x6d7a, 0x6d63, 0x6d64,
+  0x6d76, 0x6d0d, 0x6d61, 0x6d92, 0x6d58, 0x6d62, 0x6d6d, 0x6d6f,
+  0x6d91, 0x6d8d, 0x6def, 0x6d7f, 0x6d86, 0x6d5e, 0x6d67, 0x6d60,
+  0x6d97, 0x6d70, 0x6d7c, 0x6d5f, 0x6d82, 0x6d98, 0x6d2f, 0x6d68,
+  0x6d8b, 0x6d7e, 0x6d80, 0x6d84, 0x6d16, 0x6d83, 0x6d7b, 0x6d7d,
+  0x6d75, 0x6d90, 0x70dc, 0x70d3, 0x70d1, 0x70dd, 0x70cb, 0x7f39,
+  0x70e2, 0x70d7, 0x70d2, 0x70de, 0x70e0, 0x70d4, 0x70cd, 0x70c5,
+  0x70c6, 0x70c7, 0x70da, 0x70ce, 0x70e1, 0x7242, 0x7278, 0x7277,
+  0x7276, 0x7300, 0x72fa, 0x72f4, 0x72fe, 0x72f6, 0x72f3, 0x72fb,
+  0x7301, 0x73d3, 0x73d9, 0x73e5, 0x73d6, 0x73bc, 0x73e7, 0x73e3,
+  0x73e9, 0x73dc, 0x73d2, 0x73db, 0x73d4, 0x73dd, 0x73da, 0x73d7,
+  0x73d8, 0x73e8, 0x74de, 0x74df, 0x74f4, 0x74f5, 0x7521, 0x755b,
+  0x755f, 0x75b0, 0x75c1, 0x75bb, 0x75c4, 0x75c0, 0x75bf, 0x75b6,
+  0x75ba, 0x768a, 0x76c9, 0x771d, 0x771b, 0x7710, 0x7713, 0x7712,
+  0x7723, 0x7711, 0x7715, 0x7719, 0x771a, 0x7722, 0x7727, 0x7823,
+  0x782c, 0x7822, 0x7835, 0x782f, 0x7828, 0x782e, 0x782b, 0x7821,
+  0x7829, 0x7833, 0x782a, 0x7831, 0x7954, 0x795b, 0x794f, 0x795c,
+  0x7953, 0x7952, 0x7951, 0x79eb, 0x79ec, 0x79e0, 0x79ee, 0x79ed,
+  0x79ea, 0x79dc, 0x79de, 0x79dd, 0x7a86, 0x7a89, 0x7a85, 0x7a8b,
+  0x7a8c, 0x7a8a, 0x7a87, 0x7ad8, 0x7b10,
+  /* 0xd3 */
+  0x7b04, 0x7b13, 0x7b05, 0x7b0f, 0x7b08, 0x7b0a, 0x7b0e, 0x7b09,
+  0x7b12, 0x7c84, 0x7c91, 0x7c8a, 0x7c8c, 0x7c88, 0x7c8d, 0x7c85,
+  0x7d1e, 0x7d1d, 0x7d11, 0x7d0e, 0x7d18, 0x7d16, 0x7d13, 0x7d1f,
+  0x7d12, 0x7d0f, 0x7d0c, 0x7f5c, 0x7f61, 0x7f5e, 0x7f60, 0x7f5d,
+  0x7f5b, 0x7f96, 0x7f92, 0x7fc3, 0x7fc2, 0x7fc0, 0x8016, 0x803e,
+  0x8039, 0x80fa, 0x80f2, 0x80f9, 0x80f5, 0x8101, 0x80fb, 0x8100,
+  0x8201, 0x822f, 0x8225, 0x8333, 0x832d, 0x8344, 0x8319, 0x8351,
+  0x8325, 0x8356, 0x833f, 0x8341, 0x8326, 0x831c, 0x8322, 0x8342,
+  0x834e, 0x831b, 0x832a, 0x8308, 0x833c, 0x834d, 0x8316, 0x8324,
+  0x8320, 0x8337, 0x832f, 0x8329, 0x8347, 0x8345, 0x834c, 0x8353,
+  0x831e, 0x832c, 0x834b, 0x8327, 0x8348, 0x8653, 0x8652, 0x86a2,
+  0x86a8, 0x8696, 0x868d, 0x8691, 0x869e, 0x8687, 0x8697, 0x8686,
+  0x868b, 0x869a, 0x8685, 0x86a5, 0x8699, 0x86a1, 0x86a7, 0x8695,
+  0x8698, 0x868e, 0x869d, 0x8690, 0x8694, 0x8843, 0x8844, 0x886d,
+  0x8875, 0x8876, 0x8872, 0x8880, 0x8871, 0x887f, 0x886f, 0x8883,
+  0x887e, 0x8874, 0x887c, 0x8a12, 0x8c47, 0x8c57, 0x8c7b, 0x8ca4,
+  0x8ca3, 0x8d76, 0x8d78, 0x8db5, 0x8db7, 0x8db6, 0x8ed1, 0x8ed3,
+  0x8ffe, 0x8ff5, 0x9002, 0x8fff, 0x8ffb, 0x9004, 0x8ffc, 0x8ff6,
+  0x90d6, 0x90e0, 0x90d9, 0x90da, 0x90e3, 0x90df, 0x90e5, 0x90d8,
+  0x90db, 0x90d7, 0x90dc, 0x90e4, 0x9150,
+  /* 0xd4 */
+  0x914e, 0x914f, 0x91d5, 0x91e2, 0x91da, 0x965c, 0x965f, 0x96bc,
+  0x98e3, 0x9adf, 0x9b2f, 0x4e7f, 0x5070, 0x506a, 0x5061, 0x505e,
+  0x5060, 0x5053, 0x504b, 0x505d, 0x5072, 0x5048, 0x504d, 0x5041,
+  0x505b, 0x504a, 0x5062, 0x5015, 0x5045, 0x505f, 0x5069, 0x506b,
+  0x5063, 0x5064, 0x5046, 0x5040, 0x506e, 0x5073, 0x5057, 0x5051,
+  0x51d0, 0x526b, 0x526d, 0x526c, 0x526e, 0x52d6, 0x52d3, 0x532d,
+  0x539c, 0x5575, 0x5576, 0x553c, 0x554d, 0x5550, 0x5534, 0x552a,
+  0x5551, 0x5562, 0x5536, 0x5535, 0x5530, 0x5552, 0x5545, 0x550c,
+  0x5532, 0x5565, 0x554e, 0x5539, 0x5548, 0x552d, 0x553b, 0x5540,
+  0x554b, 0x570a, 0x5707, 0x57fb, 0x5814, 0x57e2, 0x57f6, 0x57dc,
+  0x57f4, 0x5800, 0x57ed, 0x57fd, 0x5808, 0x57f8, 0x580b, 0x57f3,
+  0x57cf, 0x5807, 0x57ee, 0x57e3, 0x57f2, 0x57e5, 0x57ec, 0x57e1,
+  0x580e, 0x57fc, 0x5810, 0x57e7, 0x5801, 0x580c, 0x57f1, 0x57e9,
+  0x57f0, 0x580d, 0x5804, 0x595c, 0x5a60, 0x5a58, 0x5a55, 0x5a67,
+  0x5a5e, 0x5a38, 0x5a35, 0x5a6d, 0x5a50, 0x5a5f, 0x5a65, 0x5a6c,
+  0x5a53, 0x5a64, 0x5a57, 0x5a43, 0x5a5d, 0x5a52, 0x5a44, 0x5a5b,
+  0x5a48, 0x5a8e, 0x5a3e, 0x5a4d, 0x5a39, 0x5a4c, 0x5a70, 0x5a69,
+  0x5a47, 0x5a51, 0x5a56, 0x5a42, 0x5a5c, 0x5b72, 0x5b6e, 0x5bc1,
+  0x5bc0, 0x5c59, 0x5d1e, 0x5d0b, 0x5d1d, 0x5d1a, 0x5d20, 0x5d0c,
+  0x5d28, 0x5d0d, 0x5d26, 0x5d25, 0x5d0f,
+  /* 0xd5 */
+  0x5d30, 0x5d12, 0x5d23, 0x5d1f, 0x5d2e, 0x5e3e, 0x5e34, 0x5eb1,
+  0x5eb4, 0x5eb9, 0x5eb2, 0x5eb3, 0x5f36, 0x5f38, 0x5f9b, 0x5f96,
+  0x5f9f, 0x608a, 0x6090, 0x6086, 0x60be, 0x60b0, 0x60ba, 0x60d3,
+  0x60d4, 0x60cf, 0x60e4, 0x60d9, 0x60dd, 0x60c8, 0x60b1, 0x60db,
+  0x60b7, 0x60ca, 0x60bf, 0x60c3, 0x60cd, 0x60c0, 0x6332, 0x6365,
+  0x638a, 0x6382, 0x637d, 0x63bd, 0x639e, 0x63ad, 0x639d, 0x6397,
+  0x63ab, 0x638e, 0x636f, 0x6387, 0x6390, 0x636e, 0x63af, 0x6375,
+  0x639c, 0x636d, 0x63ae, 0x637c, 0x63a4, 0x633b, 0x639f, 0x6378,
+  0x6385, 0x6381, 0x6391, 0x638d, 0x6370, 0x6553, 0x65cd, 0x6665,
+  0x6661, 0x665b, 0x6659, 0x665c, 0x6662, 0x6718, 0x6879, 0x6887,
+  0x6890, 0x689c, 0x686d, 0x686e, 0x68ae, 0x68ab, 0x6956, 0x686f,
+  0x68a3, 0x68ac, 0x68a9, 0x6875, 0x6874, 0x68b2, 0x688f, 0x6877,
+  0x6892, 0x687c, 0x686b, 0x6872, 0x68aa, 0x6880, 0x6871, 0x687e,
+  0x689b, 0x6896, 0x688b, 0x68a0, 0x6889, 0x68a4, 0x6878, 0x687b,
+  0x6891, 0x688c, 0x688a, 0x687d, 0x6b36, 0x6b33, 0x6b37, 0x6b38,
+  0x6b91, 0x6b8f, 0x6b8d, 0x6b8e, 0x6b8c, 0x6c2a, 0x6dc0, 0x6dab,
+  0x6db4, 0x6db3, 0x6e74, 0x6dac, 0x6de9, 0x6de2, 0x6db7, 0x6df6,
+  0x6dd4, 0x6e00, 0x6dc8, 0x6de0, 0x6ddf, 0x6dd6, 0x6dbe, 0x6de5,
+  0x6ddc, 0x6ddd, 0x6ddb, 0x6df4, 0x6dca, 0x6dbd, 0x6ded, 0x6df0,
+  0x6dba, 0x6dd5, 0x6dc2, 0x6dcf, 0x6dc9,
+  /* 0xd6 */
+  0x6dd0, 0x6df2, 0x6dd3, 0x6dfd, 0x6dd7, 0x6dcd, 0x6de3, 0x6dbb,
+  0x70fa, 0x710d, 0x70f7, 0x7117, 0x70f4, 0x710c, 0x70f0, 0x7104,
+  0x70f3, 0x7110, 0x70fc, 0x70ff, 0x7106, 0x7113, 0x7100, 0x70f8,
+  0x70f6, 0x710b, 0x7102, 0x710e, 0x727e, 0x727b, 0x727c, 0x727f,
+  0x731d, 0x7317, 0x7307, 0x7311, 0x7318, 0x730a, 0x7308, 0x72ff,
+  0x730f, 0x731e, 0x7388, 0x73f6, 0x73f8, 0x73f5, 0x7404, 0x7401,
+  0x73fd, 0x7407, 0x7400, 0x73fa, 0x73fc, 0x73ff, 0x740c, 0x740b,
+  0x73f4, 0x7408, 0x7564, 0x7563, 0x75ce, 0x75d2, 0x75cf, 0x75cb,
+  0x75cc, 0x75d1, 0x75d0, 0x768f, 0x7689, 0x76d3, 0x7739, 0x772f,
+  0x772d, 0x7731, 0x7732, 0x7734, 0x7733, 0x773d, 0x7725, 0x773b,
+  0x7735, 0x7848, 0x7852, 0x7849, 0x784d, 0x784a, 0x784c, 0x7826,
+  0x7845, 0x7850, 0x7964, 0x7967, 0x7969, 0x796a, 0x7963, 0x796b,
+  0x7961, 0x79bb, 0x79fa, 0x79f8, 0x79f6, 0x79f7, 0x7a8f, 0x7a94,
+  0x7a90, 0x7b35, 0x7b47, 0x7b34, 0x7b25, 0x7b30, 0x7b22, 0x7b24,
+  0x7b33, 0x7b18, 0x7b2a, 0x7b1d, 0x7b31, 0x7b2b, 0x7b2d, 0x7b2f,
+  0x7b32, 0x7b38, 0x7b1a, 0x7b23, 0x7c94, 0x7c98, 0x7c96, 0x7ca3,
+  0x7d35, 0x7d3d, 0x7d38, 0x7d36, 0x7d3a, 0x7d45, 0x7d2c, 0x7d29,
+  0x7d41, 0x7d47, 0x7d3e, 0x7d3f, 0x7d4a, 0x7d3b, 0x7d28, 0x7f63,
+  0x7f95, 0x7f9c, 0x7f9d, 0x7f9b, 0x7fca, 0x7fcb, 0x7fcd, 0x7fd0,
+  0x7fd1, 0x7fc7, 0x7fcf, 0x7fc9, 0x801f,
+  /* 0xd7 */
+  0x801e, 0x801b, 0x8047, 0x8043, 0x8048, 0x8118, 0x8125, 0x8119,
+  0x811b, 0x812d, 0x811f, 0x812c, 0x811e, 0x8121, 0x8115, 0x8127,
+  0x811d, 0x8122, 0x8211, 0x8238, 0x8233, 0x823a, 0x8234, 0x8232,
+  0x8274, 0x8390, 0x83a3, 0x83a8, 0x838d, 0x837a, 0x8373, 0x83a4,
+  0x8374, 0x838f, 0x8381, 0x8395, 0x8399, 0x8375, 0x8394, 0x83a9,
+  0x837d, 0x8383, 0x838c, 0x839d, 0x839b, 0x83aa, 0x838b, 0x837e,
+  0x83a5, 0x83af, 0x8388, 0x8397, 0x83b0, 0x837f, 0x83a6, 0x8387,
+  0x83ae, 0x8376, 0x839a, 0x8659, 0x8656, 0x86bf, 0x86b7, 0x86c2,
+  0x86c1, 0x86c5, 0x86ba, 0x86b0, 0x86c8, 0x86b9, 0x86b3, 0x86b8,
+  0x86cc, 0x86b4, 0x86bb, 0x86bc, 0x86c3, 0x86bd, 0x86be, 0x8852,
+  0x8889, 0x8895, 0x88a8, 0x88a2, 0x88aa, 0x889a, 0x8891, 0x88a1,
+  0x889f, 0x8898, 0x88a7, 0x8899, 0x889b, 0x8897, 0x88a4, 0x88ac,
+  0x888c, 0x8893, 0x888e, 0x8982, 0x89d6, 0x89d9, 0x89d5, 0x8a30,
+  0x8a27, 0x8a2c, 0x8a1e, 0x8c39, 0x8c3b, 0x8c5c, 0x8c5d, 0x8c7d,
+  0x8ca5, 0x8d7d, 0x8d7b, 0x8d79, 0x8dbc, 0x8dc2, 0x8db9, 0x8dbf,
+  0x8dc1, 0x8ed8, 0x8ede, 0x8edd, 0x8edc, 0x8ed7, 0x8ee0, 0x8ee1,
+  0x9024, 0x900b, 0x9011, 0x901c, 0x900c, 0x9021, 0x90ef, 0x90ea,
+  0x90f0, 0x90f4, 0x90f2, 0x90f3, 0x90d4, 0x90eb, 0x90ec, 0x90e9,
+  0x9156, 0x9158, 0x915a, 0x9153, 0x9155, 0x91ec, 0x91f4, 0x91f1,
+  0x91f3, 0x91f8, 0x91e4, 0x91f9, 0x91ea,
+  /* 0xd8 */
+  0x91eb, 0x91f7, 0x91e8, 0x91ee, 0x957a, 0x9586, 0x9588, 0x967c,
+  0x966d, 0x966b, 0x9671, 0x966f, 0x96bf, 0x976a, 0x9804, 0x98e5,
+  0x9997, 0x509b, 0x5095, 0x5094, 0x509e, 0x508b, 0x50a3, 0x5083,
+  0x508c, 0x508e, 0x509d, 0x5068, 0x509c, 0x5092, 0x5082, 0x5087,
+  0x515f, 0x51d4, 0x5312, 0x5311, 0x53a4, 0x53a7, 0x5591, 0x55a8,
+  0x55a5, 0x55ad, 0x5577, 0x5645, 0x55a2, 0x5593, 0x5588, 0x558f,
+  0x55b5, 0x5581, 0x55a3, 0x5592, 0x55a4, 0x557d, 0x558c, 0x55a6,
+  0x557f, 0x5595, 0x55a1, 0x558e, 0x570c, 0x5829, 0x5837, 0x5819,
+  0x581e, 0x5827, 0x5823, 0x5828, 0x57f5, 0x5848, 0x5825, 0x581c,
+  0x581b, 0x5833, 0x583f, 0x5836, 0x582e, 0x5839, 0x5838, 0x582d,
+  0x582c, 0x583b, 0x5961, 0x5aaf, 0x5a94, 0x5a9f, 0x5a7a, 0x5aa2,
+  0x5a9e, 0x5a78, 0x5aa6, 0x5a7c, 0x5aa5, 0x5aac, 0x5a95, 0x5aae,
+  0x5a37, 0x5a84, 0x5a8a, 0x5a97, 0x5a83, 0x5a8b, 0x5aa9, 0x5a7b,
+  0x5a7d, 0x5a8c, 0x5a9c, 0x5a8f, 0x5a93, 0x5a9d, 0x5bea, 0x5bcd,
+  0x5bcb, 0x5bd4, 0x5bd1, 0x5bca, 0x5bce, 0x5c0c, 0x5c30, 0x5d37,
+  0x5d43, 0x5d6b, 0x5d41, 0x5d4b, 0x5d3f, 0x5d35, 0x5d51, 0x5d4e,
+  0x5d55, 0x5d33, 0x5d3a, 0x5d52, 0x5d3d, 0x5d31, 0x5d59, 0x5d42,
+  0x5d39, 0x5d49, 0x5d38, 0x5d3c, 0x5d32, 0x5d36, 0x5d40, 0x5d45,
+  0x5e44, 0x5e41, 0x5f58, 0x5fa6, 0x5fa5, 0x5fab, 0x60c9, 0x60b9,
+  0x60cc, 0x60e2, 0x60ce, 0x60c4, 0x6114,
+  /* 0xd9 */
+  0x60f2, 0x610a, 0x6116, 0x6105, 0x60f5, 0x6113, 0x60f8, 0x60fc,
+  0x60fe, 0x60c1, 0x6103, 0x6118, 0x611d, 0x6110, 0x60ff, 0x6104,
+  0x610b, 0x624a, 0x6394, 0x63b1, 0x63b0, 0x63ce, 0x63e5, 0x63e8,
+  0x63ef, 0x63c3, 0x649d, 0x63f3, 0x63ca, 0x63e0, 0x63f6, 0x63d5,
+  0x63f2, 0x63f5, 0x6461, 0x63df, 0x63be, 0x63dd, 0x63dc, 0x63c4,
+  0x63d8, 0x63d3, 0x63c2, 0x63c7, 0x63cc, 0x63cb, 0x63c8, 0x63f0,
+  0x63d7, 0x63d9, 0x6532, 0x6567, 0x656a, 0x6564, 0x655c, 0x6568,
+  0x6565, 0x658c, 0x659d, 0x659e, 0x65ae, 0x65d0, 0x65d2, 0x667c,
+  0x666c, 0x667b, 0x6680, 0x6671, 0x6679, 0x666a, 0x6672, 0x6701,
+  0x690c, 0x68d3, 0x6904, 0x68dc, 0x692a, 0x68ec, 0x68ea, 0x68f1,
+  0x690f, 0x68d6, 0x68f7, 0x68eb, 0x68e4, 0x68f6, 0x6913, 0x6910,
+  0x68f3, 0x68e1, 0x6907, 0x68cc, 0x6908, 0x6970, 0x68b4, 0x6911,
+  0x68ef, 0x68c6, 0x6914, 0x68f8, 0x68d0, 0x68fd, 0x68fc, 0x68e8,
+  0x690b, 0x690a, 0x6917, 0x68ce, 0x68c8, 0x68dd, 0x68de, 0x68e6,
+  0x68f4, 0x68d1, 0x6906, 0x68d4, 0x68e9, 0x6915, 0x6925, 0x68c7,
+  0x6b39, 0x6b3b, 0x6b3f, 0x6b3c, 0x6b94, 0x6b97, 0x6b99, 0x6b95,
+  0x6bbd, 0x6bf0, 0x6bf2, 0x6bf3, 0x6c30, 0x6dfc, 0x6e46, 0x6e47,
+  0x6e1f, 0x6e49, 0x6e88, 0x6e3c, 0x6e3d, 0x6e45, 0x6e62, 0x6e2b,
+  0x6e3f, 0x6e41, 0x6e5d, 0x6e73, 0x6e1c, 0x6e33, 0x6e4b, 0x6e40,
+  0x6e51, 0x6e3b, 0x6e03, 0x6e2e, 0x6e5e,
+  /* 0xda */
+  0x6e68, 0x6e5c, 0x6e61, 0x6e31, 0x6e28, 0x6e60, 0x6e71, 0x6e6b,
+  0x6e39, 0x6e22, 0x6e30, 0x6e53, 0x6e65, 0x6e27, 0x6e78, 0x6e64,
+  0x6e77, 0x6e55, 0x6e79, 0x6e52, 0x6e66, 0x6e35, 0x6e36, 0x6e5a,
+  0x7120, 0x711e, 0x712f, 0x70fb, 0x712e, 0x7131, 0x7123, 0x7125,
+  0x7122, 0x7132, 0x711f, 0x7128, 0x713a, 0x711b, 0x724b, 0x725a,
+  0x7288, 0x7289, 0x7286, 0x7285, 0x728b, 0x7312, 0x730b, 0x7330,
+  0x7322, 0x7331, 0x7333, 0x7327, 0x7332, 0x732d, 0x7326, 0x7323,
+  0x7335, 0x730c, 0x742e, 0x742c, 0x7430, 0x742b, 0x7416, 0x741a,
+  0x7421, 0x742d, 0x7431, 0x7424, 0x7423, 0x741d, 0x7429, 0x7420,
+  0x7432, 0x74fb, 0x752f, 0x756f, 0x756c, 0x75e7, 0x75da, 0x75e1,
+  0x75e6, 0x75dd, 0x75df, 0x75e4, 0x75d7, 0x7695, 0x7692, 0x76da,
+  0x7746, 0x7747, 0x7744, 0x774d, 0x7745, 0x774a, 0x774e, 0x774b,
+  0x774c, 0x77de, 0x77ec, 0x7860, 0x7864, 0x7865, 0x785c, 0x786d,
+  0x7871, 0x786a, 0x786e, 0x7870, 0x7869, 0x7868, 0x785e, 0x7862,
+  0x7974, 0x7973, 0x7972, 0x7970, 0x7a02, 0x7a0a, 0x7a03, 0x7a0c,
+  0x7a04, 0x7a99, 0x7ae6, 0x7ae4, 0x7b4a, 0x7b3b, 0x7b44, 0x7b48,
+  0x7b4c, 0x7b4e, 0x7b40, 0x7b58, 0x7b45, 0x7ca2, 0x7c9e, 0x7ca8,
+  0x7ca1, 0x7d58, 0x7d6f, 0x7d63, 0x7d53, 0x7d56, 0x7d67, 0x7d6a,
+  0x7d4f, 0x7d6d, 0x7d5c, 0x7d6b, 0x7d52, 0x7d54, 0x7d69, 0x7d51,
+  0x7d5f, 0x7d4e, 0x7f3e, 0x7f3f, 0x7f65,
+  /* 0xdb */
+  0x7f66, 0x7fa2, 0x7fa0, 0x7fa1, 0x7fd7, 0x8051, 0x804f, 0x8050,
+  0x80fe, 0x80d4, 0x8143, 0x814a, 0x8152, 0x814f, 0x8147, 0x813d,
+  0x814d, 0x813a, 0x81e6, 0x81ee, 0x81f7, 0x81f8, 0x81f9, 0x8204,
+  0x823c, 0x823d, 0x823f, 0x8275, 0x833b, 0x83cf, 0x83f9, 0x8423,
+  0x83c0, 0x83e8, 0x8412, 0x83e7, 0x83e4, 0x83fc, 0x83f6, 0x8410,
+  0x83c6, 0x83c8, 0x83eb, 0x83e3, 0x83bf, 0x8401, 0x83dd, 0x83e5,
+  0x83d8, 0x83ff, 0x83e1, 0x83cb, 0x83ce, 0x83d6, 0x83f5, 0x83c9,
+  0x8409, 0x840f, 0x83de, 0x8411, 0x8406, 0x83c2, 0x83f3, 0x83d5,
+  0x83fa, 0x83c7, 0x83d1, 0x83ea, 0x8413, 0x83c3, 0x83ec, 0x83ee,
+  0x83c4, 0x83fb, 0x83d7, 0x83e2, 0x841b, 0x83db, 0x83fe, 0x86d8,
+  0x86e2, 0x86e6, 0x86d3, 0x86e3, 0x86da, 0x86ea, 0x86dd, 0x86eb,
+  0x86dc, 0x86ec, 0x86e9, 0x86d7, 0x86e8, 0x86d1, 0x8848, 0x8856,
+  0x8855, 0x88ba, 0x88d7, 0x88b9, 0x88b8, 0x88c0, 0x88be, 0x88b6,
+  0x88bc, 0x88b7, 0x88bd, 0x88b2, 0x8901, 0x88c9, 0x8995, 0x8998,
+  0x8997, 0x89dd, 0x89da, 0x89db, 0x8a4e, 0x8a4d, 0x8a39, 0x8a59,
+  0x8a40, 0x8a57, 0x8a58, 0x8a44, 0x8a45, 0x8a52, 0x8a48, 0x8a51,
+  0x8a4a, 0x8a4c, 0x8a4f, 0x8c5f, 0x8c81, 0x8c80, 0x8cba, 0x8cbe,
+  0x8cb0, 0x8cb9, 0x8cb5, 0x8d84, 0x8d80, 0x8d89, 0x8dd8, 0x8dd3,
+  0x8dcd, 0x8dc7, 0x8dd6, 0x8ddc, 0x8dcf, 0x8dd5, 0x8dd9, 0x8dc8,
+  0x8dd7, 0x8dc5, 0x8eef, 0x8ef7, 0x8efa,
+  /* 0xdc */
+  0x8ef9, 0x8ee6, 0x8eee, 0x8ee5, 0x8ef5, 0x8ee7, 0x8ee8, 0x8ef6,
+  0x8eeb, 0x8ef1, 0x8eec, 0x8ef4, 0x8ee9, 0x902d, 0x9034, 0x902f,
+  0x9106, 0x912c, 0x9104, 0x90ff, 0x90fc, 0x9108, 0x90f9, 0x90fb,
+  0x9101, 0x9100, 0x9107, 0x9105, 0x9103, 0x9161, 0x9164, 0x915f,
+  0x9162, 0x9160, 0x9201, 0x920a, 0x9225, 0x9203, 0x921a, 0x9226,
+  0x920f, 0x920c, 0x9200, 0x9212, 0x91ff, 0x91fd, 0x9206, 0x9204,
+  0x9227, 0x9202, 0x921c, 0x9224, 0x9219, 0x9217, 0x9205, 0x9216,
+  0x957b, 0x958d, 0x958c, 0x9590, 0x9687, 0x967e, 0x9688, 0x9689,
+  0x9683, 0x9680, 0x96c2, 0x96c8, 0x96c3, 0x96f1, 0x96f0, 0x976c,
+  0x9770, 0x976e, 0x9807, 0x98a9, 0x98eb, 0x9ce6, 0x9ef9, 0x4e83,
+  0x4e84, 0x4eb6, 0x50bd, 0x50bf, 0x50c6, 0x50ae, 0x50c4, 0x50ca,
+  0x50b4, 0x50c8, 0x50c2, 0x50b0, 0x50c1, 0x50ba, 0x50b1, 0x50cb,
+  0x50c9, 0x50b6, 0x50b8, 0x51d7, 0x527a, 0x5278, 0x527b, 0x527c,
+  0x55c3, 0x55db, 0x55cc, 0x55d0, 0x55cb, 0x55ca, 0x55dd, 0x55c0,
+  0x55d4, 0x55c4, 0x55e9, 0x55bf, 0x55d2, 0x558d, 0x55cf, 0x55d5,
+  0x55e2, 0x55d6, 0x55c8, 0x55f2, 0x55cd, 0x55d9, 0x55c2, 0x5714,
+  0x5853, 0x5868, 0x5864, 0x584f, 0x584d, 0x5849, 0x586f, 0x5855,
+  0x584e, 0x585d, 0x5859, 0x5865, 0x585b, 0x583d, 0x5863, 0x5871,
+  0x58fc, 0x5ac7, 0x5ac4, 0x5acb, 0x5aba, 0x5ab8, 0x5ab1, 0x5ab5,
+  0x5ab0, 0x5abf, 0x5ac8, 0x5abb, 0x5ac6,
+  /* 0xdd */
+  0x5ab7, 0x5ac0, 0x5aca, 0x5ab4, 0x5ab6, 0x5acd, 0x5ab9, 0x5a90,
+  0x5bd6, 0x5bd8, 0x5bd9, 0x5c1f, 0x5c33, 0x5d71, 0x5d63, 0x5d4a,
+  0x5d65, 0x5d72, 0x5d6c, 0x5d5e, 0x5d68, 0x5d67, 0x5d62, 0x5df0,
+  0x5e4f, 0x5e4e, 0x5e4a, 0x5e4d, 0x5e4b, 0x5ec5, 0x5ecc, 0x5ec6,
+  0x5ecb, 0x5ec7, 0x5f40, 0x5faf, 0x5fad, 0x60f7, 0x6149, 0x614a,
+  0x612b, 0x6145, 0x6136, 0x6132, 0x612e, 0x6146, 0x612f, 0x614f,
+  0x6129, 0x6140, 0x6220, 0x9168, 0x6223, 0x6225, 0x6224, 0x63c5,
+  0x63f1, 0x63eb, 0x6410, 0x6412, 0x6409, 0x6420, 0x6424, 0x6433,
+  0x6443, 0x641f, 0x6415, 0x6418, 0x6439, 0x6437, 0x6422, 0x6423,
+  0x640c, 0x6426, 0x6430, 0x6428, 0x6441, 0x6435, 0x642f, 0x640a,
+  0x641a, 0x6440, 0x6425, 0x6427, 0x640b, 0x63e7, 0x641b, 0x642e,
+  0x6421, 0x640e, 0x656f, 0x6592, 0x65d3, 0x6686, 0x668c, 0x6695,
+  0x6690, 0x668b, 0x668a, 0x6699, 0x6694, 0x6678, 0x6720, 0x6966,
+  0x695f, 0x6938, 0x694e, 0x6962, 0x6971, 0x693f, 0x6945, 0x696a,
+  0x6939, 0x6942, 0x6957, 0x6959, 0x697a, 0x6948, 0x6949, 0x6935,
+  0x696c, 0x6933, 0x693d, 0x6965, 0x68f0, 0x6978, 0x6934, 0x6969,
+  0x6940, 0x696f, 0x6944, 0x6976, 0x6958, 0x6941, 0x6974, 0x694c,
+  0x693b, 0x694b, 0x6937, 0x695c, 0x694f, 0x6951, 0x6932, 0x6952,
+  0x692f, 0x697b, 0x693c, 0x6b46, 0x6b45, 0x6b43, 0x6b42, 0x6b48,
+  0x6b41, 0x6b9b, 0xfa0d, 0x6bfb, 0x6bfc,
+  /* 0xde */
+  0x6bf9, 0x6bf7, 0x6bf8, 0x6e9b, 0x6ed6, 0x6ec8, 0x6e8f, 0x6ec0,
+  0x6e9f, 0x6e93, 0x6e94, 0x6ea0, 0x6eb1, 0x6eb9, 0x6ec6, 0x6ed2,
+  0x6ebd, 0x6ec1, 0x6e9e, 0x6ec9, 0x6eb7, 0x6eb0, 0x6ecd, 0x6ea6,
+  0x6ecf, 0x6eb2, 0x6ebe, 0x6ec3, 0x6edc, 0x6ed8, 0x6e99, 0x6e92,
+  0x6e8e, 0x6e8d, 0x6ea4, 0x6ea1, 0x6ebf, 0x6eb3, 0x6ed0, 0x6eca,
+  0x6e97, 0x6eae, 0x6ea3, 0x7147, 0x7154, 0x7152, 0x7163, 0x7160,
+  0x7141, 0x715d, 0x7162, 0x7172, 0x7178, 0x716a, 0x7161, 0x7142,
+  0x7158, 0x7143, 0x714b, 0x7170, 0x715f, 0x7150, 0x7153, 0x7144,
+  0x714d, 0x715a, 0x724f, 0x728d, 0x728c, 0x7291, 0x7290, 0x728e,
+  0x733c, 0x7342, 0x733b, 0x733a, 0x7340, 0x734a, 0x7349, 0x7444,
+  0x744a, 0x744b, 0x7452, 0x7451, 0x7457, 0x7440, 0x744f, 0x7450,
+  0x744e, 0x7442, 0x7446, 0x744d, 0x7454, 0x74e1, 0x74ff, 0x74fe,
+  0x74fd, 0x751d, 0x7579, 0x7577, 0x6983, 0x75ef, 0x760f, 0x7603,
+  0x75f7, 0x75fe, 0x75fc, 0x75f9, 0x75f8, 0x7610, 0x75fb, 0x75f6,
+  0x75ed, 0x75f5, 0x75fd, 0x7699, 0x76b5, 0x76dd, 0x7755, 0x775f,
+  0x7760, 0x7752, 0x7756, 0x775a, 0x7769, 0x7767, 0x7754, 0x7759,
+  0x776d, 0x77e0, 0x7887, 0x789a, 0x7894, 0x788f, 0x7884, 0x7895,
+  0x7885, 0x7886, 0x78a1, 0x7883, 0x7879, 0x7899, 0x7880, 0x7896,
+  0x787b, 0x797c, 0x7982, 0x797d, 0x7979, 0x7a11, 0x7a18, 0x7a19,
+  0x7a12, 0x7a17, 0x7a15, 0x7a22, 0x7a13,
+  /* 0xdf */
+  0x7a1b, 0x7a10, 0x7aa3, 0x7aa2, 0x7a9e, 0x7aeb, 0x7b66, 0x7b64,
+  0x7b6d, 0x7b74, 0x7b69, 0x7b72, 0x7b65, 0x7b73, 0x7b71, 0x7b70,
+  0x7b61, 0x7b78, 0x7b76, 0x7b63, 0x7cb2, 0x7cb4, 0x7caf, 0x7d88,
+  0x7d86, 0x7d80, 0x7d8d, 0x7d7f, 0x7d85, 0x7d7a, 0x7d8e, 0x7d7b,
+  0x7d83, 0x7d7c, 0x7d8c, 0x7d94, 0x7d84, 0x7d7d, 0x7d92, 0x7f6d,
+  0x7f6b, 0x7f67, 0x7f68, 0x7f6c, 0x7fa6, 0x7fa5, 0x7fa7, 0x7fdb,
+  0x7fdc, 0x8021, 0x8164, 0x8160, 0x8177, 0x815c, 0x8169, 0x815b,
+  0x8162, 0x8172, 0x6721, 0x815e, 0x8176, 0x8167, 0x816f, 0x8144,
+  0x8161, 0x821d, 0x8249, 0x8244, 0x8240, 0x8242, 0x8245, 0x84f1,
+  0x843f, 0x8456, 0x8476, 0x8479, 0x848f, 0x848d, 0x8465, 0x8451,
+  0x8440, 0x8486, 0x8467, 0x8430, 0x844d, 0x847d, 0x845a, 0x8459,
+  0x8474, 0x8473, 0x845d, 0x8507, 0x845e, 0x8437, 0x843a, 0x8434,
+  0x847a, 0x8443, 0x8478, 0x8432, 0x8445, 0x8429, 0x83d9, 0x844b,
+  0x842f, 0x8442, 0x842d, 0x845f, 0x8470, 0x8439, 0x844e, 0x844c,
+  0x8452, 0x846f, 0x84c5, 0x848e, 0x843b, 0x8447, 0x8436, 0x8433,
+  0x8468, 0x847e, 0x8444, 0x842b, 0x8460, 0x8454, 0x846e, 0x8450,
+  0x870b, 0x8704, 0x86f7, 0x870c, 0x86fa, 0x86d6, 0x86f5, 0x874d,
+  0x86f8, 0x870e, 0x8709, 0x8701, 0x86f6, 0x870d, 0x8705, 0x88d6,
+  0x88cb, 0x88cd, 0x88ce, 0x88de, 0x88db, 0x88da, 0x88cc, 0x88d0,
+  0x8985, 0x899b, 0x89df, 0x89e5, 0x89e4,
+  /* 0xe0 */
+  0x89e1, 0x89e0, 0x89e2, 0x89dc, 0x89e6, 0x8a76, 0x8a86, 0x8a7f,
+  0x8a61, 0x8a3f, 0x8a77, 0x8a82, 0x8a84, 0x8a75, 0x8a83, 0x8a81,
+  0x8a74, 0x8a7a, 0x8c3c, 0x8c4b, 0x8c4a, 0x8c65, 0x8c64, 0x8c66,
+  0x8c86, 0x8c84, 0x8c85, 0x8ccc, 0x8d68, 0x8d69, 0x8d91, 0x8d8c,
+  0x8d8e, 0x8d8f, 0x8d8d, 0x8d93, 0x8d94, 0x8d90, 0x8d92, 0x8df0,
+  0x8de0, 0x8dec, 0x8df1, 0x8dee, 0x8dd0, 0x8de9, 0x8de3, 0x8de2,
+  0x8de7, 0x8df2, 0x8deb, 0x8df4, 0x8f06, 0x8eff, 0x8f01, 0x8f00,
+  0x8f05, 0x8f07, 0x8f08, 0x8f02, 0x8f0b, 0x9052, 0x903f, 0x9044,
+  0x9049, 0x903d, 0x9110, 0x910d, 0x910f, 0x9111, 0x9116, 0x9114,
+  0x910b, 0x910e, 0x916e, 0x916f, 0x9248, 0x9252, 0x9230, 0x923a,
+  0x9266, 0x9233, 0x9265, 0x925e, 0x9283, 0x922e, 0x924a, 0x9246,
+  0x926d, 0x926c, 0x924f, 0x9260, 0x9267, 0x926f, 0x9236, 0x9261,
+  0x9270, 0x9231, 0x9254, 0x9263, 0x9250, 0x9272, 0x924e, 0x9253,
+  0x924c, 0x9256, 0x9232, 0x959f, 0x959c, 0x959e, 0x959b, 0x9692,
+  0x9693, 0x9691, 0x9697, 0x96ce, 0x96fa, 0x96fd, 0x96f8, 0x96f5,
+  0x9773, 0x9777, 0x9778, 0x9772, 0x980f, 0x980d, 0x980e, 0x98ac,
+  0x98f6, 0x98f9, 0x99af, 0x99b2, 0x99b0, 0x99b5, 0x9aad, 0x9aab,
+  0x9b5b, 0x9cea, 0x9ced, 0x9ce7, 0x9e80, 0x9efd, 0x50e6, 0x50d4,
+  0x50d7, 0x50e8, 0x50f3, 0x50db, 0x50ea, 0x50dd, 0x50e4, 0x50d3,
+  0x50ec, 0x50f0, 0x50ef, 0x50e3, 0x50e0,
+  /* 0xe1 */
+  0x51d8, 0x5280, 0x5281, 0x52e9, 0x52eb, 0x5330, 0x53ac, 0x5627,
+  0x5615, 0x560c, 0x5612, 0x55fc, 0x560f, 0x561c, 0x5601, 0x5613,
+  0x5602, 0x55fa, 0x561d, 0x5604, 0x55ff, 0x55f9, 0x5889, 0x587c,
+  0x5890, 0x5898, 0x5886, 0x5881, 0x587f, 0x5874, 0x588b, 0x587a,
+  0x5887, 0x5891, 0x588e, 0x5876, 0x5882, 0x5888, 0x587b, 0x5894,
+  0x588f, 0x58fe, 0x596b, 0x5adc, 0x5aee, 0x5ae5, 0x5ad5, 0x5aea,
+  0x5ada, 0x5aed, 0x5aeb, 0x5af3, 0x5ae2, 0x5ae0, 0x5adb, 0x5aec,
+  0x5ade, 0x5add, 0x5ad9, 0x5ae8, 0x5adf, 0x5b77, 0x5be0, 0x5be3,
+  0x5c63, 0x5d82, 0x5d80, 0x5d7d, 0x5d86, 0x5d7a, 0x5d81, 0x5d77,
+  0x5d8a, 0x5d89, 0x5d88, 0x5d7e, 0x5d7c, 0x5d8d, 0x5d79, 0x5d7f,
+  0x5e58, 0x5e59, 0x5e53, 0x5ed8, 0x5ed1, 0x5ed7, 0x5ece, 0x5edc,
+  0x5ed5, 0x5ed9, 0x5ed2, 0x5ed4, 0x5f44, 0x5f43, 0x5f6f, 0x5fb6,
+  0x612c, 0x6128, 0x6141, 0x615e, 0x6171, 0x6173, 0x6152, 0x6153,
+  0x6172, 0x616c, 0x6180, 0x6174, 0x6154, 0x617a, 0x615b, 0x6165,
+  0x613b, 0x616a, 0x6161, 0x6156, 0x6229, 0x6227, 0x622b, 0x642b,
+  0x644d, 0x645b, 0x645d, 0x6474, 0x6476, 0x6472, 0x6473, 0x647d,
+  0x6475, 0x6466, 0x64a6, 0x644e, 0x6482, 0x645e, 0x645c, 0x644b,
+  0x6453, 0x6460, 0x6450, 0x647f, 0x643f, 0x646c, 0x646b, 0x6459,
+  0x6465, 0x6477, 0x6573, 0x65a0, 0x66a1, 0x66a0, 0x669f, 0x6705,
+  0x6704, 0x6722, 0x69b1, 0x69b6, 0x69c9,
+  /* 0xe2 */
+  0x69a0, 0x69ce, 0x6996, 0x69b0, 0x69ac, 0x69bc, 0x6991, 0x6999,
+  0x698e, 0x69a7, 0x698d, 0x69a9, 0x69be, 0x69af, 0x69bf, 0x69c4,
+  0x69bd, 0x69a4, 0x69d4, 0x69b9, 0x69ca, 0x699a, 0x69cf, 0x69b3,
+  0x6993, 0x69aa, 0x69a1, 0x699e, 0x69d9, 0x6997, 0x6990, 0x69c2,
+  0x69b5, 0x69a5, 0x69c6, 0x6b4a, 0x6b4d, 0x6b4b, 0x6b9e, 0x6b9f,
+  0x6ba0, 0x6bc3, 0x6bc4, 0x6bfe, 0x6ece, 0x6ef5, 0x6ef1, 0x6f03,
+  0x6f25, 0x6ef8, 0x6f37, 0x6efb, 0x6f2e, 0x6f09, 0x6f4e, 0x6f19,
+  0x6f1a, 0x6f27, 0x6f18, 0x6f3b, 0x6f12, 0x6eed, 0x6f0a, 0x6f36,
+  0x6f73, 0x6ef9, 0x6eee, 0x6f2d, 0x6f40, 0x6f30, 0x6f3c, 0x6f35,
+  0x6eeb, 0x6f07, 0x6f0e, 0x6f43, 0x6f05, 0x6efd, 0x6ef6, 0x6f39,
+  0x6f1c, 0x6efc, 0x6f3a, 0x6f1f, 0x6f0d, 0x6f1e, 0x6f08, 0x6f21,
+  0x7187, 0x7190, 0x7189, 0x7180, 0x7185, 0x7182, 0x718f, 0x717b,
+  0x7186, 0x7181, 0x7197, 0x7244, 0x7253, 0x7297, 0x7295, 0x7293,
+  0x7343, 0x734d, 0x7351, 0x734c, 0x7462, 0x7473, 0x7471, 0x7475,
+  0x7472, 0x7467, 0x746e, 0x7500, 0x7502, 0x7503, 0x757d, 0x7590,
+  0x7616, 0x7608, 0x760c, 0x7615, 0x7611, 0x760a, 0x7614, 0x76b8,
+  0x7781, 0x777c, 0x7785, 0x7782, 0x776e, 0x7780, 0x776f, 0x777e,
+  0x7783, 0x78b2, 0x78aa, 0x78b4, 0x78ad, 0x78a8, 0x787e, 0x78ab,
+  0x789e, 0x78a5, 0x78a0, 0x78ac, 0x78a2, 0x78a4, 0x7998, 0x798a,
+  0x798b, 0x7996, 0x7995, 0x7994, 0x7993,
+  /* 0xe3 */
+  0x7997, 0x7988, 0x7992, 0x7990, 0x7a2b, 0x7a4a, 0x7a30, 0x7a2f,
+  0x7a28, 0x7a26, 0x7aa8, 0x7aab, 0x7aac, 0x7aee, 0x7b88, 0x7b9c,
+  0x7b8a, 0x7b91, 0x7b90, 0x7b96, 0x7b8d, 0x7b8c, 0x7b9b, 0x7b8e,
+  0x7b85, 0x7b98, 0x5284, 0x7b99, 0x7ba4, 0x7b82, 0x7cbb, 0x7cbf,
+  0x7cbc, 0x7cba, 0x7da7, 0x7db7, 0x7dc2, 0x7da3, 0x7daa, 0x7dc1,
+  0x7dc0, 0x7dc5, 0x7d9d, 0x7dce, 0x7dc4, 0x7dc6, 0x7dcb, 0x7dcc,
+  0x7daf, 0x7db9, 0x7d96, 0x7dbc, 0x7d9f, 0x7da6, 0x7dae, 0x7da9,
+  0x7da1, 0x7dc9, 0x7f73, 0x7fe2, 0x7fe3, 0x7fe5, 0x7fde, 0x8024,
+  0x805d, 0x805c, 0x8189, 0x8186, 0x8183, 0x8187, 0x818d, 0x818c,
+  0x818b, 0x8215, 0x8497, 0x84a4, 0x84a1, 0x849f, 0x84ba, 0x84ce,
+  0x84c2, 0x84ac, 0x84ae, 0x84ab, 0x84b9, 0x84b4, 0x84c1, 0x84cd,
+  0x84aa, 0x849a, 0x84b1, 0x84d0, 0x849d, 0x84a7, 0x84bb, 0x84a2,
+  0x8494, 0x84c7, 0x84cc, 0x849b, 0x84a9, 0x84af, 0x84a8, 0x84d6,
+  0x8498, 0x84b6, 0x84cf, 0x84a0, 0x84d7, 0x84d4, 0x84d2, 0x84db,
+  0x84b0, 0x8491, 0x8661, 0x8733, 0x8723, 0x8728, 0x876b, 0x8740,
+  0x872e, 0x871e, 0x8721, 0x8719, 0x871b, 0x8743, 0x872c, 0x8741,
+  0x873e, 0x8746, 0x8720, 0x8732, 0x872a, 0x872d, 0x873c, 0x8712,
+  0x873a, 0x8731, 0x8735, 0x8742, 0x8726, 0x8727, 0x8738, 0x8724,
+  0x871a, 0x8730, 0x8711, 0x88f7, 0x88e7, 0x88f1, 0x88f2, 0x88fa,
+  0x88fe, 0x88ee, 0x88fc, 0x88f6, 0x88fb,
+  /* 0xe4 */
+  0x88f0, 0x88ec, 0x88eb, 0x899d, 0x89a1, 0x899f, 0x899e, 0x89e9,
+  0x89eb, 0x89e8, 0x8aab, 0x8a99, 0x8a8b, 0x8a92, 0x8a8f, 0x8a96,
+  0x8c3d, 0x8c68, 0x8c69, 0x8cd5, 0x8ccf, 0x8cd7, 0x8d96, 0x8e09,
+  0x8e02, 0x8dff, 0x8e0d, 0x8dfd, 0x8e0a, 0x8e03, 0x8e07, 0x8e06,
+  0x8e05, 0x8dfe, 0x8e00, 0x8e04, 0x8f10, 0x8f11, 0x8f0e, 0x8f0d,
+  0x9123, 0x911c, 0x9120, 0x9122, 0x911f, 0x911d, 0x911a, 0x9124,
+  0x9121, 0x911b, 0x917a, 0x9172, 0x9179, 0x9173, 0x92a5, 0x92a4,
+  0x9276, 0x929b, 0x927a, 0x92a0, 0x9294, 0x92aa, 0x928d, 0x92a6,
+  0x929a, 0x92ab, 0x9279, 0x9297, 0x927f, 0x92a3, 0x92ee, 0x928e,
+  0x9282, 0x9295, 0x92a2, 0x927d, 0x9288, 0x92a1, 0x928a, 0x9286,
+  0x928c, 0x9299, 0x92a7, 0x927e, 0x9287, 0x92a9, 0x929d, 0x928b,
+  0x922d, 0x969e, 0x96a1, 0x96ff, 0x9758, 0x977d, 0x977a, 0x977e,
+  0x9783, 0x9780, 0x9782, 0x977b, 0x9784, 0x9781, 0x977f, 0x97ce,
+  0x97cd, 0x9816, 0x98ad, 0x98ae, 0x9902, 0x9900, 0x9907, 0x999d,
+  0x999c, 0x99c3, 0x99b9, 0x99bb, 0x99ba, 0x99c2, 0x99bd, 0x99c7,
+  0x9ab1, 0x9ae3, 0x9ae7, 0x9b3e, 0x9b3f, 0x9b60, 0x9b61, 0x9b5f,
+  0x9cf1, 0x9cf2, 0x9cf5, 0x9ea7, 0x50ff, 0x5103, 0x5130, 0x50f8,
+  0x5106, 0x5107, 0x50f6, 0x50fe, 0x510b, 0x510c, 0x50fd, 0x510a,
+  0x528b, 0x528c, 0x52f1, 0x52ef, 0x5648, 0x5642, 0x564c, 0x5635,
+  0x5641, 0x564a, 0x5649, 0x5646, 0x5658,
+  /* 0xe5 */
+  0x565a, 0x5640, 0x5633, 0x563d, 0x562c, 0x563e, 0x5638, 0x562a,
+  0x563a, 0x571a, 0x58ab, 0x589d, 0x58b1, 0x58a0, 0x58a3, 0x58af,
+  0x58ac, 0x58a5, 0x58a1, 0x58ff, 0x5aff, 0x5af4, 0x5afd, 0x5af7,
+  0x5af6, 0x5b03, 0x5af8, 0x5b02, 0x5af9, 0x5b01, 0x5b07, 0x5b05,
+  0x5b0f, 0x5c67, 0x5d99, 0x5d97, 0x5d9f, 0x5d92, 0x5da2, 0x5d93,
+  0x5d95, 0x5da0, 0x5d9c, 0x5da1, 0x5d9a, 0x5d9e, 0x5e69, 0x5e5d,
+  0x5e60, 0x5e5c, 0x7df3, 0x5edb, 0x5ede, 0x5ee1, 0x5f49, 0x5fb2,
+  0x618b, 0x6183, 0x6179, 0x61b1, 0x61b0, 0x61a2, 0x6189, 0x619b,
+  0x6193, 0x61af, 0x61ad, 0x619f, 0x6192, 0x61aa, 0x61a1, 0x618d,
+  0x6166, 0x61b3, 0x622d, 0x646e, 0x6470, 0x6496, 0x64a0, 0x6485,
+  0x6497, 0x649c, 0x648f, 0x648b, 0x648a, 0x648c, 0x64a3, 0x649f,
+  0x6468, 0x64b1, 0x6498, 0x6576, 0x657a, 0x6579, 0x657b, 0x65b2,
+  0x65b3, 0x66b5, 0x66b0, 0x66a9, 0x66b2, 0x66b7, 0x66aa, 0x66af,
+  0x6a00, 0x6a06, 0x6a17, 0x69e5, 0x69f8, 0x6a15, 0x69f1, 0x69e4,
+  0x6a20, 0x69ff, 0x69ec, 0x69e2, 0x6a1b, 0x6a1d, 0x69fe, 0x6a27,
+  0x69f2, 0x69ee, 0x6a14, 0x69f7, 0x69e7, 0x6a40, 0x6a08, 0x69e6,
+  0x69fb, 0x6a0d, 0x69fc, 0x69eb, 0x6a09, 0x6a04, 0x6a18, 0x6a25,
+  0x6a0f, 0x69f6, 0x6a26, 0x6a07, 0x69f4, 0x6a16, 0x6b51, 0x6ba5,
+  0x6ba3, 0x6ba2, 0x6ba6, 0x6c01, 0x6c00, 0x6bff, 0x6c02, 0x6f41,
+  0x6f26, 0x6f7e, 0x6f87, 0x6fc6, 0x6f92,
+  /* 0xe6 */
+  0x6f8d, 0x6f89, 0x6f8c, 0x6f62, 0x6f4f, 0x6f85, 0x6f5a, 0x6f96,
+  0x6f76, 0x6f6c, 0x6f82, 0x6f55, 0x6f72, 0x6f52, 0x6f50, 0x6f57,
+  0x6f94, 0x6f93, 0x6f5d, 0x6f00, 0x6f61, 0x6f6b, 0x6f7d, 0x6f67,
+  0x6f90, 0x6f53, 0x6f8b, 0x6f69, 0x6f7f, 0x6f95, 0x6f63, 0x6f77,
+  0x6f6a, 0x6f7b, 0x71b2, 0x71af, 0x719b, 0x71b0, 0x71a0, 0x719a,
+  0x71a9, 0x71b5, 0x719d, 0x71a5, 0x719e, 0x71a4, 0x71a1, 0x71aa,
+  0x719c, 0x71a7, 0x71b3, 0x7298, 0x729a, 0x7358, 0x7352, 0x735e,
+  0x735f, 0x7360, 0x735d, 0x735b, 0x7361, 0x735a, 0x7359, 0x7362,
+  0x7487, 0x7489, 0x748a, 0x7486, 0x7481, 0x747d, 0x7485, 0x7488,
+  0x747c, 0x7479, 0x7508, 0x7507, 0x757e, 0x7625, 0x761e, 0x7619,
+  0x761d, 0x761c, 0x7623, 0x761a, 0x7628, 0x761b, 0x769c, 0x769d,
+  0x769e, 0x769b, 0x778d, 0x778f, 0x7789, 0x7788, 0x78cd, 0x78bb,
+  0x78cf, 0x78cc, 0x78d1, 0x78ce, 0x78d4, 0x78c8, 0x78c3, 0x78c4,
+  0x78c9, 0x799a, 0x79a1, 0x79a0, 0x799c, 0x79a2, 0x799b, 0x6b76,
+  0x7a39, 0x7ab2, 0x7ab4, 0x7ab3, 0x7bb7, 0x7bcb, 0x7bbe, 0x7bac,
+  0x7bce, 0x7baf, 0x7bb9, 0x7bca, 0x7bb5, 0x7cc5, 0x7cc8, 0x7ccc,
+  0x7ccb, 0x7df7, 0x7ddb, 0x7dea, 0x7de7, 0x7dd7, 0x7de1, 0x7e03,
+  0x7dfa, 0x7de6, 0x7df6, 0x7df1, 0x7df0, 0x7dee, 0x7ddf, 0x7f76,
+  0x7fac, 0x7fb0, 0x7fad, 0x7fed, 0x7feb, 0x7fea, 0x7fec, 0x7fe6,
+  0x7fe8, 0x8064, 0x8067, 0x81a3, 0x819f,
+  /* 0xe7 */
+  0x819e, 0x8195, 0x81a2, 0x8199, 0x8197, 0x8216, 0x824f, 0x8253,
+  0x8252, 0x8250, 0x824e, 0x8251, 0x8524, 0x853b, 0x850f, 0x8500,
+  0x8529, 0x850e, 0x8509, 0x850d, 0x851f, 0x850a, 0x8527, 0x851c,
+  0x84fb, 0x852b, 0x84fa, 0x8508, 0x850c, 0x84f4, 0x852a, 0x84f2,
+  0x8515, 0x84f7, 0x84eb, 0x84f3, 0x84fc, 0x8512, 0x84ea, 0x84e9,
+  0x8516, 0x84fe, 0x8528, 0x851d, 0x852e, 0x8502, 0x84fd, 0x851e,
+  0x84f6, 0x8531, 0x8526, 0x84e7, 0x84e8, 0x84f0, 0x84ef, 0x84f9,
+  0x8518, 0x8520, 0x8530, 0x850b, 0x8519, 0x852f, 0x8662, 0x8756,
+  0x8763, 0x8764, 0x8777, 0x87e1, 0x8773, 0x8758, 0x8754, 0x875b,
+  0x8752, 0x8761, 0x875a, 0x8751, 0x875e, 0x876d, 0x876a, 0x8750,
+  0x874e, 0x875f, 0x875d, 0x876f, 0x876c, 0x877a, 0x876e, 0x875c,
+  0x8765, 0x874f, 0x877b, 0x8775, 0x8762, 0x8767, 0x8769, 0x885a,
+  0x8905, 0x890c, 0x8914, 0x890b, 0x8917, 0x8918, 0x8919, 0x8906,
+  0x8916, 0x8911, 0x890e, 0x8909, 0x89a2, 0x89a4, 0x89a3, 0x89ed,
+  0x89f0, 0x89ec, 0x8acf, 0x8ac6, 0x8ab8, 0x8ad3, 0x8ad1, 0x8ad4,
+  0x8ad5, 0x8abb, 0x8ad7, 0x8abe, 0x8ac0, 0x8ac5, 0x8ad8, 0x8ac3,
+  0x8aba, 0x8abd, 0x8ad9, 0x8c3e, 0x8c4d, 0x8c8f, 0x8ce5, 0x8cdf,
+  0x8cd9, 0x8ce8, 0x8cda, 0x8cdd, 0x8ce7, 0x8da0, 0x8d9c, 0x8da1,
+  0x8d9b, 0x8e20, 0x8e23, 0x8e25, 0x8e24, 0x8e2e, 0x8e15, 0x8e1b,
+  0x8e16, 0x8e11, 0x8e19, 0x8e26, 0x8e27,
+  /* 0xe8 */
+  0x8e14, 0x8e12, 0x8e18, 0x8e13, 0x8e1c, 0x8e17, 0x8e1a, 0x8f2c,
+  0x8f24, 0x8f18, 0x8f1a, 0x8f20, 0x8f23, 0x8f16, 0x8f17, 0x9073,
+  0x9070, 0x906f, 0x9067, 0x906b, 0x912f, 0x912b, 0x9129, 0x912a,
+  0x9132, 0x9126, 0x912e, 0x9185, 0x9186, 0x918a, 0x9181, 0x9182,
+  0x9184, 0x9180, 0x92d0, 0x92c3, 0x92c4, 0x92c0, 0x92d9, 0x92b6,
+  0x92cf, 0x92f1, 0x92df, 0x92d8, 0x92e9, 0x92d7, 0x92dd, 0x92cc,
+  0x92ef, 0x92c2, 0x92e8, 0x92ca, 0x92c8, 0x92ce, 0x92e6, 0x92cd,
+  0x92d5, 0x92c9, 0x92e0, 0x92de, 0x92e7, 0x92d1, 0x92d3, 0x92b5,
+  0x92e1, 0x92c6, 0x92b4, 0x957c, 0x95ac, 0x95ab, 0x95ae, 0x95b0,
+  0x96a4, 0x96a2, 0x96d3, 0x9705, 0x9708, 0x9702, 0x975a, 0x978a,
+  0x978e, 0x9788, 0x97d0, 0x97cf, 0x981e, 0x981d, 0x9826, 0x9829,
+  0x9828, 0x9820, 0x981b, 0x9827, 0x98b2, 0x9908, 0x98fa, 0x9911,
+  0x9914, 0x9916, 0x9917, 0x9915, 0x99dc, 0x99cd, 0x99cf, 0x99d3,
+  0x99d4, 0x99ce, 0x99c9, 0x99d6, 0x99d8, 0x99cb, 0x99d7, 0x99cc,
+  0x9ab3, 0x9aec, 0x9aeb, 0x9af3, 0x9af2, 0x9af1, 0x9b46, 0x9b43,
+  0x9b67, 0x9b74, 0x9b71, 0x9b66, 0x9b76, 0x9b75, 0x9b70, 0x9b68,
+  0x9b64, 0x9b6c, 0x9cfc, 0x9cfa, 0x9cfd, 0x9cff, 0x9cf7, 0x9d07,
+  0x9d00, 0x9cf9, 0x9cfb, 0x9d08, 0x9d05, 0x9d04, 0x9e83, 0x9ed3,
+  0x9f0f, 0x9f10, 0x511c, 0x5113, 0x5117, 0x511a, 0x5111, 0x51de,
+  0x5334, 0x53e1, 0x5670, 0x5660, 0x566e,
+  /* 0xe9 */
+  0x5673, 0x5666, 0x5663, 0x566d, 0x5672, 0x565e, 0x5677, 0x571c,
+  0x571b, 0x58c8, 0x58bd, 0x58c9, 0x58bf, 0x58ba, 0x58c2, 0x58bc,
+  0x58c6, 0x5b17, 0x5b19, 0x5b1b, 0x5b21, 0x5b14, 0x5b13, 0x5b10,
+  0x5b16, 0x5b28, 0x5b1a, 0x5b20, 0x5b1e, 0x5bef, 0x5dac, 0x5db1,
+  0x5da9, 0x5da7, 0x5db5, 0x5db0, 0x5dae, 0x5daa, 0x5da8, 0x5db2,
+  0x5dad, 0x5daf, 0x5db4, 0x5e67, 0x5e68, 0x5e66, 0x5e6f, 0x5ee9,
+  0x5ee7, 0x5ee6, 0x5ee8, 0x5ee5, 0x5f4b, 0x5fbc, 0x619d, 0x61a8,
+  0x6196, 0x61c5, 0x61b4, 0x61c6, 0x61c1, 0x61cc, 0x61ba, 0x61bf,
+  0x61b8, 0x618c, 0x64d7, 0x64d6, 0x64d0, 0x64cf, 0x64c9, 0x64bd,
+  0x6489, 0x64c3, 0x64db, 0x64f3, 0x64d9, 0x6533, 0x657f, 0x657c,
+  0x65a2, 0x66c8, 0x66be, 0x66c0, 0x66ca, 0x66cb, 0x66cf, 0x66bd,
+  0x66bb, 0x66ba, 0x66cc, 0x6723, 0x6a34, 0x6a66, 0x6a49, 0x6a67,
+  0x6a32, 0x6a68, 0x6a3e, 0x6a5d, 0x6a6d, 0x6a76, 0x6a5b, 0x6a51,
+  0x6a28, 0x6a5a, 0x6a3b, 0x6a3f, 0x6a41, 0x6a6a, 0x6a64, 0x6a50,
+  0x6a4f, 0x6a54, 0x6a6f, 0x6a69, 0x6a60, 0x6a3c, 0x6a5e, 0x6a56,
+  0x6a55, 0x6a4d, 0x6a4e, 0x6a46, 0x6b55, 0x6b54, 0x6b56, 0x6ba7,
+  0x6baa, 0x6bab, 0x6bc8, 0x6bc7, 0x6c04, 0x6c03, 0x6c06, 0x6fad,
+  0x6fcb, 0x6fa3, 0x6fc7, 0x6fbc, 0x6fce, 0x6fc8, 0x6f5e, 0x6fc4,
+  0x6fbd, 0x6f9e, 0x6fca, 0x6fa8, 0x7004, 0x6fa5, 0x6fae, 0x6fba,
+  0x6fac, 0x6faa, 0x6fcf, 0x6fbf, 0x6fb8,
+  /* 0xea */
+  0x6fa2, 0x6fc9, 0x6fab, 0x6fcd, 0x6faf, 0x6fb2, 0x6fb0, 0x71c5,
+  0x71c2, 0x71bf, 0x71b8, 0x71d6, 0x71c0, 0x71c1, 0x71cb, 0x71d4,
+  0x71ca, 0x71c7, 0x71cf, 0x71bd, 0x71d8, 0x71bc, 0x71c6, 0x71da,
+  0x71db, 0x729d, 0x729e, 0x7369, 0x7366, 0x7367, 0x736c, 0x7365,
+  0x736b, 0x736a, 0x747f, 0x749a, 0x74a0, 0x7494, 0x7492, 0x7495,
+  0x74a1, 0x750b, 0x7580, 0x762f, 0x762d, 0x7631, 0x763d, 0x7633,
+  0x763c, 0x7635, 0x7632, 0x7630, 0x76bb, 0x76e6, 0x779a, 0x779d,
+  0x77a1, 0x779c, 0x779b, 0x77a2, 0x77a3, 0x7795, 0x7799, 0x7797,
+  0x78dd, 0x78e9, 0x78e5, 0x78ea, 0x78de, 0x78e3, 0x78db, 0x78e1,
+  0x78e2, 0x78ed, 0x78df, 0x78e0, 0x79a4, 0x7a44, 0x7a48, 0x7a47,
+  0x7ab6, 0x7ab8, 0x7ab5, 0x7ab1, 0x7ab7, 0x7bde, 0x7be3, 0x7be7,
+  0x7bdd, 0x7bd5, 0x7be5, 0x7bda, 0x7be8, 0x7bf9, 0x7bd4, 0x7bea,
+  0x7be2, 0x7bdc, 0x7beb, 0x7bd8, 0x7bdf, 0x7cd2, 0x7cd4, 0x7cd7,
+  0x7cd0, 0x7cd1, 0x7e12, 0x7e21, 0x7e17, 0x7e0c, 0x7e1f, 0x7e20,
+  0x7e13, 0x7e0e, 0x7e1c, 0x7e15, 0x7e1a, 0x7e22, 0x7e0b, 0x7e0f,
+  0x7e16, 0x7e0d, 0x7e14, 0x7e25, 0x7e24, 0x7f43, 0x7f7b, 0x7f7c,
+  0x7f7a, 0x7fb1, 0x7fef, 0x802a, 0x8029, 0x806c, 0x81b1, 0x81a6,
+  0x81ae, 0x81b9, 0x81b5, 0x81ab, 0x81b0, 0x81ac, 0x81b4, 0x81b2,
+  0x81b7, 0x81a7, 0x81f2, 0x8255, 0x8256, 0x8257, 0x8556, 0x8545,
+  0x856b, 0x854d, 0x8553, 0x8561, 0x8558,
+  /* 0xeb */
+  0x8540, 0x8546, 0x8564, 0x8541, 0x8562, 0x8544, 0x8551, 0x8547,
+  0x8563, 0x853e, 0x855b, 0x8571, 0x854e, 0x856e, 0x8575, 0x8555,
+  0x8567, 0x8560, 0x858c, 0x8566, 0x855d, 0x8554, 0x8565, 0x856c,
+  0x8663, 0x8665, 0x8664, 0x879b, 0x878f, 0x8797, 0x8793, 0x8792,
+  0x8788, 0x8781, 0x8796, 0x8798, 0x8779, 0x8787, 0x87a3, 0x8785,
+  0x8790, 0x8791, 0x879d, 0x8784, 0x8794, 0x879c, 0x879a, 0x8789,
+  0x891e, 0x8926, 0x8930, 0x892d, 0x892e, 0x8927, 0x8931, 0x8922,
+  0x8929, 0x8923, 0x892f, 0x892c, 0x891f, 0x89f1, 0x8ae0, 0x8ae2,
+  0x8af2, 0x8af4, 0x8af5, 0x8add, 0x8b14, 0x8ae4, 0x8adf, 0x8af0,
+  0x8ac8, 0x8ade, 0x8ae1, 0x8ae8, 0x8aff, 0x8aef, 0x8afb, 0x8c91,
+  0x8c92, 0x8c90, 0x8cf5, 0x8cee, 0x8cf1, 0x8cf0, 0x8cf3, 0x8d6c,
+  0x8d6e, 0x8da5, 0x8da7, 0x8e33, 0x8e3e, 0x8e38, 0x8e40, 0x8e45,
+  0x8e36, 0x8e3c, 0x8e3d, 0x8e41, 0x8e30, 0x8e3f, 0x8ebd, 0x8f36,
+  0x8f2e, 0x8f35, 0x8f32, 0x8f39, 0x8f37, 0x8f34, 0x9076, 0x9079,
+  0x907b, 0x9086, 0x90fa, 0x9133, 0x9135, 0x9136, 0x9193, 0x9190,
+  0x9191, 0x918d, 0x918f, 0x9327, 0x931e, 0x9308, 0x931f, 0x9306,
+  0x930f, 0x937a, 0x9338, 0x933c, 0x931b, 0x9323, 0x9312, 0x9301,
+  0x9346, 0x932d, 0x930e, 0x930d, 0x92cb, 0x931d, 0x92fa, 0x9325,
+  0x9313, 0x92f9, 0x92f7, 0x9334, 0x9302, 0x9324, 0x92ff, 0x9329,
+  0x9339, 0x9335, 0x932a, 0x9314, 0x930c,
+  /* 0xec */
+  0x930b, 0x92fe, 0x9309, 0x9300, 0x92fb, 0x9316, 0x95bc, 0x95cd,
+  0x95be, 0x95b9, 0x95ba, 0x95b6, 0x95bf, 0x95b5, 0x95bd, 0x96a9,
+  0x96d4, 0x970b, 0x9712, 0x9710, 0x9799, 0x9797, 0x9794, 0x97f0,
+  0x97f8, 0x9835, 0x982f, 0x9832, 0x9924, 0x991f, 0x9927, 0x9929,
+  0x999e, 0x99ee, 0x99ec, 0x99e5, 0x99e4, 0x99f0, 0x99e3, 0x99ea,
+  0x99e9, 0x99e7, 0x9ab9, 0x9abf, 0x9ab4, 0x9abb, 0x9af6, 0x9afa,
+  0x9af9, 0x9af7, 0x9b33, 0x9b80, 0x9b85, 0x9b87, 0x9b7c, 0x9b7e,
+  0x9b7b, 0x9b82, 0x9b93, 0x9b92, 0x9b90, 0x9b7a, 0x9b95, 0x9b7d,
+  0x9b88, 0x9d25, 0x9d17, 0x9d20, 0x9d1e, 0x9d14, 0x9d29, 0x9d1d,
+  0x9d18, 0x9d22, 0x9d10, 0x9d19, 0x9d1f, 0x9e88, 0x9e86, 0x9e87,
+  0x9eae, 0x9ead, 0x9ed5, 0x9ed6, 0x9efa, 0x9f12, 0x9f3d, 0x5126,
+  0x5125, 0x5122, 0x5124, 0x5120, 0x5129, 0x52f4, 0x5693, 0x568c,
+  0x568d, 0x5686, 0x5684, 0x5683, 0x567e, 0x5682, 0x567f, 0x5681,
+  0x58d6, 0x58d4, 0x58cf, 0x58d2, 0x5b2d, 0x5b25, 0x5b32, 0x5b23,
+  0x5b2c, 0x5b27, 0x5b26, 0x5b2f, 0x5b2e, 0x5b7b, 0x5bf1, 0x5bf2,
+  0x5db7, 0x5e6c, 0x5e6a, 0x5fbe, 0x5fbb, 0x61c3, 0x61b5, 0x61bc,
+  0x61e7, 0x61e0, 0x61e5, 0x61e4, 0x61e8, 0x61de, 0x64ef, 0x64e9,
+  0x64e3, 0x64eb, 0x64e4, 0x64e8, 0x6581, 0x6580, 0x65b6, 0x65da,
+  0x66d2, 0x6a8d, 0x6a96, 0x6a81, 0x6aa5, 0x6a89, 0x6a9f, 0x6a9b,
+  0x6aa1, 0x6a9e, 0x6a87, 0x6a93, 0x6a8e,
+  /* 0xed */
+  0x6a95, 0x6a83, 0x6aa8, 0x6aa4, 0x6a91, 0x6a7f, 0x6aa6, 0x6a9a,
+  0x6a85, 0x6a8c, 0x6a92, 0x6b5b, 0x6bad, 0x6c09, 0x6fcc, 0x6fa9,
+  0x6ff4, 0x6fd4, 0x6fe3, 0x6fdc, 0x6fed, 0x6fe7, 0x6fe6, 0x6fde,
+  0x6ff2, 0x6fdd, 0x6fe2, 0x6fe8, 0x71e1, 0x71f1, 0x71e8, 0x71f2,
+  0x71e4, 0x71f0, 0x71e2, 0x7373, 0x736e, 0x736f, 0x7497, 0x74b2,
+  0x74ab, 0x7490, 0x74aa, 0x74ad, 0x74b1, 0x74a5, 0x74af, 0x7510,
+  0x7511, 0x7512, 0x750f, 0x7584, 0x7643, 0x7648, 0x7649, 0x7647,
+  0x76a4, 0x76e9, 0x77b5, 0x77ab, 0x77b2, 0x77b7, 0x77b6, 0x77b4,
+  0x77b1, 0x77a8, 0x77f0, 0x78f3, 0x78fd, 0x7902, 0x78fb, 0x78fc,
+  0x78f2, 0x7905, 0x78f9, 0x78fe, 0x7904, 0x79ab, 0x79a8, 0x7a5c,
+  0x7a5b, 0x7a56, 0x7a58, 0x7a54, 0x7a5a, 0x7abe, 0x7ac0, 0x7ac1,
+  0x7c05, 0x7c0f, 0x7bf2, 0x7c00, 0x7bff, 0x7bfb, 0x7c0e, 0x7bf4,
+  0x7c0b, 0x7bf3, 0x7c02, 0x7c09, 0x7c03, 0x7c01, 0x7bf8, 0x7bfd,
+  0x7c06, 0x7bf0, 0x7bf1, 0x7c10, 0x7c0a, 0x7ce8, 0x7e2d, 0x7e3c,
+  0x7e42, 0x7e33, 0x9848, 0x7e38, 0x7e2a, 0x7e49, 0x7e40, 0x7e47,
+  0x7e29, 0x7e4c, 0x7e30, 0x7e3b, 0x7e36, 0x7e44, 0x7e3a, 0x7f45,
+  0x7f7f, 0x7f7e, 0x7f7d, 0x7ff4, 0x7ff2, 0x802c, 0x81bb, 0x81c4,
+  0x81cc, 0x81ca, 0x81c5, 0x81c7, 0x81bc, 0x81e9, 0x825b, 0x825a,
+  0x825c, 0x8583, 0x8580, 0x858f, 0x85a7, 0x8595, 0x85a0, 0x858b,
+  0x85a3, 0x857b, 0x85a4, 0x859a, 0x859e,
+  /* 0xee */
+  0x8577, 0x857c, 0x8589, 0x85a1, 0x857a, 0x8578, 0x8557, 0x858e,
+  0x8596, 0x8586, 0x858d, 0x8599, 0x859d, 0x8581, 0x85a2, 0x8582,
+  0x8588, 0x8585, 0x8579, 0x8576, 0x8598, 0x8590, 0x859f, 0x8668,
+  0x87be, 0x87aa, 0x87ad, 0x87c5, 0x87b0, 0x87ac, 0x87b9, 0x87b5,
+  0x87bc, 0x87ae, 0x87c9, 0x87c3, 0x87c2, 0x87cc, 0x87b7, 0x87af,
+  0x87c4, 0x87ca, 0x87b4, 0x87b6, 0x87bf, 0x87b8, 0x87bd, 0x87de,
+  0x87b2, 0x8935, 0x8933, 0x893c, 0x893e, 0x8941, 0x8952, 0x8937,
+  0x8942, 0x89ad, 0x89af, 0x89ae, 0x89f2, 0x89f3, 0x8b1e, 0x8b18,
+  0x8b16, 0x8b11, 0x8b05, 0x8b0b, 0x8b22, 0x8b0f, 0x8b12, 0x8b15,
+  0x8b07, 0x8b0d, 0x8b08, 0x8b06, 0x8b1c, 0x8b13, 0x8b1a, 0x8c4f,
+  0x8c70, 0x8c72, 0x8c71, 0x8c6f, 0x8c95, 0x8c94, 0x8cf9, 0x8d6f,
+  0x8e4e, 0x8e4d, 0x8e53, 0x8e50, 0x8e4c, 0x8e47, 0x8f43, 0x8f40,
+  0x9085, 0x907e, 0x9138, 0x919a, 0x91a2, 0x919b, 0x9199, 0x919f,
+  0x91a1, 0x919d, 0x91a0, 0x93a1, 0x9383, 0x93af, 0x9364, 0x9356,
+  0x9347, 0x937c, 0x9358, 0x935c, 0x9376, 0x9349, 0x9350, 0x9351,
+  0x9360, 0x936d, 0x938f, 0x934c, 0x936a, 0x9379, 0x9357, 0x9355,
+  0x9352, 0x934f, 0x9371, 0x9377, 0x937b, 0x9361, 0x935e, 0x9363,
+  0x9367, 0x9380, 0x934e, 0x9359, 0x95c7, 0x95c0, 0x95c9, 0x95c3,
+  0x95c5, 0x95b7, 0x96ae, 0x96b0, 0x96ac, 0x9720, 0x971f, 0x9718,
+  0x971d, 0x9719, 0x979a, 0x97a1, 0x979c,
+  /* 0xef */
+  0x979e, 0x979d, 0x97d5, 0x97d4, 0x97f1, 0x9841, 0x9844, 0x984a,
+  0x9849, 0x9845, 0x9843, 0x9925, 0x992b, 0x992c, 0x992a, 0x9933,
+  0x9932, 0x992f, 0x992d, 0x9931, 0x9930, 0x9998, 0x99a3, 0x99a1,
+  0x9a02, 0x99fa, 0x99f4, 0x99f7, 0x99f9, 0x99f8, 0x99f6, 0x99fb,
+  0x99fd, 0x99fe, 0x99fc, 0x9a03, 0x9abe, 0x9afe, 0x9afd, 0x9b01,
+  0x9afc, 0x9b48, 0x9b9a, 0x9ba8, 0x9b9e, 0x9b9b, 0x9ba6, 0x9ba1,
+  0x9ba5, 0x9ba4, 0x9b86, 0x9ba2, 0x9ba0, 0x9baf, 0x9d33, 0x9d41,
+  0x9d67, 0x9d36, 0x9d2e, 0x9d2f, 0x9d31, 0x9d38, 0x9d30, 0x9d45,
+  0x9d42, 0x9d43, 0x9d3e, 0x9d37, 0x9d40, 0x9d3d, 0x7ff5, 0x9d2d,
+  0x9e8a, 0x9e89, 0x9e8d, 0x9eb0, 0x9ec8, 0x9eda, 0x9efb, 0x9eff,
+  0x9f24, 0x9f23, 0x9f22, 0x9f54, 0x9fa0, 0x5131, 0x512d, 0x512e,
+  0x5698, 0x569c, 0x5697, 0x569a, 0x569d, 0x5699, 0x5970, 0x5b3c,
+  0x5c69, 0x5c6a, 0x5dc0, 0x5e6d, 0x5e6e, 0x61d8, 0x61df, 0x61ed,
+  0x61ee, 0x61f1, 0x61ea, 0x61f0, 0x61eb, 0x61d6, 0x61e9, 0x64ff,
+  0x6504, 0x64fd, 0x64f8, 0x6501, 0x6503, 0x64fc, 0x6594, 0x65db,
+  0x66da, 0x66db, 0x66d8, 0x6ac5, 0x6ab9, 0x6abd, 0x6ae1, 0x6ac6,
+  0x6aba, 0x6ab6, 0x6ab7, 0x6ac7, 0x6ab4, 0x6aad, 0x6b5e, 0x6bc9,
+  0x6c0b, 0x7007, 0x700c, 0x700d, 0x7001, 0x7005, 0x7014, 0x700e,
+  0x6fff, 0x7000, 0x6ffb, 0x7026, 0x6ffc, 0x6ff7, 0x700a, 0x7201,
+  0x71ff, 0x71f9, 0x7203, 0x71fd, 0x7376,
+  /* 0xf0 */
+  0x74b8, 0x74c0, 0x74b5, 0x74c1, 0x74be, 0x74b6, 0x74bb, 0x74c2,
+  0x7514, 0x7513, 0x765c, 0x7664, 0x7659, 0x7650, 0x7653, 0x7657,
+  0x765a, 0x76a6, 0x76bd, 0x76ec, 0x77c2, 0x77ba, 0x78ff, 0x790c,
+  0x7913, 0x7914, 0x7909, 0x7910, 0x7912, 0x7911, 0x79ad, 0x79ac,
+  0x7a5f, 0x7c1c, 0x7c29, 0x7c19, 0x7c20, 0x7c1f, 0x7c2d, 0x7c1d,
+  0x7c26, 0x7c28, 0x7c22, 0x7c25, 0x7c30, 0x7e5c, 0x7e50, 0x7e56,
+  0x7e63, 0x7e58, 0x7e62, 0x7e5f, 0x7e51, 0x7e60, 0x7e57, 0x7e53,
+  0x7fb5, 0x7fb3, 0x7ff7, 0x7ff8, 0x8075, 0x81d1, 0x81d2, 0x81d0,
+  0x825f, 0x825e, 0x85b4, 0x85c6, 0x85c0, 0x85c3, 0x85c2, 0x85b3,
+  0x85b5, 0x85bd, 0x85c7, 0x85c4, 0x85bf, 0x85cb, 0x85ce, 0x85c8,
+  0x85c5, 0x85b1, 0x85b6, 0x85d2, 0x8624, 0x85b8, 0x85b7, 0x85be,
+  0x8669, 0x87e7, 0x87e6, 0x87e2, 0x87db, 0x87eb, 0x87ea, 0x87e5,
+  0x87df, 0x87f3, 0x87e4, 0x87d4, 0x87dc, 0x87d3, 0x87ed, 0x87d8,
+  0x87e3, 0x87a4, 0x87d7, 0x87d9, 0x8801, 0x87f4, 0x87e8, 0x87dd,
+  0x8953, 0x894b, 0x894f, 0x894c, 0x8946, 0x8950, 0x8951, 0x8949,
+  0x8b2a, 0x8b27, 0x8b23, 0x8b33, 0x8b30, 0x8b35, 0x8b47, 0x8b2f,
+  0x8b3c, 0x8b3e, 0x8b31, 0x8b25, 0x8b37, 0x8b26, 0x8b36, 0x8b2e,
+  0x8b24, 0x8b3b, 0x8b3d, 0x8b3a, 0x8c42, 0x8c75, 0x8c99, 0x8c98,
+  0x8c97, 0x8cfe, 0x8d04, 0x8d02, 0x8d00, 0x8e5c, 0x8e62, 0x8e60,
+  0x8e57, 0x8e56, 0x8e5e, 0x8e65, 0x8e67,
+  /* 0xf1 */
+  0x8e5b, 0x8e5a, 0x8e61, 0x8e5d, 0x8e69, 0x8e54, 0x8f46, 0x8f47,
+  0x8f48, 0x8f4b, 0x9128, 0x913a, 0x913b, 0x913e, 0x91a8, 0x91a5,
+  0x91a7, 0x91af, 0x91aa, 0x93b5, 0x938c, 0x9392, 0x93b7, 0x939b,
+  0x939d, 0x9389, 0x93a7, 0x938e, 0x93aa, 0x939e, 0x93a6, 0x9395,
+  0x9388, 0x9399, 0x939f, 0x938d, 0x93b1, 0x9391, 0x93b2, 0x93a4,
+  0x93a8, 0x93b4, 0x93a3, 0x93a5, 0x95d2, 0x95d3, 0x95d1, 0x96b3,
+  0x96d7, 0x96da, 0x5dc2, 0x96df, 0x96d8, 0x96dd, 0x9723, 0x9722,
+  0x9725, 0x97ac, 0x97ae, 0x97a8, 0x97ab, 0x97a4, 0x97aa, 0x97a2,
+  0x97a5, 0x97d7, 0x97d9, 0x97d6, 0x97d8, 0x97fa, 0x9850, 0x9851,
+  0x9852, 0x98b8, 0x9941, 0x993c, 0x993a, 0x9a0f, 0x9a0b, 0x9a09,
+  0x9a0d, 0x9a04, 0x9a11, 0x9a0a, 0x9a05, 0x9a07, 0x9a06, 0x9ac0,
+  0x9adc, 0x9b08, 0x9b04, 0x9b05, 0x9b29, 0x9b35, 0x9b4a, 0x9b4c,
+  0x9b4b, 0x9bc7, 0x9bc6, 0x9bc3, 0x9bbf, 0x9bc1, 0x9bb5, 0x9bb8,
+  0x9bd3, 0x9bb6, 0x9bc4, 0x9bb9, 0x9bbd, 0x9d5c, 0x9d53, 0x9d4f,
+  0x9d4a, 0x9d5b, 0x9d4b, 0x9d59, 0x9d56, 0x9d4c, 0x9d57, 0x9d52,
+  0x9d54, 0x9d5f, 0x9d58, 0x9d5a, 0x9e8e, 0x9e8c, 0x9edf, 0x9f01,
+  0x9f00, 0x9f16, 0x9f25, 0x9f2b, 0x9f2a, 0x9f29, 0x9f28, 0x9f4c,
+  0x9f55, 0x5134, 0x5135, 0x5296, 0x52f7, 0x53b4, 0x56ab, 0x56ad,
+  0x56a6, 0x56a7, 0x56aa, 0x56ac, 0x58da, 0x58dd, 0x58db, 0x5912,
+  0x5b3d, 0x5b3e, 0x5b3f, 0x5dc3, 0x5e70,
+  /* 0xf2 */
+  0x5fbf, 0x61fb, 0x6507, 0x6510, 0x650d, 0x6509, 0x650c, 0x650e,
+  0x6584, 0x65de, 0x65dd, 0x66de, 0x6ae7, 0x6ae0, 0x6acc, 0x6ad1,
+  0x6ad9, 0x6acb, 0x6adf, 0x6adc, 0x6ad0, 0x6aeb, 0x6acf, 0x6acd,
+  0x6ade, 0x6b60, 0x6bb0, 0x6c0c, 0x7019, 0x7027, 0x7020, 0x7016,
+  0x702b, 0x7021, 0x7022, 0x7023, 0x7029, 0x7017, 0x7024, 0x701c,
+  0x702a, 0x720c, 0x720a, 0x7207, 0x7202, 0x7205, 0x72a5, 0x72a6,
+  0x72a4, 0x72a3, 0x72a1, 0x74cb, 0x74c5, 0x74b7, 0x74c3, 0x7516,
+  0x7660, 0x77c9, 0x77ca, 0x77c4, 0x77f1, 0x791d, 0x791b, 0x7921,
+  0x791c, 0x7917, 0x791e, 0x79b0, 0x7a67, 0x7a68, 0x7c33, 0x7c3c,
+  0x7c39, 0x7c2c, 0x7c3b, 0x7cec, 0x7cea, 0x7e76, 0x7e75, 0x7e78,
+  0x7e70, 0x7e77, 0x7e6f, 0x7e7a, 0x7e72, 0x7e74, 0x7e68, 0x7f4b,
+  0x7f4a, 0x7f83, 0x7f86, 0x7fb7, 0x7ffd, 0x7ffe, 0x8078, 0x81d7,
+  0x81d5, 0x8264, 0x8261, 0x8263, 0x85eb, 0x85f1, 0x85ed, 0x85d9,
+  0x85e1, 0x85e8, 0x85da, 0x85d7, 0x85ec, 0x85f2, 0x85f8, 0x85d8,
+  0x85df, 0x85e3, 0x85dc, 0x85d1, 0x85f0, 0x85e6, 0x85ef, 0x85de,
+  0x85e2, 0x8800, 0x87fa, 0x8803, 0x87f6, 0x87f7, 0x8809, 0x880c,
+  0x880b, 0x8806, 0x87fc, 0x8808, 0x87ff, 0x880a, 0x8802, 0x8962,
+  0x895a, 0x895b, 0x8957, 0x8961, 0x895c, 0x8958, 0x895d, 0x8959,
+  0x8988, 0x89b7, 0x89b6, 0x89f6, 0x8b50, 0x8b48, 0x8b4a, 0x8b40,
+  0x8b53, 0x8b56, 0x8b54, 0x8b4b, 0x8b55,
+  /* 0xf3 */
+  0x8b51, 0x8b42, 0x8b52, 0x8b57, 0x8c43, 0x8c77, 0x8c76, 0x8c9a,
+  0x8d06, 0x8d07, 0x8d09, 0x8dac, 0x8daa, 0x8dad, 0x8dab, 0x8e6d,
+  0x8e78, 0x8e73, 0x8e6a, 0x8e6f, 0x8e7b, 0x8ec2, 0x8f52, 0x8f51,
+  0x8f4f, 0x8f50, 0x8f53, 0x8fb4, 0x9140, 0x913f, 0x91b0, 0x91ad,
+  0x93de, 0x93c7, 0x93cf, 0x93c2, 0x93da, 0x93d0, 0x93f9, 0x93ec,
+  0x93cc, 0x93d9, 0x93a9, 0x93e6, 0x93ca, 0x93d4, 0x93ee, 0x93e3,
+  0x93d5, 0x93c4, 0x93ce, 0x93c0, 0x93d2, 0x93e7, 0x957d, 0x95da,
+  0x95db, 0x96e1, 0x9729, 0x972b, 0x972c, 0x9728, 0x9726, 0x97b3,
+  0x97b7, 0x97b6, 0x97dd, 0x97de, 0x97df, 0x985c, 0x9859, 0x985d,
+  0x9857, 0x98bf, 0x98bd, 0x98bb, 0x98be, 0x9948, 0x9947, 0x9943,
+  0x99a6, 0x99a7, 0x9a1a, 0x9a15, 0x9a25, 0x9a1d, 0x9a24, 0x9a1b,
+  0x9a22, 0x9a20, 0x9a27, 0x9a23, 0x9a1e, 0x9a1c, 0x9a14, 0x9ac2,
+  0x9b0b, 0x9b0a, 0x9b0e, 0x9b0c, 0x9b37, 0x9bea, 0x9beb, 0x9be0,
+  0x9bde, 0x9be4, 0x9be6, 0x9be2, 0x9bf0, 0x9bd4, 0x9bd7, 0x9bec,
+  0x9bdc, 0x9bd9, 0x9be5, 0x9bd5, 0x9be1, 0x9bda, 0x9d77, 0x9d81,
+  0x9d8a, 0x9d84, 0x9d88, 0x9d71, 0x9d80, 0x9d78, 0x9d86, 0x9d8b,
+  0x9d8c, 0x9d7d, 0x9d6b, 0x9d74, 0x9d75, 0x9d70, 0x9d69, 0x9d85,
+  0x9d73, 0x9d7b, 0x9d82, 0x9d6f, 0x9d79, 0x9d7f, 0x9d87, 0x9d68,
+  0x9e94, 0x9e91, 0x9ec0, 0x9efc, 0x9f2d, 0x9f40, 0x9f41, 0x9f4d,
+  0x9f56, 0x9f57, 0x9f58, 0x5337, 0x56b2,
+  /* 0xf4 */
+  0x56b5, 0x56b3, 0x58e3, 0x5b45, 0x5dc6, 0x5dc7, 0x5eee, 0x5eef,
+  0x5fc0, 0x5fc1, 0x61f9, 0x6517, 0x6516, 0x6515, 0x6513, 0x65df,
+  0x66e8, 0x66e3, 0x66e4, 0x6af3, 0x6af0, 0x6aea, 0x6ae8, 0x6af9,
+  0x6af1, 0x6aee, 0x6aef, 0x703c, 0x7035, 0x702f, 0x7037, 0x7034,
+  0x7031, 0x7042, 0x7038, 0x703f, 0x703a, 0x7039, 0x7040, 0x703b,
+  0x7033, 0x7041, 0x7213, 0x7214, 0x72a8, 0x737d, 0x737c, 0x74ba,
+  0x76ab, 0x76aa, 0x76be, 0x76ed, 0x77cc, 0x77ce, 0x77cf, 0x77cd,
+  0x77f2, 0x7925, 0x7923, 0x7927, 0x7928, 0x7924, 0x7929, 0x79b2,
+  0x7a6e, 0x7a6c, 0x7a6d, 0x7af7, 0x7c49, 0x7c48, 0x7c4a, 0x7c47,
+  0x7c45, 0x7cee, 0x7e7b, 0x7e7e, 0x7e81, 0x7e80, 0x7fba, 0x7fff,
+  0x8079, 0x81db, 0x81d9, 0x820b, 0x8268, 0x8269, 0x8622, 0x85ff,
+  0x8601, 0x85fe, 0x861b, 0x8600, 0x85f6, 0x8604, 0x8609, 0x8605,
+  0x860c, 0x85fd, 0x8819, 0x8810, 0x8811, 0x8817, 0x8813, 0x8816,
+  0x8963, 0x8966, 0x89b9, 0x89f7, 0x8b60, 0x8b6a, 0x8b5d, 0x8b68,
+  0x8b63, 0x8b65, 0x8b67, 0x8b6d, 0x8dae, 0x8e86, 0x8e88, 0x8e84,
+  0x8f59, 0x8f56, 0x8f57, 0x8f55, 0x8f58, 0x8f5a, 0x908d, 0x9143,
+  0x9141, 0x91b7, 0x91b5, 0x91b2, 0x91b3, 0x940b, 0x9413, 0x93fb,
+  0x9420, 0x940f, 0x9414, 0x93fe, 0x9415, 0x9410, 0x9428, 0x9419,
+  0x940d, 0x93f5, 0x9400, 0x93f7, 0x9407, 0x940e, 0x9416, 0x9412,
+  0x93fa, 0x9409, 0x93f8, 0x940a, 0x93ff,
+  /* 0xf5 */
+  0x93fc, 0x940c, 0x93f6, 0x9411, 0x9406, 0x95de, 0x95e0, 0x95df,
+  0x972e, 0x972f, 0x97b9, 0x97bb, 0x97fd, 0x97fe, 0x9860, 0x9862,
+  0x9863, 0x985f, 0x98c1, 0x98c2, 0x9950, 0x994e, 0x9959, 0x994c,
+  0x994b, 0x9953, 0x9a32, 0x9a34, 0x9a31, 0x9a2c, 0x9a2a, 0x9a36,
+  0x9a29, 0x9a2e, 0x9a38, 0x9a2d, 0x9ac7, 0x9aca, 0x9ac6, 0x9b10,
+  0x9b12, 0x9b11, 0x9c0b, 0x9c08, 0x9bf7, 0x9c05, 0x9c12, 0x9bf8,
+  0x9c40, 0x9c07, 0x9c0e, 0x9c06, 0x9c17, 0x9c14, 0x9c09, 0x9d9f,
+  0x9d99, 0x9da4, 0x9d9d, 0x9d92, 0x9d98, 0x9d90, 0x9d9b, 0x9da0,
+  0x9d94, 0x9d9c, 0x9daa, 0x9d97, 0x9da1, 0x9d9a, 0x9da2, 0x9da8,
+  0x9d9e, 0x9da3, 0x9dbf, 0x9da9, 0x9d96, 0x9da6, 0x9da7, 0x9e99,
+  0x9e9b, 0x9e9a, 0x9ee5, 0x9ee4, 0x9ee7, 0x9ee6, 0x9f30, 0x9f2e,
+  0x9f5b, 0x9f60, 0x9f5e, 0x9f5d, 0x9f59, 0x9f91, 0x513a, 0x5139,
+  0x5298, 0x5297, 0x56c3, 0x56bd, 0x56be, 0x5b48, 0x5b47, 0x5dcb,
+  0x5dcf, 0x5ef1, 0x61fd, 0x651b, 0x6b02, 0x6afc, 0x6b03, 0x6af8,
+  0x6b00, 0x7043, 0x7044, 0x704a, 0x7048, 0x7049, 0x7045, 0x7046,
+  0x721d, 0x721a, 0x7219, 0x737e, 0x7517, 0x766a, 0x77d0, 0x792d,
+  0x7931, 0x792f, 0x7c54, 0x7c53, 0x7cf2, 0x7e8a, 0x7e87, 0x7e88,
+  0x7e8b, 0x7e86, 0x7e8d, 0x7f4d, 0x7fbb, 0x8030, 0x81dd, 0x8618,
+  0x862a, 0x8626, 0x861f, 0x8623, 0x861c, 0x8619, 0x8627, 0x862e,
+  0x8621, 0x8620, 0x8629, 0x861e, 0x8625,
+  /* 0xf6 */
+  0x8829, 0x881d, 0x881b, 0x8820, 0x8824, 0x881c, 0x882b, 0x884a,
+  0x896d, 0x8969, 0x896e, 0x896b, 0x89fa, 0x8b79, 0x8b78, 0x8b45,
+  0x8b7a, 0x8b7b, 0x8d10, 0x8d14, 0x8daf, 0x8e8e, 0x8e8c, 0x8f5e,
+  0x8f5b, 0x8f5d, 0x9146, 0x9144, 0x9145, 0x91b9, 0x943f, 0x943b,
+  0x9436, 0x9429, 0x943d, 0x943c, 0x9430, 0x9439, 0x942a, 0x9437,
+  0x942c, 0x9440, 0x9431, 0x95e5, 0x95e4, 0x95e3, 0x9735, 0x973a,
+  0x97bf, 0x97e1, 0x9864, 0x98c9, 0x98c6, 0x98c0, 0x9958, 0x9956,
+  0x9a39, 0x9a3d, 0x9a46, 0x9a44, 0x9a42, 0x9a41, 0x9a3a, 0x9a3f,
+  0x9acd, 0x9b15, 0x9b17, 0x9b18, 0x9b16, 0x9b3a, 0x9b52, 0x9c2b,
+  0x9c1d, 0x9c1c, 0x9c2c, 0x9c23, 0x9c28, 0x9c29, 0x9c24, 0x9c21,
+  0x9db7, 0x9db6, 0x9dbc, 0x9dc1, 0x9dc7, 0x9dca, 0x9dcf, 0x9dbe,
+  0x9dc5, 0x9dc3, 0x9dbb, 0x9db5, 0x9dce, 0x9db9, 0x9dba, 0x9dac,
+  0x9dc8, 0x9db1, 0x9dad, 0x9dcc, 0x9db3, 0x9dcd, 0x9db2, 0x9e7a,
+  0x9e9c, 0x9eeb, 0x9eee, 0x9eed, 0x9f1b, 0x9f18, 0x9f1a, 0x9f31,
+  0x9f4e, 0x9f65, 0x9f64, 0x9f92, 0x4eb9, 0x56c6, 0x56c5, 0x56cb,
+  0x5971, 0x5b4b, 0x5b4c, 0x5dd5, 0x5dd1, 0x5ef2, 0x6521, 0x6520,
+  0x6526, 0x6522, 0x6b0b, 0x6b08, 0x6b09, 0x6c0d, 0x7055, 0x7056,
+  0x7057, 0x7052, 0x721e, 0x721f, 0x72a9, 0x737f, 0x74d8, 0x74d5,
+  0x74d9, 0x74d7, 0x766d, 0x76ad, 0x7935, 0x79b4, 0x7a70, 0x7a71,
+  0x7c57, 0x7c5c, 0x7c59, 0x7c5b, 0x7c5a,
+  /* 0xf7 */
+  0x7cf4, 0x7cf1, 0x7e91, 0x7f4f, 0x7f87, 0x81de, 0x826b, 0x8634,
+  0x8635, 0x8633, 0x862c, 0x8632, 0x8636, 0x882c, 0x8828, 0x8826,
+  0x882a, 0x8825, 0x8971, 0x89bf, 0x89be, 0x89fb, 0x8b7e, 0x8b84,
+  0x8b82, 0x8b86, 0x8b85, 0x8b7f, 0x8d15, 0x8e95, 0x8e94, 0x8e9a,
+  0x8e92, 0x8e90, 0x8e96, 0x8e97, 0x8f60, 0x8f62, 0x9147, 0x944c,
+  0x9450, 0x944a, 0x944b, 0x944f, 0x9447, 0x9445, 0x9448, 0x9449,
+  0x9446, 0x973f, 0x97e3, 0x986a, 0x9869, 0x98cb, 0x9954, 0x995b,
+  0x9a4e, 0x9a53, 0x9a54, 0x9a4c, 0x9a4f, 0x9a48, 0x9a4a, 0x9a49,
+  0x9a52, 0x9a50, 0x9ad0, 0x9b19, 0x9b2b, 0x9b3b, 0x9b56, 0x9b55,
+  0x9c46, 0x9c48, 0x9c3f, 0x9c44, 0x9c39, 0x9c33, 0x9c41, 0x9c3c,
+  0x9c37, 0x9c34, 0x9c32, 0x9c3d, 0x9c36, 0x9ddb, 0x9dd2, 0x9dde,
+  0x9dda, 0x9dcb, 0x9dd0, 0x9ddc, 0x9dd1, 0x9ddf, 0x9de9, 0x9dd9,
+  0x9dd8, 0x9dd6, 0x9df5, 0x9dd5, 0x9ddd, 0x9eb6, 0x9ef0, 0x9f35,
+  0x9f33, 0x9f32, 0x9f42, 0x9f6b, 0x9f95, 0x9fa2, 0x513d, 0x5299,
+  0x58e8, 0x58e7, 0x5972, 0x5b4d, 0x5dd8, 0x882f, 0x5f4f, 0x6201,
+  0x6203, 0x6204, 0x6529, 0x6525, 0x6596, 0x66eb, 0x6b11, 0x6b12,
+  0x6b0f, 0x6bca, 0x705b, 0x705a, 0x7222, 0x7382, 0x7381, 0x7383,
+  0x7670, 0x77d4, 0x7c67, 0x7c66, 0x7e95, 0x826c, 0x863a, 0x8640,
+  0x8639, 0x863c, 0x8631, 0x863b, 0x863e, 0x8830, 0x8832, 0x882e,
+  0x8833, 0x8976, 0x8974, 0x8973, 0x89fe,
+  /* 0xf8 */
+  0x8b8c, 0x8b8e, 0x8b8b, 0x8b88, 0x8c45, 0x8d19, 0x8e98, 0x8f64,
+  0x8f63, 0x91bc, 0x9462, 0x9455, 0x945d, 0x9457, 0x945e, 0x97c4,
+  0x97c5, 0x9800, 0x9a56, 0x9a59, 0x9b1e, 0x9b1f, 0x9b20, 0x9c52,
+  0x9c58, 0x9c50, 0x9c4a, 0x9c4d, 0x9c4b, 0x9c55, 0x9c59, 0x9c4c,
+  0x9c4e, 0x9dfb, 0x9df7, 0x9def, 0x9de3, 0x9deb, 0x9df8, 0x9de4,
+  0x9df6, 0x9de1, 0x9dee, 0x9de6, 0x9df2, 0x9df0, 0x9de2, 0x9dec,
+  0x9df4, 0x9df3, 0x9de8, 0x9ded, 0x9ec2, 0x9ed0, 0x9ef2, 0x9ef3,
+  0x9f06, 0x9f1c, 0x9f38, 0x9f37, 0x9f36, 0x9f43, 0x9f4f, 0x9f71,
+  0x9f70, 0x9f6e, 0x9f6f, 0x56d3, 0x56cd, 0x5b4e, 0x5c6d, 0x652d,
+  0x66ed, 0x66ee, 0x6b13, 0x705f, 0x7061, 0x705d, 0x7060, 0x7223,
+  0x74db, 0x74e5, 0x77d5, 0x7938, 0x79b7, 0x79b6, 0x7c6a, 0x7e97,
+  0x7f89, 0x826d, 0x8643, 0x8838, 0x8837, 0x8835, 0x884b, 0x8b94,
+  0x8b95, 0x8e9e, 0x8e9f, 0x8ea0, 0x8e9d, 0x91be, 0x91bd, 0x91c2,
+  0x946b, 0x9468, 0x9469, 0x96e5, 0x9746, 0x9743, 0x9747, 0x97c7,
+  0x97e5, 0x9a5e, 0x9ad5, 0x9b59, 0x9c63, 0x9c67, 0x9c66, 0x9c62,
+  0x9c5e, 0x9c60, 0x9e02, 0x9dfe, 0x9e07, 0x9e03, 0x9e06, 0x9e05,
+  0x9e00, 0x9e01, 0x9e09, 0x9dff, 0x9dfd, 0x9e04, 0x9ea0, 0x9f1e,
+  0x9f46, 0x9f74, 0x9f75, 0x9f76, 0x56d4, 0x652e, 0x65b8, 0x6b18,
+  0x6b19, 0x6b17, 0x6b1a, 0x7062, 0x7226, 0x72aa, 0x77d8, 0x77d9,
+  0x7939, 0x7c69, 0x7c6b, 0x7cf6, 0x7e9a,
+  /* 0xf9 */
+  0x7e98, 0x7e9b, 0x7e99, 0x81e0, 0x81e1, 0x8646, 0x8647, 0x8648,
+  0x8979, 0x897a, 0x897c, 0x897b, 0x89ff, 0x8b98, 0x8b99, 0x8ea5,
+  0x8ea4, 0x8ea3, 0x946e, 0x946d, 0x946f, 0x9471, 0x9473, 0x9749,
+  0x9872, 0x995f, 0x9c68, 0x9c6e, 0x9c6d, 0x9e0b, 0x9e0d, 0x9e10,
+  0x9e0f, 0x9e12, 0x9e11, 0x9ea1, 0x9ef5, 0x9f09, 0x9f47, 0x9f78,
+  0x9f7b, 0x9f7a, 0x9f79, 0x571e, 0x7066, 0x7c6f, 0x883c, 0x8db2,
+  0x8ea6, 0x91c3, 0x9474, 0x9478, 0x9476, 0x9475, 0x9a60, 0x9c74,
+  0x9c73, 0x9c71, 0x9c75, 0x9e14, 0x9e13, 0x9ef6, 0x9f0a, 0x9fa4,
+  0x7068, 0x7065, 0x7cf7, 0x866a, 0x883e, 0x883d, 0x883f, 0x8b9e,
+  0x8c9c, 0x8ea9, 0x8ec9, 0x974b, 0x9873, 0x9874, 0x98cc, 0x9961,
+  0x99ab, 0x9a64, 0x9a66, 0x9a67, 0x9b24, 0x9e15, 0x9e17, 0x9f48,
+  0x6207, 0x6b1e, 0x7227, 0x864c, 0x8ea8, 0x9482, 0x9480, 0x9481,
+  0x9a69, 0x9a68, 0x9b2e, 0x9e19, 0x7229, 0x864b, 0x8b9f, 0x9483,
+  0x9c79, 0x9eb7, 0x7675, 0x9a6b, 0x9c7a, 0x9e1d, 0x7069, 0x706a,
+  0x9ea4, 0x9f7e, 0x9f49, 0x9f98,
+};
+
+static int
+big5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  unsigned char c1 = s[0];
+  if ((c1 >= 0xa1 && c1 <= 0xc7) || (c1 >= 0xc9 && c1 <= 0xf9)) {
+    if (n >= 2) {
+      unsigned char c2 = s[1];
+      if ((c2 >= 0x40 && c2 < 0x7f) || (c2 >= 0xa1 && c2 < 0xff)) {
+        unsigned int i = 157 * (c1 - 0xa1) + (c2 - (c2 >= 0xa1 ? 0x62 : 0x40));
+        unsigned short wc = 0xfffd;
+        if (i < 6280) {
+          if (i < 6121)
+            wc = big5_2uni_pagea1[i];
+        } else {
+          if (i < 13932)
+            wc = big5_2uni_pagec9[i-6280];
+        }
+        if (wc != 0xfffd) {
+          *pwc = (ucs4_t) wc;
+          return 2;
+        }
+      }
+      return RET_ILSEQ;
+    }
+    return RET_TOOFEW(0);
+  }
+  return RET_ILSEQ;
+}
+
+static const unsigned short big5_2charset[13703] = {
+  0xa246, 0xa247, 0xa244, 0xa1b1, 0xa258, 0xa1d3, 0xa150, 0xa1d1,
+  0xa1d2, 0xa3be, 0xa3bc, 0xa3bd, 0xa3bf, 0xa3bb, 0xa344, 0xa345,
+  0xa346, 0xa347, 0xa348, 0xa349, 0xa34a, 0xa34b, 0xa34c, 0xa34d,
+  0xa34e, 0xa34f, 0xa350, 0xa351, 0xa352, 0xa353, 0xa354, 0xa355,
+  0xa356, 0xa357, 0xa358, 0xa359, 0xa35a, 0xa35b, 0xa35c, 0xa35d,
+  0xa35e, 0xa35f, 0xa360, 0xa361, 0xa362, 0xa363, 0xa364, 0xa365,
+  0xa366, 0xa367, 0xa368, 0xa369, 0xa36a, 0xa36b, 0xa36c, 0xa36d,
+  0xa36e, 0xa36f, 0xa370, 0xa371, 0xa372, 0xa373, 0xc7b3, 0xc7b1,
+  0xc7b2, 0xc7b4, 0xc7b5, 0xc7b6, 0xc7b7, 0xc7b8, 0xc7b9, 0xc7ba,
+  0xc7bb, 0xc7bc, 0xc7bd, 0xc7be, 0xc7bf, 0xc7c0, 0xc7c1, 0xc7c2,
+  0xc7c3, 0xc7c4, 0xc7c5, 0xc7c6, 0xc7c7, 0xc7c8, 0xc7c9, 0xc7ca,
+  0xc7cb, 0xc7cc, 0xc7cd, 0xc7cf, 0xc7d0, 0xc7d1, 0xc7d2, 0xc7d3,
+  0xc7d4, 0xc7d5, 0xc7d6, 0xc7d7, 0xc7d8, 0xc7d9, 0xc7da, 0xc7db,
+  0xc7dc, 0xc7dd, 0xc7de, 0xc7df, 0xc7e0, 0xc7e1, 0xc7e2, 0xc7e3,
+  0xc7e4, 0xc7e5, 0xc7e6, 0xc7e7, 0xc7e8, 0xc7ce, 0xa156, 0xa158,
+  0xa1a5, 0xa1a6, 0xa1a7, 0xa1a8, 0xa145, 0xa14c, 0xa14b, 0xa1ac,
+  0xa1ab, 0xa1b0, 0xa1c2, 0xa24a, 0xa1c1, 0xa24b, 0xa2b9, 0xa2ba,
+  0xa2bb, 0xa2bc, 0xa2bd, 0xa2be, 0xa2bf, 0xa2c0, 0xa2c1, 0xa2c2,
+  0xa1f6, 0xa1f4, 0xa1f7, 0xa1f5, 0xa1f8, 0xa1f9, 0xa1fb, 0xa1fa,
+  0xa1d4, 0xa1db, 0xa1e8, 0xa1e7, 0xa1fd, 0xa1fc, 0xa1e4, 0xa1e5,
+  0xa1ec, 0xa1ed, 0xa1ef, 0xa1ee, 0xa1e3, 0xa1dc, 0xa1da, 0xa1dd,
+  0xa1d8, 0xa1d9, 0xa1e6, 0xa1e9, 0xc7e9, 0xc7ea, 0xc7eb, 0xc7ec,
+  0xc7ed, 0xc7ee, 0xc7ef, 0xc7f0, 0xc7f1, 0xc7f2, 0xc7f3, 0xc7f4,
+  0xc7f5, 0xc7f6, 0xc7f7, 0xc7f8, 0xc7f9, 0xc7fa, 0xc7fb, 0xc7fc,
+  0xa277, 0xa278, 0xa27a, 0xa27b, 0xa27c, 0xa27d, 0xa275, 0xa274,
+  0xa273, 0xa272, 0xa271, 0xa2a4, 0xa2a5, 0xa2a7, 0xa2a6, 0xa27e,
+  0xa2a1, 0xa2a3, 0xa2a2, 0xa2ac, 0xa2ad, 0xa2ae, 0xa262, 0xa263,
+  0xa264, 0xa265, 0xa266, 0xa267, 0xa268, 0xa269, 0xa270, 0xa26f,
+  0xa26e, 0xa26d, 0xa26c, 0xa26b, 0xa26a, 0xa276, 0xa279, 0xa1bd,
+  0xa1bc, 0xa1b6, 0xa1b5, 0xa1bf, 0xa1be, 0xa1bb, 0xa1ba, 0xa1b3,
+  0xa1b7, 0xa1b4, 0xa2a8, 0xa2a9, 0xa2ab, 0xa2aa, 0xa1b9, 0xa1b8,
+  0xa1f3, 0xa1f0, 0xa1f2, 0xa1f1, 0xa140, 0xa142, 0xa143, 0xa1b2,
+  0xc6a4, 0xa171, 0xa172, 0xa16d, 0xa16e, 0xa175, 0xa176, 0xa179,
+  0xa17a, 0xa169, 0xa16a, 0xa245, 0xa165, 0xa166, 0xa1a9, 0xa1aa,
+  0xa2c3, 0xa2c4, 0xa2c5, 0xa2c6, 0xa2c7, 0xa2c8, 0xa2c9, 0xa2ca,
+  0xa2cb, 0xc6a5, 0xc6a6, 0xc6a7, 0xc6a8, 0xc6a9, 0xc6aa, 0xc6ab,
+  0xc6ac, 0xc6ad, 0xc6ae, 0xc6af, 0xc6b0, 0xc6b1, 0xc6b2, 0xc6b3,
+  0xc6b4, 0xc6b5, 0xc6b6, 0xc6b7, 0xc6b8, 0xc6b9, 0xc6ba, 0xc6bb,
+  0xc6bc, 0xc6bd, 0xc6be, 0xc6bf, 0xc6c0, 0xc6c1, 0xc6c2, 0xc6c3,
+  0xc6c4, 0xc6c5, 0xc6c6, 0xc6c7, 0xc6c8, 0xc6c9, 0xc6ca, 0xc6cb,
+  0xc6cc, 0xc6cd, 0xc6ce, 0xc6cf, 0xc6d0, 0xc6d1, 0xc6d2, 0xc6d3,
+  0xc6d4, 0xc6d5, 0xc6d6, 0xc6d7, 0xc6d8, 0xc6d9, 0xc6da, 0xc6db,
+  0xc6dc, 0xc6dd, 0xc6de, 0xc6df, 0xc6e0, 0xc6e1, 0xc6e2, 0xc6e3,
+  0xc6e4, 0xc6e5, 0xc6e6, 0xc6e7, 0xc6e8, 0xc6e9, 0xc6ea, 0xc6eb,
+  0xc6ec, 0xc6ed, 0xc6ee, 0xc6ef, 0xc6f0, 0xc6f1, 0xc6f2, 0xc6f3,
+  0xc6f4, 0xc6f5, 0xc6f6, 0xc6f7, 0xc6a2, 0xc6a3, 0xc6f8, 0xc6f9,
+  0xc6fa, 0xc6fb, 0xc6fc, 0xc6fd, 0xc6fe, 0xc740, 0xc741, 0xc742,
+  0xc743, 0xc744, 0xc745, 0xc746, 0xc747, 0xc748, 0xc749, 0xc74a,
+  0xc74b, 0xc74c, 0xc74d, 0xc74e, 0xc74f, 0xc750, 0xc751, 0xc752,
+  0xc753, 0xc754, 0xc755, 0xc756, 0xc757, 0xc758, 0xc759, 0xc75a,
+  0xc75b, 0xc75c, 0xc75d, 0xc75e, 0xc75f, 0xc760, 0xc761, 0xc762,
+  0xc763, 0xc764, 0xc765, 0xc766, 0xc767, 0xc768, 0xc769, 0xc76a,
+  0xc76b, 0xc76c, 0xc76d, 0xc76e, 0xc76f, 0xc770, 0xc771, 0xc772,
+  0xc773, 0xc774, 0xc775, 0xc776, 0xc777, 0xc778, 0xc779, 0xc77a,
+  0xc77b, 0xc77c, 0xc77d, 0xc77e, 0xc7a1, 0xc7a2, 0xc7a3, 0xc7a4,
+  0xc7a5, 0xc7a6, 0xc7a7, 0xc7a8, 0xc7a9, 0xc7aa, 0xc7ab, 0xc7ac,
+  0xc7ad, 0xc7ae, 0xc7af, 0xc7b0, 0xc6a1, 0xa374, 0xa375, 0xa376,
+  0xa377, 0xa378, 0xa379, 0xa37a, 0xa37b, 0xa37c, 0xa37d, 0xa37e,
+  0xa3a1, 0xa3a2, 0xa3a3, 0xa3a4, 0xa3a5, 0xa3a6, 0xa3a7, 0xa3a8,
+  0xa3a9, 0xa3aa, 0xa3ab, 0xa3ac, 0xa3ad, 0xa3ae, 0xa3af, 0xa3b0,
+  0xa3b1, 0xa3b2, 0xa3b3, 0xa3b4, 0xa3b5, 0xa3b6, 0xa3b7, 0xa3b8,
+  0xa3b9, 0xa3ba, 0xa1c0, 0xa255, 0xa256, 0xa250, 0xa251, 0xa252,
+  0xa254, 0xa257, 0xa253, 0xa1eb, 0xa1ea, 0xa24f, 0xa440, 0xa442,
+  0xa443, 0xc945, 0xa456, 0xa454, 0xa457, 0xa455, 0xc946, 0xa4a3,
+  0xc94f, 0xc94d, 0xa4a2, 0xa4a1, 0xa542, 0xa541, 0xa540, 0xa543,
+  0xa4fe, 0xa5e0, 0xa5e1, 0xa8c3, 0xa458, 0xa4a4, 0xc950, 0xa4a5,
+  0xc963, 0xa6ea, 0xcbb1, 0xa459, 0xa4a6, 0xa544, 0xc964, 0xc940,
+  0xa444, 0xa45b, 0xc947, 0xa45c, 0xa4a7, 0xa545, 0xa547, 0xa546,
+  0xa5e2, 0xa5e3, 0xa8c4, 0xadbc, 0xa441, 0xc941, 0xa445, 0xa45e,
+  0xa45d, 0xa5e4, 0xa8c5, 0xb0ae, 0xd44b, 0xb6c3, 0xdcb1, 0xdcb2,
+  0xa446, 0xa4a9, 0xa8c6, 0xa447, 0xc948, 0xa45f, 0xa4aa, 0xa4ac,
+  0xc951, 0xa4ad, 0xa4ab, 0xa5e5, 0xa8c7, 0xa8c8, 0xab45, 0xa460,
+  0xa4ae, 0xa5e6, 0xa5e8, 0xa5e7, 0xa6eb, 0xa8c9, 0xa8ca, 0xab46,
+  0xab47, 0xadbd, 0xdcb3, 0xf6d6, 0xa448, 0xa4b0, 0xa4af, 0xc952,
+  0xa4b1, 0xa4b7, 0xa4b2, 0xa4b3, 0xc954, 0xc953, 0xa4b5, 0xa4b6,
+  0xa4b4, 0xa54a, 0xa54b, 0xa54c, 0xa54d, 0xa549, 0xa550, 0xc96a,
+  0xc966, 0xc969, 0xa551, 0xa561, 0xc968, 0xa54e, 0xa54f, 0xa548,
+  0xc965, 0xc967, 0xa5f5, 0xc9b0, 0xa5f2, 0xa5f6, 0xc9ba, 0xc9ae,
+  0xa5f3, 0xc9b2, 0xa5f4, 0xa5f7, 0xa5e9, 0xc9b1, 0xa5f8, 0xc9b5,
+  0xc9b9, 0xc9b6, 0xc9b3, 0xa5ea, 0xa5ec, 0xa5f9, 0xa5ee, 0xc9ab,
+  0xa5f1, 0xa5ef, 0xa5f0, 0xc9bb, 0xc9b8, 0xc9af, 0xa5ed, 0xc9ac,
+  0xa5eb, 0xc9b4, 0xc9b7, 0xc9ad, 0xca66, 0xa742, 0xa6f4, 0xca67,
+  0xa6f1, 0xa744, 0xa6f9, 0xa6f8, 0xca5b, 0xa6fc, 0xa6f7, 0xca60,
+  0xca68, 0xca64, 0xa6fa, 0xa6fd, 0xa6ee, 0xa747, 0xca5d, 0xcbbd,
+  0xa6ec, 0xa743, 0xa6ed, 0xa6f5, 0xa6f6, 0xca62, 0xca5e, 0xa6fb,
+  0xa6f3, 0xca5a, 0xa6ef, 0xca65, 0xa745, 0xa748, 0xa6f2, 0xa740,
+  0xa746, 0xa6f0, 0xca63, 0xa741, 0xca69, 0xca5c, 0xa6fe, 0xca5f,
+  0xca61, 0xa8d8, 0xcbbf, 0xcbcb, 0xa8d0, 0xcbcc, 0xa8cb, 0xa8d5,
+  0xa8ce, 0xcbb9, 0xa8d6, 0xcbb8, 0xcbbc, 0xcbc3, 0xcbc1, 0xa8de,
+  0xa8d9, 0xcbb3, 0xcbb5, 0xa8db, 0xa8cf, 0xcbb6, 0xcbc2, 0xcbc9,
+  0xa8d4, 0xcbbb, 0xcbb4, 0xa8d3, 0xcbb7, 0xa8d7, 0xcbba, 0xa8d2,
+  0xa8cd, 0xa8dc, 0xcbc4, 0xa8dd, 0xcbc8, 0xcbc6, 0xcbca, 0xa8da,
+  0xcbbe, 0xcbb2, 0xcbc0, 0xa8d1, 0xcbc5, 0xa8cc, 0xcbc7, 0xab56,
+  0xab4a, 0xcde0, 0xcde8, 0xab49, 0xab51, 0xab5d, 0xcdee, 0xcdec,
+  0xcde7, 0xab4b, 0xcded, 0xcde3, 0xab59, 0xab50, 0xab58, 0xcdde,
+  0xcdea, 0xcde1, 0xab54, 0xcde2, 0xcddd, 0xab5b, 0xab4e, 0xab57,
+  0xab4d, 0xcddf, 0xcde4, 0xcdeb, 0xab55, 0xab52, 0xcde6, 0xab5a,
+  0xcde9, 0xcde5, 0xab4f, 0xab5c, 0xab53, 0xab4c, 0xab48, 0xcdef,
+  0xadd7, 0xadc1, 0xadd1, 0xadd6, 0xd0d0, 0xd0cf, 0xd0d4, 0xd0d5,
+  0xadc4, 0xadcd, 0xadda, 0xadce, 0xd0c9, 0xadc7, 0xd0ca, 0xaddc,
+  0xadd3, 0xadbe, 0xadbf, 0xd0dd, 0xb0bf, 0xadcc, 0xadcb, 0xd0cb,
+  0xadcf, 0xd45b, 0xadc6, 0xd0d6, 0xadd5, 0xadd4, 0xadca, 0xd0ce,
+  0xd0d7, 0xd0c8, 0xadc9, 0xd0d8, 0xadd2, 0xd0cc, 0xadc0, 0xadc3,
+  0xadc2, 0xd0d9, 0xadd0, 0xadc5, 0xadd9, 0xaddb, 0xd0d3, 0xadd8,
+  0xd0db, 0xd0cd, 0xd0dc, 0xd0d1, 0xd0da, 0xd0d2, 0xadc8, 0xd463,
+  0xd457, 0xb0b3, 0xd45c, 0xd462, 0xb0b2, 0xd455, 0xb0b6, 0xd459,
+  0xd452, 0xb0b4, 0xd456, 0xb0b9, 0xb0be, 0xd467, 0xd451, 0xb0ba,
+  0xd466, 0xb0b5, 0xd458, 0xb0b1, 0xd453, 0xd44f, 0xd45d, 0xd450,
+  0xd44e, 0xd45a, 0xd460, 0xd461, 0xb0b7, 0xd85b, 0xd45e, 0xd44d,
+  0xd45f, 0xb0c1, 0xd464, 0xb0c0, 0xd44c, 0xd454, 0xd465, 0xb0bc,
+  0xb0bb, 0xb0b8, 0xb0bd, 0xb0af, 0xb0b0, 0xb3c8, 0xd85e, 0xd857,
+  0xb3c5, 0xd85f, 0xd855, 0xd858, 0xb3c4, 0xd859, 0xb3c7, 0xd85d,
+  0xd853, 0xd852, 0xb3c9, 0xb3ca, 0xb3c6, 0xb3cb, 0xd851, 0xd85c,
+  0xd85a, 0xd854, 0xb3c3, 0xd856, 0xb6ca, 0xb6c4, 0xdcb7, 0xb6cd,
+  0xdcbd, 0xdcc0, 0xb6c6, 0xb6c7, 0xdcba, 0xb6c5, 0xdcc3, 0xb6cb,
+  0xdcc4, 0xdcbf, 0xb6cc, 0xdcb4, 0xb6c9, 0xdcb5, 0xdcbe, 0xdcbc,
+  0xdcb8, 0xb6c8, 0xdcb6, 0xb6ce, 0xdcbb, 0xdcc2, 0xdcb9, 0xdcc1,
+  0xb9b6, 0xb9b3, 0xb9b4, 0xe0f9, 0xe0f1, 0xb9b2, 0xb9af, 0xe0f2,
+  0xb9b1, 0xe0f5, 0xe0f7, 0xe0fe, 0xe0fd, 0xe0f8, 0xb9ae, 0xe0f0,
+  0xb9ac, 0xe0f3, 0xb9b7, 0xe0f6, 0xe0fa, 0xb9b0, 0xb9ad, 0xe0fc,
+  0xe0fb, 0xb9b5, 0xe0f4, 0xbbf8, 0xe4ec, 0xe4e9, 0xbbf9, 0xbbf7,
+  0xe4f0, 0xe4ed, 0xe4e6, 0xbbf6, 0xbbfa, 0xe4e7, 0xbbf5, 0xbbfd,
+  0xe4ea, 0xe4eb, 0xbbfb, 0xbbfc, 0xe4f1, 0xe4ee, 0xe4ef, 0xbeaa,
+  0xe8f8, 0xbea7, 0xe8f5, 0xbea9, 0xbeab, 0xe8f6, 0xbea8, 0xe8f7,
+  0xe8f4, 0xc076, 0xecbd, 0xc077, 0xecbb, 0xecbc, 0xecba, 0xecb9,
+  0xecbe, 0xc075, 0xefb8, 0xefb9, 0xe4e8, 0xefb7, 0xc078, 0xc35f,
+  0xf1eb, 0xf1ec, 0xc4d7, 0xc4d8, 0xf5c1, 0xf5c0, 0xc56c, 0xc56b,
+  0xf7d0, 0xa449, 0xa461, 0xa4b9, 0xa4b8, 0xa553, 0xa552, 0xa5fc,
+  0xa5fb, 0xa5fd, 0xa5fa, 0xa74a, 0xa749, 0xa74b, 0xa8e0, 0xa8df,
+  0xa8e1, 0xab5e, 0xa259, 0xd0de, 0xa25a, 0xb0c2, 0xa25c, 0xa25b,
+  0xd860, 0xa25d, 0xb9b8, 0xa25e, 0xa44a, 0xa4ba, 0xa5fe, 0xa8e2,
+  0xa44b, 0xa4bd, 0xa4bb, 0xa4bc, 0xa640, 0xa74c, 0xa8e4, 0xa8e3,
+  0xa8e5, 0xaddd, 0xbeac, 0xc94e, 0xa554, 0xa555, 0xa641, 0xca6a,
+  0xab60, 0xab5f, 0xd0e0, 0xd0df, 0xb0c3, 0xa4be, 0xc955, 0xcbcd,
+  0xab61, 0xade0, 0xadde, 0xaddf, 0xbead, 0xa556, 0xa642, 0xc9bc,
+  0xa74d, 0xa74e, 0xca6b, 0xcbce, 0xa8e6, 0xcbcf, 0xd0e2, 0xd0e3,
+  0xade3, 0xd0e4, 0xd0e1, 0xade4, 0xade2, 0xade1, 0xd0e5, 0xd468,
+  0xd861, 0xdcc5, 0xe140, 0xbbfe, 0xbeae, 0xe8f9, 0xa44c, 0xa45a,
+  0xb0c4, 0xb3cd, 0xb9b9, 0xc942, 0xa4bf, 0xa559, 0xa557, 0xa558,
+  0xa8e7, 0xa44d, 0xa44e, 0xa462, 0xa4c0, 0xa4c1, 0xa4c2, 0xc9be,
+  0xa55a, 0xc96b, 0xa646, 0xc9bf, 0xa644, 0xa645, 0xc9bd, 0xa647,
+  0xa643, 0xca6c, 0xaaec, 0xca6d, 0xca6e, 0xa750, 0xa74f, 0xa753,
+  0xa751, 0xa752, 0xa8ed, 0xa8ec, 0xcbd4, 0xcbd1, 0xcbd2, 0xcbd0,
+  0xa8ee, 0xa8ea, 0xa8e9, 0xa8eb, 0xa8e8, 0xa8ef, 0xab63, 0xcdf0,
+  0xcbd3, 0xab68, 0xcdf1, 0xab64, 0xab67, 0xab66, 0xab65, 0xab62,
+  0xd0e8, 0xade7, 0xd0eb, 0xade5, 0xd0e7, 0xade8, 0xade6, 0xade9,
+  0xd0e9, 0xd0ea, 0xd0e6, 0xd0ec, 0xb3d1, 0xb0c5, 0xd469, 0xd46b,
+  0xd46a, 0xd46c, 0xb0c6, 0xb3ce, 0xb3cf, 0xb3d0, 0xb6d0, 0xdcc7,
+  0xdcc6, 0xdcc8, 0xdcc9, 0xb6d1, 0xb6cf, 0xe141, 0xe142, 0xb9bb,
+  0xb9ba, 0xe35a, 0xbc40, 0xbc41, 0xbc42, 0xbc44, 0xe4f2, 0xe4f3,
+  0xbc43, 0xbeaf, 0xbeb0, 0xf1ed, 0xf5c3, 0xf5c2, 0xf7d1, 0xa44f,
+  0xa55c, 0xa55b, 0xa648, 0xc9c0, 0xa755, 0xa756, 0xa754, 0xa757,
+  0xca6f, 0xca70, 0xa8f1, 0xcbd5, 0xa8f0, 0xcdf2, 0xab6c, 0xcdf3,
+  0xab6b, 0xab69, 0xab6a, 0xd0ed, 0xb0c7, 0xd46e, 0xb0ca, 0xd46d,
+  0xb1e5, 0xb0c9, 0xb0c8, 0xb3d4, 0xb3d3, 0xb3d2, 0xb6d2, 0xb6d5,
+  0xb6d6, 0xb6d4, 0xb6d3, 0xe143, 0xe144, 0xe4f5, 0xbc45, 0xe4f4,
+  0xbeb1, 0xecbf, 0xc079, 0xf1ee, 0xc455, 0xa463, 0xa4c3, 0xc956,
+  0xa4c4, 0xa4c5, 0xa55d, 0xa55e, 0xa649, 0xca71, 0xcbd6, 0xcbd7,
+  0xab6d, 0xd0ee, 0xb0cc, 0xb0cb, 0xd863, 0xd862, 0xa450, 0xa4c6,
+  0xa55f, 0xb0cd, 0xc943, 0xc96c, 0xa560, 0xc9c2, 0xa64b, 0xa64a,
+  0xc9c1, 0xa758, 0xadea, 0xd46f, 0xb6d7, 0xe145, 0xb9bc, 0xe8fa,
+  0xf3fd, 0xa4c7, 0xcbd8, 0xcdf4, 0xb0d0, 0xb0ce, 0xb0cf, 0xa451,
+  0xa464, 0xa2cd, 0xa4ca, 0xa4c9, 0xa4c8, 0xa563, 0xa562, 0xc96d,
+  0xc9c3, 0xa8f5, 0xa8f2, 0xa8f4, 0xa8f3, 0xab6e, 0xb3d5, 0xa452,
+  0xa4cb, 0xa565, 0xa564, 0xca72, 0xa8f6, 0xc957, 0xa567, 0xa566,
+  0xa64c, 0xa64d, 0xca73, 0xa759, 0xa75a, 0xa8f7, 0xa8f8, 0xa8f9,
+  0xab6f, 0xcdf5, 0xadeb, 0xc944, 0xa4cc, 0xc9c4, 0xca74, 0xca75,
+  0xcbd9, 0xcbda, 0xcdf7, 0xcdf6, 0xcdf9, 0xcdf8, 0xab70, 0xd470,
+  0xaded, 0xd0ef, 0xadec, 0xd864, 0xb3d6, 0xd865, 0xe146, 0xb9bd,
+  0xbc46, 0xf1ef, 0xc958, 0xa568, 0xb0d1, 0xa453, 0xa465, 0xa4ce,
+  0xa4cd, 0xa4cf, 0xa8fb, 0xa8fa, 0xa8fc, 0xab71, 0xadee, 0xe8fb,
+  0xc24f, 0xa466, 0xa56a, 0xa579, 0xa574, 0xa56f, 0xa56e, 0xa575,
+  0xa573, 0xa56c, 0xa57a, 0xa56d, 0xa569, 0xa578, 0xa577, 0xa576,
+  0xa56b, 0xa572, 0xa571, 0xa57b, 0xa570, 0xa653, 0xa659, 0xa655,
+  0xa65b, 0xc9c5, 0xa658, 0xa64e, 0xa651, 0xa654, 0xa650, 0xa657,
+  0xa65a, 0xa64f, 0xa652, 0xa656, 0xa65c, 0xca7e, 0xca7b, 0xa767,
+  0xca7c, 0xa75b, 0xa75d, 0xa775, 0xa770, 0xcaa5, 0xca7d, 0xa75f,
+  0xa761, 0xcaa4, 0xa768, 0xca78, 0xa774, 0xa776, 0xa75c, 0xa76d,
+  0xca76, 0xa773, 0xa764, 0xa76e, 0xa76f, 0xca77, 0xa76c, 0xa76a,
+  0xa76b, 0xa771, 0xcaa1, 0xa75e, 0xa772, 0xcaa3, 0xa766, 0xa763,
+  0xca7a, 0xa762, 0xcaa6, 0xa765, 0xa769, 0xa760, 0xcaa2, 0xca79,
+  0xcbeb, 0xcbea, 0xa94f, 0xcbed, 0xcbef, 0xcbe4, 0xcbe7, 0xcbee,
+  0xa950, 0xcbe1, 0xcbe5, 0xcbe9, 0xce49, 0xa94b, 0xce4d, 0xa8fd,
+  0xcbe6, 0xa8fe, 0xa94c, 0xa945, 0xa941, 0xcbe2, 0xa944, 0xa949,
+  0xa952, 0xcbe3, 0xcbdc, 0xa943, 0xcbdd, 0xcbdf, 0xa946, 0xa948,
+  0xcbdb, 0xcbe0, 0xa951, 0xa94d, 0xcbe8, 0xa953, 0xa94a, 0xcbde,
+  0xa947, 0xa942, 0xa940, 0xcbec, 0xa94e, 0xce48, 0xcdfb, 0xce4b,
+  0xcdfd, 0xab78, 0xaba8, 0xab74, 0xaba7, 0xab7d, 0xaba4, 0xab72,
+  0xcdfc, 0xce43, 0xaba3, 0xce4f, 0xaba5, 0xab79, 0xce45, 0xce42,
+  0xab77, 0xcdfa, 0xaba6, 0xce4a, 0xab7c, 0xce4c, 0xaba9, 0xab73,
+  0xab7e, 0xab7b, 0xce40, 0xaba1, 0xce46, 0xce47, 0xab7a, 0xaba2,
+  0xab76, 0xab75, 0xcdfe, 0xce44, 0xce4e, 0xd144, 0xadfb, 0xd0f1,
+  0xd0f6, 0xadf4, 0xae40, 0xd0f4, 0xadef, 0xadf9, 0xadfe, 0xd0fb,
+  0xadfa, 0xadfd, 0xd0fe, 0xadf5, 0xd0f5, 0xd142, 0xd143, 0xadf7,
+  0xd141, 0xadf3, 0xae43, 0xd0f8, 0xadf1, 0xd146, 0xd0f9, 0xd0fd,
+  0xadf6, 0xae42, 0xd0fa, 0xadfc, 0xd140, 0xd147, 0xd4a1, 0xd145,
+  0xae44, 0xadf0, 0xd0fc, 0xd0f3, 0xadf8, 0xd0f2, 0xd0f7, 0xd0f0,
+  0xae41, 0xd477, 0xb0e4, 0xd4a7, 0xb0e2, 0xb0df, 0xd47c, 0xb0db,
+  0xd4a2, 0xb0e6, 0xd476, 0xd47b, 0xd47a, 0xadf2, 0xb0e1, 0xd4a5,
+  0xd4a8, 0xd473, 0xb3e8, 0xd4a9, 0xb0e7, 0xb0d9, 0xb0d6, 0xd47e,
+  0xb0d3, 0xd4a6, 0xb0da, 0xd4aa, 0xd474, 0xd4a4, 0xb0dd, 0xd475,
+  0xd478, 0xd47d, 0xb0de, 0xb0dc, 0xb0e8, 0xb0e3, 0xb0d7, 0xb1d2,
+  0xb0d8, 0xd479, 0xb0e5, 0xb0e0, 0xd4a3, 0xb0d5, 0xb0d4, 0xd471,
+  0xd472, 0xd86a, 0xb3d7, 0xb3da, 0xd875, 0xb3ee, 0xd878, 0xb3d8,
+  0xd871, 0xb3de, 0xb3e4, 0xb5bd, 0xb3e2, 0xd86e, 0xb3ef, 0xb3db,
+  0xb3e3, 0xd876, 0xdcd7, 0xd87b, 0xd86f, 0xd866, 0xd873, 0xd86d,
+  0xb3e1, 0xd879, 0xb3dd, 0xb3f1, 0xb3ea, 0xb3df, 0xb3dc, 0xb3e7,
+  0xd87a, 0xd86c, 0xd872, 0xd874, 0xd868, 0xd877, 0xb3d9, 0xd867,
+  0xb3e0, 0xb3f0, 0xb3ec, 0xd869, 0xb3e6, 0xb3ed, 0xb3e9, 0xb3e5,
+  0xd870, 0xb3eb, 0xdcd5, 0xdcd1, 0xdce0, 0xdcca, 0xdcd3, 0xb6e5,
+  0xb6e6, 0xb6de, 0xdcdc, 0xb6e8, 0xdccf, 0xdcce, 0xdccc, 0xdcde,
+  0xb6dc, 0xdcd8, 0xdccd, 0xb6df, 0xdcd6, 0xb6da, 0xdcd2, 0xdcd9,
+  0xdcdb, 0xdcdf, 0xb6e3, 0xdccb, 0xb6dd, 0xdcd0, 0xb6d8, 0xb6e4,
+  0xdcda, 0xb6e0, 0xb6e1, 0xb6e7, 0xb6db, 0xa25f, 0xb6d9, 0xdcd4,
+  0xb6e2, 0xdcdd, 0xb9cd, 0xb9c8, 0xe155, 0xe151, 0xe14b, 0xb9c2,
+  0xb9be, 0xe154, 0xb9bf, 0xe14e, 0xe150, 0xe153, 0xb9c4, 0xb9cb,
+  0xb9c5, 0xe149, 0xb9c6, 0xb9c7, 0xe14c, 0xb9cc, 0xe14a, 0xe14f,
+  0xb9c3, 0xe148, 0xb9c9, 0xb9c1, 0xb9c0, 0xe14d, 0xe152, 0xb9ca,
+  0xe147, 0xbc4d, 0xe547, 0xe544, 0xbc47, 0xbc53, 0xbc54, 0xbc4a,
+  0xe542, 0xbc4c, 0xe4f9, 0xbc52, 0xe546, 0xbc49, 0xe548, 0xbc48,
+  0xe543, 0xe545, 0xbc4b, 0xe541, 0xe4fa, 0xe4f7, 0xd86b, 0xe4fd,
+  0xe4f6, 0xe4fc, 0xe4fb, 0xe4f8, 0xbc4f, 0xbc4e, 0xbc50, 0xe4fe,
+  0xbeb2, 0xe540, 0xe945, 0xe8fd, 0xbebe, 0xe942, 0xbeb6, 0xbeba,
+  0xe941, 0xbeb9, 0xbeb5, 0xbeb8, 0xbeb3, 0xbebd, 0xe943, 0xe8fe,
+  0xbebc, 0xe8fc, 0xbebb, 0xe944, 0xe940, 0xbc51, 0xbebf, 0xe946,
+  0xbeb7, 0xbeb4, 0xecc6, 0xecc8, 0xc07b, 0xecc9, 0xecc7, 0xecc5,
+  0xecc4, 0xc07d, 0xecc3, 0xc07e, 0xecc1, 0xecc2, 0xc07a, 0xc0a1,
+  0xc07c, 0xecc0, 0xc250, 0xefbc, 0xefba, 0xefbf, 0xefbd, 0xefbb,
+  0xefbe, 0xc360, 0xf1f2, 0xf1f3, 0xc456, 0xf1f4, 0xf1f0, 0xf1f5,
+  0xf1f1, 0xc251, 0xf3fe, 0xf441, 0xc459, 0xf440, 0xc458, 0xc457,
+  0xc45a, 0xf5c5, 0xf5c6, 0xc4da, 0xc4d9, 0xc4db, 0xf5c4, 0xf6d8,
+  0xf6d7, 0xc56d, 0xc56f, 0xc56e, 0xf6d9, 0xc5c8, 0xf8a6, 0xc5f1,
+  0xf8a5, 0xf8ee, 0xc949, 0xa57d, 0xa57c, 0xa65f, 0xa65e, 0xc9c7,
+  0xa65d, 0xc9c6, 0xa779, 0xcaa9, 0xcaa8, 0xa777, 0xa77a, 0xcaa7,
+  0xa778, 0xcbf0, 0xcbf1, 0xa954, 0xabaa, 0xd148, 0xd149, 0xae45,
+  0xae46, 0xd4ac, 0xb0e9, 0xb0eb, 0xd4ab, 0xb0ea, 0xd87c, 0xb3f2,
+  0xb6e9, 0xb6ea, 0xdce1, 0xb9cf, 0xb9ce, 0xe549, 0xe948, 0xe947,
+  0xf96b, 0xa467, 0xc959, 0xc96e, 0xc96f, 0xa662, 0xa666, 0xc9c9,
+  0xa664, 0xa663, 0xc9c8, 0xa665, 0xa661, 0xa660, 0xc9ca, 0xa7a6,
+  0xa7a3, 0xa77d, 0xcaaa, 0xcaab, 0xa7a1, 0xcaad, 0xa77b, 0xcaae,
+  0xcaac, 0xa77e, 0xa7a2, 0xa7a5, 0xa7a4, 0xa77c, 0xcaaf, 0xa959,
+  0xcbfe, 0xa95b, 0xa95a, 0xcc40, 0xa958, 0xa957, 0xcbf5, 0xcbf4,
+  0xcbf2, 0xcbf7, 0xcbf6, 0xcbf3, 0xcbfc, 0xcbfd, 0xcbfa, 0xcbf8,
+  0xa956, 0xcbfb, 0xa95c, 0xcc41, 0xcbf9, 0xabab, 0xa955, 0xabac,
+  0xce54, 0xce5a, 0xabb2, 0xce58, 0xce5e, 0xce55, 0xce59, 0xce5b,
+  0xce5d, 0xce57, 0xce56, 0xce51, 0xce52, 0xabad, 0xabaf, 0xabae,
+  0xce53, 0xce5c, 0xabb1, 0xce50, 0xd153, 0xd152, 0xd157, 0xd14e,
+  0xd151, 0xd150, 0xd154, 0xd158, 0xae47, 0xae4a, 0xd14f, 0xd155,
+  0xae49, 0xd14a, 0xabb0, 0xd4ba, 0xd156, 0xd14d, 0xae48, 0xd14c,
+  0xd4b1, 0xb0ec, 0xb0f0, 0xd4c1, 0xd4af, 0xd4bd, 0xb0f1, 0xd4bf,
+  0xd4c5, 0xd4c9, 0xd4c0, 0xd4b4, 0xd4bc, 0xd4ca, 0xd4c8, 0xd4be,
+  0xd4b9, 0xd4b2, 0xd8a6, 0xd4b0, 0xb0f5, 0xd4b7, 0xb0f6, 0xb0f2,
+  0xd4ad, 0xd4c3, 0xd4b5, 0xd4b3, 0xd4c6, 0xb0f3, 0xd4cc, 0xb0ed,
+  0xb0ef, 0xd4bb, 0xd4b6, 0xae4b, 0xb0ee, 0xd4b8, 0xd4c7, 0xd4cb,
+  0xd4c2, 0xd4c4, 0xd4ae, 0xd8a1, 0xd8aa, 0xd8a9, 0xb3fa, 0xd8a2,
+  0xb3fb, 0xb3f9, 0xd8a4, 0xb3f6, 0xd8a8, 0xd8a3, 0xd8a5, 0xd87d,
+  0xb3f4, 0xd8b2, 0xd8b1, 0xd8ae, 0xb3f3, 0xb3f7, 0xb3f8, 0xd14b,
+  0xd8ab, 0xb3f5, 0xb0f4, 0xd8ad, 0xd87e, 0xd8b0, 0xd8af, 0xd8b3,
+  0xdcef, 0xd8ac, 0xd8a7, 0xdce7, 0xb6f4, 0xb6f7, 0xb6f2, 0xdce6,
+  0xdcea, 0xdce5, 0xb6ec, 0xb6f6, 0xdce2, 0xb6f0, 0xdce9, 0xb6ee,
+  0xb6ed, 0xdcec, 0xb6ef, 0xdcee, 0xdceb, 0xb6eb, 0xb6f5, 0xdcf0,
+  0xdce4, 0xdced, 0xdce3, 0xb6f1, 0xb6f3, 0xdce8, 0xdcf1, 0xe15d,
+  0xb9d0, 0xe163, 0xb9d5, 0xe15f, 0xe166, 0xe157, 0xb9d7, 0xb9d1,
+  0xe15c, 0xbc55, 0xe15b, 0xe164, 0xb9d2, 0xb9d6, 0xe15a, 0xe160,
+  0xe165, 0xe156, 0xb9d4, 0xe15e, 0xe162, 0xe168, 0xe158, 0xe161,
+  0xb9d3, 0xe167, 0xe159, 0xbc59, 0xe54b, 0xbc57, 0xbc56, 0xe54d,
+  0xe552, 0xe54e, 0xe551, 0xbc5c, 0xbea5, 0xbc5b, 0xe54a, 0xe550,
+  0xbc5a, 0xe54f, 0xe54c, 0xbc58, 0xe94d, 0xe94f, 0xe94a, 0xbec1,
+  0xe94c, 0xbec0, 0xe94e, 0xbec3, 0xe950, 0xbec2, 0xe949, 0xe94b,
+  0xc0a5, 0xeccc, 0xc0a4, 0xeccd, 0xc0a3, 0xeccb, 0xc0a2, 0xecca,
+  0xc253, 0xc252, 0xf1f6, 0xf1f8, 0xf1f7, 0xc361, 0xc362, 0xc363,
+  0xf442, 0xc45b, 0xf7d3, 0xf7d2, 0xc5f2, 0xa468, 0xa4d0, 0xa7a7,
+  0xce5f, 0xb3fc, 0xb3fd, 0xdcf2, 0xb9d8, 0xe169, 0xe553, 0xc95a,
+  0xcab0, 0xcc42, 0xce60, 0xd159, 0xae4c, 0xf1f9, 0xc4dc, 0xa469,
+  0xa57e, 0xc970, 0xa667, 0xa668, 0xa95d, 0xb0f7, 0xb9da, 0xb9db,
+  0xb9d9, 0xa46a, 0xa4d1, 0xa4d3, 0xa4d2, 0xc95b, 0xa4d4, 0xa5a1,
+  0xc971, 0xa5a2, 0xa669, 0xa66a, 0xc9cb, 0xa7a8, 0xcab1, 0xa961,
+  0xcc43, 0xa95f, 0xa960, 0xa95e, 0xd15a, 0xabb6, 0xabb5, 0xabb7,
+  0xabb4, 0xce61, 0xa962, 0xabb3, 0xae4d, 0xae4e, 0xae4f, 0xd4cd,
+  0xb3fe, 0xd8b4, 0xb0f8, 0xb6f8, 0xb9dd, 0xb9dc, 0xe16a, 0xbc5d,
+  0xbec4, 0xefc0, 0xf6da, 0xf7d4, 0xa46b, 0xa5a3, 0xa5a4, 0xc9d1,
+  0xa66c, 0xa66f, 0xc9cf, 0xc9cd, 0xa66e, 0xc9d0, 0xc9d2, 0xc9cc,
+  0xa671, 0xa670, 0xa66d, 0xa66b, 0xc9ce, 0xa7b3, 0xa7b0, 0xcab6,
+  0xcab9, 0xcab8, 0xa7aa, 0xa7b2, 0xa7af, 0xcab5, 0xcab3, 0xa7ae,
+  0xa7a9, 0xa7ac, 0xcab4, 0xcabb, 0xcab7, 0xa7ad, 0xa7b1, 0xa7b4,
+  0xcab2, 0xcaba, 0xa7ab, 0xa967, 0xa96f, 0xcc4f, 0xcc48, 0xa970,
+  0xcc53, 0xcc44, 0xcc4b, 0xa966, 0xcc45, 0xa964, 0xcc4c, 0xcc50,
+  0xa963, 0xcc51, 0xcc4a, 0xcc4d, 0xa972, 0xa969, 0xcc54, 0xcc52,
+  0xa96e, 0xa96c, 0xcc49, 0xa96b, 0xcc47, 0xcc46, 0xa96a, 0xa968,
+  0xa971, 0xa96d, 0xa965, 0xcc4e, 0xabb9, 0xabc0, 0xce6f, 0xabb8,
+  0xce67, 0xce63, 0xce73, 0xce62, 0xabbb, 0xce6c, 0xabbe, 0xabc1,
+  0xabbc, 0xce70, 0xabbf, 0xae56, 0xce76, 0xce64, 0xce66, 0xce6d,
+  0xce71, 0xce75, 0xce72, 0xce6b, 0xce6e, 0xce68, 0xabc3, 0xce6a,
+  0xce69, 0xce74, 0xabba, 0xce65, 0xabc2, 0xabbd, 0xae5c, 0xd162,
+  0xae5b, 0xd160, 0xae50, 0xae55, 0xd15f, 0xd15c, 0xd161, 0xae51,
+  0xd15b, 0xae54, 0xae52, 0xd163, 0xae53, 0xae57, 0xae58, 0xae5a,
+  0xae59, 0xd15d, 0xd15e, 0xd164, 0xd4d4, 0xb0f9, 0xd8c2, 0xd4d3,
+  0xd4e6, 0xb140, 0xd4e4, 0xb0fe, 0xb0fa, 0xd4ed, 0xd4dd, 0xd4e0,
+  0xb143, 0xd4ea, 0xd4e2, 0xb0fb, 0xb144, 0xd4e7, 0xd4e5, 0xd4d6,
+  0xd4eb, 0xd4df, 0xd4da, 0xd4d0, 0xd4ec, 0xd4dc, 0xd4cf, 0xb142,
+  0xd4e1, 0xd4ee, 0xd4de, 0xd4d2, 0xd4d7, 0xd4ce, 0xb141, 0xd4db,
+  0xd4d8, 0xb0fc, 0xd4d1, 0xd4e9, 0xb0fd, 0xd4d9, 0xd4d5, 0xd4e8,
+  0xb440, 0xd8bb, 0xd8b8, 0xd8c9, 0xd8bd, 0xd8ca, 0xb442, 0xd8c6,
+  0xd8c3, 0xd8c4, 0xd8c7, 0xd8cb, 0xd4e3, 0xd8cd, 0xdd47, 0xb443,
+  0xd8ce, 0xd8b6, 0xd8c0, 0xd8c5, 0xb441, 0xb444, 0xd8cc, 0xd8cf,
+  0xd8ba, 0xd8b7, 0xd8b9, 0xd8be, 0xd8bc, 0xb445, 0xd8c8, 0xd8bf,
+  0xd8c1, 0xd8b5, 0xdcfa, 0xdcf8, 0xb742, 0xb740, 0xdd43, 0xdcf9,
+  0xdd44, 0xdd40, 0xdcf7, 0xdd46, 0xdcf6, 0xdcfd, 0xb6fe, 0xb6fd,
+  0xb6fc, 0xdcfb, 0xdd41, 0xb6f9, 0xb741, 0xdcf4, 0xdcfe, 0xdcf3,
+  0xdcfc, 0xb6fa, 0xdd42, 0xdcf5, 0xb6fb, 0xdd45, 0xe16e, 0xb9e2,
+  0xb9e1, 0xb9e3, 0xe17a, 0xe170, 0xe176, 0xe16b, 0xe179, 0xe178,
+  0xe17c, 0xe175, 0xb9de, 0xe174, 0xb9e4, 0xe16d, 0xb9df, 0xe17b,
+  0xb9e0, 0xe16f, 0xe172, 0xe177, 0xe171, 0xe16c, 0xe173, 0xe555,
+  0xbc61, 0xe558, 0xe557, 0xe55a, 0xe55c, 0xbc5f, 0xe556, 0xe554,
+  0xe55d, 0xe55b, 0xe559, 0xe55f, 0xe55e, 0xbc63, 0xbc5e, 0xbc60,
+  0xbc62, 0xe560, 0xe957, 0xe956, 0xe955, 0xe958, 0xe951, 0xe952,
+  0xe95a, 0xe953, 0xbec5, 0xe95c, 0xe95b, 0xe954, 0xecd1, 0xc0a8,
+  0xeccf, 0xecd4, 0xecd3, 0xe959, 0xc0a7, 0xecd2, 0xecce, 0xecd6,
+  0xecd5, 0xc0a6, 0xecd0, 0xbec6, 0xc254, 0xefc1, 0xf1fa, 0xf1fb,
+  0xf1fc, 0xc45c, 0xc45d, 0xf443, 0xf5c8, 0xf5c7, 0xf6db, 0xf6dc,
+  0xf7d5, 0xf8a7, 0xa46c, 0xa46d, 0xa46e, 0xa4d5, 0xa5a5, 0xc9d3,
+  0xa672, 0xa673, 0xa7b7, 0xa7b8, 0xa7b6, 0xa7b5, 0xa973, 0xcc55,
+  0xa975, 0xa974, 0xcc56, 0xabc4, 0xae5d, 0xd165, 0xd4f0, 0xb145,
+  0xb447, 0xd4ef, 0xb446, 0xb9e5, 0xe17d, 0xbec7, 0xc0a9, 0xecd7,
+  0xc45e, 0xc570, 0xc972, 0xa5a6, 0xc973, 0xa676, 0xa674, 0xa675,
+  0xa677, 0xa7ba, 0xa7b9, 0xcabc, 0xa7bb, 0xcabd, 0xcc57, 0xcc58,
+  0xa976, 0xa978, 0xa97a, 0xa977, 0xa97b, 0xa979, 0xabc8, 0xabc5,
+  0xabc7, 0xabc9, 0xabc6, 0xd166, 0xce77, 0xd168, 0xd167, 0xae63,
+  0xae5f, 0xae60, 0xae62, 0xae64, 0xae61, 0xae66, 0xae65, 0xb14a,
+  0xd4f2, 0xd4f1, 0xb149, 0xb148, 0xb147, 0xb14b, 0xb146, 0xd8d5,
+  0xd8d2, 0xb449, 0xd8d1, 0xd8d6, 0xb44b, 0xd8d4, 0xb448, 0xb44a,
+  0xd8d3, 0xdd48, 0xdd49, 0xdd4a, 0xb9e6, 0xb9ee, 0xe17e, 0xb9e8,
+  0xb9ec, 0xe1a1, 0xb9ed, 0xb9e9, 0xb9ea, 0xb9e7, 0xb9eb, 0xbc66,
+  0xd8d0, 0xbc67, 0xbc65, 0xbc64, 0xe95d, 0xbec8, 0xecd8, 0xecd9,
+  0xc364, 0xc45f, 0xa46f, 0xa678, 0xabca, 0xd169, 0xae67, 0xb14e,
+  0xb14d, 0xb14c, 0xb44c, 0xb44d, 0xd8d7, 0xb9ef, 0xbec9, 0xa470,
+  0xc95c, 0xa4d6, 0xc974, 0xc9d4, 0xa679, 0xa97c, 0xdd4b, 0xa471,
+  0xa4d7, 0xc9d5, 0xcabe, 0xcabf, 0xa7bc, 0xd8d8, 0xb44e, 0xdd4c,
+  0xc0aa, 0xa472, 0xa4a8, 0xa4d8, 0xc975, 0xa5a7, 0xa7c0, 0xa7bf,
+  0xa7bd, 0xa7be, 0xcc59, 0xa97e, 0xa9a1, 0xcc5a, 0xa97d, 0xabce,
+  0xce78, 0xabcd, 0xabcb, 0xabcc, 0xae6a, 0xae68, 0xd16b, 0xae69,
+  0xd16a, 0xae5e, 0xd4f3, 0xb150, 0xb151, 0xb14f, 0xb9f0, 0xe1a2,
+  0xbc68, 0xbc69, 0xe561, 0xc0ab, 0xefc2, 0xefc3, 0xc4dd, 0xf8a8,
+  0xc94b, 0xa4d9, 0xa473, 0xc977, 0xc976, 0xa67a, 0xc9d7, 0xc9d8,
+  0xc9d6, 0xc9d9, 0xcac7, 0xcac2, 0xcac4, 0xcac6, 0xcac3, 0xa7c4,
+  0xcac0, 0xcac1, 0xa7c1, 0xa7c2, 0xcac5, 0xcac8, 0xa7c3, 0xcac9,
+  0xcc68, 0xcc62, 0xcc5d, 0xa9a3, 0xcc65, 0xcc63, 0xcc5c, 0xcc69,
+  0xcc6c, 0xcc67, 0xcc60, 0xa9a5, 0xcc66, 0xa9a6, 0xcc61, 0xcc64,
+  0xcc5b, 0xcc5f, 0xcc6b, 0xa9a7, 0xa9a8, 0xcc5e, 0xcc6a, 0xa9a2,
+  0xa9a4, 0xceab, 0xcea4, 0xceaa, 0xcea3, 0xcea5, 0xce7d, 0xce7b,
+  0xceac, 0xcea9, 0xce79, 0xabd0, 0xcea7, 0xcea8, 0xcea6, 0xce7c,
+  0xce7a, 0xabcf, 0xcea2, 0xce7e, 0xcea1, 0xcead, 0xae6f, 0xae6e,
+  0xd16c, 0xae6b, 0xd16e, 0xae70, 0xd16f, 0xae73, 0xae71, 0xd170,
+  0xceae, 0xd172, 0xae6d, 0xae6c, 0xd16d, 0xd171, 0xae72, 0xb153,
+  0xb152, 0xd4f5, 0xd4f9, 0xd4fb, 0xb154, 0xd4fe, 0xb158, 0xd541,
+  0xb15a, 0xb156, 0xb15e, 0xb15b, 0xd4f7, 0xb155, 0xd4f6, 0xd4f4,
+  0xd543, 0xd4f8, 0xb157, 0xd542, 0xb15c, 0xd4fd, 0xd4fc, 0xb15d,
+  0xd4fa, 0xb159, 0xd544, 0xd540, 0xd8e7, 0xd8ee, 0xd8e3, 0xb451,
+  0xd8df, 0xd8ef, 0xd8d9, 0xd8ec, 0xd8ea, 0xd8e4, 0xd8ed, 0xd8e6,
+  0xd8de, 0xd8f0, 0xd8dc, 0xd8e9, 0xd8da, 0xd8f1, 0xb452, 0xd8eb,
+  0xdd4f, 0xd8dd, 0xb44f, 0xd8e1, 0xb450, 0xd8e0, 0xd8e5, 0xd8e2,
+  0xd8e8, 0xdd53, 0xdd56, 0xdd4e, 0xdd50, 0xdd55, 0xdd54, 0xb743,
+  0xd8db, 0xdd52, 0xb744, 0xdd4d, 0xdd51, 0xe1a9, 0xe1b0, 0xe1a7,
+  0xe1ae, 0xe1a5, 0xe1ad, 0xe1b1, 0xe1a4, 0xe1a8, 0xe1a3, 0xb9f1,
+  0xe1a6, 0xb9f2, 0xe1ac, 0xe1ab, 0xe1aa, 0xe1af, 0xe565, 0xe567,
+  0xbc6b, 0xe568, 0xe563, 0xe562, 0xe56c, 0xe56a, 0xbc6a, 0xe56d,
+  0xe564, 0xe569, 0xe56b, 0xe566, 0xe961, 0xe966, 0xe960, 0xe965,
+  0xe95e, 0xe968, 0xe964, 0xe969, 0xe963, 0xe95f, 0xe967, 0xe96a,
+  0xe962, 0xecda, 0xc0af, 0xc0ad, 0xc0ac, 0xc0ae, 0xefc4, 0xf172,
+  0xf1fd, 0xf444, 0xf445, 0xc460, 0xf5c9, 0xc4de, 0xf5ca, 0xf6de,
+  0xc572, 0xc571, 0xf6dd, 0xc5c9, 0xf7d6, 0xa474, 0xa67b, 0xc9da,
+  0xcaca, 0xa8b5, 0xb15f, 0xa475, 0xa5aa, 0xa5a9, 0xa5a8, 0xa7c5,
+  0xae74, 0xdd57, 0xa476, 0xa477, 0xa478, 0xa4da, 0xabd1, 0xceaf,
+  0xb453, 0xa479, 0xc95d, 0xa5ab, 0xa5ac, 0xc978, 0xa67c, 0xcacb,
+  0xa7c6, 0xcacc, 0xa9ae, 0xcc6e, 0xa9ac, 0xa9ab, 0xcc6d, 0xa9a9,
+  0xcc6f, 0xa9aa, 0xa9ad, 0xabd2, 0xabd4, 0xceb3, 0xceb0, 0xceb1,
+  0xceb2, 0xceb4, 0xabd3, 0xd174, 0xd173, 0xae76, 0xae75, 0xb162,
+  0xd546, 0xb161, 0xb163, 0xb160, 0xb455, 0xd545, 0xb456, 0xd8f3,
+  0xb457, 0xd8f2, 0xb454, 0xdd5a, 0xdd5c, 0xb745, 0xdd5b, 0xdd59,
+  0xdd58, 0xe1b4, 0xb9f7, 0xb9f5, 0xb9f6, 0xe1b2, 0xe1b3, 0xb9f3,
+  0xe571, 0xe56f, 0xbc6d, 0xe570, 0xbc6e, 0xbc6c, 0xb9f4, 0xe96d,
+  0xe96b, 0xe96c, 0xe56e, 0xecdc, 0xc0b0, 0xecdb, 0xefc5, 0xefc6,
+  0xe96e, 0xf1fe, 0xa47a, 0xa5ad, 0xa67e, 0xc9db, 0xa67d, 0xa9af,
+  0xb746, 0xa4db, 0xa5ae, 0xabd5, 0xb458, 0xc979, 0xc97a, 0xc9dc,
+  0xa7c8, 0xcad0, 0xcace, 0xa7c9, 0xcacd, 0xcacf, 0xcad1, 0xa7c7,
+  0xa9b3, 0xa9b4, 0xa9b1, 0xa9b0, 0xceb8, 0xa9b2, 0xabd6, 0xceb7,
+  0xceb9, 0xceb6, 0xceba, 0xabd7, 0xae79, 0xd175, 0xd177, 0xae77,
+  0xd178, 0xae78, 0xd176, 0xceb5, 0xd547, 0xd54a, 0xd54b, 0xd548,
+  0xb167, 0xb166, 0xb164, 0xb165, 0xd549, 0xb168, 0xb45a, 0xb45b,
+  0xb45c, 0xdd5d, 0xdd5f, 0xdd61, 0xb748, 0xb747, 0xb459, 0xdd60,
+  0xdd5e, 0xe1b8, 0xe1b6, 0xe1bc, 0xb9f8, 0xe1bd, 0xe1ba, 0xb9f9,
+  0xe1b7, 0xe1b5, 0xe1bb, 0xbc70, 0xe573, 0xe1b9, 0xbc72, 0xe574,
+  0xbc71, 0xbc74, 0xe575, 0xbc6f, 0xbc73, 0xe973, 0xe971, 0xe970,
+  0xe972, 0xe96f, 0xc366, 0xf446, 0xf447, 0xf5cb, 0xf6df, 0xc655,
+  0xa9b5, 0xa7ca, 0xabd8, 0xa47b, 0xa4dc, 0xa5af, 0xc9dd, 0xa7cb,
+  0xcad2, 0xcebb, 0xabd9, 0xb9fa, 0xa47c, 0xa6a1, 0xb749, 0xa47d,
+  0xa4dd, 0xa4de, 0xa5b1, 0xa5b0, 0xc9de, 0xa6a2, 0xcad3, 0xa7cc,
+  0xcc71, 0xcc72, 0xcc73, 0xa9b6, 0xa9b7, 0xcc70, 0xa9b8, 0xabda,
+  0xcebc, 0xd17a, 0xae7a, 0xd179, 0xb169, 0xd54c, 0xb16a, 0xd54d,
+  0xb45d, 0xdd62, 0xe1bf, 0xe1be, 0xb9fb, 0xbc75, 0xe576, 0xbeca,
+  0xe974, 0xc0b1, 0xc573, 0xf7d8, 0xcc74, 0xcebd, 0xb16b, 0xd8f4,
+  0xb74a, 0xc255, 0xa7ce, 0xa7cd, 0xabdb, 0xd17b, 0xb16d, 0xb343,
+  0xb16e, 0xb16c, 0xb45e, 0xe1c0, 0xb9fc, 0xbc76, 0xc94c, 0xc9df,
+  0xcad5, 0xa7cf, 0xcad4, 0xa7d0, 0xa9bc, 0xcc77, 0xcc76, 0xa9bb,
+  0xa9b9, 0xa9ba, 0xcc75, 0xabdd, 0xcebe, 0xabe0, 0xabdc, 0xabe2,
+  0xabde, 0xabdf, 0xabe1, 0xae7d, 0xae7c, 0xae7b, 0xd54f, 0xb16f,
+  0xb172, 0xb170, 0xd54e, 0xb175, 0xb171, 0xd550, 0xb174, 0xb173,
+  0xd8f6, 0xd8f5, 0xb461, 0xb45f, 0xb460, 0xd8f7, 0xb74b, 0xdd64,
+  0xb74c, 0xdd63, 0xe577, 0xbc78, 0xe1c1, 0xbc77, 0xb9fd, 0xecde,
+  0xe975, 0xc0b2, 0xecdd, 0xf240, 0xf448, 0xf449, 0xa4df, 0xa5b2,
+  0xc97b, 0xa7d2, 0xa7d4, 0xc9e2, 0xcad8, 0xcad7, 0xcad6, 0xc9e1,
+  0xc9e0, 0xa6a4, 0xa7d3, 0xa7d1, 0xa6a3, 0xa9bd, 0xcc78, 0xa9be,
+  0xcadd, 0xcadf, 0xcade, 0xcc79, 0xcada, 0xa7d8, 0xa7d6, 0xcad9,
+  0xcadb, 0xcae1, 0xa7d5, 0xcadc, 0xcae5, 0xa9c0, 0xcae2, 0xa7d7,
+  0xcae0, 0xcae3, 0xa9bf, 0xa9c1, 0xcae4, 0xccaf, 0xcca2, 0xcc7e,
+  0xccae, 0xcca9, 0xabe7, 0xa9c2, 0xccaa, 0xccad, 0xabe3, 0xccac,
+  0xa9c3, 0xa9c8, 0xa9c6, 0xcca3, 0xcc7c, 0xcca5, 0xa9cd, 0xccb0,
+  0xabe4, 0xcca6, 0xabe5, 0xa9c9, 0xcca8, 0xcecd, 0xabe6, 0xcc7b,
+  0xa9ca, 0xabe8, 0xa9cb, 0xa9c7, 0xa9cc, 0xcca7, 0xcc7a, 0xccab,
+  0xa9c4, 0xcc7d, 0xcca4, 0xcca1, 0xa9c5, 0xcebf, 0xcec0, 0xceca,
+  0xd1a1, 0xcecb, 0xabee, 0xcece, 0xcec4, 0xabed, 0xcec6, 0xcec7,
+  0xcec9, 0xabe9, 0xaea3, 0xcec5, 0xcec1, 0xaea4, 0xcecf, 0xae7e,
+  0xd17d, 0xcec8, 0xd17c, 0xcec3, 0xcecc, 0xabec, 0xaea1, 0xabf2,
+  0xaea2, 0xced0, 0xd17e, 0xabeb, 0xaea6, 0xabf1, 0xabf0, 0xabef,
+  0xaea5, 0xced1, 0xaea7, 0xabea, 0xcec2, 0xb176, 0xd1a4, 0xd1a6,
+  0xd1a8, 0xaea8, 0xaeae, 0xd553, 0xd1ac, 0xd1a3, 0xb178, 0xd551,
+  0xaead, 0xaeab, 0xd1ae, 0xd552, 0xd1a5, 0xaeac, 0xd1a9, 0xaeaf,
+  0xd1ab, 0xaeaa, 0xd1aa, 0xd1ad, 0xd1a7, 0xaea9, 0xb179, 0xd1a2,
+  0xb177, 0xb17a, 0xd555, 0xd55e, 0xb464, 0xb17c, 0xb1a3, 0xb465,
+  0xd560, 0xb1aa, 0xd8f9, 0xd556, 0xb1a2, 0xb1a5, 0xb17e, 0xd554,
+  0xd562, 0xd565, 0xd949, 0xd563, 0xd8fd, 0xb1a1, 0xb1a8, 0xb1ac,
+  0xd55d, 0xd8f8, 0xd561, 0xb17b, 0xd8fa, 0xd564, 0xd8fc, 0xd559,
+  0xb462, 0xd557, 0xd558, 0xb1a7, 0xb1a6, 0xd55b, 0xb1ab, 0xd55f,
+  0xb1a4, 0xd55c, 0xb1a9, 0xb466, 0xb463, 0xd8fb, 0xd55a, 0xb17d,
+  0xb46b, 0xb46f, 0xd940, 0xb751, 0xb46d, 0xd944, 0xb471, 0xdd65,
+  0xd946, 0xb753, 0xb469, 0xb46c, 0xd947, 0xd948, 0xd94e, 0xb473,
+  0xb754, 0xd94a, 0xd94f, 0xd943, 0xb75e, 0xb755, 0xb472, 0xd941,
+  0xd950, 0xb75d, 0xb470, 0xb74e, 0xd94d, 0xb474, 0xd945, 0xd8fe,
+  0xb46a, 0xd942, 0xd94b, 0xb74d, 0xb752, 0xb467, 0xd94c, 0xb750,
+  0xb468, 0xb75c, 0xe1c3, 0xdd70, 0xdd68, 0xe1c2, 0xdd6c, 0xdd6e,
+  0xdd6b, 0xb75b, 0xdd6a, 0xb75f, 0xe1d2, 0xb75a, 0xba40, 0xdd71,
+  0xe1c4, 0xb758, 0xdd69, 0xdd6d, 0xb9fe, 0xb74f, 0xdd66, 0xdd67,
+  0xba41, 0xb757, 0xb759, 0xb756, 0xdd6f, 0xe1c8, 0xe1c9, 0xe1ce,
+  0xbc7d, 0xe1d5, 0xba47, 0xba46, 0xe1d0, 0xbc7c, 0xe1c5, 0xba45,
+  0xe1d4, 0xba43, 0xba44, 0xe1d1, 0xe5aa, 0xbc7a, 0xb46e, 0xe1d3,
+  0xbca3, 0xe1cb, 0xbc7b, 0xbca2, 0xe1c6, 0xe1ca, 0xe1c7, 0xe1cd,
+  0xba48, 0xbc79, 0xba42, 0xe57a, 0xe1cf, 0xbca1, 0xbca4, 0xe1cc,
+  0xbc7e, 0xe579, 0xe57e, 0xbece, 0xe578, 0xe9a3, 0xe5a9, 0xbca8,
+  0xbca6, 0xbecc, 0xe5a6, 0xe5a2, 0xbcac, 0xe978, 0xbcaa, 0xe5a1,
+  0xe976, 0xe5a5, 0xe5a8, 0xe57d, 0xbcab, 0xbca5, 0xe977, 0xbecd,
+  0xe5a7, 0xbca7, 0xbca9, 0xe5a4, 0xbcad, 0xe5a3, 0xe57c, 0xe57b,
+  0xbecb, 0xe5ab, 0xe97a, 0xece0, 0xbed0, 0xe9a2, 0xe97e, 0xece1,
+  0xbed1, 0xe9a1, 0xe97c, 0xc0b4, 0xecdf, 0xe979, 0xe97b, 0xc0b5,
+  0xbed3, 0xc0b3, 0xbed2, 0xc0b7, 0xe97d, 0xbecf, 0xefcf, 0xefc7,
+  0xece7, 0xefc8, 0xece3, 0xc256, 0xece5, 0xece4, 0xc0b6, 0xece2,
+  0xece6, 0xefd0, 0xefcc, 0xefce, 0xefc9, 0xefca, 0xefcd, 0xefcb,
+  0xc367, 0xc36a, 0xc369, 0xc368, 0xc461, 0xf44a, 0xc462, 0xf241,
+  0xc4df, 0xf5cc, 0xc4e0, 0xc574, 0xc5ca, 0xf7d9, 0xf7da, 0xf7db,
+  0xf9ba, 0xa4e0, 0xc97c, 0xa5b3, 0xa6a6, 0xa6a7, 0xa6a5, 0xa6a8,
+  0xa7da, 0xa7d9, 0xccb1, 0xa9cf, 0xa9ce, 0xd1af, 0xb1ad, 0xb1ae,
+  0xb475, 0xdd72, 0xb760, 0xb761, 0xdd74, 0xdd76, 0xdd75, 0xe1d7,
+  0xe1d6, 0xba49, 0xe1d8, 0xe5ac, 0xbcae, 0xbed4, 0xc0b8, 0xc257,
+  0xc0b9, 0xa4e1, 0xcae6, 0xccb2, 0xa9d1, 0xa9d0, 0xa9d2, 0xabf3,
+  0xced2, 0xced3, 0xd1b0, 0xaeb0, 0xb1af, 0xb476, 0xd951, 0xa4e2,
+  0xa47e, 0xa4e3, 0xc97d, 0xa5b7, 0xa5b6, 0xa5b4, 0xa5b5, 0xa6ab,
+  0xc9e9, 0xc9eb, 0xa6aa, 0xc9e3, 0xc9e4, 0xc9ea, 0xc9e6, 0xc9e8,
+  0xa6a9, 0xc9e5, 0xc9ec, 0xc9e7, 0xa7e1, 0xa7ea, 0xa7e8, 0xcaf0,
+  0xcaed, 0xcaf5, 0xa7e6, 0xcaf6, 0xa7df, 0xcaf3, 0xa7e5, 0xcaef,
+  0xcaee, 0xa7e3, 0xcaf4, 0xa7e4, 0xa9d3, 0xa7de, 0xcaf1, 0xcae7,
+  0xa7db, 0xa7ee, 0xcaec, 0xcaf2, 0xa7e0, 0xa7e2, 0xcae8, 0xcae9,
+  0xcaea, 0xa7ed, 0xa7e7, 0xa7ec, 0xcaeb, 0xa7eb, 0xa7dd, 0xa7dc,
+  0xa7e9, 0xa9e1, 0xccbe, 0xccb7, 0xa9dc, 0xa9ef, 0xccb3, 0xccba,
+  0xccbc, 0xccbf, 0xa9ea, 0xccbb, 0xccb4, 0xa9e8, 0xccb8, 0xccc0,
+  0xa9d9, 0xccbd, 0xa9e3, 0xa9e2, 0xccb6, 0xa9d7, 0xa9d8, 0xa9d6,
+  0xa9ee, 0xa9e6, 0xa9e0, 0xa9d4, 0xccb9, 0xa9df, 0xa9d5, 0xa9e7,
+  0xa9f0, 0xced4, 0xa9e4, 0xccb5, 0xa9da, 0xa9dd, 0xa9de, 0xa9ec,
+  0xa9ed, 0xa9eb, 0xa9e5, 0xa9e9, 0xa9db, 0xabf4, 0xceda, 0xac41,
+  0xabf8, 0xabfa, 0xac40, 0xcee6, 0xabfd, 0xd1b1, 0xaeb1, 0xac43,
+  0xced7, 0xcedf, 0xabfe, 0xcede, 0xcedb, 0xcee3, 0xcee5, 0xabf7,
+  0xabfb, 0xac42, 0xaeb3, 0xcee0, 0xabf9, 0xac45, 0xced9, 0xabfc,
+  0xaeb2, 0xabf6, 0xced6, 0xcedd, 0xced5, 0xced8, 0xcedc, 0xd1b2,
+  0xac44, 0xcee1, 0xcee2, 0xcee4, 0xabf5, 0xaec1, 0xd1be, 0xaebf,
+  0xaec0, 0xd1b4, 0xd1c4, 0xaeb6, 0xd566, 0xd1c6, 0xd1c0, 0xd1b7,
+  0xd1c9, 0xd1ba, 0xaebc, 0xd57d, 0xd1bd, 0xaebe, 0xaeb5, 0xd1cb,
+  0xd1bf, 0xaeb8, 0xd1b8, 0xd1b5, 0xd1b6, 0xaeb9, 0xd1c5, 0xd1cc,
+  0xaebb, 0xd1bc, 0xd1bb, 0xaec3, 0xaec2, 0xaeb4, 0xaeba, 0xaebd,
+  0xd1c8, 0xd1c2, 0xaeb7, 0xd1b3, 0xd1ca, 0xd1c1, 0xd1c3, 0xd1c7,
+  0xd567, 0xb1b7, 0xb1cb, 0xb1ca, 0xb1bf, 0xd579, 0xd575, 0xd572,
+  0xd5a6, 0xb1ba, 0xb1b2, 0xd577, 0xb4a8, 0xb1b6, 0xd5a1, 0xb1cc,
+  0xb1c9, 0xd57b, 0xd56a, 0xb1c8, 0xd5a3, 0xd569, 0xb1bd, 0xb1c1,
+  0xd5a2, 0xd573, 0xb1c2, 0xb1bc, 0xd568, 0xb478, 0xd5a5, 0xd571,
+  0xb1c7, 0xd574, 0xd5a4, 0xb1c6, 0xd952, 0xb1b3, 0xd56f, 0xb1b8,
+  0xb1c3, 0xb1be, 0xd578, 0xd56e, 0xd56c, 0xd57e, 0xb1b0, 0xb1c4,
+  0xb1b4, 0xb477, 0xd57c, 0xb1b5, 0xb1b1, 0xb1c0, 0xb1bb, 0xb1b9,
+  0xd570, 0xb1c5, 0xd56d, 0xd57a, 0xd576, 0xd954, 0xd953, 0xd56b,
+  0xd964, 0xb47a, 0xd96a, 0xd959, 0xd967, 0xdd77, 0xb47d, 0xd96b,
+  0xd96e, 0xb47c, 0xd95c, 0xd96d, 0xd96c, 0xb47e, 0xd955, 0xb479,
+  0xb4a3, 0xb4a1, 0xd969, 0xd95f, 0xb4a5, 0xd970, 0xd968, 0xd971,
+  0xb4ad, 0xb4ab, 0xd966, 0xd965, 0xd963, 0xd95d, 0xb4a4, 0xb4a2,
+  0xd1b9, 0xd956, 0xddb7, 0xd957, 0xb47b, 0xb4aa, 0xdd79, 0xb4a6,
+  0xb4a7, 0xd958, 0xd96f, 0xdd78, 0xd960, 0xd95b, 0xb4a9, 0xd961,
+  0xd95e, 0xb4ae, 0xb770, 0xdd7c, 0xddb1, 0xddb6, 0xddaa, 0xb76c,
+  0xddbb, 0xb769, 0xdd7a, 0xdd7b, 0xb762, 0xb76b, 0xdda4, 0xb76e,
+  0xb76f, 0xdda5, 0xddb2, 0xddb8, 0xb76a, 0xb764, 0xdda3, 0xdd7d,
+  0xddba, 0xdda8, 0xdda9, 0xdd7e, 0xddb4, 0xddab, 0xddb5, 0xddad,
+  0xb765, 0xe1d9, 0xb768, 0xb766, 0xddb9, 0xddb0, 0xddac, 0xdda1,
+  0xba53, 0xddaf, 0xb76d, 0xdda7, 0xdda6, 0xb767, 0xb763, 0xe1ee,
+  0xddb3, 0xddae, 0xdda2, 0xe1e9, 0xe1da, 0xe1e5, 0xe1ec, 0xba51,
+  0xb4ac, 0xe1ea, 0xba4c, 0xba4b, 0xe1f1, 0xe1db, 0xe1e8, 0xe1dc,
+  0xe1e7, 0xba4f, 0xe1eb, 0xd962, 0xe1f2, 0xe1e3, 0xba52, 0xe5ba,
+  0xbcaf, 0xe1f0, 0xe1ef, 0xba54, 0xe5ad, 0xbcb0, 0xe5ae, 0xe1df,
+  0xe1e0, 0xe1dd, 0xe1e2, 0xe1de, 0xe1f3, 0xba4e, 0xbcb1, 0xba50,
+  0xba55, 0xe1e1, 0xe1ed, 0xe1e6, 0xe5b1, 0xba4a, 0xbcb4, 0xe9aa,
+  0xe5b6, 0xe5b5, 0xe5b7, 0xe5b4, 0xbcb5, 0xbcbb, 0xbcb8, 0xbcb9,
+  0xe5af, 0xe5b2, 0xe5bc, 0xbcc1, 0xbcbf, 0xe5b3, 0xd95a, 0xbcb2,
+  0xe5b9, 0xe5b0, 0xbcc2, 0xe5b8, 0xba4d, 0xbcb7, 0xe1e4, 0xbcba,
+  0xbcbe, 0xbcc0, 0xbcbd, 0xbcbc, 0xbcb6, 0xe5bb, 0xbcb3, 0xbcc3,
+  0xbed8, 0xbed9, 0xe9a9, 0xbee2, 0xbedf, 0xbed6, 0xbedd, 0xe9ab,
+  0xbedb, 0xbed5, 0xbedc, 0xe9a8, 0xc0bb, 0xbed7, 0xbede, 0xc0ba,
+  0xe9a7, 0xe9a6, 0xbee0, 0xbee1, 0xe9a5, 0xe9a4, 0xc0bc, 0xe9ae,
+  0xbeda, 0xe9ac, 0xc0bd, 0xc0c2, 0xecea, 0xecec, 0xc0bf, 0xeced,
+  0xece9, 0xeceb, 0xc0c0, 0xc0c3, 0xece8, 0xc0be, 0xc0c1, 0xc259,
+  0xe9ad, 0xc258, 0xc25e, 0xefd4, 0xc25c, 0xc25d, 0xefd7, 0xefd3,
+  0xc25a, 0xefd1, 0xc36b, 0xefd5, 0xefd6, 0xefd2, 0xc25b, 0xf242,
+  0xf245, 0xf246, 0xf244, 0xf247, 0xc36c, 0xf243, 0xf44e, 0xc464,
+  0xf44d, 0xf44c, 0xf44b, 0xc463, 0xc465, 0xf5cd, 0xc4e2, 0xc4e1,
+  0xf6e1, 0xf6e0, 0xf6e3, 0xc5cb, 0xc575, 0xf7dd, 0xf6e2, 0xf7dc,
+  0xc5cd, 0xc5cc, 0xc5f3, 0xf8a9, 0xf8ef, 0xa4e4, 0xd972, 0xe9af,
+  0xa6ac, 0xcaf7, 0xa7f1, 0xa7ef, 0xa7f0, 0xccc1, 0xa9f1, 0xac46,
+  0xcee7, 0xcee8, 0xac47, 0xd1ce, 0xaec4, 0xaec5, 0xd1cd, 0xb1d3,
+  0xb1cf, 0xd5a7, 0xb1d6, 0xb1d5, 0xb1ce, 0xb1d1, 0xb1d4, 0xb1d0,
+  0xd976, 0xb1cd, 0xb4af, 0xb4b1, 0xb4b2, 0xd975, 0xd978, 0xb4b0,
+  0xd973, 0xd977, 0xd974, 0xb771, 0xddbc, 0xba56, 0xe1f4, 0xbee3,
+  0xbcc4, 0xe5bd, 0xbcc5, 0xbcc6, 0xe5bf, 0xe5be, 0xe5c0, 0xe9b1,
+  0xe9b0, 0xecef, 0xecee, 0xc0c4, 0xc0c5, 0xf248, 0xa4e5, 0xd979,
+  0xb4b4, 0xb4b3, 0xddbd, 0xefd8, 0xc4e3, 0xf7de, 0xa4e6, 0xaec6,
+  0xb1d8, 0xb1d7, 0xd97a, 0xd97b, 0xb772, 0xe1f5, 0xba57, 0xe9b2,
+  0xa4e7, 0xa5b8, 0xa9f2, 0xccc2, 0xcee9, 0xac48, 0xb1d9, 0xd97c,
+  0xb4b5, 0xb773, 0xe5c1, 0xe5c2, 0xecf0, 0xc25f, 0xf8f0, 0xa4e8,
+  0xccc3, 0xa9f3, 0xac49, 0xceea, 0xaec7, 0xd1d2, 0xd1d0, 0xd1d1,
+  0xaec8, 0xd1cf, 0xb1db, 0xb1dc, 0xd5a8, 0xb1dd, 0xb1da, 0xd97d,
+  0xd97e, 0xddbe, 0xba59, 0xba58, 0xecf1, 0xefd9, 0xf24a, 0xf249,
+  0xf44f, 0xc95e, 0xac4a, 0xa4e9, 0xa5b9, 0xa6ae, 0xa6ad, 0xa6af,
+  0xa6b0, 0xc9ee, 0xc9ed, 0xcaf8, 0xa7f2, 0xcafb, 0xcafa, 0xcaf9,
+  0xcafc, 0xa9f4, 0xccc9, 0xccc5, 0xccce, 0xa9fb, 0xa9f9, 0xccca,
+  0xccc6, 0xcccd, 0xa9f8, 0xaa40, 0xccc8, 0xccc4, 0xa9fe, 0xcccb,
+  0xa9f7, 0xcccc, 0xa9fa, 0xa9fc, 0xccd0, 0xcccf, 0xccc7, 0xa9f6,
+  0xa9f5, 0xa9fd, 0xceef, 0xcef5, 0xac50, 0xac4d, 0xceec, 0xcef1,
+  0xac53, 0xac4b, 0xcef0, 0xac4e, 0xac51, 0xcef3, 0xac4c, 0xcef8,
+  0xac4f, 0xac52, 0xceed, 0xcef2, 0xcef6, 0xceee, 0xceeb, 0xcef7,
+  0xcef4, 0xaed0, 0xaec9, 0xaecc, 0xaecf, 0xd1d5, 0xaeca, 0xd1d3,
+  0xaece, 0xaecb, 0xd1d6, 0xaecd, 0xd5ac, 0xb1df, 0xd5ab, 0xd5ad,
+  0xb1de, 0xb1e3, 0xd1d4, 0xd5aa, 0xd5ae, 0xb1e0, 0xd5a9, 0xb1e2,
+  0xb1e1, 0xd9a7, 0xd9a2, 0xb4b6, 0xb4ba, 0xb4b7, 0xd9a5, 0xd9a8,
+  0xb4b8, 0xb4b9, 0xb4be, 0xddc7, 0xd9a6, 0xb4bc, 0xd9a3, 0xd9a1,
+  0xb4bd, 0xd9a4, 0xb779, 0xddbf, 0xb776, 0xb777, 0xb775, 0xddc4,
+  0xddc3, 0xddc0, 0xb77b, 0xddc2, 0xb4bb, 0xddc6, 0xddc1, 0xb778,
+  0xb774, 0xb77a, 0xddc5, 0xba5c, 0xe1f8, 0xe1f7, 0xe1f6, 0xba5a,
+  0xba5b, 0xe5c5, 0xe5c8, 0xbcc8, 0xbcc7, 0xe5c9, 0xe5c4, 0xbcca,
+  0xe5c6, 0xbcc9, 0xe5c3, 0xe5c7, 0xbee9, 0xbee6, 0xe9bb, 0xe9ba,
+  0xe9b9, 0xe9b4, 0xe9b5, 0xbee7, 0xbee4, 0xbee8, 0xe9b3, 0xbee5,
+  0xe9b6, 0xe9b7, 0xe9bc, 0xe9b8, 0xecf2, 0xc0c7, 0xefdc, 0xc0c6,
+  0xefda, 0xefdb, 0xc260, 0xc36e, 0xf24b, 0xc36d, 0xf451, 0xf452,
+  0xc466, 0xf450, 0xc4e4, 0xf7df, 0xc5ce, 0xf8aa, 0xf8ab, 0xa4ea,
+  0xa6b1, 0xa6b2, 0xa7f3, 0xccd1, 0xac54, 0xaed1, 0xb1e4, 0xb0d2,
+  0xb4bf, 0xb4c0, 0xb3cc, 0xd9a9, 0xb77c, 0xe1fa, 0xe1f9, 0xa4eb,
+  0xa6b3, 0xccd2, 0xaa42, 0xaa41, 0xcef9, 0xcefa, 0xd1d7, 0xd1d8,
+  0xaed2, 0xaed3, 0xaed4, 0xd5af, 0xb1e6, 0xb4c2, 0xb4c1, 0xddc8,
+  0xdf7a, 0xe1fb, 0xe9bd, 0xc261, 0xc467, 0xa4ec, 0xa5bc, 0xa5bd,
+  0xa5bb, 0xa5be, 0xa5ba, 0xa6b6, 0xc9f6, 0xa6b5, 0xa6b7, 0xc9f1,
+  0xc9f0, 0xc9f3, 0xc9f2, 0xc9f5, 0xa6b4, 0xc9ef, 0xc9f4, 0xcafd,
+  0xa7fd, 0xcafe, 0xcb43, 0xa7fc, 0xcb47, 0xcb42, 0xcb45, 0xa7f5,
+  0xa7f6, 0xa7f7, 0xa7f8, 0xa840, 0xcb41, 0xa7fa, 0xa841, 0xcb40,
+  0xcb46, 0xa7f9, 0xcb44, 0xa7fb, 0xa7f4, 0xa7fe, 0xaa57, 0xccd4,
+  0xaa43, 0xaa4d, 0xaa4e, 0xaa46, 0xaa58, 0xaa48, 0xccdc, 0xaa53,
+  0xccd7, 0xaa49, 0xcce6, 0xcce7, 0xccdf, 0xccd8, 0xaa56, 0xcce4,
+  0xaa51, 0xaa4f, 0xcce5, 0xcce3, 0xccdb, 0xccd3, 0xccda, 0xaa4a,
+  0xaa50, 0xaa44, 0xccde, 0xccdd, 0xccd5, 0xaa52, 0xcce1, 0xccd6,
+  0xaa55, 0xcce8, 0xaa45, 0xaa4c, 0xccd9, 0xcce2, 0xaa54, 0xaa47,
+  0xaa4b, 0xcce0, 0xcf5b, 0xac5c, 0xac69, 0xcf56, 0xcf4c, 0xac62,
+  0xcf4a, 0xac5b, 0xcf45, 0xac65, 0xcf52, 0xcefe, 0xcf41, 0xcf44,
+  0xcefb, 0xcf51, 0xcf61, 0xac60, 0xcf46, 0xcf58, 0xcefd, 0xcf5f,
+  0xcf60, 0xcf63, 0xcf5a, 0xcf4b, 0xcf53, 0xac66, 0xac59, 0xac61,
+  0xac6d, 0xac56, 0xac58, 0xcf43, 0xac6a, 0xac63, 0xcf5d, 0xcf40,
+  0xac6c, 0xac67, 0xcf49, 0xac6b, 0xcf50, 0xcf48, 0xac64, 0xcf5c,
+  0xcf54, 0xac5e, 0xcf62, 0xcf47, 0xac5a, 0xcf59, 0xcf4f, 0xac5f,
+  0xcf55, 0xac57, 0xcefc, 0xac68, 0xaee3, 0xac5d, 0xcf4e, 0xcf4d,
+  0xcf42, 0xcf5e, 0xcf57, 0xac55, 0xd1ec, 0xaeea, 0xd1ed, 0xd1e1,
+  0xaedf, 0xaeeb, 0xd1da, 0xd1e3, 0xd1eb, 0xd1d9, 0xd1f4, 0xaed5,
+  0xd1f3, 0xd1ee, 0xd1ef, 0xaedd, 0xaee8, 0xd1e5, 0xd1e6, 0xd1f0,
+  0xd1e7, 0xd1e2, 0xd1dc, 0xd1dd, 0xd1ea, 0xd1e4, 0xaed6, 0xaeda,
+  0xd1f2, 0xd1de, 0xaee6, 0xaee2, 0xaee5, 0xaeec, 0xaedb, 0xaee7,
+  0xd1e9, 0xaee9, 0xaed8, 0xaed7, 0xd1db, 0xd1df, 0xaee0, 0xd1f1,
+  0xd1e8, 0xd1e0, 0xaee4, 0xaee1, 0xaed9, 0xaedc, 0xd5c4, 0xd5b4,
+  0xd5b5, 0xd5b9, 0xd5c8, 0xd5c5, 0xd5be, 0xd5bd, 0xb1ed, 0xd5c1,
+  0xd5d0, 0xd5b0, 0xd5d1, 0xd5c3, 0xd5d5, 0xd5c9, 0xb1ec, 0xd5c7,
+  0xb1e7, 0xb1fc, 0xb1f2, 0xb1f6, 0xb1f5, 0xd5b1, 0xd5ce, 0xd5d4,
+  0xd5cc, 0xd5d3, 0xd5c0, 0xd5b2, 0xd5d2, 0xd5c2, 0xb1ea, 0xb1f7,
+  0xd5cb, 0xb1f0, 0xd5ca, 0xd5b3, 0xb1f8, 0xb1fa, 0xd5cd, 0xb1fb,
+  0xb1e9, 0xd5ba, 0xd5cf, 0xb1ef, 0xb1f9, 0xd5bc, 0xd5c6, 0xd5b7,
+  0xd5bb, 0xb1f4, 0xd5b6, 0xb1e8, 0xb1f1, 0xb1ee, 0xd5bf, 0xaede,
+  0xd9c0, 0xb1eb, 0xb1f3, 0xd9c3, 0xd9d9, 0xd9ce, 0xb4d6, 0xb4d1,
+  0xd9bd, 0xb4d2, 0xd9cd, 0xd9c6, 0xd9d3, 0xb4ce, 0xd9ab, 0xd9d5,
+  0xb4c4, 0xd9b3, 0xb4c7, 0xb4c6, 0xb4d7, 0xd9ad, 0xd9cf, 0xd9d0,
+  0xb4c9, 0xb4c5, 0xd9bb, 0xb4d0, 0xd9b6, 0xd9d1, 0xb4cc, 0xd9c9,
+  0xd9d6, 0xd9b0, 0xd9b5, 0xd9af, 0xb4cb, 0xd9c2, 0xddde, 0xd9b1,
+  0xb4cf, 0xd9ba, 0xd9d2, 0xb4ca, 0xd9b7, 0xd9b4, 0xd9c5, 0xb4cd,
+  0xb4c3, 0xb4d9, 0xd9c8, 0xd9c7, 0xd9ac, 0xb4c8, 0xd9d4, 0xd9bc,
+  0xd9be, 0xd9cb, 0xd9ca, 0xd9aa, 0xb4d3, 0xb4d5, 0xd9b2, 0xd9b9,
+  0xd9c1, 0xb4d4, 0xd9b8, 0xd9c4, 0xd9d7, 0xd9cc, 0xd9d8, 0xd9ae,
+  0xddf2, 0xb7a6, 0xddf0, 0xdddb, 0xdde0, 0xddd9, 0xddec, 0xddcb,
+  0xddd2, 0xddea, 0xddf4, 0xdddc, 0xddcf, 0xdde2, 0xdde7, 0xddd3,
+  0xdde4, 0xddd0, 0xddd7, 0xddd8, 0xb7a8, 0xddeb, 0xdde9, 0xddcc,
+  0xddee, 0xddef, 0xddf1, 0xb7ac, 0xb7a4, 0xd5b8, 0xddd4, 0xdde6,
+  0xddd5, 0xb7a1, 0xb7b1, 0xdded, 0xb7af, 0xb7ab, 0xddca, 0xb7a3,
+  0xddcd, 0xb7b0, 0xdddd, 0xddc9, 0xb7a9, 0xdde1, 0xddd1, 0xb7aa,
+  0xddda, 0xb77e, 0xb4d8, 0xdde3, 0xd9bf, 0xddce, 0xdde8, 0xb7a5,
+  0xdde5, 0xb7a2, 0xdddf, 0xb7ad, 0xddd6, 0xddf3, 0xb7a7, 0xdec6,
+  0xb7ae, 0xe24a, 0xe248, 0xe25e, 0xe246, 0xe258, 0xb77d, 0xba5f,
+  0xe242, 0xe25d, 0xe247, 0xe255, 0xba64, 0xba5d, 0xe25b, 0xe240,
+  0xe25a, 0xba6f, 0xe251, 0xe261, 0xba6d, 0xe249, 0xba5e, 0xe24b,
+  0xe259, 0xba67, 0xe244, 0xba6b, 0xba61, 0xe24d, 0xe243, 0xe1fc,
+  0xe257, 0xba68, 0xe260, 0xe1fd, 0xba65, 0xe253, 0xba66, 0xe245,
+  0xe250, 0xe24c, 0xe24e, 0xba60, 0xe25f, 0xba6e, 0xe24f, 0xe262,
+  0xe1fe, 0xe254, 0xba63, 0xba6c, 0xba6a, 0xe241, 0xe256, 0xba69,
+  0xba62, 0xe252, 0xe25c, 0xe5d5, 0xe5d1, 0xe5cd, 0xe5e1, 0xe5de,
+  0xbccd, 0xe5e5, 0xe5d4, 0xbcd8, 0xe5db, 0xe5d0, 0xe5da, 0xbcd5,
+  0xe5ee, 0xe5eb, 0xe5dd, 0xe5ce, 0xe5e2, 0xe5e4, 0xbcd1, 0xe5d8,
+  0xe5d3, 0xe5ca, 0xbcce, 0xbcd6, 0xe5e7, 0xbcd7, 0xe5cb, 0xe5ed,
+  0xe5e0, 0xe5e6, 0xbcd4, 0xe5e3, 0xe5ea, 0xbcd9, 0xbcd3, 0xe5dc,
+  0xe5cf, 0xe5ef, 0xe5cc, 0xe5e8, 0xbcd0, 0xe5d6, 0xe5d7, 0xbccf,
+  0xbccc, 0xe5d2, 0xbcd2, 0xbccb, 0xe5e9, 0xe5ec, 0xe5d9, 0xe9ca,
+  0xe9c2, 0xe9be, 0xbef6, 0xbeeb, 0xbef0, 0xbeec, 0xe9cc, 0xe9d7,
+  0xbeea, 0xe9c4, 0xe9cd, 0xe5df, 0xe9ce, 0xbef1, 0xe9dd, 0xbef5,
+  0xbef8, 0xe9c0, 0xbef4, 0xe9db, 0xe9dc, 0xe9d2, 0xe9d1, 0xe9c9,
+  0xe9d3, 0xe9da, 0xe9d9, 0xbeef, 0xbeed, 0xe9cb, 0xe9c8, 0xe9c5,
+  0xe9d8, 0xbef7, 0xe9d6, 0xbef3, 0xbef2, 0xe9d0, 0xe9bf, 0xe9c1,
+  0xe9c3, 0xe9d5, 0xe9cf, 0xbeee, 0xe9c6, 0xe9d4, 0xe9c7, 0xc0cf,
+  0xed45, 0xc0c8, 0xecf5, 0xed41, 0xc0ca, 0xed48, 0xecfc, 0xecf7,
+  0xed49, 0xecf3, 0xecfe, 0xc0d1, 0xed44, 0xed4a, 0xecfd, 0xc0c9,
+  0xed40, 0xecf4, 0xc0d0, 0xed47, 0xecf9, 0xc0cc, 0xecfb, 0xecf8,
+  0xc0d2, 0xecfa, 0xc0cb, 0xc0ce, 0xed43, 0xecf6, 0xed46, 0xed42,
+  0xc263, 0xefe7, 0xc268, 0xc269, 0xc262, 0xefe6, 0xefe3, 0xefe4,
+  0xc266, 0xefde, 0xefe2, 0xc265, 0xefdf, 0xc267, 0xc264, 0xefdd,
+  0xefe1, 0xefe5, 0xf251, 0xf24e, 0xf257, 0xf256, 0xf254, 0xf24f,
+  0xc372, 0xf250, 0xc371, 0xc0cd, 0xf253, 0xc370, 0xf258, 0xf252,
+  0xf24d, 0xefe0, 0xc36f, 0xf24c, 0xf456, 0xf455, 0xf255, 0xc468,
+  0xf459, 0xf45a, 0xf454, 0xf458, 0xf453, 0xf5d1, 0xf457, 0xc4e7,
+  0xc4e5, 0xf5cf, 0xf5d2, 0xf5ce, 0xf5d0, 0xc4e6, 0xf6e5, 0xf6e6,
+  0xc576, 0xf6e4, 0xf7e2, 0xc5cf, 0xf7e0, 0xf7e1, 0xf8ac, 0xc656,
+  0xf8f3, 0xf8f1, 0xf8f2, 0xf8f4, 0xf9bb, 0xa4ed, 0xa6b8, 0xaa59,
+  0xcce9, 0xcf64, 0xd1f5, 0xd1f7, 0xd1f6, 0xd1f8, 0xb1fd, 0xd5d7,
+  0xd1f9, 0xd5d6, 0xd5d8, 0xd5d9, 0xd9da, 0xb4db, 0xd9db, 0xd9dd,
+  0xb4dc, 0xb4da, 0xd9dc, 0xddfa, 0xddf8, 0xddf7, 0xddf6, 0xddf5,
+  0xb7b2, 0xddf9, 0xba70, 0xe263, 0xe265, 0xba71, 0xe264, 0xbcdb,
+  0xbcda, 0xe5f0, 0xe9df, 0xe9de, 0xe9e0, 0xbef9, 0xed4b, 0xc0d3,
+  0xefe8, 0xc26a, 0xf259, 0xc577, 0xa4ee, 0xa5bf, 0xa6b9, 0xa842,
+  0xaa5a, 0xaa5b, 0xac6e, 0xd1fa, 0xb7b3, 0xe6d1, 0xbefa, 0xc26b,
+  0xa4ef, 0xa6ba, 0xcceb, 0xaa5c, 0xccea, 0xcf65, 0xac6f, 0xcf66,
+  0xac70, 0xd1fc, 0xaeee, 0xaeed, 0xd5de, 0xd5dc, 0xd5dd, 0xd5db,
+  0xd5da, 0xd9de, 0xd9e1, 0xb4de, 0xd9df, 0xb4dd, 0xd9e0, 0xddfb,
+  0xe266, 0xe267, 0xe268, 0xe5f3, 0xe5f2, 0xbcdc, 0xe5f1, 0xe5f4,
+  0xe9e1, 0xe9e2, 0xe9e3, 0xed4c, 0xc0d4, 0xc26c, 0xf25a, 0xc4e8,
+  0xc95f, 0xac71, 0xcf67, 0xaeef, 0xb1fe, 0xb4df, 0xd9e2, 0xb7b5,
+  0xb7b4, 0xe269, 0xe26a, 0xbcdd, 0xbcde, 0xe9e5, 0xe9e4, 0xefe9,
+  0xf7e3, 0xa4f0, 0xc960, 0xa5c0, 0xa843, 0xcb48, 0xac72, 0xb7b6,
+  0xa4f1, 0xcf68, 0xac73, 0xcf69, 0xc0d5, 0xa4f2, 0xccec, 0xcf6a,
+  0xd242, 0xd241, 0xd1fe, 0xd1fd, 0xd243, 0xd240, 0xb240, 0xb241,
+  0xb4e0, 0xd9e3, 0xd9e4, 0xd9e5, 0xde41, 0xde42, 0xde40, 0xddfd,
+  0xddfe, 0xb7b7, 0xe26b, 0xe5f7, 0xe5f6, 0xe5f5, 0xe5f8, 0xe9e7,
+  0xe9e6, 0xbefb, 0xe9e8, 0xc0d6, 0xed4d, 0xefea, 0xf25b, 0xf6e7,
+  0xa4f3, 0xa5c2, 0xa5c1, 0xaa5d, 0xc961, 0xc97e, 0xa6bb, 0xc9f7,
+  0xcb49, 0xcb4a, 0xaa5e, 0xcced, 0xac74, 0xcf6b, 0xcf6c, 0xaef0,
+  0xaef4, 0xd244, 0xaef3, 0xaef1, 0xaef2, 0xd5df, 0xb242, 0xb4e3,
+  0xb4e1, 0xb4e2, 0xd9e6, 0xba72, 0xa4f4, 0xc9a1, 0xa5c3, 0xc9a4,
+  0xa5c6, 0xc9a3, 0xa5c5, 0xa5c4, 0xa844, 0xc9a2, 0xc9f8, 0xc9fc,
+  0xc9fe, 0xca40, 0xa6c5, 0xa6c6, 0xc9fb, 0xa6c1, 0xc9f9, 0xc9fd,
+  0xa6c2, 0xa6bd, 0xa6be, 0xa6c4, 0xc9fa, 0xa6bc, 0xa845, 0xa6bf,
+  0xa6c0, 0xa6c3, 0xcb5b, 0xcb59, 0xcb4c, 0xa851, 0xcb53, 0xa84c,
+  0xcb4d, 0xcb55, 0xcb52, 0xa84f, 0xcb51, 0xa856, 0xcb5a, 0xa858,
+  0xa85a, 0xcb4b, 0xa84d, 0xcb5c, 0xa854, 0xa857, 0xcd45, 0xa847,
+  0xa85e, 0xa855, 0xcb4e, 0xa84a, 0xa859, 0xcb56, 0xa848, 0xa849,
+  0xcd43, 0xcb4f, 0xa850, 0xa85b, 0xcb5d, 0xcb50, 0xa84e, 0xa853,
+  0xccee, 0xa85c, 0xcb57, 0xa852, 0xa85d, 0xa846, 0xcb54, 0xa84b,
+  0xcb58, 0xcd44, 0xaa6a, 0xaa7a, 0xccf5, 0xaa71, 0xcd4b, 0xaa62,
+  0xaa65, 0xcd42, 0xccf3, 0xccf7, 0xaa6d, 0xaa6f, 0xccfa, 0xaa76,
+  0xaa68, 0xaa66, 0xaa67, 0xaa75, 0xcd47, 0xaa70, 0xccf9, 0xccfb,
+  0xaa6e, 0xaa73, 0xccfc, 0xcd4a, 0xac75, 0xaa79, 0xaa63, 0xcd49,
+  0xcd4d, 0xccf8, 0xcd4f, 0xcd40, 0xaa6c, 0xccf4, 0xaa6b, 0xaa7d,
+  0xaa72, 0xccf2, 0xcf75, 0xaa78, 0xaa7c, 0xcd41, 0xcd46, 0xaa7e,
+  0xaa77, 0xaa69, 0xaa5f, 0xaa64, 0xccf6, 0xaa60, 0xcd4e, 0xccf0,
+  0xccef, 0xccfd, 0xccf1, 0xaa7b, 0xaef5, 0xaa74, 0xccfe, 0xaa61,
+  0xaca6, 0xcd4c, 0xcf7c, 0xcfa1, 0xcfa4, 0xcf77, 0xcfa7, 0xcfaa,
+  0xcfac, 0xcf74, 0xac76, 0xac7b, 0xd249, 0xacad, 0xcfa5, 0xcfad,
+  0xcf7b, 0xcf73, 0xd264, 0xac7e, 0xcfa2, 0xcf78, 0xcf7a, 0xaca5,
+  0xcf7d, 0xac7d, 0xcf70, 0xcfa8, 0xcfab, 0xac7a, 0xaca8, 0xcf6d,
+  0xacaa, 0xac78, 0xacae, 0xcfa9, 0xcf6f, 0xacab, 0xd25e, 0xcd48,
+  0xac7c, 0xac77, 0xcf76, 0xcf6e, 0xacac, 0xaca4, 0xcfa3, 0xaca9,
+  0xaca7, 0xcf79, 0xaca1, 0xcf71, 0xaca2, 0xaca3, 0xcf72, 0xcfa6,
+  0xac79, 0xcf7e, 0xd24c, 0xaefd, 0xaf43, 0xd255, 0xd25b, 0xd257,
+  0xd24a, 0xd24d, 0xd246, 0xd247, 0xaf4a, 0xaefa, 0xd256, 0xd25f,
+  0xaf45, 0xaef6, 0xaf40, 0xd24e, 0xaf42, 0xd24f, 0xd259, 0xaf44,
+  0xd268, 0xd248, 0xaefc, 0xaefb, 0xaf48, 0xd245, 0xd266, 0xd25a,
+  0xd267, 0xd261, 0xd253, 0xd262, 0xd25c, 0xd265, 0xd263, 0xaf49,
+  0xd254, 0xaef9, 0xaef8, 0xaf41, 0xaf47, 0xd260, 0xaf46, 0xd251,
+  0xb243, 0xd269, 0xd250, 0xd24b, 0xaefe, 0xaf4b, 0xaef7, 0xd258,
+  0xd25d, 0xb265, 0xd5e1, 0xd5e5, 0xb252, 0xb250, 0xb247, 0xd5e3,
+  0xd5e2, 0xb25b, 0xd5e8, 0xb255, 0xd5fa, 0xd647, 0xb244, 0xd5f7,
+  0xd5f0, 0xb267, 0xd5e0, 0xd5fc, 0xb264, 0xb258, 0xb263, 0xb24e,
+  0xd5ec, 0xd5fe, 0xd5f6, 0xb24f, 0xb249, 0xd645, 0xd5fd, 0xd640,
+  0xb251, 0xb259, 0xd642, 0xd5ea, 0xd5fb, 0xd5ef, 0xd644, 0xb25e,
+  0xb246, 0xb25c, 0xd5f4, 0xd5f2, 0xd5f3, 0xb253, 0xd5ee, 0xd5ed,
+  0xb248, 0xd5e7, 0xd646, 0xb24a, 0xd5f1, 0xb268, 0xb262, 0xd5e6,
+  0xb25f, 0xb25d, 0xb266, 0xd5f8, 0xb261, 0xd252, 0xd5f9, 0xb260,
+  0xd641, 0xb245, 0xd5f5, 0xb257, 0xd5e9, 0xb256, 0xb254, 0xb24c,
+  0xb24b, 0xd9e7, 0xd643, 0xd5eb, 0xd9fc, 0xb24d, 0xb541, 0xb25a,
+  0xb4ee, 0xd9f6, 0xb4fc, 0xd9ea, 0xb4eb, 0xb4e7, 0xda49, 0xb4ed,
+  0xb4f1, 0xb4ec, 0xb4f5, 0xda4d, 0xda44, 0xd9f1, 0xb4fa, 0xb4f4,
+  0xd9fd, 0xb4e4, 0xda4a, 0xda43, 0xb4e8, 0xd9f7, 0xb4f7, 0xda55,
+  0xda56, 0xb4e5, 0xda48, 0xb4f9, 0xd9fb, 0xd9ed, 0xd9ee, 0xb4fd,
+  0xd9f2, 0xd9f9, 0xd9f3, 0xb4fb, 0xb544, 0xd9ef, 0xd9e8, 0xd9e9,
+  0xd9eb, 0xb4ea, 0xd9f8, 0xb4f8, 0xb542, 0xd9fa, 0xda53, 0xda4b,
+  0xb4e6, 0xda51, 0xb4f2, 0xb4f0, 0xda57, 0xb4ef, 0xda41, 0xd9f4,
+  0xd9fe, 0xb547, 0xda45, 0xda42, 0xd9f0, 0xb543, 0xda4f, 0xda4c,
+  0xda54, 0xb4e9, 0xda40, 0xb546, 0xda47, 0xb4f3, 0xb4f6, 0xda46,
+  0xb545, 0xd9f5, 0xd5e4, 0xda50, 0xda4e, 0xda52, 0xd9ec, 0xb540,
+  0xde61, 0xde60, 0xde46, 0xb7bd, 0xde5f, 0xde49, 0xde4a, 0xb7c7,
+  0xde68, 0xb7c2, 0xde5e, 0xde43, 0xb7c8, 0xb7be, 0xde52, 0xde48,
+  0xde4b, 0xde63, 0xb7b8, 0xde6a, 0xde62, 0xb7c1, 0xde57, 0xb7cc,
+  0xb7cb, 0xb7c5, 0xde69, 0xb7b9, 0xde55, 0xde4c, 0xde59, 0xde65,
+  0xb7cd, 0xb7bb, 0xde54, 0xde4d, 0xb7c4, 0xb7c3, 0xde50, 0xde5a,
+  0xde64, 0xde47, 0xde51, 0xb7bc, 0xde5b, 0xb7c9, 0xb7c0, 0xde4e,
+  0xb7bf, 0xde45, 0xde53, 0xde67, 0xb4fe, 0xbab0, 0xde56, 0xe26c,
+  0xde58, 0xde66, 0xb7c6, 0xde4f, 0xb7ba, 0xb7ca, 0xbcf0, 0xde44,
+  0xde5d, 0xde5c, 0xe2aa, 0xbaad, 0xe27d, 0xe2a4, 0xbaa2, 0xe26e,
+  0xbaaf, 0xba77, 0xe26d, 0xe2b0, 0xbab1, 0xe271, 0xe2a3, 0xe273,
+  0xe2b3, 0xe2af, 0xba75, 0xbaa1, 0xe653, 0xbaae, 0xba7d, 0xe26f,
+  0xe2ae, 0xbaa3, 0xe2ab, 0xe2b8, 0xe275, 0xe27e, 0xe2b6, 0xe2ac,
+  0xba7c, 0xe27c, 0xba76, 0xba74, 0xbaa8, 0xe27a, 0xe277, 0xe278,
+  0xe2b2, 0xe2b7, 0xe2b5, 0xba7a, 0xe2b9, 0xba7e, 0xbaa7, 0xe270,
+  0xe5fa, 0xe279, 0xba78, 0xbaac, 0xbaa9, 0xba7b, 0xe2a5, 0xe274,
+  0xbaaa, 0xe2a7, 0xbaa4, 0xbaa6, 0xba73, 0xe2a9, 0xe2a1, 0xe272,
+  0xbaa5, 0xe2b1, 0xe2b4, 0xe27b, 0xe2a8, 0xba79, 0xbcdf, 0xe2a6,
+  0xe5f9, 0xe2ad, 0xe276, 0xe644, 0xe64e, 0xbce2, 0xe64d, 0xe659,
+  0xbce4, 0xe64b, 0xe64f, 0xbcef, 0xe646, 0xbce7, 0xe652, 0xe9f0,
+  0xbcf3, 0xbcf2, 0xe654, 0xe643, 0xe65e, 0xbced, 0xbce3, 0xe657,
+  0xe65b, 0xe660, 0xe655, 0xe649, 0xbce6, 0xbce9, 0xbcf1, 0xbcec,
+  0xe64c, 0xe2a2, 0xe648, 0xe65f, 0xbce8, 0xbceb, 0xe661, 0xbce0,
+  0xe656, 0xe5fb, 0xe65c, 0xc0df, 0xe64a, 0xbce1, 0xe645, 0xbce5,
+  0xe5fc, 0xbaab, 0xe641, 0xe65a, 0xe642, 0xe640, 0xbcea, 0xe658,
+  0xe5fe, 0xe651, 0xe650, 0xe65d, 0xe647, 0xbcee, 0xe9f3, 0xbf49,
+  0xbefe, 0xea40, 0xe9eb, 0xbf41, 0xe9f7, 0xbf48, 0xbf43, 0xe9f5,
+  0xed4f, 0xe9fb, 0xea42, 0xe9fa, 0xe9e9, 0xe9f8, 0xea44, 0xea46,
+  0xbefd, 0xea45, 0xbf44, 0xbf4a, 0xbf47, 0xe9fe, 0xbf46, 0xe9f9,
+  0xe9ed, 0xe9f2, 0xe9fd, 0xbf45, 0xbf42, 0xbefc, 0xbf40, 0xe9f1,
+  0xe5fd, 0xe9ec, 0xe9ef, 0xea41, 0xe9f4, 0xe9ea, 0xed4e, 0xea43,
+  0xe9ee, 0xe9fc, 0xed51, 0xc0e3, 0xc0d7, 0xc0db, 0xed53, 0xed59,
+  0xed57, 0xc0d9, 0xc0da, 0xc0e1, 0xed5a, 0xed52, 0xc0dc, 0xed56,
+  0xed55, 0xed5b, 0xc0e2, 0xc0dd, 0xc0e0, 0xed54, 0xc0e4, 0xc0de,
+  0xc0e5, 0xc0d8, 0xed58, 0xed50, 0xeff7, 0xc271, 0xeff4, 0xeff6,
+  0xc26f, 0xeff2, 0xeff3, 0xefee, 0xe9f6, 0xefef, 0xc270, 0xefeb,
+  0xc26d, 0xeff8, 0xc26e, 0xefec, 0xefed, 0xeff1, 0xc273, 0xc272,
+  0xeff0, 0xc378, 0xf25f, 0xf265, 0xc379, 0xf25c, 0xc376, 0xc373,
+  0xf267, 0xc377, 0xc374, 0xf25e, 0xf261, 0xf262, 0xf263, 0xf266,
+  0xeff5, 0xf25d, 0xc375, 0xf264, 0xf268, 0xf260, 0xf45d, 0xc46a,
+  0xf460, 0xc46b, 0xf468, 0xf45f, 0xf45c, 0xf45e, 0xf462, 0xf465,
+  0xf464, 0xf467, 0xf45b, 0xc469, 0xf463, 0xf466, 0xf469, 0xf461,
+  0xf5d3, 0xf5d4, 0xf5d8, 0xf5d9, 0xf5d6, 0xf5d7, 0xf5d5, 0xc4e9,
+  0xc578, 0xf6eb, 0xf6e8, 0xf6e9, 0xf6ea, 0xc579, 0xf7e5, 0xf7e4,
+  0xf8af, 0xc5f4, 0xf8ad, 0xf8b0, 0xf8ae, 0xf8f5, 0xc657, 0xc665,
+  0xf9a3, 0xf96c, 0xf9a2, 0xf9d0, 0xf9d1, 0xa4f5, 0xa6c7, 0xca41,
+  0xcb5e, 0xa85f, 0xa862, 0xcb5f, 0xa860, 0xa861, 0xcd58, 0xcd5a,
+  0xcd55, 0xcd52, 0xcd54, 0xaaa4, 0xaaa2, 0xcd56, 0xaaa3, 0xcd53,
+  0xcd50, 0xaaa1, 0xcd57, 0xcd51, 0xaaa5, 0xcd59, 0xcfaf, 0xcfb3,
+  0xacb7, 0xcfb6, 0xacaf, 0xacb2, 0xacb4, 0xacb6, 0xacb3, 0xcfb2,
+  0xcfb1, 0xacb1, 0xcfb4, 0xcfb5, 0xcfae, 0xacb5, 0xacb0, 0xcfb0,
+  0xd277, 0xd278, 0xd279, 0xaf50, 0xaf4c, 0xd26e, 0xd276, 0xd27b,
+  0xaf51, 0xd26c, 0xd272, 0xd26b, 0xd275, 0xd271, 0xaf4d, 0xaf4f,
+  0xd27a, 0xd26a, 0xd26d, 0xd273, 0xd274, 0xd27c, 0xd270, 0xaf4e,
+  0xb26d, 0xd64e, 0xd650, 0xd64c, 0xd658, 0xd64a, 0xd657, 0xb269,
+  0xd648, 0xda5b, 0xd652, 0xb26c, 0xd653, 0xd656, 0xd65a, 0xd64f,
+  0xd654, 0xb26a, 0xb26b, 0xd659, 0xd64d, 0xd649, 0xd65b, 0xd651,
+  0xd655, 0xd64b, 0xb548, 0xb549, 0xda65, 0xb54f, 0xda59, 0xda62,
+  0xda58, 0xb54c, 0xda60, 0xda5e, 0xda5f, 0xb54a, 0xda63, 0xda5c,
+  0xda5a, 0xb54b, 0xda5d, 0xda61, 0xb54d, 0xda64, 0xde70, 0xde77,
+  0xde79, 0xdea1, 0xb7da, 0xde6b, 0xb7d2, 0xde7a, 0xb7d7, 0xdea2,
+  0xb7ce, 0xde7d, 0xde6d, 0xde7e, 0xde6c, 0xb7dc, 0xde78, 0xb7cf,
+  0xdea3, 0xb7d4, 0xde71, 0xb7d9, 0xde7c, 0xde6f, 0xde76, 0xde72,
+  0xde6e, 0xb7d1, 0xb7d8, 0xb7d6, 0xb7d3, 0xb7db, 0xb7d0, 0xde75,
+  0xb7d5, 0xb54e, 0xde7b, 0xde73, 0xde74, 0xe2c1, 0xbab4, 0xe2bd,
+  0xe2c3, 0xe2bf, 0xbab6, 0xe2be, 0xe2c2, 0xe2ba, 0xe2bc, 0xbab5,
+  0xe2c0, 0xe2bb, 0xbab7, 0xbab2, 0xe2c4, 0xbab3, 0xe667, 0xe664,
+  0xe670, 0xe66a, 0xe66c, 0xbcf4, 0xe666, 0xe66e, 0xe66d, 0xe66b,
+  0xe671, 0xbcf7, 0xe668, 0xe66f, 0xbcf5, 0xe663, 0xe665, 0xbcf6,
+  0xe662, 0xe672, 0xe669, 0xea4a, 0xbf51, 0xea55, 0xea53, 0xbf4b,
+  0xea49, 0xea4c, 0xea4d, 0xea48, 0xbf55, 0xbf56, 0xea47, 0xea56,
+  0xea51, 0xbf4f, 0xbf4c, 0xea50, 0xea4e, 0xbf52, 0xea52, 0xbf4d,
+  0xbf4e, 0xea4f, 0xbf50, 0xea4b, 0xea54, 0xbf53, 0xea57, 0xea58,
+  0xbf54, 0xc0e7, 0xc0ee, 0xed5c, 0xed62, 0xed60, 0xc0ea, 0xc0e9,
+  0xc0e6, 0xed5e, 0xc0ec, 0xc0eb, 0xc0e8, 0xed61, 0xed5d, 0xed5f,
+  0xc0ed, 0xc277, 0xeffb, 0xc274, 0xc275, 0xeffd, 0xc276, 0xeffa,
+  0xeff9, 0xf26c, 0xeffc, 0xf26d, 0xc37a, 0xf26b, 0xf26a, 0xf269,
+  0xc37b, 0xc46c, 0xf46a, 0xf46b, 0xf5dc, 0xf5db, 0xc4ea, 0xf5da,
+  0xf6ec, 0xf6ed, 0xf7e6, 0xf8b1, 0xf8f6, 0xf9bc, 0xc679, 0xf9c6,
+  0xa4f6, 0xaaa6, 0xaaa7, 0xacb8, 0xc0ef, 0xa4f7, 0xaaa8, 0xaf52,
+  0xb7dd, 0xa4f8, 0xb26e, 0xbab8, 0xc962, 0xcfb7, 0xd27d, 0xe2c5,
+  0xc0f0, 0xa4f9, 0xaaa9, 0xcfb8, 0xcfb9, 0xda66, 0xb550, 0xdea4,
+  0xb7de, 0xe2c6, 0xbcf8, 0xc37c, 0xa4fa, 0xda67, 0xa4fb, 0xa6c9,
+  0xca42, 0xa6c8, 0xa865, 0xa864, 0xa863, 0xcb60, 0xaaaa, 0xaaab,
+  0xcd5b, 0xcfba, 0xcfbd, 0xacba, 0xcfbb, 0xacb9, 0xcfbc, 0xacbb,
+  0xd2a2, 0xd2a1, 0xd27e, 0xaf53, 0xd65d, 0xd65e, 0xb26f, 0xd65c,
+  0xd65f, 0xb552, 0xb270, 0xb551, 0xda6b, 0xda6a, 0xda68, 0xda69,
+  0xda6c, 0xdea6, 0xdea5, 0xdea9, 0xdea8, 0xdea7, 0xbab9, 0xe2c9,
+  0xe2c8, 0xbaba, 0xe2c7, 0xe673, 0xe674, 0xbcf9, 0xea59, 0xea5a,
+  0xf272, 0xc37d, 0xf271, 0xf270, 0xf26e, 0xf26f, 0xc4eb, 0xf46c,
+  0xf6ee, 0xf8f7, 0xa4fc, 0xc9a5, 0xa5c7, 0xc9a6, 0xca43, 0xca44,
+  0xcb66, 0xcb62, 0xcb61, 0xaaac, 0xcb65, 0xa867, 0xcb63, 0xa866,
+  0xcb67, 0xcb64, 0xcd5f, 0xcfbe, 0xcd5d, 0xcd64, 0xaaad, 0xaab0,
+  0xcd65, 0xcd61, 0xcd62, 0xcd5c, 0xaaaf, 0xcd5e, 0xaaae, 0xcd63,
+  0xcd60, 0xcfc2, 0xacbd, 0xacbe, 0xcfc5, 0xcfbf, 0xcfc4, 0xcfc0,
+  0xacbc, 0xcfc3, 0xcfc1, 0xd2a8, 0xd2a5, 0xd2a7, 0xaf58, 0xaf57,
+  0xaf55, 0xd2a4, 0xd2a9, 0xaf54, 0xaf56, 0xd2a6, 0xd667, 0xd2a3,
+  0xd2aa, 0xd662, 0xd666, 0xd665, 0xda6e, 0xda79, 0xd668, 0xd663,
+  0xda6d, 0xb274, 0xb273, 0xd661, 0xd664, 0xb275, 0xb272, 0xb271,
+  0xd660, 0xd669, 0xda70, 0xda77, 0xb554, 0xda76, 0xda73, 0xb556,
+  0xda75, 0xda6f, 0xda71, 0xda74, 0xda72, 0xb555, 0xda78, 0xb553,
+  0xb7df, 0xdead, 0xdeac, 0xdeaa, 0xb7e2, 0xb7e1, 0xdeae, 0xdeab,
+  0xe2ca, 0xbabb, 0xb7e0, 0xdeb0, 0xdeaf, 0xe2cd, 0xe2cb, 0xbcfa,
+  0xbabc, 0xe2cc, 0xe676, 0xbcfb, 0xe675, 0xe67e, 0xe67d, 0xe67b,
+  0xe67a, 0xe677, 0xe678, 0xe679, 0xe67c, 0xe6a1, 0xea5f, 0xea5c,
+  0xea5d, 0xbf57, 0xea5b, 0xea61, 0xea60, 0xea5e, 0xed64, 0xed65,
+  0xc0f1, 0xc0f2, 0xed63, 0xc279, 0xeffe, 0xc278, 0xc37e, 0xc3a1,
+  0xc46d, 0xf46e, 0xf46d, 0xf5dd, 0xf6ef, 0xc57a, 0xf7e8, 0xf7e7,
+  0xf7e9, 0xa5c8, 0xcfc6, 0xaf59, 0xb276, 0xd66a, 0xa5c9, 0xc9a7,
+  0xa4fd, 0xca45, 0xcb6c, 0xcb6a, 0xcb6b, 0xcb68, 0xa868, 0xcb69,
+  0xcd6d, 0xaab3, 0xcd6b, 0xcd67, 0xcd6a, 0xcd66, 0xaab5, 0xcd69,
+  0xaab2, 0xaab1, 0xaab4, 0xcd6c, 0xcd68, 0xacc2, 0xacc5, 0xcfce,
+  0xcfcd, 0xcfcc, 0xacbf, 0xcfd5, 0xcfcb, 0xacc1, 0xd2af, 0xcfd2,
+  0xcfd0, 0xacc4, 0xcfc8, 0xcfd3, 0xcfca, 0xcfd4, 0xcfd1, 0xcfc9,
+  0xacc0, 0xcfd6, 0xcfc7, 0xacc3, 0xd2b4, 0xd2ab, 0xd2b6, 0xd2ae,
+  0xd2b9, 0xd2ba, 0xd2ac, 0xd2b8, 0xd2b5, 0xd2b3, 0xd2b7, 0xaf5f,
+  0xaf5d, 0xd2b1, 0xd2ad, 0xd2b0, 0xd2bb, 0xd2b2, 0xaf5e, 0xcfcf,
+  0xaf5a, 0xaf5c, 0xd678, 0xd66d, 0xd66b, 0xd66c, 0xd673, 0xd674,
+  0xd670, 0xb27b, 0xd675, 0xd672, 0xd66f, 0xb279, 0xd66e, 0xb277,
+  0xb27a, 0xd671, 0xd679, 0xaf5b, 0xb278, 0xd677, 0xd676, 0xb27c,
+  0xda7e, 0xdaa1, 0xb560, 0xdaa7, 0xdaa9, 0xdaa2, 0xb55a, 0xdaa6,
+  0xdaa5, 0xb55b, 0xb561, 0xb562, 0xdaa8, 0xb558, 0xda7d, 0xda7b,
+  0xdaa3, 0xda7a, 0xb55f, 0xda7c, 0xdaa4, 0xdaaa, 0xb559, 0xb55e,
+  0xb55c, 0xb55d, 0xb557, 0xb7e9, 0xdeb7, 0xb7e8, 0xdebb, 0xdeb1,
+  0xdebc, 0xdeb2, 0xdeb3, 0xdebd, 0xdeba, 0xdeb8, 0xdeb9, 0xdeb5,
+  0xdeb4, 0xdebe, 0xb7e5, 0xdeb6, 0xb7ea, 0xb7e4, 0xb7eb, 0xb7ec,
+  0xb7e7, 0xb7e6, 0xe2ce, 0xbabe, 0xbabd, 0xe2d3, 0xbcfc, 0xbabf,
+  0xbac1, 0xe2d4, 0xb7e3, 0xbac0, 0xe2d0, 0xe2d2, 0xe2cf, 0xe2d1,
+  0xe6ab, 0xe6aa, 0xe6a7, 0xbd40, 0xea62, 0xbd41, 0xe6a6, 0xbcfe,
+  0xe6a8, 0xe6a5, 0xe6a2, 0xe6a9, 0xe6a3, 0xe6a4, 0xbcfd, 0xed69,
+  0xea66, 0xea65, 0xea67, 0xed66, 0xbf5a, 0xea63, 0xbf58, 0xbf5c,
+  0xbf5b, 0xea64, 0xea68, 0xbf59, 0xed6d, 0xc0f5, 0xc27a, 0xc0f6,
+  0xc0f3, 0xed6a, 0xed68, 0xed6b, 0xed6e, 0xc0f4, 0xed6c, 0xed67,
+  0xf042, 0xf045, 0xf275, 0xf040, 0xf46f, 0xf046, 0xc3a2, 0xf044,
+  0xc27b, 0xf041, 0xf043, 0xf047, 0xf276, 0xf274, 0xc3a3, 0xf273,
+  0xc46e, 0xc4ed, 0xf6f1, 0xc4ec, 0xf6f3, 0xf6f0, 0xf6f2, 0xc5d0,
+  0xf8b2, 0xa5ca, 0xcd6e, 0xd2bc, 0xd2bd, 0xb27d, 0xdebf, 0xbf5d,
+  0xc3a4, 0xc57b, 0xf8b3, 0xa5cb, 0xcd6f, 0xa260, 0xcfd7, 0xcfd8,
+  0xd2be, 0xd2bf, 0xb27e, 0xb2a1, 0xdaab, 0xdec2, 0xdec1, 0xdec0,
+  0xe2d5, 0xe2d6, 0xe2d7, 0xbac2, 0xe6ad, 0xe6ac, 0xea69, 0xbf5e,
+  0xbf5f, 0xed72, 0xed6f, 0xed70, 0xed71, 0xf049, 0xf048, 0xc27c,
+  0xf277, 0xf5de, 0xa5cc, 0xacc6, 0xb2a2, 0xdec3, 0xa5cd, 0xd2c0,
+  0xb2a3, 0xb563, 0xb564, 0xa5ce, 0xa5cf, 0xca46, 0xa86a, 0xa869,
+  0xacc7, 0xcfd9, 0xdaac, 0xa5d0, 0xa5d1, 0xa5d2, 0xa5d3, 0xa86b,
+  0xa86c, 0xcb6e, 0xcb6d, 0xaab6, 0xcd72, 0xcd70, 0xcd71, 0xcfda,
+  0xcfdb, 0xaccb, 0xacc9, 0xacca, 0xacc8, 0xaf60, 0xaf64, 0xaf63,
+  0xd2c1, 0xaf62, 0xaf61, 0xd2c2, 0xb2a6, 0xd67b, 0xd67a, 0xb2a4,
+  0xb2a5, 0xb566, 0xb565, 0xdaae, 0xdaad, 0xb2a7, 0xb7ed, 0xdec5,
+  0xb7ee, 0xdec4, 0xe2d8, 0xe6ae, 0xbd42, 0xea6a, 0xed73, 0xc3a6,
+  0xc3a5, 0xc57c, 0xa5d4, 0xcd73, 0xb2a8, 0xe2d9, 0xbac3, 0xcb6f,
+  0xcb70, 0xcd74, 0xaab8, 0xaab9, 0xaab7, 0xaccf, 0xacd0, 0xaccd,
+  0xacce, 0xcfdc, 0xcfdd, 0xaccc, 0xd2c3, 0xaf68, 0xaf69, 0xb2ab,
+  0xd2c9, 0xaf6e, 0xaf6c, 0xd2ca, 0xd2c5, 0xaf6b, 0xaf6a, 0xaf65,
+  0xd2c8, 0xd2c7, 0xd2c4, 0xaf6d, 0xd2c6, 0xaf66, 0xaf67, 0xb2ac,
+  0xd6a1, 0xd6a2, 0xb2ad, 0xd67c, 0xd67e, 0xd6a4, 0xd6a3, 0xd67d,
+  0xb2a9, 0xb2aa, 0xdab6, 0xb56b, 0xb56a, 0xdab0, 0xb568, 0xdab3,
+  0xb56c, 0xdab4, 0xb56d, 0xdab1, 0xb567, 0xb569, 0xdab5, 0xdab2,
+  0xdaaf, 0xded2, 0xdec7, 0xb7f0, 0xb7f3, 0xb7f2, 0xb7f7, 0xb7f6,
+  0xded3, 0xded1, 0xdeca, 0xdece, 0xdecd, 0xb7f4, 0xded0, 0xdecc,
+  0xded4, 0xdecb, 0xb7f5, 0xb7ef, 0xb7f1, 0xdec9, 0xe2db, 0xbac7,
+  0xe2df, 0xbac6, 0xe2dc, 0xbac5, 0xdec8, 0xdecf, 0xe2de, 0xbac8,
+  0xe2e0, 0xe2dd, 0xe2da, 0xe6b1, 0xe6b5, 0xe6b7, 0xe6b3, 0xe6b2,
+  0xe6b0, 0xbd45, 0xbd43, 0xbd48, 0xbd49, 0xe6b4, 0xbd46, 0xe6af,
+  0xbd47, 0xbac4, 0xe6b6, 0xbd44, 0xea6c, 0xea6b, 0xea73, 0xea6d,
+  0xea72, 0xea6f, 0xbf60, 0xea71, 0xbf61, 0xbf62, 0xea70, 0xea6e,
+  0xc0f8, 0xed74, 0xc0f7, 0xed77, 0xed75, 0xed76, 0xc0f9, 0xf04d,
+  0xc2a1, 0xf04e, 0xc27d, 0xf04f, 0xc27e, 0xf04c, 0xf050, 0xf04a,
+  0xc3a7, 0xf278, 0xc3a8, 0xc46f, 0xf04b, 0xc470, 0xc4ee, 0xf5df,
+  0xc57e, 0xf6f4, 0xc57d, 0xf7ea, 0xc5f5, 0xc5f6, 0xf9cc, 0xacd1,
+  0xcfde, 0xb56e, 0xb56f, 0xa5d5, 0xa6ca, 0xca47, 0xcb71, 0xa86d,
+  0xaaba, 0xacd2, 0xacd3, 0xacd4, 0xd6a6, 0xd2cb, 0xaf6f, 0xb2ae,
+  0xd6a5, 0xdab8, 0xb571, 0xdab7, 0xb570, 0xded5, 0xbd4a, 0xe6bb,
+  0xe6b8, 0xe6b9, 0xe6ba, 0xed78, 0xf051, 0xf471, 0xf470, 0xf6f5,
+  0xa5d6, 0xcd75, 0xaf70, 0xb572, 0xded6, 0xe2e1, 0xbd4b, 0xea74,
+  0xf052, 0xf472, 0xa5d7, 0xaabb, 0xacd7, 0xcfdf, 0xacd8, 0xacd6,
+  0xacd5, 0xd2cc, 0xaf71, 0xaf72, 0xaf73, 0xb2b0, 0xd6a7, 0xb2af,
+  0xdab9, 0xb2b1, 0xb573, 0xded7, 0xb7f8, 0xb7f9, 0xbac9, 0xbaca,
+  0xbd4c, 0xbf64, 0xea75, 0xbf63, 0xed79, 0xc0fa, 0xf053, 0xf473,
+  0xa5d8, 0xa86e, 0xcd78, 0xcd77, 0xaabc, 0xcd76, 0xaabd, 0xcd79,
+  0xcfe5, 0xacdb, 0xacda, 0xcfe7, 0xcfe6, 0xacdf, 0xacde, 0xacd9,
+  0xcfe1, 0xcfe2, 0xcfe3, 0xace0, 0xcfe0, 0xacdc, 0xcfe4, 0xacdd,
+  0xd2cf, 0xd2d3, 0xd2d1, 0xd2d0, 0xd2d4, 0xd2d5, 0xd2d6, 0xd2ce,
+  0xd2cd, 0xaf75, 0xaf76, 0xd2d7, 0xd2d2, 0xd6b0, 0xd2d8, 0xaf77,
+  0xaf74, 0xd6aa, 0xd6a9, 0xd6ab, 0xd6ac, 0xd6ae, 0xd6ad, 0xd6b2,
+  0xb2b5, 0xb2b2, 0xb2b6, 0xd6a8, 0xb2b7, 0xd6b1, 0xb2b4, 0xd6af,
+  0xb2b3, 0xdabc, 0xdabe, 0xdaba, 0xdabb, 0xdabf, 0xdac1, 0xdac2,
+  0xdabd, 0xdac0, 0xb574, 0xdedb, 0xdee0, 0xded8, 0xdedc, 0xdee1,
+  0xdedd, 0xb7fa, 0xb843, 0xb7fd, 0xded9, 0xdeda, 0xbace, 0xb846,
+  0xb7fe, 0xb844, 0xb7fc, 0xdedf, 0xb845, 0xdede, 0xb841, 0xb7fb,
+  0xb842, 0xdee2, 0xe2e6, 0xe2e8, 0xb840, 0xe2e3, 0xbacc, 0xe2e9,
+  0xbacd, 0xe2e7, 0xe2e2, 0xe2e5, 0xe2ea, 0xbacb, 0xe2e4, 0xbd4e,
+  0xe6bf, 0xe6be, 0xbd51, 0xbd4f, 0xe6bc, 0xbd4d, 0xe6bd, 0xbd50,
+  0xea7d, 0xeaa1, 0xea7e, 0xea76, 0xea7a, 0xea79, 0xea77, 0xbf66,
+  0xbf67, 0xbf65, 0xea78, 0xea7b, 0xea7c, 0xbf68, 0xc140, 0xeda3,
+  0xc0fc, 0xed7b, 0xc0fe, 0xc141, 0xc0fd, 0xeda2, 0xed7c, 0xc0fb,
+  0xeda1, 0xed7a, 0xed7e, 0xed7d, 0xf055, 0xc2a4, 0xc2a5, 0xc2a2,
+  0xc2a3, 0xf054, 0xf27b, 0xc3a9, 0xf279, 0xf27a, 0xf474, 0xf477,
+  0xf475, 0xf476, 0xf5e0, 0xc4ef, 0xf7eb, 0xf8b4, 0xc5f7, 0xf8f8,
+  0xf8f9, 0xc666, 0xa5d9, 0xace1, 0xdac3, 0xdee3, 0xa5da, 0xa86f,
+  0xaabe, 0xcfe8, 0xcfe9, 0xaf78, 0xdac4, 0xb575, 0xb847, 0xc142,
+  0xeda4, 0xf27c, 0xf478, 0xa5db, 0xcda1, 0xcd7a, 0xcd7c, 0xcd7e,
+  0xcd7d, 0xcd7b, 0xaabf, 0xace2, 0xcff2, 0xcfed, 0xcfea, 0xcff1,
+  0xace4, 0xace5, 0xcff0, 0xcfef, 0xcfee, 0xcfeb, 0xcfec, 0xcff3,
+  0xace3, 0xaf7c, 0xafa4, 0xafa3, 0xd2e1, 0xd2db, 0xd2d9, 0xafa1,
+  0xd6b9, 0xaf7a, 0xd2de, 0xd2e2, 0xd2e4, 0xd2e0, 0xd2da, 0xafa2,
+  0xd2df, 0xd2dd, 0xaf79, 0xd2e5, 0xafa5, 0xd2e3, 0xaf7d, 0xd2dc,
+  0xaf7e, 0xaf7b, 0xb2b9, 0xd6ba, 0xd6b3, 0xd6b5, 0xd6b7, 0xd6b8,
+  0xd6b6, 0xb2ba, 0xd6bb, 0xd6b4, 0xdac8, 0xb576, 0xdad0, 0xdac5,
+  0xdad1, 0xdac6, 0xdac7, 0xdacf, 0xdace, 0xdacb, 0xb2b8, 0xb577,
+  0xdac9, 0xdacc, 0xb578, 0xdacd, 0xdaca, 0xdeee, 0xdef2, 0xb84e,
+  0xe2f0, 0xb851, 0xdef0, 0xdeed, 0xdee8, 0xdeea, 0xdeeb, 0xdee4,
+  0xb84d, 0xb84c, 0xb848, 0xdee7, 0xb84f, 0xb850, 0xdee6, 0xdee9,
+  0xdef1, 0xb84a, 0xb84b, 0xdeef, 0xdee5, 0xe2f2, 0xbad0, 0xe2f4,
+  0xdeec, 0xe2f6, 0xbad4, 0xe2f7, 0xe2f3, 0xbad1, 0xe2ef, 0xbad3,
+  0xe2ec, 0xe2f1, 0xe2f5, 0xe2ee, 0xb849, 0xe2eb, 0xbad2, 0xe2ed,
+  0xbd54, 0xe6c1, 0xbd58, 0xbd56, 0xbacf, 0xe6c8, 0xe6c9, 0xbd53,
+  0xe6c7, 0xe6ca, 0xbd55, 0xbd52, 0xe6c3, 0xe6c0, 0xe6c5, 0xe6c2,
+  0xbd59, 0xe6c4, 0xe6c6, 0xbd57, 0xbf6a, 0xeaa8, 0xeaa2, 0xeaa6,
+  0xeaac, 0xeaad, 0xeaa9, 0xeaaa, 0xeaa7, 0xeaa4, 0xbf6c, 0xbf69,
+  0xeaa3, 0xeaa5, 0xbf6b, 0xeaab, 0xc146, 0xedaa, 0xeda5, 0xc145,
+  0xc143, 0xedac, 0xc144, 0xeda8, 0xeda9, 0xeda6, 0xedad, 0xf056,
+  0xc147, 0xeda7, 0xedae, 0xedab, 0xf05a, 0xf057, 0xc2a6, 0xf05b,
+  0xf05d, 0xf05c, 0xf058, 0xf059, 0xf2a3, 0xc3aa, 0xf27e, 0xf2a2,
+  0xf27d, 0xf2a4, 0xf2a1, 0xf47a, 0xf47d, 0xf479, 0xc471, 0xf47b,
+  0xf47c, 0xf47e, 0xc472, 0xc474, 0xc473, 0xf5e1, 0xf5e3, 0xf5e2,
+  0xf6f6, 0xf8b5, 0xf8fa, 0xa5dc, 0xcb72, 0xaac0, 0xcda3, 0xaac1,
+  0xaac2, 0xcda2, 0xcff8, 0xcff7, 0xace6, 0xace9, 0xace8, 0xace7,
+  0xcff4, 0xcff6, 0xcff5, 0xd2e8, 0xafa7, 0xd2ec, 0xd2eb, 0xd2ea,
+  0xd2e6, 0xafa6, 0xafaa, 0xafad, 0xafae, 0xd2e7, 0xd2e9, 0xafac,
+  0xafab, 0xafa9, 0xafa8, 0xd6c2, 0xd6c0, 0xd6bc, 0xb2bb, 0xd6bd,
+  0xb2bc, 0xd6be, 0xd6bf, 0xd6c1, 0xb2bd, 0xdad5, 0xdad4, 0xdad3,
+  0xdad2, 0xdef6, 0xb852, 0xdef3, 0xdef5, 0xb853, 0xb854, 0xdef4,
+  0xe341, 0xe2f9, 0xe2fa, 0xbad7, 0xbad5, 0xbad6, 0xe343, 0xe342,
+  0xe2fe, 0xe2fd, 0xe2fc, 0xe2fb, 0xe340, 0xe2f8, 0xe6cb, 0xe6d0,
+  0xe6ce, 0xe6cd, 0xe6cc, 0xe6cf, 0xeaae, 0xbf6d, 0xc148, 0xedb0,
+  0xc149, 0xedaf, 0xf05f, 0xf05e, 0xc2a7, 0xf2a5, 0xc3ab, 0xf4a1,
+  0xc5a1, 0xf6f7, 0xf8b7, 0xf8b6, 0xc9a8, 0xacea, 0xaceb, 0xd6c3,
+  0xb856, 0xa5dd, 0xa872, 0xa871, 0xa870, 0xcda4, 0xaac4, 0xaac3,
+  0xacee, 0xcffa, 0xcffd, 0xcffb, 0xacec, 0xaced, 0xcff9, 0xcffc,
+  0xafb5, 0xd2f3, 0xd2f5, 0xd2f4, 0xafb2, 0xd2ef, 0xafb0, 0xafaf,
+  0xafb3, 0xafb1, 0xafb4, 0xd2f2, 0xd2ed, 0xd2ee, 0xd2f1, 0xd2f0,
+  0xd6c6, 0xd6c7, 0xd6c5, 0xd6c4, 0xb2be, 0xb57d, 0xdad6, 0xdad8,
+  0xdada, 0xb57c, 0xb57a, 0xdad7, 0xb57b, 0xdad9, 0xb579, 0xdf41,
+  0xdef7, 0xdefa, 0xdefe, 0xb85a, 0xdefc, 0xdefb, 0xdef8, 0xdef9,
+  0xb858, 0xdf40, 0xb857, 0xb85c, 0xb85b, 0xb859, 0xdefd, 0xe349,
+  0xe348, 0xe344, 0xbad8, 0xe347, 0xe346, 0xbad9, 0xbd5e, 0xe6d2,
+  0xbd5f, 0xbd5b, 0xbd5d, 0xbd5a, 0xbd5c, 0xeaaf, 0xbf70, 0xeab1,
+  0xeab0, 0xe345, 0xbf72, 0xbf71, 0xbf6e, 0xbf6f, 0xedb5, 0xedb3,
+  0xc14a, 0xedb4, 0xedb6, 0xedb2, 0xedb1, 0xf060, 0xc2aa, 0xc2a8,
+  0xc2a9, 0xf2a6, 0xf2a7, 0xc3ad, 0xc3ac, 0xf4a3, 0xf4a4, 0xf4a2,
+  0xf6f8, 0xf6f9, 0xa5de, 0xca48, 0xa873, 0xcda5, 0xaac6, 0xaac5,
+  0xcda6, 0xd040, 0xacef, 0xcffe, 0xacf0, 0xafb6, 0xd2f8, 0xd2f6,
+  0xd2fc, 0xafb7, 0xd2f7, 0xd2fb, 0xd2f9, 0xd2fa, 0xd6c8, 0xd6ca,
+  0xb2bf, 0xd6c9, 0xb2c0, 0xb5a2, 0xb5a1, 0xb57e, 0xdadb, 0xdf44,
+  0xb85d, 0xb85e, 0xdf43, 0xdf42, 0xe34a, 0xbadb, 0xbada, 0xe34b,
+  0xe34c, 0xbd61, 0xbd60, 0xeab5, 0xe6d3, 0xe6d5, 0xe6d4, 0xeab4,
+  0xeab2, 0xeab6, 0xeab3, 0xbf73, 0xedb7, 0xc14b, 0xedb8, 0xedb9,
+  0xc2ab, 0xc2ac, 0xc475, 0xc5d1, 0xa5df, 0xd041, 0xd2fd, 0xafb8,
+  0xb3ba, 0xb3b9, 0xb5a4, 0xdadd, 0xb5a3, 0xdadc, 0xdf45, 0xbadc,
+  0xe34d, 0xbadd, 0xc476, 0xf4a5, 0xa6cb, 0xaac7, 0xcda7, 0xacf2,
+  0xacf1, 0xd042, 0xd043, 0xd340, 0xd342, 0xafb9, 0xd344, 0xd347,
+  0xd345, 0xd346, 0xd343, 0xd2fe, 0xafba, 0xd348, 0xd341, 0xd6d3,
+  0xb2c6, 0xd6dc, 0xb2c3, 0xd6d5, 0xb2c7, 0xb2c1, 0xd6d0, 0xd6dd,
+  0xd6d1, 0xd6ce, 0xb2c5, 0xb2c2, 0xd6d4, 0xd6d7, 0xb2c4, 0xd6d8,
+  0xb2c8, 0xd6d9, 0xd6cf, 0xd6d6, 0xd6da, 0xd6d2, 0xd6cd, 0xd6cb,
+  0xd6db, 0xdadf, 0xdae4, 0xdae0, 0xdae6, 0xb5a7, 0xd6cc, 0xdae1,
+  0xb5a5, 0xdade, 0xb5ac, 0xdae2, 0xb5ab, 0xdae3, 0xb5ad, 0xb5a8,
+  0xb5ae, 0xb5a9, 0xb5aa, 0xb5a6, 0xdae5, 0xb861, 0xdf50, 0xdf53,
+  0xdf47, 0xdf4c, 0xdf46, 0xb863, 0xdf4a, 0xdf48, 0xb862, 0xdf4f,
+  0xdf4e, 0xdf4b, 0xdf4d, 0xdf49, 0xbae1, 0xdf52, 0xb85f, 0xdf51,
+  0xe35d, 0xbae8, 0xe358, 0xbae7, 0xe34e, 0xe350, 0xbae0, 0xe355,
+  0xe354, 0xe357, 0xbae5, 0xe352, 0xe351, 0xbae4, 0xbadf, 0xe353,
+  0xbae2, 0xe359, 0xe35b, 0xe356, 0xe34f, 0xbae3, 0xbd69, 0xbade,
+  0xe35c, 0xe6d9, 0xbd62, 0xe6db, 0xbd63, 0xbd65, 0xe6de, 0xe6d6,
+  0xbae6, 0xe6dc, 0xe6d8, 0xb860, 0xbd68, 0xbd64, 0xbd66, 0xbd67,
+  0xbf76, 0xe6dd, 0xe6d7, 0xbd6a, 0xe6da, 0xeac0, 0xeabb, 0xeac5,
+  0xbf74, 0xeabd, 0xbf78, 0xeac3, 0xeaba, 0xeab7, 0xeac6, 0xc151,
+  0xbf79, 0xeac2, 0xeab8, 0xbf77, 0xeabc, 0xbf7b, 0xeab9, 0xeabe,
+  0xbf7a, 0xeac1, 0xeac4, 0xedcb, 0xedcc, 0xedbc, 0xedc3, 0xedc1,
+  0xc14f, 0xedc8, 0xeabf, 0xedbf, 0xedc9, 0xc14e, 0xedbe, 0xedbd,
+  0xedc7, 0xedc4, 0xedc6, 0xedba, 0xedca, 0xc14c, 0xedc5, 0xedce,
+  0xedc2, 0xc150, 0xc14d, 0xedc0, 0xedbb, 0xedcd, 0xbf75, 0xf063,
+  0xf061, 0xf067, 0xc2b0, 0xf065, 0xf064, 0xc2b2, 0xf06a, 0xc2b1,
+  0xf06b, 0xf068, 0xc2ae, 0xf069, 0xf062, 0xc2af, 0xc2ad, 0xf2ab,
+  0xf066, 0xf06c, 0xf2a8, 0xc3b2, 0xc3b0, 0xf2aa, 0xf2ac, 0xf2a9,
+  0xc3b1, 0xc3ae, 0xc3af, 0xc3b3, 0xc478, 0xf4aa, 0xf4a9, 0xf4a7,
+  0xf4a6, 0xf4a8, 0xc477, 0xc479, 0xc4f0, 0xf5e5, 0xf5e4, 0xf6fa,
+  0xf6fc, 0xf6fe, 0xf6fd, 0xf6fb, 0xc5a3, 0xc5a2, 0xc5d3, 0xc5d2,
+  0xc5d4, 0xf7ed, 0xf7ec, 0xf8fb, 0xf8b8, 0xf8fc, 0xc658, 0xc659,
+  0xf96d, 0xc67e, 0xa6cc, 0xcda8, 0xd045, 0xd046, 0xd044, 0xacf3,
+  0xd047, 0xd048, 0xd049, 0xd349, 0xd34f, 0xd34d, 0xafbb, 0xd34b,
+  0xd34c, 0xd34e, 0xd34a, 0xb2c9, 0xd6de, 0xb2cb, 0xd6e0, 0xb2ca,
+  0xd6df, 0xdae8, 0xb5af, 0xdaea, 0xdae7, 0xd6e1, 0xb5b0, 0xdae9,
+  0xdf56, 0xb864, 0xdf54, 0xb865, 0xdf55, 0xb866, 0xbae9, 0xe361,
+  0xe35e, 0xe360, 0xbaea, 0xbaeb, 0xe35f, 0xe6df, 0xe6e0, 0xbd6b,
+  0xe6e2, 0xe6e1, 0xa261, 0xeaca, 0xeacb, 0xeac7, 0xeac8, 0xbf7c,
+  0xbf7d, 0xeac9, 0xc157, 0xc153, 0xc158, 0xc154, 0xc156, 0xc152,
+  0xc155, 0xc2b3, 0xedcf, 0xf2ae, 0xf2ad, 0xf4ab, 0xc47a, 0xc47b,
+  0xf741, 0xf5e6, 0xf740, 0xf8fd, 0xf9a4, 0xa6cd, 0xa874, 0xcda9,
+  0xaac8, 0xacf6, 0xd04c, 0xacf4, 0xd04a, 0xacf9, 0xacf5, 0xacfa,
+  0xacf8, 0xd04b, 0xacf7, 0xafbf, 0xafbe, 0xd35a, 0xafc7, 0xd353,
+  0xd359, 0xafc3, 0xd352, 0xd358, 0xd356, 0xafc2, 0xafc4, 0xd355,
+  0xafbd, 0xd354, 0xafc8, 0xafc5, 0xafc9, 0xafc6, 0xd351, 0xd350,
+  0xd357, 0xafc0, 0xafbc, 0xafc1, 0xd6f0, 0xd6e9, 0xb5b5, 0xd6e8,
+  0xb2cf, 0xb2d6, 0xb2d3, 0xb2d9, 0xb2d8, 0xb2d4, 0xd6e2, 0xd6e5,
+  0xd6e4, 0xb2d0, 0xd6e6, 0xd6ef, 0xb2d1, 0xd6e3, 0xd6ec, 0xd6ed,
+  0xb2d2, 0xd6ea, 0xb2d7, 0xb2cd, 0xb2d5, 0xd6e7, 0xb2cc, 0xd6eb,
+  0xd6ee, 0xdafb, 0xdaf2, 0xb5b2, 0xdaf9, 0xdaf6, 0xdaee, 0xdaf7,
+  0xb5b4, 0xdaef, 0xdaeb, 0xb86c, 0xdaf4, 0xb5b1, 0xdafa, 0xb5b8,
+  0xb5ba, 0xdaed, 0xb5b9, 0xdaf0, 0xb5b3, 0xdaf8, 0xdaf1, 0xdaf5,
+  0xdaf3, 0xb5b6, 0xdaec, 0xb5bb, 0xb2ce, 0xb5b7, 0xb5bc, 0xb868,
+  0xdf5d, 0xdf5f, 0xdf61, 0xdf65, 0xdf5b, 0xdf59, 0xb86a, 0xdf60,
+  0xdf64, 0xdf5c, 0xdf58, 0xdf57, 0xdf62, 0xdf5a, 0xdf5e, 0xb86b,
+  0xb869, 0xdf66, 0xb867, 0xdf63, 0xe372, 0xbaee, 0xe36a, 0xbd78,
+  0xe374, 0xbaf1, 0xe378, 0xbaf7, 0xe365, 0xe375, 0xe362, 0xe377,
+  0xe366, 0xbafe, 0xbafb, 0xe376, 0xe370, 0xbaed, 0xbaf5, 0xbaf4,
+  0xbaf3, 0xbaf9, 0xe363, 0xbafa, 0xe371, 0xbaf6, 0xbaec, 0xe373,
+  0xbaef, 0xbaf0, 0xbaf8, 0xe368, 0xe367, 0xe364, 0xe36c, 0xe369,
+  0xe36d, 0xbafd, 0xe379, 0xbaf2, 0xe36e, 0xe36f, 0xe36b, 0xbafc,
+  0xe6e7, 0xbd70, 0xbd79, 0xbd75, 0xe6e4, 0xbd72, 0xbd76, 0xe6f0,
+  0xbd6c, 0xe6e8, 0xbd74, 0xe6eb, 0xe6e6, 0xbd73, 0xbd77, 0xe6e5,
+  0xbd71, 0xe6ef, 0xbd6e, 0xe6ee, 0xe6ed, 0xbd7a, 0xe572, 0xbd6d,
+  0xe6ec, 0xe6e3, 0xbd7b, 0xe6ea, 0xbd6f, 0xe6e9, 0xbfa2, 0xbfa7,
+  0xbf7e, 0xead8, 0xeacf, 0xeadb, 0xead3, 0xead9, 0xbfa8, 0xbfa1,
+  0xeacc, 0xead2, 0xeadc, 0xead5, 0xeada, 0xeace, 0xead6, 0xbfa3,
+  0xead4, 0xbfa6, 0xbfa5, 0xead0, 0xead1, 0xeacd, 0xead7, 0xbfa4,
+  0xeade, 0xeadd, 0xedda, 0xedd6, 0xc15f, 0xedd0, 0xc159, 0xc169,
+  0xeddc, 0xc161, 0xc15d, 0xedd3, 0xc164, 0xc167, 0xedde, 0xc15c,
+  0xedd5, 0xc165, 0xede0, 0xeddd, 0xedd1, 0xc160, 0xc15a, 0xc168,
+  0xedd8, 0xc163, 0xedd2, 0xc15e, 0xeddf, 0xc162, 0xc15b, 0xedd9,
+  0xc166, 0xedd7, 0xeddb, 0xf06e, 0xf074, 0xc2b9, 0xf077, 0xc2b4,
+  0xc2b5, 0xf06f, 0xf076, 0xf071, 0xc2ba, 0xc2b7, 0xf06d, 0xc2b6,
+  0xf073, 0xf075, 0xc2b8, 0xf072, 0xf070, 0xf2b8, 0xc3b7, 0xc3b8,
+  0xc3b4, 0xc3b5, 0xf2b4, 0xf2b2, 0xf2b6, 0xc3ba, 0xf2b7, 0xf2b0,
+  0xf2af, 0xf2b3, 0xf2b1, 0xc3b6, 0xf2b5, 0xf4ac, 0xc47e, 0xc47d,
+  0xf4ad, 0xf4af, 0xf4ae, 0xc4a1, 0xf5eb, 0xf5e8, 0xf5e9, 0xf5e7,
+  0xf5ea, 0xc4f2, 0xf5ec, 0xc4f1, 0xf742, 0xc5d5, 0xc5d7, 0xf7ee,
+  0xc5d6, 0xf8b9, 0xf940, 0xf942, 0xf8fe, 0xf941, 0xc66c, 0xa6ce,
+  0xacfb, 0xd26f, 0xafca, 0xb2da, 0xdafc, 0xdafd, 0xeadf, 0xc16a,
+  0xede1, 0xc2bb, 0xf2ba, 0xf2b9, 0xc4a2, 0xf5ed, 0xf743, 0xc5f8,
+  0xca49, 0xaac9, 0xa875, 0xd04d, 0xd360, 0xd35b, 0xd35f, 0xd35d,
+  0xafcb, 0xd35e, 0xd35c, 0xd6f1, 0xdafe, 0xdb40, 0xdf69, 0xdf6a,
+  0xb86e, 0xb86f, 0xdf68, 0xdf6b, 0xdf67, 0xb86d, 0xbb40, 0xb870,
+  0xe37a, 0xbd7c, 0xe6f1, 0xbd7d, 0xbfa9, 0xeae2, 0xeae0, 0xeae1,
+  0xede4, 0xede3, 0xede2, 0xf2bb, 0xc3b9, 0xf2bc, 0xf744, 0xc5f9,
+  0xf8ba, 0xa6cf, 0xaacb, 0xaaca, 0xd04f, 0xacfc, 0xd04e, 0xd362,
+  0xafcc, 0xd6f2, 0xd361, 0xb2dc, 0xd6f5, 0xd6f3, 0xd6f4, 0xb2db,
+  0xdb42, 0xdb43, 0xdb41, 0xb873, 0xdf6d, 0xdf6c, 0xdf6e, 0xb872,
+  0xb871, 0xe6f2, 0xe6f4, 0xbd7e, 0xe6f3, 0xeae3, 0xbfaa, 0xf079,
+  0xf078, 0xc3bb, 0xf2bd, 0xc3bd, 0xc3bc, 0xf4b0, 0xf5ee, 0xc4f3,
+  0xa6d0, 0xd050, 0xacfd, 0xd365, 0xafce, 0xd364, 0xd363, 0xafcd,
+  0xd6fb, 0xd6fd, 0xd6f6, 0xd6f7, 0xb2dd, 0xd6f8, 0xb2de, 0xd6fc,
+  0xd6f9, 0xd6fa, 0xb2df, 0xb5be, 0xb5bf, 0xdb44, 0xdf6f, 0xdf70,
+  0xe37e, 0xbb43, 0xbb41, 0xbb42, 0xe37b, 0xe37c, 0xe37d, 0xe6f9,
+  0xe6fa, 0xbda1, 0xe6f7, 0xe6f6, 0xe6f8, 0xe6f5, 0xbfad, 0xeae4,
+  0xbfab, 0xbfac, 0xede6, 0xc16b, 0xede5, 0xefa8, 0xf07a, 0xf07b,
+  0xc2bc, 0xc2bd, 0xc16c, 0xf2be, 0xf2bf, 0xf4b1, 0xc4a3, 0xa6d1,
+  0xa6d2, 0xacfe, 0xaacc, 0xafcf, 0xd051, 0xb5c0, 0xa6d3, 0xad41,
+  0xd052, 0xd053, 0xad40, 0xad42, 0xa6d4, 0xd054, 0xafd1, 0xd366,
+  0xafd3, 0xafd0, 0xafd2, 0xd741, 0xb2e0, 0xd740, 0xd6fe, 0xdf71,
+  0xe3a1, 0xbda2, 0xbfae, 0xeae6, 0xeae5, 0xede7, 0xf5ef, 0xa6d5,
+  0xcb73, 0xcdaa, 0xad43, 0xd055, 0xd368, 0xafd4, 0xd367, 0xafd5,
+  0xd743, 0xb2e2, 0xd742, 0xd744, 0xb2e1, 0xdb46, 0xdb47, 0xdb45,
+  0xb5c1, 0xb874, 0xb875, 0xbb45, 0xe3a3, 0xe3a2, 0xbb44, 0xe6fb,
+  0xe6fc, 0xeae7, 0xc170, 0xc16f, 0xc16d, 0xc16e, 0xc171, 0xf07c,
+  0xc2bf, 0xc2be, 0xf2c0, 0xf4b2, 0xc5a5, 0xc5a4, 0xa6d6, 0xd1fb,
+  0xb877, 0xb5c2, 0xb876, 0xbb46, 0xa6d7, 0xc9a9, 0xa6d8, 0xa6d9,
+  0xcdab, 0xcb76, 0xcb77, 0xa877, 0xcb74, 0xa876, 0xa879, 0xcb75,
+  0xa87b, 0xa87a, 0xcb78, 0xa878, 0xaad1, 0xaacf, 0xcdad, 0xaace,
+  0xaad3, 0xaad5, 0xaad2, 0xcdb0, 0xcdac, 0xaad6, 0xaad0, 0xa87c,
+  0xaad4, 0xcdaf, 0xcdae, 0xaacd, 0xd05b, 0xad47, 0xad48, 0xd05d,
+  0xd057, 0xd05a, 0xd063, 0xd061, 0xad49, 0xd067, 0xad4c, 0xd064,
+  0xd05c, 0xd059, 0xdb49, 0xd062, 0xad44, 0xd065, 0xd056, 0xd05f,
+  0xad46, 0xad4b, 0xd060, 0xad4f, 0xad4d, 0xd058, 0xad4a, 0xd05e,
+  0xad4e, 0xad45, 0xd066, 0xafda, 0xafe3, 0xafd8, 0xafd6, 0xd36a,
+  0xafde, 0xafdb, 0xd36c, 0xafdd, 0xd36b, 0xd369, 0xd36e, 0xafe2,
+  0xafe0, 0xdb48, 0xd36f, 0xd36d, 0xafd7, 0xafd9, 0xafdc, 0xafdf,
+  0xafe1, 0xd74e, 0xb2e4, 0xd745, 0xd747, 0xd748, 0xd750, 0xd74c,
+  0xd74a, 0xd74d, 0xd751, 0xb2e5, 0xb2e9, 0xd746, 0xd74f, 0xb2e7,
+  0xb2e6, 0xd74b, 0xd749, 0xb2e3, 0xb2e8, 0xb5c8, 0xdb51, 0xdb4f,
+  0xb5ca, 0xdb4a, 0xdfa1, 0xb5c9, 0xdb4e, 0xdb4b, 0xb5c5, 0xb5cb,
+  0xdb50, 0xb5c7, 0xdb4d, 0xbb47, 0xb5c6, 0xdb4c, 0xb5cc, 0xb5c4,
+  0xb5c3, 0xdf77, 0xdf75, 0xdf7b, 0xdf73, 0xdfa2, 0xdf78, 0xdf72,
+  0xb87b, 0xb8a3, 0xdf7d, 0xdf76, 0xb87e, 0xb87c, 0xdf7e, 0xb879,
+  0xb878, 0xdf79, 0xb87d, 0xb5cd, 0xdf7c, 0xdf74, 0xb87a, 0xb8a1,
+  0xb8a2, 0xbb4c, 0xbb48, 0xbb4d, 0xe3a6, 0xe3a5, 0xe3a7, 0xbb4a,
+  0xe3a4, 0xbb4b, 0xe3aa, 0xe3a9, 0xe3a8, 0xbb49, 0xe741, 0xe744,
+  0xbda8, 0xe743, 0xbda7, 0xbda3, 0xbda4, 0xbda5, 0xe740, 0xe6fe,
+  0xbda6, 0xe742, 0xe6fd, 0xeae9, 0xeaf3, 0xbfb1, 0xbfb0, 0xeaed,
+  0xeaef, 0xeaea, 0xeaee, 0xeae8, 0xeaf1, 0xbfaf, 0xeaf0, 0xeaec,
+  0xeaf2, 0xeaeb, 0xc174, 0xede8, 0xedee, 0xc178, 0xc17a, 0xc177,
+  0xc176, 0xc175, 0xc173, 0xede9, 0xedec, 0xc172, 0xeded, 0xc179,
+  0xedeb, 0xedea, 0xc2c0, 0xc2c1, 0xf0a1, 0xf07d, 0xf07e, 0xf2c2,
+  0xf2c1, 0xc3be, 0xf4b4, 0xc4a4, 0xf4b3, 0xf5f0, 0xf745, 0xc5a6,
+  0xf943, 0xf944, 0xc5d8, 0xa6da, 0xaad7, 0xdb52, 0xbb4e, 0xc17b,
+  0xedef, 0xa6db, 0xafe5, 0xafe4, 0xdb53, 0xeaf4, 0xa6dc, 0xad50,
+  0xdb54, 0xdb55, 0xdb56, 0xbb4f, 0xbfb2, 0xa6dd, 0xaad8, 0xd068,
+  0xafe6, 0xd370, 0xb2ea, 0xdb57, 0xb8a4, 0xbb50, 0xbfb3, 0xc17c,
+  0xc2c2, 0xf4b5, 0xa6de, 0xaad9, 0xafe7, 0xd752, 0xb5ce, 0xbb51,
+  0xe3ab, 0xe745, 0xa6df, 0xb5cf, 0xdfa3, 0xbb52, 0xa6e0, 0xcdb1,
+  0xd069, 0xad51, 0xd372, 0xafea, 0xafe8, 0xafe9, 0xafeb, 0xd371,
+  0xd757, 0xd754, 0xd756, 0xb2eb, 0xb2ed, 0xb2ec, 0xd753, 0xb2ee,
+  0xd755, 0xdb58, 0xdb59, 0xdb5a, 0xdfa6, 0xdfa7, 0xdfa5, 0xdfa8,
+  0xb8a5, 0xdfa4, 0xbb53, 0xe74a, 0xe746, 0xe749, 0xe74b, 0xe748,
+  0xe747, 0xeaf5, 0xeaf6, 0xeaf7, 0xbfb4, 0xbfb5, 0xedf1, 0xedf0,
+  0xedf2, 0xf0a3, 0xf0a2, 0xf2c4, 0xf2c5, 0xf2c3, 0xc4a5, 0xf4b6,
+  0xf4b7, 0xf746, 0xf7ef, 0xf8bb, 0xa6e1, 0xa87d, 0xc17d, 0xa6e2,
+  0xd758, 0xdb5b, 0xc641, 0xca4a, 0xca4b, 0xca4d, 0xa6e3, 0xca4e,
+  0xca4c, 0xcba2, 0xcba3, 0xcb7b, 0xcba1, 0xa8a1, 0xa8a2, 0xcb7c,
+  0xcb7a, 0xcb79, 0xcb7d, 0xa87e, 0xcb7e, 0xd06a, 0xcdb6, 0xaadc,
+  0xcdb5, 0xcdb7, 0xaadb, 0xcdbc, 0xaadf, 0xcdb2, 0xcdc0, 0xcdc6,
+  0xaae6, 0xcdc3, 0xaae3, 0xcdb9, 0xcdbf, 0xcdc1, 0xcdb4, 0xaae2,
+  0xaadd, 0xcdba, 0xaae4, 0xaae7, 0xaae1, 0xaada, 0xcdbe, 0xcdb8,
+  0xcdc5, 0xaae9, 0xaae5, 0xaae0, 0xcdbd, 0xafec, 0xcdbb, 0xaade,
+  0xaae8, 0xcdb3, 0xcdc2, 0xcdc4, 0xad62, 0xad5c, 0xad64, 0xad61,
+  0xd071, 0xd074, 0xad5d, 0xd06b, 0xad56, 0xad60, 0xad63, 0xad65,
+  0xd0a2, 0xd077, 0xad55, 0xd0a1, 0xad59, 0xad57, 0xad52, 0xd06f,
+  0xd07e, 0xd073, 0xd076, 0xd0a5, 0xad66, 0xd07d, 0xad5e, 0xd078,
+  0xd0a4, 0xd075, 0xd079, 0xd07c, 0xd06d, 0xd0a3, 0xd07b, 0xd06c,
+  0xd070, 0xad5f, 0xad5a, 0xad53, 0xad58, 0xad54, 0xad67, 0xd06e,
+  0xd3a5, 0xad5b, 0xd07a, 0xce41, 0xd3a8, 0xaffa, 0xd376, 0xd3a3,
+  0xd37d, 0xd3b2, 0xd3aa, 0xd37e, 0xd3a9, 0xd378, 0xd37c, 0xd3b5,
+  0xaffd, 0xd3ad, 0xd3a4, 0xafed, 0xd3b3, 0xd374, 0xd3ac, 0xaffc,
+  0xaff7, 0xd373, 0xaff5, 0xaff4, 0xaff9, 0xd3ab, 0xaff1, 0xaff8,
+  0xd072, 0xdb5c, 0xd3a6, 0xd37a, 0xaffb, 0xd37b, 0xd3a1, 0xaffe,
+  0xd375, 0xd3af, 0xd3ae, 0xd3b6, 0xaff3, 0xaff0, 0xd3b4, 0xd3b0,
+  0xd3a7, 0xd3a2, 0xaff6, 0xaff2, 0xd377, 0xafee, 0xd3b1, 0xafef,
+  0xd379, 0xd75e, 0xd760, 0xd765, 0xd779, 0xb2fc, 0xb2f2, 0xd75d,
+  0xb2fd, 0xb2fe, 0xd768, 0xd76f, 0xd775, 0xd762, 0xd769, 0xb340,
+  0xd777, 0xd772, 0xb2fa, 0xb2f8, 0xd76e, 0xd76a, 0xd75c, 0xb2ef,
+  0xd761, 0xd759, 0xb2f7, 0xb2f9, 0xd766, 0xd763, 0xb2f4, 0xd773,
+  0xb2f1, 0xd764, 0xd77a, 0xd76c, 0xd76b, 0xb2f0, 0xb2fb, 0xb2f3,
+  0xd75a, 0xd75f, 0xd770, 0xd776, 0xb341, 0xd75b, 0xd767, 0xd76d,
+  0xb2f6, 0xd778, 0xd771, 0xd774, 0xb2f5, 0xdb6c, 0xdb60, 0xb5d7,
+  0xdb7d, 0xdba7, 0xdbaa, 0xb5d5, 0xdb68, 0xdba3, 0xdb69, 0xdb77,
+  0xb5e2, 0xdb73, 0xb5df, 0xdb74, 0xdb5d, 0xdba4, 0xb5e8, 0xdba1,
+  0xdb75, 0xdbac, 0xdb70, 0xdfc8, 0xdbaf, 0xb5e6, 0xdb6e, 0xdb7a,
+  0xb5e9, 0xb5d4, 0xdb72, 0xdbad, 0xdb6b, 0xdb64, 0xdb6f, 0xdb63,
+  0xdb61, 0xb5d0, 0xdba5, 0xdb6a, 0xdba8, 0xdba9, 0xb5d8, 0xb5dd,
+  0xb5d9, 0xb5e1, 0xdb7e, 0xb5da, 0xdb76, 0xdb66, 0xb5d2, 0xdb5e,
+  0xdba2, 0xdbab, 0xdb65, 0xb5e0, 0xdbb0, 0xdb71, 0xdb6d, 0xb5d1,
+  0xb5e5, 0xdb7c, 0xb5e7, 0xdb78, 0xb5dc, 0xb5d6, 0xb5de, 0xb5d3,
+  0xb5e4, 0xdb79, 0xdb67, 0xdb7b, 0xdb62, 0xdba6, 0xdbae, 0xdb5f,
+  0xdfc7, 0xdfdd, 0xb855, 0xdfcc, 0xdfca, 0xdfb5, 0xb8a9, 0xdfc5,
+  0xdfd9, 0xdfc1, 0xb8b1, 0xdfd8, 0xdfbf, 0xb5e3, 0xdfcf, 0xdfc0,
+  0xdfd6, 0xb8b0, 0xb8a8, 0xdfaa, 0xdfb2, 0xdfcb, 0xdfc3, 0xdfdc,
+  0xdfc6, 0xb8b6, 0xdfd7, 0xb8ad, 0xdfc9, 0xdfd1, 0xdfb6, 0xdfd0,
+  0xdfe1, 0xdfb1, 0xdfd2, 0xdfdf, 0xdfab, 0xb5db, 0xdfb9, 0xdfb8,
+  0xb8af, 0xdfbc, 0xdfbe, 0xdfcd, 0xdfde, 0xb8b2, 0xb8b3, 0xdfb0,
+  0xb8ab, 0xdfb4, 0xdfda, 0xb8b4, 0xb8ac, 0xb8ae, 0xb8b5, 0xdfe0,
+  0xdfd3, 0xdfce, 0xdfbb, 0xdfba, 0xb8aa, 0xdfac, 0xb8a7, 0xdfc4,
+  0xdfad, 0xdfc2, 0xdfb7, 0xdfdb, 0xb8a6, 0xdfb3, 0xdfaf, 0xdfd5,
+  0xdfae, 0xbb60, 0xe3d3, 0xe3c2, 0xe3ac, 0xe3ca, 0xbb58, 0xe3bb,
+  0xe3c5, 0xbb5b, 0xe3be, 0xbb59, 0xe3af, 0xe3cd, 0xe3ae, 0xe3c1,
+  0xe3ad, 0xe3bf, 0xe3c8, 0xe3c6, 0xe3ba, 0xe3b5, 0xe3b3, 0xe3b4,
+  0xe3c7, 0xe3d2, 0xe3bc, 0xbb5a, 0xe3b7, 0xe3cb, 0xbb5d, 0xe3b6,
+  0xe3b0, 0xe3c0, 0xbb61, 0xbb55, 0xbb5e, 0xe3b8, 0xe3b2, 0xbb57,
+  0xdfd4, 0xbb56, 0xe3c3, 0xbb54, 0xbb63, 0xbb5c, 0xe3c4, 0xe3b9,
+  0xe3b1, 0xe3cc, 0xe3bd, 0xbb62, 0xe3d0, 0xbb5f, 0xe3cf, 0xe3c9,
+  0xe3ce, 0xe3d1, 0xe773, 0xe774, 0xe767, 0xe766, 0xe762, 0xbdb4,
+  0xbdac, 0xe776, 0xe775, 0xdfa9, 0xe75f, 0xe763, 0xe75d, 0xe770,
+  0xe761, 0xe777, 0xe75a, 0xe758, 0xe764, 0xe76e, 0xe769, 0xbdb6,
+  0xe74f, 0xe76d, 0xbdb7, 0xdfbd, 0xe75b, 0xe752, 0xe755, 0xe77b,
+  0xe75c, 0xe753, 0xe751, 0xe74e, 0xbdb0, 0xe765, 0xbdaf, 0xbdb3,
+  0xe760, 0xe768, 0xbda9, 0xe778, 0xe77c, 0xbdab, 0xe757, 0xe76b,
+  0xe76f, 0xe754, 0xe779, 0xbdb2, 0xbdb1, 0xe74c, 0xbdb5, 0xe772,
+  0xe756, 0xe76a, 0xe750, 0xe75e, 0xe759, 0xbdad, 0xbdae, 0xe76c,
+  0xe77d, 0xe77a, 0xe771, 0xe74d, 0xbdaa, 0xeb49, 0xeb40, 0xeb43,
+  0xbfbb, 0xeb45, 0xeaf9, 0xeb41, 0xeb47, 0xbfb8, 0xbfbc, 0xbfb6,
+  0xeafb, 0xeb4c, 0xeb46, 0xeafc, 0xeb55, 0xeb4f, 0xeaf8, 0xee46,
+  0xeafe, 0xbfb7, 0xeb4a, 0xeb54, 0xbfbf, 0xeb51, 0xeafd, 0xeb44,
+  0xeb48, 0xeb42, 0xeb56, 0xeb53, 0xeb50, 0xbfb9, 0xbfba, 0xbfbe,
+  0xeafa, 0xeb57, 0xbfbd, 0xeb4d, 0xeb4b, 0xeb4e, 0xee53, 0xee40,
+  0xee45, 0xee52, 0xee44, 0xedfb, 0xee41, 0xc1a2, 0xedf4, 0xee4d,
+  0xee4f, 0xedf3, 0xc1a1, 0xee51, 0xee49, 0xc1a8, 0xee50, 0xee42,
+  0xc1aa, 0xedf9, 0xeb52, 0xee4a, 0xee47, 0xedf5, 0xee55, 0xc1a4,
+  0xc1a5, 0xedf7, 0xee48, 0xee54, 0xee4b, 0xedfd, 0xc1a7, 0xc1a3,
+  0xee4c, 0xedfe, 0xee56, 0xedf8, 0xee43, 0xee4e, 0xedfa, 0xedfc,
+  0xc2cb, 0xedf6, 0xc1a9, 0xc2c4, 0xc17e, 0xc1a6, 0xc2c8, 0xf0b3,
+  0xf0a9, 0xf0a4, 0xf0aa, 0xf0b4, 0xf0b8, 0xf0b7, 0xc2ca, 0xc2c9,
+  0xf0ab, 0xf0b9, 0xf0ae, 0xf0a6, 0xf0a8, 0xf0a7, 0xf0ad, 0xf0b2,
+  0xf0a5, 0xf0ac, 0xf0b1, 0xc2c7, 0xf0af, 0xc2c5, 0xf0b0, 0xc2c3,
+  0xc2c6, 0xf2d5, 0xf0b5, 0xc3c2, 0xf2cd, 0xf2d1, 0xf2c9, 0xf2cc,
+  0xf2d4, 0xc3c0, 0xf2d9, 0xf2d2, 0xf2ca, 0xf2da, 0xf2d3, 0xc3c3,
+  0xc3c4, 0xf2d7, 0xf2cb, 0xc3bf, 0xc3c1, 0xf2c6, 0xf2ce, 0xf2c8,
+  0xf2d8, 0xf2d6, 0xf2c7, 0xf2cf, 0xf4be, 0xc3c5, 0xf2d0, 0xc4a7,
+  0xc4a9, 0xc4a6, 0xf4c3, 0xf4bb, 0xf4b9, 0xf4bd, 0xf4ba, 0xf4bf,
+  0xf4c1, 0xc4aa, 0xc4ac, 0xf4c0, 0xc4ad, 0xc4ab, 0xf4c2, 0xc4a8,
+  0xc4f4, 0xf5f1, 0xf5f7, 0xc4f6, 0xf4bc, 0xf5f6, 0xf5fd, 0xf5f4,
+  0xf5fb, 0xf5fa, 0xf4b8, 0xf5f5, 0xf0b6, 0xf5fe, 0xf5f3, 0xf5f8,
+  0xf5fc, 0xf5f2, 0xf74a, 0xc4f5, 0xf5f9, 0xf7f4, 0xf74b, 0xf749,
+  0xf747, 0xf748, 0xf74c, 0xc5d9, 0xf7f2, 0xf7f0, 0xf7f5, 0xf7f3,
+  0xf7f6, 0xc5da, 0xf7f1, 0xf8bc, 0xf945, 0xf946, 0xf947, 0xf9c7,
+  0xf9bd, 0xca4f, 0xaaea, 0xad68, 0xd3b8, 0xd3b7, 0xb040, 0xb342,
+  0xd77c, 0xd77b, 0xb5ea, 0xb8b8, 0xb8b7, 0xb8b9, 0xe3d4, 0xe77e,
+  0xeb58, 0xeb5a, 0xeb59, 0xc1ab, 0xee57, 0xf0ba, 0xf9a5, 0xa6e4,
+  0xcdc9, 0xcdca, 0xcdc8, 0xcdc7, 0xaaeb, 0xd0a9, 0xd0a7, 0xd0a6,
+  0xad69, 0xad6b, 0xad6a, 0xd0a8, 0xd3c4, 0xd3c1, 0xd3bf, 0xb041,
+  0xd3c2, 0xb046, 0xd3bc, 0xd3cb, 0xd3cd, 0xd3bd, 0xb043, 0xd3ce,
+  0xd3c9, 0xd3bb, 0xd3c0, 0xd3ca, 0xd3c6, 0xd3c3, 0xb048, 0xd3cc,
+  0xd3be, 0xd3c7, 0xd3b9, 0xb047, 0xb044, 0xd3c5, 0xd3c8, 0xd3ba,
+  0xb045, 0xb042, 0xb34c, 0xd7a5, 0xb34b, 0xd7a8, 0xd7ab, 0xb348,
+  0xb346, 0xd77e, 0xd7a9, 0xd7a7, 0xd7a4, 0xd7ac, 0xd7ad, 0xd7af,
+  0xd7b0, 0xd77d, 0xb345, 0xd7a2, 0xd7a1, 0xd7ae, 0xb347, 0xd7a3,
+  0xb349, 0xb344, 0xd7a6, 0xb34d, 0xb34a, 0xd7aa, 0xb5f1, 0xdbbf,
+  0xdbb4, 0xb5ee, 0xdfe7, 0xdbbd, 0xdbb1, 0xb5ec, 0xdbb6, 0xb5ef,
+  0xdbba, 0xdbb8, 0xb5f2, 0xb5eb, 0xdbb2, 0xdbb5, 0xb5f0, 0xdbb3,
+  0xdbbe, 0xdbbc, 0xdbb7, 0xdbb9, 0xdbbb, 0xb5ed, 0xdfe8, 0xdfee,
+  0xdfe4, 0xdfea, 0xb8ba, 0xdfe6, 0xb8c0, 0xb8bf, 0xb8be, 0xdfed,
+  0xb8c1, 0xb8c2, 0xdfe3, 0xdff0, 0xb8c3, 0xb8bd, 0xb8bc, 0xdfec,
+  0xb8c4, 0xdfe2, 0xdfe5, 0xdfef, 0xdfeb, 0xe3f4, 0xe3e9, 0xb8bb,
+  0xbb6a, 0xe3dd, 0xe3f2, 0xe3de, 0xbb65, 0xe3db, 0xe3e4, 0xe3dc,
+  0xbb67, 0xe3d6, 0xe3f1, 0xbb68, 0xe3ee, 0xe3ef, 0xe3d7, 0xbb6d,
+  0xe3e6, 0xe3e0, 0xe3e7, 0xe3da, 0xe3f3, 0xe3eb, 0xe3e5, 0xe3d5,
+  0xbb69, 0xe3ec, 0xbb6c, 0xe3f0, 0xe3ea, 0xbb66, 0xe3e8, 0xe3e2,
+  0xbb64, 0xe3d9, 0xe3e1, 0xe3ed, 0xe3df, 0xe3e3, 0xbdc1, 0xdfe9,
+  0xe7b2, 0xe7bb, 0xe7b1, 0xe7ad, 0xe7aa, 0xbdc2, 0xe7a8, 0xbb6b,
+  0xe7a1, 0xbdc0, 0xe7a7, 0xbdbf, 0xe7ac, 0xe7a9, 0xe7b9, 0xe7b4,
+  0xe7ae, 0xe7b3, 0xbdbb, 0xe7ab, 0xe7be, 0xe7a2, 0xe7a3, 0xe7ba,
+  0xbdbc, 0xe7bf, 0xbdbe, 0xe7c0, 0xe7b0, 0xe3d8, 0xe7b6, 0xe7af,
+  0xe7b8, 0xe7b5, 0xe7a6, 0xbdb9, 0xe7bd, 0xbdba, 0xe7a4, 0xbdbd,
+  0xeb64, 0xe7b7, 0xe7bc, 0xeb61, 0xbdb8, 0xbfc0, 0xeb6b, 0xeb67,
+  0xeb65, 0xeb60, 0xeb6f, 0xbfc4, 0xeb5c, 0xeb68, 0xeb69, 0xeb5f,
+  0xeb5e, 0xeb6c, 0xeb62, 0xeb5d, 0xeb63, 0xeb6e, 0xeb5b, 0xeb6d,
+  0xeb6a, 0xbfc2, 0xbfc1, 0xbfc3, 0xeb66, 0xf0cb, 0xee59, 0xc1b1,
+  0xee5d, 0xee5a, 0xee61, 0xee67, 0xee5c, 0xee70, 0xc1ae, 0xee6a,
+  0xee5f, 0xee6b, 0xee66, 0xee6d, 0xee5e, 0xc1b3, 0xc1b2, 0xee60,
+  0xee6e, 0xee58, 0xee6c, 0xc1ac, 0xee64, 0xee63, 0xee68, 0xee5b,
+  0xc1b0, 0xc1b4, 0xee62, 0xee69, 0xc1b5, 0xee65, 0xc1ad, 0xc1af,
+  0xf0c7, 0xf0c5, 0xf0cc, 0xf0c9, 0xf0cd, 0xf0be, 0xf0c6, 0xf0d1,
+  0xee6f, 0xf0c2, 0xc2cf, 0xe7a5, 0xf0bd, 0xf0ca, 0xf0c4, 0xf0c1,
+  0xf0bc, 0xf0bb, 0xf0d0, 0xf0c0, 0xf0bf, 0xc2cd, 0xf0c8, 0xc2cc,
+  0xc2ce, 0xf0c3, 0xf0cf, 0xf2de, 0xf2df, 0xc3c9, 0xf2dc, 0xc3c6,
+  0xf2e4, 0xc3ca, 0xf2e6, 0xf2db, 0xf0ce, 0xf2e8, 0xf2dd, 0xc3c7,
+  0xf2e3, 0xf2e5, 0xf2e0, 0xf2e7, 0xf2e2, 0xf2e1, 0xc3c8, 0xf4c5,
+  0xf4c6, 0xf4c8, 0xc4ae, 0xc4af, 0xf4c9, 0xf4c7, 0xf4c4, 0xf642,
+  0xf645, 0xf641, 0xc4fa, 0xf643, 0xc4f9, 0xc4f8, 0xc4f7, 0xf644,
+  0xf751, 0xf74f, 0xf74e, 0xf640, 0xf750, 0xf646, 0xf74d, 0xf7f9,
+  0xf7d7, 0xf7f7, 0xc5db, 0xf7f8, 0xf7fa, 0xf8bf, 0xc5fa, 0xf8be,
+  0xf8bd, 0xc5fb, 0xc65a, 0xf96e, 0xf9a7, 0xf9a6, 0xf9a8, 0xa6e5,
+  0xd0aa, 0xd3cf, 0xd3d0, 0xdbc0, 0xf647, 0xf8c0, 0xa6e6, 0xad6c,
+  0xd0ab, 0xd7b1, 0xb34e, 0xdbc2, 0xdbc1, 0xb5f3, 0xb8c5, 0xe7c1,
+  0xbdc3, 0xbdc4, 0xbfc5, 0xc5fc, 0xa6e7, 0xd0ac, 0xaaed, 0xd0ae,
+  0xd0ad, 0xad6d, 0xd3d1, 0xd3d8, 0xb049, 0xd3d6, 0xd3d4, 0xd3db,
+  0xd3d2, 0xd3d3, 0xb04a, 0xb04e, 0xd3dc, 0xb04d, 0xd3da, 0xd3d7,
+  0xd3d5, 0xb04b, 0xb04c, 0xd3d9, 0xb350, 0xd7b2, 0xb355, 0xd7c2,
+  0xb354, 0xd7c4, 0xd7b8, 0xb352, 0xd7c3, 0xd7b3, 0xb353, 0xd7bf,
+  0xd7bb, 0xd7bd, 0xd7b7, 0xd7be, 0xb34f, 0xd7ba, 0xd7b9, 0xd7b5,
+  0xd7c0, 0xd7bc, 0xd7b4, 0xd7b6, 0xb351, 0xd7c1, 0xb5f6, 0xdbcd,
+  0xdbc9, 0xdbcb, 0xdbc6, 0xdbc5, 0xdbc3, 0xdbca, 0xdbcc, 0xdbc8,
+  0xdbc7, 0xb5f4, 0xb5f5, 0xdbcf, 0xb8cd, 0xdff2, 0xdff8, 0xdff3,
+  0xdff4, 0xdff9, 0xb8cf, 0xb8c7, 0xb8ce, 0xdff1, 0xdbc4, 0xb8ca,
+  0xb8c8, 0xdff7, 0xdff6, 0xb8c9, 0xb8cb, 0xdff5, 0xb8c6, 0xb8cc,
+  0xe3f6, 0xbb74, 0xe442, 0xe441, 0xe3fb, 0xbb76, 0xe440, 0xe3f7,
+  0xe3f8, 0xbb6e, 0xbb70, 0xe3fd, 0xe3f5, 0xbb72, 0xbb71, 0xe3f9,
+  0xe3fe, 0xe3fc, 0xbb73, 0xe3fa, 0xdbce, 0xbb6f, 0xe7c2, 0xe7c9,
+  0xbdc6, 0xe7cd, 0xbdca, 0xe7c5, 0xe7c3, 0xe7cc, 0xbdc5, 0xe7cb,
+  0xbdc7, 0xbdc8, 0xe7c4, 0xbdc9, 0xe7ca, 0xe7c6, 0xe7c7, 0xe7c8,
+  0xbb75, 0xeb70, 0xeb7c, 0xbfca, 0xeb77, 0xeb79, 0xbfc8, 0xeb71,
+  0xeb75, 0xeb78, 0xbfc6, 0xbfc9, 0xeb7b, 0xeb73, 0xeb74, 0xeb7a,
+  0xeb72, 0xeb76, 0xbfc7, 0xee72, 0xee71, 0xc1b7, 0xee77, 0xc1b9,
+  0xc1b6, 0xee73, 0xc1ba, 0xee74, 0xee75, 0xee78, 0xc1b8, 0xf0d6,
+  0xf0d9, 0xf0d3, 0xf0d5, 0xf0d4, 0xf0d7, 0xf0d8, 0xee76, 0xf0d2,
+  0xc3cd, 0xf2ec, 0xf2ef, 0xf2f1, 0xf2ea, 0xf2eb, 0xf2ee, 0xf2f0,
+  0xc3ce, 0xc3cc, 0xc3cb, 0xf2ed, 0xf2e9, 0xf4ca, 0xc4b0, 0xf4cb,
+  0xf649, 0xc4fb, 0xf64b, 0xc4fc, 0xf648, 0xf64a, 0xc5a8, 0xf752,
+  0xc5a7, 0xf7fd, 0xf7fc, 0xf7fb, 0xf948, 0xf949, 0xf94b, 0xf94a,
+  0xca50, 0xa6e8, 0xad6e, 0xd7c5, 0xb5f7, 0xdffa, 0xc2d0, 0xf2f2,
+  0xa8a3, 0xb357, 0xb356, 0xdbd0, 0xb5f8, 0xdbd2, 0xdbd1, 0xdffb,
+  0xb8d0, 0xe443, 0xe446, 0xe445, 0xe444, 0xe7ce, 0xe7d0, 0xe7cf,
+  0xbfcc, 0xbfcb, 0xc1bb, 0xee79, 0xee7b, 0xee7a, 0xc2d1, 0xf2f4,
+  0xf2f3, 0xf4cc, 0xc4b1, 0xc4fd, 0xf754, 0xf753, 0xc65b, 0xa8a4,
+  0xd0af, 0xad6f, 0xd7c8, 0xd7c6, 0xd7c7, 0xdbd4, 0xdbd5, 0xe043,
+  0xdbd3, 0xdffc, 0xe041, 0xe040, 0xe042, 0xb8d1, 0xdffe, 0xdffd,
+  0xe044, 0xe449, 0xe447, 0xe448, 0xe7d3, 0xe7d1, 0xe7d2, 0xeb7d,
+  0xee7c, 0xee7d, 0xc2d2, 0xf2f5, 0xf4cd, 0xc4b2, 0xf64c, 0xf755,
+  0xc5a9, 0xf7fe, 0xf94c, 0xa8a5, 0xad71, 0xad72, 0xd0b0, 0xd0b1,
+  0xad70, 0xb054, 0xb052, 0xb051, 0xb058, 0xb050, 0xb059, 0xd3dd,
+  0xb056, 0xb053, 0xb057, 0xb055, 0xb04f, 0xb35f, 0xb359, 0xd7cc,
+  0xb35e, 0xb360, 0xb35a, 0xb35b, 0xd7ca, 0xb358, 0xd7cb, 0xb35d,
+  0xd7c9, 0xb35c, 0xb644, 0xb646, 0xdbd8, 0xb645, 0xb5f9, 0xb5fd,
+  0xb8e4, 0xe049, 0xdbda, 0xb5fe, 0xdbdd, 0xdbde, 0xb643, 0xdbe0,
+  0xdbe2, 0xdbe3, 0xdbd7, 0xdbd6, 0xdbe4, 0xb642, 0xdbe1, 0xdbdf,
+  0xb640, 0xb5fb, 0xb647, 0xdbdb, 0xdbdc, 0xdbd9, 0xb641, 0xb5fc,
+  0xb5fa, 0xe048, 0xb8df, 0xb8da, 0xb8d5, 0xb8e5, 0xb8d6, 0xb8d2,
+  0xb8e1, 0xb8de, 0xb8e0, 0xb8d7, 0xb8dc, 0xb8d3, 0xb8d4, 0xe050,
+  0xe04d, 0xe045, 0xe04a, 0xb8e2, 0xe051, 0xb8e3, 0xb8d9, 0xe047,
+  0xe04f, 0xe04b, 0xe04e, 0xe04c, 0xb8dd, 0xe046, 0xb8d8, 0xe44c,
+  0xbb78, 0xbb7b, 0xe44e, 0xbba5, 0xe44d, 0xbb7d, 0xbdcf, 0xe44f,
+  0xbba4, 0xe44b, 0xbba6, 0xbb79, 0xb8db, 0xbb7c, 0xbb7a, 0xbb7e,
+  0xbba2, 0xbb77, 0xbba7, 0xbba3, 0xbba1, 0xe44a, 0xbdd6, 0xbdd2,
+  0xbdd9, 0xe7d6, 0xbdda, 0xe7e2, 0xe7db, 0xbdcb, 0xe7e3, 0xe7dd,
+  0xbdd5, 0xe7de, 0xbdd4, 0xe7e1, 0xbdce, 0xe7df, 0xe7d5, 0xbdcd,
+  0xebaa, 0xbdd3, 0xbdd0, 0xbdd8, 0xe7d4, 0xe7d8, 0xbdcc, 0xe7d7,
+  0xe7d9, 0xe7da, 0xbdd7, 0xe7dc, 0xe7e0, 0xe7e4, 0xbddb, 0xbfd2,
+  0xeba5, 0xebab, 0xeba8, 0xeb7e, 0xebac, 0xeba1, 0xeba7, 0xbfcd,
+  0xbfd3, 0xebad, 0xbfcf, 0xbfd9, 0xbfd4, 0xebaf, 0xeba9, 0xbfd0,
+  0xeba2, 0xbfda, 0xeba3, 0xeba4, 0xbfdb, 0xbfd8, 0xbdd1, 0xbfce,
+  0xebb0, 0xbfdc, 0xbfd5, 0xebae, 0xbfd1, 0xbfd6, 0xbfd7, 0xc1c3,
+  0xeea4, 0xeead, 0xeeaa, 0xeeac, 0xc1c0, 0xeea5, 0xeeab, 0xc1bc,
+  0xeea7, 0xc1c4, 0xeea3, 0xeea8, 0xeeaf, 0xeba6, 0xeea9, 0xeea2,
+  0xc1bd, 0xeea1, 0xc1be, 0xeeb0, 0xc1bf, 0xeeae, 0xc1c2, 0xee7e,
+  0xc1c1, 0xeea6, 0xf0dc, 0xf0ea, 0xf0e5, 0xf0e7, 0xf0db, 0xc2d3,
+  0xf0da, 0xc2d6, 0xc2d5, 0xf0e9, 0xf0e1, 0xf0de, 0xf0e4, 0xf0dd,
+  0xf0df, 0xf0e8, 0xf0e6, 0xc2d4, 0xf0ed, 0xf0eb, 0xf0e2, 0xf0ec,
+  0xf0e3, 0xf2f9, 0xc3cf, 0xf341, 0xf64f, 0xc3d6, 0xf0e0, 0xf2f7,
+  0xc3d2, 0xf2f8, 0xf2fd, 0xc3d4, 0xc3d5, 0xf2f6, 0xf340, 0xf342,
+  0xf2fa, 0xf2fc, 0xf2fe, 0xf2fb, 0xf343, 0xc3d1, 0xc3d7, 0xc3d3,
+  0xc3d0, 0xf4d0, 0xc4b7, 0xf4ce, 0xf4d2, 0xf4d3, 0xc4b5, 0xf4d4,
+  0xf4d1, 0xf4cf, 0xc4b8, 0xc4b4, 0xf4d5, 0xc4b6, 0xc4b3, 0xc4fe,
+  0xc540, 0xf64e, 0xf64d, 0xf650, 0xf651, 0xc541, 0xf756, 0xf75b,
+  0xc5aa, 0xf758, 0xf757, 0xf75a, 0xf759, 0xf843, 0xc5dc, 0xf842,
+  0xf840, 0xf841, 0xc5fe, 0xc5fd, 0xf8c1, 0xf8c2, 0xc640, 0xf94d,
+  0xf94e, 0xc667, 0xc66d, 0xf9a9, 0xf9c8, 0xa8a6, 0xd7cd, 0xd7ce,
+  0xe052, 0xe450, 0xe7e5, 0xc1c6, 0xc1c5, 0xf0ee, 0xf344, 0xf844,
+  0xa8a7, 0xd3de, 0xb05a, 0xb361, 0xe054, 0xe053, 0xbddc, 0xe7e6,
+  0xbddd, 0xeeb1, 0xc2d7, 0xc676, 0xa8a8, 0xcdcb, 0xd3df, 0xb362,
+  0xd7cf, 0xd7d0, 0xdbe5, 0xb648, 0xb8e6, 0xe056, 0xe055, 0xe057,
+  0xe451, 0xe452, 0xbba8, 0xbfdd, 0xbdde, 0xbfde, 0xeeb5, 0xeeb2,
+  0xeeb4, 0xeeb3, 0xc1c7, 0xf0ef, 0xf346, 0xf345, 0xcba4, 0xb05c,
+  0xb05b, 0xd3e0, 0xd7d1, 0xdbe7, 0xdbe6, 0xb649, 0xe059, 0xe05a,
+  0xe058, 0xb8e8, 0xb8e7, 0xbbaa, 0xbba9, 0xe7e7, 0xebb3, 0xebb1,
+  0xebb2, 0xbfdf, 0xeeb7, 0xeeb6, 0xf0f2, 0xf0f1, 0xf0f0, 0xf347,
+  0xf9aa, 0xa8a9, 0xad73, 0xad74, 0xb05d, 0xb05e, 0xd3e2, 0xd3e1,
+  0xd7d2, 0xb368, 0xb366, 0xb363, 0xb367, 0xb365, 0xb364, 0xb64a,
+  0xdbea, 0xb8ed, 0xb64c, 0xb651, 0xdbec, 0xb653, 0xb652, 0xb655,
+  0xdbeb, 0xdbe8, 0xb64f, 0xb64b, 0xb64d, 0xdbe9, 0xb654, 0xb650,
+  0xb64e, 0xb8ef, 0xb8ee, 0xb8ec, 0xb8f0, 0xb8ea, 0xb8eb, 0xb8e9,
+  0xe05b, 0xe454, 0xbbac, 0xbbad, 0xbbab, 0xe453, 0xe455, 0xe7ea,
+  0xe7ec, 0xbde7, 0xe7ed, 0xbde0, 0xe7e9, 0xbddf, 0xbde9, 0xbde5,
+  0xbde6, 0xbde2, 0xe7e8, 0xbde1, 0xe7ee, 0xe7eb, 0xbde8, 0xbde3,
+  0xbde4, 0xebb5, 0xebb7, 0xebb6, 0xebb8, 0xbfe0, 0xebb4, 0xc1cb,
+  0xeeb8, 0xc1c8, 0xc1cc, 0xc1ca, 0xc1c9, 0xf0f3, 0xf0f6, 0xf0f5,
+  0xf0f4, 0xc2d8, 0xf348, 0xf349, 0xc3d8, 0xf34a, 0xc3d9, 0xc4ba,
+  0xc4b9, 0xf652, 0xc542, 0xf653, 0xf75c, 0xc5ab, 0xc5ac, 0xf845,
+  0xc642, 0xa8aa, 0xb36a, 0xb369, 0xe05c, 0xe05d, 0xbbae, 0xebb9,
+  0xbdea, 0xebba, 0xeeb9, 0xa8ab, 0xd0b2, 0xad76, 0xad75, 0xd3e3,
+  0xb05f, 0xd3e4, 0xd7d5, 0xd7d4, 0xd7d3, 0xdbee, 0xb658, 0xdbed,
+  0xb657, 0xdbef, 0xb656, 0xe05f, 0xe062, 0xe060, 0xe061, 0xe065,
+  0xe05e, 0xe066, 0xe063, 0xe064, 0xbbb0, 0xe456, 0xbbaf, 0xe7f2,
+  0xe7f0, 0xbdeb, 0xe7ef, 0xe7f1, 0xbdec, 0xebbb, 0xebbc, 0xc1cd,
+  0xf34c, 0xf34e, 0xf34b, 0xf34d, 0xf4d6, 0xf654, 0xf96f, 0xa8ac,
+  0xad77, 0xd3e5, 0xd3e7, 0xd3e6, 0xd7d8, 0xb36c, 0xd7d6, 0xb36b,
+  0xd7d9, 0xd7da, 0xd7d7, 0xdbfb, 0xb660, 0xdbf3, 0xdbf9, 0xb65b,
+  0xb65e, 0xdbf2, 0xb659, 0xdbf6, 0xe06c, 0xb65d, 0xdbf1, 0xdbf7,
+  0xdbf4, 0xdbfa, 0xdbf0, 0xdbf8, 0xb65c, 0xb65f, 0xdbf5, 0xb65a,
+  0xb8f2, 0xe068, 0xb8f1, 0xe06f, 0xe06e, 0xb8f8, 0xb8f9, 0xe070,
+  0xb8f3, 0xe06d, 0xb8f7, 0xe072, 0xe069, 0xe06b, 0xb8f4, 0xe067,
+  0xe06a, 0xe071, 0xb8f5, 0xe073, 0xb8f6, 0xbbb1, 0xe45b, 0xe461,
+  0xe459, 0xe462, 0xe458, 0xe45d, 0xe463, 0xe460, 0xe45f, 0xe45e,
+  0xe457, 0xe45c, 0xe45a, 0xbdf1, 0xbdee, 0xe7fb, 0xe841, 0xe843,
+  0xe840, 0xe7f8, 0xe7fa, 0xe845, 0xe842, 0xe7fc, 0xe846, 0xe7f9,
+  0xe844, 0xbdef, 0xbdf5, 0xbdf3, 0xe7f3, 0xbdf4, 0xbdf0, 0xe7f4,
+  0xe7f6, 0xe7f5, 0xe7fd, 0xe7fe, 0xbdf2, 0xbded, 0xe7f7, 0xebc6,
+  0xbfe2, 0xebbd, 0xbfe3, 0xbfe6, 0xebc2, 0xebbf, 0xbfe5, 0xebc3,
+  0xebc4, 0xebbe, 0xebc7, 0xebc0, 0xebc5, 0xbfe4, 0xbfe1, 0xebc1,
+  0xeebf, 0xc1d0, 0xc1ce, 0xc1d1, 0xc1cf, 0xeebe, 0xeebb, 0xeeba,
+  0xeebd, 0xeebc, 0xf145, 0xc2de, 0xf0fb, 0xf0fa, 0xc2d9, 0xf141,
+  0xf140, 0xf0f7, 0xf143, 0xf0fc, 0xc2dd, 0xf0f9, 0xf142, 0xf0f8,
+  0xc2da, 0xc2dc, 0xf0fd, 0xc2db, 0xf0fe, 0xf144, 0xf352, 0xc3de,
+  0xf34f, 0xf353, 0xc3db, 0xf351, 0xc3e0, 0xc3dd, 0xf350, 0xc3df,
+  0xf354, 0xc3da, 0xc4bc, 0xc4be, 0xf4d9, 0xc4bd, 0xf4d7, 0xc3dc,
+  0xf4d8, 0xc4bb, 0xc543, 0xc545, 0xf656, 0xc544, 0xf655, 0xf761,
+  0xc5ad, 0xf760, 0xc5ae, 0xf75e, 0xf75d, 0xf762, 0xf763, 0xf846,
+  0xf75f, 0xf8c6, 0xf8c3, 0xf8c4, 0xf8c5, 0xc65c, 0xf951, 0xf950,
+  0xf94f, 0xf970, 0xf9be, 0xf9ab, 0xc66e, 0xa8ad, 0xb060, 0xb8fa,
+  0xbdf6, 0xebc8, 0xc2df, 0xf355, 0xf9ac, 0xa8ae, 0xaaee, 0xad79,
+  0xad78, 0xb063, 0xd3e8, 0xb061, 0xd3e9, 0xb062, 0xd7df, 0xd7db,
+  0xb36d, 0xd7de, 0xd7dd, 0xd7dc, 0xb36e, 0xd7e0, 0xd7e1, 0xdc43,
+  0xdc41, 0xdc45, 0xdc46, 0xdc4c, 0xdc48, 0xdc4a, 0xdc42, 0xdbfc,
+  0xdc49, 0xdc4b, 0xdc44, 0xdc47, 0xdbfd, 0xb662, 0xdc40, 0xdbfe,
+  0xb661, 0xb663, 0xb8fd, 0xe075, 0xe077, 0xe076, 0xe07b, 0xb8fb,
+  0xe078, 0xe074, 0xe079, 0xe07a, 0xb8fc, 0xb8fe, 0xe07c, 0xe467,
+  0xe466, 0xe464, 0xe465, 0xbbb3, 0xbbb5, 0xbbb2, 0xbbb4, 0xe84d,
+  0xe84e, 0xe849, 0xe84a, 0xbdf8, 0xbdfd, 0xbdf7, 0xbdfe, 0xbdf9,
+  0xe84b, 0xe84c, 0xe848, 0xbe40, 0xbdfb, 0xbdfa, 0xbdfc, 0xe847,
+  0xebca, 0xbfe8, 0xebcc, 0xbfea, 0xebcf, 0xebcb, 0xebc9, 0xebce,
+  0xbfe9, 0xebcd, 0xbfe7, 0xc1d3, 0xc1d6, 0xeec1, 0xc1d4, 0xeec0,
+  0xc1d2, 0xc1d5, 0xf146, 0xf147, 0xf148, 0xc2e0, 0xf149, 0xc2e1,
+  0xc3e2, 0xf358, 0xf359, 0xf357, 0xf356, 0xf35a, 0xc3e1, 0xf4dd,
+  0xf4db, 0xf4dc, 0xf4de, 0xf4da, 0xf4df, 0xf658, 0xf659, 0xf657,
+  0xc546, 0xf764, 0xc5af, 0xf765, 0xf848, 0xf847, 0xa8af, 0xb664,
+  0xb940, 0xbbb6, 0xbfec, 0xbfeb, 0xc3e3, 0xc47c, 0xc547, 0xa8b0,
+  0xb064, 0xb941, 0xf35b, 0xcba6, 0xa8b1, 0xa8b4, 0xa8b3, 0xa8b2,
+  0xcba5, 0xcdcd, 0xcdcf, 0xaaef, 0xaaf1, 0xcdcc, 0xcdce, 0xaaf0,
+  0xcdd1, 0xcdd0, 0xcdd2, 0xd0b6, 0xd0b4, 0xad7c, 0xd0b3, 0xada3,
+  0xad7e, 0xad7b, 0xada4, 0xad7d, 0xada2, 0xada1, 0xd0b5, 0xad7a,
+  0xb06a, 0xd3eb, 0xd3f1, 0xb067, 0xb06e, 0xb069, 0xd3ee, 0xd3f0,
+  0xb06c, 0xd3ea, 0xd3ed, 0xb068, 0xb065, 0xd3ec, 0xb06b, 0xd3ef,
+  0xb06d, 0xb066, 0xd7e3, 0xd7e6, 0xb370, 0xb37a, 0xb376, 0xd7e4,
+  0xb37e, 0xb377, 0xb37c, 0xb372, 0xb36f, 0xb371, 0xb37d, 0xd7e5,
+  0xb375, 0xb378, 0xb374, 0xb379, 0xd7e7, 0xb37b, 0xb373, 0xd7e2,
+  0xdc4d, 0xb665, 0xdc4f, 0xb667, 0xb669, 0xdc4e, 0xb666, 0xb66a,
+  0xb668, 0xb947, 0xe0a3, 0xb94f, 0xe07e, 0xb950, 0xb945, 0xe0a1,
+  0xb94a, 0xe0a2, 0xb943, 0xb942, 0xb94d, 0xb94c, 0xb94b, 0xb949,
+  0xb94e, 0xe07d, 0xb944, 0xb946, 0xb948, 0xbbb8, 0xbbbb, 0xbbbf,
+  0xbbb9, 0xbbbe, 0xbbbc, 0xbbb7, 0xbbbd, 0xbbba, 0xe852, 0xbe43,
+  0xbe41, 0xe853, 0xbe44, 0xbe42, 0xe851, 0xe850, 0xbff0, 0xe84f,
+  0xbfee, 0xbfed, 0xebd0, 0xbe45, 0xbfef, 0xebd1, 0xbff2, 0xebd2,
+  0xbff1, 0xc1d8, 0xeec3, 0xc1d7, 0xc1dc, 0xc1da, 0xc1db, 0xc2e3,
+  0xc1d9, 0xeec2, 0xebd3, 0xc2e2, 0xc2e4, 0xc3e4, 0xc3e5, 0xf4e0,
+  0xc5de, 0xc5dd, 0xa8b6, 0xca55, 0xb06f, 0xca52, 0xca53, 0xca51,
+  0xca54, 0xcbaa, 0xcba7, 0xcbac, 0xcba8, 0xa8b7, 0xa8ba, 0xcba9,
+  0xa8b9, 0xcbab, 0xa8b8, 0xcdd5, 0xcdd7, 0xaaf4, 0xcdd3, 0xcdd6,
+  0xcdd4, 0xaaf2, 0xaaf5, 0xaaf3, 0xd0b8, 0xd0bc, 0xd0b9, 0xada7,
+  0xada8, 0xd0bb, 0xd0bd, 0xd0bf, 0xada5, 0xd0be, 0xada6, 0xd7ee,
+  0xd0ba, 0xd3f2, 0xd3fb, 0xd3f9, 0xd3f4, 0xd3f5, 0xd3fa, 0xd3fc,
+  0xb071, 0xd3f7, 0xd3f3, 0xb070, 0xb072, 0xd3f6, 0xd3fd, 0xd3f8,
+  0xb3a1, 0xd7f1, 0xd7e9, 0xd7ef, 0xd7f0, 0xb3a2, 0xd7e8, 0xd7ea,
+  0xd0b7, 0xd7ec, 0xd7ed, 0xd7eb, 0xb66c, 0xdc56, 0xebd4, 0xdc57,
+  0xdc54, 0xb3a3, 0xb66e, 0xdc53, 0xdc59, 0xdc58, 0xb66b, 0xdc5c,
+  0xdc52, 0xdc5b, 0xdc50, 0xdc5a, 0xdc55, 0xb66d, 0xe0aa, 0xe0a5,
+  0xe0ab, 0xe0a6, 0xe0a4, 0xe0a7, 0xb951, 0xe0a9, 0xe0a8, 0xb952,
+  0xbbc1, 0xbbc0, 0xe46e, 0xe471, 0xe469, 0xe46d, 0xbbc2, 0xe46c,
+  0xe46a, 0xe470, 0xe46b, 0xe468, 0xe46f, 0xe859, 0xbe48, 0xf14a,
+  0xe856, 0xe857, 0xe855, 0xdc51, 0xbe47, 0xe85a, 0xe854, 0xbe46,
+  0xbe49, 0xe858, 0xebd5, 0xbff3, 0xebd6, 0xebd7, 0xeec4, 0xc1dd,
+  0xf14b, 0xf14c, 0xf14d, 0xf35d, 0xf35c, 0xf4e2, 0xf4e1, 0xf65b,
+  0xf65c, 0xf65a, 0xf766, 0xc5b0, 0xa8bb, 0xadaa, 0xada9, 0xb075,
+  0xb074, 0xd440, 0xd441, 0xd3fe, 0xb073, 0xd7f5, 0xd7f6, 0xd7f2,
+  0xb3a4, 0xd7f3, 0xd7f4, 0xdc5f, 0xdc61, 0xdc5d, 0xdc60, 0xb66f,
+  0xdc5e, 0xb670, 0xdd73, 0xb955, 0xb954, 0xb953, 0xe0ac, 0xe0ad,
+  0xe473, 0xe475, 0xbbc6, 0xbbc3, 0xbbc5, 0xbbc4, 0xe474, 0xe472,
+  0xe861, 0xe85e, 0xe85f, 0xbe4d, 0xe860, 0xe85b, 0xe85c, 0xbe4a,
+  0xbe4b, 0xe85d, 0xbe4c, 0xebdb, 0xebdc, 0xebd9, 0xebda, 0xbff4,
+  0xebd8, 0xeec8, 0xeec5, 0xeec7, 0xc1e0, 0xeecb, 0xc1df, 0xeec9,
+  0xeecc, 0xeeca, 0xeec6, 0xc1de, 0xf14f, 0xf150, 0xf14e, 0xf152,
+  0xc2e5, 0xc2e6, 0xf35f, 0xc3e7, 0xf151, 0xf35e, 0xc3e6, 0xf4e5,
+  0xf4e6, 0xc4bf, 0xf4e4, 0xf4e3, 0xf65d, 0xc548, 0xf849, 0xf8c8,
+  0xf8c7, 0xc643, 0xc65d, 0xf8c9, 0xf971, 0xc66f, 0xa8bc, 0xaaf6,
+  0xb956, 0xc4c0, 0xa8bd, 0xadab, 0xb3a5, 0xb671, 0xc2e7, 0xaaf7,
+  0xd0c1, 0xd0c0, 0xd442, 0xb078, 0xb076, 0xb07a, 0xd444, 0xb079,
+  0xb077, 0xd443, 0xb3a8, 0xd7fc, 0xb3a7, 0xb3a9, 0xd842, 0xb3ab,
+  0xd7fe, 0xd840, 0xd7f7, 0xb3aa, 0xd843, 0xd7f9, 0xd7fa, 0xd7f8,
+  0xb3a6, 0xd841, 0xd7fb, 0xd7fd, 0xdc6d, 0xdc6c, 0xdc6a, 0xdc62,
+  0xdc71, 0xdc65, 0xdc6f, 0xdc76, 0xdc6e, 0xb679, 0xb675, 0xdc63,
+  0xdc69, 0xb677, 0xdc68, 0xb678, 0xb67a, 0xdc6b, 0xb672, 0xb673,
+  0xdc77, 0xdc75, 0xdc74, 0xdc66, 0xdc72, 0xb676, 0xb674, 0xdc73,
+  0xdc64, 0xdc67, 0xdc70, 0xe4ba, 0xe0b7, 0xe0b0, 0xe0c3, 0xe0cc,
+  0xe0b3, 0xb961, 0xe0c0, 0xb957, 0xb959, 0xb965, 0xe0b1, 0xb95a,
+  0xb95c, 0xb966, 0xb95b, 0xb964, 0xe0b9, 0xe0ae, 0xb962, 0xe0b8,
+  0xb95e, 0xe0ca, 0xb963, 0xe0c8, 0xe0bc, 0xe0c6, 0xb960, 0xe0af,
+  0xe0c9, 0xe0c4, 0xe0cb, 0xb958, 0xb967, 0xb95d, 0xe0b5, 0xe0bd,
+  0xe0c1, 0xe0c5, 0xb95f, 0xe0b4, 0xe0b2, 0xe0be, 0xe0bb, 0xe0ba,
+  0xe0bf, 0xe0c2, 0xe0c7, 0xe478, 0xbbc7, 0xe4a4, 0xe47a, 0xbbcc,
+  0xbbd0, 0xe4ad, 0xe4b5, 0xe4a6, 0xbbc8, 0xe4aa, 0xe0b6, 0xbbc9,
+  0xe4b1, 0xe4b6, 0xe4ae, 0xe4b0, 0xe4b9, 0xe4b2, 0xe47e, 0xe4a9,
+  0xbbd1, 0xbbcd, 0xe47c, 0xe4ab, 0xbbcb, 0xe4a5, 0xbbca, 0xe4b3,
+  0xe4a2, 0xe479, 0xbbce, 0xe4b8, 0xe47b, 0xe4af, 0xe4ac, 0xe4a7,
+  0xe477, 0xe476, 0xe4a1, 0xe4b4, 0xbbcf, 0xe4b7, 0xe47d, 0xe4a3,
+  0xbe52, 0xbe5a, 0xbe55, 0xe8a4, 0xe8a1, 0xe867, 0xbe50, 0xbe4f,
+  0xbe56, 0xe865, 0xbe54, 0xe871, 0xe863, 0xe864, 0xbe4e, 0xe8a3,
+  0xbe58, 0xe874, 0xe879, 0xe873, 0xebee, 0xe86f, 0xe877, 0xe875,
+  0xe868, 0xe862, 0xe87d, 0xbe57, 0xe87e, 0xe878, 0xe86d, 0xe86b,
+  0xe866, 0xe86e, 0xe87b, 0xe86a, 0xe87a, 0xe8a2, 0xbe53, 0xe876,
+  0xe87c, 0xe872, 0xe86c, 0xbe51, 0xe4a8, 0xe870, 0xbe59, 0xe869,
+  0xebf4, 0xbff7, 0xebf3, 0xebf0, 0xec44, 0xbffb, 0xec41, 0xebf8,
+  0xec43, 0xebe9, 0xebf6, 0xbffd, 0xebe1, 0xebdf, 0xec42, 0xec40,
+  0xebfe, 0xebed, 0xebec, 0xebe2, 0xc040, 0xebe8, 0xebf2, 0xebfd,
+  0xc043, 0xec45, 0xc1e8, 0xc045, 0xbffe, 0xebe6, 0xebef, 0xebde,
+  0xebe0, 0xbff5, 0xc042, 0xbffa, 0xebe7, 0xebf7, 0xebf1, 0xc041,
+  0xebdd, 0xc1e3, 0xebf9, 0xebfc, 0xbffc, 0xebeb, 0xc044, 0xbff9,
+  0xbff8, 0xebf5, 0xebfb, 0xbff6, 0xebe4, 0xebfa, 0xebe5, 0xebea,
+  0xeed2, 0xeed7, 0xc1e5, 0xc1e7, 0xeedd, 0xc1e1, 0xeeec, 0xeee3,
+  0xeed8, 0xeed9, 0xeee2, 0xc1ee, 0xeee1, 0xeed1, 0xeee0, 0xeed4,
+  0xeeed, 0xc1ed, 0xc1eb, 0xeed5, 0xeee8, 0xeeda, 0xeee7, 0xeee9,
+  0xeed0, 0xc1e6, 0xeeea, 0xeede, 0xc1ea, 0xeedb, 0xc1ec, 0xeee4,
+  0xc1e4, 0xeed6, 0xeee5, 0xeedf, 0xebe3, 0xeee6, 0xeed3, 0xc1e9,
+  0xeeeb, 0xc1e2, 0xeece, 0xf160, 0xf159, 0xc2e9, 0xf154, 0xf163,
+  0xf15b, 0xeedc, 0xf165, 0xf155, 0xc2e8, 0xf15f, 0xc2ea, 0xc2f2,
+  0xc2f0, 0xf161, 0xc2f1, 0xf157, 0xf158, 0xf15d, 0xf162, 0xeecd,
+  0xc2eb, 0xf16a, 0xf167, 0xf16b, 0xf15e, 0xf15a, 0xf168, 0xf36a,
+  0xf15c, 0xc2ee, 0xc2ed, 0xeecf, 0xc2ef, 0xf164, 0xf166, 0xc2ec,
+  0xf169, 0xf153, 0xf156, 0xf373, 0xf363, 0xc3eb, 0xf371, 0xf361,
+  0xc3ec, 0xf36c, 0xf368, 0xc3f1, 0xf372, 0xf362, 0xf365, 0xc3e9,
+  0xf374, 0xf36d, 0xf370, 0xc3ef, 0xc3f4, 0xc3f2, 0xf369, 0xf364,
+  0xc3ed, 0xc3ee, 0xf360, 0xc3ea, 0xc3e8, 0xc3f0, 0xf36f, 0xc3f3,
+  0xf36b, 0xf375, 0xc3f5, 0xf367, 0xf36e, 0xf4f3, 0xf542, 0xf4f5,
+  0xf4fc, 0xf366, 0xf4fa, 0xf4e9, 0xf540, 0xc4c3, 0xf4ed, 0xf4fe,
+  0xf4f4, 0xc4c2, 0xf544, 0xf4f6, 0xf4fb, 0xf4fd, 0xf4e7, 0xf541,
+  0xf4f2, 0xf4f7, 0xf4eb, 0xf4ef, 0xf543, 0xf4f9, 0xf4e8, 0xf4ec,
+  0xf4ee, 0xf4f8, 0xc4c1, 0xf4f1, 0xf4ea, 0xf4f0, 0xf661, 0xf666,
+  0xc54f, 0xf668, 0xc549, 0xf664, 0xf66a, 0xc54e, 0xc54a, 0xc54b,
+  0xf660, 0xf667, 0xc54d, 0xf665, 0xc54c, 0xf65f, 0xf663, 0xf662,
+  0xf65e, 0xf669, 0xc5b1, 0xf76d, 0xf770, 0xf76c, 0xf76e, 0xf76f,
+  0xf769, 0xf76a, 0xf767, 0xf76b, 0xf768, 0xc5b2, 0xc5b3, 0xf84b,
+  0xf84d, 0xf84c, 0xf84e, 0xc5e0, 0xf84a, 0xc5df, 0xc5e1, 0xf8cb,
+  0xf8cc, 0xc644, 0xf8ca, 0xf953, 0xf952, 0xf954, 0xc65f, 0xf955,
+  0xc65e, 0xf956, 0xf972, 0xf975, 0xf974, 0xc668, 0xf973, 0xc672,
+  0xc670, 0xc671, 0xc677, 0xf9c0, 0xf9c1, 0xf9bf, 0xf9c9, 0xaaf8,
+  0xd844, 0xdc78, 0xe8a5, 0xf376, 0xaaf9, 0xadac, 0xb07b, 0xd845,
+  0xd846, 0xb3ac, 0xb67d, 0xdc7a, 0xdc79, 0xb6a3, 0xb67c, 0xdc7b,
+  0xb67e, 0xb6a2, 0xb6a1, 0xb67b, 0xb968, 0xe0d0, 0xe0ce, 0xe0cf,
+  0xe0cd, 0xbbd2, 0xbbd5, 0xbbd7, 0xbbd6, 0xbbd3, 0xbbd4, 0xe8a7,
+  0xe8a6, 0xbe5b, 0xe8a8, 0xe8a9, 0xbe5c, 0xec4d, 0xec4b, 0xeef3,
+  0xec49, 0xec4a, 0xc046, 0xec46, 0xec4e, 0xec48, 0xec4c, 0xeeef,
+  0xeef1, 0xeef2, 0xc1f3, 0xeeee, 0xc1f2, 0xeef0, 0xc1ef, 0xc1f0,
+  0xc1f1, 0xec47, 0xc2f5, 0xf16e, 0xf16c, 0xf16d, 0xc2f3, 0xc2f6,
+  0xc2f4, 0xf377, 0xf378, 0xc3f6, 0xf545, 0xf547, 0xf546, 0xc4c4,
+  0xc550, 0xf66d, 0xf66c, 0xf66b, 0xaafa, 0xc9aa, 0xca58, 0xa6e9,
+  0xca56, 0xca59, 0xca57, 0xcbae, 0xa8c1, 0xa8c2, 0xcbb0, 0xa8bf,
+  0xcbaf, 0xcbad, 0xa8c0, 0xa8be, 0xcdd8, 0xcddb, 0xaafd, 0xcdda,
+  0xcdd9, 0xaafc, 0xaafb, 0xab40, 0xcddc, 0xaafe, 0xd0c6, 0xadae,
+  0xadaf, 0xadb0, 0xd0c7, 0xd0c3, 0xadad, 0xd0c4, 0xd0c5, 0xd0c2,
+  0xb0a4, 0xb0a1, 0xd445, 0xb0a2, 0xb0a5, 0xd446, 0xb07e, 0xb07c,
+  0xb07d, 0xb0a3, 0xb3ad, 0xd849, 0xb3b5, 0xd848, 0xd84b, 0xb3b1,
+  0xd84a, 0xb6ab, 0xb3af, 0xb3b2, 0xb3ae, 0xb3b3, 0xb3b4, 0xb3b0,
+  0xd847, 0xb6a7, 0xdc7d, 0xdca3, 0xdca2, 0xb6ac, 0xb6a8, 0xb6a9,
+  0xdc7c, 0xdc7e, 0xdca1, 0xb6a4, 0xb6a6, 0xb6aa, 0xb6a5, 0xe0d3,
+  0xe0d1, 0xe0d2, 0xb96a, 0xb96b, 0xe0d4, 0xb969, 0xbbd8, 0xbbda,
+  0xbbd9, 0xe4bb, 0xe4bc, 0xe8ab, 0xe8aa, 0xc047, 0xc048, 0xec4f,
+  0xc049, 0xeef6, 0xeef4, 0xeef5, 0xc1f4, 0xf16f, 0xc3f7, 0xc1f5,
+  0xab41, 0xb0a6, 0xd447, 0xd84c, 0xb3b6, 0xb6ad, 0xdca4, 0xdca6,
+  0xb6af, 0xb6ae, 0xb6b0, 0xb6b1, 0xdca5, 0xb96e, 0xb96f, 0xb96d,
+  0xbbdb, 0xb96c, 0xe0d5, 0xbbdc, 0xe8ac, 0xec50, 0xc04a, 0xc1f6,
+  0xf170, 0xf174, 0xc2f9, 0xf171, 0xc2fa, 0xc2f8, 0xf175, 0xc2fb,
+  0xf173, 0xf379, 0xc2f7, 0xc3f8, 0xf8cd, 0xab42, 0xb3b8, 0xb3b7,
+  0xb6b2, 0xdca8, 0xdca7, 0xb6b3, 0xe0d9, 0xb973, 0xb970, 0xe0d8,
+  0xb972, 0xe0d6, 0xb971, 0xe0d7, 0xe4bd, 0xbbdd, 0xe8af, 0xbe5d,
+  0xe8ad, 0xbe5e, 0xbe5f, 0xe8ae, 0xbe60, 0xec51, 0xc04e, 0xc04b,
+  0xc050, 0xec53, 0xc04c, 0xec52, 0xc04f, 0xc04d, 0xeef9, 0xeefb,
+  0xc1f7, 0xeefa, 0xc1f8, 0xeef8, 0xeef7, 0xf177, 0xf176, 0xc2fc,
+  0xf178, 0xf37e, 0xc3fa, 0xf37d, 0xf37a, 0xc3f9, 0xf37b, 0xf37c,
+  0xf548, 0xf549, 0xc4c5, 0xc553, 0xf66e, 0xc551, 0xc552, 0xf66f,
+  0xc5b4, 0xc5b5, 0xf771, 0xc645, 0xf8cf, 0xc647, 0xf8ce, 0xf8d0,
+  0xc646, 0xf957, 0xf9ad, 0xab43, 0xb974, 0xe4be, 0xe8b0, 0xc051,
+  0xc052, 0xab44, 0xbe61, 0xc3fb, 0xadb1, 0xc053, 0xc5e2, 0xadb2,
+  0xd84d, 0xdca9, 0xdcab, 0xdcaa, 0xe0dd, 0xe0da, 0xb975, 0xb976,
+  0xe0db, 0xe0dc, 0xe4c0, 0xe4c5, 0xbbde, 0xe4bf, 0xe4c1, 0xe4c8,
+  0xe4c3, 0xe4c7, 0xe4c4, 0xe4c2, 0xe4c6, 0xbbdf, 0xe8b3, 0xe8b1,
+  0xbe63, 0xbe62, 0xe8b2, 0xbe64, 0xec56, 0xec55, 0xc054, 0xec54,
+  0xeefc, 0xeefe, 0xef41, 0xef40, 0xc1f9, 0xeefd, 0xf1a1, 0xc2fd,
+  0xf17d, 0xf1a2, 0xc2fe, 0xf17b, 0xf17e, 0xf17c, 0xf179, 0xc340,
+  0xf17a, 0xf3a1, 0xf3a3, 0xf3a2, 0xf54a, 0xf54b, 0xf670, 0xc5b7,
+  0xc5b6, 0xf84f, 0xf850, 0xc648, 0xf8d1, 0xc669, 0xadb3, 0xb6b4,
+  0xe4ca, 0xe4c9, 0xe8b5, 0xe8b4, 0xc1fa, 0xef43, 0xef42, 0xf1a5,
+  0xf1a3, 0xf1a6, 0xf1a4, 0xc3fc, 0xf3a4, 0xf3a5, 0xf3a6, 0xf671,
+  0xf772, 0xf8d2, 0xadb4, 0xec57, 0xef44, 0xadb5, 0xbbe0, 0xec58,
+  0xc341, 0xf1a7, 0xc3fd, 0xf54c, 0xf54d, 0xc554, 0xf851, 0xadb6,
+  0xb3bb, 0xb3bc, 0xd84e, 0xb6b5, 0xb6b6, 0xdcac, 0xb6b7, 0xb97a,
+  0xb97c, 0xe0df, 0xe0e0, 0xe0de, 0xb977, 0xb978, 0xb97b, 0xb979,
+  0xe4cb, 0xbbe1, 0xbbe2, 0xe8bc, 0xbe67, 0xe8b7, 0xe8b6, 0xe8bb,
+  0xbe65, 0xc05b, 0xe8b8, 0xe8bd, 0xe8ba, 0xe8b9, 0xbe66, 0xc059,
+  0xec5a, 0xc055, 0xec5b, 0xec59, 0xc058, 0xc056, 0xc05a, 0xc057,
+  0xef45, 0xef4a, 0xef46, 0xef49, 0xc1fb, 0xedd4, 0xef48, 0xef47,
+  0xc344, 0xc342, 0xc345, 0xc343, 0xf1a8, 0xf1a9, 0xf1aa, 0xc346,
+  0xf3aa, 0xc440, 0xf3a8, 0xc441, 0xf3a7, 0xf3a9, 0xc3fe, 0xf551,
+  0xf54e, 0xf54f, 0xf550, 0xf672, 0xc556, 0xc555, 0xf774, 0xf773,
+  0xc5b8, 0xc5e3, 0xc649, 0xc660, 0xf958, 0xf9ae, 0xf9af, 0xadb7,
+  0xdcad, 0xe0e1, 0xe4cc, 0xe4cd, 0xbbe3, 0xbbe4, 0xe8be, 0xbe68,
+  0xc1fc, 0xf1ab, 0xc347, 0xf3ad, 0xc442, 0xf3ac, 0xf3ae, 0xf3ab,
+  0xf675, 0xf552, 0xf553, 0xc4c6, 0xf674, 0xf673, 0xf775, 0xf9b0,
+  0xadb8, 0xadb9, 0xb0a7, 0xd448, 0xd84f, 0xb6b8, 0xb6bb, 0xb6b9,
+  0xdcae, 0xb6bd, 0xb6ba, 0xb6bc, 0xb97e, 0xe0e2, 0xe0e3, 0xe8c0,
+  0xb97d, 0xb9a1, 0xb9a2, 0xe4cf, 0xe4ce, 0xbbe5, 0xbbe6, 0xe4d0,
+  0xe8bf, 0xbbe8, 0xbe69, 0xbbe7, 0xc05c, 0xe8c1, 0xbe6b, 0xbe6a,
+  0xe8c2, 0xe8c5, 0xe8c3, 0xe8c4, 0xbe6c, 0xc061, 0xc05f, 0xc05e,
+  0xec5d, 0xc060, 0xec5c, 0xef4b, 0xec5e, 0xc05d, 0xec5f, 0xef4e,
+  0xef4c, 0xef4d, 0xef52, 0xc34b, 0xef51, 0xef54, 0xef53, 0xef50,
+  0xef4f, 0xc1fd, 0xf1ae, 0xf1ad, 0xc34a, 0xc348, 0xc349, 0xf1ac,
+  0xf3b1, 0xc443, 0xf3b0, 0xf3af, 0xc444, 0xf558, 0xf557, 0xf555,
+  0xf554, 0xc4c8, 0xc4c7, 0xf559, 0xf776, 0xc5b9, 0xf677, 0xc557,
+  0xf676, 0xf556, 0xf777, 0xc5e4, 0xc661, 0xf959, 0xf9b1, 0xadba,
+  0xd850, 0xef55, 0xadbb, 0xe4d2, 0xe4d1, 0xec60, 0xef57, 0xef56,
+  0xc34c, 0xf3b2, 0xf3b3, 0xc4c9, 0xf9b2, 0xb0a8, 0xb6bf, 0xb6be,
+  0xe0e4, 0xe0e6, 0xb9a4, 0xe0e5, 0xb9a3, 0xb9a5, 0xe0e7, 0xe4d4,
+  0xe4d6, 0xe4d5, 0xe4d8, 0xbbe9, 0xe4d7, 0xe4d3, 0xe4d9, 0xe8cc,
+  0xe8cf, 0xe8d1, 0xe8c7, 0xe8cb, 0xe8c8, 0xbe6e, 0xbe71, 0xbe73,
+  0xe8c9, 0xe8ca, 0xbe72, 0xe8cd, 0xe8d0, 0xe8ce, 0xbe74, 0xbe70,
+  0xe8c6, 0xbe6d, 0xbe6f, 0xc063, 0xec66, 0xec64, 0xec63, 0xec69,
+  0xec68, 0xec67, 0xec62, 0xc062, 0xec61, 0xec65, 0xc064, 0xef5a,
+  0xef5e, 0xef5b, 0xef5d, 0xef5c, 0xef59, 0xef5f, 0xef62, 0xef60,
+  0xef61, 0xc240, 0xc1fe, 0xef58, 0xef63, 0xf1b3, 0xf1b6, 0xf1b8,
+  0xf1b7, 0xf1b1, 0xf1b5, 0xf1b0, 0xf1b2, 0xc34d, 0xf1af, 0xf1b4,
+  0xf3c0, 0xf3b5, 0xc445, 0xc446, 0xf3b4, 0xf3b9, 0xf3bf, 0xf3b7,
+  0xf3be, 0xf3bb, 0xf3ba, 0xf3bd, 0xf3b8, 0xf3b6, 0xf3bc, 0xf560,
+  0xf55e, 0xc4ca, 0xf55d, 0xf563, 0xf561, 0xc4cb, 0xf55c, 0xf55a,
+  0xf55b, 0xc4cd, 0xf55f, 0xc4cc, 0xf562, 0xf678, 0xf67e, 0xf679,
+  0xc55b, 0xf6a1, 0xc55a, 0xf67d, 0xf67c, 0xc559, 0xf67b, 0xc558,
+  0xf67a, 0xf77d, 0xf7a1, 0xf77e, 0xf77b, 0xc5bb, 0xf778, 0xf77c,
+  0xf7a3, 0xf7a2, 0xf779, 0xf77a, 0xc5ba, 0xf852, 0xc5e7, 0xf853,
+  0xc5e5, 0xc5e6, 0xf8d3, 0xc64a, 0xf976, 0xc66a, 0xf9b3, 0xc66b,
+  0xf9b4, 0xf9b5, 0xf9c3, 0xf9c2, 0xc67a, 0xf9cd, 0xb0a9, 0xe0e9,
+  0xe0e8, 0xbbea, 0xbbeb, 0xe4da, 0xe8d2, 0xec6c, 0xbe75, 0xc065,
+  0xec6a, 0xec6d, 0xc066, 0xef64, 0xec6b, 0xf1b9, 0xc34e, 0xf3c1,
+  0xf566, 0xf564, 0xf565, 0xf6a2, 0xc55c, 0xf7a4, 0xc5ea, 0xc5bc,
+  0xc5e8, 0xc5e9, 0xf8d4, 0xc662, 0xb0aa, 0xf1ba, 0xd449, 0xb9a6,
+  0xe4db, 0xbbec, 0xe4dc, 0xe8d4, 0xe8d3, 0xc068, 0xbe76, 0xbe77,
+  0xe8d7, 0xe8d6, 0xe8d5, 0xec6e, 0xec71, 0xec70, 0xec6f, 0xc067,
+  0xef68, 0xef66, 0xef65, 0xef67, 0xc34f, 0xf1bc, 0xf1bd, 0xc350,
+  0xf1bb, 0xf3c3, 0xf3c2, 0xf3c5, 0xc447, 0xf3c4, 0xf567, 0xf569,
+  0xf568, 0xf6a3, 0xf6a6, 0xf6a4, 0xf6a5, 0xf7a5, 0xc5bd, 0xf854,
+  0xf855, 0xf856, 0xc64b, 0xc663, 0xf9b6, 0xb0ab, 0xbe78, 0xc069,
+  0xf1be, 0xf7a6, 0xf9c4, 0xd44a, 0xc67b, 0xb0ac, 0xec72, 0xf1bf,
+  0xf3c6, 0xf6a7, 0xf7a7, 0xb0ad, 0xe4dd, 0xe4de, 0xbbed, 0xbbee,
+  0xe8d9, 0xbe7a, 0xbe79, 0xe8d8, 0xef69, 0xf1c0, 0xf1c2, 0xf1c1,
+  0xc353, 0xc352, 0xc351, 0xc55e, 0xf6a8, 0xc55d, 0xf7a9, 0xf7a8,
+  0xc64c, 0xf8d5, 0xb3bd, 0xe0ea, 0xe4e1, 0xe4df, 0xe4e0, 0xe8e2,
+  0xe8dd, 0xe8da, 0xe8e1, 0xe8e3, 0xbe7c, 0xe8e0, 0xe8dc, 0xe8db,
+  0xe8df, 0xe8de, 0xbe7b, 0xec7d, 0xec78, 0xec76, 0xeca1, 0xec77,
+  0xec73, 0xec79, 0xec74, 0xef72, 0xec75, 0xeca2, 0xec7c, 0xc06a,
+  0xec7b, 0xec7a, 0xec7e, 0xef6a, 0xef6d, 0xef6c, 0xef74, 0xef6f,
+  0xef73, 0xef71, 0xef70, 0xef6e, 0xef6b, 0xc243, 0xc242, 0xc244,
+  0xc241, 0xef75, 0xf1c8, 0xf1cb, 0xf1c9, 0xf1cd, 0xf1ce, 0xf1c6,
+  0xc358, 0xf1c7, 0xf1c5, 0xf1cc, 0xf1c4, 0xf1c3, 0xc357, 0xc355,
+  0xc354, 0xf1ca, 0xf3cf, 0xf3d5, 0xc44a, 0xf3d0, 0xf3d3, 0xf3d7,
+  0xc44b, 0xf3d2, 0xf3ca, 0xf3c9, 0xf3d6, 0xf3cd, 0xf3cb, 0xf3d4,
+  0xf3cc, 0xc449, 0xc448, 0xf3c7, 0xf3c8, 0xf3d1, 0xf3ce, 0xf56c,
+  0xf56f, 0xc356, 0xf56d, 0xf573, 0xf571, 0xf56b, 0xf576, 0xf56a,
+  0xc4cf, 0xf572, 0xf56e, 0xc4ce, 0xf575, 0xf574, 0xf6ab, 0xf6aa,
+  0xf6b1, 0xf6ad, 0xf6b0, 0xc560, 0xf6ae, 0xf6af, 0xf6a9, 0xf6ac,
+  0xc55f, 0xc5bf, 0xf7b4, 0xf7af, 0xf7b3, 0xf7b6, 0xf7b2, 0xf7ae,
+  0xc5c1, 0xf7b1, 0xf7b5, 0xc5c0, 0xf7ac, 0xf570, 0xf7b0, 0xf7ad,
+  0xf7aa, 0xf7ab, 0xc5be, 0xf85a, 0xf85c, 0xf85f, 0xf85b, 0xf860,
+  0xf859, 0xf857, 0xc5eb, 0xf85d, 0xc5ed, 0xc5ec, 0xf858, 0xf85e,
+  0xf8da, 0xc64d, 0xf8db, 0xf8d9, 0xf8d6, 0xf8d8, 0xf8d7, 0xf95a,
+  0xf95c, 0xf95b, 0xf979, 0xf978, 0xf977, 0xf97a, 0xc673, 0xc674,
+  0xf9ca, 0xf9ce, 0xb3be, 0xdcaf, 0xe0ed, 0xb9a7, 0xe0eb, 0xe0ec,
+  0xe4e2, 0xe4e3, 0xbbf1, 0xbbef, 0xe4e4, 0xbbf0, 0xe8e8, 0xe8eb,
+  0xe8e5, 0xe8ec, 0xe8e4, 0xe8e6, 0xe8e7, 0xe8ea, 0xbea1, 0xe8ef,
+  0xe8ee, 0xbe7d, 0xe8e9, 0xe8ed, 0xbe7e, 0xecac, 0xc06f, 0xeca7,
+  0xc06b, 0xeca4, 0xecaa, 0xecad, 0xc070, 0xeca9, 0xeca6, 0xecae,
+  0xeca5, 0xecab, 0xc06c, 0xeca3, 0xc06d, 0xc06e, 0xeca8, 0xefa9,
+  0xef7a, 0xef7b, 0xef7e, 0xef7c, 0xef76, 0xef79, 0xefa5, 0xef7d,
+  0xc245, 0xefa7, 0xefa4, 0xc246, 0xefa6, 0xef77, 0xefa2, 0xefa3,
+  0xefa1, 0xf1d2, 0xf1d4, 0xf1d7, 0xf1d1, 0xc359, 0xf1d9, 0xf1d0,
+  0xf1da, 0xf1d6, 0xf1d8, 0xf1dc, 0xf1d5, 0xf1dd, 0xf1d3, 0xf1cf,
+  0xc35a, 0xf1db, 0xc35b, 0xc44d, 0xef78, 0xf3f1, 0xf3e8, 0xc44f,
+  0xf3e4, 0xc450, 0xf3ed, 0xf3e7, 0xf3dd, 0xc44e, 0xf3ea, 0xf3e5,
+  0xf3e6, 0xf3d8, 0xf3df, 0xf3ee, 0xf3eb, 0xf3e3, 0xf3ef, 0xf3de,
+  0xf3d9, 0xf3ec, 0xf3db, 0xf3e9, 0xf3e0, 0xf3f0, 0xf3dc, 0xc44c,
+  0xf3da, 0xf3e1, 0xf3e2, 0xf57d, 0xf57b, 0xf5a2, 0xf5ae, 0xf5a5,
+  0xf57c, 0xf578, 0xf5a7, 0xf57e, 0xf5a3, 0xf57a, 0xf5aa, 0xf577,
+  0xf5a1, 0xf5a6, 0xf5a8, 0xf5ab, 0xf579, 0xf5af, 0xf5b0, 0xf5a9,
+  0xf5ad, 0xf5a4, 0xf6c1, 0xf6c4, 0xc561, 0xf6c3, 0xf6c8, 0xf6c6,
+  0xc562, 0xf6bd, 0xf6b3, 0xf6b2, 0xc564, 0xf6bf, 0xf6c0, 0xf6bc,
+  0xf6b4, 0xf6b9, 0xf5ac, 0xf6b5, 0xc563, 0xf6bb, 0xf6ba, 0xf6b6,
+  0xf6c2, 0xf6b7, 0xf7bb, 0xf6c5, 0xf6c7, 0xf6be, 0xf6b8, 0xf7bc,
+  0xf7be, 0xf7b8, 0xc5c2, 0xf7c5, 0xf7c3, 0xc5c3, 0xf7c2, 0xf7c1,
+  0xf7ba, 0xf7b7, 0xf7bd, 0xf7c6, 0xf7b9, 0xf7bf, 0xf869, 0xf86e,
+  0xf864, 0xf867, 0xc5ee, 0xf86b, 0xf872, 0xf7c0, 0xf865, 0xf86f,
+  0xf873, 0xf86a, 0xf863, 0xf86d, 0xf86c, 0xf871, 0xf870, 0xf7c4,
+  0xf868, 0xf862, 0xf866, 0xc64e, 0xc64f, 0xf861, 0xf8e6, 0xf8dd,
+  0xf8e5, 0xf8e2, 0xf8e3, 0xf8dc, 0xf8df, 0xf8e7, 0xf8e1, 0xf8e0,
+  0xf8de, 0xf8e4, 0xf95d, 0xf95e, 0xf960, 0xf95f, 0xf962, 0xf961,
+  0xf97c, 0xf97b, 0xf9b7, 0xf9b8, 0xf9c5, 0xc678, 0xc67c, 0xf9cf,
+  0xc67d, 0xb3bf, 0xc4d0, 0xf6c9, 0xc650, 0xc651, 0xb3c0, 0xe0ee,
+  0xb9a8, 0xe8f0, 0xecb0, 0xecb1, 0xecaf, 0xefab, 0xefaa, 0xc247,
+  0xf1df, 0xefac, 0xf1de, 0xf3f3, 0xc451, 0xc453, 0xf3f2, 0xc452,
+  0xf5b1, 0xf5b3, 0xf5b2, 0xf6ca, 0xc565, 0xc5ef, 0xf8e8, 0xf963,
+  0xf9d2, 0xb3c1, 0xe4e5, 0xbea2, 0xecb3, 0xecb2, 0xefad, 0xc454,
+  0xc4d1, 0xf7c7, 0xf9cb, 0xb3c2, 0xbbf2, 0xbea3, 0xf3f4, 0xf874,
+  0xb6c0, 0xefae, 0xc664, 0xb6c1, 0xbea4, 0xc248, 0xf875, 0xb6c2,
+  0xe8f1, 0xc072, 0xecb4, 0xecb5, 0xc071, 0xefaf, 0xc24c, 0xc24a,
+  0xc24b, 0xc249, 0xf1e0, 0xc35c, 0xf5b5, 0xf5b4, 0xf5b7, 0xf5b6,
+  0xc4d2, 0xf6cb, 0xf6cd, 0xf6cc, 0xc566, 0xf7c8, 0xf876, 0xf877,
+  0xc5f0, 0xf964, 0xf97d, 0xc675, 0xdcb0, 0xecb6, 0xefb0, 0xf3f5,
+  0xe0ef, 0xefb1, 0xf1e2, 0xf1e1, 0xf878, 0xc652, 0xf965, 0xf97e,
+  0xb9a9, 0xe8f2, 0xe8f3, 0xecb7, 0xb9aa, 0xc35d, 0xf1e3, 0xf6cf,
+  0xc567, 0xf6d0, 0xf6ce, 0xf879, 0xf8e9, 0xb9ab, 0xefb4, 0xefb3,
+  0xefb2, 0xf1e4, 0xf1e8, 0xf1e7, 0xf1e6, 0xf1e5, 0xc35e, 0xf3f6,
+  0xf5b9, 0xc4d3, 0xf5b8, 0xf6d1, 0xf7cb, 0xf7ca, 0xc5c4, 0xf7c9,
+  0xf87c, 0xf87b, 0xf87a, 0xbbf3, 0xecb8, 0xc24d, 0xf3f7, 0xf3f8,
+  0xf7cc, 0xf87d, 0xf8ea, 0xf966, 0xf9b9, 0xf9d4, 0xbbf4, 0xc24e,
+  0xf1e9, 0xf3f9, 0xf6d2, 0xf87e, 0xbea6, 0xefb5, 0xf1ea, 0xf3fa,
+  0xf3fb, 0xf3fc, 0xf5be, 0xf5ba, 0xc568, 0xf5bd, 0xf5bc, 0xc4d4,
+  0xf5bb, 0xc4d6, 0xc4d5, 0xf6d4, 0xf6d3, 0xc569, 0xc56a, 0xc5c6,
+  0xf7cd, 0xc5c5, 0xf8a3, 0xf8a4, 0xf8a2, 0xf8a1, 0xc654, 0xf8eb,
+  0xf8ec, 0xf8ed, 0xc653, 0xf967, 0xf96a, 0xf969, 0xf968, 0xf9d3,
+  0xc073, 0xc365, 0xf5bf, 0xf6d5, 0xc5c7, 0xf7ce, 0xf9d5, 0xc074,
+  0xefb6, 0xf7cf, 0xf9a1, 0xc94a, 0xddfc, 0xa14a, 0xa157, 0xa159,
+  0xa15b, 0xa15f, 0xa160, 0xa163, 0xa164, 0xa167, 0xa168, 0xa16b,
+  0xa16c, 0xa16f, 0xa170, 0xa173, 0xa174, 0xa177, 0xa178, 0xa17b,
+  0xa17c, 0xa1c6, 0xa1c7, 0xa1ca, 0xa1cb, 0xa1c8, 0xa1c9, 0xa15c,
+  0xa14d, 0xa14f, 0xa151, 0xa152, 0xa153, 0xa154, 0xa17d, 0xa17e,
+  0xa1a1, 0xa1a2, 0xa1a3, 0xa1a4, 0xa1cc, 0xa1cd, 0xa1ce, 0xa1de,
+  0xa1df, 0xa1e0, 0xa1e1, 0xa1e2, 0xa24c, 0xa24d, 0xa24e, 0xa149,
+  0xa1ad, 0xa243, 0xa248, 0xa1ae, 0xa15d, 0xa15e, 0xa1af, 0xa1cf,
+  0xa141, 0xa1d0, 0xa144, 0xa241, 0xa2af, 0xa2b0, 0xa2b1, 0xa2b2,
+  0xa2b3, 0xa2b4, 0xa2b5, 0xa2b6, 0xa2b7, 0xa2b8, 0xa147, 0xa146,
+  0xa1d5, 0xa1d7, 0xa1d6, 0xa148, 0xa249, 0xa2cf, 0xa2d0, 0xa2d1,
+  0xa2d2, 0xa2d3, 0xa2d4, 0xa2d5, 0xa2d6, 0xa2d7, 0xa2d8, 0xa2d9,
+  0xa2da, 0xa2db, 0xa2dc, 0xa2dd, 0xa2de, 0xa2df, 0xa2e0, 0xa2e1,
+  0xa2e2, 0xa2e3, 0xa2e4, 0xa2e5, 0xa2e6, 0xa2e7, 0xa2e8, 0xa242,
+  0xa1c4, 0xa2e9, 0xa2ea, 0xa2eb, 0xa2ec, 0xa2ed, 0xa2ee, 0xa2ef,
+  0xa2f0, 0xa2f1, 0xa2f2, 0xa2f3, 0xa2f4, 0xa2f5, 0xa2f6, 0xa2f7,
+  0xa2f8, 0xa2f9, 0xa2fa, 0xa2fb, 0xa2fc, 0xa2fd, 0xa2fe, 0xa340,
+  0xa341, 0xa342, 0xa343, 0xa161, 0xa155, 0xa162, 0xa14e,
+};
+
+static const Summary16 big5_uni2indx_page00[16] = {
+  /* 0x0000 */
+  {    0, 0x0000 }, {    0, 0x0000 }, {    0, 0x0000 }, {    0, 0x0000 },
+  {    0, 0x0000 }, {    0, 0x0000 }, {    0, 0x0000 }, {    0, 0x0000 },
+  {    0, 0x0000 }, {    0, 0x0000 }, {    0, 0x00ac }, {    4, 0x0083 },
+  {    7, 0x0000 }, {    7, 0x0080 }, {    8, 0x0000 }, {    8, 0x0080 },
+};
+static const Summary16 big5_uni2indx_page02[38] = {
+  /* 0x0200 */
+  {    9, 0x0000 }, {    9, 0x0000 }, {    9, 0x0000 }, {    9, 0x0000 },
+  {    9, 0x0000 }, {    9, 0x0000 }, {    9, 0x0000 }, {    9, 0x0000 },
+  {    9, 0x0000 }, {    9, 0x0000 }, {    9, 0x0000 }, {    9, 0x0000 },
+  {    9, 0x0e80 }, {   13, 0x0200 }, {   14, 0x0000 }, {   14, 0x0000 },
+  /* 0x0300 */
+  {   14, 0x0000 }, {   14, 0x0000 }, {   14, 0x0000 }, {   14, 0x0000 },
+  {   14, 0x0000 }, {   14, 0x0000 }, {   14, 0x0000 }, {   14, 0x0000 },
+  {   14, 0x0000 }, {   14, 0xfffe }, {   29, 0x03fb }, {   38, 0xfffe },
+  {   53, 0x03fb }, {   62, 0x0000 }, {   62, 0x0000 }, {   62, 0x0000 },
+  /* 0x0400 */
+  {   62, 0x0002 }, {   63, 0x1ff0 }, {   72, 0xfff8 }, {   85, 0xffff },
+  {  101, 0xffff }, {  117, 0x0002 },
+};
+static const Summary16 big5_uni2indx_page20[44] = {
+  /* 0x2000 */
+  {  118, 0x0000 }, {  118, 0x3318 }, {  124, 0x0064 }, {  127, 0x4824 },
+  {  131, 0x0000 }, {  131, 0x0000 }, {  131, 0x0000 }, {  131, 0x0000 },
+  {  131, 0x0000 }, {  131, 0x0000 }, {  131, 0x0000 }, {  131, 0x0000 },
+  {  131, 0x0000 }, {  131, 0x0000 }, {  131, 0x0000 }, {  131, 0x0000 },
+  /* 0x2100 */
+  {  131, 0x0228 }, {  134, 0x0000 }, {  134, 0x0000 }, {  134, 0x0000 },
+  {  134, 0x0000 }, {  134, 0x0000 }, {  134, 0x03ff }, {  144, 0x0000 },
+  {  144, 0x0000 }, {  144, 0x03cf }, {  152, 0x0000 }, {  152, 0x0000 },
+  {  152, 0x0000 }, {  152, 0x0000 }, {  152, 0x0000 }, {  152, 0x0000 },
+  /* 0x2200 */
+  {  152, 0x0000 }, {  152, 0xc400 }, {  155, 0x4e29 }, {  162, 0x1030 },
+  {  165, 0x0000 }, {  165, 0x0004 }, {  166, 0x00c3 }, {  170, 0x0000 },
+  {  170, 0x0000 }, {  170, 0x0000 }, {  170, 0x0020 }, {  171, 0x8000 },
+};
+static const Summary16 big5_uni2indx_page24[37] = {
+  /* 0x2400 */
+  {  172, 0x0000 }, {  172, 0x0000 }, {  172, 0x0000 }, {  172, 0x0000 },
+  {  172, 0x0000 }, {  172, 0x0000 }, {  172, 0x03ff }, {  182, 0x3ff0 },
+  {  192, 0x0000 }, {  192, 0x0000 }, {  192, 0x0000 }, {  192, 0x0000 },
+  {  192, 0x0000 }, {  192, 0x0000 }, {  192, 0x0000 }, {  192, 0x0000 },
+  /* 0x2500 */
+  {  192, 0x1005 }, {  195, 0x1111 }, {  199, 0x1010 }, {  201, 0x1010 },
+  {  203, 0x0000 }, {  203, 0x4001 }, {  205, 0xe402 }, {  210, 0x000f },
+  {  214, 0xfffe }, {  229, 0x0030 }, {  231, 0x0003 }, {  233, 0x300c },
+  {  237, 0xc8c0 }, {  242, 0x0000 }, {  242, 0x003c }, {  246, 0x0000 },
+  /* 0x2600 */
+  {  246, 0x0260 }, {  249, 0x0000 }, {  249, 0x0000 }, {  249, 0x0000 },
+  {  249, 0x0007 },
+};
+static const Summary16 big5_uni2indx_page30[62] = {
+  /* 0x3000 */
+  {  252, 0xff2f }, {  265, 0x6037 }, {  272, 0x03fe }, {  281, 0x0000 },
+  {  281, 0xfffe }, {  296, 0xffff }, {  312, 0xffff }, {  328, 0xffff },
+  {  344, 0xffff }, {  360, 0x600f }, {  366, 0xfffe }, {  381, 0xffff },
+  {  397, 0xffff }, {  413, 0xffff }, {  429, 0xffff }, {  445, 0x407f },
+  /* 0x3100 */
+  {  453, 0xffe0 }, {  464, 0xffff }, {  480, 0x03ff }, {  490, 0x0000 },
+  {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 },
+  {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 },
+  {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 },
+  /* 0x3200 */
+  {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 },
+  {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0000 },
+  {  490, 0x0000 }, {  490, 0x0000 }, {  490, 0x0008 }, {  491, 0x0000 },
+  {  491, 0x0000 }, {  491, 0x0000 }, {  491, 0x0000 }, {  491, 0x0000 },
+  /* 0x3300 */
+  {  491, 0x0000 }, {  491, 0x0000 }, {  491, 0x0000 }, {  491, 0x0000 },
+  {  491, 0x0000 }, {  491, 0x0000 }, {  491, 0x0000 }, {  491, 0x0000 },
+  {  491, 0xc000 }, {  493, 0x7000 }, {  496, 0x0002 }, {  497, 0x0000 },
+  {  497, 0x4010 }, {  499, 0x0026 },
+};
+static const Summary16 big5_uni2indx_page4e[1307] = {
+  /* 0x4e00 */
+  {  502, 0xff8b }, {  514, 0xc373 }, {  523, 0x6840 }, {  527, 0x1b0f },
+  {  535, 0xe9ac }, {  544, 0xf34c }, {  553, 0x0200 }, {  554, 0xc008 },
+  {  557, 0x795c }, {  566, 0xca3e }, {  575, 0x7976 }, {  585, 0x0648 },
+  {  589, 0x2fdf }, {  601, 0xf7f0 }, {  612, 0x033a }, {  618, 0xa8ff },
+  /* 0x4f00 */
+  {  629, 0xef37 }, {  641, 0x233f }, {  650, 0xb004 }, {  654, 0xfd59 },
+  {  665, 0xf3ca }, {  675, 0xffff }, {  691, 0xde9f }, {  703, 0xfff9 },
+  {  717, 0xabff }, {  730, 0x7df7 }, {  743, 0xc000 }, {  745, 0x8eec },
+  {  754, 0xeebf }, {  767, 0xffdb }, {  781, 0xd003 }, {  786, 0x45fa },
+  /* 0x5000 */
+  {  795, 0xfae1 }, {  805, 0xdffe }, {  819, 0xbfef }, {  833, 0x10ab },
+  {  839, 0xffeb }, {  853, 0xfcaa }, {  863, 0xef3f }, {  876, 0x24fd },
+  {  885, 0x78ad }, {  894, 0x7f76 }, {  906, 0xf00c }, {  912, 0xedff },
+  {  926, 0xcff6 }, {  938, 0x2cfa }, {  947, 0xf7f9 }, {  960, 0xeb6b },
+  /* 0x5100 */
+  {  971, 0x1ffd }, {  983, 0x95bf }, {  994, 0x6677 }, { 1004, 0xbfbf },
+  { 1018, 0x3bfb }, { 1030, 0xfeb4 }, { 1041, 0x7bae }, { 1052, 0x11e2 },
+  { 1058, 0xa681 }, { 1064, 0x41be }, { 1072, 0x1435 }, { 1078, 0x72c3 },
+  { 1086, 0x7d70 }, { 1095, 0x7191 }, { 1102, 0x0003 }, { 1104, 0x276b },
+  /* 0x5200 */
+  { 1113, 0x57cb }, { 1123, 0x70cf }, { 1132, 0x4732 }, { 1139, 0x0def },
+  { 1149, 0x7eda }, { 1160, 0xfc74 }, { 1170, 0xfe06 }, { 1179, 0xbdb4 },
+  { 1189, 0x3f9f }, { 1201, 0x8bca }, { 1209, 0x7e49 }, { 1218, 0x5800 },
+  { 1221, 0x228f }, { 1228, 0xebec }, { 1239, 0x8a5c }, { 1246, 0xddbb },
+  /* 0x5300 */
+  { 1258, 0xef60 }, { 1267, 0xb6e7 }, { 1278, 0xa40f }, { 1285, 0xf293 },
+  { 1294, 0x37bb }, { 1305, 0x549e }, { 1313, 0xd04b }, { 1320, 0x9baf },
+  { 1331, 0xc414 }, { 1336, 0xf7d4 }, { 1347, 0x30b0 }, { 1352, 0x0a14 },
+  { 1356, 0x2f08 }, { 1362, 0x88d0 }, { 1367, 0xff7e }, { 1381, 0x192f },
+  /* 0x5400 */
+  { 1389, 0xffda }, { 1402, 0xfb07 }, { 1412, 0x7ff1 }, { 1424, 0x7beb },
+  { 1436, 0xc5ef }, { 1447, 0x0010 }, { 1448, 0x99ff }, { 1460, 0xfdff },
+  { 1475, 0x79d7 }, { 1486, 0x0567 }, { 1493, 0xffe7 }, { 1507, 0xfdcb },
+  { 1519, 0xc3ff }, { 1531, 0x4040 }, { 1533, 0x6ff7 }, { 1546, 0xbd8e },
+  /* 0x5500 */
+  { 1556, 0xdffa }, { 1569, 0x0497 }, { 1575, 0xf4c0 }, { 1582, 0x5bff },
+  { 1595, 0xed7b }, { 1607, 0xd0e7 }, { 1616, 0x047e }, { 1623, 0xf8e0 },
+  { 1631, 0xff9f }, { 1645, 0xb73e }, { 1656, 0x7dfe }, { 1669, 0x882e },
+  { 1675, 0xfffd }, { 1690, 0xbe7f }, { 1703, 0x83fe }, { 1713, 0xf6c4 },
+  /* 0x5600 */
+  { 1722, 0xf357 }, { 1733, 0xb8fd }, { 1744, 0xd680 }, { 1750, 0xef7d },
+  { 1763, 0x5767 }, { 1773, 0x4788 }, { 1779, 0xff7d }, { 1793, 0xc3df },
+  { 1804, 0xf0ff }, { 1816, 0x37a9 }, { 1825, 0x7de0 }, { 1834, 0x70fc },
+  { 1843, 0x3f6f }, { 1855, 0xec9a }, { 1864, 0x4cb3 }, { 1872, 0x8681 },
+  /* 0x5700 */
+  { 1877, 0x3f9e }, { 1888, 0xdd5c }, { 1898, 0xf70d }, { 1908, 0x4819 },
+  { 1913, 0xfea3 }, { 1924, 0x0007 }, { 1927, 0xaf56 }, { 1937, 0x38ff },
+  { 1948, 0x980d }, { 1954, 0xefb8 }, { 1965, 0x403d }, { 1971, 0xb760 },
+  { 1979, 0xd8ce }, { 1988, 0x9035 }, { 1994, 0x72bf }, { 2005, 0x3fff },
+  /* 0x5800 */
+  { 2019, 0x7ff7 }, { 2033, 0x7a11 }, { 2040, 0xf7bb }, { 2053, 0xabff },
+  { 2066, 0xff00 }, { 2074, 0x6fbe }, { 2086, 0xa93c }, { 2094, 0xfe72 },
+  { 2105, 0xcfef }, { 2118, 0xf11b }, { 2127, 0xdb6b }, { 2138, 0xf40a },
+  { 2145, 0xc3e6 }, { 2154, 0xef7e }, { 2167, 0x9b9c }, { 2176, 0xf610 },
+  /* 0x5900 */
+  { 2183, 0xf048 }, { 2189, 0x16f4 }, { 2197, 0xfeb5 }, { 2209, 0x5182 },
+  { 2214, 0xc7b1 }, { 2223, 0x15bb }, { 2232, 0x6e87 }, { 2241, 0xfbdf },
+  { 2255, 0xe43f }, { 2265, 0x63cd }, { 2274, 0xc1ff }, { 2285, 0x7e7e },
+  { 2297, 0xfdeb }, { 2310, 0x7d5f }, { 2322, 0x777b }, { 2334, 0xfcfe },
+  /* 0x5a00 */
+  { 2347, 0x960b }, { 2354, 0xdbea }, { 2365, 0x6229 }, { 2371, 0x53e8 },
+  { 2379, 0x37df }, { 2391, 0xfdef }, { 2405, 0x36f5 }, { 2415, 0xbd81 },
+  { 2423, 0xdc18 }, { 2430, 0xfcbd }, { 2442, 0xd2e4 }, { 2450, 0xffff },
+  { 2466, 0x3fd7 }, { 2478, 0xffe0 }, { 2489, 0x7f6f }, { 2502, 0xabf8 },
+  /* 0x5b00 */
+  { 2512, 0x9bae }, { 2522, 0x6ed9 }, { 2532, 0xf5fb }, { 2545, 0xf115 },
+  { 2553, 0x79a9 }, { 2562, 0xbdfb }, { 2575, 0x5a3c }, { 2583, 0xadaf },
+  { 2594, 0xdbba }, { 2605, 0x1fac }, { 2614, 0x71fc }, { 2624, 0x8379 },
+  { 2632, 0x7cf7 }, { 2644, 0xc35f }, { 2654, 0xdfff }, { 2669, 0x0567 },
+  /* 0x5c00 */
+  { 2676, 0xff9a }, { 2688, 0x8467 }, { 2695, 0x1534 }, { 2701, 0xdf8b },
+  { 2712, 0xf9f3 }, { 2724, 0x3373 }, { 2733, 0xf7bd }, { 2746, 0x5e1a },
+  { 2754, 0xbf40 }, { 2762, 0xa03f }, { 2770, 0xffff }, { 2786, 0x01eb },
+  { 2793, 0xdfc0 }, { 2802, 0xcfdd }, { 2814, 0x7500 }, { 2819, 0xabd3 },
+  /* 0x5d00 */
+  { 2829, 0xf8c3 }, { 2838, 0xeed6 }, { 2849, 0x43fd }, { 2859, 0xb7ff },
+  { 2873, 0x5eaf }, { 2884, 0x4227 }, { 2890, 0x9bac }, { 2899, 0xf686 },
+  { 2908, 0x27d7 }, { 2918, 0xf6bc }, { 2929, 0xf787 }, { 2940, 0x35b7 },
+  { 2950, 0xaacd }, { 2959, 0xe176 }, { 2968, 0x49e7 }, { 2977, 0xe29f },
+  /* 0x5e00 */
+  { 2987, 0x545c }, { 2994, 0xaff2 }, { 3005, 0x2b3f }, { 3015, 0x61d8 },
+  { 3022, 0xfc3b }, { 3033, 0xbbb8 }, { 3043, 0xffcf }, { 3057, 0x7b7d },
+  { 3069, 0xbf95 }, { 3080, 0x1ce0 }, { 3086, 0x7dfd }, { 3099, 0x43ff },
+  { 3110, 0x5ff6 }, { 3122, 0xfffe }, { 3137, 0xd3ef }, { 3149, 0xc4ce },
+  /* 0x5f00 */
+  { 3157, 0x8db6 }, { 3166, 0xadbc }, { 3176, 0x63dc }, { 3185, 0x11eb },
+  { 3193, 0xdf59 }, { 3204, 0x23d0 }, { 3210, 0xbeb4 }, { 3220, 0xf3db },
+  { 3232, 0x1fe7 }, { 3243, 0xdbc7 }, { 3254, 0xff63 }, { 3266, 0xfae4 },
+  { 3276, 0xb22b }, { 3284, 0x63f7 }, { 3295, 0xed3b }, { 3306, 0xadba },
+  /* 0x6000 */
+  { 3316, 0xfe01 }, { 3324, 0x7eff }, { 3338, 0xfff7 }, { 3353, 0x02bc },
+  { 3359, 0x32ff }, { 3370, 0xef39 }, { 3381, 0xfffc }, { 3395, 0x8005 },
+  { 3398, 0x77fb }, { 3411, 0xbcf5 }, { 3422, 0x010d }, { 3426, 0xfff7 },
+  { 3441, 0xfffb }, { 3456, 0xbf3a }, { 3467, 0x0057 }, { 3472, 0xdfff },
+  /* 0x6100 */
+  { 3487, 0xef7b }, { 3500, 0xbd7d }, { 3512, 0xdb88 }, { 3520, 0xc8d4 },
+  { 3527, 0xfff3 }, { 3541, 0xed7c }, { 3552, 0x5dee }, { 3563, 0x56ff },
+  { 3575, 0x7e0d }, { 3584, 0xac5f }, { 3594, 0xff96 }, { 3606, 0xd57f },
+  { 3618, 0x3fee }, { 3630, 0xc140 }, { 3634, 0x6ff9 }, { 3646, 0xffe7 },
+  /* 0x6200 */
+  { 3660, 0x779b }, { 3671, 0x8e77 }, { 3681, 0x6ebf }, { 3693, 0xe45d },
+  { 3702, 0x6fcf }, { 3714, 0x5f1f }, { 3725, 0xe07f }, { 3735, 0xfedf },
+  { 3749, 0xd7db }, { 3761, 0x01fe }, { 3769, 0xff00 }, { 3777, 0xfb7b },
+  { 3790, 0xffd4 }, { 3802, 0x1fdf }, { 3814, 0xf800 }, { 3819, 0xffff },
+  /* 0x6300 */
+  { 3835, 0xfb8f }, { 3847, 0x007b }, { 3853, 0xbf00 }, { 3860, 0x7f5c },
+  { 3871, 0xffff }, { 3887, 0x07f3 }, { 3896, 0xeba0 }, { 3904, 0x3de7 },
+  { 3915, 0xf7bf }, { 3929, 0xfbd7 }, { 3942, 0xffbf }, { 3957, 0x6003 },
+  { 3961, 0xfffd }, { 3976, 0xbfed }, { 3989, 0xefbb }, { 4002, 0x027f },
+  /* 0x6400 */
+  { 4010, 0xfe40 }, { 4018, 0xddfd }, { 4031, 0xfdff }, { 4046, 0xe2f9 },
+  { 4056, 0x680b }, { 4062, 0xfb1f }, { 4074, 0xfbe3 }, { 4086, 0xaffd },
+  { 4099, 0x9fa4 }, { 4108, 0xf7ed }, { 4121, 0x7a7d }, { 4132, 0xf80f },
+  { 4141, 0xeebe }, { 4153, 0x0fd5 }, { 4162, 0xbb5d }, { 4173, 0xfd9f },
+  /* 0x6500 */
+  { 4186, 0xf2db }, { 4197, 0x3bf9 }, { 4208, 0xfe7f }, { 4222, 0xebcc },
+  { 4232, 0x876a }, { 4240, 0x73fa }, { 4251, 0x95fc }, { 4261, 0x9ffc },
+  { 4273, 0x109f }, { 4280, 0xfaf7 }, { 4293, 0xddb7 }, { 4305, 0xbbcd },
+  { 4316, 0xf87e }, { 4327, 0xeccd }, { 4337, 0xf366 }, { 4347, 0x3c3f },
+  /* 0x6600 */
+  { 4357, 0xfffd }, { 4372, 0xb03f }, { 4381, 0xe9f7 }, { 4393, 0x067e },
+  { 4401, 0x96ae }, { 4410, 0xfe06 }, { 4419, 0xd576 }, { 4429, 0x5fd7 },
+  { 4441, 0x3fd1 }, { 4451, 0xa3f3 }, { 4461, 0xcf07 }, { 4470, 0x6fb7 },
+  { 4482, 0x9fd1 }, { 4492, 0x7f44 }, { 4501, 0x7b59 }, { 4511, 0xd3dd },
+  /* 0x6700 */
+  { 4522, 0xaf3b }, { 4533, 0xa9bd }, { 4543, 0x7dcf }, { 4555, 0xff3a },
+  { 4567, 0xfbe0 }, { 4577, 0xf6eb }, { 4589, 0xb401 }, { 4594, 0xffff },
+  { 4610, 0x7afa }, { 4621, 0xb7bf }, { 4634, 0xc000 }, { 4636, 0x0ffd },
+  { 4647, 0xff7f }, { 4662, 0xff1f }, { 4675, 0xfefc }, { 4688, 0x95ff },
+  /* 0x6800 */
+  { 4700, 0x0000 }, { 4700, 0xb5dc }, { 4710, 0xef63 }, { 4721, 0x3f3e },
+  { 4732, 0xfb7f }, { 4746, 0x001b }, { 4750, 0xe800 }, { 4754, 0xfbf6 },
+  { 4767, 0x9eef }, { 4779, 0xb8df }, { 4790, 0xff9f }, { 4804, 0x003f },
+  { 4810, 0x7bd0 }, { 4819, 0xf5ff }, { 4833, 0xdfdb }, { 4846, 0x3fff },
+  /* 0x6900 */
+  { 4860, 0xfdf0 }, { 4871, 0x00bf }, { 4878, 0x8420 }, { 4881, 0xbbbd },
+  { 4893, 0xdf37 }, { 4905, 0xffde }, { 4919, 0xff6d }, { 4932, 0x0ff3 },
+  { 4942, 0x604c }, { 4947, 0x5efb }, { 4959, 0xfffb }, { 4974, 0xfafb },
+  { 4987, 0xfe5e }, { 4999, 0x0219 }, { 5003, 0x79f4 }, { 5013, 0xf9de },
+  /* 0x6a00 */
+  { 5025, 0xa7f7 }, { 5037, 0xebfa }, { 5049, 0x01eb }, { 5056, 0xff34 },
+  { 5067, 0xebd3 }, { 5078, 0xef73 }, { 5090, 0xafd7 }, { 5102, 0xc040 },
+  { 5105, 0x72bb }, { 5115, 0xdcff }, { 5128, 0xf17f }, { 5140, 0x2fd8 },
+  { 5149, 0xb8ec }, { 5158, 0xfe0b }, { 5168, 0xdda3 }, { 5178, 0x1f0b },
+  /* 0x6b00 */
+  { 5186, 0x8f1d }, { 5195, 0x47cf }, { 5205, 0xb12b }, { 5213, 0xffde },
+  { 5227, 0x7fee }, { 5240, 0xda73 }, { 5250, 0x24ff }, { 5260, 0xcbc4 },
+  { 5268, 0xf75d }, { 5280, 0xcbf2 }, { 5290, 0xecfd }, { 5302, 0xb4ed },
+  { 5312, 0xbff9 }, { 5325, 0x4ddd }, { 5335, 0x99dd }, { 5345, 0xfb8d },
+  /* 0x6c00 */
+  { 5356, 0xbb7f }, { 5369, 0xaf7b }, { 5381, 0xddfb }, { 5394, 0xc959 },
+  { 5402, 0xfc4f }, { 5413, 0xfab5 }, { 5424, 0xafe3 }, { 5435, 0x6d5f },
+  { 5446, 0xffff }, { 5462, 0x3f7d }, { 5474, 0x7800 }, { 5478, 0xffdb },
+  { 5492, 0xb6ff }, { 5505, 0x7eff }, { 5519, 0xfbaf }, { 5532, 0x022f },
+  /* 0x6d00 */
+  { 5538, 0xff9b }, { 5551, 0xefc7 }, { 5563, 0xffa5 }, { 5575, 0xffff },
+  { 5591, 0x0007 }, { 5594, 0xc700 }, { 5599, 0xf7ff }, { 5614, 0xfff1 },
+  { 5627, 0x7ffd }, { 5641, 0x01bf }, { 5649, 0xdc00 }, { 5654, 0xfdbc },
+  { 5666, 0xbff5 }, { 5679, 0xffff }, { 5695, 0xff7f }, { 5710, 0x3eff },
+  /* 0x6e00 */
+  { 5723, 0x0029 }, { 5726, 0xbe00 }, { 5732, 0xf9ff }, { 5746, 0xff7f },
+  { 5761, 0x6efb }, { 5773, 0xfd7e }, { 5786, 0xcbff }, { 5799, 0x039e },
+  { 5806, 0xe300 }, { 5811, 0xfbdd }, { 5824, 0xccff }, { 5836, 0xf6df },
+  { 5849, 0xffff }, { 5865, 0x117f }, { 5874, 0xf800 }, { 5879, 0xfbf6 },
+  /* 0x6f00 */
+  { 5892, 0xe7ef }, { 5905, 0xd73c }, { 5915, 0xfeef }, { 5929, 0xdfef },
+  { 5943, 0xc00b }, { 5948, 0xedbf }, { 5961, 0xfedf }, { 5975, 0xfdcd },
+  { 5987, 0x7bf5 }, { 5999, 0x40fd }, { 6007, 0xffff }, { 6023, 0xb75f },
+  { 6035, 0xffdf }, { 6050, 0xf930 }, { 6058, 0xfbdf }, { 6072, 0xdc97 },
+  /* 0x7000 */
+  { 6082, 0xfef3 }, { 6095, 0xbff2 }, { 6107, 0x8fdf }, { 6119, 0xdfbf },
+  { 6133, 0x177f }, { 6144, 0xede6 }, { 6155, 0x0f7f }, { 6166, 0x3553 },
+  { 6174, 0x447c }, { 6181, 0x877e }, { 6191, 0xfa12 }, { 6199, 0x45bb },
+  { 6208, 0xede0 }, { 6217, 0x779e }, { 6228, 0x8017 }, { 6233, 0xbfd9 },
+  /* 0x7100 */
+  { 6245, 0x7e55 }, { 6255, 0xde89 }, { 6264, 0xc16f }, { 6273, 0x0447 },
+  { 6278, 0x7ade }, { 6289, 0xf75d }, { 6301, 0x57ff }, { 6314, 0x2905 },
+  { 6319, 0x86f7 }, { 6329, 0xfe95 }, { 6340, 0x97b3 }, { 6350, 0xf32f },
+  { 6361, 0xcfff }, { 6375, 0x9f75 }, { 6386, 0x71f7 }, { 6397, 0xfb17 },
+  /* 0x7200 */
+  { 6408, 0x34ee }, { 6417, 0xee19 }, { 6426, 0x37cc }, { 6435, 0xef61 },
+  { 6445, 0x9fd6 }, { 6456, 0xef4c }, { 6466, 0xd68f }, { 6476, 0xfbdd },
+  { 6489, 0x7b73 }, { 6500, 0x6def }, { 6512, 0xd7fe }, { 6525, 0xa431 },
+  { 6531, 0x5e7f }, { 6543, 0x97d7 }, { 6554, 0x0f5b }, { 6563, 0xffd8 },
+  /* 0x7300 */
+  { 6575, 0x9d83 }, { 6583, 0x7bce }, { 6594, 0x22ec }, { 6601, 0xdcff },
+  { 6614, 0x763d }, { 6624, 0xef87 }, { 6635, 0xdfe7 }, { 6648, 0xfded },
+  { 6661, 0x4fff }, { 6674, 0xa0fc }, { 6682, 0x3b77 }, { 6693, 0xdbfc },
+  { 6705, 0x3ded }, { 6716, 0x7fdc }, { 6728, 0x6fa9 }, { 6738, 0xf570 },
+  /* 0x7400 */
+  { 6747, 0x3ffb }, { 6760, 0x2c40 }, { 6764, 0xff7f }, { 6779, 0x847f },
+  { 6788, 0xec57 }, { 6798, 0xdeb7 }, { 6810, 0xe69c }, { 6819, 0xf22f },
+  { 6829, 0x0feb }, { 6839, 0xd5b5 }, { 6849, 0xafeb }, { 6861, 0xede7 },
+  { 6873, 0x8c2f }, { 6881, 0xfff0 }, { 6893, 0x537f }, { 6904, 0xe8f0 },
+  /* 0x7500 */
+  { 6912, 0xb99d }, { 6922, 0xb5ff }, { 6935, 0xff66 }, { 6947, 0xe78f },
+  { 6958, 0xd981 }, { 6965, 0xbe10 }, { 6972, 0x9c7c }, { 6981, 0xe3c1 },
+  { 6989, 0x9cd1 }, { 6997, 0x2733 }, { 7005, 0x0cbc }, { 7012, 0xff6d },
+  { 7025, 0xfcb7 }, { 7037, 0xefb7 }, { 7050, 0xa0df }, { 7059, 0xffff },
+  /* 0x7600 */
+  { 7075, 0xbf0b }, { 7085, 0xfe7b }, { 7098, 0xa3ff }, { 7110, 0x353f },
+  { 7120, 0x13cc }, { 7127, 0x97cd }, { 7137, 0x7637 }, { 7147, 0xfb27 },
+  { 7158, 0xcfd6 }, { 7169, 0x7e6c }, { 7179, 0xec50 }, { 7186, 0xed31 },
+  { 7195, 0x677c }, { 7205, 0xfc1c }, { 7214, 0xf6fa }, { 7226, 0x5fbf },
+  /* 0x7700 */
+  { 7239, 0x0fba }, { 7248, 0xae2f }, { 7258, 0xa3ad }, { 7267, 0x7ffe },
+  { 7281, 0xfcf0 }, { 7291, 0xde74 }, { 7301, 0xffef }, { 7316, 0xf200 },
+  { 7321, 0xfbbf }, { 7335, 0xfea2 }, { 7345, 0x3daf }, { 7356, 0xbcff },
+  { 7369, 0xf694 }, { 7378, 0x5fb9 }, { 7389, 0xf3ad }, { 7400, 0x3f8f },
+  /* 0x7800 */
+  { 7411, 0xf26c }, { 7420, 0xa01f }, { 7427, 0xffef }, { 7442, 0x01bf },
+  { 7450, 0x7728 }, { 7458, 0x7005 }, { 7463, 0xff35 }, { 7475, 0xda03 },
+  { 7482, 0xd2f9 }, { 7492, 0xc7fa }, { 7503, 0x3fbf }, { 7516, 0x5c1d },
+  { 7524, 0xff3a }, { 7536, 0xec33 }, { 7545, 0xb7af }, { 7557, 0xfe9c },
+  /* 0x7900 */
+  { 7568, 0x5236 }, { 7575, 0x7a9f }, { 7586, 0xbffa }, { 7599, 0xe722 },
+  { 7607, 0x9ff7 }, { 7620, 0xfcff }, { 7634, 0x2fbb }, { 7645, 0xb61d },
+  { 7654, 0xed06 }, { 7662, 0x1dfd }, { 7673, 0x7dd7 }, { 7685, 0xefdf },
+  { 7699, 0xeb23 }, { 7708, 0xf166 }, { 7717, 0x7ed9 }, { 7728, 0x0dc0 },
+  /* 0x7a00 */
+  { 7733, 0x3d3d }, { 7743, 0xdfbf }, { 7757, 0xc945 }, { 7764, 0xba83 },
+  { 7772, 0x7dd1 }, { 7782, 0x9dd0 }, { 7790, 0x7b87 }, { 7800, 0xcf73 },
+  { 7811, 0x9ff3 }, { 7823, 0xc3f5 }, { 7833, 0xdf0d }, { 7843, 0xc5fe },
+  { 7854, 0x0cb3 }, { 7861, 0x8302 }, { 7865, 0xe879 }, { 7874, 0xaec0 },
+  /* 0x7b00 */
+  { 7881, 0xc773 }, { 7891, 0x6f0f }, { 7901, 0xfd7d }, { 7914, 0x093f },
+  { 7922, 0xfff1 }, { 7935, 0x0157 }, { 7941, 0x62fb }, { 7951, 0x01ff },
+  { 7960, 0xfdb4 }, { 7971, 0x3bf3 }, { 7982, 0xb013 }, { 7988, 0x43b2 },
+  { 7995, 0x5ed3 }, { 8005, 0xff30 }, { 8015, 0x0fff }, { 8027, 0xeb9f },
+  /* 0x7c00 */
+  { 8039, 0xfeef }, { 8053, 0xf203 }, { 8060, 0x3fef }, { 8073, 0xfb89 },
+  { 8083, 0x37a9 }, { 8092, 0x9e99 }, { 8101, 0xdef9 }, { 8113, 0xa72c },
+  { 8121, 0x3733 }, { 8130, 0xc1f6 }, { 8139, 0x812e }, { 8145, 0xfe3e },
+  { 8157, 0x5d20 }, { 8163, 0xf2f7 }, { 8175, 0xd585 }, { 8183, 0x69d7 },
+  /* 0x7d00 */
+  { 8193, 0xffff }, { 8209, 0xffff }, { 8225, 0xdb07 }, { 8234, 0xff6f },
+  { 8248, 0xc4ff }, { 8259, 0xd97f }, { 8271, 0xefce }, { 8283, 0xbe0f },
+  { 8293, 0xf17b }, { 8304, 0xf05e }, { 8313, 0xf6cf }, { 8325, 0xffb7 },
+  { 8339, 0x5ef7 }, { 8351, 0xef84 }, { 8360, 0xd7cb }, { 8371, 0x0edf },
+  /* 0x7e00 */
+  { 8381, 0xff08 }, { 8390, 0xfcff }, { 8404, 0xee3f }, { 8416, 0xffff },
+  { 8432, 0x13ff }, { 8443, 0xd7ff }, { 8457, 0xaf0f }, { 8467, 0x7ffd },
+  { 8481, 0xbdc7 }, { 8492, 0x1ffa }, { 8503, 0x0000 }, { 8503, 0x0000 },
+  { 8503, 0x0000 }, { 8503, 0x0000 }, { 8503, 0x0000 }, { 8503, 0x0000 },
+  /* 0x7f00 */
+  { 8503, 0x0000 }, { 8503, 0x0000 }, { 8503, 0x0000 }, { 8503, 0xe740 },
+  { 8510, 0xbd38 }, { 8519, 0xf933 }, { 8529, 0x7feb }, { 8542, 0xfeed },
+  { 8555, 0x7fe8 }, { 8566, 0x7c76 }, { 8576, 0xb3f7 }, { 8588, 0xffef },
+  { 8603, 0xfeaf }, { 8616, 0xd8b7 }, { 8626, 0xff6f }, { 8640, 0xfbbf },
+  /* 0x8000 */
+  { 8654, 0xf8fb }, { 8666, 0xdbf7 }, { 8679, 0x1752 }, { 8686, 0xe2f9 },
+  { 8696, 0x85c8 }, { 8702, 0x7547 }, { 8711, 0x9090 }, { 8715, 0xe3ef },
+  { 8727, 0x9ef4 }, { 8737, 0x3f6d }, { 8748, 0xee2e }, { 8758, 0x0536 },
+  { 8764, 0xf7bc }, { 8776, 0x7ff3 }, { 8789, 0xa07b }, { 8797, 0x7f3f },
+  /* 0x8100 */
+  { 8810, 0x0567 }, { 8817, 0xeb60 }, { 8825, 0xbabe }, { 8836, 0x6601 },
+  { 8841, 0xfcd8 }, { 8851, 0x583f }, { 8860, 0xcaf7 }, { 8871, 0x87df },
+  { 8882, 0xbfcd }, { 8894, 0xffa0 }, { 8904, 0x5bcd }, { 8914, 0xfebf },
+  { 8928, 0xb6fd }, { 8940, 0xefa7 }, { 8952, 0x77ef }, { 8965, 0xdf9c },
+  /* 0x8200 */
+  { 8976, 0x3fb7 }, { 8988, 0xf877 }, { 8999, 0x9d27 }, { 9008, 0xb7fc },
+  { 9020, 0xcab5 }, { 9029, 0xdfef }, { 9043, 0xfb5a }, { 9054, 0xf1b6 },
+  { 9064, 0xec39 }, { 9073, 0xef1f }, { 9085, 0xfbbf }, { 9099, 0x7ffb },
+  { 9113, 0x000d }, { 9116, 0xdafe }, { 9128, 0xbdfb }, { 9141, 0x4e7f },
+  /* 0x8300 */
+  { 9152, 0x33ff }, { 9164, 0x5ac0 }, { 9170, 0xbff5 }, { 9183, 0x9ffe },
+  { 9196, 0xffbf }, { 9211, 0x005f }, { 9217, 0x0000 }, { 9217, 0xfdf8 },
+  { 9229, 0xffca }, { 9241, 0x6ffd }, { 9254, 0xcffd }, { 9267, 0xa001 },
+  { 9270, 0xdfff }, { 9285, 0xfbf2 }, { 9297, 0xdfbf }, { 9311, 0xff7f },
+  /* 0x8400 */
+  { 9326, 0xfeda }, { 9338, 0x080f }, { 9343, 0xba08 }, { 9349, 0xbfff },
+  { 9364, 0x7afd }, { 9376, 0xeed7 }, { 9388, 0xfbeb }, { 9401, 0x67f9 },
+  { 9412, 0xe044 }, { 9417, 0xff93 }, { 9429, 0xdf97 }, { 9441, 0x9f57 },
+  { 9452, 0xfef7 }, { 9466, 0x08df }, { 9474, 0xdf80 }, { 9482, 0xfedf },
+  /* 0x8500 */
+  { 9496, 0xffc5 }, { 9508, 0xf7fe }, { 9522, 0xfffb }, { 9537, 0x6803 },
+  { 9542, 0x67fb }, { 9554, 0x6bfa }, { 9565, 0x7fff }, { 9580, 0x5fe2 },
+  { 9590, 0xffff }, { 9606, 0xff73 }, { 9619, 0x87df }, { 9630, 0xe7fb },
+  { 9643, 0xebfd }, { 9656, 0xf7a7 }, { 9668, 0xbf7e }, { 9681, 0xefc7 },
+  /* 0x8600 */
+  { 9693, 0x1ef3 }, { 9703, 0xdf82 }, { 9712, 0x76ff }, { 9725, 0xdf7e },
+  { 9738, 0x79c9 }, { 9747, 0xda7d }, { 9758, 0xefbe }, { 9771, 0x1e9b },
+  { 9780, 0x7ce0 }, { 9788, 0x77fb }, { 9801, 0x87be }, { 9811, 0xfffb },
+  { 9826, 0x1bff }, { 9838, 0xffdb }, { 9852, 0x3f5c }, { 9862, 0x4fe0 },
+  /* 0x8700 */
+  { 9870, 0x7fff }, { 9885, 0x5f0e }, { 9894, 0x77ff }, { 9908, 0xddbf },
+  { 9921, 0xf04f }, { 9930, 0xffff }, { 9946, 0xffff }, { 9962, 0x0ff8 },
+  { 9971, 0xa3be }, { 9981, 0xfddf }, { 9995, 0xfc1c }, { 10004, 0xfffd },
+  { 10019, 0x1f7d }, { 10030, 0xfb9e }, { 10042, 0xbdff }, { 10056, 0xdedc },
+  /* 0x8800 */
+  { 10067, 0x3f6f }, { 10079, 0xbafb }, { 10091, 0xdf7f }, { 10105, 0xfbef },
+  { 10119, 0x7d1b }, { 10129, 0x2eec }, { 10138, 0xaf8e }, { 10148, 0xf2f7 },
+  { 10160, 0x7b0f }, { 10170, 0xcfee }, { 10182, 0x1d96 }, { 10190, 0x77c6 },
+  { 10200, 0x7e07 }, { 10209, 0xfff5 }, { 10223, 0xd982 }, { 10230, 0x7fdf },
+  /* 0x8900 */
+  { 10244, 0x5ee6 }, { 10254, 0xc7ff }, { 10267, 0xfeee }, { 10280, 0x79ef },
+  { 10292, 0x9a56 }, { 10300, 0xffcf }, { 10314, 0xfe5f }, { 10327, 0xde5e },
+  { 10338, 0x896e }, { 10346, 0xf9e8 }, { 10356, 0xf45e }, { 10366, 0xe6c4 },
+  { 10374, 0x0001 }, { 10375, 0xbe7c }, { 10386, 0x3b7f }, { 10398, 0xdddf },
+  /* 0x8a00 */
+  { 10411, 0xd59d }, { 10421, 0xe9ef }, { 10433, 0x34ac }, { 10440, 0xde53 },
+  { 10450, 0xf573 }, { 10461, 0x4bf7 }, { 10472, 0x7b4f }, { 10483, 0x9eff },
+  { 10496, 0xb8fe }, { 10507, 0x476e }, { 10516, 0x0dfb }, { 10526, 0xff45 },
+  { 10537, 0xabfd }, { 10549, 0xfbfe }, { 10563, 0xe9d7 }, { 10574, 0xddff },
+  /* 0x8b00 */
+  { 10588, 0xedf7 }, { 10601, 0x7fff }, { 10616, 0xddfd }, { 10629, 0x7eeb },
+  { 10641, 0xcfe7 }, { 10653, 0xb7ff }, { 10667, 0xbde9 }, { 10678, 0xef91 },
+  { 10688, 0x5d75 }, { 10698, 0xd77c }, { 10709, 0x0000 }, { 10709, 0x0000 },
+  { 10709, 0x0000 }, { 10709, 0x0000 }, { 10709, 0x0000 }, { 10709, 0x0000 },
+  /* 0x8c00 */
+  { 10709, 0x0000 }, { 10709, 0x0000 }, { 10709, 0x0000 }, { 10709, 0xfa80 },
+  { 10716, 0xffee }, { 10730, 0xb4f1 }, { 10739, 0xbf76 }, { 10751, 0x2fef },
+  { 10763, 0xb677 }, { 10774, 0x77bf }, { 10787, 0x9fbf }, { 10800, 0xfffd },
+  { 10815, 0x95bf }, { 10826, 0xf6ae }, { 10837, 0x75ff }, { 10850, 0x7f3b },
+  /* 0x8d00 */
+  { 10862, 0xa7f5 }, { 10873, 0x0af9 }, { 10881, 0x0000 }, { 10881, 0x0000 },
+  { 10881, 0x0000 }, { 10881, 0x0000 }, { 10881, 0xfbd0 }, { 10891, 0x2bdd },
+  { 10901, 0xf633 }, { 10911, 0x9a7f }, { 10922, 0xfdab }, { 10934, 0xd6fc },
+  { 10945, 0xf9e6 }, { 10956, 0xbfeb }, { 10969, 0xdfdf }, { 10983, 0xf41f },
+  /* 0x8e00 */
+  { 10993, 0xa6fd }, { 11004, 0xffff }, { 11020, 0x4aff }, { 11031, 0xf37b },
+  { 11043, 0x7fb7 }, { 11056, 0xfef9 }, { 11069, 0xb6ff }, { 11082, 0x1d5c },
+  { 11090, 0x7ff6 }, { 11103, 0xe5ff }, { 11116, 0x1f7b }, { 11127, 0x2404 },
+  { 11130, 0xbe05 }, { 11138, 0xf99e }, { 11149, 0xdbe3 }, { 11160, 0xdff2 },
+  /* 0x8f00 */
+  { 11172, 0x6fef }, { 11185, 0xfdff }, { 11200, 0xd679 }, { 11210, 0xcbfc },
+  { 11221, 0xebfd }, { 11234, 0xefff }, { 11249, 0x001f }, { 11254, 0x0000 },
+  { 11254, 0x0000 }, { 11254, 0x9800 }, { 11257, 0xe148 }, { 11263, 0x8017 },
+  { 11268, 0x6a74 }, { 11276, 0x00fe }, { 11283, 0x6d7f }, { 11295, 0xfdf1 },
+  /* 0x9000 */
+  { 11307, 0xb87f }, { 11318, 0xfef3 }, { 11331, 0xe01f }, { 11339, 0xf176 },
+  { 11349, 0xee96 }, { 11359, 0x7b3f }, { 11371, 0xeb8d }, { 11381, 0xfffd },
+  { 11396, 0xadff }, { 11409, 0xcbb3 }, { 11419, 0x84ef }, { 11428, 0xe17f },
+  { 11439, 0x4daa }, { 11447, 0xbff0 }, { 11458, 0xbf3f }, { 11471, 0xfe3f },
+  /* 0x9100 */
+  { 11484, 0xebff }, { 11498, 0xffd7 }, { 11512, 0xffdf }, { 11527, 0xcf7f },
+  { 11540, 0xfffb }, { 11555, 0x85ed }, { 11564, 0xd73f }, { 11576, 0x07bc },
+  { 11584, 0xaeff }, { 11597, 0xfe0f }, { 11608, 0xfdaf }, { 11621, 0x76bf },
+  { 11633, 0xfaef }, { 11646, 0x37bb }, { 11657, 0x7fdc }, { 11669, 0xa3ba },
+  /* 0x9200 */
+  { 11678, 0xb6ff }, { 11691, 0x56f7 }, { 11702, 0x60f8 }, { 11709, 0xe7df },
+  { 11722, 0xff61 }, { 11733, 0x4cdf }, { 11743, 0xb0fb }, { 11753, 0xff45 },
+  { 11764, 0x7ded }, { 11776, 0x3ffa }, { 11788, 0x1fff }, { 11801, 0x18fc },
+  { 11809, 0xffff }, { 11825, 0xe3af }, { 11836, 0xc7d3 }, { 11846, 0xdf83 },
+  /* 0x9300 */
+  { 11856, 0xfb57 }, { 11868, 0xef7d }, { 11881, 0xefff }, { 11896, 0x1378 },
+  { 11903, 0xfec0 }, { 11912, 0x5ff7 }, { 11925, 0x34bb }, { 11934, 0x5ee3 },
+  { 11944, 0xf70d }, { 11954, 0xeff6 }, { 11967, 0xd7fe }, { 11980, 0x00bf },
+  { 11987, 0xf59d }, { 11998, 0xf7f7 }, { 12012, 0x51de }, { 12021, 0xffe0 },
+  /* 0x9400 */
+  { 12032, 0xfec9 }, { 12043, 0x037f }, { 12052, 0x5f01 }, { 12059, 0xbfef },
+  { 12073, 0x9ff1 }, { 12084, 0x60a7 }, { 12091, 0xef1d }, { 12102, 0xf1ff },
+  { 12115, 0x000f }, { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 },
+  { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 },
+  /* 0x9500 */
+  { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 },
+  { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x0000 }, { 12119, 0x3c80 },
+  { 12124, 0xfb4d }, { 12135, 0xd91f }, { 12145, 0x7b3a }, { 12155, 0xfee3 },
+  { 12167, 0x3fe9 }, { 12178, 0xdc7f }, { 12190, 0x003f }, { 12196, 0x0000 },
+  /* 0x9600 */
+  { 12196, 0x0000 }, { 12196, 0x5000 }, { 12198, 0xf51f }, { 12209, 0xbe07 },
+  { 12218, 0xfc1d }, { 12228, 0xf91b }, { 12238, 0xbc1e }, { 12247, 0x71ff },
+  { 12259, 0x6ff9 }, { 12271, 0x5bbe }, { 12282, 0x5796 }, { 12291, 0x9b1b },
+  { 12300, 0x7fff }, { 12315, 0xfffc }, { 12329, 0x872e }, { 12337, 0xafe7 },
+  /* 0x9700 */
+  { 12349, 0xebf5 }, { 12361, 0xf34f }, { 12372, 0xdffd }, { 12386, 0xe725 },
+  { 12395, 0x0bdc }, { 12403, 0x5d44 }, { 12410, 0x5747 }, { 12419, 0xfddd },
+  { 12432, 0xed3f }, { 12444, 0x7790 }, { 12452, 0x7d7f }, { 12465, 0x8ac8 },
+  { 12471, 0xfafa }, { 12483, 0xf3f9 }, { 12495, 0x202a }, { 12499, 0xef4b },
+  /* 0x9800 */
+  { 12510, 0xf5ff }, { 12524, 0x79cf }, { 12535, 0xabd3 }, { 12545, 0x0ba5 },
+  { 12552, 0xf77a }, { 12564, 0xfb8f }, { 12576, 0x8ebd }, { 12586, 0x001f },
+  { 12591, 0x0000 }, { 12591, 0x0000 }, { 12591, 0xf300 }, { 12597, 0xfd4e },
+  { 12608, 0x1a57 }, { 12616, 0x8800 }, { 12618, 0xaeac }, { 12627, 0x7654 },
+  /* 0x9900 */
+  { 12635, 0x17ad }, { 12644, 0xcdff }, { 12657, 0xffb2 }, { 12669, 0xf42f },
+  { 12679, 0x5baa }, { 12688, 0xdbff }, { 12702, 0x0002 }, { 12703, 0x0000 },
+  { 12703, 0x0000 }, { 12703, 0x73c0 }, { 12710, 0xf9ea }, { 12721, 0x2e3f },
+  { 12731, 0xfa8e }, { 12741, 0xbbff }, { 12755, 0x76bc }, { 12765, 0xffd3 },
+  /* 0x9a00 */
+  { 12778, 0xeefe }, { 12791, 0x7e72 }, { 12801, 0x7ebd }, { 12813, 0xe7f7 },
+  { 12826, 0xf77f }, { 12840, 0xcefd }, { 12852, 0x0ff5 }, { 12862, 0x0000 },
+  { 12862, 0x0000 }, { 12862, 0x0000 }, { 12862, 0xa900 }, { 12866, 0xdb9b },
+  { 12877, 0xa4c7 }, { 12885, 0x917f }, { 12895, 0xf8ca }, { 12904, 0x7ece },
+  /* 0x9b00 */
+  { 12915, 0x7d7a }, { 12926, 0xc7e7 }, { 12937, 0xcbbd }, { 12948, 0xdcae },
+  { 12958, 0xfd7e }, { 12971, 0x8f76 }, { 12981, 0x91d3 }, { 12989, 0x7cf3 },
+  { 13000, 0x01e5 }, { 13006, 0x4c2f }, { 13014, 0xed77 }, { 13026, 0xa360 },
+  { 13032, 0x07db }, { 13041, 0x5ef8 }, { 13051, 0x1df7 }, { 13062, 0x2181 },
+  /* 0x9c00 */
+  { 13066, 0x6be0 }, { 13074, 0x309c }, { 13080, 0x3b3a }, { 13089, 0xfade },
+  { 13101, 0x7f53 }, { 13112, 0xc3f5 }, { 13122, 0x61cd }, { 13130, 0x07ba },
+  { 13138, 0x0000 }, { 13138, 0x0000 }, { 13138, 0x0000 }, { 13138, 0x0000 },
+  { 13138, 0x0000 }, { 13138, 0x0000 }, { 13138, 0x26e0 }, { 13144, 0xbefe },
+  /* 0x9d00 */
+  { 13157, 0x03f9 }, { 13165, 0xebb5 }, { 13176, 0xe36d }, { 13186, 0xe9cb },
+  { 13196, 0x9c2f }, { 13205, 0xbfde }, { 13218, 0x9f83 }, { 13227, 0xabbf },
+  { 13239, 0x1ff7 }, { 13251, 0xffd5 }, { 13264, 0xb7df }, { 13277, 0xdffe },
+  { 13291, 0xfdae }, { 13303, 0xffef }, { 13318, 0xfb7e }, { 13331, 0xeffd },
+  /* 0x9e00 */
+  { 13345, 0xaaff }, { 13357, 0x6ebf }, { 13369, 0x0000 }, { 13369, 0x0000 },
+  { 13369, 0x0000 }, { 13369, 0x0000 }, { 13369, 0x0000 }, { 13369, 0xb620 },
+  { 13375, 0x7fcd }, { 13387, 0xbe9e }, { 13398, 0x62b3 }, { 13406, 0x58f1 },
+  { 13414, 0xf10d }, { 13422, 0xfd7b }, { 13435, 0xe9f1 }, { 13445, 0xbefd },
+  /* 0x9f00 */
+  { 13458, 0xc6c3 }, { 13466, 0x5f6d }, { 13477, 0xff3d }, { 13490, 0x69ff },
+  { 13502, 0xffcf }, { 13516, 0xfbf4 }, { 13528, 0xdcfb }, { 13540, 0x4ff7 },
+  { 13552, 0x2000 }, { 13553, 0x1137 }, { 13560, 0x0015 },
+};
+static const Summary16 big5_uni2indx_pagefa[1] = {
+  /* 0xfa00 */
+  { 13563, 0x3000 },
+};
+static const Summary16 big5_uni2indx_pagefe[23] = {
+  /* 0xfe00 */
+  { 13565, 0x0000 }, { 13565, 0x0000 }, { 13565, 0x0000 }, { 13565, 0xfffb },
+  { 13580, 0xfe1f }, { 13592, 0xfef5 }, { 13605, 0x0e7f }, { 13615, 0x0000 },
+  { 13615, 0x0000 }, { 13615, 0x0000 }, { 13615, 0x0000 }, { 13615, 0x0000 },
+  { 13615, 0x0000 }, { 13615, 0x0000 }, { 13615, 0x0000 }, { 13615, 0x0000 },
+  /* 0xff00 */
+  { 13615, 0xff7a }, { 13628, 0xffff }, { 13644, 0xffff }, { 13660, 0x97ff },
+  { 13673, 0xfffe }, { 13688, 0x3fff }, { 13702, 0x0010 },
+};
+
+static int
+big5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  if (n >= 2) {
+    const Summary16 *summary = NULL;
+    if (wc >= 0x0000 && wc < 0x0100)
+      summary = &big5_uni2indx_page00[(wc>>4)];
+    else if (wc >= 0x0200 && wc < 0x0460)
+      summary = &big5_uni2indx_page02[(wc>>4)-0x020];
+    else if (wc >= 0x2000 && wc < 0x22c0)
+      summary = &big5_uni2indx_page20[(wc>>4)-0x200];
+    else if (wc >= 0x2400 && wc < 0x2650)
+      summary = &big5_uni2indx_page24[(wc>>4)-0x240];
+    else if (wc >= 0x3000 && wc < 0x33e0)
+      summary = &big5_uni2indx_page30[(wc>>4)-0x300];
+    else if (wc >= 0x4e00 && wc < 0x9fb0)
+      summary = &big5_uni2indx_page4e[(wc>>4)-0x4e0];
+    else if (wc >= 0xfa00 && wc < 0xfa10)
+      summary = &big5_uni2indx_pagefa[(wc>>4)-0xfa0];
+    else if (wc >= 0xfe00 && wc < 0xff70)
+      summary = &big5_uni2indx_pagefe[(wc>>4)-0xfe0];
+    if (summary) {
+      unsigned short used = summary->used;
+      unsigned int i = wc & 0x0f;
+      if (used & ((unsigned short) 1 << i)) {
+        unsigned short c;
+        /* Keep in `used' only the bits 0..i-1. */
+        used &= ((unsigned short) 1 << i) - 1;
+        /* Add `summary->indx' and the number of bits set in `used'. */
+        used = (used & 0x5555) + ((used & 0xaaaa) >> 1);
+        used = (used & 0x3333) + ((used & 0xcccc) >> 2);
+        used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);
+        used = (used & 0x00ff) + (used >> 8);
+        c = big5_2charset[summary->indx + used];
+        r[0] = (c >> 8); r[1] = (c & 0xff);
+        return 2;
+      }
+    }
+    return RET_ILSEQ;
+  }
+  return RET_TOOSMALL;
+}
Index: xc/lib/X11/lcUniConv/big5_emacs.h
diff -u /dev/null xc/lib/X11/lcUniConv/big5_emacs.h:1.1
--- /dev/null	Mon Dec 18 14:24:01 2000
+++ xc/lib/X11/lcUniConv/big5_emacs.h	Tue Nov 28 13:50:06 2000
@@ -0,0 +1,164 @@
+/* $XFree86: xc/lib/X11/lcUniConv/big5_emacs.h,v 1.1 2000/11/28 18:50:06 dawes Exp $ */
+
+/*
+ * BIG5-0 and BIG5-1
+ */
+
+/*
+   BIG5 with its 13494 characters doesn't fit in a single 94x94 or 96x96
+   block. Therefore Emacs/Mule developers, in a typically Japanese way of
+   thinking, have developed an alternative encoding of BIG5 in two 94x94
+   planes, very similar to the SHIFT_JIS encoding for JISX0208.
+
+   Conversion between BIG5 codes (s1,s2) and BIG5-0 codes (c1,c2):
+   Example. (s1,s2) = 0xA140, (c1,c2) = 0x2121.
+   0xA1 <= s1 <= 0xC7, 0x40 <= s2 <= 0x7E || 0xA1 <= s2 <= 0xFE,
+   0x21 <= c1 <= 0x62, 0x21 <= c2 <= 0x7E.
+   Invariant:
+     157*(s1-0xA1) + (s2 < 0x80 ? s2-0x40 : s2-0x62)
+     = 94*(c1-0x21)+(c2-0x21)
+   Conversion (s1,s2) -> (c1,c2):
+     t := 157*(s1-0xA1) + (s2 < 0x80 ? s2-0x40 : s2-0x62)
+     c1 := (t div 94) + 0x21
+     c2 := (t mod 94) + 0x21
+   Conversion (c1,c2) -> (s1,s2):
+     t := 94*(c1-0x21)+(c2-0x21)
+     t2 := t mod 157
+     s1 := (t div 157) + 0xA1
+     s2 := (t2 < 0x3F ? t2+0x40 : t2+0x62)
+
+   Conversion between BIG5 codes (s1,s2) and BIG5-1 codes (c1,c2):
+   Example. (s1,s2) = 0xC940, (c1,c2) = 0x2121.
+   0xC9 <= s1 <= 0xF9, 0x40 <= s2 <= 0x7E || 0xA1 <= s2 <= 0xFE,
+   0x21 <= c1 <= 0x72, 0x21 <= c2 <= 0x7E.
+   Invariant:
+     157*(s1-0xC9) + (s2 < 0x80 ? s2-0x40 : s2-0x62)
+     = 94*(c1-0x21)+(c2-0x21)
+   Conversion (s1,s2) -> (c1,c2):
+     t := 157*(s1-0xC9) + (s2 < 0x80 ? s2-0x40 : s2-0x62)
+     c1 := (t div 94) + 0x21
+     c2 := (t mod 94) + 0x21
+   Conversion (c1,c2) -> (s1,s2):
+     t := 94*(c1-0x21)+(c2-0x21)
+     t2 := t mod 157
+     s1 := (t div 157) + 0xC9
+     s2 := (t2 < 0x3F ? t2+0x40 : t2+0x62)
+ */
+
+static int
+big5_0_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  unsigned char c1 = s[0];
+  if (c1 >= 0x21 && c1 <= 0x62) {
+    if (n >= 2) {
+      unsigned char c2 = s[1];
+      if (c2 >= 0x21 && c2 <= 0x7e) {
+        unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21);
+        if (0) {
+          /* Unoptimized. */
+          unsigned char buf[2];
+          buf[0] = (i / 157) + 0xa1;
+          i = i % 157;
+          buf[1] = i + (i < 0x3f ? 0x40 : 0x62);
+          return big5_mbtowc(conv,pwc,buf,2);
+        } else {
+          /* Inline the implementation of big5_mbtowc. */
+          if (i < 6121) {
+            unsigned short wc = big5_2uni_pagea1[i];
+            if (wc != 0xfffd) {
+              *pwc = (ucs4_t) wc;
+              return 2;
+            }
+          }
+        }
+      }
+      return RET_ILSEQ;
+    }
+    return RET_TOOFEW(0);
+  }
+  return RET_ILSEQ;
+}
+
+static int
+big5_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  unsigned char c1 = s[0];
+  if (c1 >= 0x21 && c1 <= 0x72) {
+    if (n >= 2) {
+      unsigned char c2 = s[1];
+      if (c2 >= 0x21 && c2 <= 0x7e) {
+        unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21);
+        if (0) {
+          /* Unoptimized. */
+          unsigned char buf[2];
+          buf[0] = (i / 157) + 0xc9;
+          i = i % 157;
+          buf[1] = i + (i < 0x3f ? 0x40 : 0x62);
+          return big5_mbtowc(conv,pwc,buf,2);
+        } else {
+          /* Inline the implementation of big5_mbtowc. */
+          if (i < 7652) {
+            unsigned short wc = big5_2uni_pagec9[i];
+            if (wc != 0xfffd) {
+              *pwc = (ucs4_t) wc;
+              return 2;
+            }
+          }
+        }
+      }
+      return RET_ILSEQ;
+    }
+    return RET_TOOFEW(0);
+  }
+  return RET_ILSEQ;
+}
+
+static int
+big5_0_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  if (n >= 2) {
+    unsigned char buf[2];
+    int ret = big5_wctomb(conv,buf,wc,2);
+    if (ret != RET_ILSEQ) {
+      unsigned char s1, s2;
+      if (ret != 2) abort();
+      s1 = buf[0];
+      s2 = buf[1];
+      if (!(s1 >= 0xa1)) abort();
+      if (!((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0xa1 && s2 <= 0xfe))) abort();
+      if (s1 < 0xc9) {
+        unsigned int t = 157 * (s1 - 0xa1) + s2 - (s2 < 0x80 ? 0x40 : 0x62);
+        r[0] = (t / 94) + 0x21;
+        r[1] = (t % 94) + 0x21;
+        return 2;
+      }
+    }
+    return RET_ILSEQ;
+  }
+  return RET_TOOSMALL;
+}
+
+static int
+big5_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  if (n >= 2) {
+    unsigned char buf[2];
+    int ret = big5_wctomb(conv,buf,wc,2);
+    if (ret != RET_ILSEQ) {
+      unsigned char s1, s2;
+      if (ret != 2) abort();
+      s1 = buf[0];
+      s2 = buf[1];
+      if (!(s1 <= 0xf9)) abort();
+      if (!((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0xa1 && s2 <= 0xfe))) abort();
+      if (s1 >= 0xc9) {
+        unsigned int t = 157 * (s1 - 0xc9) + s2 - (s2 < 0x80 ? 0x40 : 0x62);
+        r[0] = (t / 94) + 0x21;
+        r[1] = (t % 94) + 0x21;
+        return 2;
+      }
+    }
+    return RET_ILSEQ;
+  }
+  return RET_TOOSMALL;
+}
Index: xc/lib/X11/lcUniConv/cjk_tab_to_h.c
diff -u xc/lib/X11/lcUniConv/cjk_tab_to_h.c:1.1 xc/lib/X11/lcUniConv/cjk_tab_to_h.c:1.2
--- xc/lib/X11/lcUniConv/cjk_tab_to_h.c:1.1	Fri Feb 11 21:54:21 2000
+++ xc/lib/X11/lcUniConv/cjk_tab_to_h.c	Mon Dec  4 13:49:31 2000
@@ -1,3 +1,5 @@
+/* $XFree86: xc/lib/X11/lcUniConv/cjk_tab_to_h.c,v 1.2 2000/12/04 18:49:31 dawes Exp $ */
+
 /*
  * Generates a CJK character set table from a .TXT table as found on
  * ftp.unicode.org or in the X nls directory.
@@ -202,7 +204,7 @@
   printf("\n");
 
   printf("static int\n");
-  printf("%s_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)\n", name);
+  printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", name);
   printf("{\n");
   printf("  unsigned char c1 = s[0];\n");
   printf("  if (");
@@ -243,7 +245,7 @@
   }
   printf("        }\n");
   printf("        if (wc != 0xfffd) {\n");
-  printf("          *pwc = (wchar_t) wc;\n");
+  printf("          *pwc = (ucs4_t) wc;\n");
   printf("          return 2;\n");
   printf("        }\n");
   printf("      }\n");
@@ -355,7 +357,7 @@
     if (p >= 0)
       printf("\n");
   }
-  printf("static int\n%s_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)\n", name);
+  printf("static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name);
   printf("{\n");
   printf("  if (n >= 2) {\n");
   printf("    unsigned short c = 0;\n");
@@ -494,7 +496,7 @@
   printf("\n");
 
   printf("static int\n");
-  printf("%s_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)\n", name);
+  printf("%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name);
   printf("{\n");
   printf("  if (n >= 2) {\n");
   printf("    const Summary16 *summary = NULL;\n");
Index: xc/lib/X11/lcUniConv/cp1133.h
diff -u xc/lib/X11/lcUniConv/cp1133.h:1.1 xc/lib/X11/lcUniConv/cp1133.h:1.3
--- xc/lib/X11/lcUniConv/cp1133.h:1.1	Fri Feb 11 21:54:21 2000
+++ xc/lib/X11/lcUniConv/cp1133.h	Wed Nov 29 12:40:28 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/cp1133.h,v 1.3 2000/11/29 17:40:28 dawes Exp $ */
 
 /*
  * IBM-CP1133
@@ -24,17 +25,17 @@
 };
 
 static int
-cp1133_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+cp1133_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
     return 1;
   }
   else if (c < 0xe0) {
     unsigned short wc = cp1133_2uni_1[c-0xa0];
     if (wc != 0xfffd) {
-      *pwc = (wchar_t) wc;
+      *pwc = (ucs4_t) wc;
       return 1;
     }
   }
@@ -43,7 +44,7 @@
   else {
     unsigned short wc = cp1133_2uni_2[c-0xf0];
     if (wc != 0xfffd) {
-      *pwc = (wchar_t) wc;
+      *pwc = (ucs4_t) wc;
       return 1;
     }
   }
@@ -70,7 +71,7 @@
 };
 
 static int
-cp1133_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+cp1133_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/cp1251.h
diff -u /dev/null xc/lib/X11/lcUniConv/cp1251.h:1.1
--- /dev/null	Mon Dec 18 14:24:02 2000
+++ xc/lib/X11/lcUniConv/cp1251.h	Mon Dec  4 13:49:32 2000
@@ -0,0 +1,113 @@
+/* $XFree86: xc/lib/X11/lcUniConv/cp1251.h,v 1.1 2000/12/04 18:49:32 dawes Exp $ */
+
+/*
+ * CP1251
+ */
+
+static const unsigned short cp1251_2uni[128] = {
+  /* 0x80 */
+  0x0402, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021,
+  0x20ac, 0x2030, 0x0409, 0x2039, 0x040a, 0x040c, 0x040b, 0x040f,
+  /* 0x90 */
+  0x0452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+  0xfffd, 0x2122, 0x0459, 0x203a, 0x045a, 0x045c, 0x045b, 0x045f,
+  /* 0xa0 */
+  0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7,
+  0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407,
+  /* 0xb0 */
+  0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7,
+  0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457,
+  /* 0xc0 */
+  0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+  0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
+  /* 0xd0 */
+  0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+  0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
+  /* 0xe0 */
+  0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+  0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
+  /* 0xf0 */
+  0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+  0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
+};
+
+static int
+cp1251_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  unsigned char c = *s;
+  if (c < 0x80) {
+    *pwc = (ucs4_t) c;
+    return 1;
+  }
+  else {
+    unsigned short wc = cp1251_2uni[c-0x80];
+    if (wc != 0xfffd) {
+      *pwc = (ucs4_t) wc;
+      return 1;
+    }
+  }
+  return RET_ILSEQ;
+}
+
+static const unsigned char cp1251_page00[32] = {
+  0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */
+  0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
+  0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+  0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+};
+static const unsigned char cp1251_page04[152] = {
+  0x00, 0xa8, 0x80, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */
+  0xa3, 0x8a, 0x8c, 0x8e, 0x8d, 0x00, 0xa1, 0x8f, /* 0x08-0x0f */
+  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */
+  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */
+  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */
+  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */
+  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */
+  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */
+  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */
+  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */
+  0x00, 0xb8, 0x90, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */
+  0xbc, 0x9a, 0x9c, 0x9e, 0x9d, 0x00, 0xa2, 0x9f, /* 0x58-0x5f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+  0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+};
+static const unsigned char cp1251_page20[48] = {
+  0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+  0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+  0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+  0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+  0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+
+static int
+cp1251_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  unsigned char c = 0;
+  if (wc < 0x0080) {
+    *r = wc;
+    return 1;
+  }
+  else if (wc >= 0x00a0 && wc < 0x00c0)
+    c = cp1251_page00[wc-0x00a0];
+  else if (wc >= 0x0400 && wc < 0x0498)
+    c = cp1251_page04[wc-0x0400];
+  else if (wc >= 0x2010 && wc < 0x2040)
+    c = cp1251_page20[wc-0x2010];
+  else if (wc == 0x20ac)
+    c = 0x88;
+  else if (wc == 0x2116)
+    c = 0xb9;
+  else if (wc == 0x2122)
+    c = 0x99;
+  if (c != 0) {
+    *r = c;
+    return 1;
+  }
+  return RET_ILSEQ;
+}
Index: xc/lib/X11/lcUniConv/cp1255.h
diff -u /dev/null xc/lib/X11/lcUniConv/cp1255.h:1.1
--- /dev/null	Mon Dec 18 14:24:02 2000
+++ xc/lib/X11/lcUniConv/cp1255.h	Mon Dec  4 13:49:33 2000
@@ -0,0 +1,121 @@
+/* $XFree86: xc/lib/X11/lcUniConv/cp1255.h,v 1.1 2000/12/04 18:49:33 dawes Exp $ */
+
+/*
+ * CP1255
+ */
+
+static const unsigned short cp1255_2uni[128] = {
+  /* 0x80 */
+  0x20ac, 0xfffd, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
+  0x02c6, 0x2030, 0xfffd, 0x2039, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  /* 0x90 */
+  0xfffd, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+  0x02dc, 0x2122, 0xfffd, 0x203a, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  /* 0xa0 */
+  0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20aa, 0x00a5, 0x00a6, 0x00a7,
+  0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+  /* 0xb0 */
+  0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+  0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
+  /* 0xc0 */
+  0x05b0, 0x05b1, 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7,
+  0x05b8, 0x05b9, 0xfffd, 0x05bb, 0x05bc, 0x05bd, 0x05be, 0x05bf,
+  /* 0xd0 */
+  0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f0, 0x05f1, 0x05f2, 0x05f3,
+  0x05f4, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
+  /* 0xe0 */
+  0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
+  0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
+  /* 0xf0 */
+  0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
+  0x05e8, 0x05e9, 0x05ea, 0xfffd, 0xfffd, 0x200e, 0x200f, 0xfffd,
+};
+
+static int
+cp1255_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  unsigned char c = *s;
+  if (c < 0x80) {
+    *pwc = (ucs4_t) c;
+    return 1;
+  }
+  else {
+    unsigned short wc = cp1255_2uni[c-0x80];
+    if (wc != 0xfffd) {
+      *pwc = (ucs4_t) wc;
+      return 1;
+    }
+  }
+  return RET_ILSEQ;
+}
+
+static const unsigned char cp1255_page00[88] = {
+  0xa0, 0xa1, 0xa2, 0xa3, 0x00, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */
+  0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */
+  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+  0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* 0xb8-0xbf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, /* 0xd0-0xd7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, /* 0xf0-0xf7 */
+};
+static const unsigned char cp1255_page02[32] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, /* 0xc0-0xc7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+  0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+};
+static const unsigned char cp1255_page05[72] = {
+  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xb0-0xb7 */
+  0xc8, 0xc9, 0x00, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xb8-0xbf */
+  0xd0, 0xd1, 0xd2, 0xd3, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xd0-0xd7 */
+  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xd8-0xdf */
+  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xe0-0xe7 */
+  0xf8, 0xf9, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+  0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
+};
+static const unsigned char cp1255_page20[56] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xfe, /* 0x08-0x0f */
+  0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+  0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+  0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+  0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+  0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+
+static int
+cp1255_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  unsigned char c = 0;
+  if (wc < 0x0080) {
+    *r = wc;
+    return 1;
+  }
+  else if (wc >= 0x00a0 && wc < 0x00f8)
+    c = cp1255_page00[wc-0x00a0];
+  else if (wc == 0x0192)
+    c = 0x83;
+  else if (wc >= 0x02c0 && wc < 0x02e0)
+    c = cp1255_page02[wc-0x02c0];
+  else if (wc >= 0x05b0 && wc < 0x05f8)
+    c = cp1255_page05[wc-0x05b0];
+  else if (wc >= 0x2008 && wc < 0x2040)
+    c = cp1255_page20[wc-0x2008];
+  else if (wc == 0x20aa)
+    c = 0xa4;
+  else if (wc == 0x20ac)
+    c = 0x80;
+  else if (wc == 0x2122)
+    c = 0x99;
+  if (c != 0) {
+    *r = c;
+    return 1;
+  }
+  return RET_ILSEQ;
+}
Index: xc/lib/X11/lcUniConv/cp1256.h
diff -u /dev/null xc/lib/X11/lcUniConv/cp1256.h:1.1
--- /dev/null	Mon Dec 18 14:24:02 2000
+++ xc/lib/X11/lcUniConv/cp1256.h	Mon Dec  4 13:49:34 2000
@@ -0,0 +1,135 @@
+/* $XFree86: xc/lib/X11/lcUniConv/cp1256.h,v 1.1 2000/12/04 18:49:34 dawes Exp $ */
+
+/*
+ * CP1256
+ */
+
+static const unsigned short cp1256_2uni[128] = {
+  /* 0x80 */
+  0x20ac, 0x067e, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
+  0x02c6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
+  /* 0x90 */
+  0x06af, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+  0x06a9, 0x2122, 0x0691, 0x203a, 0x0153, 0x200c, 0x200d, 0x06ba,
+  /* 0xa0 */
+  0x00a0, 0x060c, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
+  0x00a8, 0x00a9, 0x06be, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+  /* 0xb0 */
+  0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+  0x00b8, 0x00b9, 0x061b, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x061f,
+  /* 0xc0 */
+  0x06c1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
+  0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
+  /* 0xd0 */
+  0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00d7,
+  0x0637, 0x0638, 0x0639, 0x063a, 0x0640, 0x0641, 0x0642, 0x0643,
+  /* 0xe0 */
+  0x00e0, 0x0644, 0x00e2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00e7,
+  0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x0649, 0x064a, 0x00ee, 0x00ef,
+  /* 0xf0 */
+  0x064b, 0x064c, 0x064d, 0x064e, 0x00f4, 0x064f, 0x0650, 0x00f7,
+  0x0651, 0x00f9, 0x0652, 0x00fb, 0x00fc, 0x200e, 0x200f, 0x06d2,
+};
+
+static int
+cp1256_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  unsigned char c = *s;
+  if (c < 0x80)
+    *pwc = (ucs4_t) c;
+  else
+    *pwc = (ucs4_t) cp1256_2uni[c-0x80];
+  return 1;
+}
+
+static const unsigned char cp1256_page00[96] = {
+  0xa0, 0x00, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xa0-0xa7 */
+  0xa8, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0xa8-0xaf */
+  0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+  0xb8, 0xb9, 0x00, 0xbb, 0xbc, 0xbd, 0xbe, 0x00, /* 0xb8-0xbf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd7, /* 0xd0-0xd7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+  0xe0, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x00, 0xe7, /* 0xe0-0xe7 */
+  0xe8, 0xe9, 0xea, 0xeb, 0x00, 0x00, 0xee, 0xef, /* 0xe8-0xef */
+  0x00, 0x00, 0x00, 0x00, 0xf4, 0x00, 0x00, 0xf7, /* 0xf0-0xf7 */
+  0x00, 0xf9, 0x00, 0xfb, 0xfc, 0x00, 0x00, 0x00, /* 0xf8-0xff */
+};
+static const unsigned char cp1256_page01[72] = {
+  0x00, 0x00, 0x8c, 0x9c, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+  0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+};
+static const unsigned char cp1256_page06[208] = {
+  0x00, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, /* 0x08-0x0f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+  0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0xbf, /* 0x18-0x1f */
+  0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x20-0x27 */
+  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x28-0x2f */
+  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd8, /* 0x30-0x37 */
+  0xd9, 0xda, 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+  0xdc, 0xdd, 0xde, 0xdf, 0xe1, 0xe3, 0xe4, 0xe5, /* 0x40-0x47 */
+  0xe6, 0xec, 0xed, 0xf0, 0xf1, 0xf2, 0xf3, 0xf5, /* 0x48-0x4f */
+  0xf6, 0xf8, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+  0x00, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, /* 0x78-0x7f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8d, 0x00, /* 0x80-0x87 */
+  0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+  0x00, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+  0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+  0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, /* 0xa8-0xaf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+  0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0xaa, 0x00, /* 0xb8-0xbf */
+  0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+  0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+};
+static const unsigned char cp1256_page20[56] = {
+  0x00, 0x00, 0x00, 0x00, 0x9d, 0x9e, 0xfd, 0xfe, /* 0x08-0x0f */
+  0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+  0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+  0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+  0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+  0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+
+static int
+cp1256_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  unsigned char c = 0;
+  if (wc < 0x0080) {
+    *r = wc;
+    return 1;
+  }
+  else if (wc >= 0x00a0 && wc < 0x0100)
+    c = cp1256_page00[wc-0x00a0];
+  else if (wc >= 0x0150 && wc < 0x0198)
+    c = cp1256_page01[wc-0x0150];
+  else if (wc == 0x02c6)
+    c = 0x88;
+  else if (wc >= 0x0608 && wc < 0x06d8)
+    c = cp1256_page06[wc-0x0608];
+  else if (wc >= 0x2008 && wc < 0x2040)
+    c = cp1256_page20[wc-0x2008];
+  else if (wc == 0x20ac)
+    c = 0x80;
+  else if (wc == 0x2122)
+    c = 0x99;
+  if (c != 0) {
+    *r = c;
+    return 1;
+  }
+  return RET_ILSEQ;
+}
Index: xc/lib/X11/lcUniConv/gb2312.h
diff -u xc/lib/X11/lcUniConv/gb2312.h:1.1 xc/lib/X11/lcUniConv/gb2312.h:1.3
--- xc/lib/X11/lcUniConv/gb2312.h:1.1	Fri Feb 11 21:54:21 2000
+++ xc/lib/X11/lcUniConv/gb2312.h	Wed Nov 29 12:40:28 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/gb2312.h,v 1.3 2000/11/29 17:40:28 dawes Exp $ */
 
 /*
  * GB2312.1980-0
@@ -1060,7 +1061,7 @@
 };
 
 static int
-gb2312_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+gb2312_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x29) || (c1 >= 0x30 && c1 <= 0x77)) {
@@ -1077,7 +1078,7 @@
             wc = gb2312_2uni_page30[i-1410];
         }
         if (wc != 0xfffd) {
-          *pwc = (wchar_t) wc;
+          *pwc = (ucs4_t) wc;
           return 2;
         }
       }
@@ -2513,7 +2514,7 @@
 };
 
 static int
-gb2312_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+gb2312_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
Index: xc/lib/X11/lcUniConv/georgian_academy.h
diff -u xc/lib/X11/lcUniConv/georgian_academy.h:1.1 xc/lib/X11/lcUniConv/georgian_academy.h:1.3
--- xc/lib/X11/lcUniConv/georgian_academy.h:1.1	Fri Feb 11 21:54:22 2000
+++ xc/lib/X11/lcUniConv/georgian_academy.h	Wed Nov 29 12:40:29 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/georgian_academy.h,v 1.3 2000/11/29 17:40:29 dawes Exp $ */
 
 /*
  * GEORGIAN-ACADEMY
@@ -13,15 +14,15 @@
 };
 
 static int
-georgian_academy_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+georgian_academy_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c >= 0x80 && c < 0xa0)
-    *pwc = (wchar_t) georgian_academy_2uni[c-0x80];
+    *pwc = (ucs4_t) georgian_academy_2uni[c-0x80];
   else if (c >= 0xc0 && c < 0xe7)
-    *pwc = (wchar_t) c + 0x1010;
+    *pwc = (ucs4_t) c + 0x1010;
   else
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   return 1;
 }
 
@@ -58,7 +59,7 @@
 };
 
 static int
-georgian_academy_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+georgian_academy_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
Index: xc/lib/X11/lcUniConv/georgian_ps.h
diff -u xc/lib/X11/lcUniConv/georgian_ps.h:1.1 xc/lib/X11/lcUniConv/georgian_ps.h:1.3
--- xc/lib/X11/lcUniConv/georgian_ps.h:1.1	Fri Feb 11 21:54:22 2000
+++ xc/lib/X11/lcUniConv/georgian_ps.h	Wed Nov 29 12:40:29 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/georgian_ps.h,v 1.3 2000/11/29 17:40:29 dawes Exp $ */
 
 /*
  * GEORGIAN-PS
@@ -23,15 +24,15 @@
 };
 
 static int
-georgian_ps_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+georgian_ps_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c >= 0x80 && c < 0xa0)
-    *pwc = (wchar_t) georgian_ps_2uni_1[c-0x80];
+    *pwc = (ucs4_t) georgian_ps_2uni_1[c-0x80];
   else if (c >= 0xc0 && c < 0xe6)
-    *pwc = (wchar_t) georgian_ps_2uni_2[c-0xc0];
+    *pwc = (ucs4_t) georgian_ps_2uni_2[c-0xc0];
   else
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   return 1;
 }
 
@@ -75,7 +76,7 @@
 };
 
 static int
-georgian_ps_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+georgian_ps_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
Index: xc/lib/X11/lcUniConv/iso8859_1.h
diff -u xc/lib/X11/lcUniConv/iso8859_1.h:1.1 xc/lib/X11/lcUniConv/iso8859_1.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_1.h:1.1	Fri Feb 11 21:54:22 2000
+++ xc/lib/X11/lcUniConv/iso8859_1.h	Wed Nov 29 12:40:30 2000
@@ -1,18 +1,19 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_1.h,v 1.3 2000/11/29 17:40:30 dawes Exp $ */
 
 /*
  * ISO-8859-1
  */
 
 static int
-iso8859_1_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
-  *pwc = (wchar_t) c;
+  *pwc = (ucs4_t) c;
   return 1;
 }
 
 static int
-iso8859_1_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   if (wc < 0x0100) {
     *r = wc;
Index: xc/lib/X11/lcUniConv/iso8859_10.h
diff -u xc/lib/X11/lcUniConv/iso8859_10.h:1.1 xc/lib/X11/lcUniConv/iso8859_10.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_10.h:1.1	Fri Feb 11 21:54:22 2000
+++ xc/lib/X11/lcUniConv/iso8859_10.h	Wed Nov 29 12:40:30 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_10.h,v 1.3 2000/11/29 17:40:30 dawes Exp $ */
 
 /*
  * ISO-8859-10
@@ -25,13 +26,13 @@
 };
 
 static int
-iso8859_10_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_10_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) iso8859_10_2uni[c-0xa0];
+    *pwc = (ucs4_t) iso8859_10_2uni[c-0xa0];
   return 1;
 }
 
@@ -68,7 +69,7 @@
 };
 
 static int
-iso8859_10_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_10_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_13.h
diff -u xc/lib/X11/lcUniConv/iso8859_13.h:1.1 xc/lib/X11/lcUniConv/iso8859_13.h:1.2
--- xc/lib/X11/lcUniConv/iso8859_13.h:1.1	Fri Jun 23 15:50:59 2000
+++ xc/lib/X11/lcUniConv/iso8859_13.h	Tue Nov 28 11:10:26 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/X11/lcUniConv/iso8859_13.h,v 1.1 2000/06/23 19:50:59 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_13.h,v 1.2 2000/11/28 16:10:26 dawes Exp $ */
 
 /*
  * ISO-8859-13
@@ -26,13 +26,13 @@
 };
 
 static int
-iso8859_13_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_13_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) iso8859_13_2uni[c-0xa0];
+    *pwc = (ucs4_t) iso8859_13_2uni[c-0xa0];
   return 1;
 }
 
@@ -72,7 +72,7 @@
 };
 
 static int
-iso8859_13_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_13_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_14.h
diff -u xc/lib/X11/lcUniConv/iso8859_14.h:1.1 xc/lib/X11/lcUniConv/iso8859_14.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_14.h:1.1	Fri Feb 11 21:54:23 2000
+++ xc/lib/X11/lcUniConv/iso8859_14.h	Wed Nov 29 12:40:30 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_14.h,v 1.3 2000/11/29 17:40:30 dawes Exp $ */
 
 /*
  * ISO-8859-14
@@ -25,13 +26,13 @@
 };
 
 static int
-iso8859_14_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_14_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c >= 0xa0)
-    *pwc = (wchar_t) iso8859_14_2uni[c-0xa0];
+    *pwc = (ucs4_t) iso8859_14_2uni[c-0xa0];
   else
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   return 1;
 }
 
@@ -83,7 +84,7 @@
 };
 
 static int
-iso8859_14_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_14_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_15.h
diff -u xc/lib/X11/lcUniConv/iso8859_15.h:1.1 xc/lib/X11/lcUniConv/iso8859_15.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_15.h:1.1	Fri Feb 11 21:54:23 2000
+++ xc/lib/X11/lcUniConv/iso8859_15.h	Wed Nov 29 12:40:31 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_15.h,v 1.3 2000/11/29 17:40:31 dawes Exp $ */
 
 /*
  * ISO-8859-15
@@ -13,13 +14,13 @@
 };
 
 static int
-iso8859_15_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_15_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c >= 0xa0 && c < 0xc0)
-    *pwc = (wchar_t) iso8859_15_2uni[c-0xa0];
+    *pwc = (ucs4_t) iso8859_15_2uni[c-0xa0];
   else
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   return 1;
 }
 
@@ -39,7 +40,7 @@
 };
 
 static int
-iso8859_15_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_15_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_16.h
diff -u xc/lib/X11/lcUniConv/iso8859_16.h:1.1 xc/lib/X11/lcUniConv/iso8859_16.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_16.h:1.1	Fri Feb 11 21:54:23 2000
+++ xc/lib/X11/lcUniConv/iso8859_16.h	Wed Nov 29 12:40:31 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_16.h,v 1.3 2000/11/29 17:40:31 dawes Exp $ */
 
 /*
  * ISO-8859-16
@@ -25,13 +26,13 @@
 };
 
 static int
-iso8859_16_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_16_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) iso8859_16_2uni[c-0xa0];
+    *pwc = (ucs4_t) iso8859_16_2uni[c-0xa0];
   return 1;
 }
 
@@ -74,7 +75,7 @@
 };
 
 static int
-iso8859_16_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_16_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_2.h
diff -u xc/lib/X11/lcUniConv/iso8859_2.h:1.1 xc/lib/X11/lcUniConv/iso8859_2.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_2.h:1.1	Fri Feb 11 21:54:23 2000
+++ xc/lib/X11/lcUniConv/iso8859_2.h	Wed Nov 29 12:40:31 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_2.h,v 1.3 2000/11/29 17:40:31 dawes Exp $ */
 
 /*
  * ISO-8859-2
@@ -25,13 +26,13 @@
 };
 
 static int
-iso8859_2_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) iso8859_2_2uni[c-0xa0];
+    *pwc = (ucs4_t) iso8859_2_2uni[c-0xa0];
   return 1;
 }
 
@@ -74,7 +75,7 @@
 };
 
 static int
-iso8859_2_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_3.h
diff -u xc/lib/X11/lcUniConv/iso8859_3.h:1.1 xc/lib/X11/lcUniConv/iso8859_3.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_3.h:1.1	Fri Feb 11 21:54:23 2000
+++ xc/lib/X11/lcUniConv/iso8859_3.h	Wed Nov 29 12:40:31 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_3.h,v 1.3 2000/11/29 17:40:31 dawes Exp $ */
 
 /*
  * ISO-8859-3
@@ -25,17 +26,17 @@
 };
 
 static int
-iso8859_3_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_3_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
     return 1;
   }
   else {
     unsigned short wc = iso8859_3_2uni[c-0xa0];
     if (wc != 0xfffd) {
-      *pwc = (wchar_t) wc;
+      *pwc = (ucs4_t) wc;
       return 1;
     }
   }
@@ -78,7 +79,7 @@
 };
 
 static int
-iso8859_3_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_3_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_4.h
diff -u xc/lib/X11/lcUniConv/iso8859_4.h:1.1 xc/lib/X11/lcUniConv/iso8859_4.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_4.h:1.1	Fri Feb 11 21:54:24 2000
+++ xc/lib/X11/lcUniConv/iso8859_4.h	Wed Nov 29 12:40:31 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_4.h,v 1.3 2000/11/29 17:40:31 dawes Exp $ */
 
 /*
  * ISO-8859-4
@@ -25,13 +26,13 @@
 };
 
 static int
-iso8859_4_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_4_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) iso8859_4_2uni[c-0xa0];
+    *pwc = (ucs4_t) iso8859_4_2uni[c-0xa0];
   return 1;
 }
 
@@ -74,7 +75,7 @@
 };
 
 static int
-iso8859_4_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_4_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_5.h
diff -u xc/lib/X11/lcUniConv/iso8859_5.h:1.1 xc/lib/X11/lcUniConv/iso8859_5.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_5.h:1.1	Fri Feb 11 21:54:24 2000
+++ xc/lib/X11/lcUniConv/iso8859_5.h	Wed Nov 29 12:40:32 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_5.h,v 1.3 2000/11/29 17:40:32 dawes Exp $ */
 
 /*
  * ISO-8859-5
@@ -25,13 +26,13 @@
 };
 
 static int
-iso8859_5_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_5_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) iso8859_5_2uni[c-0xa0];
+    *pwc = (ucs4_t) iso8859_5_2uni[c-0xa0];
   return 1;
 }
 
@@ -55,7 +56,7 @@
 };
 
 static int
-iso8859_5_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_5_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_6.h
diff -u xc/lib/X11/lcUniConv/iso8859_6.h:1.1 xc/lib/X11/lcUniConv/iso8859_6.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_6.h:1.1	Fri Feb 11 21:54:24 2000
+++ xc/lib/X11/lcUniConv/iso8859_6.h	Wed Nov 29 12:40:32 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_6.h,v 1.3 2000/11/29 17:40:32 dawes Exp $ */
 
 /*
  * ISO-8859-6
@@ -25,17 +26,17 @@
 };
 
 static int
-iso8859_6_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_6_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
     return 1;
   }
   else {
     unsigned short wc = iso8859_6_2uni[c-0xa0];
     if (wc != 0xfffd) {
-      *pwc = (wchar_t) wc;
+      *pwc = (ucs4_t) wc;
       return 1;
     }
   }
@@ -60,7 +61,7 @@
 };
 
 static int
-iso8859_6_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_6_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_7.h
diff -u xc/lib/X11/lcUniConv/iso8859_7.h:1.1 xc/lib/X11/lcUniConv/iso8859_7.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_7.h:1.1	Fri Feb 11 21:54:24 2000
+++ xc/lib/X11/lcUniConv/iso8859_7.h	Wed Nov 29 12:40:32 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_7.h,v 1.3 2000/11/29 17:40:32 dawes Exp $ */
 
 /*
  * ISO-8859-7
@@ -25,17 +26,17 @@
 };
 
 static int
-iso8859_7_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
     return 1;
   }
   else {
     unsigned short wc = iso8859_7_2uni[c-0xa0];
     if (wc != 0xfffd) {
-      *pwc = (wchar_t) wc;
+      *pwc = (ucs4_t) wc;
       return 1;
     }
   }
@@ -66,7 +67,7 @@
 };
 
 static int
-iso8859_7_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_7_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_8.h
diff -u xc/lib/X11/lcUniConv/iso8859_8.h:1.1 xc/lib/X11/lcUniConv/iso8859_8.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_8.h:1.1	Fri Feb 11 21:54:24 2000
+++ xc/lib/X11/lcUniConv/iso8859_8.h	Wed Nov 29 12:40:32 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_8.h,v 1.3 2000/11/29 17:40:32 dawes Exp $ */
 
 /*
  * ISO-8859-8
@@ -25,18 +26,18 @@
 };
 
 static int
-iso8859_8_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c >= 0xa0) {
     unsigned short wc = iso8859_8_2uni[c-0xa0];
     if (wc != 0xfffd) {
-      *pwc = (wchar_t) wc;
+      *pwc = (ucs4_t) wc;
       return 1;
     }
   }
   else {
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
     return 1;
   }
   return RET_ILSEQ;
@@ -67,7 +68,7 @@
 };
 
 static int
-iso8859_8_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/iso8859_9.h
diff -u xc/lib/X11/lcUniConv/iso8859_9.h:1.1 xc/lib/X11/lcUniConv/iso8859_9.h:1.3
--- xc/lib/X11/lcUniConv/iso8859_9.h:1.1	Fri Feb 11 21:54:25 2000
+++ xc/lib/X11/lcUniConv/iso8859_9.h	Wed Nov 29 12:40:32 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_9.h,v 1.3 2000/11/29 17:40:32 dawes Exp $ */
 
 /*
  * ISO-8859-9
@@ -16,13 +17,13 @@
 };
 
 static int
-iso8859_9_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+iso8859_9_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c >= 0xd0)
-    *pwc = (wchar_t) iso8859_9_2uni[c-0xd0];
+    *pwc = (ucs4_t) iso8859_9_2uni[c-0xd0];
   else
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   return 1;
 }
 
@@ -47,7 +48,7 @@
 };
 
 static int
-iso8859_9_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+iso8859_9_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00d0) {
Index: xc/lib/X11/lcUniConv/iso8859_9e.h
diff -u /dev/null xc/lib/X11/lcUniConv/iso8859_9e.h:1.3
--- /dev/null	Mon Dec 18 14:24:03 2000
+++ xc/lib/X11/lcUniConv/iso8859_9e.h	Tue Nov 28 11:10:28 2000
@@ -0,0 +1,103 @@
+/* $XFree86: xc/lib/X11/lcUniConv/iso8859_9e.h,v 1.3 2000/11/28 16:10:28 dawes Exp $ */
+
+/*
+ * ISO-8859-9E
+ */
+
+static const unsigned short iso8859_9e_2uni[96] = {
+  /* 0xa0 */
+  0x00a0, 0x017d, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x012c, 0x00a7,
+  0x016c, 0x00a9, 0x01e6, 0x00ab, 0x014a, 0x00ad, 0x00ae, 0x01d1,
+  /* 0xb0 */
+  0x00b0, 0x017e, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x012d, 0x00b7,
+  0x016d, 0x00b9, 0x01e7, 0x00bb, 0x014b, 0x00bd, 0x0178, 0x01d2,
+  /* 0xc0 */
+  0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x018f, 0x00c7,
+  0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+  /* 0xd0 */
+  0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00dd,
+  0x019f, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
+  /* 0xe0 */
+  0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x0259, 0x00e7,
+  0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+  /* 0xf0 */
+  0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00fd,
+  0x0275, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
+};
+
+static int
+iso8859_9e_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  unsigned char c = *s;
+  if (c >= 0xa0)
+    *pwc = (ucs4_t) iso8859_9e_2uni[c-0xa0];
+  else
+    *pwc = (ucs4_t) c;
+  return 1;
+}
+
+static const unsigned char iso8859_9e_page00[96] = {
+  0xa0, 0x00, 0xa2, 0xa3, 0x00, 0xa5, 0x00, 0xa7, /* 0xa0-0xa7 */
+  0x00, 0xa9, 0x00, 0xab, 0x00, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
+  0xb0, 0x00, 0xb2, 0xb3, 0xb4, 0xb5, 0x00, 0xb7, /* 0xb0-0xb7 */
+  0x00, 0xb9, 0x00, 0xbb, 0x00, 0xbd, 0x00, 0x00, /* 0xb8-0xbf */
+  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0x00, 0xc7, /* 0xc0-0xc7 */
+  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */
+  0x00, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* 0xd0-0xd7 */
+  0x00, 0xd9, 0xda, 0xdb, 0xdc, 0xd7, 0x00, 0xdf, /* 0xd8-0xdf */
+  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0x00, 0xe7, /* 0xe0-0xe7 */
+  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0xe8-0xef */
+  0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0x00, /* 0xf0-0xf7 */
+  0x00, 0xf9, 0xfa, 0xfb, 0xfc, 0xf7, 0x00, 0xff, /* 0xf8-0xff */
+};
+static const unsigned char iso8859_9e_page01[136] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0xf0, /* 0x18-0x1f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+  0x00, 0x00, 0x00, 0x00, 0xa6, 0xb6, 0x00, 0x00, /* 0x28-0x2f */
+  0xdd, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
+  0x00, 0x00, 0xac, 0xbc, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xfe, /* 0x58-0x5f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+  0x00, 0x00, 0x00, 0x00, 0xa8, 0xb8, 0x00, 0x00, /* 0x68-0x6f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+  0xbe, 0x00, 0x00, 0x00, 0x00, 0xa1, 0xb1, 0x00, /* 0x78-0x7f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, /* 0x88-0x8f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, /* 0x98-0x9f */
+};
+static const unsigned char iso8859_9e_page01_d[24] = {
+  0x00, 0xaf, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xba, /* 0xe0-0xe7 */
+};
+  
+static int
+iso8859_9e_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  unsigned char c = 0;
+  if (wc < 0x00a0) {
+    *r = wc;
+    return 1;
+  }
+  else if (wc >= 0x00a0 && wc < 0x0100)
+    c = iso8859_9e_page00[wc-0x00a0];
+  else if (wc >= 0x0118 && wc < 0x01a0)
+    c = iso8859_9e_page01[wc-0x0118];
+  else if (wc >= 0x01d0 && wc < 0x01e8)
+    c = iso8859_9e_page01_d[wc-0x01d0];
+  else if (wc == 0x0259)
+    c = 0xe6;
+  else if (wc == 0x0275)
+    c = 0xf8;
+  else if (wc == 0x20ac)
+    c = 0xa4;
+  if (c != 0) {
+    *r = c;
+    return 1;
+  }
+  return RET_ILSEQ;
+}
Index: xc/lib/X11/lcUniConv/jisx0201.h
diff -u xc/lib/X11/lcUniConv/jisx0201.h:1.1 xc/lib/X11/lcUniConv/jisx0201.h:1.3
--- xc/lib/X11/lcUniConv/jisx0201.h:1.1	Fri Feb 11 21:54:25 2000
+++ xc/lib/X11/lcUniConv/jisx0201.h	Wed Nov 29 12:40:33 2000
@@ -1,23 +1,24 @@
+/* $XFree86: xc/lib/X11/lcUniConv/jisx0201.h,v 1.3 2000/11/29 17:40:33 dawes Exp $ */
 
 /*
  * JISX0201.1976-0
  */
 
 static int
-jisx0201_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+jisx0201_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
     if (c == 0x5c)
-      *pwc = (wchar_t) 0x00a5;
+      *pwc = (ucs4_t) 0x00a5;
     else if (c == 0x7e)
-      *pwc = (wchar_t) 0x203e;
+      *pwc = (ucs4_t) 0x203e;
     else
-      *pwc = (wchar_t) c;
+      *pwc = (ucs4_t) c;
     return 1;
   } else {
     if (c >= 0xa1 && c < 0xe0) {
-      *pwc = (wchar_t) c + 0xfec0;
+      *pwc = (ucs4_t) c + 0xfec0;
       return 1;
     }
   }
@@ -25,7 +26,7 @@
 }
 
 static int
-jisx0201_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+jisx0201_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   if (wc < 0x0080 && !(wc == 0x005c || wc == 0x007e)) {
     *r = wc;
Index: xc/lib/X11/lcUniConv/jisx0208.h
diff -u xc/lib/X11/lcUniConv/jisx0208.h:1.1 xc/lib/X11/lcUniConv/jisx0208.h:1.3
--- xc/lib/X11/lcUniConv/jisx0208.h:1.1	Fri Feb 11 21:54:25 2000
+++ xc/lib/X11/lcUniConv/jisx0208.h	Wed Nov 29 12:40:33 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/jisx0208.h,v 1.3 2000/11/29 17:40:33 dawes Exp $ */
 
 /*
  * JISX0208.1990-0
@@ -991,7 +992,7 @@
 };
 
 static int
-jisx0208_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+jisx0208_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x28) || (c1 >= 0x30 && c1 <= 0x74)) {
@@ -1008,7 +1009,7 @@
             wc = jisx0208_2uni_page30[i-1410];
         }
         if (wc != 0xfffd) {
-          *pwc = (wchar_t) wc;
+          *pwc = (ucs4_t) wc;
           return 2;
         }
       }
@@ -2355,7 +2356,7 @@
 };
 
 static int
-jisx0208_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+jisx0208_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
Index: xc/lib/X11/lcUniConv/jisx0212.h
diff -u xc/lib/X11/lcUniConv/jisx0212.h:1.1 xc/lib/X11/lcUniConv/jisx0212.h:1.3
--- xc/lib/X11/lcUniConv/jisx0212.h:1.1	Fri Feb 11 21:54:25 2000
+++ xc/lib/X11/lcUniConv/jisx0212.h	Wed Nov 29 12:40:33 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/jisx0212.h,v 1.3 2000/11/29 17:40:33 dawes Exp $ */
 
 /*
  * JISX0212.1990-0
@@ -892,7 +893,7 @@
 };
 
 static int
-jisx0212_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+jisx0212_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c1 = s[0];
   if ((c1 == 0x22) || (c1 >= 0x26 && c1 <= 0x27) || (c1 >= 0x29 && c1 <= 0x2b) || (c1 >= 0x30 && c1 <= 0x6d)) {
@@ -915,7 +916,7 @@
             wc = jisx0212_2uni_page30[i-1410];
         }
         if (wc != 0xfffd) {
-          *pwc = (wchar_t) wc;
+          *pwc = (ucs4_t) wc;
           return 2;
         }
       }
@@ -2130,7 +2131,7 @@
 };
 
 static int
-jisx0212_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+jisx0212_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
Index: xc/lib/X11/lcUniConv/koi8_c.h
diff -u /dev/null xc/lib/X11/lcUniConv/koi8_c.h:1.2
--- /dev/null	Mon Dec 18 14:24:04 2000
+++ xc/lib/X11/lcUniConv/koi8_c.h	Tue Nov 28 11:10:29 2000
@@ -0,0 +1,103 @@
+/* $XFree86: xc/lib/X11/lcUniConv/koi8_c.h,v 1.2 2000/11/28 16:10:29 dawes Exp $ */
+
+/*
+ * KOI8-C
+ */
+
+static const unsigned short koi8_c_2uni[128] = {
+  /* 0x80 */
+  0x0493, 0x0497, 0x049b, 0x049d, 0x04a3, 0x04af, 0x04b1, 0x04b3,
+  0x04b7, 0x04b9, 0x04bb, 0x2580, 0x04d9, 0x04e3, 0x04e9, 0x04ef,
+  /* 0x90 */
+  0x0492, 0x0496, 0x049a, 0x049c, 0x04a2, 0x04ae, 0x04b0, 0x04b2,
+  0x04b6, 0x04b8, 0x04ba, 0x2321, 0x04d8, 0x04e2, 0x04e8, 0x04ee,
+  /* 0xa0 */
+  0x00a0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
+  0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0491, 0x045e, 0x045f,
+  /* 0xb0 */
+  0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
+  0x0486, 0x0409, 0x040a, 0x040b, 0x040c, 0x0490, 0x040e, 0x040f,
+  /* 0xc0 */
+  0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+  0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+  /* 0xd0 */
+  0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+  0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a,
+  /* 0xe0 */
+  0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+  0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+  /* 0xf0 */
+  0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+  0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a,
+};
+
+static int
+koi8_c_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  unsigned char c = *s;
+  if (c < 0x80)
+    *pwc = (ucs4_t) c;
+  else
+    *pwc = (ucs4_t) koi8_c_2uni[c-0x80];
+  return 1;
+}
+
+static const unsigned char koi8_c_page00[1] = {
+  0xa0,                                           /* 0xa0-0xa7 */
+};
+static const unsigned char koi8_c_page04[240] = {
+  0x00, 0xb3, 0xb1, 0xb2, 0xb4, 0xb5, 0xb6, 0xb7, /* 0x00-0x07 */
+  0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0x00, 0xbe, 0xbf, /* 0x08-0x0f */
+  0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, /* 0x10-0x17 */
+  0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, /* 0x18-0x1f */
+  0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, /* 0x20-0x27 */
+  0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, /* 0x28-0x2f */
+  0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, /* 0x30-0x37 */
+  0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, /* 0x38-0x3f */
+  0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, /* 0x40-0x47 */
+  0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, /* 0x48-0x4f */
+  0x00, 0xa3, 0xa1, 0xa2, 0xa4, 0xa5, 0xa6, 0xa7, /* 0x50-0x57 */
+  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf, /* 0x58-0x5f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+  0xbd, 0xad, 0x90, 0x80, 0x00, 0x00, 0x91, 0x81, /* 0x90-0x97 */
+  0x00, 0x00, 0x92, 0x82, 0x93, 0x83, 0x00, 0x00, /* 0x98-0x9f */
+  0x00, 0x00, 0x94, 0x84, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x85, /* 0xa8-0xaf */
+  0x96, 0x86, 0x97, 0x87, 0x00, 0x00, 0x98, 0x88, /* 0xb0-0xb7 */
+  0x99, 0x89, 0x9a, 0x8a, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+  0x9c, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+  0x00, 0x00, 0x9d, 0x8d, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+  0x9e, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x9f, 0x8f, /* 0xe8-0xef */
+};
+static const unsigned char koi8_c_page22[1] = {
+                                      0xb0,       /* 0x16-0x16 */
+};
+
+static int
+koi8_c_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  unsigned char c = 0;
+  if (wc < 0x0080) {
+    *r = wc;
+    return 1;
+  }
+  else if (wc >= 0x00a0 && wc < 0x00a1)
+    c = koi8_c_page00[wc-0x00a0];
+  else if (wc >= 0x0400 && wc < 0x04ef)
+    c = koi8_c_page04[wc-0x0400];
+  else if (wc >= 0x2216 && wc < 0x2217)
+    c = koi8_c_page22[wc-0x2216];
+  if (c != 0) {
+    *r = c;
+    return 1;
+  }
+  return RET_ILSEQ;
+}
Index: xc/lib/X11/lcUniConv/koi8_r.h
diff -u xc/lib/X11/lcUniConv/koi8_r.h:1.1 xc/lib/X11/lcUniConv/koi8_r.h:1.3
--- xc/lib/X11/lcUniConv/koi8_r.h:1.1	Fri Feb 11 21:54:26 2000
+++ xc/lib/X11/lcUniConv/koi8_r.h	Wed Nov 29 12:40:34 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/koi8_r.h,v 1.3 2000/11/29 17:40:34 dawes Exp $ */
 
 /*
  * KOI8-R
@@ -33,13 +34,13 @@
 };
 
 static int
-koi8_r_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+koi8_r_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0x80)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) koi8_r_2uni[c-0x80];
+    *pwc = (ucs4_t) koi8_r_2uni[c-0x80];
   return 1;
 }
 
@@ -109,7 +110,7 @@
 };
 
 static int
-koi8_r_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+koi8_r_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
Index: xc/lib/X11/lcUniConv/koi8_u.h
diff -u xc/lib/X11/lcUniConv/koi8_u.h:1.1 xc/lib/X11/lcUniConv/koi8_u.h:1.3
--- xc/lib/X11/lcUniConv/koi8_u.h:1.1	Fri Feb 11 21:54:26 2000
+++ xc/lib/X11/lcUniConv/koi8_u.h	Wed Nov 29 12:40:34 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/koi8_u.h,v 1.3 2000/11/29 17:40:34 dawes Exp $ */
 
 /*
  * KOI8-U
@@ -33,13 +34,13 @@
 };
 
 static int
-koi8_u_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+koi8_u_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0x80)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) koi8_u_2uni[c-0x80];
+    *pwc = (ucs4_t) koi8_u_2uni[c-0x80];
   return 1;
 }
 
@@ -117,7 +118,7 @@
 };
 
 static int
-koi8_u_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+koi8_u_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
Index: xc/lib/X11/lcUniConv/ksc5601.h
diff -u xc/lib/X11/lcUniConv/ksc5601.h:1.1 xc/lib/X11/lcUniConv/ksc5601.h:1.3
--- xc/lib/X11/lcUniConv/ksc5601.h:1.1	Fri Feb 11 21:54:26 2000
+++ xc/lib/X11/lcUniConv/ksc5601.h	Wed Nov 29 12:40:34 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/ksc5601.h,v 1.3 2000/11/29 17:40:34 dawes Exp $ */
 
 /*
  * KSC5601.1987-0
@@ -1167,7 +1168,7 @@
 };
 
 static int
-ksc5601_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+ksc5601_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c1 = s[0];
   if ((c1 >= 0x21 && c1 <= 0x2c) || (c1 >= 0x30 && c1 <= 0x48) || (c1 >= 0x4a && c1 <= 0x7d)) {
@@ -1187,7 +1188,7 @@
             wc = ksc5601_2uni_page4a[i-3854];
         }
         if (wc != 0xfffd) {
-          *pwc = (wchar_t) wc;
+          *pwc = (ucs4_t) wc;
           return 2;
         }
       }
@@ -2961,7 +2962,7 @@
 };
 
 static int
-ksc5601_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+ksc5601_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   if (n >= 2) {
     const Summary16 *summary = NULL;
Index: xc/lib/X11/lcUniConv/mulelao.h
diff -u xc/lib/X11/lcUniConv/mulelao.h:1.1 xc/lib/X11/lcUniConv/mulelao.h:1.3
--- xc/lib/X11/lcUniConv/mulelao.h:1.1	Fri Feb 11 21:54:27 2000
+++ xc/lib/X11/lcUniConv/mulelao.h	Wed Nov 29 12:40:35 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/mulelao.h,v 1.3 2000/11/29 17:40:35 dawes Exp $ */
 
 /*
  * MULELAO-1
@@ -25,17 +26,17 @@
 };
 
 static int
-mulelao_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+mulelao_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0xa0) {
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
     return 1;
   }
   else {
     unsigned short wc = mulelao_2uni[c-0xa0];
     if (wc != 0xfffd) {
-      *pwc = (wchar_t) wc;
+      *pwc = (ucs4_t) wc;
       return 1;
     }
   }
@@ -58,7 +59,7 @@
 };
 
 static int
-mulelao_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+mulelao_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x00a0) {
Index: xc/lib/X11/lcUniConv/tatar_cyr.h
diff -u /dev/null xc/lib/X11/lcUniConv/tatar_cyr.h:1.3
--- /dev/null	Mon Dec 18 14:24:06 2000
+++ xc/lib/X11/lcUniConv/tatar_cyr.h	Mon Dec  4 13:49:42 2000
@@ -0,0 +1,123 @@
+/* $XFree86: xc/lib/X11/lcUniConv/tatar_cyr.h,v 1.3 2000/12/04 18:49:42 dawes Exp $ */
+
+/*
+ * TATAR-CYR
+ */
+
+static const unsigned short tatar_cyr_2uni[128] = {
+  /* 0x80 */
+  0x04d8, 0x0403, 0x201a, 0x0453, 0x201e, 0x2026, 0x2020, 0x2021,
+  0x20ac, 0x2030, 0x04e8, 0x2039, 0x04ae, 0x0496, 0x04a2, 0x04ba,
+  /* 0x90 */
+  0x04d9, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+    0x98, 0x2122, 0x04e9, 0x203a, 0x04af, 0x0497, 0x04a3, 0x04bb,
+  /* 0xa0 */
+  0x00a0, 0x040e, 0x045e, 0x0408, 0x00a4, 0x0490, 0x00a6, 0x00a7,
+  0x0401, 0x00a9, 0x0404, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x0407,
+  /* 0xb0 */
+  0x00b0, 0x00b1, 0x0406, 0x0456, 0x0491, 0x00b5, 0x00b6, 0x00b7,
+  0x0451, 0x2116, 0x0454, 0x00bb, 0x0458, 0x0405, 0x0455, 0x0457,
+  /* 0xc0 */
+  0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+  0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
+  /* 0xd0 */
+  0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+  0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
+  /* 0xe0 */
+  0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+  0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
+  /* 0xf0 */
+  0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+  0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
+};
+
+static int
+tatar_cyr_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  unsigned char c = *s;
+  if (c < 0x80)
+    *pwc = (ucs4_t) c;
+  else
+    *pwc = (ucs4_t) tatar_cyr_2uni[c-0x80];
+  return 1;
+}
+
+static const unsigned char tatar_cyr_page00[32] = {
+  0xa0, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */
+  0x00, 0xa9, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
+  0xb0, 0xb1, 0x00, 0x00, 0x00, 0xb5, 0xb6, 0xb7, /* 0xb0-0xb7 */
+  0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+};
+static const unsigned char tatar_cyr_page04[240] = {
+  0x00, 0xa8, 0x00, 0x81, 0xaa, 0xbd, 0xb2, 0xaf, /* 0x00-0x07 */
+  0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa1, 0x00, /* 0x08-0x0f */
+  0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0x10-0x17 */
+  0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* 0x18-0x1f */
+  0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 0x20-0x27 */
+  0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, /* 0x28-0x2f */
+  0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x30-0x37 */
+  0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x38-0x3f */
+  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 0x40-0x47 */
+  0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* 0x48-0x4f */
+  0x00, 0xb8, 0x00, 0x83, 0xba, 0xbe, 0xb3, 0xbf, /* 0x50-0x57 */
+  0xbc, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa2, 0x00, /* 0x58-0x5f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
+  0xa5, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8d, 0x9d, /* 0x90-0x97 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
+  0x00, 0x00, 0x8e, 0x9e, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x9c, /* 0xa8-0xaf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
+  0x00, 0x00, 0x8f, 0x9f, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
+  0x80, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
+  0x8a, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
+};
+static const unsigned char tatar_cyr_page20[48] = {
+  0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
+  0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
+  0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
+  0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
+  0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
+};
+static const unsigned char tatar_cyr_page21[24] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, /* 0x10-0x17 */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
+  0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
+};
+static const unsigned char tatar_cyr_page22[1] = {
+                                      0xb0,       /* 0x16-0x16 */
+};
+
+static int
+tatar_cyr_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  unsigned char c = 0;
+  if (wc < 0x0080) {
+    *r = wc;
+    return 1;
+  }
+  else if (wc >= 0x00a0 && wc < 0x00bc)
+    c = tatar_cyr_page00[wc-0x00a0];
+  else if (wc >= 0x0400 && wc < 0x04ef)
+    c = tatar_cyr_page04[wc-0x0400];
+  else if (wc >= 0x2010 && wc < 0x203b)
+    c = tatar_cyr_page20[wc-0x2010];
+  else if (wc == 0x20ac)
+    c = 0x88;
+  else if (wc >= 0x2110 && wc < 0x2123)
+    c = tatar_cyr_page21[wc-0x2110];
+  if (c != 0) {
+    *r = c;
+    return 1;
+  }
+  return RET_ILSEQ;
+}
Index: xc/lib/X11/lcUniConv/tcvn.h
diff -u xc/lib/X11/lcUniConv/tcvn.h:1.1 xc/lib/X11/lcUniConv/tcvn.h:1.3
--- xc/lib/X11/lcUniConv/tcvn.h:1.1	Fri Feb 11 21:54:27 2000
+++ xc/lib/X11/lcUniConv/tcvn.h	Wed Nov 29 12:40:35 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/tcvn.h,v 1.3 2000/11/29 17:40:35 dawes Exp $ */
 
 /*
  * TCVN-5712
@@ -39,15 +40,15 @@
 };
 
 static int
-tcvn_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+tcvn_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0x20)
-    *pwc = (wchar_t) tcvn_2uni_1[c];
+    *pwc = (ucs4_t) tcvn_2uni_1[c];
   else if (c < 0x80)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) tcvn_2uni_2[c-0x80];
+    *pwc = (ucs4_t) tcvn_2uni_2[c-0x80];
   return 1;
 }
 
@@ -112,7 +113,7 @@
 };
 
 static int
-tcvn_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+tcvn_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x0080 && (wc >= 0x0020 || (0x00fe0076 & (1 << wc)) == 0)) {
Index: xc/lib/X11/lcUniConv/tis620.h
diff -u xc/lib/X11/lcUniConv/tis620.h:1.1 xc/lib/X11/lcUniConv/tis620.h:1.3
--- xc/lib/X11/lcUniConv/tis620.h:1.1	Fri Feb 11 21:54:27 2000
+++ xc/lib/X11/lcUniConv/tis620.h	Wed Nov 29 12:40:35 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/tis620.h,v 1.3 2000/11/29 17:40:35 dawes Exp $ */
 
 /*
  * TIS620.2533-1
@@ -25,11 +26,11 @@
 };
 
 static int
-tis620_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+tis620_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0x80) {
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
     return 1;
   }
   else if (c < 0xa0) {
@@ -37,7 +38,7 @@
   else {
     unsigned short wc = tis620_2uni[c-0xa0];
     if (wc != 0xfffd) {
-      *pwc = (wchar_t) wc;
+      *pwc = (ucs4_t) wc;
       return 1;
     }
   }
@@ -60,7 +61,7 @@
 };
 
 static int
-tis620_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+tis620_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x0080) {
Index: xc/lib/X11/lcUniConv/ucs2be.h
diff -u /dev/null xc/lib/X11/lcUniConv/ucs2be.h:1.1
--- /dev/null	Mon Dec 18 14:24:07 2000
+++ xc/lib/X11/lcUniConv/ucs2be.h	Tue Nov 28 12:25:09 2000
@@ -0,0 +1,32 @@
+/*
+ * UCS-2BE = UCS-2 big endian
+ */
+/* $XFree86: xc/lib/X11/lcUniConv/ucs2be.h,v 1.1 2000/11/28 17:25:09 dawes Exp $ */
+
+static int
+ucs2be_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
+{
+  if (n >= 2) {
+    if (s[0] >= 0xd8 && s[0] < 0xe0) {
+      return RET_ILSEQ;
+    } else {
+      *pwc = (s[0] << 8) + s[1];
+      return 2;
+    }
+  }
+  return RET_TOOFEW(0);
+}
+
+static int
+ucs2be_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
+{
+  if (wc < 0x10000 && !(wc >= 0xd800 && wc < 0xe000)) {
+    if (n >= 2) {
+      r[0] = (unsigned char) (wc >> 8);
+      r[1] = (unsigned char) wc;
+      return 2;
+    } else
+      return RET_TOOSMALL;
+  }
+  return RET_ILSEQ;
+}
Index: xc/lib/X11/lcUniConv/utf8.h
diff -u xc/lib/X11/lcUniConv/utf8.h:1.1 xc/lib/X11/lcUniConv/utf8.h:1.3
--- xc/lib/X11/lcUniConv/utf8.h:1.1	Fri Jun 23 19:13:19 2000
+++ xc/lib/X11/lcUniConv/utf8.h	Tue Nov 28 13:50:07 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/X11/lcUniConv/utf8.h,v 1.1 2000/06/23 23:13:19 dawes Exp $ */
+/* $XFree86: xc/lib/X11/lcUniConv/utf8.h,v 1.3 2000/11/28 18:50:07 dawes Exp $ */
 
 /*
  * UTF-8
@@ -7,7 +7,7 @@
 /* Specification: RFC 2279 */
 
 static int
-utf8_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+utf8_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = s[0];
 
@@ -21,8 +21,8 @@
       return RET_TOOFEW(0);
     if (!((s[1] ^ 0x80) < 0x40))
       return RET_ILSEQ;
-    *pwc = ((wchar_t) (c & 0x1f) << 6)
-           | (wchar_t) (s[1] ^ 0x80);
+    *pwc = ((ucs4_t) (c & 0x1f) << 6)
+           | (ucs4_t) (s[1] ^ 0x80);
     return 2;
   } else if (c < 0xf0) {
     if (n < 3)
@@ -30,36 +30,36 @@
     if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
           && (c >= 0xe1 || s[1] >= 0xa0)))
       return RET_ILSEQ;
-    *pwc = ((wchar_t) (c & 0x0f) << 12)
-           | ((wchar_t) (s[1] ^ 0x80) << 6)
-           | (wchar_t) (s[2] ^ 0x80);
+    *pwc = ((ucs4_t) (c & 0x0f) << 12)
+           | ((ucs4_t) (s[1] ^ 0x80) << 6)
+           | (ucs4_t) (s[2] ^ 0x80);
     return 3;
-  } else if (c < 0xf8 && sizeof(wchar_t)*8 >= 32) {
+  } else if (c < 0xf8) {
     if (n < 4)
       return RET_TOOFEW(0);
     if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
           && (s[3] ^ 0x80) < 0x40
           && (c >= 0xf1 || s[1] >= 0x90)))
       return RET_ILSEQ;
-    *pwc = ((wchar_t) (c & 0x07) << 18)
-           | ((wchar_t) (s[1] ^ 0x80) << 12)
-           | ((wchar_t) (s[2] ^ 0x80) << 6)
-           | (wchar_t) (s[3] ^ 0x80);
+    *pwc = ((ucs4_t) (c & 0x07) << 18)
+           | ((ucs4_t) (s[1] ^ 0x80) << 12)
+           | ((ucs4_t) (s[2] ^ 0x80) << 6)
+           | (ucs4_t) (s[3] ^ 0x80);
     return 4;
-  } else if (c < 0xfc && sizeof(wchar_t)*8 >= 32) {
+  } else if (c < 0xfc) {
     if (n < 5)
       return RET_TOOFEW(0);
     if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
           && (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
           && (c >= 0xf9 || s[1] >= 0x88)))
       return RET_ILSEQ;
-    *pwc = ((wchar_t) (c & 0x03) << 24)
-           | ((wchar_t) (s[1] ^ 0x80) << 18)
-           | ((wchar_t) (s[2] ^ 0x80) << 12)
-           | ((wchar_t) (s[3] ^ 0x80) << 6)
-           | (wchar_t) (s[4] ^ 0x80);
+    *pwc = ((ucs4_t) (c & 0x03) << 24)
+           | ((ucs4_t) (s[1] ^ 0x80) << 18)
+           | ((ucs4_t) (s[2] ^ 0x80) << 12)
+           | ((ucs4_t) (s[3] ^ 0x80) << 6)
+           | (ucs4_t) (s[4] ^ 0x80);
     return 5;
-  } else if (c < 0xfe && sizeof(wchar_t)*8 >= 32) {
+  } else if (c < 0xfe) {
     if (n < 6)
       return RET_TOOFEW(0);
     if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
@@ -67,19 +67,19 @@
           && (s[5] ^ 0x80) < 0x40
           && (c >= 0xfd || s[1] >= 0x84)))
       return RET_ILSEQ;
-    *pwc = ((wchar_t) (c & 0x01) << 30)
-           | ((wchar_t) (s[1] ^ 0x80) << 24)
-           | ((wchar_t) (s[2] ^ 0x80) << 18)
-           | ((wchar_t) (s[3] ^ 0x80) << 12)
-           | ((wchar_t) (s[4] ^ 0x80) << 6)
-           | (wchar_t) (s[5] ^ 0x80);
+    *pwc = ((ucs4_t) (c & 0x01) << 30)
+           | ((ucs4_t) (s[1] ^ 0x80) << 24)
+           | ((ucs4_t) (s[2] ^ 0x80) << 18)
+           | ((ucs4_t) (s[3] ^ 0x80) << 12)
+           | ((ucs4_t) (s[4] ^ 0x80) << 6)
+           | (ucs4_t) (s[5] ^ 0x80);
     return 6;
   } else
     return RET_ILSEQ;
 }
 
 static int
-utf8_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n) /* n == 0 is acceptable */
+utf8_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) /* n == 0 is acceptable */
 {
   int count;
   if (wc < 0x80)
Index: xc/lib/X11/lcUniConv/viscii.h
diff -u xc/lib/X11/lcUniConv/viscii.h:1.1 xc/lib/X11/lcUniConv/viscii.h:1.3
--- xc/lib/X11/lcUniConv/viscii.h:1.1	Fri Feb 11 21:54:27 2000
+++ xc/lib/X11/lcUniConv/viscii.h	Wed Nov 29 12:40:35 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/X11/lcUniConv/viscii.h,v 1.3 2000/11/29 17:40:35 dawes Exp $ */
 
 /*
  * VISCII1.1-1
@@ -41,15 +42,15 @@
 };
 
 static int
-viscii_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+viscii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 {
   unsigned char c = *s;
   if (c < 0x20)
-    *pwc = (wchar_t) viscii_2uni_1[c];
+    *pwc = (ucs4_t) viscii_2uni_1[c];
   else if (c < 0x80)
-    *pwc = (wchar_t) c;
+    *pwc = (ucs4_t) c;
   else
-    *pwc = (wchar_t) viscii_2uni_2[c-0x80];
+    *pwc = (ucs4_t) viscii_2uni_2[c-0x80];
   return 1;
 }
 
@@ -103,7 +104,7 @@
 };
 
 static int
-viscii_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+viscii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 {
   unsigned char c = 0;
   if (wc < 0x0080 && (wc >= 0x0020 || (0x42100064 & (1 << wc)) == 0)) {
Index: xc/lib/XIE/colorlist.c
diff -u xc/lib/XIE/colorlist.c:1.3 xc/lib/XIE/colorlist.c:1.4
--- xc/lib/XIE/colorlist.c:1.3	Sun Jun 13 12:18:08 1999
+++ xc/lib/XIE/colorlist.c	Tue Sep 26 11:56:53 2000
@@ -23,7 +23,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/XIE/colorlist.c,v 1.3 1999/06/13 16:18:08 dawes Exp $ */
+/* $XFree86: xc/lib/XIE/colorlist.c,v 1.4 2000/09/26 15:56:53 tsi Exp $ */
 
 #include "XIElibint.h"
 
@@ -142,7 +142,7 @@
       *colors_ret = (unsigned long *) Xmalloc (
 	rep.length * sizeof (unsigned long));
 
-      _XRead32 (display, *colors_ret, rep.length << 2);
+      _XRead32 (display, (long *)(*colors_ret), rep.length << 2);
     }
     else
 	*colors_ret = NULL;
Index: xc/lib/XIE/init.c
diff -u xc/lib/XIE/init.c:3.3 xc/lib/XIE/init.c:3.4
--- xc/lib/XIE/init.c:3.3	Sun Jun 13 12:18:10 1999
+++ xc/lib/XIE/init.c	Tue Sep 26 11:56:53 2000
@@ -23,7 +23,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/XIE/init.c,v 3.3 1999/06/13 16:18:10 dawes Exp $ */
+/* $XFree86: xc/lib/XIE/init.c,v 3.4 2000/09/26 15:56:53 tsi Exp $ */
 
 #define NEED_EVENTS	/* so XErrorEvent will get pulled in */
 
@@ -109,7 +109,7 @@
     (*extinfo_ret)->cnst_levels = (unsigned long *)
 	Xmalloc (rep.length * sizeof (unsigned long));
 
-    _XRead32 (display, (*extinfo_ret)->cnst_levels, rep.length << 2);
+    _XRead32 (display, (long *)((*extinfo_ret)->cnst_levels), rep.length << 2);
 
 
     /*
Index: xc/lib/XThrStub/UIThrStubs.c
diff -u xc/lib/XThrStub/UIThrStubs.c:3.1 xc/lib/XThrStub/UIThrStubs.c:3.2
--- xc/lib/XThrStub/UIThrStubs.c:3.1	Mon Feb 28 22:09:06 2000
+++ xc/lib/XThrStub/UIThrStubs.c	Tue Oct 24 14:07:37 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/XThrStub/UIThrStubs.c,v 3.1 2000/02/29 03:09:06 dawes Exp $
+ * $XFree86: xc/lib/XThrStub/UIThrStubs.c,v 3.2 2000/10/24 18:07:37 dawes Exp $
  *
  * Copyright (c) 1995 David E. Wexelblat.  All rights reserved
  *
@@ -54,29 +54,29 @@
 #define xthread_self cthread_self
 #pragma weak cthread_self = _Xthr_self_stub_
 #define xmutex_init mutex_init
-#pragma weak mutex_init = _Xmutex_init_stub_
-#pragma weak mutex_clear = _Xmutex_destroy_stub_
-#pragma weak mutex_lock = _Xmutex_lock_stub_
-#pragma weak mutex_unlock = _Xmutex_unlock_stub_
-#pragma weak condition_init = _Xcond_init_stub_
-#pragma weak condition_clear = _Xcond_destroy_stub_
-#pragma weak condition_wait = _Xcond_wait_stub_
-#pragma weak condition_signal = _Xcond_signal_stub_
-#pragma weak condition_broadcast = _Xcond_signal_stub_
+#pragma weak mutex_init = _Xthr_zero_stub_
+#pragma weak mutex_clear = _Xthr_zero_stub_
+#pragma weak mutex_lock = _Xthr_zero_stub_
+#pragma weak mutex_unlock = _Xthr_zero_stub_
+#pragma weak condition_init = _Xthr_zero_stub_
+#pragma weak condition_clear = _Xthr_zero_stub_
+#pragma weak condition_wait = _Xthr_zero_stub_
+#pragma weak condition_signal = _Xthr_zero_stub_
+#pragma weak condition_broadcast = _Xthr_zero_stub_
 #else /* !CTHREADS */
 #if defined(SVR4) && !defined(__sgi)
 #include <thread.h>
 typedef thread_t xthread_t;
 #pragma weak thr_self = _Xthr_self_stub_
-#pragma weak mutex_init = _Xmutex_init_stub_
-#pragma weak mutex_destroy = _Xmutex_destroy_stub_
-#pragma weak mutex_lock = _Xmutex_lock_stub_
-#pragma weak mutex_unlock = _Xmutex_unlock_stub_
-#pragma weak cond_init = _Xcond_init_stub_
-#pragma weak cond_destroy = _Xcond_destroy_stub_
-#pragma weak cond_wait = _Xcond_wait_stub_
-#pragma weak cond_signal = _Xcond_signal_stub_
-#pragma weak cond_broadcast = _Xcond_signal_stub_
+#pragma weak mutex_init = _Xthr_zero_stub_
+#pragma weak mutex_destroy = _Xthr_zero_stub_
+#pragma weak mutex_lock = _Xthr_zero_stub_
+#pragma weak mutex_unlock = _Xthr_zero_stub_
+#pragma weak cond_init = _Xthr_zero_stub_
+#pragma weak cond_destroy = _Xthr_zero_stub_
+#pragma weak cond_wait = _Xthr_zero_stub_
+#pragma weak cond_signal = _Xthr_zero_stub_
+#pragma weak cond_broadcast = _Xthr_zero_stub_
 #else /* !SVR4 */
 #ifdef WIN32
     /*
@@ -87,28 +87,28 @@
 #include <tis.h>
 typedef pthread_t xthread_t;
 #pragma weak tis_self = _Xthr_self_stub_
-#pragma weak tis_mutex_init = _Xmutex_init_stub_
-#pragma weak tis_mutex_destroy = _Xmutex_destroy_stub_
-#pragma weak tis_mutex_lock = _Xmutex_lock_stub_
-#pragma weak tis_mutex_unlock = _Xmutex_unlock_stub_
-#pragma weak tis_cond_init = _Xcond_init_stub_
-#pragma weak tis_cond_destroy = _Xcond_destroy_stub_
-#pragma weak tis_cond_wait = _Xcond_wait_stub_
-#pragma weak tis_cond_signal = _Xcond_signal_stub_
-#pragma weak tis_cond_broadcast = _Xcond_signal_stub_
+#pragma weak tis_mutex_init = _Xthr_zero_stub_
+#pragma weak tis_mutex_destroy = _Xthr_zero_stub_
+#pragma weak tis_mutex_lock = _Xthr_zero_stub_
+#pragma weak tis_mutex_unlock = _Xthr_zero_stub_
+#pragma weak tis_cond_init = _Xthr_zero_stub_
+#pragma weak tis_cond_destroy = _Xthr_zero_stub_
+#pragma weak tis_cond_wait = _Xthr_zero_stub_
+#pragma weak tis_cond_signal = _Xthr_zero_stub_
+#pragma weak tis_cond_broadcast = _Xthr_zero_stub_
 #else
 #include <pthread.h>
 typedef pthread_t xthread_t;
 #pragma weak pthread_self = _Xthr_self_stub_
-#pragma weak pthread_mutex_init = _Xmutex_init_stub_
-#pragma weak pthread_mutex_destroy = _Xmutex_destroy_stub_
-#pragma weak pthread_mutex_lock = _Xmutex_lock_stub_
-#pragma weak pthread_mutex_unlock = _Xmutex_unlock_stub_
-#pragma weak pthread_cond_init = _Xcond_init_stub_
-#pragma weak pthread_cond_destroy = _Xcond_destroy_stub_
-#pragma weak pthread_cond_wait = _Xcond_wait_stub_
-#pragma weak pthread_cond_signal = _Xcond_signal_stub_
-#pragma weak pthread_cond_broadcast = _Xcond_broadcast_stub_
+#pragma weak pthread_mutex_init = _Xthr_zero_stub_
+#pragma weak pthread_mutex_destroy = _Xthr_zero_stub_
+#pragma weak pthread_mutex_lock = _Xthr_zero_stub_
+#pragma weak pthread_mutex_unlock = _Xthr_zero_stub_
+#pragma weak pthread_cond_init = _Xthr_zero_stub_
+#pragma weak pthread_cond_destroy = _Xthr_zero_stub_
+#pragma weak pthread_cond_wait = _Xthr_zero_stub_
+#pragma weak pthread_cond_signal = _Xthr_zero_stub_
+#pragma weak pthread_cond_broadcast = _Xthr_zero_stub_
 #if defined(_DECTHREADS_) || defined(linux)
 #pragma weak pthread_equal = _Xthr_equal_stub_	/* See Xthreads.h! */
 int
@@ -122,7 +122,7 @@
 #endif /* SVR4 */
 #endif /* CTHREADS */
 
-xthread_t 
+static xthread_t 
 _Xthr_self_stub_()
 {
     static xthread_t _X_no_thread_id;
@@ -130,56 +130,8 @@
     return(_X_no_thread_id);	/* defined by <X11/Xthreads.h> */
 }
 
-int 
-_Xmutex_init_stub_()
-{
-    return(0);
-}
-
-int
-_Xmutex_destroy_stub_()
-{
-    return(0);
-}
-
-int
-_Xmutex_lock_stub_()
-{
-    return(0);
-}
-
-int
-_Xmutex_unlock_stub_()
-{
-    return(0);
-}
-
-int 
-_Xcond_init_stub_()
-{
-    return(0);
-}
-
-int
-_Xcond_destroy_stub_()
-{
-    return(0);
-}
-
-int
-_Xcond_wait_stub_()
-{
-    return(0);
-}
-
-int
-_Xcond_signal_stub_()
-{
-    return(0);
-}
-
-int
-_Xcond_broadcast_stub_()
+static int 
+_Xthr_zero_stub_()
 {
     return(0);
 }
Index: xc/lib/Xanti/Imakefile
diff -u xc/lib/Xanti/Imakefile:1.1 xc/lib/Xanti/Imakefile:removed
--- xc/lib/Xanti/Imakefile:1.1	Sat Nov 14 23:29:56 1998
+++ xc/lib/Xanti/Imakefile	Mon Dec 18 14:24:12 2000
@@ -1,30 +0,0 @@
-XCOMM $XFree86: xc/lib/Xanti/Imakefile,v 1.1 1998/11/15 04:29:56 dawes Exp $
-
-#define DoNormalLib NormalLibXanti
-#define DoSharedLib SharedLibXanti
-#define DoDebugLib DebugLibXanti
-#define DoProfileLib ProfileLibXanti
-#define LibName Xanti
-#define SoRev SOXANTIREV
-
-#include <Threads.tmpl>
-
-#ifdef SharedXantiReqs
-REQUIREDLIBS = SharedXantiReqs
-#endif
-
-#if Malloc0ReturnsNull
-ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
-#endif
-
-      DEFINES = $(ALLOC_DEFINES)
-     INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC)
-         SRCS = XAnti.c
-         OBJS = XAnti.o
-     LINTLIBS = $(LINTXLIB)
-
-HEADERS = XAntiint.h
-
-#include <Library.tmpl>
-
-DependTarget()
Index: xc/lib/Xanti/XAnti.c
diff -u xc/lib/Xanti/XAnti.c:1.2 xc/lib/Xanti/XAnti.c:removed
--- xc/lib/Xanti/XAnti.c:1.2	Sun Jun  6 04:47:49 1999
+++ xc/lib/Xanti/XAnti.c	Mon Dec 18 14:24:13 2000
@@ -1,893 +0,0 @@
-/*
-Copyright (c) 1986  X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
-*/
-/* $XFree86: xc/lib/Xanti/XAnti.c,v 1.2 1999/06/06 08:47:49 dawes Exp $ */
-
-/*
-  Based on xc/lib/X11/Text.c and others.  
-  Altered for antialiased text by Mark Vojkovich (mvojkovi@ucsd.edu). 
-*/
-
-#define NEED_REPLIES
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "XAntiint.h"
-#include "XAnti.h"
-#include "XAntiproto.h"
-#include <stdio.h>
-
-
-static XExtCodes *_XAntiCodes;
-
-#define	PREAMBLE(dpy) {\
-  LockDisplay(dpy); \
-  if ((!_XAntiCodes) && (!(_XAntiCodes = XInitExtension(dpy, XAntiName)))) {\
-	UnlockDisplay(dpy); \
-	SyncHandle(); \
-	return 0; \
-  }}
-
-#define POSTAMBLE(dpy) \
-  UnlockDisplay(dpy); \
-  SyncHandle()
-
-
-Bool
-XAntiQueryExtension(
-    Display *dpy,
-    unsigned int *p_version, 
-    unsigned int *p_revision
-){
-   xAntiQueryExtensionReq *req;
-   xAntiQueryExtensionReply rep;
- 
-   PREAMBLE(dpy);
-
-   XAntiGetReq(QueryExtension, req);
-
-   if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
-      POSTAMBLE(dpy);
-      return False;
-   }
-
-   POSTAMBLE(dpy);
-
-   *p_version = rep.version;
-   *p_revision = rep.revision;
- 
-   return True;
-}
-
-
-int
-XAntiInterpolateColors(
-    Display *dpy,
-    GC gc,
-    Colormap cmap,
-    XColor *colors
-){
-   xAntiInterpolateColorsReq *req;
-   xAntiInterpolateColorsReply rep;
-   int i;
-
-   if(!colors) return BadValue;
- 
-   PREAMBLE(dpy);
-
-   FlushGC(dpy, gc);
-
-   XAntiGetReq(InterpolateColors, req);
-   req->colormap = cmap;
-   req->number = 3;
-   req->gc = gc->gid;
-
-   if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-   	xColorItem *items;
-	int size = 3 * sizeof(xColorItem);
-
-	if((items = (xColorItem*)Xmalloc(size))) {
-	    _XRead(dpy, (char*)items, size);
-	    for(i = 0; i < 3; i++) {
-		colors[i].pixel = items[i].pixel;
-		colors[i].red   = items[i].red;
-		colors[i].green = items[i].green;
-		colors[i].blue  = items[i].blue;
-		colors[i].flags = items[i].flags;
-	    }
-	    Xfree(items);
-	} else 
-	    _XEatData(dpy, size);
-   } else {
-	POSTAMBLE(dpy); 
-	return BadImplementation;
-   }
-
-   POSTAMBLE(dpy); 
-   return Success;
-}
-
-
-/* 
-   I considered having XAntiSetInterpolationPixels not generate any 
-   protocol right off, but wait until it was explicitly flushed.  But
-   this complicates things and there is no real benefit.  Unlike 
-   the main GC data where you can set a whole bunch of different
-   fields without generating any protocol, we are only setting one
-   field and the only benefit would be to programmers who can't make
-   up their minds and keep changing the interpolation pixels before
-   they use them. 
-*/ 
-
-int
-XAntiSetInterpolationPixels(
-   Display *dpy,
-   GC gc,
-   unsigned long *pixels
-){
-   xAntiSetInterpolationPixelsReq *req;
-   CARD32 toSend[3];
-
-   if(!pixels)
-	return BadValue;
-
-   toSend[0] = pixels[0];
-   toSend[1] = pixels[1];
-   toSend[2] = pixels[2];
-
-   PREAMBLE(dpy);
-   XAntiGetReq(SetInterpolationPixels, req);
-   req->length += 3;
-   req->gc = gc->gid;
-   req->number = 3;
-
-   Data(dpy, (char*)toSend, 12);
-
-   POSTAMBLE(dpy);
-   return Success;
-}
-
-
-int
-XAntiDrawString(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x,
-    int y,
-    _Xconst char *string,
-    int length
-){   
-    int Datalength = 0;
-    xAntiPolyText8Req *req;
-
-    if (length <= 0)
-       return 0;
-
-    PREAMBLE(dpy);
-    FlushGC(dpy, gc);
-    XAntiGetReq (PolyText8, req);
-    req->drawable = d;
-    req->gc = gc->gid;
-    req->x = x;
-    req->y = y;
-
-    Datalength += SIZEOF(xTextElt) * ((length + 253) / 254) + length;
-    req->length += (Datalength + 3)>>2;  /* convert to number of 32-bit words */
-
-    /* 
-     * If the entire request does not fit into the remaining space in the
-     * buffer, flush the buffer first.   If the request does fit into the
-     * empty buffer, then we won't have to flush it at the end to keep
-     * the buffer 32-bit aligned. 
-     */
-
-    if (dpy->bufptr + Datalength > dpy->bufmax)
-    	_XFlush (dpy);
-
-    {
-	int nbytes;
-	int PartialNChars = length;
- 	char *CharacterOffset = (char *)string;
-        unsigned char *tbuf;
-
-	while(PartialNChars > 254) {
- 	    nbytes = 254 + SIZEOF(xTextElt);
-	    BufAlloc (unsigned char *, tbuf, nbytes);
-            *(unsigned char *)tbuf = 254;
-            *(tbuf+1) = 0;
-            memcpy ((char *)tbuf+2, CharacterOffset, 254);
-	    PartialNChars = PartialNChars - 254;
-	    CharacterOffset += 254;
-	}
-	    
-        if (PartialNChars) {
-	    nbytes = PartialNChars + SIZEOF(xTextElt);
-	    BufAlloc (unsigned char *, tbuf, nbytes); 
-            *(unsigned char *)tbuf =  PartialNChars;
-            *(tbuf+1) = 0;
-	    memcpy ((char *)tbuf+2, CharacterOffset, PartialNChars);
-	 }
-    }
-
-    /* Pad request out to a 32-bit boundary */
-
-    if (Datalength &= 3) {
-	char *pad;
-	/* 
-	 * BufAlloc is a macro that uses its last argument more than
-	 * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)" 
-	 */
-	length = 4 - Datalength;
-	BufAlloc (char *, pad, length);
-	/* 
-	 * if there are 3 bytes of padding, the first byte MUST be 0
-	 * so the pad bytes aren't mistaken for a final xTextElt 
-	 */
-	*pad = 0;
-        }
-
-    /* 
-     * If the buffer pointer is not now pointing to a 32-bit boundary,
-     * we must flush the buffer so that it does point to a 32-bit boundary
-     * at the end of this routine. 
-     */
-
-    if ((dpy->bufptr - dpy->buffer) & 3)
-       _XFlush (dpy);
-    POSTAMBLE(dpy);
-    return 0;
-}
-
-int
-XAntiDrawString16(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x,
-    int y,
-    _Xconst XChar2b *string,
-    int length
-){   
-    int Datalength = 0;
-    xAntiPolyText16Req *req;
-
-    if (length <= 0)
-       return 0;
-
-    PREAMBLE(dpy);
-    FlushGC(dpy, gc);
-    XAntiGetReq (PolyText16, req);
-    req->drawable = d;
-    req->gc = gc->gid;
-    req->x = x;
-    req->y = y;
-
-    Datalength += SIZEOF(xTextElt) * ((length + 253) / 254) + (length << 1);
-    req->length += (Datalength + 3)>>2;  /* convert to number of 32-bit words */
-
-    /* 
-     * If the entire request does not fit into the remaining space in the
-     * buffer, flush the buffer first.   If the request does fit into the
-     * empty buffer, then we won't have to flush it at the end to keep
-     * the buffer 32-bit aligned. 
-     */
-
-    if (dpy->bufptr + Datalength > dpy->bufmax)
-    	_XFlush (dpy);
-
-    {
-	int nbytes;
-	int PartialNChars = length;
-        xTextElt *elt;
- 	XChar2b *CharacterOffset = (XChar2b *)string;
-
-	while(PartialNChars > 254) {
- 	    nbytes = 254 * 2 + SIZEOF(xTextElt);
-	    BufAlloc (xTextElt *, elt, nbytes);
-	    elt->delta = 0;
-	    elt->len = 254;
-#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
-	    {
-		register int i;
-		register unsigned char *cp;
-		for (i = 0, cp = ((unsigned char *)elt) + 2; i < 254; i++) {
-		    *cp++ = CharacterOffset[i].byte1;
-		    *cp++ = CharacterOffset[i].byte2;
-		}
-	    }
-#else
-            memcpy ((char *) (elt + 1), (char *)CharacterOffset, 254 * 2);
-#endif
-	    PartialNChars = PartialNChars - 254;
-	    CharacterOffset += 254;
-	}
-	    
-        if (PartialNChars) {
-	    nbytes = PartialNChars * 2  + SIZEOF(xTextElt);
-	    BufAlloc (xTextElt *, elt, nbytes); 
-	    elt->delta = 0;
-	    elt->len = PartialNChars;
-#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
-	    {
-		register int i;
-		register unsigned char *cp;
-		for (i = 0, cp = ((unsigned char *)elt) + 2; i < PartialNChars;
-		     i++) {
-		    *cp++ = CharacterOffset[i].byte1;
-		    *cp++ = CharacterOffset[i].byte2;
-		}
-	    }
-#else
-            memcpy((char *)(elt + 1), (char *)CharacterOffset, 
-					PartialNChars * 2);
-#endif
-	 }
-    }
-
-    /* Pad request out to a 32-bit boundary */
-
-    if (Datalength &= 3) {
-	char *pad;
-	/* 
-	 * BufAlloc is a macro that uses its last argument more than
-	 * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)" 
-	 */
-	length = 4 - Datalength;
-	BufAlloc (char *, pad, length);
-	/* 
-	 * if there are 3 bytes of padding, the first byte MUST be 0
-	 * so the pad bytes aren't mistaken for a final xTextElt 
-	 */
-	*pad = 0;
-        }
-
-    /* 
-     * If the buffer pointer is not now pointing to a 32-bit boundary,
-     * we must flush the buffer so that it does point to a 32-bit boundary
-     * at the end of this routine. 
-     */
-
-    if ((dpy->bufptr - dpy->buffer) & 3)
-       _XFlush (dpy);
-    POSTAMBLE(dpy);
-    return 0;
-}
-
-
-int
-XAntiDrawText(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x, 
-    int y,
-    XTextItem *items,
-    int nitems
-){   
-    int i;
-    XTextItem *item;
-    int length = 0;
-    xAntiPolyText8Req *req;
-
-    PREAMBLE(dpy);
-    FlushGC(dpy, gc);
-    XAntiGetReq (PolyText8, req);
-    req->drawable = d;
-    req->gc = gc->gid;
-    req->x = x;
-    req->y = y;
-
-    item = items;
-    for (i=0; i < nitems; i++) {
-	if (item->font)
-	    length += 5;  /* a 255 byte, plus size of Font id */
-        if (item->delta) {
-	    if (item->delta > 0)
-	      length += SIZEOF(xTextElt) * ((item->delta + 126) / 127);
-            else
-   	      length += SIZEOF(xTextElt) * ((-item->delta + 127) / 128);
-        }
-	if (item->nchars > 0) {
-	    length += SIZEOF(xTextElt) * ((item->nchars + 253) / 254 - 1);
-	    if (!item->delta) length += SIZEOF(xTextElt);
-	    length += item->nchars;
-     	}
-	item++;
-    }
-
-    req->length += (length + 3)>>2;  /* convert to number of 32-bit words */
-
-
-    /* 
-     * If the entire request does not fit into the remaining space in the
-     * buffer, flush the buffer first.   If the request does fit into the
-     * empty buffer, then we won't have to flush it at the end to keep
-     * the buffer 32-bit aligned. 
-     */
-
-    if (dpy->bufptr + length > dpy->bufmax)
-    	_XFlush (dpy);
-
-    item = items;
-    for (i=0; i< nitems; i++) {
-
-	if (item->font) {
-            /* to mark a font shift, write a 255 byte followed by
-	       the 4 bytes of font ID, big-end first */
-	    register unsigned char *f;
-	    BufAlloc (unsigned char *, f, 5);
-
-	    f[0] = 255;
-	    f[1] = (item->font & 0xff000000) >> 24;
-	    f[2] = (item->font & 0x00ff0000) >> 16;
-	    f[3] = (item->font & 0x0000ff00) >> 8;
-	    f[4] =  item->font & 0x000000ff;
-
-            /* update GC shadow */
-	    gc->values.font = item->font;
-	}
-
-	{
-	    int nbytes = SIZEOF(xTextElt);
-	    int PartialNChars = item->nchars;
-	    int PartialDelta = item->delta;
-            /* register xTextElt *elt; */
-	    int FirstTimeThrough = True;
- 	    char *CharacterOffset = item->chars;
-            char *tbuf;
-
-	    while((PartialDelta < -128) || (PartialDelta > 127)) {
-	    	int nb = SIZEOF(xTextElt);
-
-	    	BufAlloc (char *, tbuf, nb); 
-	    	*tbuf = 0;    /*   elt->len  */
-	    	if (PartialDelta > 0 )  {
-		    *(tbuf+1) = 127;  /* elt->delta  */
-		    PartialDelta = PartialDelta - 127;
-		} else {
-		    /* -128 = 0x8, need to be careful of signed chars... */
-		    *((unsigned char *)(tbuf+1)) = 0x80;  /* elt->delta */
-		    PartialDelta = PartialDelta + 128;
-		}
-	    }
-	    if (PartialDelta) {
-                BufAlloc (char *, tbuf , nbytes); 
-	        *tbuf = 0;      /* elt->len */
-		*(tbuf+1) = PartialDelta;    /* elt->delta  */
-	    }
-	    while(PartialNChars > 254) {
-		nbytes = 254;
-	    	if (FirstTimeThrough) {
-		    FirstTimeThrough = False;
-		    if (!item->delta) { 
-			nbytes += SIZEOF(xTextElt);
-	   		BufAlloc (char *, tbuf, nbytes); 
-		        *(tbuf+1) = 0;     /* elt->delta */
-		    } else {
-			char *DummyChar;
-		        BufAlloc(char *, DummyChar, nbytes);
-		    }
-		} else {
- 		    nbytes += SIZEOF(xTextElt);
-	   	    BufAlloc (char *, tbuf, nbytes);
-		    *(tbuf+1) = 0;   /* elt->delta */
-		}
-		/* watch out for signs on chars */
-		*(unsigned char *)tbuf = 254;  /* elt->len */
-                memcpy (tbuf+2 , CharacterOffset, 254);
-		PartialNChars = PartialNChars - 254;
-		CharacterOffset += 254;
-
-	    }
-	    if (PartialNChars) {
-		nbytes = PartialNChars;
-	    	if (FirstTimeThrough) {
-		    FirstTimeThrough = False;
-		    if (!item->delta) { 
-			nbytes += SIZEOF(xTextElt);
-	   		BufAlloc (char *, tbuf, nbytes); 
-			*(tbuf+1) = 0;   /*  elt->delta  */
-		    }  else {
-			char *DummyChar;
-		        BufAlloc(char *, DummyChar, nbytes);
-		    }
-		} else {
- 		    nbytes += SIZEOF(xTextElt);
-	   	    BufAlloc (char *, tbuf, nbytes); 
-		    *(tbuf+1) = 0;   /* elt->delta  */
-		}
-	    	*tbuf = PartialNChars;   /*  elt->len  */
-                memcpy (tbuf+2 , CharacterOffset, PartialNChars);
-	    }
-	}
-    item++;
-    }
-
-    /* Pad request out to a 32-bit boundary */
-
-    if (length &= 3) {
-	char *pad;
-	/* 
-	 * BufAlloc is a macro that uses its last argument more than
-	 * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)" 
-	 */
-	length = 4 - length;
-	BufAlloc (char *, pad, length);
-	/* 
-	 * if there are 3 bytes of padding, the first byte MUST be 0
-	 * so the pad bytes aren't mistaken for a final xTextElt 
-	 */
-	*pad = 0;
-        }
-
-    /* 
-     * If the buffer pointer is not now pointing to a 32-bit boundary,
-     * we must flush the buffer so that it does point to a 32-bit boundary
-     * at the end of this routine. 
-     */
-
-    if ((dpy->bufptr - dpy->buffer) & 3)
-       _XFlush (dpy);
-    POSTAMBLE(dpy);
-    return 0;
-}
-
-
-int
-XAntiDrawText16(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x, 
-    int y,
-    XTextItem16 *items,
-    int nitems
-){   
-    int i;
-    XTextItem16 *item;
-    int length = 0;
-    xAntiPolyText16Req *req;
-
-    PREAMBLE(dpy);
-    FlushGC(dpy, gc);
-    XAntiGetReq (PolyText16, req);
-    req->drawable = d;
-    req->gc = gc->gid;
-    req->x = x;
-    req->y = y;
-
-    item = items;
-    for (i=0; i < nitems; i++) {
-	if (item->font)
-	    length += 5;  /* a 255 byte, plus size of Font id */
-        if (item->delta) {
-	    if (item->delta > 0)
-	      length += SIZEOF(xTextElt) * ((item->delta + 126) / 127);
-            else
-   	      length += SIZEOF(xTextElt) * ((-item->delta + 127) / 128);
-        }
-	if (item->nchars > 0) {
-	    length += SIZEOF(xTextElt) * ((item->nchars + 253) / 254 - 1);
-	    if (!item->delta) length += SIZEOF(xTextElt);
-	    length += item->nchars << 1;
-     	}
-	item++;
-    }
-
-    req->length += (length + 3)>>2;  /* convert to number of 32-bit words */
-
-
-    /*
-     * If the entire request does not fit into the remaining space in the
-     * buffer, flush the buffer first.   If the request does fit into the
-     * empty buffer, then we won't have to flush it at the end to keep
-     *  the buffer 32-bit aligned. 
-     */
-
-    if (dpy->bufptr + length > dpy->bufmax)
-    	_XFlush (dpy);
-
-    item = items;
-    for (i=0; i< nitems; i++) {
-
-	if (item->font) {
-            /* to mark a font shift, write a 255 byte followed by
-	       the 4 bytes of font ID, big-end first */
-	    register unsigned char *f;
-	    BufAlloc (unsigned char *, f, 5);
-
-
-	    f[0] = 255;
-	    f[1] = (item->font & 0xff000000) >> 24;
-	    f[2] = (item->font & 0x00ff0000) >> 16;
-	    f[3] = (item->font & 0x0000ff00) >> 8;
-	    f[4] =  item->font & 0x000000ff;
-
-            /* update GC shadow */
-	    gc->values.font = item->font;
-	}
-
-	{
-	    int nbytes = SIZEOF(xTextElt);
-	    int PartialNChars = item->nchars;
-	    int PartialDelta = item->delta;
-            xTextElt *elt;
-	    int FirstTimeThrough = True;
- 	    XChar2b *CharacterOffset = item->chars;
-
-	    while((PartialDelta < -128) || (PartialDelta > 127)) {
-	    	int nb = SIZEOF(xTextElt);
-
-	    	BufAlloc (xTextElt *, elt, nb); 
-	    	elt->len = 0;
-	    	if (PartialDelta > 0 ) {
-		    elt->delta = 127;
-		    PartialDelta = PartialDelta - 127;
-		} else {
-		    elt->delta = -128;
-		    PartialDelta = PartialDelta + 128;
-		}
-	    }
-	    if (PartialDelta) {
-                BufAlloc (xTextElt *, elt, nbytes); 
-	        elt->len = 0;
-		elt->delta = PartialDelta;
-	    }
-	    while(PartialNChars > 254) {
-		nbytes = 254 * 2;
-	    	if (FirstTimeThrough) {
-		    FirstTimeThrough = False;
-		    if (!item->delta) { 
-			nbytes += SIZEOF(xTextElt);
-	   		BufAlloc (xTextElt *, elt, nbytes); 
-		        elt->delta = 0;
-		    } else {
-			char *DummyChar;
-		        BufAlloc(char *, DummyChar, nbytes);
-		    }
-		} else {
- 		    nbytes += SIZEOF(xTextElt);
-	   	    BufAlloc (xTextElt *, elt, nbytes);
-		    elt->delta = 0;
-		}
-	    	elt->len = 254;
-
-#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
-		{
-		    register int i;
-		    register unsigned char *cp;
-		    for (i = 0, cp = ((unsigned char *)elt) + 2; i < 254; i++) {
-			*cp++ = CharacterOffset[i].byte1;
-			*cp++ = CharacterOffset[i].byte2;
-		    }
-		}
-#else
-		memcpy ((char *) (elt + 1), (char *)CharacterOffset, 254 * 2);
-#endif
-		PartialNChars = PartialNChars - 254;
-		CharacterOffset += 254;
-
-	    }
-	    if (PartialNChars) {
-		nbytes = PartialNChars * 2;
-	    	if (FirstTimeThrough) {
-		    FirstTimeThrough = False;
-		    if (!item->delta) { 
-			nbytes += SIZEOF(xTextElt);
-	   		BufAlloc (xTextElt *, elt, nbytes); 
-			elt->delta = 0;
-		    } else {
-			char *DummyChar;
-		        BufAlloc(char *, DummyChar, nbytes);
-		    }
-		} else {
- 		    nbytes += SIZEOF(xTextElt);
-	   	    BufAlloc (xTextElt *, elt, nbytes); 
-		    elt->delta = 0;
-		}
-	    	elt->len = PartialNChars;
-
-#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
-		{
-		    register int i;
-		    register unsigned char *cp;
-		    for (i = 0, cp = ((unsigned char *)elt) + 2; 
-			 i < PartialNChars;
-			 i++) {
-			*cp++ = CharacterOffset[i].byte1;
-			*cp++ = CharacterOffset[i].byte2;
-		    }
-		}
-#else
-		memcpy ((char *) (elt + 1), (char *)CharacterOffset,
-						PartialNChars * 2);
-#endif
-	    }
-	}
-    item++;
-    }
-
-    /* Pad request out to a 32-bit boundary */
-
-    if (length &= 3) {
-	char *pad;
-	/*
-	 * BufAlloc is a macro that uses its last argument more than
-	 * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)" 
-	 */
-	length = 4 - length;
-	BufAlloc (char *, pad, length);
-	/* 
-	 * if there are 3 bytes of padding, the first byte MUST be 0
-	 * so the pad bytes aren't mistaken for a final xTextElt 
-	 */
-	*pad = 0;
-        }
-
-    /* 
-     * If the buffer pointer is not now pointing to a 32-bit boundary,
-     * we must flush the buffer so that it does point to a 32-bit boundary
-     * at the end of this routine. 
-     */
-
-    if ((dpy->bufptr - dpy->buffer) & 3)
-       _XFlush (dpy);
-
-    POSTAMBLE(dpy);
-    return 1;
-}
-
-int
-XAntiDrawImageString(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x,
-    int y,
-    _Xconst char *string,
-    int length
-){   
-    xAntiImageText8Req *req;
-    char *CharacterOffset = (char *)string;
-    int FirstTimeThrough = True;
-    int lastX = 0;
-
-    PREAMBLE(dpy);
-    FlushGC(dpy, gc);
-
-    while (length > 0) {
-	int Unit;
-
-	if (length > 255) Unit = 255;
-	else Unit = length;
-
-   	if (FirstTimeThrough) {
-	    FirstTimeThrough = False;
-        } else {
-	    char buf[512];
-	    char *ptr, *str;
-	    xQueryTextExtentsReq *qreq;
-	    xQueryTextExtentsReply rep;
-	    int i;
-
-	    GetReq(QueryTextExtents, qreq);
-	    qreq->fid = gc->gid;
-	    qreq->length += (510 + 3)>>2;
-	    qreq->oddLength = 1;
-	    str = CharacterOffset - 255;
-	    for (ptr = buf, i = 255; --i >= 0; ) {
-		*ptr++ = 0;
-		*ptr++ = *str++;
-	    }
-	    Data (dpy, buf, 510);
-	    if (!_XReply (dpy, (xReply *)&rep, 0, xTrue))
-		break;
-
-	    x = lastX + cvtINT32toInt (rep.overallWidth);
-	}
-
-        XAntiGetReq (ImageText8, req);
-        req->length += (Unit + 3) >> 2;
-        req->nChars = Unit;
-        req->drawable = d;
-        req->gc = gc->gid;
-        req->y = y;
-
-	lastX = req->x = x;
-        Data (dpy, CharacterOffset, (long)Unit);
-        CharacterOffset += Unit;
-	length -= Unit;
-    }
-    POSTAMBLE(dpy);
-    return 0;
-}
-
-
-int
-XAntiDrawImageString16(
-    Display *dpy,
-    Drawable d,
-    GC gc,
-    int x,
-    int y,
-    _Xconst XChar2b *string,
-    int length
-){   
-    xAntiImageText16Req *req;
-    XChar2b *CharacterOffset = (XChar2b *)string;
-    int FirstTimeThrough = True;
-    int lastX = 0;
-
-    PREAMBLE(dpy);
-    FlushGC(dpy, gc);
-
-    while (length > 0)  {
-	int Unit, Datalength;
-
-	if (length > 255) Unit = 255;
-	else Unit = length;
-
-   	if (FirstTimeThrough) {
-	    FirstTimeThrough = False;
-        } else {
-	    char buf[512];
-	    xQueryTextExtentsReq *qreq;
-	    xQueryTextExtentsReply rep;
-	    unsigned char *ptr;
-	    XChar2b *str;
-	    int i;
-
-	    GetReq(QueryTextExtents, qreq);
-	    qreq->fid = gc->gid;
-	    qreq->length += (510 + 3)>>2;
-	    qreq->oddLength = 1;
-	    str = CharacterOffset - 255;
-	    for (ptr = (unsigned char *)buf, i = 255; --i >= 0; str++) {
-		*ptr++ = str->byte1;
-		*ptr++ = str->byte2;
-	    }
-	    Data (dpy, buf, 510);
-	    if (!_XReply (dpy, (xReply *)&rep, 0, xTrue))
-		break;
-
-	    x = lastX + cvtINT32toInt (rep.overallWidth);
-	}
-
-        XAntiGetReq (ImageText16, req);
-        req->length += ((Unit << 1) + 3) >> 2;
-        req->nChars = Unit;
-        req->drawable = d;
-        req->gc = gc->gid;
-        req->y = y;
-
-	lastX = req->x = x;
-	Datalength = Unit << 1;
-        Data (dpy, (char *)CharacterOffset, (long)Datalength);
-        CharacterOffset += Unit;
-	length -= Unit;
-    }
-    POSTAMBLE(dpy);
-    return 0;
-}
-
Index: xc/lib/Xanti/XAntiint.h
diff -u xc/lib/Xanti/XAntiint.h:1.1 xc/lib/Xanti/XAntiint.h:removed
--- xc/lib/Xanti/XAntiint.h:1.1	Sat Nov 14 23:29:57 1998
+++ xc/lib/Xanti/XAntiint.h	Mon Dec 18 14:24:13 2000
@@ -1,60 +0,0 @@
-/***********************************************************
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
-and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the names of Digital or MIT not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-/* $XFree86: xc/lib/Xanti/XAntiint.h,v 1.1 1998/11/15 04:29:57 dawes Exp $ */
-
-#ifndef XANTIINT_H
-#define XANTIINT_H
-
-#define NEED_REPLIES
-
-#include "Xlibint.h"
-#include "XAnti.h"
-
-#if defined(__STDC__) && !defined(UNIXCPP)
-#define XAntiGetReq(name, req) \
-        WORD64ALIGN\
-	if ((dpy->bufptr + SIZEOF(xAnti##name##Req)) > dpy->bufmax)\
-		_XFlush(dpy);\
-	req = (xAnti##name##Req *)(dpy->last_req = dpy->bufptr);\
-	req->reqType = _XAntiCodes->major_opcode;\
-        req->xAntiReqType = XAnti_##name; \
-        req->length = (SIZEOF(xAnti##name##Req))>>2;\
-	dpy->bufptr += SIZEOF(xAnti##name##Req);\
-	dpy->request++
-
-#else  /* non-ANSI C uses empty comment instead of "##" for token concatenation */
-#define XAntiGetReq(name, req) \
-        WORD64ALIGN\
-	if ((dpy->bufptr + SIZEOF(xAnti/**/name/**/Req)) > dpy->bufmax)\
-		_XFlush(dpy);\
-	req = (xAnti/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
-	req->reqType = _XAntiCodes->major_opcode;\
-	req->xAntiReqType = XAnti_/**/name;\
-	req->length = (SIZEOF(xAnti/**/name/**/Req))>>2;\
-	dpy->bufptr += SIZEOF(xAnti/**/name/**/Req);\
-	dpy->request++
-#endif
-
-
-#endif /* XANTIINT_H */
Index: xc/lib/Xaw/Actions.c
diff -u xc/lib/Xaw/Actions.c:3.14 xc/lib/Xaw/Actions.c:3.15
--- xc/lib/Xaw/Actions.c:3.14	Sun Jun  6 04:47:50 1999
+++ xc/lib/Xaw/Actions.c	Tue Sep 26 11:56:53 2000
@@ -25,12 +25,13 @@
  * XFree86 Project.
  */
 
-/* $XFree86: xc/lib/Xaw/Actions.c,v 3.14 1999/06/06 08:47:50 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/Actions.c,v 3.15 2000/09/26 15:56:53 tsi Exp $ */
 
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <X11/Xmd.h>
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
 #include <X11/CoreP.h>
@@ -403,7 +404,7 @@
   char  c_1;
   short c_2;
   int   c_4;
-#ifdef LONG_64
+#ifdef LONG64
   long  c_8;
 #endif
 
@@ -443,7 +444,7 @@
 	case 1: to.addr = (XPointer)&c_1; break;
 	case 2: to.addr = (XPointer)&c_2; break;
 	case 4: to.addr = (XPointer)&c_4; break;
-#ifdef LONG_64
+#ifdef LONG64
 	case 8: to.addr = (XPointer)&c_8; break;
 #endif
 	default:
@@ -458,8 +459,8 @@
 	}
 
       if (strcmp(XtRString, XrmQuarkToString(resource->qtype)) == 0)
-#ifdef LONG_64
-	c_8 = (int)from.addr;
+#ifdef LONG64
+	c_8 = (long)from.addr;
 #else
 	c_4 = (int)from.addr;
 #endif
@@ -478,7 +479,7 @@
 	case 4:
 	  XtSetArg(arglist[num_args], XrmQuarkToString(resource->qname), c_4);
 	  break;
-#ifdef LONG_64
+#ifdef LONG64
 	case 8:
 	  XtSetArg(arglist[num_args], XrmQuarkToString(resource->qname), c_8);
 	  break;
@@ -579,7 +580,7 @@
   char  c_1;
   short c_2;
   int   c_4;   
-#ifdef LONG_64
+#ifdef LONG64
   long  c_8;
 #endif
 
@@ -608,7 +609,7 @@
       XtSetArg(arg, XrmQuarkToString(resource->qname),
                from.addr = (XPointer)&c_4);
       break;
-#ifdef LONG_64
+#ifdef LONG64
     case 8:
       XtSetArg(arg, XrmQuarkToString(resource->qname),
 	       from.addr = (XPointer)&c_8);
@@ -675,8 +676,8 @@
 qcmp_action_resource_list(register _Xconst void *left,
 			  register _Xconst void *right)
 {   
-  return ((int)((*(XawActionResList **)left)->widget_class) -
-          (int)((*(XawActionResList **)right)->widget_class));
+  return ((char *)((*(XawActionResList **)left)->widget_class) -
+          (char *)((*(XawActionResList **)right)->widget_class));
 }
 
 static XawActionResList *
@@ -715,7 +716,7 @@
 bcmp_action_resource_list(register _Xconst void *wc,
 			  register _Xconst void *list)
 {
-  return ((int)wc - (int)((*(XawActionResList **)list)->widget_class));
+  return ((char *)wc - (char *)((*(XawActionResList **)list)->widget_class));
 }
 
 static XawActionResList *
@@ -966,8 +967,8 @@
 qcmp_action_variable_list(register _Xconst void *left,
 			  register _Xconst void *right)
 {
-  return ((int)((*(XawActionVarList **)left)->widget) -
-	  (int)((*(XawActionVarList **)right)->widget));
+  return ((char *)((*(XawActionVarList **)left)->widget) -
+	  (char *)((*(XawActionVarList **)right)->widget));
 }
 
 static XawActionVarList *
@@ -1012,7 +1013,7 @@
 bcmp_action_variable_list(register _Xconst void *widget,
 			  register _Xconst void *list)
 {
-  return ((int)widget - (int)((*(XawActionVarList **)list)->widget));
+  return ((char *)widget - (char *)((*(XawActionVarList **)list)->widget));
 }
 
 static XawActionVarList *
Index: xc/lib/Xaw/AsciiSink.c
diff -u xc/lib/Xaw/AsciiSink.c:1.21 xc/lib/Xaw/AsciiSink.c:1.22
--- xc/lib/Xaw/AsciiSink.c:1.21	Mon Sep 27 02:29:09 1999
+++ xc/lib/Xaw/AsciiSink.c	Tue Sep 26 11:56:53 2000
@@ -42,7 +42,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/Xaw/AsciiSink.c,v 1.21 1999/09/27 06:29:09 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/AsciiSink.c,v 1.22 2000/09/26 15:56:53 tsi Exp $ */
 
 #include <stdio.h>
 #include <X11/IntrinsicP.h>
@@ -1614,7 +1614,7 @@
     XGCValues values;
 
     /* XXX We dont want do share a gc that will change the clip-mask */
-    values.clip_x_origin = (int)sink;
+    values.clip_x_origin = (long)sink;
     values.clip_mask = None;
     values.font = sink->ascii_sink.font->fid;
     values.graphics_exposures = False;
Index: xc/lib/Xaw/AsciiSrc.c
diff -u xc/lib/Xaw/AsciiSrc.c:1.24 xc/lib/Xaw/AsciiSrc.c:1.25
--- xc/lib/Xaw/AsciiSrc.c:1.24	Tue Jun 13 19:15:48 2000
+++ xc/lib/Xaw/AsciiSrc.c	Tue Nov 28 12:25:09 2000
@@ -22,7 +22,7 @@
 
 */
 
-/* $XFree86: xc/lib/Xaw/AsciiSrc.c,v 1.24 2000/06/13 23:15:48 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/AsciiSrc.c,v 1.25 2000/11/28 17:25:09 dawes Exp $ */
 
 /*
  * AsciiSrc.c - AsciiSrc object. (For use with the text widget).
@@ -43,13 +43,17 @@
 #include <X11/Xmu/Misc.h>
 #include <X11/Xaw/XawInit.h>
 #include <X11/Xaw/AsciiSrcP.h>
-#include <X11/Xaw/MultiSrcP.h> 
+#include <X11/Xaw/MultiSrcP.h>
 #ifndef OLDXAW
 #include <X11/Xaw/TextSinkP.h>
 #include <X11/Xaw/AsciiSinkP.h>
 #endif
 #include "Private.h"
 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
 #if (defined(ASCII_STRING) || defined(ASCII_DISK))
 #include <X11/Xaw/AsciiText.h>		/* for Widget Classes */
 #endif
@@ -1398,7 +1402,9 @@
 static FILE *
 InitStringOrFile(AsciiSrcObject src, Bool newString)
 {
-    char *open_mode = NULL;
+    mode_t open_mode = 0;
+    const char *fdopen_mode = NULL;
+    int fd;
     FILE *file;
     char fileName[TMPSIZ];
 
@@ -1438,7 +1444,8 @@
 		XtErrorMsg("NoFile", "asciiSourceCreate", "XawError",
 			   "Creating a read only disk widget and no file specified.",
 			   NULL, 0);
-	    open_mode = "r";
+	    open_mode = O_RDONLY;
+	    fdopen_mode = "r";
 	    break;
 	case XawtextAppend:
 	case XawtextEdit:
@@ -1446,10 +1453,17 @@
 		src->ascii_src.string = fileName;
 		(void)tmpnam(src->ascii_src.string);
 		src->ascii_src.is_tempfile = True;
-		open_mode = "w";
+		open_mode = O_WRONLY | O_CREAT | O_EXCL;
+		fdopen_mode = "w";
 	    }
 	    else
-		open_mode = "r+";
+/* O_NOFOLLOW is a FreeBSD & Linux extension */
+#ifdef O_NOFOLLOW
+		open_mode = O_RDWR | O_NOFOLLOW;
+#else
+		open_mode = O_RDWR; /* unsafe; subject to race conditions */
+#endif /* O_NOFOLLOW */
+		fdopen_mode = "r+";
 	    break;
 	default:
 	    XtErrorMsg("badMode", "asciiSourceCreate", "XawError",
@@ -1469,12 +1483,14 @@
     }
 
     if (!src->ascii_src.is_tempfile) {
-	if ((file = fopen(src->ascii_src.string, open_mode)) != 0) {
-	    (void)fseek(file, 0, 2);
-	    src->ascii_src.length = (XawTextPosition)ftell(file);
-	    return (file);
+	if ((fd = open(src->ascii_src.string, open_mode, 0666))) {
+	    if ((file = fdopen(fd, fdopen_mode))) {
+		(void)fseek(file, 0, SEEK_END);
+		src->ascii_src.length = (XawTextPosition)ftell(file);
+		return (file);
+	    }
 	}
-	else {
+	{
 	    String params[2];
 	    Cardinal num_params = 2;
 
@@ -1483,10 +1499,10 @@
 	    XtAppWarningMsg(XtWidgetToApplicationContext((Widget)src),
 			    "openError", "asciiSourceCreate", "XawWarning",
 			    "Cannot open file %s; %s", params, &num_params);
-	  }
-      }
-      src->ascii_src.length = 0;
-      return (NULL);
+	}
+    }
+    src->ascii_src.length = 0;
+    return (NULL);
 }
 
 static void
Index: xc/lib/Xaw/DisplayList.c
diff -u xc/lib/Xaw/DisplayList.c:3.15 xc/lib/Xaw/DisplayList.c:3.16
--- xc/lib/Xaw/DisplayList.c:3.15	Sat Aug 28 05:00:26 1999
+++ xc/lib/Xaw/DisplayList.c	Tue Sep 26 11:56:54 2000
@@ -27,7 +27,7 @@
  * Author: Paulo César Pereira de Andrade
  */
 
-/* $XFree86: xc/lib/Xaw/DisplayList.c,v 3.15 1999/08/28 09:00:26 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/DisplayList.c,v 3.16 2000/09/26 15:56:54 tsi Exp $ */
 
 #include <ctype.h>
 #include <string.h>
@@ -910,7 +910,7 @@
 	    XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  unsigned line_width = (unsigned)args;
+  unsigned line_width = (unsigned long)args;
 
   if (xdata->values.line_width != line_width)
     {
@@ -986,7 +986,7 @@
 	  XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int arc_mode  = (int)args;
+  int arc_mode  = (long)args;
 
   if (xdata->values.arc_mode != arc_mode)
     {
@@ -1002,7 +1002,7 @@
 	    XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int mode  = (int)args;
+  int mode  = (long)args;
 
   xdata->mode = mode;
 }
@@ -1013,7 +1013,7 @@
 	    XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int shape  = (int)args;
+  int shape  = (long)args;
 
   xdata->shape = shape;
 }
@@ -1024,7 +1024,7 @@
 	    XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int line_style = (int)args;
+  int line_style = (long)args;
 
   if (xdata->values.line_style != line_style)
     {
@@ -1040,7 +1040,7 @@
 	   XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int cap_style = (int)args;
+  int cap_style = (long)args;
 
   if (xdata->values.cap_style != cap_style)
     {
@@ -1056,7 +1056,7 @@
 	    XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int join_style = (int)args;
+  int join_style = (long)args;
 
   if (xdata->values.join_style != join_style)
     {
@@ -1072,7 +1072,7 @@
 	    XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int fill_style = (int)args;
+  int fill_style = (long)args;
 
   if (xdata->values.fill_style != fill_style)
     {
@@ -1088,7 +1088,7 @@
 	   XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int fill_rule = (int)args;
+  int fill_rule = (long)args;
 
   if (xdata->values.fill_rule != fill_rule)
     {
@@ -1143,7 +1143,7 @@
 	   XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int function = (int)args;
+  int function = (long)args;
 
   if (function != xdata->values.function)
     {
@@ -1258,7 +1258,7 @@
 		XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  int subwindow_mode = (int)args;
+  int subwindow_mode = (long)args;
 
   if (xdata->values.subwindow_mode != subwindow_mode)
     {
@@ -1274,7 +1274,7 @@
 	    XEvent *event, Region region)
 {
   XawXlibData *xdata = (XawXlibData *)data;
-  Bool graphics_exposures = (Bool)args;
+  Bool graphics_exposures = (Bool)(long)args;
 
   if (xdata->values.graphics_exposures != graphics_exposures)
     {
@@ -1594,10 +1594,10 @@
   return (strcmp((String)string, ((Dl_init*)dlinfo)->name));
 }
 
-static int
+static long
 read_int(char *cp, char **cpp)
 {
-  int value = 0, sign = 1;
+  long value = 0, sign = 1;
 
   if (*cp == '-')
     {
Index: xc/lib/Xaw/Form.c
diff -u xc/lib/Xaw/Form.c:1.16 xc/lib/Xaw/Form.c:1.18
--- xc/lib/Xaw/Form.c:1.16	Fri Nov 19 08:53:26 1999
+++ xc/lib/Xaw/Form.c	Thu Oct 26 13:57:49 2000
@@ -43,7 +43,7 @@
 
 ******************************************************************/
 
-/* $XFree86: xc/lib/Xaw/Form.c,v 1.16 1999/11/19 13:53:26 hohndel Exp $ */
+/* $XFree86: xc/lib/Xaw/Form.c,v 1.18 2000/10/26 17:57:49 dawes Exp $ */
 
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
@@ -877,6 +877,10 @@
     else {
 	if ((*((FormWidgetClass)fw->core.widget_class)->form_class.layout)
 		(fw, XtWidth(w), XtHeight(w), False)) {
+	    Widget *childP;
+	    int num_children = fw->composite.num_children;
+	    WidgetList children = fw->composite.children;
+
 	    if (fw->form.no_refigure) {
 		/*
 		 * I am changing the widget wrapper w/o modifing the window.
@@ -887,11 +891,33 @@
 		 * The window will be updated when no_refigure is set back
 		 * to False
 		 */
+		form->form.virtual_width = XtWidth(w);
+		form->form.virtual_height = XtHeight(w);
 		form->form.deferred_resize = True;
 		ret_val = XtGeometryDone;
 	    }
 	    else
 		ret_val = XtGeometryYes;
+
+	    /*
+	     * Resets everything.
+	     */
+	    for (childP = children; childP - children < num_children; childP++) {
+		Widget nw = *childP;
+
+		if (XtIsManaged(nw)) {
+		    FormConstraints nform = (FormConstraints)nw->core.constraints;
+
+#ifndef OLDXAW
+		    nform->form.virtual_x = XtX(nw);
+		    nform->form.virtual_y = XtY(nw);
+#endif
+		    nform->form.virtual_width = XtWidth(nw);
+		    nform->form.virtual_height = XtHeight(nw);
+		}
+	    }
+	    fw->form.old_width = XtWidth(fw);
+	    fw->form.old_height = XtHeight(fw);
 	}
 	else {
 	    XtWidth(w) = old_width;
@@ -900,42 +926,6 @@
 	}
     }
 
-    if (ret_val == XtGeometryDone) {
-#ifndef OLDXAW
-	int x, y, width, height;
-
-	if (fw->form.old_width && fw->form.old_height) {
-	    x = TransformCoord(XtX(w), XtWidth(fw), fw->form.old_width,
-			      form->form.left);
-	    y = TransformCoord(XtY(w), XtHeight(fw), fw->form.old_height,
-			       form->form.top);
-	    width = TransformCoord(XtX(w) + XtWidth(w) +
-				   (XtBorderWidth(w) << 1),
-				   XtWidth(fw), fw->form.old_width,
-				   form->form.right) -
-				   (x + (XtBorderWidth(w) << 1));
-	    height = TransformCoord(XtY(w) + XtHeight(w) +
-				    (XtBorderWidth(w) << 1),
-				    XtHeight(fw), fw->form.old_height,
-				    form->form.bottom) -
-				    (y + (XtBorderWidth(w) << 1));
-	}
-	else {
-	    x = XtX(w);
-	    y = XtY(w);
-	    width = XtWidth(w);
-	    height = XtHeight(w);
-	}
-	form->form.virtual_x = x;
-	form->form.virtual_y = y;
-	form->form.virtual_width = width;
-	form->form.virtual_height = height;
-#else
-	form->form.virtual_width = XtWidth(w);
-	form->form.virtual_height = XtHeight(w);
-#endif /* OLDXAW */
-    }
-
     return (ret_val);
 }
 
@@ -1099,7 +1089,7 @@
 	Widget nw = *childP;
 
 	if (XtIsManaged(nw)) {
-	    FormConstraints form = (FormConstraints)w->core.constraints;
+	    FormConstraints form = (FormConstraints)nw->core.constraints;
 
 	    /*
 	     * Xt Configure widget is too smart, and optimizes out
Index: xc/lib/Xaw/MultiSink.c
diff -u xc/lib/Xaw/MultiSink.c:1.17 xc/lib/Xaw/MultiSink.c:1.18
--- xc/lib/Xaw/MultiSink.c:1.17	Sun Jun 13 09:47:19 1999
+++ xc/lib/Xaw/MultiSink.c	Tue Sep 26 11:56:54 2000
@@ -66,7 +66,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/Xaw/MultiSink.c,v 1.17 1999/06/13 13:47:19 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/MultiSink.c,v 1.18 2000/09/26 15:56:54 tsi Exp $ */
 
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
@@ -655,7 +655,7 @@
     XGCValues values;
 
     /* XXX We dont want do share a gc that will change the clip-mask */
-    values.clip_x_origin = (int)sink;
+    values.clip_x_origin = (long)sink;
     values.clip_mask = None;
     values.graphics_exposures = False;
     
Index: xc/lib/Xaw/Pixmap.c
diff -u xc/lib/Xaw/Pixmap.c:3.14 xc/lib/Xaw/Pixmap.c:3.15
--- xc/lib/Xaw/Pixmap.c:3.14	Thu May 18 12:29:52 2000
+++ xc/lib/Xaw/Pixmap.c	Tue Sep 26 11:56:54 2000
@@ -25,7 +25,7 @@
  * XFree86 Project.
  */
 
-/* $XFree86: xc/lib/Xaw/Pixmap.c,v 3.14 2000/05/18 16:29:52 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/Pixmap.c,v 3.15 2000/09/26 15:56:54 tsi Exp $ */
 
 #include <string.h>
 #include <stdio.h>
@@ -390,7 +390,7 @@
 static int
 bcmp_x_cache(register _Xconst void *pixmap, register _Xconst void *xaw)
 {
-  return ((int)pixmap - (int)((*(XawPixmap **)xaw)->pixmap));
+  return (int)((long)pixmap - (long)((*(XawPixmap **)xaw)->pixmap));
 }
 
 static int
@@ -452,7 +452,7 @@
     return (*cache);
 
   /* Depth */
-  cache = (XawCache **)bsearch((void *)depth, (*cache)->elems,
+  cache = (XawCache **)bsearch((void *)(long)depth, (*cache)->elems,
 			       (*cache)->num_elems, sizeof(XtPointer),
 			       bcmp_long);
 
Index: xc/lib/Xaw/Scrollbar.c
diff -u xc/lib/Xaw/Scrollbar.c:1.9 xc/lib/Xaw/Scrollbar.c:1.11
--- xc/lib/Xaw/Scrollbar.c:1.9	Sun Jun  6 04:48:08 1999
+++ xc/lib/Xaw/Scrollbar.c	Tue Sep 26 11:56:54 2000
@@ -42,7 +42,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/Xaw/Scrollbar.c,v 1.9 1999/06/06 08:48:08 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/Scrollbar.c,v 1.11 2000/09/26 15:56:54 tsi Exp $ */
 
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
@@ -752,7 +752,7 @@
 NotifyScroll(Widget gw, XEvent *event, String *params, Cardinal *num_params)
 {
     ScrollbarWidget w = (ScrollbarWidget)gw;
-    int call_data = 0;
+    long call_data = 0;
     char style;
     Position x, y;
 
@@ -831,6 +831,10 @@
 NotifyThumb(Widget gw, XEvent *event, String *params, Cardinal *num_params)
 {
     ScrollbarWidget w = (ScrollbarWidget)gw;
+    union {
+	XtPointer xtp;
+	float xtf;
+    } xtpf;
 
     if (w->scrollbar.direction == 0)	/* if no StartScroll */
 	return;
@@ -841,7 +845,8 @@
     /* thumbProc is not pretty, but is necessary for backwards
        compatibility on those architectures for which it work{s,ed};
        the intent is to pass a (truncated) float by value. */
-    XtCallCallbacks(gw, XtNthumbProc, *(XtPointer*)&w->scrollbar.top);
+    xtpf.xtf = w->scrollbar.top;
+    XtCallCallbacks(gw, XtNthumbProc, xtpf.xtp);
     XtCallCallbacks(gw, XtNjumpProc, (XtPointer)&w->scrollbar.top);
 
     PaintThumb(w);
Index: xc/lib/Xaw/Text.c
diff -u xc/lib/Xaw/Text.c:3.35 xc/lib/Xaw/Text.c:3.40
--- xc/lib/Xaw/Text.c:3.35	Tue Jun 13 19:15:48 2000
+++ xc/lib/Xaw/Text.c	Thu Dec  7 15:26:12 2000
@@ -70,7 +70,7 @@
  * XFree86 Project.
  */
 
-/* $XFree86: xc/lib/Xaw/Text.c,v 3.35 2000/06/13 23:15:48 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/Text.c,v 3.40 2000/12/07 20:26:12 dawes Exp $ */
 
 #include <stdio.h>
 #include <X11/IntrinsicP.h>
@@ -1729,10 +1729,10 @@
 HScroll(Widget w, XtPointer closure, XtPointer callData)
 {
     TextWidget ctx = (TextWidget)closure;
-    int pixels = (int)callData;
+    long pixels = (long)callData;
 
     if (pixels > 0) {
-	int max;
+	long max;
 
 	max = (int)GetWidestLine(ctx) + ctx->text.left_margin -
 	      ctx->text.r_margin.left;
@@ -1753,7 +1753,7 @@
 {
     TextWidget ctx = (TextWidget)closure;
     float percent = *(float *)callData;
-    int pixels;
+    long pixels;
 
     pixels = ctx->text.left_margin -
 	     (ctx->text.r_margin.left - (int)(percent * GetWidestLine(ctx)));
@@ -1821,12 +1821,12 @@
 VScroll(Widget w, XtPointer closure, XtPointer callData)
 {
     TextWidget ctx = (TextWidget)closure;
-    int height, lines = (int)callData;
+    long height, lines = (long)callData;
 
-    height = (int)XtHeight(ctx) - (int)VMargins(ctx);
+    height = XtHeight(ctx) - VMargins(ctx);
     if (height < 1)
 	height = 1;
-    lines = (int)(lines * (int)ctx->text.lt.lines) / height;
+    lines = (lines * ctx->text.lt.lines) / height;
     _XawTextPrepareToUpdate(ctx);
     XawTextScroll(ctx, lines, 0);
     _XawTextExecuteUpdate(ctx);
@@ -1958,26 +1958,25 @@
 	if (SrcCvtSel(src, selection, target, type, value, length, format))
 	    return (True);
 
+	XtSetArg(args[0], XtNeditType, &edit_mode);
+	XtGetValues(src, args, ONE);
+
 	XmuConvertStandardSelection(w, ctx->text.time, selection,
 				    target, type, (XPointer*)&std_targets,
 				    &std_length, format);
 
-	*value = XtMalloc((unsigned)sizeof(Atom)*(std_length + 7));
+	*length = 7 + (edit_mode == XawtextEdit) + std_length;
+	*value = XtMalloc((unsigned)sizeof(Atom)*(*length));
 	targetP = *(Atom**)value;
-	*length = std_length + 6;
 	*targetP++ = XA_STRING;
 	*targetP++ = XA_TEXT(d);
+	*targetP++ = XA_UTF8_STRING(d);
 	*targetP++ = XA_COMPOUND_TEXT(d);
 	*targetP++ = XA_LENGTH(d);
 	*targetP++ = XA_LIST_LENGTH(d);
 	*targetP++ = XA_CHARACTER_POSITION(d);
-
-	XtSetArg(args[0], XtNeditType, &edit_mode);
-	XtGetValues(src, args, ONE);
-
 	if (edit_mode == XawtextEdit) {
 	    *targetP++ = XA_DELETE(d);
-	    (*length)++;
 	}
 	(void)memmove((char*)targetP, (char*)std_targets,
 		      sizeof(Atom) * std_length);
@@ -2000,7 +1999,9 @@
 	    return (False);
 	s = &salt->s;
     }
-    if (*target == XA_STRING || *target == XA_TEXT(d)
+    if (*target == XA_STRING
+	|| *target == XA_TEXT(d)
+	|| *target == XA_UTF8_STRING(d)
 	|| *target == XA_COMPOUND_TEXT(d)) {
 	if (*target == XA_TEXT(d)) {
 	    if (XawTextFormat(ctx, XawFmtWide))
@@ -2039,6 +2040,7 @@
 	    strcpy ((char *)*value, salt->contents);
 	    *length = salt->length;
 	}
+	/* Got *value,*length, now in COMPOUND_TEXT format. */
 	if (XawTextFormat(ctx, XawFmtWide) && *type == XA_STRING) {
 	    XTextProperty textprop;
 	    wchar_t **wlist;
@@ -2048,20 +2050,40 @@
 	    textprop.value = (unsigned char *)*value;
 	    textprop.nitems = strlen(*value);
 	    textprop.format = 8;
-	    if (XwcTextPropertyToTextList(d, &textprop, (wchar_t ***)&wlist,
-					  &count) < Success) {
+	    if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
+		 < Success
+		|| count < 1) {
 		XtFree((char *)*value);
 		return (False);
 	    }
 	    XtFree((char *)*value);
-	    if (XwcTextListToTextProperty(d, (wchar_t **)wlist, 1,
-					  XStringStyle, &textprop) < Success) {
+	    if (XwcTextListToTextProperty(d, wlist, 1, XStringStyle, &textprop)
+		 < Success) {
 		XwcFreeStringList((wchar_t**) wlist);
 		return (False);
 	    }
 	    *value = (XtPointer)textprop.value;
 	    *length = textprop.nitems;
-	    XwcFreeStringList((wchar_t**)wlist);
+	    XwcFreeStringList(wlist);
+	} else if (*type == XA_UTF8_STRING(d)) {
+	    XTextProperty textprop;
+	    char **list;
+	    int count;
+
+	    textprop.encoding = XA_COMPOUND_TEXT(d);
+	    textprop.value = (unsigned char *)*value;
+	    textprop.nitems = strlen(*value);
+	    textprop.format = 8;
+	    if (Xutf8TextPropertyToTextList(d, &textprop, &list, &count)
+		 < Success
+		|| count < 1) {
+		XtFree((char *)*value);
+		return (False);
+	    }
+	    XtFree((char *)*value);
+	    *value = *list;
+	    *length = strlen(*list);
+	    XFree(list);
 	}
 	*format = 8;
 	return (True);
@@ -2723,8 +2745,6 @@
     TextWidget ctx = (TextWidget)w;
     int y, line;
     XawTextPosition from, to, lastPos;
-    XmuScanline *scan;
-    XmuSegment *seg;
     Bool cleol = ctx->text.clear_to_eol;
     Bool has_selection = ctx->text.s.right > ctx->text.s.left;
     XawTextPaintList *paint_list;
@@ -3026,7 +3046,8 @@
 
     _XawTextShowPosition(ctx);
 
-    if (visible && left_margin == ctx->text.left_margin) {
+    if (XtIsRealized((Widget)ctx) && visible &&
+	left_margin == ctx->text.left_margin) {
 	int insert_line = LineForPosition(ctx, ctx->text.insertPos);
 	int scroll_by = insert_line - (ctx->text.lt.lines >> 1);
 	Boolean clear_to_eol = ctx->text.clear_to_eol;
Index: xc/lib/Xaw/TextAction.c
diff -u xc/lib/Xaw/TextAction.c:3.34 xc/lib/Xaw/TextAction.c:3.35
--- xc/lib/Xaw/TextAction.c:3.34	Mon Sep 27 02:29:10 1999
+++ xc/lib/Xaw/TextAction.c	Thu Dec  7 15:26:12 2000
@@ -21,7 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/Xaw/TextAction.c,v 3.34 1999/09/27 06:29:10 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/TextAction.c,v 3.35 2000/12/07 20:26:12 dawes Exp $ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -88,7 +88,6 @@
 static int LocalInsertNewLine(TextWidget, XEvent*);
 static void LoseSelection(Widget, Atom*);
 static void ParameterError(Widget, String);
-static int ProbablyMB(char*);
 static Bool MatchSelection(Atom, XawTextSelection*);
 static void ModifySelection(TextWidget, XEvent*, XawTextSelectionMode,
 			    XawTextSelectionAction, String*, Cardinal*);
@@ -350,36 +349,18 @@
     String* params;
     Cardinal count;
     Time time;
-    Boolean CT_asked;	/* flag if asked XA_COMPOUND_TEXT */
-    Atom selection;	/* selection atom when asking XA_COMPOUND_TEXT */
+    int asked;		/* which selection currently has been asked for:
+			   0 = UTF8_STRING, 1 = COMPOUND_TEXT, 2 = STRING */
+    Atom selection;	/* selection atom (normally XA_PRIMARY) */
 };
 
-static int
-ProbablyMB(char *s)
-{
-    int escapes = 0;
-    int has_hi_bit = False;
-
-    /* if it has more than one ESC char, I assume it is COMPOUND_TEXT.
-       If it has at least one hi bit set character, I pretend it is multibyte. */
-
-    while ((*s) != (wchar_t)0) {
-	if (*s & 128)
-	    has_hi_bit = True;
-	if (*s++ == '\033')
-	    escapes++;
-	if (escapes >= 2)
-	    return (0);
-    }
-    return (has_hi_bit);
-}
-
 /*ARGSUSED*/
 static void
 _SelectionReceived(Widget w, XtPointer client_data, Atom *selection,
 		   Atom *type, XtPointer value, unsigned long *length,
 		   int *format)
 {
+    Display *d = XtDisplay(w);
     TextWidget ctx = (TextWidget)w;
     XawTextBlock text;
 
@@ -387,16 +368,23 @@
 	struct _SelectionList* list = (struct _SelectionList*)client_data;
 
 	if (list != NULL) {
-	    if (list->CT_asked) {
-
-		/* If we just asked for a XA_COMPOUND_TEXT and got a null
-		   response, we'll ask again, this time for an XA_STRING. */
-		list->CT_asked = False;
+	    if (list->asked == 0) {
+		/* If we just asked for XA_UTF8_STRING and got no response,
+		   we'll ask again, this time for XA_COMPOUND_TEXT. */
+		list->asked++;
+		XtGetSelectionValue(w, list->selection, XA_COMPOUND_TEXT(d),
+				    _SelectionReceived,
+				    (XtPointer)list, list->time);
+	    } else if (list->asked == 1) {
+		/* If we just asked for XA_COMPOUND_TEXT and got no response,
+		   we'll ask again, this time for XA_STRING. */
+		list->asked++;
 		XtGetSelectionValue(w, list->selection, XA_STRING,
 				    _SelectionReceived,
 				    (XtPointer)list, list->time);
-	    }
-	    else {
+	    } else {
+		/* We tried all possible text targets in this param.
+		   Recurse on the tail of the params list. */
 		GetSelection(w, list->time, list->params, list->count);
 		XtFree(client_data);
 	    }
@@ -404,51 +392,31 @@
 	return;
     }
 
-    /* Many programs, especially old terminal emulators, give us multibyte text
-       but tell us it is COMPOUND_TEXT :(  The following routine checks to see
-       if the string is a legal multibyte string in our locale using a spooky
-       heuristic :O and if it is we can only assume the sending client is using
-       the same locale as we are, and convert it.  I also warn the user that the
-       other client is evil */
-
     StartAction(ctx, NULL);
     if (XawTextFormat(ctx, XawFmtWide)) {
 	XTextProperty textprop;
-	Display *d = XtDisplay((Widget)ctx);
 	wchar_t **wlist;
 	int count;
-	int try_CT = 1;
-
-	/* IS THE SELECTION IN MULTIBYTE FORMAT? */
-	if (ProbablyMB( (char *)value)) {
-	    char *list[1];
-
-	    list[0] = (char *)value;
-	    if (XmbTextListToTextProperty(d, (char**)list, 1, XCompoundTextStyle,
-					  &textprop) == Success)
-		try_CT = 0;
-	}
 
-	/* OR IN COMPOUND TEXT FORMAT? */
-	if (try_CT) {
-	    textprop.encoding = XA_COMPOUND_TEXT(d);
-	    textprop.value = (unsigned char *)value;
-	    textprop.nitems = strlen(value);
-	    textprop.format = 8;
-	}
-
-	if (XwcTextPropertyToTextList(d, &textprop, (wchar_t***)&wlist, &count)
-	    !=	Success)  {
-	    XwcFreeStringList((wchar_t**)wlist);
+	textprop.encoding = *type;
+	textprop.value = (unsigned char *)value;
+	textprop.nitems = strlen(value);
+	textprop.format = 8;
+
+	if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
+	    !=	Success
+	    || count < 1) {
+	    XwcFreeStringList(wlist);
 
 	    /* Notify the user on strerr and in the insertion :) */
-	    textprop.value = (unsigned char *)" >> ILLEGAL SELECTION << ";
-	    count = 1;
 	    fprintf(stderr, "Xaw Text Widget: An attempt was made to insert "
 		    "an illegal selection.\n");
 
-	    if (XwcTextPropertyToTextList(d, &textprop, (wchar_t***)&wlist,
-					  &count) !=  Success)
+	    textprop.value = (unsigned char *)" >> ILLEGAL SELECTION << ";
+	    textprop.nitems = strlen((char *) textprop.value);
+	    if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
+		!=  Success
+		|| count < 1)
 		return;
 	}
 
@@ -458,9 +426,40 @@
 	*length = wcslen(wlist[0]);
 	XtFree((XtPointer)wlist);
 	text.format = XawFmtWide;
-    }
-    else
+    } else {
+	XTextProperty textprop;
+	char **list;
+	int count;
+
+	textprop.encoding = *type;
+	textprop.value = (unsigned char *)value;
+	textprop.nitems = strlen(value);
+	textprop.format = 8;
+
+	if (XmbTextPropertyToTextList(d, &textprop, &list, &count)
+	    !=	Success
+	    || count < 1) {
+	    XFreeStringList(list);
+
+	    /* Notify the user on strerr and in the insertion :) */
+	    fprintf(stderr, "Xaw Text Widget: An attempt was made to insert "
+		    "an illegal selection.\n");
+
+	    textprop.value = (unsigned char *)" >> ILLEGAL SELECTION << ";
+	    textprop.nitems = strlen((char *) textprop.value);
+	    if (XmbTextPropertyToTextList(d, &textprop, &list, &count)
+		!=  Success
+		|| count < 1)
+		return;
+	}
+
+	XFree(value);
+	value = (XPointer)list[0];
+
+	*length = strlen(list[0]);
+	XtFree((XtPointer)list);
 	text.format = XawFmt8Bit;
+    }
     text.ptr = (char*)value;
     text.firstPos = 0;
     text.length = *length;
@@ -517,12 +516,12 @@
 	    list->params = params + 1;
 	    list->count = num_params;
 	    list->time = timev;
-	    list->CT_asked = True;
+	    list->asked = 0;
 	    list->selection = selection;
 	}
 	else
 	    list = NULL;
-	XtGetSelectionValue(w, selection, XA_COMPOUND_TEXT(XtDisplay(w)),
+	XtGetSelectionValue(w, selection, XA_UTF8_STRING(XtDisplay(w)),
 			    _SelectionReceived, (XtPointer)list, timev);
     }
 }
@@ -983,27 +982,25 @@
 	if (SrcCvtSel(src, selection, target, type, value, length, format))
 	    return (True);
 
+	XtSetArg(args[0], XtNeditType,&edit_mode);
+	XtGetValues(src, args, 1);
+
 	XmuConvertStandardSelection(w, ctx->text.time, selection,
 				    target, type, (XPointer *)&std_targets,
 				    &std_length, format);
 
-	*value = XtMalloc((unsigned)sizeof(Atom) * (std_length + 7));
+	*length = 7 + (edit_mode == XawtextEdit) + std_length;
+	*value = XtMalloc((unsigned)sizeof(Atom)*(*length));
 	targetP = *(Atom**)value;
-
-	*length = std_length + 6;
 	*targetP++ = XA_STRING;
 	*targetP++ = XA_TEXT(d);
+	*targetP++ = XA_UTF8_STRING(d);
 	*targetP++ = XA_COMPOUND_TEXT(d);
 	*targetP++ = XA_LENGTH(d);
 	*targetP++ = XA_LIST_LENGTH(d);
 	*targetP++ = XA_CHARACTER_POSITION(d);
-
-	XtSetArg(args[0], XtNeditType,&edit_mode);
-	XtGetValues(src, args, 1);
-
 	if (edit_mode == XawtextEdit) {
 	    *targetP++ = XA_DELETE(d);
-	    (*length)++;
 	}
 	memcpy((char*)targetP, (char*)std_targets, sizeof(Atom)*std_length);
 	XtFree((char*)std_targets);
@@ -1023,6 +1020,7 @@
     s = &salt->s;
     if (*target == XA_STRING
 	|| *target == XA_TEXT(d)
+	|| *target == XA_UTF8_STRING(d)
 	|| *target == XA_COMPOUND_TEXT(d)) {
 	if (*target == XA_TEXT(d)) {
 	    if (XawTextFormat(ctx, XawFmtWide))
@@ -1062,6 +1060,7 @@
 	    strcpy (*value, salt->contents);
 	    *length = salt->length;
 	}
+	/* Got *value,*length, now in COMPOUND_TEXT format. */
 	if (XawTextFormat(ctx, XawFmtWide) && *type == XA_STRING) {
 	    XTextProperty textprop;
 	    wchar_t **wlist;
@@ -1071,20 +1070,40 @@
 	    textprop.value = (unsigned char *)*value;
 	    textprop.nitems = strlen(*value);
 	    textprop.format = 8;
-	    if (XwcTextPropertyToTextList(d, &textprop, (wchar_t***)&wlist,
-					  &count) < Success) {
+	    if (XwcTextPropertyToTextList(d, &textprop, &wlist, &count)
+		 < Success
+		|| count < 1) {
 		XtFree(*value);
 		return (False);
 	    }
 	    XtFree(*value);
-	    if (XwcTextListToTextProperty(d, (wchar_t**)wlist, 1,
-					  XStringStyle, &textprop) < Success) {
+	    if (XwcTextListToTextProperty(d, wlist, 1, XStringStyle, &textprop)
+		 < Success) {
 		XwcFreeStringList((wchar_t**)wlist);
 		return (False);
 	    }
 	    *value = (XtPointer)textprop.value;
 	    *length = textprop.nitems;
 	    XwcFreeStringList((wchar_t**) wlist);
+	} else if (*type == XA_UTF8_STRING(d)) {
+	    XTextProperty textprop;
+	    char **list;
+	    int count;
+
+	    textprop.encoding = XA_COMPOUND_TEXT(d);
+	    textprop.value = (unsigned char *)*value;
+	    textprop.nitems = strlen(*value);
+	    textprop.format = 8;
+	    if (Xutf8TextPropertyToTextList(d, &textprop, &list, &count)
+		 < Success
+		|| count < 1) {
+		XtFree(*value);
+		return (False);
+	    }
+	    XtFree(*value);
+	    *value = *list;
+	    *length = strlen(*list);
+	    XFree(list);
 	}
 	*format = 8;
 	return (True);
Index: xc/lib/Xaw/TextSink.c
diff -u xc/lib/Xaw/TextSink.c:1.15 xc/lib/Xaw/TextSink.c:1.17
--- xc/lib/Xaw/TextSink.c:1.15	Thu Jun 15 16:49:58 2000
+++ xc/lib/Xaw/TextSink.c	Sun Oct  1 22:32:12 2000
@@ -20,7 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/Xaw/TextSink.c,v 1.15 2000/06/15 20:49:58 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/TextSink.c,v 1.17 2000/10/02 02:32:12 tsi Exp $ */
 
 /*
  * Author:  Chris Peterson, MIT X Consortium.
@@ -34,6 +34,7 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
@@ -1004,7 +1005,7 @@
 static int
 bcmp_qident(_Xconst void *left, _Xconst void *right)
 {
-    return ((int)left - (*(XawTextProperty**)right)->identifier);
+    return ((long)left - (*(XawTextProperty**)right)->identifier);
 }
 
 static int
@@ -1152,7 +1153,8 @@
 {
     if (property != NULLQUARK && list && list->properties) {
 	XawTextProperty **ptr = (XawTextProperty**)
-	    bsearch((void*)property, list->properties, list->num_properties,
+	    bsearch((void*)(long)property,
+		    list->properties, list->num_properties,
 		    sizeof(XawTextProperty*), bcmp_qident);
 
 	if (ptr)
@@ -1488,7 +1490,7 @@
     String str, tok, tmp;
 
     if (prop_lists) ptr = (XawTextPropertyList**)
-	bsearch((void*)qname, prop_lists, num_prop_lists,
+	bsearch((void*)(long)qname, prop_lists, num_prop_lists,
 		sizeof(XawTextPropertyList*), bcmp_qident);
     if (ptr) {
 	propl = *ptr;
@@ -1721,7 +1723,8 @@
     if (w) {
 	XawTextPropertyList **ptr = NULL;
 	if (prop_lists) ptr = (XawTextPropertyList**)
-	    bsearch((void*)XrmStringToQuark(name), prop_lists, num_prop_lists,
+	    bsearch((void*)(long)XrmStringToQuark(name),
+		    prop_lists, num_prop_lists,
 		    sizeof(XawTextPropertyList*), bcmp_qident);
 
 	if (ptr) {
Index: xc/lib/Xaw/TextSrc.c
diff -u xc/lib/Xaw/TextSrc.c:1.24 xc/lib/Xaw/TextSrc.c:1.25
--- xc/lib/Xaw/TextSrc.c:1.24	Fri Mar 31 17:55:18 2000
+++ xc/lib/Xaw/TextSrc.c	Tue Sep 26 11:56:55 2000
@@ -21,7 +21,7 @@
 
 */
 
-/* $XFree86: xc/lib/Xaw/TextSrc.c,v 1.24 2000/03/31 22:55:18 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/TextSrc.c,v 1.25 2000/09/26 15:56:55 tsi Exp $ */
 
 /*
  * Author:  Chris Peterson, MIT X Consortium.
@@ -1153,7 +1153,7 @@
 	TellSourceChanged(src, left, right, block, lines);
 	/* Call callbacks, we have changed the buffer */
 	XtCallCallbacks(w, XtNcallback,
-			(XtPointer)((int)src->textSrc.changed));
+			(XtPointer)((long)src->textSrc.changed));
     }
 
 #endif /* OLDXAW */
Index: xc/lib/Xaw/Viewport.c
diff -u xc/lib/Xaw/Viewport.c:1.7 xc/lib/Xaw/Viewport.c:1.8
--- xc/lib/Xaw/Viewport.c:1.7	Sun Jun  6 04:48:21 1999
+++ xc/lib/Xaw/Viewport.c	Tue Sep 26 11:56:55 2000
@@ -42,7 +42,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/Xaw/Viewport.c,v 1.7 1999/06/06 08:48:21 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/Viewport.c,v 1.8 2000/09/26 15:56:55 tsi Exp $ */
 
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
@@ -803,7 +803,7 @@
 {
     ViewportWidget w = (ViewportWidget)closure;
     Widget child = w->viewport.child;
-    int pix = (int)call_data;
+    int pix = (long)call_data;
     int x, y;
 
     if (child == NULL)
Index: xc/lib/Xaw/XawIm.c
diff -u xc/lib/Xaw/XawIm.c:1.10 xc/lib/Xaw/XawIm.c:1.11
--- xc/lib/Xaw/XawIm.c:1.10	Tue Jun 13 19:15:48 2000
+++ xc/lib/Xaw/XawIm.c	Tue Sep  5 15:51:16 2000
@@ -48,7 +48,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/Xaw/XawIm.c,v 1.10 2000/06/13 23:15:48 dawes Exp $ */
+/* $XFree86: xc/lib/Xaw/XawIm.c,v 1.11 2000/09/05 19:51:16 mvojkovi Exp $ */
 
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
@@ -88,8 +88,6 @@
  *
  *****************************************************/
  
-#define	SetVaArg(arg, value)	(*((XtPointer *)arg) = (XtPointer)(value))
-
 /*
  * Prototypes
  */
@@ -724,15 +722,15 @@
 
     if (p->input_style & XIMPreeditArea) {
 	pe_attr = XVaCreateNestedList(0, XNAreaNeeded, &pe_area_needed, NULL);
-	SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes); ic_cnt++;
-	SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
     }
     if (p->input_style & XIMStatusArea) {
 	st_attr = XVaCreateNestedList(0, XNAreaNeeded, &st_area_needed, NULL);
-	SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes); ic_cnt++;
-	SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
     }
-    SetVaArg( &ic_a[ic_cnt], (XPointer) NULL);
+    ic_a[ic_cnt] = (XPointer) NULL;
 
     if (ic_cnt > 0) {
 	XGetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4]);
@@ -756,8 +754,8 @@
 
 	    XFree(st_area_needed);
 	    st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
-	    SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes); ic_cnt++;
-	    SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
+	    ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
+	    ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
 	}
 	if (p->input_style & XIMPreeditArea) {
 	    if (p->input_style & XIMStatusArea) {
@@ -771,10 +769,10 @@
 	    XFree(pe_area_needed);
 	    pe_area.y = height - pe_area.height;
 	    pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
-	    SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes); ic_cnt++;
-	    SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
+	    ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
+	    ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
 	}
-	SetVaArg( &ic_a[ic_cnt], (XPointer) NULL);
+	ic_a[ic_cnt] = (XPointer) NULL;
 	XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4]);
 	if (pe_attr) XFree(pe_attr);
 	if (st_attr) XFree(st_attr);
@@ -808,37 +806,37 @@
     
     if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
 	if (p->flg & CIFontSet) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNFontSet); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->font_set); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNFontSet); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->font_set); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNFontSet; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->font_set; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNFontSet; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->font_set; st_cnt++;
 	    height = maxAscentOfFontSet(p->font_set)
 		   + maxDescentOfFontSet(p->font_set);
 	    height = SetVendorShellHeight(ve, height);
 	}
 	if (p->flg & CIFg) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNForeground); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->foreground); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNForeground); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->foreground); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->foreground; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNForeground; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->foreground; st_cnt++;
 	}
 	if (p->flg & CIBg) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackground); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->background); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNBackground); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->background); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNBackground; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->background; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNBackground; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->background; st_cnt++;
 	}
 	if (p->flg & CIBgPixmap) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackgroundPixmap); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->bg_pixmap); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNBackgroundPixmap); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->bg_pixmap); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNBackgroundPixmap; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->bg_pixmap; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNBackgroundPixmap; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->bg_pixmap; st_cnt++;
 	}
 	if (p->flg & CILineS) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNLineSpace); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->line_spacing); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNLineSpace); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->line_spacing); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNLineSpace; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->line_spacing; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNLineSpace; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->line_spacing; st_cnt++;
 	}
     }
     if (p->input_style & XIMPreeditArea) {
@@ -846,8 +844,8 @@
 	pe_area.y = ve->parent->core.height - height;
 	pe_area.width = ve->parent->core.width;
 	pe_area.height = height;
-	SetVaArg( &pe_a[pe_cnt], (XPointer) XNArea); pe_cnt++;
-	SetVaArg( &pe_a[pe_cnt], (XPointer) &pe_area); pe_cnt++;
+	pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
+	pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
     }
     if (p->input_style & XIMPreeditPosition) {
 	pe_area.x = 0;
@@ -859,54 +857,54 @@
 	pe_area.y += margin->top;
 	pe_area.width -= (margin->left + margin->right - 1);
 	pe_area.height -= (margin->top + margin->bottom - 1);
-	SetVaArg( &pe_a[pe_cnt], (XPointer) XNArea); pe_cnt++;
-	SetVaArg( &pe_a[pe_cnt], (XPointer) &pe_area); pe_cnt++;
+	pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
+	pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
 	if (p->flg & CICursorP) {
 	    _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
 	} else {
 	    position.x = position.y = 0;
 	}
-	SetVaArg( &pe_a[pe_cnt], (XPointer) XNSpotLocation); pe_cnt++;
-	SetVaArg( &pe_a[pe_cnt], (XPointer) &position); pe_cnt++;
+	pe_a[pe_cnt] = (XPointer) XNSpotLocation; pe_cnt++;
+	pe_a[pe_cnt] = (XPointer) &position; pe_cnt++;
     }
     if (p->input_style & XIMStatusArea) {
 	st_area.x = 0;
 	st_area.y = ve->parent->core.height - height;
 	st_area.width = ve->parent->core.width;
 	st_area.height = height;
-	SetVaArg( &st_a[st_cnt], (XPointer) XNArea); st_cnt++;
-	SetVaArg( &st_a[st_cnt], (XPointer) &st_area); st_cnt++;
+	st_a[st_cnt] = (XPointer) XNArea; st_cnt++;
+	st_a[st_cnt] = (XPointer) &st_area; st_cnt++;
     }
 
-    SetVaArg( &ic_a[ic_cnt], (XPointer) XNInputStyle); ic_cnt++;
-    SetVaArg( &ic_a[ic_cnt], (XPointer) p->input_style); ic_cnt++;
-    SetVaArg( &ic_a[ic_cnt], (XPointer) XNClientWindow); ic_cnt++;
-    SetVaArg( &ic_a[ic_cnt], (XPointer) XtWindow(ve->parent)); ic_cnt++;
-    SetVaArg( &ic_a[ic_cnt], (XPointer) XNFocusWindow); ic_cnt++;
-    SetVaArg( &ic_a[ic_cnt], (XPointer) XtWindow(w)); ic_cnt++;
+    ic_a[ic_cnt] = (XPointer) XNInputStyle; ic_cnt++;
+    ic_a[ic_cnt] = (XPointer) p->input_style; ic_cnt++;
+    ic_a[ic_cnt] = (XPointer) XNClientWindow; ic_cnt++;
+    ic_a[ic_cnt] = (XPointer) XtWindow(ve->parent); ic_cnt++;
+    ic_a[ic_cnt] = (XPointer) XNFocusWindow; ic_cnt++;
+    ic_a[ic_cnt] = (XPointer) XtWindow(w); ic_cnt++;
 
     if (pe_cnt > 0) {
-	SetVaArg( &pe_a[pe_cnt], (XPointer) NULL);
+	pe_a[pe_cnt] = (XPointer) NULL;
 	pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
 				   pe_a[4], pe_a[5], pe_a[6], pe_a[7], pe_a[8],
 				   pe_a[9], pe_a[10], pe_a[11], pe_a[12],
 				   pe_a[13], pe_a[14], pe_a[15], pe_a[16],
 				   pe_a[17], pe_a[18],  pe_a[19]);
-	SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes); ic_cnt++;
-	SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
     }
 
     if (st_cnt > 0) {
-	SetVaArg( &st_a[st_cnt], (XPointer) NULL);
+	st_a[st_cnt] = (XPointer) NULL;
 	st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
 				   st_a[4], st_a[5], st_a[6], st_a[7], st_a[8],
 				   st_a[9], st_a[10], st_a[11], st_a[12],
 				   st_a[13], st_a[14], st_a[15], st_a[16],
 				   st_a[17], st_a[18],  st_a[19]);
-	SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes); ic_cnt++;
-	SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
     }
-    SetVaArg( &ic_a[ic_cnt], (XPointer) NULL);
+    ic_a[ic_cnt] = (XPointer) NULL;
 
     p->xic = XCreateIC(ve->im.xim, ic_a[0], ic_a[1], ic_a[2], ic_a[3],
 		       ic_a[4], ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9],
@@ -965,44 +963,44 @@
 
     if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
 	if (p->flg & CIFontSet) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNFontSet); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->font_set); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNFontSet); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->font_set); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNFontSet; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->font_set; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNFontSet; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->font_set; st_cnt++;
 	    height = maxAscentOfFontSet(p->font_set)
 		   + maxDescentOfFontSet(p->font_set);
 	    height = SetVendorShellHeight(ve, height);
 	}
 	if (p->flg & CIFg) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNForeground); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->foreground); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNForeground); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->foreground); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->foreground; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNForeground; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->foreground; st_cnt++;
 	}
 	if (p->flg & CIBg) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackground); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->background); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNBackground); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->background); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNBackground; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->background; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNBackground; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->background; st_cnt++;
 	}
 	if (p->flg & CIBgPixmap) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNBackgroundPixmap); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->bg_pixmap); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNBackgroundPixmap); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->bg_pixmap); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNBackgroundPixmap; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->bg_pixmap; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNBackgroundPixmap; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->bg_pixmap; st_cnt++;
 	}
 	if (p->flg & CILineS) {
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNLineSpace); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) p->line_spacing); pe_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) XNLineSpace); st_cnt++;
-	    SetVaArg( &st_a[st_cnt], (XPointer) p->line_spacing); st_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNLineSpace; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) p->line_spacing; pe_cnt++;
+	    st_a[st_cnt] = (XPointer) XNLineSpace; st_cnt++;
+	    st_a[st_cnt] = (XPointer) p->line_spacing; st_cnt++;
 	}
     }
     if (p->input_style & XIMPreeditPosition) {
 	if (p->flg & CICursorP) {
 	    _XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNSpotLocation); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) &position); pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNSpotLocation; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) &position; pe_cnt++;
 	}
     }
     if (IsSharedIC(ve)) {
@@ -1016,37 +1014,37 @@
 	    pe_area.y += margin->top;
 	    pe_area.width -= (margin->left + margin->right - 1);
 	    pe_area.height -= (margin->top + margin->bottom - 1);
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) XNArea); pe_cnt++;
-	    SetVaArg( &pe_a[pe_cnt], (XPointer) &pe_area); pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
+	    pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
 	}
     }
 
     if (pe_cnt > 0) {
-	SetVaArg( &pe_a[pe_cnt], (XPointer) NULL);
+	pe_a[pe_cnt] = (XPointer) NULL;
 	pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
 				      pe_a[4], pe_a[5], pe_a[6], pe_a[7],
 				      pe_a[8], pe_a[9], pe_a[10], pe_a[11],
 				      pe_a[12], pe_a[13], pe_a[14], pe_a[15],
 				      pe_a[16], pe_a[17], pe_a[18],  pe_a[19]);
-	SetVaArg( &ic_a[ic_cnt], (XPointer) XNPreeditAttributes); ic_cnt++;
-	SetVaArg( &ic_a[ic_cnt], (XPointer) pe_attr); ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
     }
     if (st_cnt > 0) {
-	SetVaArg( &st_a[st_cnt], (XPointer) NULL);
+	st_a[st_cnt] = (XPointer) NULL;
 	st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
 				      st_a[4], st_a[5], st_a[6], st_a[7],
 				      st_a[8], st_a[9], st_a[10], st_a[11],
 				      st_a[12], st_a[13], st_a[14], st_a[15],
 				      st_a[16], st_a[17], st_a[18],  st_a[19]);
-	SetVaArg( &ic_a[ic_cnt], (XPointer) XNStatusAttributes); ic_cnt++;
-	SetVaArg( &ic_a[ic_cnt], (XPointer) st_attr); ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
     }
     if (focus == TRUE) {
-	SetVaArg( &ic_a[ic_cnt], (XPointer) XNFocusWindow); ic_cnt++;
-	SetVaArg( &ic_a[ic_cnt], (XPointer) XtWindow(w)); ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) XNFocusWindow; ic_cnt++;
+	ic_a[ic_cnt] = (XPointer) XtWindow(w); ic_cnt++;
     }
     if (ic_cnt > 0) {
-	SetVaArg( &ic_a[ic_cnt], (XPointer) NULL);
+	ic_a[ic_cnt] = (XPointer) NULL;
 	XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4],
 		     ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9], ic_a[10],
 		     ic_a[11], ic_a[12], ic_a[13], ic_a[14], ic_a[15],
Index: xc/lib/Xdmcp/GenKey.c
diff -u xc/lib/Xdmcp/GenKey.c:3.4 xc/lib/Xdmcp/GenKey.c:3.5
--- xc/lib/Xdmcp/GenKey.c:3.4	Wed Oct 21 02:12:00 1998
+++ xc/lib/Xdmcp/GenKey.c	Tue Nov 14 13:20:33 2000
@@ -23,7 +23,7 @@
  * Author:  Keith Packard, MIT X Consortium
  */
 
-/* $XFree86: xc/lib/Xdmcp/GenKey.c,v 3.4 1998/10/21 06:12:00 dawes Exp $ */
+/* $XFree86: xc/lib/Xdmcp/GenKey.c,v 3.5 2000/11/14 18:20:33 dawes Exp $ */
 
 #include <X11/Xos.h>
 #include <X11/X.h>
@@ -47,7 +47,7 @@
 #define Time_t time_t
 #endif
 
-#if defined(linux) || defined(CSRG_BASED) || (defined(sun) && defined(SVR4))
+#ifndef X_NOT_STDC_ENV
 #include <stdlib.h>
 #else
 long random();
Index: xc/lib/Xext/XMultibuf.c
diff -u xc/lib/Xext/XMultibuf.c:1.2 xc/lib/Xext/XMultibuf.c:1.3
--- xc/lib/Xext/XMultibuf.c:1.2	Mon Jul 12 01:57:22 1999
+++ xc/lib/Xext/XMultibuf.c	Tue Sep 26 11:56:56 2000
@@ -21,7 +21,7 @@
  *
  * Authors:  Jim Fulton, MIT X Consortium
  */
-/* $XFree86: xc/lib/Xext/XMultibuf.c,v 1.2 1999/07/12 05:57:22 dawes Exp $ */
+/* $XFree86: xc/lib/Xext/XMultibuf.c,v 1.3 2000/09/26 15:56:56 tsi Exp $ */
 
 #define NEED_EVENTS
 #define NEED_REPLIES
@@ -419,7 +419,7 @@
 	    SyncHandle();
 	    return (0);
 	}
-	_XRead32 (dpy, (char *) attr->buffers, nbytes);
+	_XRead32 (dpy, (long *) attr->buffers, nbytes);
     }
     attr->displayed_index = rep.displayedBuffer;
     attr->update_action = rep.updateAction;
Index: xc/lib/Xext/Xdbe.c
diff -u xc/lib/Xext/Xdbe.c:3.1 xc/lib/Xext/Xdbe.c:3.2
--- xc/lib/Xext/Xdbe.c:3.1	Mon Jul 12 01:57:24 1999
+++ xc/lib/Xext/Xdbe.c	Tue Sep 26 11:56:56 2000
@@ -30,9 +30,8 @@
  *     Xlib DBE code
  *
  *****************************************************************************/
-/* $XFree86: xc/lib/Xext/Xdbe.c,v 3.1 1999/07/12 05:57:24 dawes Exp $ */
+/* $XFree86: xc/lib/Xext/Xdbe.c,v 3.2 2000/09/26 15:56:56 tsi Exp $ */
 
-
 #define NEED_EVENTS
 #define NEED_REPLIES
 #include <stdio.h>
@@ -431,7 +430,7 @@
         int j;
         long c;
 
-        _XRead32 (dpy, (char *)&c, sizeof(CARD32));
+        _XRead32 (dpy, (long *)&c, sizeof(CARD32));
         scrVisInfo[i].count = c;
 
         nbytes = scrVisInfo[i].count * sizeof(XdbeVisualInfo);
Index: xc/lib/Xext/Xext-def.cpp
diff -u xc/lib/Xext/Xext-def.cpp:1.5 xc/lib/Xext/Xext-def.cpp:1.6
--- xc/lib/Xext/Xext-def.cpp:1.5	Sat Jan 10 22:48:13 1998
+++ xc/lib/Xext/Xext-def.cpp	Wed Aug  9 19:40:13 2000
@@ -17,6 +17,19 @@
  XShapeQueryExtents
  XShapeQueryVersion
  XShapeSelectInput
+#if defined(__CYGWIN__) && defined(HAS_SHM)
+ XShmAttach
+ XShmCreateImage
+ XShmCreatePixmap
+ XShmDetach
+;XShmDestroyImage
+ XShmGetEventBase
+ XShmGetImage
+ XShmPixmapFormat
+ XShmPutImage
+ XShmQueryExtension
+ XShmQueryVersion
+#endif
  XSyncAwait
  XSyncChangeAlarm
  XSyncChangeCounter
@@ -89,6 +102,8 @@
  XSecurityFreeXauth
  XSecurityGenerateAuthorization
  XSecurityRevokeAuthorization
+ XLbxQueryExtension
+ XLbxQueryVersion
  XagQueryVersion
  XagCreateAssociation
  XagCreateEmbeddedApplicationGroup
@@ -103,12 +118,14 @@
  XcupGetReservedColormapEntries
  XcupQueryVersion
  XcupStoreColors
+#ifndef __CYGWIN__
  XPanoramiXQueryVersion
  XPanoramiXAllocInfo
  XPanoramiXGetScreenCount
  XPanoramiXGetScreenSize
  XPanoramiXGetState
  XPanoramiXQueryExtension
+#endif
  DPMSQueryExtension
  DPMSGetVersion
  DPMSCapable
@@ -122,3 +139,4 @@
  XeviQueryVersion
  XeviGetVisualInfo
 /* $TOG: Xext-def.cpp /main/10 1998/01/04 12:31:45 kaleb $ */
+/* $XFree86: xc/lib/Xext/Xext-def.cpp,v 1.6 2000/08/09 23:40:13 dawes Exp $ */
Index: xc/lib/Xft/Imakefile
diff -u /dev/null xc/lib/Xft/Imakefile:1.8
--- /dev/null	Mon Dec 18 14:24:32 2000
+++ xc/lib/Xft/Imakefile	Fri Dec 15 12:12:52 2000
@@ -0,0 +1,71 @@
+XCOMM $XFree86: xc/lib/Xft/Imakefile,v 1.8 2000/12/15 17:12:52 keithp Exp $
+
+#define DoNormalLib NormalLibXft
+#define DoSharedLib SharedLibXft
+#define DoExtraLib SharedLibXft
+#define DoDebugLib DebugLibXft
+#define DoProfileLib ProfileLibXft
+#define HasSharedData YES
+#define LibName Xft
+#define SoRev SOXFTREV
+#define IncSubdir X11
+#define IncSubSubdir Xft
+
+#include <Threads.tmpl>
+
+YFLAGS = -d
+
+#ifndef XftLibDir
+#define XftLibDir $(LIBDIR)
+#endif
+#ifndef XftType1Dir
+#define XftType1Dir $(LIBDIR)/fonts/Type1
+#endif
+
+XFTLIBDIR=XftLibDir
+XFTCONFIG=$(XFTLIBDIR)/XftConfig
+
+TYPE1DIR=XftType1Dir
+CONFIG_DEFS=-DXFT_TYPE1_DIR=\"$(TYPE1DIR)\"
+INCLUDES=$(FREETYPE2INCLUDES)
+DEFINES=-DXFT_DEFAULT_PATH=\"$(XFTCONFIG)\" $(FREETYPE2DEFINES) $(RENDERDEFINES)
+REQUIREDLIBS=$(LDPRELIBS) $(XRENDERLIB) $(XLIB) $(FREETYPE2LIB)
+
+#ifdef Freetype2Dir
+FT_HEADERS = XftFreetype.h
+   FT_SRCS = xftdir.c xftfreetype.c xftglyphs.c xftrender.c
+   FT_OBJS = xftdir.o xftfreetype.o xftglyphs.o xftrender.o
+#endif
+
+HEADERS = Xft.h $(FT_HEADERS)
+
+   SRCS = xftcfg.c xftcolor.c xftcore.c xftdbg.c xftdpy.c \
+          xftdraw.c xftextent.c xftfont.c xftfs.c xftgram.c \
+          xftinit.c xftlex.c xftlist.c xftmatch.c xftname.c \
+          xftpat.c xftstr.c xftxlfd.c $(FT_SRCS)
+  
+   OBJS = xftcfg.o xftcolor.o xftcore.o xftdbg.o xftdpy.o \
+          xftdraw.o  xftextent.o xftfont.o xftfs.o xftgram.o \
+          xftinit.o xftlex.o xftlist.o xftmatch.o xftname.o \
+          xftpat.o xftstr.o xftxlfd.o $(FT_OBJS)
+
+#include <Library.tmpl>
+
+LexFilePrefix(xftlex,XftConfig)
+YaccFilePrefix(xftgram,$(YFLAGS),XftConfig)
+
+#if DoSharedLib && SharedDataSeparation
+SpecialCObjectRule(sharedlib,NullParameter,$(SHLIBDEF))
+#endif
+
+CppFileTarget(XftConfig,XftConfig.cpp,$(CONFIG_DEFS),$(ICONFIGFILES))
+
+#if InstallFSConfig
+InstallNonExecFile(XftConfig,$(XFTLIBDIR))
+#else
+InstallNonExecFileNoClobber(XftConfig,$(XFTLIBDIR))
+#endif
+
+MANSUFFIX = $(LIBMANSUFFIX)
+InstallManPage(Xft,$(LIBMANDIR))
+DependTarget()
Index: xc/lib/Xft/Xft.h
diff -u /dev/null xc/lib/Xft/Xft.h:1.13
--- /dev/null	Mon Dec 18 14:24:33 2000
+++ xc/lib/Xft/Xft.h	Fri Dec  8 02:51:26 2000
@@ -0,0 +1,454 @@
+/*
+ * $XFree86: xc/lib/Xft/Xft.h,v 1.13 2000/12/08 07:51:26 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _XFT_H_
+#define _XFT_H_
+
+#include <X11/extensions/Xrender.h>
+#include <stdarg.h>
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+typedef unsigned char	XftChar8;
+typedef unsigned short	XftChar16;
+typedef unsigned int	XftChar32;
+
+#define XFT_FAMILY	    "family"	/* String */
+#define XFT_STYLE	    "style"	/* String */
+#define XFT_SLANT	    "slant"	/* Int */
+#define XFT_WEIGHT	    "weight"	/* Int */
+#define XFT_SIZE	    "size"	/* Double */
+#define XFT_PIXEL_SIZE	    "pixelsize"	/* Double */
+#define XFT_ENCODING	    "encoding"	/* String */
+#define XFT_SPACING	    "spacing"	/* Int */
+#define XFT_FOUNDRY	    "foundry"	/* String */
+#define XFT_CORE	    "core"	/* Bool */
+#define XFT_ANTIALIAS	    "antialias"	/* Bool */
+#define XFT_XLFD	    "xlfd"	/* String */
+#define XFT_FILE	    "file"	/* String */
+#define XFT_INDEX	    "index"	/* Int */
+#define XFT_RASTERIZER	    "rasterizer"/* String */
+#define XFT_OUTLINE	    "outline"	/* Bool */
+#define XFT_SCALABLE	    "scalable"	/* Bool */
+#define XFT_RGBA	    "rgba"	/* Int */
+
+/* defaults from resources */
+#define XFT_SCALE	    "scale"	/* double */
+#define XFT_RENDER	    "render"	/* Bool */
+
+/* specific to FreeType rasterizer */
+#define XFT_CHAR_WIDTH	    "charwidth"	/* Int */
+#define XFT_CHAR_HEIGHT	    "charheight"/* Int */
+
+#define XFT_WEIGHT_LIGHT	0
+#define XFT_WEIGHT_MEDIUM	100
+#define XFT_WEIGHT_DEMIBOLD	180
+#define XFT_WEIGHT_BOLD		200
+#define XFT_WEIGHT_BLACK	210
+
+#define XFT_SLANT_ROMAN		0
+#define XFT_SLANT_ITALIC	100
+#define XFT_SLANT_OBLIQUE	110
+
+#define XFT_PROPORTIONAL    0
+#define XFT_MONO	    100
+#define XFT_CHARCELL	    110
+
+#define XFT_RGBA_NONE	    0
+#define XFT_RGBA_RGB	    1
+#define XFT_RGBA_BGR	    2
+
+typedef enum _XftType {
+    XftTypeVoid, 
+    XftTypeInteger, 
+    XftTypeDouble, 
+    XftTypeString, 
+    XftTypeBool
+} XftType;
+
+typedef enum _XftResult {
+    XftResultMatch, XftResultNoMatch, XftResultTypeMismatch, XftResultNoId
+} XftResult;
+
+typedef struct _XftValue {
+    XftType	type;
+    union {
+	char    *s;
+	int	i;
+	Bool	b;
+	double	d;
+    } u;
+} XftValue;
+
+typedef struct _XftValueList {
+    struct _XftValueList    *next;
+    XftValue		    value;
+} XftValueList;
+
+typedef struct _XftPatternElt {
+    const char	    *object;
+    XftValueList    *values;
+} XftPatternElt;
+
+typedef struct _XftPattern {
+    int		    num;
+    int		    size;
+    XftPatternElt   *elts;
+} XftPattern;
+
+typedef struct _XftFontSet {
+    int		nfont;
+    int		sfont;
+    XftPattern	**fonts;
+} XftFontSet;
+
+typedef struct _XftFontStruct	XftFontStruct;
+
+typedef struct _XftFont {
+    int		ascent;
+    int		descent;
+    int		height;
+    int		max_advance_width;
+    Bool	core;
+    XftPattern	*pattern;
+    union {
+	struct {
+	    XFontStruct	    *font;
+	} core;
+	struct {
+	    XftFontStruct   *font;
+	} ft;
+    } u;
+} XftFont;
+
+typedef struct _XftDraw XftDraw;
+
+typedef struct _XftColor {
+    unsigned long   pixel;
+    XRenderColor    color;
+} XftColor;
+
+typedef struct _XftObjectSet {
+    int		nobject;
+    int		sobject;
+    const char	**objects;
+} XftObjectSet;
+
+_XFUNCPROTOBEGIN
+
+/* xftcfg.c */
+Bool
+XftConfigSubstitute (XftPattern *p);
+
+/* xftcolor.c */
+Bool
+XftColorAllocName (Display  *dpy,
+		   Visual   *visual,
+		   Colormap cmap,
+		   char	    *name,
+		   XftColor *result);
+
+Bool
+XftColorAllocValue (Display	    *dpy,
+		    Visual	    *visual,
+		    Colormap	    cmap,
+		    XRenderColor    *color,
+		    XftColor	    *result);
+
+void
+XftColorFree (Display	*dpy,
+	      Visual	*visual,
+	      Colormap	cmap,
+	      XftColor	*color);
+
+
+/* xftcore.c */
+/* xftdbg.c */
+void
+XftValuePrint (XftValue v);
+
+void
+XftValueListPrint (XftValueList *l);
+
+void
+XftPatternPrint (XftPattern *p);
+
+void
+XftFontSetPrint (XftFontSet *s);
+
+/* xftdir.c */
+/* xftdpy.c */
+Bool
+XftDefaultHasRender (Display *dpy);
+    
+Bool
+XftDefaultSet (Display *dpy, XftPattern *defaults);
+
+void
+XftDefaultSubstitute (Display *dpy, int screen, XftPattern *pattern);
+    
+/* xftdraw.c */
+
+XftDraw *
+XftDrawCreate (Display   *dpy,
+	       Drawable  drawable,
+	       Visual    *visual,
+	       Colormap  colormap);
+
+XftDraw *
+XftDrawCreateBitmap (Display  *dpy,
+		     Pixmap   bitmap);
+
+void
+XftDrawChange (XftDraw	*draw,
+	       Drawable	drawable);
+
+void
+XftDrawDestroy (XftDraw	*draw);
+
+void
+XftDrawString8 (XftDraw		*d,
+		XftColor	*color,
+		XftFont		*font,
+		int		x, 
+		int		y,
+		XftChar8	*string,
+		int		len);
+
+void
+XftDrawString16 (XftDraw	*draw,
+		 XftColor	*color,
+		 XftFont	*font,
+		 int		x,
+		 int		y,
+		 XftChar16	*string,
+		 int		len);
+
+void
+XftDrawString32 (XftDraw	*draw,
+		 XftColor	*color,
+		 XftFont	*font,
+		 int		x,
+		 int		y,
+		 XftChar32	*string,
+		 int		len);
+void
+XftDrawRect (XftDraw	    *d,
+	     XftColor	    *color,
+	     int	    x, 
+	     int	    y,
+	     unsigned int   width,
+	     unsigned int   height);
+
+
+Bool
+XftDrawSetClip (XftDraw	    *d,
+		Region	    r);
+
+/* xftextent.c */
+
+void
+XftTextExtents8 (Display	*dpy,
+		 XftFont	*font,
+		 XftChar8	*string, 
+		 int		len,
+		 XGlyphInfo	*extents);
+
+void
+XftTextExtents16 (Display	    *dpy,
+		  XftFont	    *font,
+		  XftChar16	    *string, 
+		  int		    len,
+		  XGlyphInfo	    *extents);
+
+void
+XftTextExtents32 (Display	*dpy,
+		  XftFont	*font,
+		  XftChar32	*string, 
+		  int		len,
+		  XGlyphInfo	*extents);
+    
+/* xftfont.c */
+XftPattern *
+XftFontMatch (Display *dpy, int screen, XftPattern *pattern, XftResult *result);
+
+XftFont *
+XftFontOpenPattern (Display *dpy, XftPattern *pattern);
+
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...);
+
+XftFont *
+XftFontOpenName (Display *dpy, int screen, const char *name);
+
+XftFont *
+XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd);
+
+void
+XftFontClose (Display *dpy, XftFont *font);
+
+Bool
+XftGlyphExists (Display *dpy, XftFont *font, XftChar32 glyph);
+    
+/* xftfreetype.c */
+/* xftfs.c */
+
+XftFontSet *
+XftFontSetCreate (void);
+
+void
+XftFontSetDestroy (XftFontSet *s);
+
+Bool
+XftFontSetAdd (XftFontSet *s, XftPattern *font);
+
+/* xftglyphs.c */
+/* see XftFreetype.h */
+
+/* xftgram.y */
+
+/* xftinit.c */
+Bool
+XftInit (char *config);
+    
+/* xftlex.l */
+
+/* xftlist.c */
+XftObjectSet *
+XftObjectSetCreate (void);
+
+Bool
+XftObjectSetAdd (XftObjectSet *os, const char *object);
+
+void
+XftObjectSetDestroy (XftObjectSet *os);
+
+XftObjectSet *
+XftObjectSetVaBuild (const char *first, va_list va);
+
+XftObjectSet *
+XftObjectSetBuild (const char *first, ...);
+
+XftFontSet *
+XftListFontSets (XftFontSet	**sets,
+		 int		nsets,
+		 XftPattern	*p,
+		 XftObjectSet	*os);
+
+XftFontSet *
+XftListFontsPatternObjects (Display	    *dpy,
+			    int		    screen,
+			    XftPattern	    *pattern,
+			    XftObjectSet    *os);
+
+XftFontSet *
+XftListFonts (Display	*dpy,
+	      int	screen,
+	      ...);
+
+/* xftmatch.c */
+XftPattern *
+XftFontSetMatch (XftFontSet	**sets, 
+		 int		nsets, 
+		 XftPattern	*p, 
+		 XftResult	*result);
+
+/* xftname.c */
+XftPattern *
+XftNameParse (const char *name);
+
+/* xftpat.c */
+XftPattern *
+XftPatternCreate (void);
+
+XftPattern *
+XftPatternDuplicate (XftPattern *p);
+
+void
+XftValueDestroy (XftValue v);
+
+void
+XftValueListDestroy (XftValueList *l);
+    
+void
+XftPatternDestroy (XftPattern *p);
+
+XftPatternElt *
+XftPatternFind (XftPattern *p, const char *object, Bool insert);
+
+Bool
+XftPatternAdd (XftPattern *p, const char *object, XftValue value, Bool append);
+    
+XftResult
+XftPatternGet (XftPattern *p, const char *object, int id, XftValue *v);
+    
+Bool
+XftPatternDel (XftPattern *p, const char *object);
+
+Bool
+XftPatternAddInteger (XftPattern *p, const char *object, int i);
+
+Bool
+XftPatternAddDouble (XftPattern *p, const char *object, double d);
+
+Bool
+XftPatternAddString (XftPattern *p, const char *object, const char *s);
+
+Bool
+XftPatternAddBool (XftPattern *p, const char *object, Bool b);
+
+XftResult
+XftPatternGetInteger (XftPattern *p, const char *object, int n, int *i);
+
+XftResult
+XftPatternGetDouble (XftPattern *p, const char *object, int n, double *d);
+
+XftResult
+XftPatternGetString (XftPattern *p, const char *object, int n, char **s);
+
+XftResult
+XftPatternGetBool (XftPattern *p, const char *object, int n, Bool *b);
+
+XftPattern *
+XftPatternVaBuild (XftPattern *orig, va_list va);
+    
+XftPattern *
+XftPatternBuild (XftPattern *orig, ...);
+
+/* xftrender.c */
+/* see XftFreetype.h */
+
+/* xftstr.c */
+
+/* xftxlfd.c */
+XftPattern *
+XftXlfdParse (const char *xlfd_orig, Bool ignore_scalable, Bool complete);
+    
+XFontStruct *
+XftCoreOpen (Display *dpy, XftPattern *pattern);
+
+_XFUNCPROTOEND
+
+#endif /* _XFT_H_ */
Index: xc/lib/Xft/Xft.man
diff -u /dev/null xc/lib/Xft/Xft.man:1.2
--- /dev/null	Mon Dec 18 14:24:33 2000
+++ xc/lib/Xft/Xft.man	Thu Nov 30 01:59:45 2000
@@ -0,0 +1,181 @@
+.\"
+.\" $XFree86: xc/lib/Xft/Xft.man,v 1.2 2000/11/30 06:59:45 keithp Exp $
+.\"
+.\" Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+.\"
+.\" Permission to use, copy, modify, distribute, and sell this software and its
+.\" documentation for any purpose is hereby granted without fee, provided that
+.\" the above copyright notice appear in all copies and that both that
+.\" copyright notice and this permission notice appear in supporting
+.\" documentation, and that the name of Keith Packard not be used in
+.\" advertising or publicity pertaining to distribution of the software without
+.\" specific, written prior permission.  Keith Packard makes no
+.\" representations about the suitability of this software for any purpose.  It
+.\" is provided "as is" without express or implied warranty.
+.\"
+.\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+.\" EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+.\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+.\" DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+.\" PERFORMANCE OF THIS SOFTWARE.
+.\"
+.de TQ
+.br
+.ns
+.TP \\$1
+..
+.TH XFT 3 "Version 1.0" "XFree86"
+
+.SH NAME
+ XFT \- X FreeType interface library
+
+.SH DESCRIPTION
+.B Xft
+is a simple library designed to interface the FreeType rasterizer with the X
+Rendering Extension.  This manual page barely scratches the surface of this
+library.
+
+.SH DATATYPES
+
+.B XftPattern
+holds a set of names with associated value lists; each name refers to a
+property of a font.  XftPatterns are used as inputs to the matching code as
+well as holding information about specific fonts.
+
+.B XftFont
+contains general font metrics and a pointer to either the core XFontStruct
+data or a structure holding FreeType and X Render Extension data.
+
+.B XftFontStruct
+contains information about FreeType fonts used with the X Render Extension.
+
+.B XftFontSet
+contains a list of XftPatterns.  Internally Xft uses this data structure to
+hold sets of fonts.  Externally, Xft returns the results of listing fonts in
+this format.
+
+.B XftObjectSet
+holds a set of names and is used to specify which fields from fonts are
+placed in the the list of returned patterns when listing fonts.
+
+.B XftDraw
+is an opaque object which holds information used to render to an X drawable
+using either core protocol or the X Rendering extension.
+
+.SH FUNCTIONS
+.nf
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...);
+.fi
+.B XftFontOpen
+takes a list of pattern elements of the form (field, type, value) terminated
+with a 0, matches that pattern against the available fonts and opens the
+matching font.
+.PP
+Example:
+.br
+	font = XftFontOpen (dpy, scr,
+			    XFT_FAMILY, XftTypeString, "charter",
+			    XFT_SIZE, XftTypeDouble, 12.0);
+.PP
+This opens the charter font at 12 points.  The point size is automatically
+converted to the correct pixel size based on the resolution of the monitor.
+.PP
+.nf
+void
+XftTextExtents8 (Display	*dpy,
+		 XftFont	*font,
+		 unsigned char  *string, 
+		 int		len,
+		 XGlyphInfo	*extents);
+.fi
+.B XftTextExtents8
+computes the pixel extents of "string" when drawn with "font".
+.PP
+.nf
+XftDraw *
+XftDrawCreate (Display   *dpy,
+	       Drawable  drawable,
+	       Visual    *visual,
+	       Colormap  colormap);
+.fi
+.B XtDrawCreate
+creates a structure that can be used to render text and rectangles
+to the screen.
+.PP
+.nf
+void
+XftDrawString8 (XftDraw		*d,
+		XRenderColor	*color,
+		XftFont		*font,
+		int		x, 
+		int		y,
+		unsigned char	*string,
+		int		len);
+.fi
+.B XftDrawString8
+draws "string" using "font" in "color" at "x, y".
+.PP
+.nf
+void
+XftDrawRect (XftDraw	    *d,
+	     XRenderColor   *color,
+	     int	    x, 
+	     int	    y,
+	     unsigned int   width,
+	     unsigned int   height);
+.fi
+.B XftDrawRect
+fills a solid rectangle in the specified color.
+.SH XftConfig
+The 
+.B XftConfig
+file contains configuration information for the Xft library consisting of
+directories to look at for font information as well as instructions on
+editing program specified font patterns before attempting to match the
+available fonts.
+.PP
+.nf
+config	:   "dir" STRING
+	|   "include" STRING
+	|   "includeif" STRING
+	|   "match" tests "edit" edits
+	;
+test	:   qual FIELD-NAME COMPARE CONSTANT
+	;
+qual	:   "any"
+	|   "all"
+	;
+edit	:   FIELD-NAME ASSIGN expr SEMI
+	;
+.fi
+.PP
+STRINGs are double-quote delimited.  FIELD-NAMEs are identifiers,
+ASSIGN is one of "=", "+=" or "=+".  expr can contain the usual
+arithmetic operators and can include FIELD-NAMEs.
+.PP
+"dir" adds a directory to the list of places Xft will look for fonts.
+There is no particular order implied by the list; Xft treats all fonts about
+the same.
+.PP
+"include" and "includeif" cause Xft to load more configuration parameters
+from the indicated file.  "includeif" doesn't elicit a complaint if the file
+doesn't exist.  If the file name begins with a '~' character, it refers to a
+path relative to the home directory of the user.
+.PP
+If the tests in a "match" statement all match a user-specified pattern, the
+pattern will be edited with the specified instructions.
+.PP
+Where ASSIGN is "=", the matching value in the pattern will be replaced by
+the given expression.  "+="/"=+" will prepend/append a new value to the list
+of values for the indicated field.
+
+.SH RESTRICTIONS
+.B Xft
+will probably change radically in the future; weak attempts will be made to
+retain some level of source-file compatibility.
+
+.SH AUTHOR
+Keith Packard, member of the XFree86 Project, Inc.
Index: xc/lib/Xft/XftConfig.cpp
diff -u /dev/null xc/lib/Xft/XftConfig.cpp:1.5
--- /dev/null	Mon Dec 18 14:24:34 2000
+++ xc/lib/Xft/XftConfig.cpp	Thu Dec 14 18:03:53 2000
@@ -0,0 +1,36 @@
+# $XFree86: xc/lib/Xft/XftConfig.cpp,v 1.5 2000/12/14 23:03:53 keithp Exp $
+
+dir XFT_TYPE1_DIR
+
+#
+# alias 'fixed' for 'mono'
+#
+match any family == "fixed"		edit family =+ "mono";
+
+#
+# Check users config file
+#
+includeif	"~/.xftconfig"
+
+#
+# Use Lucidux fonts for default faces
+#
+match any family == "serif"		edit family += "LuciduxSerif";
+match any family == "sans"		edit family += "LuciduxSans";
+match any family == "mono"		edit family += "LuciduxMono";
+
+#
+# Alias between XLFD families and font file family name, prefer local
+# fonts
+#
+match any family == "charter"		edit family += "bitstream charter";
+match any family == "bitstream charter" edit family =+ "charter";
+
+match any family == "Lucidux Serif"	edit family += "LuciduxSerif";
+match any family == "LuciduxSerif"	edit family =+ "Lucidux Serif";
+
+match any family == "Lucidux Sans"	edit family += "LuciduxSans";
+match any family == "LuciduxSans"	edit family =+ "Lucidux Sans";
+
+match any family == "Lucidux Mono"	edit family += "LuciduxMono";
+match any family == "LuciduxMono"	edit family =+ "Lucidux Mono";
Index: xc/lib/Xft/XftFreetype.h
diff -u /dev/null xc/lib/Xft/XftFreetype.h:1.7
--- /dev/null	Mon Dec 18 14:24:34 2000
+++ xc/lib/Xft/XftFreetype.h	Fri Dec 15 12:12:52 2000
@@ -0,0 +1,132 @@
+/*
+ * $XFree86: xc/lib/Xft/XftFreetype.h,v 1.7 2000/12/15 17:12:52 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _XFTFREETYPE_H_
+#define _XFTFREETYPE_H_
+
+#include <X11/Xft/Xft.h>
+#include <freetype/freetype.h>
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+extern FT_Library	_XftFTlibrary;
+
+struct _XftFontStruct {
+    FT_Face		face;      /* handle to face object */
+    GlyphSet		glyphset;
+    int			min_char;
+    int			max_char;
+    int			size;
+    int			ascent;
+    int			descent;
+    int			height;
+    int			max_advance_width;
+    Bool		monospace;
+    int			rgba;
+    Bool		antialias;
+    Bool		encoded;    /* use charmap */
+    XRenderPictFormat	*format;
+    XGlyphInfo		**realized;
+    int			nrealized;
+};
+
+_XFUNCPROTOBEGIN
+
+/* xftfreetype.c */
+XftFontStruct *
+XftFreeTypeOpen (Display *dpy, XftPattern *pattern);
+
+void
+XftFreeTypeClose (Display *dpy, XftFontStruct *font);
+
+/* xftglyphs.c */
+void
+XftGlyphLoad (Display		*dpy,
+	      XftFontStruct	*font,
+	      XftChar32		*glyphs,
+	      int		nglyph);
+
+void
+XftGlyphCheck (Display		*dpy,
+	       XftFontStruct	*font,
+	       XftChar32	glyph,
+	       XftChar32	*missing,
+	       int		*nmissing);
+
+Bool
+XftFreeTypeGlyphExists (Display		*dpy,
+			XftFontStruct	*font,
+			XftChar32	glyph);
+
+/* xftrender.c */
+
+void
+XftRenderString8 (Display *dpy, Picture src, 
+		  XftFontStruct *font, Picture dst,
+		  int srcx, int srcy,
+		  int x, int y,
+		  XftChar8 *string, int len);
+
+void
+XftRenderString16 (Display *dpy, Picture src, 
+		   XftFontStruct *font, Picture dst,
+		   int srcx, int srcy,
+		   int x, int y,
+		   XftChar16 *string, int len);
+
+void
+XftRenderString32 (Display *dpy, Picture src, 
+		   XftFontStruct *font, Picture dst,
+		   int srcx, int srcy,
+		   int x, int y,
+		   XftChar32 *string, int len);
+
+void
+XftRenderExtents8 (Display	    *dpy,
+		   XftFontStruct    *font,
+		   XftChar8	    *string, 
+		   int		    len,
+		   XGlyphInfo	    *extents);
+
+void
+XftRenderExtents16 (Display	    *dpy,
+		    XftFontStruct   *font,
+		    XftChar16	    *string, 
+		    int		    len,
+		    XGlyphInfo	    *extents);
+
+void
+XftRenderExtents32 (Display	    *dpy,
+		    XftFontStruct   *font,
+		    XftChar32	    *string, 
+		    int		    len,
+		    XGlyphInfo	    *extents);
+
+XftFontStruct *
+XftFreeTypeGet (XftFont *font);
+
+_XFUNCPROTOEND
+
+#endif /* _XFTFREETYPE_H_ */
Index: xc/lib/Xft/xftcfg.c
diff -u /dev/null xc/lib/Xft/xftcfg.c:1.7
--- /dev/null	Mon Dec 18 14:24:35 2000
+++ xc/lib/Xft/xftcfg.c	Sun Dec 17 04:11:37 2000
@@ -0,0 +1,594 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcfg.c,v 1.7 2000/12/17 09:11:37 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "xftint.h"
+
+static char	*XftConfigDefaultDirs[] = {
+    "/usr/X11R6/lib/X11/fonts/Type1",
+    0
+};
+
+char		**XftConfigDirs = XftConfigDefaultDirs;
+static int	XftConfigNdirs;
+
+static XftSubst	*XftSubsts;
+/* #define XFT_DEBUG_EDIT */
+
+Bool
+XftConfigAddDir (char *d)
+{
+    char    **dirs;
+    char    *dir;
+    char    *h;
+
+    if (*d == '~')
+    {
+	h = getenv ("HOME");
+	if (!h)
+	    return False;
+	dir = (char *) malloc (strlen (h) + strlen (d));
+	strcpy (dir, h);
+	strcat (dir, d+1);
+    }
+    else
+    {
+	dir = (char *) malloc (strlen (d) + 1);
+	if (!dir)
+	    return False;
+	strcpy (dir, d);
+    }
+    dirs = (char **) malloc ((XftConfigNdirs + 2) * sizeof (char *));
+    if (!dirs)
+    {
+	free (dir);
+	return False;
+    }
+    if (XftConfigNdirs)
+    {
+	memcpy (dirs, XftConfigDirs, XftConfigNdirs * sizeof (char *));
+    }
+    dirs[XftConfigNdirs] = dir;
+    XftConfigNdirs++;
+    dirs[XftConfigNdirs] = 0;
+    if (XftConfigDirs != XftConfigDefaultDirs)
+	free (XftConfigDirs);
+    XftConfigDirs = dirs;
+    return True;
+}
+
+static int XftSubstsMaxObjects;
+
+Bool
+XftConfigAddEdit (XftTest *test, XftEdit *edit)
+{
+    XftSubst	*subst, **prev;
+    XftTest	*t;
+    int		num;
+
+    subst = (XftSubst *) malloc (sizeof (XftSubst));
+    if (!subst)
+	return False;
+    for (prev = &XftSubsts; *prev; prev = &(*prev)->next);
+    *prev = subst;
+    subst->next = 0;
+    subst->test = test;
+    subst->edit = edit;
+#ifdef XFT_DEBUG_EDIT
+    printf ("Add Subst ");
+    XftSubstPrint (subst);
+#endif
+    num = 0;
+    for (t = test; t; t = t->next)
+	num++;
+    if (XftSubstsMaxObjects < num)
+	XftSubstsMaxObjects = num;
+    return True;
+}
+
+typedef struct _XftSubState {
+    XftPatternElt   *elt;
+    XftValueList    *value;
+} XftSubState;
+
+static XftValue
+_XftConfigPromote (XftValue v)
+{
+    if (v.type == XftTypeInteger)
+    {
+	v.type = XftTypeDouble;
+	v.u.d = (double) v.u.i;
+    }
+    return v;
+}
+
+Bool
+_XftConfigCompareValue (XftValue    m,
+			XftOp	    op,
+			XftValue    v)
+{
+    Bool    ret;
+    
+    if (m.type == XftTypeVoid)
+	return True;
+    m = _XftConfigPromote (m);
+    v = _XftConfigPromote (v);
+    if (m.type == v.type) 
+    {
+	ret = False;
+	switch (m.type) {
+	case XftTypeDouble:
+	    switch (op) {
+	    case XftOpEqual:    
+		ret = m.u.d == v.u.d;
+		break;
+	    case XftOpNotEqual:    
+		ret = m.u.d != v.u.d;
+		break;
+	    case XftOpLess:    
+		ret = m.u.d < v.u.d;
+		break;
+	    case XftOpLessEqual:    
+		ret = m.u.d <= v.u.d;
+		break;
+	    case XftOpMore:    
+		ret = m.u.d > v.u.d;
+		break;
+	    case XftOpMoreEqual:    
+		ret = m.u.d >= v.u.d;
+		break;
+	    default:
+		break;
+	    }
+	    break;
+	case XftTypeBool:
+	    switch (op) {
+	    case XftOpEqual:    
+		ret = m.u.b == v.u.b;
+		break;
+	    case XftOpNotEqual:    
+		ret = m.u.b != v.u.b;
+		break;
+	    default:
+		break;
+	    }
+	    break;
+	case XftTypeString:
+	    switch (op) {
+	    case XftOpEqual:    
+		ret = _XftStrCmpIgnoreCase (m.u.s, v.u.s) == 0;
+		break;
+	    case XftOpNotEqual:    
+		ret = _XftStrCmpIgnoreCase (m.u.s, v.u.s) != 0;
+		break;
+	    default:
+		break;
+	    }
+	    break;
+	default:
+	    break;
+	}
+    }
+    else
+    {
+	if (op == XftOpNotEqual)
+	    ret = True;
+	else
+	    ret = False;
+    }
+    return ret;
+}
+
+static XftValueList *
+_XftConfigMatchValueList (XftTest	*t,
+			  XftValueList  *v)
+{
+    XftValueList    *ret = 0;
+    
+    for (; v; v = v->next)
+    {
+	if (_XftConfigCompareValue (v->value, t->op, t->value))
+	{
+	    if (!ret)
+		ret = v;
+	}
+	else
+	{
+	    if (t->qual == XftQualAll)
+	    {
+		ret = 0;
+		break;
+	    }
+	}
+    }
+    return ret;
+}
+
+static XftValue
+_XftConfigEvaluate (XftPattern *p, XftExpr *e)
+{
+    XftValue	v, vl, vr;
+    XftResult	r;
+    
+    switch (e->op) {
+    case XftOpInteger:
+	v.type = XftTypeInteger;
+	v.u.i = e->u.ival;
+	break;
+    case XftOpDouble:
+	v.type = XftTypeDouble;
+	v.u.d = e->u.dval;
+	break;
+    case XftOpString:
+	v.type = XftTypeString;
+	v.u.s = e->u.sval;
+	break;
+    case XftOpBool:
+	v.type = XftTypeBool;
+	v.u.b = e->u.bval;
+	break;
+    case XftOpField:
+	r = XftPatternGet (p, e->u.field, 0, &v);
+	if (r != XftResultMatch)
+	    v.type = XftTypeVoid;
+	break;
+    case XftOpQuest:
+	vl = _XftConfigEvaluate (p, e->u.tree.left);
+	if (vl.type == XftTypeBool)
+	{
+	    if (vl.u.b)
+		v = _XftConfigEvaluate (p, e->u.tree.right->u.tree.left);
+	    else
+		v = _XftConfigEvaluate (p, e->u.tree.right->u.tree.right);
+	}
+	else
+	    v.type = XftTypeVoid;
+	break;
+    case XftOpOr:
+    case XftOpAnd:
+    case XftOpEqual:
+    case XftOpNotEqual:
+    case XftOpLess:
+    case XftOpLessEqual:
+    case XftOpMore:
+    case XftOpMoreEqual:
+    case XftOpPlus:
+    case XftOpMinus:
+    case XftOpTimes:
+    case XftOpDivide:
+	vl = _XftConfigEvaluate (p, e->u.tree.left);
+	vr = _XftConfigEvaluate (p, e->u.tree.right);
+	vl = _XftConfigPromote (vl);
+	vr = _XftConfigPromote (vr);
+	if (vl.type == vr.type)
+	{
+	    switch (vl.type) {
+	    case XftTypeDouble:
+		switch (e->op) {
+		case XftOpPlus:	   
+		    v.type = XftTypeDouble;
+		    v.u.d = vl.u.d + vr.u.d; 
+		    break;
+		case XftOpMinus:
+		    v.type = XftTypeDouble;
+		    v.u.d = vl.u.d - vr.u.d; 
+		    break;
+		case XftOpTimes:
+		    v.type = XftTypeDouble;
+		    v.u.d = vl.u.d * vr.u.d; 
+		    break;
+		case XftOpDivide:
+		    v.type = XftTypeDouble;
+		    v.u.d = vl.u.d / vr.u.d; 
+		    break;
+		case XftOpEqual:    
+		    v.type = XftTypeBool; 
+		    v.u.b = vl.u.d == vr.u.d;
+		    break;
+		case XftOpNotEqual:    
+		    v.type = XftTypeBool; 
+		    v.u.b = vl.u.d != vr.u.d;
+		    break;
+		case XftOpLess:    
+		    v.type = XftTypeBool; 
+		    v.u.b = vl.u.d < vr.u.d;
+		    break;
+		case XftOpLessEqual:    
+		    v.type = XftTypeBool; 
+		    v.u.b = vl.u.d <= vr.u.d;
+		    break;
+		case XftOpMore:    
+		    v.type = XftTypeBool; 
+		    v.u.b = vl.u.d > vr.u.d;
+		    break;
+		case XftOpMoreEqual:    
+		    v.type = XftTypeBool; 
+		    v.u.b = vl.u.d >= vr.u.d;
+		    break;
+		default:
+		    v.type = XftTypeVoid; 
+		    break;
+		}
+		if (v.type == XftTypeDouble &&
+		    v.u.d == (double) (int) v.u.d)
+		{
+		    v.type = XftTypeInteger;
+		    v.u.i = (int) v.u.d;
+		}
+		break;
+	    case XftTypeBool:
+		switch (e->op) {
+		case XftOpOr:
+		    v.type = XftTypeBool;
+		    v.u.b = vl.u.b || vr.u.b;
+		    break;
+		case XftOpAnd:
+		    v.type = XftTypeBool;
+		    v.u.b = vl.u.b && vr.u.b;
+		    break;
+		case XftOpEqual:
+		    v.type = XftTypeBool;
+		    v.u.b = vl.u.b == vr.u.b;
+		    break;
+		case XftOpNotEqual:
+		    v.type = XftTypeBool;
+		    v.u.b = vl.u.b != vr.u.b;
+		    break;
+		default:
+		    v.type = XftTypeVoid; 
+		    break;
+		}
+		break;
+	    case XftTypeString:
+		switch (e->op) {
+		case XftOpEqual:
+		    v.type = XftTypeBool;
+		    v.u.b = _XftStrCmpIgnoreCase (vl.u.s, vr.u.s) == 0;
+		    break;
+		case XftOpNotEqual:
+		    v.type = XftTypeBool;
+		    v.u.b = _XftStrCmpIgnoreCase (vl.u.s, vr.u.s) != 0;
+		    break;
+		case XftOpPlus:
+		    v.type = XftTypeString;
+		    v.u.s = malloc (strlen (vl.u.s) + strlen (vr.u.s) + 1);
+		    if (v.u.s)
+		    {
+			strcpy (v.u.s, vl.u.s);
+			strcat (v.u.s, vr.u.s);
+		    }
+		    else
+			v.type = XftTypeVoid;
+		    break;
+		default:
+		    v.type = XftTypeVoid;
+		    break;
+		}
+	    default:
+		v.type = XftTypeVoid;
+		break;
+	    }
+	}
+	else
+	    v.type = XftTypeVoid;
+	break;
+    case XftOpNot:
+	vl = _XftConfigEvaluate (p, e->u.tree.left);
+	switch (vl.type) {
+	case XftTypeBool:
+	    v.type = XftTypeBool;
+	    v.u.b = !vl.u.b;
+	    break;
+	default:
+	    v.type = XftTypeVoid;
+	    break;
+	}
+	break;
+    default:
+	v.type = XftTypeVoid;
+	break;
+    }
+    return v;
+}
+
+static Bool
+_XftConfigAdd (XftValueList  **head,
+	      XftValueList  *position,
+	      Bool	    append,
+	      XftValue	    value)
+{
+    XftValueList    *new, **prev;
+    
+    new = (XftValueList *) malloc (sizeof (XftValueList));
+    if (!new)
+	goto bail0;
+    
+    if (value.type == XftTypeString)
+    {
+	value.u.s = _XftSaveString (value.u.s);
+	if (!value.u.s)
+	    goto bail1;
+	
+    }
+    new->value = value;
+    new->next = 0;
+
+    if (append)
+    {
+	prev = &position->next;
+    }
+    else
+    {
+	for (prev = head; *prev; prev = &(*prev)->next)
+	{
+	    if (*prev == position)
+		break;
+	}
+#ifdef XFT_DEBUG
+	if (!*prev)
+	    printf ("position not on list\n");
+#endif
+    }
+
+#ifdef XFT_DEBUG_EDIT
+    printf ("%s list before ", append ? "Append" : "Prepend");
+    XftValueListPrint (*head);
+    printf ("\n");
+#endif
+    
+    new->next = *prev;
+    *prev = new;
+    
+#ifdef XFT_DEBUG_EDIT
+    printf ("%s list after ", append ? "Append" : "Prepend");
+    XftValueListPrint (*head);
+    printf ("\n");
+#endif
+    
+    return True;
+    
+bail1:
+    free (new);
+bail0:
+    return False;
+}
+
+static void
+_XftConfigDel (XftValueList	**head,
+	      XftValueList	*position)
+{
+    XftValueList    **prev;
+
+    for (prev = head; *prev; prev = &(*prev)->next)
+    {
+	if (*prev == position)
+	{
+	    *prev = position->next;
+	    position->next = 0;
+	    XftValueListDestroy (position);
+	    break;
+	}
+    }
+}
+
+Bool
+XftConfigSubstitute (XftPattern *p)
+{
+    XftSubst	    *s;
+    XftSubState	    *st;
+    int		    i;
+    XftTest	    *t;
+    XftEdit	    *e;
+    XftValue	    v;
+
+    st = (XftSubState *) malloc (XftSubstsMaxObjects * sizeof (XftSubState));
+    if (!st && XftSubstsMaxObjects)
+	return False;
+
+#ifdef XFT_DEBUG_EDIT
+    printf ("XftConfigSubstitute ");
+    XftPatternPrint (p);
+#endif
+    for (s = XftSubsts; s; s = s->next)
+    {
+	for (t = s->test, i = 0; t; t = t->next, i++)
+	{
+#ifdef XFT_DEBUG_EDIT
+	    printf ("XftConfigSubstitute test ");
+	    XftTestPrint (t);
+#endif
+	    st[i].elt = XftPatternFind (p, t->field, False);
+	    if (!st[i].elt)
+	    {
+		if (t->qual == XftQualAll)
+		    continue;
+		else
+		    break;
+	    }
+	    st[i].value = _XftConfigMatchValueList (t, st[i].elt->values);
+	    if (!st[i].value)
+		break;
+	}
+	if (t)
+	{
+#ifdef XFT_DEBUG_EDIT
+	    printf ("No match\n");
+#endif
+	    continue;
+	}
+#ifdef XFT_DEBUG_EDIT
+	printf ("Substitute ");
+	XftSubstPrint (s);
+#endif
+	for (e = s->edit; e; e = e->next)
+	{
+	    v = _XftConfigEvaluate (p, e->expr);
+	    if (v.type == XftTypeVoid)
+		continue;
+	    for (t = s->test, i = 0; t; t = t->next, i++)
+		if (!_XftStrCmpIgnoreCase (t->field, e->field))
+		    break;
+	    switch (e->op) {
+	    case XftOpAssign:
+		if (t)
+		{
+		    _XftConfigAdd (&st[i].elt->values, st[i].value, True, v);
+		    _XftConfigDel (&st[i].elt->values, st[i].value);
+		}
+		else
+		{
+		    XftPatternDel (p, e->field);
+		    XftPatternAdd (p, e->field, v, True);
+		}
+		break;
+	    case XftOpPrepend:
+		if (t)
+		    _XftConfigAdd (&st[i].elt->values, st[i].value, False, v);
+		else
+		    XftPatternAdd (p, e->field, v, False);
+		break;
+	    case XftOpAppend:
+		if (t)
+		    _XftConfigAdd (&st[i].elt->values, st[i].value, True, v);
+		else
+		    XftPatternAdd (p, e->field, v, True);
+		break;
+	    default:
+		break;
+	    }
+	}
+#ifdef XFT_DEBUG_EDIT
+	printf ("XftConfigSubstitute edit");
+	XftPatternPrint (p);
+#endif
+    }
+    free (st);
+#ifdef XFT_DEBUG_EDIT
+    printf ("XftConfigSubstitute done");
+    XftPatternPrint (p);
+#endif
+    return True;
+}
Index: xc/lib/Xft/xftcolor.c
diff -u /dev/null xc/lib/Xft/xftcolor.c:1.1
--- /dev/null	Mon Dec 18 14:24:36 2000
+++ xc/lib/Xft/xftcolor.c	Thu Nov 30 22:27:57 2000
@@ -0,0 +1,125 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcolor.c,v 1.1 2000/12/01 03:27:57 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "xftint.h"
+
+Bool
+XftColorAllocName (Display  *dpy,
+		   Visual   *visual,
+		   Colormap cmap,
+		   char	    *name,
+		   XftColor *result)
+{
+    XColor  screen, exact;
+    
+    if (!XAllocNamedColor (dpy, cmap, name, &screen, &exact))
+    {
+	/* XXX stick standard colormap stuff here */
+	return False;
+    }
+
+    result->pixel = screen.pixel;
+    result->color.red = exact.red;
+    result->color.green = exact.green;
+    result->color.blue = exact.blue;
+    result->color.alpha = 0xffff;
+    return True;
+}
+
+static short
+maskbase (unsigned long m)
+{
+    short        i;
+
+    if (!m)
+	return 0;
+    i = 0;
+    while (!(m&1))
+    {
+	m>>=1;
+	i++;
+    }
+    return i;
+}
+
+static short
+masklen (unsigned long m)
+{
+    unsigned long y;
+
+    y = (m >> 1) &033333333333;
+    y = m - y - ((y >>1) & 033333333333);
+    return (short) (((y + (y >> 3)) & 030707070707) % 077);
+}
+
+Bool
+XftColorAllocValue (Display	    *dpy,
+		    Visual	    *visual,
+		    Colormap	    cmap,
+		    XRenderColor    *color,
+		    XftColor	    *result)
+{
+    if (visual->class == TrueColor)
+    {
+	int	    red_shift, red_len;
+	int	    green_shift, green_len;
+	int	    blue_shift, blue_len;
+
+	red_shift = maskbase (visual->red_mask);
+	red_len = masklen (visual->red_mask);
+	green_shift = maskbase (visual->green_mask);
+	green_len = masklen (visual->green_mask);
+	blue_shift = maskbase (visual->blue_mask);
+	blue_len = masklen (visual->blue_mask);
+	result->pixel = (((color->red >> (16 - red_len)) << red_shift) |
+			 ((color->green >> (16 - green_len)) << green_shift) |
+			 ((color->blue >> (16 - blue_len)) << blue_shift));
+    }
+    else
+    {
+	XColor  xcolor;
+	    
+	xcolor.red = color->red;
+	xcolor.green = color->green;
+	xcolor.blue = color->blue;
+	if (!XAllocColor (dpy, cmap, &xcolor))
+	    return False;
+	result->pixel = xcolor.pixel;
+    }
+    result->color.red = color->red;
+    result->color.green = color->green;
+    result->color.blue = color->blue;
+    result->color.alpha = 0xffff;
+    return True;
+}
+
+void
+XftColorFree (Display	*dpy,
+	      Visual	*visual,
+	      Colormap	cmap,
+	      XftColor	*color)
+{
+    if (visual->class != TrueColor)
+	XFreeColors (dpy, cmap, &color->pixel, 1, 0);
+}
Index: xc/lib/Xft/xftcore.c
diff -u /dev/null xc/lib/Xft/xftcore.c:1.4
--- /dev/null	Mon Dec 18 14:24:36 2000
+++ xc/lib/Xft/xftcore.c	Fri Dec  8 02:51:27 2000
@@ -0,0 +1,178 @@
+/*
+ * $XFree86: xc/lib/Xft/xftcore.c,v 1.4 2000/12/08 07:51:27 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include "xftint.h"
+
+XChar2b *
+XftCoreConvert16 (XftChar16	*string,
+		  int		len,
+		  XChar2b	xcloc[XFT_CORE_N16LOCAL])
+{
+    XChar2b *xc;
+    int	    i;
+    
+    if (len < XFT_CORE_N16LOCAL)
+	xc = xcloc;
+    else
+	xc = (XChar2b *) malloc (len * sizeof (XChar2b));
+    for (i = 0; i < len; i++)
+    {
+	xc[i].byte1 = string[i] & 0xff;
+	xc[i].byte2 = (string[i] >> 8) & 0xff;
+    }
+    return xc;
+}
+
+XChar2b *
+XftCoreConvert32 (XftChar32	    *string,
+		  int		    len,
+		  XChar2b	    xcloc[XFT_CORE_N16LOCAL])
+{
+    XChar2b *xc;
+    int	    i;
+    
+    if (len < XFT_CORE_N16LOCAL)
+	xc = xcloc;
+    else
+	xc = (XChar2b *) malloc (len * sizeof (XChar2b));
+    for (i = 0; i < len; i++)
+    {
+	xc[i].byte1 = string[i] & 0xff;
+	xc[i].byte2 = (string[i] >> 8) & 0xff;
+    }
+    return xc;
+}
+
+void
+XftCoreExtents8 (Display	*dpy,
+		 XFontStruct	*fs,
+		 XftChar8	*string, 
+		 int		len,
+		 XGlyphInfo	*extents)
+{
+    int		direction;
+    int		ascent, descent;
+    XCharStruct overall;
+
+    XTextExtents (fs, (char *) string, len, &direction,
+		  &ascent, &descent, &overall);
+    if (overall.lbearing < overall.rbearing)
+    {
+	extents->x = overall.lbearing;
+	extents->width = overall.rbearing - overall.lbearing;
+    }
+    else
+    {
+	extents->x = overall.rbearing;
+	extents->width = overall.lbearing - overall.rbearing;
+    }
+    extents->y = -overall.ascent;
+    extents->height = overall.ascent + overall.descent;
+    extents->xOff = overall.width;
+    extents->yOff = 0;
+}
+
+void
+XftCoreExtents16 (Display	    *dpy,
+		  XFontStruct	    *fs,
+		  XftChar16	    *string, 
+		  int		    len,
+		  XGlyphInfo	    *extents)
+{
+    int		direction;
+    int		ascent, descent;
+    XCharStruct overall;
+    XChar2b	*xc, xcloc[XFT_CORE_N16LOCAL];
+
+    xc = XftCoreConvert16 (string, len, xcloc);
+    XTextExtents16 (fs, xc, len, &direction,
+		    &ascent, &descent, &overall);
+    if (overall.lbearing < overall.rbearing)
+    {
+	extents->x = overall.lbearing;
+	extents->width = overall.rbearing - overall.lbearing;
+    }
+    else
+    {
+	extents->x = overall.rbearing;
+	extents->width = overall.lbearing - overall.rbearing;
+    }
+    extents->y = -overall.ascent;
+    extents->height = overall.ascent + overall.descent;
+    extents->xOff = overall.width;
+    extents->yOff = 0;
+}
+
+void
+XftCoreExtents32 (Display	    *dpy,
+		  XFontStruct	    *fs,
+		  XftChar32	    *string, 
+		  int		    len,
+		  XGlyphInfo	    *extents)
+{
+    int		direction;
+    int		ascent, descent;
+    XCharStruct overall;
+    XChar2b	*xc, xcloc[XFT_CORE_N16LOCAL];
+
+    xc = XftCoreConvert32 (string, len, xcloc);
+    XTextExtents16 (fs, xc, len, &direction,
+		    &ascent, &descent, &overall);
+    if (overall.lbearing < overall.rbearing)
+    {
+	extents->x = overall.lbearing;
+	extents->width = overall.rbearing - overall.lbearing;
+    }
+    else
+    {
+	extents->x = overall.rbearing;
+	extents->width = overall.lbearing - overall.rbearing;
+    }
+    extents->y = -overall.ascent;
+    extents->height = overall.ascent + overall.descent;
+    extents->xOff = overall.width;
+    extents->yOff = 0;
+}
+
+Bool
+XftCoreGlyphExists (Display	    *dpy,
+		    XFontStruct	    *fs,
+		    XftChar32	    glyph)
+{
+    int		direction;
+    int		ascent, descent;
+    XCharStruct overall;
+    XChar2b	xc;
+
+    XftCoreConvert32 (&glyph, 1, &xc);
+    XTextExtents16 (fs, &xc, 1, &direction,
+		    &ascent, &descent, &overall);
+    return (overall.lbearing != 0 ||
+	    overall.rbearing != 0 ||
+	    overall.width != 0 ||
+	    overall.ascent != 0 ||
+	    overall.descent != 0);
+}
+
Index: xc/lib/Xft/xftdbg.c
diff -u /dev/null xc/lib/Xft/xftdbg.c:1.1
--- /dev/null	Mon Dec 18 14:24:36 2000
+++ xc/lib/Xft/xftdbg.c	Wed Nov 29 03:39:21 2000
@@ -0,0 +1,221 @@
+/*
+ * $XFree86: xc/lib/Xft/xftdbg.c,v 1.1 2000/11/29 08:39:21 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "xftint.h"
+#include <stdio.h>
+
+void
+XftValuePrint (XftValue v)
+{
+    switch (v.type) {
+    case XftTypeVoid:
+	printf (" <void>");
+	break;
+    case XftTypeInteger:
+	printf (" %d", v.u.i);
+	break;
+    case XftTypeDouble:
+	printf (" %g", v.u.d);
+	break;
+    case XftTypeString:
+	printf (" \"%s\"", v.u.s);
+	break;
+    case XftTypeBool:
+	printf (" %s", v.u.b ? "True" : "False");
+	break;
+    }
+}
+
+void
+XftValueListPrint (XftValueList *l)
+{
+    for (; l; l = l->next)
+	XftValuePrint (l->value);
+}
+
+void
+XftPatternPrint (XftPattern *p)
+{
+    int		    i;
+    XftPatternElt   *e;
+    
+    printf ("Pattern %d of %d\n", p->num, p->size);
+    for (i = 0; i < p->num; i++)
+    {
+	e = &p->elts[i];
+	printf ("\t%s:", e->object);
+	XftValueListPrint (e->values);
+	printf ("\n");
+    }
+    printf ("\n");
+}
+
+void
+XftOpPrint (XftOp op)
+{
+    switch (op) {
+    case XftOpInteger: printf ("Integer"); break;
+    case XftOpDouble: printf ("Double"); break;
+    case XftOpString: printf ("String"); break;
+    case XftOpBool: printf ("Bool"); break;
+    case XftOpField: printf ("Field"); break;
+    case XftOpAssign: printf ("Assign"); break;
+    case XftOpPrepend: printf ("Prepend"); break;
+    case XftOpAppend: printf ("Append"); break;
+    case XftOpQuest: printf ("Quest"); break;
+    case XftOpOr: printf ("Or"); break;
+    case XftOpAnd: printf ("And"); break;
+    case XftOpEqual: printf ("Equal"); break;
+    case XftOpNotEqual: printf ("NotEqual"); break;
+    case XftOpLess: printf ("Less"); break;
+    case XftOpLessEqual: printf ("LessEqual"); break;
+    case XftOpMore: printf ("More"); break;
+    case XftOpMoreEqual: printf ("MoreEqual"); break;
+    case XftOpPlus: printf ("Plus"); break;
+    case XftOpMinus: printf ("Minus"); break;
+    case XftOpTimes: printf ("Times"); break;
+    case XftOpDivide: printf ("Divide"); break;
+    case XftOpNot: printf ("Not"); break;
+    case XftOpNil: printf ("Nil"); break;
+    }
+}
+
+void
+XftTestPrint (XftTest *test)
+{
+    switch (test->qual) {
+    case XftQualAny:
+	printf ("any ");
+	break;
+    case XftQualAll:
+	printf ("all ");
+	break;
+    }
+    printf ("%s ", test->field);
+    XftOpPrint (test->op);
+    printf (" ");
+    XftValuePrint (test->value);
+    printf ("\n");
+}
+
+void
+XftExprPrint (XftExpr *expr)
+{
+    switch (expr->op) {
+    case XftOpInteger: printf ("%d", expr->u.ival); break;
+    case XftOpDouble: printf ("%g", expr->u.dval); break;
+    case XftOpString: printf ("\"%s\"", expr->u.sval); break;
+    case XftOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
+    case XftOpField: printf ("%s", expr->u.field); break;
+    case XftOpQuest:
+	XftExprPrint (expr->u.tree.left);
+	printf (" quest ");
+	XftExprPrint (expr->u.tree.right->u.tree.left);
+	printf (" colon ");
+	XftExprPrint (expr->u.tree.right->u.tree.right);
+	break;
+    case XftOpOr:
+    case XftOpAnd:
+    case XftOpEqual:
+    case XftOpNotEqual:
+    case XftOpLess:
+    case XftOpLessEqual:
+    case XftOpMore:
+    case XftOpMoreEqual:
+    case XftOpPlus:
+    case XftOpMinus:
+    case XftOpTimes:
+    case XftOpDivide:
+	XftExprPrint (expr->u.tree.left);
+	printf (" ");
+	switch (expr->op) {
+	case XftOpOr: printf ("Or"); break;
+	case XftOpAnd: printf ("And"); break;
+	case XftOpEqual: printf ("Equal"); break;
+	case XftOpNotEqual: printf ("NotEqual"); break;
+	case XftOpLess: printf ("Less"); break;
+	case XftOpLessEqual: printf ("LessEqual"); break;
+	case XftOpMore: printf ("More"); break;
+	case XftOpMoreEqual: printf ("MoreEqual"); break;
+	case XftOpPlus: printf ("Plus"); break;
+	case XftOpMinus: printf ("Minus"); break;
+	case XftOpTimes: printf ("Times"); break;
+	case XftOpDivide: printf ("Divide"); break;
+	default: break;
+	}
+	printf (" ");
+	XftExprPrint (expr->u.tree.right);
+	break;
+    case XftOpNot:
+	printf ("Not ");
+	XftExprPrint (expr->u.tree.left);
+	break;
+    default:
+	break;
+    }
+}
+
+void
+XftEditPrint (XftEdit *edit)
+{
+    printf ("Edit %s ", edit->field);
+    XftOpPrint (edit->op);
+    printf (" ");
+    XftExprPrint (edit->expr);
+}
+
+void
+XftSubstPrint (XftSubst *subst)
+{
+    XftEdit	*e;
+    XftTest	*t;
+    
+    printf ("match\n");
+    for (t = subst->test; t; t = t->next)
+    {
+	printf ("\t");
+	XftTestPrint (t);
+    }
+    printf ("edit\n");
+    for (e = subst->edit; e; e = e->next)
+    {
+	printf ("\t");
+	XftEditPrint (e);
+	printf (";\n");
+    }
+    printf ("\n");
+}
+
+void
+XftFontSetPrint (XftFontSet *s)
+{
+    int	    i;
+
+    printf ("FontSet %d of %d\n", s->nfont, s->sfont);
+    for (i = 0; i < s->nfont; i++)
+    {
+	printf ("Font %d ", i);
+	XftPatternPrint (s->fonts[i]);
+    }
+}
Index: xc/lib/Xft/xftdir.c
diff -u /dev/null xc/lib/Xft/xftdir.c:1.1
--- /dev/null	Mon Dec 18 14:24:37 2000
+++ xc/lib/Xft/xftdir.c	Wed Nov 29 03:39:21 2000
@@ -0,0 +1,78 @@
+/*
+ * $XFree86: xc/lib/Xft/xftdir.c,v 1.1 2000/11/29 08:39:21 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <string.h>
+#include "xftint.h"
+
+Bool
+XftDirScan (XftFontSet *set, const char *dir)
+{
+    DIR		    *d;
+    struct dirent   *e;
+    char	    *file;
+    char	    *base;
+    XftPattern	    *font;
+    int		    count;
+    Bool	    ret = True;
+    int		    id;
+
+    d = opendir (dir);
+    if (!d)
+	return False;
+    file = (char *) malloc (strlen (dir) + 1 + 256 + 1);
+    if (!file)
+    {
+	closedir (d);
+	return False;
+    }
+    strcpy (file, dir);
+    strcat (file, "/");
+    base = file + strlen (file);
+    while (ret && (e = readdir (d)))
+    {
+	if (e->d_name[0] != '.')
+	{
+	    strcpy (base, e->d_name);
+	    id = 0;
+	    do
+	    {
+		font = XftFreeTypeQuery (file, id, &count);
+		if (font)
+		{
+		    if (!XftFontSetAdd (set, font))
+			ret = False;
+		}
+		id++;
+	    } while (font && ret && id < count);
+	}
+    }
+    free (file);
+    closedir (d);
+    return ret;
+}
+
+	    
Index: xc/lib/Xft/xftdpy.c
diff -u /dev/null xc/lib/Xft/xftdpy.c:1.4
--- /dev/null	Mon Dec 18 14:24:37 2000
+++ xc/lib/Xft/xftdpy.c	Sun Dec 17 03:30:45 2000
@@ -0,0 +1,380 @@
+/*
+ * $XFree86: xc/lib/Xft/xftdpy.c,v 1.4 2000/12/17 08:30:45 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <X11/Xlibint.h>
+#include "xftint.h"
+
+XftDisplayInfo	*_XftDisplayInfo;
+
+static int
+_XftCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+    XftDisplayInfo  *info, **prev;
+
+    for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
+	if (info->codes == codes)
+	    break;
+    if (!info)
+	return 0;
+    *prev = info->next;
+    if (info->defaults)
+	XftPatternDestroy (info->defaults);
+    if (info->coreFonts)
+	XftFontSetDestroy (info->coreFonts);
+    free (info);
+    return 0;
+}
+
+static XftDisplayInfo *
+_XftDisplayInfoGet (Display *dpy)
+{
+    XftDisplayInfo  *info, **prev;
+
+    for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
+    {
+	if (info->display == dpy)
+	{
+	    /*
+	     * MRU the list
+	     */
+	    if (prev != &_XftDisplayInfo)
+	    {
+		*prev = info->next;
+		info->next = _XftDisplayInfo;
+		_XftDisplayInfo = info;
+	    }
+	    return info;
+	}
+    }
+    info = (XftDisplayInfo *) malloc (sizeof (XftDisplayInfo));
+    if (!info)
+	goto bail0;
+    info->codes = XAddExtension (dpy);
+    if (!info->codes)
+	goto bail1;
+    (void) XESetCloseDisplay (dpy, info->codes->extension, _XftCloseDisplay);
+
+    info->display = dpy;
+    info->defaults = 0;
+    info->coreFonts = 0;
+    info->hasRender = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))) != 0;
+    
+    info->next = _XftDisplayInfo;
+    _XftDisplayInfo = info;
+    return info;
+    
+bail1:
+    free (info);
+bail0:
+    return 0;
+}
+
+Bool
+XftDefaultHasRender (Display *dpy)
+{
+#ifdef FREETYPE2
+    XftDisplayInfo  *info = _XftDisplayInfoGet (dpy);
+
+    if (!info)
+	return False;
+    return info->hasRender;
+#else
+    return False;
+#endif
+}
+
+Bool
+XftDefaultSet (Display *dpy, XftPattern *defaults)
+{
+    XftDisplayInfo  *info = _XftDisplayInfoGet (dpy);
+
+    if (!info)
+	return False;
+    if (info->defaults)
+	XftPatternDestroy (info->defaults);
+    info->defaults = defaults;
+    return True;
+}
+
+int
+XftDefaultParseBool (char *v)
+{
+    char    c0, c1;
+
+    c0 = *v;
+    if (isupper (c0))
+	c0 = tolower (c0);
+    if (c0 == 't' || c0 == 'y' || c0 == '1')
+	return 1;
+    if (c0 == 'f' || c0 == 'n' || c0 == '0')
+	return 0;
+    if (c0 == 'o')
+    {
+	c1 = v[1];
+	if (isupper (c1))
+	    c1 = tolower (c1);
+	if (c1 == 'n')
+	    return 1;
+	if (c1 == 'f')
+	    return 0;
+    }
+    return -1;
+}
+
+static Bool
+_XftDefaultInitBool (Display *dpy, XftPattern *pat, char *option)
+{
+    char    *v;
+    int	    i;
+
+    v = XGetDefault (dpy, "Xft", option);
+    if (v && (i = XftDefaultParseBool (v)) >= 0)
+	return XftPatternAddBool (pat, option, i != 0);
+    return True;
+}
+
+static Bool
+_XftDefaultInitDouble (Display *dpy, XftPattern *pat, char *option)
+{
+    char    *v, *e;
+    double  d;
+
+    v = XGetDefault (dpy, "Xft", option);
+    if (v)
+    {
+	d = strtod (v, &e);
+	if (e != v)
+	    return XftPatternAddDouble (pat, option, d);
+    }
+    return True;
+}
+
+static Bool
+_XftDefaultInitInteger (Display *dpy, XftPattern *pat, char *option)
+{
+    char    *v, *e;
+    int	    i;
+
+    v = XGetDefault (dpy, "Xft", option);
+    if (v)
+    {
+	if (XftNameConstant (v, &i))
+	    return XftPatternAddInteger (pat, option, i);
+	i = strtol (v, &e, 0);
+	if (e != v)
+	    return XftPatternAddInteger (pat, option, i);
+    }
+    return True;
+}
+
+static XftPattern *
+_XftDefaultInit (Display *dpy)
+{
+    XftPattern	*pat;
+
+    pat = XftPatternCreate ();
+    if (!pat)
+	goto bail0;
+
+    if (!_XftDefaultInitBool (dpy, pat, XFT_CORE))
+	goto bail1;
+    if (!_XftDefaultInitDouble (dpy, pat, XFT_SCALE))
+	goto bail1;
+    if (!_XftDefaultInitBool (dpy, pat, XFT_RENDER))
+	goto bail1;
+    if (!_XftDefaultInitInteger (dpy, pat, XFT_RGBA))
+	goto bail1;
+    if (!_XftDefaultInitBool (dpy, pat, XFT_ANTIALIAS))
+	goto bail1;
+    
+    return pat;
+    
+bail1:
+    XftPatternDestroy (pat);
+bail0:
+    return 0;
+}
+
+static XftResult
+_XftDefaultGet (Display *dpy, const char *object, int screen, XftValue *v)
+{
+    XftDisplayInfo  *info = _XftDisplayInfoGet (dpy);
+    XftResult	    r;
+
+    if (!info)
+	return XftResultNoMatch;
+    
+    if (!info->defaults)
+    {
+	info->defaults = _XftDefaultInit (dpy);
+	if (!info->defaults)
+	    return XftResultNoMatch;
+    }
+    r = XftPatternGet (info->defaults, object, screen, v);
+    if (r == XftResultNoId && screen > 0)
+	r = XftPatternGet (info->defaults, object, 0, v);
+    return r;
+}
+
+Bool
+XftDefaultGetBool (Display *dpy, const char *object, int screen, Bool def)
+{
+    XftResult	    r;
+    XftValue	    v;
+
+    r = _XftDefaultGet (dpy, object, screen, &v);
+    if (r != XftResultMatch || v.type != XftTypeBool)
+	return def;
+    return v.u.b;
+}
+
+int
+XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def)
+{
+    XftResult	    r;
+    XftValue	    v;
+
+    r = _XftDefaultGet (dpy, object, screen, &v);
+    if (r != XftResultMatch || v.type != XftTypeInteger)
+	return def;
+    return v.u.i;
+}
+
+double
+XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def)
+{
+    XftResult	    r;
+    XftValue	    v;
+
+    r = _XftDefaultGet (dpy, object, screen, &v);
+    if (r != XftResultMatch || v.type != XftTypeDouble)
+	return def;
+    return v.u.d;
+}
+
+XftFontSet *
+XftDisplayGetFontSet (Display *dpy)
+{
+    XftDisplayInfo  *info = _XftDisplayInfoGet (dpy);
+
+    if (!info)
+	return 0;
+    if (!info->coreFonts)
+    {
+	info->coreFonts = XftFontSetCreate ();
+	if (info->coreFonts)
+	{
+	    if (!XftCoreAddFonts (info->coreFonts, dpy,
+				  XftDefaultGetBool (dpy, XFT_SCALABLE,
+						     DefaultScreen (dpy),
+						     False)))
+	    {
+		XftFontSetDestroy (info->coreFonts);
+		info->coreFonts = 0;
+	    }
+	}
+    }
+    return info->coreFonts;
+}
+
+void
+XftDefaultSubstitute (Display *dpy, int screen, XftPattern *pattern)
+{
+    XftValue	v;
+    double	size;
+    double	scale;
+
+    if (XftPatternGet (pattern, XFT_STYLE, 0, &v) == XftResultNoMatch)
+    {
+	if (XftPatternGet (pattern, XFT_WEIGHT, 0, &v) == XftResultNoMatch )
+	{
+	    XftPatternAddInteger (pattern, XFT_WEIGHT, XFT_WEIGHT_MEDIUM);
+	}
+	if (XftPatternGet (pattern, XFT_SLANT, 0, &v) == XftResultNoMatch)
+	{
+	    XftPatternAddInteger (pattern, XFT_SLANT, XFT_SLANT_ROMAN);
+	}
+    }
+    if (XftPatternGet (pattern, XFT_ENCODING, 0, &v) == XftResultNoMatch)
+	XftPatternAddString (pattern, XFT_ENCODING, "iso8859-1");
+    if (XftPatternGet (pattern, XFT_RENDER, 0, &v) == XftResultNoMatch)
+    {
+	XftPatternAddBool (pattern, XFT_RENDER,
+			   XftDefaultGetBool (dpy, XFT_RENDER, screen, 
+					      XftDefaultHasRender (dpy)));
+    }
+    if (XftPatternGet (pattern, XFT_CORE, 0, &v) == XftResultNoMatch)
+    {
+	XftPatternAddBool (pattern, XFT_CORE,
+			   XftDefaultGetBool (dpy, XFT_CORE, screen, 
+					      !XftDefaultHasRender (dpy)));
+    }
+    if (XftPatternGet (pattern, XFT_ANTIALIAS, 0, &v) == XftResultNoMatch)
+    {
+	XftPatternAddBool (pattern, XFT_ANTIALIAS,
+			   XftDefaultGetBool (dpy, XFT_ANTIALIAS, screen,
+					      True));
+    }
+    if (XftPatternGet (pattern, XFT_RGBA, 0, &v) == XftResultNoMatch)
+    {
+	XftPatternAddInteger (pattern, XFT_RGBA,
+			      XftDefaultGetInteger (dpy, XFT_RGBA, screen, 
+						    XFT_RGBA_NONE));
+    }
+    if (XftPatternGet (pattern, XFT_PIXEL_SIZE, 0, &v) == XftResultNoMatch)
+    {
+	int	pixels, mm;
+
+	if (XftPatternGet (pattern, XFT_SIZE, 0, &v) != XftResultMatch)
+	{
+	    size = 12.0;
+	    XftPatternAddDouble (pattern, XFT_SIZE, size);
+	}
+	else
+	{
+	    switch (v.type) {
+	    case XftTypeInteger:
+		size = (double) v.u.i;
+		break;
+	    case XftTypeDouble:
+		size = v.u.d;
+		break;
+	    default:
+		size = 12.0;
+		break;
+	    }
+	}
+	scale = XftDefaultGetDouble (dpy, XFT_SCALE, screen, 1.0);
+	size *= scale;
+	pixels = DisplayHeight (dpy, DefaultScreen (dpy));
+	mm = DisplayHeightMM (dpy, DefaultScreen (dpy));
+	size = size / 72.0;
+	size = size * 25.4;
+	size = size * pixels / mm;
+	XftPatternAddDouble (pattern, XFT_PIXEL_SIZE, size);
+    }
+}
+
Index: xc/lib/Xft/xftdraw.c
diff -u /dev/null xc/lib/Xft/xftdraw.c:1.10
--- /dev/null	Mon Dec 18 14:24:38 2000
+++ xc/lib/Xft/xftdraw.c	Fri Dec 15 12:12:52 2000
@@ -0,0 +1,410 @@
+/*
+ * $XFree86: xc/lib/Xft/xftdraw.c,v 1.10 2000/12/15 17:12:52 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include "xftint.h"
+#include <X11/Xutil.h>
+
+XftDraw *
+XftDrawCreate (Display   *dpy,
+	       Drawable  drawable,
+	       Visual    *visual,
+	       Colormap  colormap)
+{
+    XftDraw	*draw;
+
+    draw = (XftDraw *) malloc (sizeof (XftDraw));
+    if (!draw)
+	return 0;
+    draw->dpy = dpy;
+    draw->drawable = drawable;
+    draw->visual = visual;
+    draw->colormap = colormap;
+    draw->core_set = False;
+    draw->render_set = False;
+    draw->render_able = False;
+    draw->clip = 0;
+    return draw;
+}
+
+XftDraw *
+XftDrawCreateBitmap (Display	*dpy,
+		     Pixmap	bitmap)
+{
+    XftDraw	*draw;
+
+    draw = (XftDraw *) malloc (sizeof (XftDraw));
+    if (!draw)
+	return 0;
+    draw->dpy = dpy;
+    draw->drawable = (Drawable) bitmap;
+    draw->visual = 0;
+    draw->colormap = 0;
+    draw->core_set = False;
+    draw->render_set = False;
+    draw->render_able = False;
+    draw->clip = 0;
+    return draw;
+}
+
+static XRenderPictFormat *
+_XftDrawFormat (XftDraw	*draw)
+{
+    if (draw->visual == 0)
+    {
+	XRenderPictFormat   pf;
+
+	pf.type = PictTypeDirect;
+	pf.depth = 1;
+	pf.direct.alpha = 0;
+	pf.direct.alphaMask = 1;
+	return XRenderFindFormat (draw->dpy,
+				  (PictFormatType|
+				   PictFormatDepth|
+				   PictFormatAlpha|
+				   PictFormatAlphaMask),
+				  &pf,
+				  0);
+    }
+    else
+	return XRenderFindVisualFormat (draw->dpy, draw->visual);
+}
+
+static XRenderPictFormat *
+_XftDrawFgFormat (XftDraw	*draw)
+{
+    XRenderPictFormat   pf;
+
+    if (draw->visual == 0)
+    {
+	pf.type = PictTypeDirect;
+	pf.depth = 1;
+	pf.direct.alpha = 0;
+	pf.direct.alphaMask = 1;
+	return XRenderFindFormat (draw->dpy,
+				  (PictFormatType|
+				   PictFormatDepth|
+				   PictFormatAlpha|
+				   PictFormatAlphaMask),
+				  &pf,
+				  0);
+    }
+    else
+    {
+	pf.type = PictTypeDirect;
+	pf.depth = 32;
+	pf.direct.redMask = 0xff;
+	pf.direct.greenMask = 0xff;
+	pf.direct.blueMask = 0xff;
+	pf.direct.alphaMask = 0xff;
+	return XRenderFindFormat (draw->dpy,
+				  (PictFormatType|
+				   PictFormatDepth|
+				   PictFormatRedMask|
+				   PictFormatGreenMask|
+				   PictFormatBlueMask|
+				   PictFormatAlphaMask),
+				  &pf,
+				  0);
+    }
+}
+
+void
+XftDrawChange (XftDraw	*draw,
+	       Drawable	drawable)
+{
+    draw->drawable = drawable;
+    if (draw->render_able)
+    {
+	XRenderPictFormat	    *format;
+	
+	XRenderFreePicture (draw->dpy, draw->render.pict);
+	format = XRenderFindVisualFormat (draw->dpy, draw->visual);
+	draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
+						  format, 0, 0);
+    }
+}
+
+void
+XftDrawDestroy (XftDraw	*draw)
+{
+    if (draw->render_able)
+    {
+	XRenderFreePicture (draw->dpy, draw->render.pict);
+	XFreePixmap (draw->dpy, draw->render.fg_pix);
+	XRenderFreePicture (draw->dpy, draw->render.fg_pict);
+    }
+    if (draw->core_set)
+	XFreeGC (draw->dpy, draw->core.draw_gc);
+    if (draw->clip)
+	XDestroyRegion (draw->clip);
+    free (draw);
+}
+
+Bool
+XftDrawRenderPrepare (XftDraw	*draw,
+		      XftColor	*color,
+		      XftFont	*font)
+{
+    if (!draw->render_set)
+    {
+	XRenderPictFormat	    *format;
+	XRenderPictFormat	    *pix_format;
+	XRenderPictureAttributes    pa;
+
+	draw->render_set = True;
+	draw->render_able = False;
+	format = _XftDrawFormat (draw);
+	pix_format = _XftDrawFgFormat (draw);
+	if (format && pix_format)
+	{
+	    draw->render_able = True;
+
+	    draw->render.pict = XRenderCreatePicture (draw->dpy, draw->drawable,
+						      format, 0, 0);
+	    draw->render.fg_pix = XCreatePixmap (draw->dpy, draw->drawable,
+						 1, 1, pix_format->depth);
+	    pa.repeat = True;
+	    draw->render.fg_pict = XRenderCreatePicture (draw->dpy, 
+							 draw->render.fg_pix,
+							 pix_format,
+							 CPRepeat, &pa);
+	    draw->render.fg_color.red = ~color->color.red;
+	    if (draw->clip)
+		XRenderSetPictureClipRegion (draw->dpy, draw->render.pict,
+					     draw->clip);
+	}
+    }
+    if (!draw->render_able)
+	return False;
+    if (memcmp (&color->color, &draw->render.fg_color, sizeof (XRenderColor)))
+    {
+	XRenderFillRectangle (draw->dpy, PictOpSrc, draw->render.fg_pict,
+			      &color->color, 0, 0, 1, 1);
+	draw->render.fg_color = color->color;
+    }
+    return True;
+}
+
+Bool
+XftDrawCorePrepare (XftDraw	*draw,
+		    XftColor	*color,
+		    XftFont	*font)
+{
+
+    if (!draw->core_set)
+    {
+	XGCValues	    gcv;
+	unsigned long	    mask;
+	draw->core_set = True;
+
+	draw->core.fg = color->pixel;
+	gcv.foreground = draw->core.fg;
+	mask = GCForeground;
+	if (font)
+	{
+	    draw->core.font = font->u.core.font->fid;
+	    gcv.font = draw->core.font;
+	    mask |= GCFont;
+	}
+	draw->core.draw_gc = XCreateGC (draw->dpy, draw->drawable, 
+					mask, &gcv);
+	if (draw->clip)
+	    XSetRegion (draw->dpy, draw->core.draw_gc, draw->clip);
+    }
+    if (draw->core.fg != color->pixel)
+    {
+	draw->core.fg = color->pixel;
+	XSetForeground (draw->dpy, draw->core.draw_gc, draw->core.fg);
+    }
+    if (font && draw->core.font != font->u.core.font->fid)
+    {
+	draw->core.font = font->u.core.font->fid;
+	XSetFont (draw->dpy, draw->core.draw_gc, draw->core.font);
+    }
+    return True;
+}
+
+void
+XftDrawString8 (XftDraw		*draw,
+		XftColor	*color,
+		XftFont		*font,
+		int		x,
+		int		y,
+		XftChar8	*string,
+		int		len)
+{
+    if (font->core)
+    {
+	XftDrawCorePrepare (draw, color, font);
+	XDrawString (draw->dpy, draw->drawable, draw->core.draw_gc, x, y, 
+		     (char *) string, len);
+    }
+#ifdef FREETYPE2
+    else if (XftDrawRenderPrepare (draw, color, font))
+    {
+	XftRenderString8 (draw->dpy, draw->render.fg_pict, font->u.ft.font,
+			  draw->render.pict, 0, 0, x, y, string, len);
+    }
+#endif
+}
+
+#define N16LOCAL    256
+
+void
+XftDrawString16 (XftDraw	*draw,
+		 XftColor	*color,
+		 XftFont	*font,
+		 int		x,
+		 int		y,
+		 XftChar16	*string,
+		 int		len)
+{
+    if (font->core)
+    {
+	XChar2b	    *xc;
+	XChar2b	    xcloc[XFT_CORE_N16LOCAL];
+	
+	XftDrawCorePrepare (draw, color, font);
+	xc = XftCoreConvert16 (string, len, xcloc);
+	XDrawString16 (draw->dpy, draw->drawable, draw->core.draw_gc, x, y, 
+		       xc, len);
+	if (xc != xcloc)
+	    free (xc);
+    }
+#ifdef FREETYPE2
+    else if (XftDrawRenderPrepare (draw, color, font))
+    {
+	XftRenderString16 (draw->dpy, draw->render.fg_pict, font->u.ft.font,
+			   draw->render.pict, 0, 0, x, y, string, len);
+    }
+#endif
+}
+
+void
+XftDrawString32 (XftDraw	*draw,
+		 XftColor	*color,
+		 XftFont	*font,
+		 int		x,
+		 int		y,
+		 XftChar32	*string,
+		 int		len)
+{
+    if (font->core)
+    {
+	XChar2b	    *xc;
+	XChar2b	    xcloc[XFT_CORE_N16LOCAL];
+	
+	XftDrawCorePrepare (draw, color, font);
+	xc = XftCoreConvert32 (string, len, xcloc);
+	XDrawString16 (draw->dpy, draw->drawable, draw->core.draw_gc, x, y, 
+		       xc, len);
+	if (xc != xcloc)
+	    free (xc);
+    }
+#ifdef FREETYPE2
+    else if (XftDrawRenderPrepare (draw, color, font))
+    {
+	XftRenderString32 (draw->dpy, draw->render.fg_pict, font->u.ft.font,
+			   draw->render.pict, 0, 0, x, y, string, len);
+    }
+#endif
+}
+
+void
+XftDrawRect (XftDraw	    *draw,
+	     XftColor	    *color,
+	     int	    x, 
+	     int	    y,
+	     unsigned int   width,
+	     unsigned int   height)
+{
+    if (XftDrawRenderPrepare (draw, color, 0))
+    {
+	XRenderFillRectangle (draw->dpy, PictOpSrc, draw->render.pict,
+			      &color->color, x, y, width, height);
+    }
+    else
+    {
+	XftDrawCorePrepare (draw, color, 0);
+	XFillRectangle (draw->dpy, draw->drawable, draw->core.draw_gc,
+			x, y, width, height);
+    }
+}
+
+Bool
+XftDrawSetClip (XftDraw	*draw,
+		Region	r)
+{
+    Region			n = 0;
+
+    if (!r && !draw->clip)
+	return True;
+
+    if (r)
+    {
+	n = XCreateRegion ();
+	if (n)
+	{
+	    if (!XUnionRegion (n, r, n))
+	    {
+		XDestroyRegion (n);
+		return False;
+	    }
+	}
+    }
+    if (draw->clip)
+    {
+	XDestroyRegion (draw->clip);
+    }
+    draw->clip = n;
+    if (draw->render_able)
+    {
+	XRenderPictureAttributes	pa;
+        if (n)
+	{
+	    XRenderSetPictureClipRegion (draw->dpy, draw->render.pict, n);
+	}
+	else
+	{
+	    pa.clip_mask = None;
+	    XRenderChangePicture (draw->dpy, draw->render.pict,
+				  CPClipMask, &pa);
+	}
+    }
+    if (draw->core_set)
+    {
+	XGCValues   gv;
+	
+	if (n)
+	    XSetRegion (draw->dpy, draw->core.draw_gc, n);
+	else
+	{
+	    gv.clip_mask = None;
+	    XChangeGC (draw->dpy, draw->core.draw_gc,
+		       GCClipMask, &gv);
+	}
+    }
+    return True;
+}
Index: xc/lib/Xft/xftextent.c
diff -u /dev/null xc/lib/Xft/xftextent.c:1.4
--- /dev/null	Mon Dec 18 14:24:38 2000
+++ xc/lib/Xft/xftextent.c	Fri Dec 15 12:12:52 2000
@@ -0,0 +1,82 @@
+/*
+ * $XFree86: xc/lib/Xft/xftextent.c,v 1.4 2000/12/15 17:12:52 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "xftint.h"
+
+void
+XftTextExtents8 (Display	*dpy,
+		 XftFont	*font,
+		 XftChar8	*string, 
+		 int		len,
+		 XGlyphInfo	*extents)
+{
+    if (font->core)
+    {
+	XftCoreExtents8 (dpy, font->u.core.font, string, len, extents);
+    }
+#ifdef FREETYPE2
+    else
+    {
+	XftRenderExtents8 (dpy, font->u.ft.font, string, len, extents);
+    }
+#endif
+}
+
+void
+XftTextExtents16 (Display	    *dpy,
+		  XftFont	    *font,
+		  XftChar16	    *string, 
+		  int		    len,
+		  XGlyphInfo	    *extents)
+{
+    if (font->core)
+    {
+	XftCoreExtents16 (dpy, font->u.core.font, string, len, extents);
+    }
+#ifdef FREETYPE2
+    else
+    {
+	XftRenderExtents16 (dpy, font->u.ft.font, string, len, extents);
+    }
+#endif
+}
+
+void
+XftTextExtents32 (Display	*dpy,
+		  XftFont	*font,
+		  XftChar32	*string, 
+		  int		len,
+		  XGlyphInfo	*extents)
+{
+    if (font->core)
+    {
+	XftCoreExtents32 (dpy, font->u.core.font, string, len, extents);
+    }
+#ifdef FREETYPE2
+    else
+    {
+	XftRenderExtents32 (dpy, font->u.ft.font, string, len, extents);
+    }
+#endif
+}
Index: xc/lib/Xft/xftfont.c
diff -u /dev/null xc/lib/Xft/xftfont.c:1.7
--- /dev/null	Mon Dec 18 14:24:39 2000
+++ xc/lib/Xft/xftfont.c	Fri Dec 15 12:12:53 2000
@@ -0,0 +1,299 @@
+/*
+ * $XFree86: xc/lib/Xft/xftfont.c,v 1.7 2000/12/15 17:12:53 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include "xftint.h"
+#include <stdio.h>
+
+XftPattern *
+XftFontMatch (Display *dpy, int screen, XftPattern *pattern, XftResult *result)
+{
+    XftPattern	*new;
+    XftPattern	*match;
+    XftFontSet	*sets[2];
+    int		nsets;
+#ifdef FREETYPE2
+    Bool	render, core;
+#endif
+
+    if (!XftInit (0))
+	return 0;
+    
+    new = XftPatternDuplicate (pattern);
+    if (!new)
+	return 0;
+    XftConfigSubstitute (new);
+    XftDefaultSubstitute (dpy, screen, new);
+    nsets = 0;
+    
+#ifdef FREETYPE2
+    render = False;
+    core = True;
+    (void) XftPatternGetBool (new, XFT_RENDER, 0, &render);
+    (void) XftPatternGetBool (new, XFT_CORE, 0, &core);
+
+    if (render)
+    {
+	if (XftInitFtLibrary ())
+	{
+	    sets[nsets] = _XftFontSet;
+	    if (sets[nsets])
+		nsets++;
+	}
+    }
+    if (core)
+#endif
+    {
+	sets[nsets] = XftDisplayGetFontSet (dpy);
+	if (sets[nsets])
+	    nsets++;
+    }
+    
+    match = XftFontSetMatch (sets, nsets, new, result);
+    XftPatternDestroy (new);
+    return match;
+}
+
+XftFont *
+XftFontOpenPattern (Display *dpy, XftPattern *pattern)
+{
+    Bool	    core = True;
+    XFontStruct	    *xfs = 0;
+    XftFont	    *font;
+#ifdef FREETYPE2
+    XftFontStruct   *fs = 0;
+
+    if (XftPatternGetBool (pattern, XFT_CORE, 0, &core) != XftResultMatch)
+	return 0;
+    if (core)
+#endif
+    {
+	xfs = XftCoreOpen (dpy, pattern);
+	if (!xfs) return 0;
+    }
+#ifdef FREETYPE2
+    else
+    {
+	fs = XftFreeTypeOpen (dpy, pattern);
+	if (!fs) return 0;
+    }
+#endif
+    font = (XftFont *) malloc (sizeof (XftFont));
+    font->core = core;
+    font->pattern = pattern;
+#ifdef FREETYPE2
+    if (core)
+#endif
+    {
+	font->u.core.font = xfs;
+	font->ascent = xfs->ascent;
+	font->descent = xfs->descent;
+	font->height = xfs->ascent + xfs->descent;
+	font->max_advance_width = xfs->max_bounds.width;
+    }
+#ifdef FREETYPE2
+    else
+    {
+	font->u.ft.font = fs;
+	font->ascent = fs->ascent;
+	font->descent = fs->descent;
+	font->height = fs->height;
+	font->max_advance_width = fs->max_advance_width;
+    }
+#endif
+    return font;
+}
+
+int
+_XftFontDebug (void)
+{
+    static int	initialized;
+    static int	debug;
+
+    if (!initialized)
+    {
+	initialized = 1;
+	debug = getenv ("XFT_DEBUG") != 0;
+	if (debug)
+	    printf ("XFT_DEBUG found\n");
+    }
+    return debug;
+}
+
+XftFont *
+XftFontOpen (Display *dpy, int screen, ...)
+{
+    va_list	    va;
+    XftPattern	    *pat;
+    XftPattern	    *match;
+    XftResult	    result;
+    XftFont	    *font;
+
+    va_start (va, screen);
+    pat = XftPatternVaBuild (0, va);
+    va_end (va);
+    if (!pat)
+    {
+	if (_XftFontDebug ())
+	    printf ("XftFontOpen: Invalid pattern argument\n");
+	return 0;
+    }
+    match = XftFontMatch (dpy, screen, pat, &result);
+    if (_XftFontDebug ())
+    {
+	printf ("Pattern ");
+	XftPatternPrint (pat);
+	if (match)
+	{
+	    printf ("Match ");
+	    XftPatternPrint (match);
+	}
+	else
+	    printf ("No Match\n");
+    }
+    XftPatternDestroy (pat);
+    if (!match)
+	return 0;
+    
+    font = XftFontOpenPattern (dpy, match);
+    if (!font)
+    {
+	if (_XftFontDebug ())
+	    printf ("No Font\n");
+	XftPatternDestroy (match);
+    }
+
+    return font;
+}
+
+XftFont *
+XftFontOpenName (Display *dpy, int screen, const char *name)
+{
+    XftPattern	    *pat;
+    XftPattern	    *match;
+    XftResult	    result;
+    XftFont   *font;
+
+    pat = XftNameParse (name);
+    if (_XftFontDebug ())
+    {
+	printf ("XftFontOpenName \"%s\": ", name);
+	if (pat)
+	    XftPatternPrint (pat);
+	else
+	    printf ("Invalid name\n");
+    }
+			     
+    if (!pat)
+	return 0;
+    match = XftFontMatch (dpy, screen, pat, &result);
+    if (_XftFontDebug ())
+    {
+	if (match)
+	{
+	    printf ("Match ");
+	    XftPatternPrint (match);
+	}
+	else
+	    printf ("No Match\n");
+    }
+    XftPatternDestroy (pat);
+    if (!match)
+	return 0;
+    
+    font = XftFontOpenPattern (dpy, match);
+    if (!font)
+	XftPatternDestroy (match);
+    
+    return font;
+}
+
+XftFont *
+XftFontOpenXlfd (Display *dpy, int screen, const char *xlfd)
+{
+    XftPattern	    *pat;
+    XftPattern	    *match;
+    XftResult	    result;
+    XftFont   *font;
+
+    pat = XftXlfdParse (xlfd, False, False);
+    if (_XftFontDebug ())
+    {
+	printf ("XftFontOpenXlfd \"%s\": ", xlfd);
+	if (pat)
+	    printf ("Invalid xlfd\n");
+	else
+	    XftPatternPrint (pat);
+    }
+			     
+    if (!pat)
+	return 0;
+    match = XftFontMatch (dpy, screen, pat, &result);
+    if (_XftFontDebug ())
+    {
+	if (match)
+	{
+	    printf ("Match ");
+	    XftPatternPrint (match);
+	}
+	else
+	    printf ("No Match\n");
+    }
+    XftPatternDestroy (pat);
+    if (!match)
+	return 0;
+    
+    font = XftFontOpenPattern (dpy, match);
+    if (!font)
+	XftPatternDestroy (match);
+    
+    return font;
+}
+
+void
+XftFontClose (Display *dpy, XftFont *font)
+{
+    if (font->core)
+	XFreeFont (dpy, font->u.core.font);
+#ifdef FREETYPE2
+    else
+	XftFreeTypeClose (dpy, font->u.ft.font);
+#endif
+    if (font->pattern)
+	XftPatternDestroy (font->pattern);
+    free (font);
+}
+
+Bool
+XftGlyphExists (Display *dpy, XftFont *font, XftChar32 glyph)
+{
+    if (font->core)
+	return XftCoreGlyphExists (dpy, font->u.core.font, glyph);
+    else
+#ifdef FREETYPE2
+	return XftFreeTypeGlyphExists (dpy, font->u.ft.font, glyph);
+#else
+	return False;
+#endif
+}
Index: xc/lib/Xft/xftfreetype.c
diff -u /dev/null xc/lib/Xft/xftfreetype.c:1.5
--- /dev/null	Mon Dec 18 14:24:39 2000
+++ xc/lib/Xft/xftfreetype.c	Fri Dec 15 12:12:53 2000
@@ -0,0 +1,411 @@
+/*
+ * $XFree86: xc/lib/Xft/xftfreetype.c,v 1.5 2000/12/15 17:12:53 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include "xftint.h"
+
+FT_Library  _XftFTlibrary;
+
+typedef struct _XftFtEncoding {
+    const char	*name;
+    FT_Encoding	encoding;
+} XftFtEncoding;
+
+XftFtEncoding	xftFtEncoding[] = {
+    { "iso10646-1",	    ft_encoding_unicode, },
+    { "iso8859-1",	    ft_encoding_unicode, },
+    { "adobe-fontspecific", ft_encoding_symbol,  },
+    { "glyphs-fontspecific",ft_encoding_none,	 },
+};
+
+#define NUM_FT_ENCODINGS    (sizeof xftFtEncoding / sizeof xftFtEncoding[0])
+
+XftPattern *
+XftFreeTypeQuery (const char *file, int id, int *count)
+{
+    FT_Face	face;
+    XftPattern	*pat;
+    int		slant;
+    int		weight;
+    int		i, j;
+    
+    if (FT_New_Face (_XftFTlibrary, file, id, &face))
+	return 0;
+
+    *count = face->num_faces;
+    
+    pat = XftPatternCreate ();
+    if (!pat)
+	goto bail0;
+
+
+    if (!XftPatternAddBool (pat, XFT_CORE, False))
+	goto bail1;
+    
+    if (!XftPatternAddBool (pat, XFT_OUTLINE,
+			    (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
+	goto bail1;
+    
+    if (!XftPatternAddBool (pat, XFT_SCALABLE,
+			    (face->face_flags & FT_FACE_FLAG_SCALABLE) != 0))
+	goto bail1;
+    
+
+    slant = XFT_SLANT_ROMAN;
+    if (face->style_flags & FT_STYLE_FLAG_ITALIC)
+	slant = (XFT_SLANT_ITALIC + XFT_SLANT_OBLIQUE) / 2;
+
+    if (!XftPatternAddInteger (pat, XFT_SLANT, slant))
+	goto bail1;
+    
+    weight = XFT_WEIGHT_MEDIUM;
+    if (face->style_flags & FT_STYLE_FLAG_BOLD)
+	weight = XFT_WEIGHT_BOLD;
+    
+    if (!XftPatternAddInteger (pat, XFT_WEIGHT, weight))
+	goto bail1;
+    
+    if (!XftPatternAddString (pat, XFT_FAMILY, face->family_name))
+	goto bail1;
+
+    if (!XftPatternAddString (pat, XFT_STYLE, face->style_name))
+	goto bail1;
+
+    if (!XftPatternAddString (pat, XFT_FILE, file))
+	goto bail1;
+
+    if (!XftPatternAddInteger (pat, XFT_INDEX, id))
+	goto bail1;
+    
+    if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
+    {
+	for (i = 0; i < face->num_fixed_sizes; i++)
+	    if (!XftPatternAddDouble (pat, XFT_PIXEL_SIZE,
+				      (double) face->available_sizes[i].height))
+		goto bail1;
+    }
+    
+    for (i = 0; i < face->num_charmaps; i++)
+    {
+#if 0	
+	printf ("face %s encoding %d %c%c%c%c\n",
+		face->family_name, i, 
+		face->charmaps[i]->encoding >> 24,
+		face->charmaps[i]->encoding >> 16,
+		face->charmaps[i]->encoding >> 8,
+		face->charmaps[i]->encoding >> 0);
+#endif
+	for (j = 0; j < NUM_FT_ENCODINGS; j++)
+	{
+	    if (face->charmaps[i]->encoding == xftFtEncoding[j].encoding)
+	    {
+		if (!XftPatternAddString (pat, XFT_ENCODING, 
+					  xftFtEncoding[j].name))
+		    goto bail1;
+	    }
+	}
+    }
+
+    if (!XftPatternAddString (pat, XFT_ENCODING, 
+			      "glyphs-fontspecific"))
+	goto bail1;
+	
+
+    FT_Done_Face (face);
+    return pat;
+    
+bail1:
+    XftPatternDestroy (pat);
+bail0:
+    FT_Done_Face (face);
+    return 0;
+}
+
+XftFontStruct *
+XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
+{
+    char	    *file;
+    int		    id;
+    double	    size;
+    int		    rgba;
+    int		    spacing;
+    int		    char_width;
+    Bool	    antialias;
+    Bool	    encoded;
+    char	    *encoding_name;
+    FT_Face	    face;
+    XftFontStruct   *font;
+    int		    j;
+    FT_Encoding	    encoding;
+    int		    charmap;
+    int		    error;
+
+    int		    height, ascent, descent;
+    int		    extra;
+    int		    div;
+    
+    XRenderPictFormat	pf, *format;
+    
+    if (XftPatternGetString (pattern, XFT_FILE, 0, &file) != XftResultMatch)
+	goto bail0;
+    
+    if (XftPatternGetInteger (pattern, XFT_INDEX, 0, &id) != XftResultMatch)
+	goto bail0;
+    
+    if (XftPatternGetString (pattern, XFT_ENCODING, 0, &encoding_name) != XftResultMatch)
+	goto bail0;
+    
+    if (XftPatternGetDouble (pattern, XFT_PIXEL_SIZE, 0, &size) != XftResultMatch)
+	goto bail0;
+    
+    switch (XftPatternGetInteger (pattern, XFT_RGBA, 0, &rgba)) {
+    case XftResultNoMatch:
+	rgba = XFT_RGBA_NONE;
+	break;
+    case XftResultMatch:
+	break;
+    default:
+	goto bail0;
+    }
+    
+    switch (XftPatternGetBool (pattern, XFT_ANTIALIAS, 0, &antialias)) {
+    case XftResultNoMatch:
+	antialias = True;
+	break;
+    case XftResultMatch:
+	break;
+    default:
+	goto bail0;
+    }
+    
+    if (XftPatternGetInteger (pattern, XFT_CHAR_WIDTH, 
+			      0, &char_width) != XftResultMatch)
+    {
+	char_width = 0;
+    }
+    
+    if (antialias)
+    {
+	if (rgba)
+	{
+	    pf.depth = 32;
+	    pf.type = PictTypeDirect;
+	    pf.direct.alpha = 24;
+	    pf.direct.alphaMask = 0xff;
+	    pf.direct.red = 16;
+	    pf.direct.redMask = 0xff;
+	    pf.direct.green = 8;
+	    pf.direct.greenMask = 0xff;
+	    pf.direct.blue = 0;
+	    pf.direct.blueMask = 0xff;
+	    format = XRenderFindFormat(dpy, 
+				       PictFormatType|
+				       PictFormatDepth|
+				       PictFormatAlpha|
+				       PictFormatAlphaMask|
+				       PictFormatRed|
+				       PictFormatRedMask|
+				       PictFormatGreen|
+				       PictFormatGreenMask|
+				       PictFormatBlue|
+				       PictFormatBlueMask,
+				       &pf, 0);
+	}
+	else
+	{
+	    pf.depth = 8;
+	    pf.type = PictTypeDirect;
+	    pf.direct.alpha = 0;
+	    pf.direct.alphaMask = 0xff;
+	    format = XRenderFindFormat(dpy, 
+				       PictFormatType|
+				       PictFormatDepth|
+				       PictFormatAlpha|
+				       PictFormatAlphaMask,
+				       &pf, 0);
+	}
+    }
+    else
+    {
+	pf.depth = 1;
+	pf.type = PictTypeDirect;
+	pf.direct.alpha = 0;
+	pf.direct.alphaMask = 0x1;
+	format = XRenderFindFormat(dpy, 
+				   PictFormatType|
+				   PictFormatDepth|
+				   PictFormatAlpha|
+				   PictFormatAlphaMask,
+				   &pf, 0);
+    }
+    
+    if (!format)
+	goto bail0;
+    
+    if (FT_New_Face (_XftFTlibrary, file, id, &face))
+	goto bail0;
+
+    font = (XftFontStruct *) malloc (sizeof (XftFontStruct));
+    if (!font)
+	goto bail1;
+    
+    font->size = (FT_F26Dot6) (size * 64.0);
+    
+    if ( FT_Set_Char_Size (face, font->size, font->size, 0, 0) )
+	goto bail2;
+
+    encoding = face->charmaps[0]->encoding;
+    
+    for (j = 0; j < NUM_FT_ENCODINGS; j++)
+	if (!strcmp (encoding_name, xftFtEncoding[j].name))
+	{
+	    encoding = xftFtEncoding[j].encoding;
+	    break;
+	}
+    
+    if (encoding == ft_encoding_none)
+	encoded = False;
+    else
+    {
+	encoded = True;
+	for (charmap = 0; charmap < face->num_charmaps; charmap++)
+	    if (face->charmaps[charmap]->encoding == encoding)
+		break;
+
+	if (charmap == face->num_charmaps)
+	    goto bail2;
+
+	error = FT_Set_Charmap(face,
+			       face->charmaps[charmap]);
+
+	if (error)
+	    goto bail2;
+    }
+    
+    height = face->height;
+    ascent = face->ascender;
+    descent = face->descender;
+    if (descent < 0) descent = - descent;
+    extra = (height - (ascent + descent));
+    if (extra > 0)
+    {
+	ascent = ascent + extra / 2;
+	descent = height - ascent;
+    }
+    else if (extra < 0)
+	height = ascent + descent;
+    div = face->units_per_EM;
+    if (height > div * 5)
+	div *= 10;
+    
+    div = face->units_per_EM;
+    if (height > div * 5)
+	div *= 10;
+    
+    font->descent = descent * font->size / (64 * div);
+    font->ascent = ascent * font->size / (64 * div);
+    font->height = height * font->size / (64 * div);
+    font->max_advance_width = face->max_advance_width * font->size / (64 * div);
+    
+    font->monospace = (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0;
+    if (char_width)
+    {
+	font->max_advance_width = char_width;
+	font->monospace = True;
+    }
+    switch (XftPatternGetInteger (pattern, XFT_SPACING, 0, &spacing)) {
+    case XftResultNoMatch:
+	break;
+    case XftResultMatch:
+	if (spacing != XFT_PROPORTIONAL)
+	    font->monospace = True;
+	break;
+    default:
+	goto bail2;
+    }
+    
+    font->glyphset = XRenderCreateGlyphSet (dpy, format);
+
+    font->format = format;
+    font->realized =0;
+    font->nrealized = 0;
+    font->rgba = rgba;
+    font->antialias = antialias;
+    font->encoded = encoded;
+    font->face = face;
+
+    return font;
+    
+bail2:
+    free (font);
+bail1:
+    FT_Done_Face (font->face);
+bail0:
+    return 0;
+}
+
+void
+XftFreeTypeClose (Display *dpy, XftFontStruct *font)
+{
+    XRenderFreeGlyphSet (dpy, font->glyphset);
+    if (font->realized)
+	free (font->realized);
+    FT_Done_Face (font->face);
+}
+		  
+XftFontStruct *
+XftFreeTypeGet (XftFont *font)
+{
+    if (font->core)
+	return 0;
+    return font->u.ft.font;
+}
+
+/* #define XFT_DEBUG_FONTSET */
+
+Bool
+XftInitFtLibrary (void)
+{
+    char    **d;
+    
+    if (_XftFTlibrary)
+	return True;
+    if (FT_Init_FreeType (&_XftFTlibrary))
+	return False;
+    _XftFontSet = XftFontSetCreate ();
+    if (!_XftFontSet)
+	return False;
+    for (d = XftConfigDirs; d && *d; d++)
+    {
+#ifdef XFT_DEBUG_FONTSET
+	printf ("scan dir %s\n", *d);
+#endif
+	XftDirScan (_XftFontSet, *d);
+    }
+#ifdef XFT_DEBUG_FONTSET
+    XftPrintFontSet (_XftFontSet);
+#endif
+    return True;
+}
+
Index: xc/lib/Xft/xftfs.c
diff -u /dev/null xc/lib/Xft/xftfs.c:1.1
--- /dev/null	Mon Dec 18 14:24:39 2000
+++ xc/lib/Xft/xftfs.c	Wed Nov 29 03:39:22 2000
@@ -0,0 +1,74 @@
+/*
+ * $XFree86: xc/lib/Xft/xftfs.c,v 1.1 2000/11/29 08:39:22 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include "xftint.h"
+
+XftFontSet *
+XftFontSetCreate (void)
+{
+    XftFontSet	*s;
+
+    s = (XftFontSet *) malloc (sizeof (XftFontSet));
+    if (!s)
+	return 0;
+    s->nfont = 0;
+    s->sfont = 0;
+    s->fonts = 0;
+    return s;
+}
+
+void
+XftFontSetDestroy (XftFontSet *s)
+{
+    int	    i;
+
+    for (i = 0; i < s->nfont; i++)
+	XftPatternDestroy (s->fonts[i]);
+    if (s->fonts)
+	free (s->fonts);
+    free (s);
+}
+
+Bool
+XftFontSetAdd (XftFontSet *s, XftPattern *font)
+{
+    XftPattern	**f;
+    int		sfont;
+    
+    if (s->nfont == s->sfont)
+    {
+	sfont = s->sfont + 32;
+	if (s->fonts)
+	    f = (XftPattern **) realloc (s->fonts, sfont * sizeof (XftPattern *));
+	else
+	    f = (XftPattern **) malloc (sfont * sizeof (XftPattern *));
+	if (!f)
+	    return False;
+	s->sfont = sfont;
+	s->fonts = f;
+    }
+    s->fonts[s->nfont++] = font;
+    return True;
+}
Index: xc/lib/Xft/xftglyphs.c
diff -u /dev/null xc/lib/Xft/xftglyphs.c:1.6
--- /dev/null	Mon Dec 18 14:24:40 2000
+++ xc/lib/Xft/xftglyphs.c	Fri Dec 15 12:12:53 2000
@@ -0,0 +1,374 @@
+/*
+ * $XFree86: xc/lib/Xft/xftglyphs.c,v 1.6 2000/12/15 17:12:53 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include "xftint.h"
+#include <freetype/ftoutln.h>
+
+static const int    filters[3][3] = {
+    /* red */
+#if 0
+{    65538*4/7,65538*2/7,65538*1/7 },
+    /* green */
+{    65536*1/4, 65536*2/4, 65537*1/4 },
+    /* blue */
+{    65538*1/7,65538*2/7,65538*4/7 },
+#endif
+{    65538*9/13,65538*3/13,65538*1/13 },
+    /* green */
+{    65538*1/6, 65538*4/6, 65538*1/6 },
+    /* blue */
+{    65538*1/13,65538*3/13,65538*9/13 },
+};
+
+#define _UntestedGlyph	((XGlyphInfo *) 1)
+
+void
+XftGlyphLoad (Display		*dpy,
+	      XftFontStruct	*font,
+	      XftChar32		*glyphs,
+	      int		nglyph)
+{
+    FT_Error	    error;
+    FT_ULong	    charcode;
+    FT_UInt	    glyphindex;
+    FT_GlyphSlot    glyph;
+    XGlyphInfo	    *gi;
+    Glyph	    g;
+    unsigned char   bufLocal[4096];
+    unsigned char   *bufBitmap = bufLocal;
+    unsigned char   *b;
+    int		    bufSize = sizeof (bufLocal);
+    int		    size, pitch;
+    unsigned char   bufLocalRgba[4096];
+    unsigned char   *bufBitmapRgba = bufLocalRgba;
+    int		    bufSizeRgba = sizeof (bufLocalRgba);
+    int		    sizergba, pitchrgba, widthrgba;
+    int		    width;
+    int		    height;
+    int		    i;
+    int		    left, right, top, bottom;
+    int		    mul = 1;
+    FT_Bitmap	    ftbit;
+    FT_Matrix	    matrix;
+
+    if (font->antialias && font->rgba)
+    {
+	matrix.xx = 0x30000L;
+	matrix.yy = 0x10000L;
+	matrix.xy = matrix.yx = 0;
+	mul = 3;
+    }
+    while (nglyph--)
+    {
+	charcode = (FT_ULong) *glyphs++;
+	gi = font->realized[charcode];
+	if (!gi)
+	    continue;
+	
+	if (font->encoded)
+	{
+	    glyphindex = FT_Get_Char_Index (font->face, charcode);
+	    if (!glyphindex)
+		continue;
+	}
+	else
+	    glyphindex = (FT_UInt) charcode;
+	error = FT_Load_Glyph (font->face, glyphindex, 0/*|FT_LOAD_NO_HINTING */);
+	if (error)
+	    continue;
+
+#define FLOOR(x)    ((x) & -64)
+#define CEIL(x)	    (((x)+63) & -64)
+#define TRUNC(x)    ((x) >> 6)
+#define ROUND(x)    (((x)+32) & -64)
+		
+	glyph = font->face->glyph;
+	
+	left  = FLOOR( glyph->metrics.horiBearingX );
+	right = CEIL( glyph->metrics.horiBearingX + glyph->metrics.width );
+	width = TRUNC(right - left);
+	/*
+	 * Try to keep monospace fonts ink-inside
+	 */
+	if (font->monospace)
+	{
+	    if (TRUNC(right) > font->max_advance_width)
+	    {
+		int adjust;
+
+		adjust = right - (font->max_advance_width << 6);
+		if (adjust > left)
+		    adjust = left;
+		left -= adjust;
+		right -= adjust;
+		width = font->max_advance_width;
+	    }
+	}
+
+	top    = CEIL( glyph->metrics.horiBearingY );
+	bottom = FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height );
+	height = TRUNC( top - bottom );
+
+	if ( glyph->format == ft_glyph_format_outline )
+	{
+	    if (font->antialias)
+		pitch = (width * mul + 3) & ~3;
+	    else
+		pitch = ((width + 31) & ~31) >> 3;
+	    
+	    size = pitch * height;
+	    
+	    if (size > bufSize)
+	    {
+		if (bufBitmap != bufLocal)
+		    free (bufBitmap);
+		bufBitmap = (unsigned char *) malloc (size);
+		if (!bufBitmap)
+		    continue;
+		bufSize = size;
+	    }
+	    memset (bufBitmap, 0, size);
+
+	    ftbit.width      = width * mul;
+	    ftbit.rows       = height;
+	    ftbit.pitch      = pitch;
+	    if (font->antialias)
+		ftbit.pixel_mode = ft_pixel_mode_grays;
+	    else
+		ftbit.pixel_mode = ft_pixel_mode_mono;
+	    
+	    ftbit.buffer     = bufBitmap;
+	    
+	    if (font->antialias && font->rgba)
+		FT_Outline_Transform (&glyph->outline, &matrix);
+
+	    FT_Outline_Translate ( &glyph->outline, -left*mul, -bottom );
+
+	    FT_Outline_Get_Bitmap( _XftFTlibrary, &glyph->outline, &ftbit );
+	    i = size;
+	    b = (unsigned char *) bufBitmap;
+	    /*
+	     * swap bit order around
+	     */
+	    if (!font->antialias)
+	    {
+		if (BitmapBitOrder (dpy) != MSBFirst)
+		{
+		    unsigned char   *line;
+		    unsigned char   c;
+		    int		    i;
+
+		    line = (unsigned char *) bufBitmap;
+		    i = size;
+		    while (i--)
+		    {
+			c = *line;
+			c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
+			c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
+			c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
+			*line++ = c;
+		    }
+		}
+	    }
+#if 0
+	    {
+		int		x, y;
+		unsigned char	*line;
+
+		line = bufBitmap;
+		printf ("\nchar 0x%x (%c):\n", (int) charcode, (char) charcode);
+		for (y = 0; y < height; y++)
+		{
+		    if (font->antialias) 
+		    {
+			static char    den[] = { " .:;=+*#" };
+			for (x = 0; x < pitch; x++)
+			    printf ("%c", den[line[x] >> 5]);
+		    }
+		    else
+		    {
+			for (x = 0; x < pitch * 8; x++)
+			{
+			    printf ("%c", line[x>>3] & (1 << (x & 7)) ? '#' : ' ');
+			}
+		    }
+		    printf ("\n");
+		    line += pitch;
+		}
+	    }
+#endif
+	}
+	else
+	{
+#if 0
+	    printf ("glyph (%c) %d missing\n", (int) charcode, (int) charcode);
+#endif
+	    continue;
+	}
+	
+	gi->width = width;
+	gi->height = height;
+	gi->x = -TRUNC(left);
+	gi->y = TRUNC(top);
+	if (font->monospace)
+	    gi->xOff = font->max_advance_width;
+	else
+	    gi->xOff = TRUNC(ROUND(glyph->metrics.horiAdvance));
+	gi->yOff = 0;
+	g = charcode;
+
+	if (font->antialias && font->rgba != XFT_RGBA_NONE)
+	{
+	    int		    x, y;
+	    unsigned char   *in_line, *out_line, *in;
+	    unsigned int    *out;
+	    unsigned int    red, green, blue;
+	    int		    rf, gf, bf;
+	    int		    s;
+	    
+	    widthrgba = width;
+	    pitchrgba = (widthrgba * 4 + 3) & ~3;
+	    sizergba = pitchrgba * height;
+
+	    switch (font->rgba) {
+	    case XFT_RGBA_RGB:
+	    default:
+		rf = 0;
+		gf = 1;
+		bf = 2;
+		break;
+	    case XFT_RGBA_BGR:
+		bf = 0;
+		gf = 1;
+		rf = 2;
+		break;
+	    }
+	    if (sizergba > bufSizeRgba)
+	    {
+		if (bufBitmapRgba != bufLocalRgba)
+		    free (bufBitmapRgba);
+		bufBitmapRgba = (unsigned char *) malloc (sizergba);
+		if (!bufBitmapRgba)
+		    continue;
+		bufSizeRgba = sizergba;
+	    }
+	    memset (bufBitmapRgba, 0, sizergba);
+	    in_line = bufBitmap;
+	    out_line = bufBitmapRgba;
+	    for (y = 0; y < height; y++)
+	    {
+		in = in_line;
+		out = (unsigned int *) out_line;
+		in_line += pitch;
+		out_line += pitchrgba;
+		for (x = 0; x < width * mul; x += 3)
+		{
+		    red = green = blue = 0;
+		    for (s = 0; s < 3; s++)
+		    {
+			red += filters[rf][s]*in[x+s];
+			green += filters[gf][s]*in[x+s];
+			blue += filters[bf][s]*in[x+s];
+		    }
+		    red = red / 65536;
+		    green = green / 65536;
+		    blue = blue / 65536;
+		    out[x/3] = (green << 24) | (red << 16) | (green << 8) | blue;
+		}
+	    }
+	    
+	    XRenderAddGlyphs (dpy, font->glyphset, &g, gi, 1, 
+			      (char *) bufBitmapRgba, sizergba);
+	}
+	else
+	{
+	    XRenderAddGlyphs (dpy, font->glyphset, &g, gi, 1, 
+			      (char *) bufBitmap, size);
+	}
+    }
+    if (bufBitmap != bufLocal)
+	free (bufBitmap);
+    if (bufBitmapRgba != bufLocalRgba)
+	free (bufBitmapRgba);
+}
+
+#define STEP	    256
+
+void
+XftGlyphCheck (Display		*dpy,
+	       XftFontStruct	*font,
+	       XftChar32	glyph,
+	       XftChar32	*missing,
+	       int		*nmissing)
+{
+    XGlyphInfo	    **realized;
+    int		    nrealized;
+    int		    n;
+    
+    if (glyph >= font->nrealized)
+    {
+	nrealized = glyph + STEP;
+	
+	if (font->realized)
+	    realized = (XGlyphInfo **) realloc ((void *) font->realized,
+						nrealized * sizeof (XGlyphInfo *));
+	else
+	    realized = (XGlyphInfo **) malloc (nrealized * sizeof (XGlyphInfo *));
+	if (!realized)
+	    return;
+	for (n = font->nrealized; n < nrealized; n++)
+	    realized[n] = _UntestedGlyph;
+	
+	font->realized = realized;
+	font->nrealized = nrealized;
+    }
+    if (font->realized[glyph] == _UntestedGlyph)
+    {
+	if (XftFreeTypeGlyphExists (dpy, font, glyph))
+	{
+	    font->realized[glyph] = (XGlyphInfo *) malloc (sizeof (XGlyphInfo));
+	    n = *nmissing;
+	    missing[n++] = glyph;
+	    if (n == XFT_NMISSING)
+	    {
+		XftGlyphLoad (dpy, font, missing, n);
+		n = 0;
+	    }
+	    *nmissing = n;
+	}
+	else
+	    font->realized[glyph] = 0;
+    }
+}
+
+Bool
+XftFreeTypeGlyphExists (Display		*dpy,
+			XftFontStruct	*font,
+			XftChar32	glyph)
+{
+    if (font->encoded)
+	glyph = (XftChar32) FT_Get_Char_Index (font->face, (FT_ULong) glyph);
+    return glyph && glyph <= font->face->num_glyphs;
+}
Index: xc/lib/Xft/xftgram.y
diff -u /dev/null xc/lib/Xft/xftgram.y:1.2
--- /dev/null	Mon Dec 18 14:24:40 2000
+++ xc/lib/Xft/xftgram.y	Thu Nov 30 18:30:00 2000
@@ -0,0 +1,410 @@
+/*
+ * $XFree86: xc/lib/Xft/xftgram.y,v 1.2 2000/11/30 23:30:00 dawes Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+%{
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "xftint.h"
+
+%}
+
+%union {
+    int		ival;
+    double	dval;
+    char	*sval;
+    XftExpr	*eval;
+    XftPattern	*pval;
+    XftValue	vval;
+    XftEdit	*Eval;
+    XftOp	oval;
+    XftQual	qval;
+    XftTest	*tval;
+}
+
+%token <ival>	INTEGER
+%token <dval>	DOUBLE
+%token <sval>	STRING NAME
+%token <ival>	ANY ALL
+%token <ival>	DIR INCLUDE INCLUDEIF MATCH EDIT TOK_TRUE TOK_FALSE TOK_NIL
+%token <ival>	EQUAL SEMI
+
+%type  <eval>	expr
+%type  <vval>	value
+%type  <sval>	field
+%type  <Eval>	edit
+%type  <Eval>	edits
+%type  <oval>	eqop
+%type  <qval>	qual
+%type  <oval>	compare
+%type  <tval>	tests test
+
+%right <ival>	QUEST COLON
+%left <ival>	OROR
+%left <ival>	ANDAND
+%left <ival>	EQEQ NOTEQ
+%left <ival>	LESS LESSEQ MORE MOREEQ
+%left <ival>	PLUS MINUS
+%left <ival>	TIMES DIVIDE
+%right <ival>	NOT
+
+%%
+configs	:   configs config
+	|
+	;
+config	:   DIR STRING
+		{ XftConfigAddDir ($2); }
+	|   INCLUDE STRING
+		{ XftConfigPushInput ($2, True); }
+	|   INCLUDEIF STRING
+		{ XftConfigPushInput ($2, False); }
+	|   MATCH tests EDIT edits
+		{ XftConfigAddEdit ($2, $4); }
+	;
+tests	:   test tests
+		{ $1->next = $2; $$ = $1; }
+	|
+		{ $$ = 0; }
+	;
+test	:   qual field compare value
+		{ $$ = XftTestCreate ($1, $2, $3, $4); }
+	;
+qual	:   ANY
+	    { $$ = XftQualAny; }
+	|   ALL
+	    { $$ = XftQualAll; }
+	|
+	    { $$ = XftQualAny; }
+	;
+field	:   NAME
+		{ 
+		    $$ = XftConfigSaveField ($1); 
+		}
+	;
+compare	:   EQUAL
+		{ $$ = XftOpEqual; }
+	|   EQEQ
+		{ $$ = XftOpEqual; }
+	|   NOTEQ
+		{ $$ = XftOpNotEqual; }
+	|   LESS
+		{ $$ = XftOpLess; }
+	|   LESSEQ
+		{ $$ = XftOpLessEqual; }
+	|   MORE
+		{ $$ = XftOpMore; }
+	|   MOREEQ
+		{ $$ = XftOpMoreEqual; }
+	;
+value	:   INTEGER
+		{
+		    $$.type = XftTypeInteger;
+		    $$.u.i = $1;
+		}
+	|   DOUBLE		
+		{
+		    $$.type = XftTypeDouble;
+		    $$.u.d = $1;
+		}
+	|   STRING
+		{
+		    $$.type = XftTypeString;
+		    $$.u.s = $1;
+		}
+	|   TOK_TRUE
+		{
+		    $$.type = XftTypeBool;
+		    $$.u.b = True;
+		}
+	|   TOK_FALSE
+		{
+		    $$.type = XftTypeBool;
+		    $$.u.b = False;
+		}
+	|   TOK_NIL
+		{
+		    $$.type = XftTypeVoid;
+		}
+	;
+edits	:   edit edits
+	    { $1->next = $2; $$ = $1; }
+	|
+	    { $$ = 0; }
+	;
+edit	:   field eqop expr SEMI
+	    { $$ = XftEditCreate ($1, $2, $3); }
+	;
+eqop	:   EQUAL
+	    { $$ = XftOpAssign; }
+	|   PLUS EQUAL
+	    { $$ = XftOpPrepend; }
+	|   EQUAL PLUS
+	    { $$ = XftOpAppend; }
+	;
+expr	:   INTEGER
+	    { $$ = XftExprCreateInteger ($1); }
+	|   DOUBLE
+	    { $$ = XftExprCreateDouble ($1); }
+	|   STRING
+	    { $$ = XftExprCreateString ($1); }
+	|   TOK_TRUE
+	    { $$ = XftExprCreateBool (True); }
+	|   TOK_FALSE
+	    { $$ = XftExprCreateBool (False); }
+	|   TOK_NIL
+	    { $$ = XftExprCreateNil (); }
+	|   NAME
+	    { $$ = XftExprCreateField ($1); }
+	|   expr OROR expr
+	    { $$ = XftExprCreateOp ($1, XftOpOr, $3); }
+	|   expr ANDAND expr
+	    { $$ = XftExprCreateOp ($1, XftOpAnd, $3); }
+	|   expr EQEQ expr
+	    { $$ = XftExprCreateOp ($1, XftOpEqual, $3); }
+	|   expr NOTEQ expr
+	    { $$ = XftExprCreateOp ($1, XftOpNotEqual, $3); }
+	|   expr LESS expr
+	    { $$ = XftExprCreateOp ($1, XftOpLess, $3); }
+	|   expr LESSEQ expr
+	    { $$ = XftExprCreateOp ($1, XftOpLessEqual, $3); }
+	|   expr MORE expr
+	    { $$ = XftExprCreateOp ($1, XftOpMore, $3); }
+	|   expr MOREEQ expr
+	    { $$ = XftExprCreateOp ($1, XftOpMoreEqual, $3); }
+	|   expr PLUS expr
+	    { $$ = XftExprCreateOp ($1, XftOpPlus, $3); }
+	|   expr MINUS expr
+	    { $$ = XftExprCreateOp ($1, XftOpMinus, $3); }
+	|   expr TIMES expr
+	    { $$ = XftExprCreateOp ($1, XftOpTimes, $3); }
+	|   expr DIVIDE expr
+	    { $$ = XftExprCreateOp ($1, XftOpDivide, $3); }
+	|   NOT expr
+	    { $$ = XftExprCreateOp ($2, XftOpNot, (XftExpr *) 0); }
+	|   expr QUEST expr COLON expr
+	    { $$ = XftExprCreateOp ($1, XftOpQuest, XftExprCreateOp ($3, XftOpQuest, $5)); }
+	;
+%%
+
+int
+XftConfigwrap (void)
+{
+    return 1;
+}
+
+void
+XftConfigerror (char *fmt, ...)
+{
+    va_list	args;
+
+    fprintf (stderr, "\"%s\": line %d, ", XftConfigFile, XftConfigLineno);
+    va_start (args, fmt);
+    vfprintf (stderr, fmt, args);
+    va_end (args);
+    fprintf (stderr, "\n");
+}
+
+XftTest *
+XftTestCreate (XftQual qual, const char *field, XftOp compare, XftValue value)
+{
+    XftTest	*test = (XftTest *) malloc (sizeof (XftTest));;
+
+    if (test)
+    {
+	test->next = 0;
+	test->qual = qual;
+	test->field = _XftSaveString (field);
+	test->op = compare;
+	if (value.type == XftTypeString)
+	    value.u.s = _XftSaveString (value.u.s);
+	test->value = value;
+    }
+    return test;
+}
+
+XftExpr *
+XftExprCreateInteger (int i)
+{
+    XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+    if (e)
+    {
+	e->op = XftOpInteger;
+	e->u.ival = i;
+    }
+    return e;
+}
+
+XftExpr *
+XftExprCreateDouble (double d)
+{
+    XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+    if (e)
+    {
+	e->op = XftOpDouble;
+	e->u.dval = d;
+    }
+    return e;
+}
+
+XftExpr *
+XftExprCreateString (const char *s)
+{
+    XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+    if (e)
+    {
+	e->op = XftOpString;
+	e->u.sval = _XftSaveString (s);
+    }
+    return e;
+}
+
+XftExpr *
+XftExprCreateBool (Bool b)
+{
+    XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+    if (e)
+    {
+	e->op = XftOpBool;
+	e->u.bval = b;
+    }
+    return e;
+}
+
+XftExpr *
+XftExprCreateNil (void)
+{
+    XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+    if (e)
+    {
+	e->op = XftOpNil;
+    }
+    return e;
+}
+
+XftExpr *
+XftExprCreateField (const char *field)
+{
+    XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+    if (e)
+    {
+	e->op = XftOpField;
+	e->u.field = _XftSaveString (field);
+    }
+    return e;
+}
+
+XftExpr *
+XftExprCreateOp (XftExpr *left, XftOp op, XftExpr *right)
+{
+    XftExpr *e = (XftExpr *) malloc (sizeof (XftExpr));
+
+    if (e)
+    {
+	e->op = op;
+	e->u.tree.left = left;
+	e->u.tree.right = right;
+    }
+    return e;
+}
+
+void
+XftExprDestroy (XftExpr *e)
+{
+    switch (e->op) {
+    case XftOpInteger:
+	break;
+    case XftOpDouble:
+	break;
+    case XftOpString:
+	free (e->u.sval);
+	break;
+    case XftOpBool:
+	break;
+    case XftOpField:
+	free (e->u.field);
+	break;
+    case XftOpAssign:
+    case XftOpPrepend:
+    case XftOpAppend:
+	break;
+    case XftOpOr:
+    case XftOpAnd:
+    case XftOpEqual:
+    case XftOpNotEqual:
+    case XftOpLess:
+    case XftOpLessEqual:
+    case XftOpMore:
+    case XftOpMoreEqual:
+    case XftOpPlus:
+    case XftOpMinus:
+    case XftOpTimes:
+    case XftOpDivide:
+    case XftOpQuest:
+	XftExprDestroy (e->u.tree.right);
+	/* fall through */
+    case XftOpNot:
+	XftExprDestroy (e->u.tree.left);
+	break;
+    case XftOpNil:
+	break;
+    }
+    free (e);
+}
+
+XftEdit *
+XftEditCreate (const char *field, XftOp op, XftExpr *expr)
+{
+    XftEdit *e = (XftEdit *) malloc (sizeof (XftEdit));
+
+    if (e)
+    {
+	e->next = 0;
+	e->field = _XftSaveString (field);
+	e->op = op;
+	e->expr = expr;
+    }
+    return e;
+}
+
+void
+XftEditDestroy (XftEdit *e)
+{
+    if (e->next)
+	XftEditDestroy (e->next);
+    free ((void *) e->field);
+    if (e->expr)
+	XftExprDestroy (e->expr);
+}
+
+char *
+XftConfigSaveField (const char *field)
+{
+    return _XftSaveString (field);
+}
Index: xc/lib/Xft/xftinit.c
diff -u /dev/null xc/lib/Xft/xftinit.c:1.2
--- /dev/null	Mon Dec 18 14:24:41 2000
+++ xc/lib/Xft/xftinit.c	Fri Dec 15 12:12:53 2000
@@ -0,0 +1,48 @@
+/*
+ * $XFree86: xc/lib/Xft/xftinit.c,v 1.2 2000/12/15 17:12:53 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include "xftint.h"
+
+XftFontSet  *_XftFontSet;
+Bool	    _XftConfigInitialized;
+
+Bool
+XftInit (char *config)
+{
+    if (_XftConfigInitialized)
+	return True;
+    _XftConfigInitialized = True;
+    if (!config)
+    {
+	config = getenv ("XFT_CONFIG");
+	if (!config)
+	    config = XFT_DEFAULT_PATH;
+    }
+    if (XftConfigLexFile (config))
+    {
+	XftConfigparse ();
+    }
+    return True;
+}
Index: xc/lib/Xft/xftint.h
diff -u /dev/null xc/lib/Xft/xftint.h:1.15
--- /dev/null	Mon Dec 18 14:24:42 2000
+++ xc/lib/Xft/xftint.h	Fri Dec 15 12:12:53 2000
@@ -0,0 +1,430 @@
+/*
+ * $XFree86: xc/lib/Xft/xftint.h,v 1.15 2000/12/15 17:12:53 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _XFTINT_H_
+#define _XFTINT_H_
+
+#include <X11/Xlib.h>
+#ifdef FREETYPE2
+#include "XftFreetype.h"
+#else
+#include "Xft.h"
+#endif
+
+typedef struct _XftMatcher {
+    char    *object;
+    double  (*compare) (char *object, XftValue value1, XftValue value2);
+} XftMatcher;
+
+typedef struct _XftSymbolic {
+    const char	*name;
+    int		value;
+} XftSymbolic;
+
+struct _XftDraw {
+    Display	    *dpy;
+    Drawable	    drawable;
+    Visual	    *visual;	/* NULL for bitmaps */
+    Colormap	    colormap;
+    Region	    clip;
+    Bool	    core_set;
+    Bool	    render_set;
+    Bool	    render_able;
+    struct {
+	Picture		pict;
+	Pixmap		fg_pix;
+	Picture		fg_pict;
+	XRenderColor	fg_color;
+    } render;
+    struct {
+	GC		draw_gc;
+	unsigned long	fg;
+	Font		font;
+    } core;
+};
+
+typedef struct _XftDisplayInfo {
+    struct _XftDisplayInfo  *next;
+    Display		    *display;
+    XExtCodes		    *codes;
+    XftPattern		    *defaults;
+    XftFontSet		    *coreFonts;
+    Bool		    hasRender;
+} XftDisplayInfo;
+
+extern XftFontSet	*_XftGlobalFontSet;
+extern XftDisplayInfo	*_XftDisplayInfo;
+extern char		**XftConfigDirs;
+extern XftFontSet	*_XftFontSet;
+
+#define XFT_NMISSING	256
+
+#ifndef XFT_DEFAULT_PATH
+#define XFT_DEFAULT_PATH "/usr/X11R6/lib/X11/XftConfig"
+#endif
+
+typedef enum _XftOp {
+    XftOpInteger, XftOpDouble, XftOpString, XftOpBool, XftOpNil,
+    XftOpField,
+    XftOpAssign, XftOpPrepend, XftOpAppend,
+    XftOpQuest,
+    XftOpOr, XftOpAnd, XftOpEqual, XftOpNotEqual,
+    XftOpLess, XftOpLessEqual, XftOpMore, XftOpMoreEqual,
+    XftOpPlus, XftOpMinus, XftOpTimes, XftOpDivide,
+    XftOpNot
+} XftOp;
+
+typedef struct _XftExpr {
+    XftOp   op;
+    union {
+	int	ival;
+	double	dval;
+	char	*sval;
+	Bool	bval;
+	char	*field;
+	struct {
+	    struct _XftExpr *left, *right;
+	} tree;
+    } u;
+} XftExpr;
+
+typedef enum _XftQual {
+    XftQualAny, XftQualAll
+} XftQual;
+
+typedef struct _XftTest {
+    struct _XftTest	*next;
+    XftQual		qual;
+    char		*field;
+    XftOp		op;
+    XftValue		value;
+} XftTest;
+
+typedef struct _XftEdit {
+    struct _XftEdit *next;
+    const char	    *field;
+    XftOp	    op;
+    XftExpr	    *expr;
+} XftEdit;
+
+typedef struct _XftSubst {
+    struct _XftSubst	*next;
+    XftTest		*test;
+    XftEdit		*edit;
+} XftSubst;
+
+/*
+ * I tried this with functions that took va_list* arguments
+ * but portability concerns made me change these functions
+ * into macros (sigh).
+ */
+
+#define _XftPatternVapBuild(result, orig, va)			    \
+{								    \
+    XftPattern	*__p__ = (orig);				    \
+    const char	*__o__;						    \
+    XftValue	__v__;						    \
+								    \
+    if (!__p__)							    \
+    {								    \
+	__p__ = XftPatternCreate ();				    \
+	if (!__p__)		    				    \
+	    goto _XftPatternVapBuild_bail0;			    \
+    }				    				    \
+    for (;;)			    				    \
+    {				    				    \
+	__o__ = va_arg (va, const char *);			    \
+	if (!__o__)		    				    \
+	    break;		    				    \
+	__v__.type = va_arg (va, XftType);			    \
+	switch (__v__.type) {	    				    \
+	case XftTypeVoid:					    \
+	    goto _XftPatternVapBuild_bail1;       		    \
+	case XftTypeInteger:	    				    \
+	    __v__.u.i = va_arg (va, int);			    \
+	    break;						    \
+	case XftTypeDouble:					    \
+	    __v__.u.d = va_arg (va, double);			    \
+	    break;						    \
+	case XftTypeString:					    \
+	    __v__.u.s = va_arg (va, char *);			    \
+	    break;						    \
+	case XftTypeBool:					    \
+	    __v__.u.b = va_arg (va, Bool);			    \
+	    break;						    \
+	}							    \
+	if (!XftPatternAdd (__p__, __o__, __v__, True))		    \
+	    goto _XftPatternVapBuild_bail1;			    \
+    }								    \
+    result = __p__;						    \
+    goto _XftPatternVapBuild_return;				    \
+								    \
+_XftPatternVapBuild_bail1:					    \
+    if (!orig)							    \
+	XftPatternDestroy (__p__);				    \
+_XftPatternVapBuild_bail0:					    \
+    result = 0;							    \
+								    \
+_XftPatternVapBuild_return:					    \
+    ;								    \
+}
+
+
+/* xftcfg.c */
+Bool
+XftConfigAddDir (char *d);
+
+Bool
+XftConfigAddEdit (XftTest *test, XftEdit *edit);
+
+Bool
+_XftConfigCompareValue (XftValue    m,
+			XftOp	    op,
+			XftValue    v);
+
+/* xftcore.c */
+
+#define XFT_CORE_N16LOCAL	256
+
+XChar2b *
+XftCoreConvert16 (XftChar16	    *string,
+		  int		    len,
+		  XChar2b	    xcloc[XFT_CORE_N16LOCAL]);
+
+XChar2b *
+XftCoreConvert32 (unsigned int	    *string,
+		  int		    len,
+		  XChar2b	    xcloc[XFT_CORE_N16LOCAL]);
+
+void
+XftCoreExtents8 (Display	*dpy,
+		 XFontStruct	*fs,
+		 XftChar8	*string, 
+		 int		len,
+		 XGlyphInfo	*extents);
+
+void
+XftCoreExtents16 (Display	    *dpy,
+		  XFontStruct	    *fs,
+		  XftChar16	    *string, 
+		  int		    len,
+		  XGlyphInfo	    *extents);
+
+void
+XftCoreExtents32 (Display	    *dpy,
+		  XFontStruct	    *fs,
+		  unsigned int	    *string, 
+		  int		    len,
+		  XGlyphInfo	    *extents);
+
+Bool
+XftCoreGlyphExists (Display	    *dpy,
+		    XFontStruct	    *fs,
+		    unsigned int    glyph);
+
+/* xftdbg.c */
+void
+XftOpPrint (XftOp op);
+
+void
+XftTestPrint (XftTest *test);
+
+void
+XftExprPrint (XftExpr *expr);
+
+void
+XftEditPrint (XftEdit *edit);
+
+void
+XftSubstPrint (XftSubst *subst);
+
+/* xftdir.c */
+Bool
+XftDirScan (XftFontSet *set, const char *dir);
+
+/* xftdpy.c */
+int
+XftDefaultParseBool (char *v);
+
+Bool
+XftDefaultGetBool (Display *dpy, const char *object, int screen, Bool def);
+
+int
+XftDefaultGetInteger (Display *dpy, const char *object, int screen, int def);
+
+double
+XftDefaultGetDouble (Display *dpy, const char *object, int screen, double def);
+
+XftFontSet *
+XftDisplayGetFontSet (Display *dpy);
+
+/* xftdraw.c */
+Bool
+XftDrawRenderPrepare (XftDraw	*draw,
+		      XftColor	*color,
+		      XftFont	*font);
+
+Bool
+XftDrawCorePrepare (XftDraw	*draw,
+		    XftColor	*color,
+		    XftFont	*font);
+
+/* xftextent.c */
+/* xftfont.c */
+int
+_XftFontDebug (void);
+    
+/* xftfreetype.c */
+XftPattern *
+XftFreeTypeQuery (const char *file, int id, int *count);
+
+/* xftfs.c */
+/* xftglyphs.c */
+/* xftgram.y */
+int
+XftConfigparse (void);
+
+int
+XftConfigwrap (void);
+    
+void
+XftConfigerror (char *fmt, ...);
+    
+char *
+XftConfigSaveField (const char *field);
+
+XftTest *
+XftTestCreate (XftQual qual, const char *field, XftOp compare, XftValue value);
+
+XftExpr *
+XftExprCreateInteger (int i);
+
+XftExpr *
+XftExprCreateDouble (double d);
+
+XftExpr *
+XftExprCreateString (const char *s);
+
+XftExpr *
+XftExprCreateBool (Bool b);
+
+XftExpr *
+XftExprCreateNil (void);
+
+XftExpr *
+XftExprCreateField (const char *field);
+
+XftExpr *
+XftExprCreateOp (XftExpr *left, XftOp op, XftExpr *right);
+
+void
+XftExprDestroy (XftExpr *e);
+
+XftEdit *
+XftEditCreate (const char *field, XftOp op, XftExpr *expr);
+
+void
+XftEditDestroy (XftEdit *e);
+
+/* xftinit.c */
+Bool
+XftInitFtLibrary (void);
+
+/* xftlex.l */
+extern int	XftConfigLineno;
+extern char	*XftConfigFile;
+
+int
+XftConfiglex (void);
+
+Bool
+XftConfigLexFile(char *s);
+
+Bool
+XftConfigPushInput (char *s, Bool complain);
+
+/* xftlist.c */
+XftObjectSet *
+_XftObjectSetVapBuild (const char *first, va_list *vap);
+
+Bool
+XftListValueCompare (XftValue	v1,
+		     XftValue	v2);
+
+Bool
+XftListValueListCompare (XftValueList	*v1orig,
+			 XftValueList	*v2orig,
+			 XftQual	qual);
+
+Bool
+XftListMatch (XftPattern    *p,
+	      XftPattern    *font,
+	      XftQual	    qual);
+
+Bool
+XftListAppend (XftFontSet   *s,
+	       XftPattern   *font,
+	       XftObjectSet *os);
+
+
+/* xftmatch.c */
+
+/* xftname.c */
+Bool
+XftNameConstant (char *string, int *result);
+
+/* xftpat.c */
+
+/* xftrender.c */
+
+/* xftstr.c */
+char *
+_XftSaveString (const char *s);
+
+const char *
+_XftGetInt(const char *ptr, int *val);
+
+char *
+_XftSplitStr (const char *field, char *save);
+
+char *
+_XftDownStr (const char *field, char *save);
+
+const char *
+_XftSplitField (const char *field, char *save);
+
+const char *
+_XftSplitValue (const char *field, char *save);
+
+int
+_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def);
+
+int
+_XftStrCmpIgnoreCase (const char *s1, const char *s2);
+    
+/* xftxlfd.c */
+Bool
+XftCoreAddFonts (XftFontSet *set, Display *dpy, Bool ignore_scalable);
+
+#endif /* _XFT_INT_H_ */
Index: xc/lib/Xft/xftlex.l
diff -u /dev/null xc/lib/Xft/xftlex.l:1.3
--- /dev/null	Mon Dec 18 14:24:43 2000
+++ xc/lib/Xft/xftlex.l	Fri Dec 15 17:48:39 2000
@@ -0,0 +1,258 @@
+%{
+/*
+ * $XFree86: xc/lib/Xft/xftlex.l,v 1.3 2000/12/15 22:48:39 dawes Exp $
+ *
+ * Copyright (c) 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <string.h>
+#include "xftint.h"
+
+#include "xftgram.h"
+
+int	    XftConfigLineno;
+
+static void _XftConfigSkipComment (void);
+
+static void _XftConfigSkipLine (void);
+    
+static int _XftConfigPopInput (void);
+    
+    
+#define		XFT_CONFIG_IN_DEEP	20
+FILE	*XftConfigInStack[XFT_CONFIG_IN_DEEP];
+FILE	**XftConfigInpt = XftConfigInStack + XFT_CONFIG_IN_DEEP;
+FILE	*XftConfigInput;
+int	XftConfigLinenos[XFT_CONFIG_IN_DEEP];
+int 	*XftConfigLinenopt = XftConfigLinenos + XFT_CONFIG_IN_DEEP;
+char	*XftConfigFile = "";
+char	*XftConfigFileNames[XFT_CONFIG_IN_DEEP];
+char	**XftConfigFileNamePt = XftConfigFileNames + XFT_CONFIG_IN_DEEP;
+int	XftConfigFiledeep = 0;
+
+#undef YY_INPUT
+
+#define YY_INPUT(buf,result,max_size) \
+{ \
+    int c; \
+    result = 0; \
+    while (result < max_size) { \
+	c = getc (XftConfigInput); \
+	if (c < 0) { \
+	    c = _XftConfigPopInput (); \
+	    if (c < 0) \
+		break; \
+	} \
+	buf[result++] = c; \
+	if (c == '\n') \
+	{ \
+	    XftConfigLineno++; \
+	    break; \
+	} \
+    } \
+}
+    
+#ifndef FLEX_SCANNER
+#undef		input
+#undef		unput
+static int input (void)
+{
+    char    buf[1];
+    int	    r;
+
+    YY_INPUT(buf, r, 1);
+    if (r == 0)
+	return 0;
+    return buf[0];
+}
+
+static void unput (char c)
+{
+    if (c == '\n')
+	XftConfigLineno--;
+    ungetc (c, XftConfigInput);
+}
+#endif
+
+%}
+%%
+"/\052"		_XftConfigSkipComment();
+^#		_XftConfigSkipLine();
+dir		return DIR;
+include		return INCLUDE;
+includeif	return INCLUDEIF;
+match		return MATCH;
+edit		return EDIT;
+true		return TOK_TRUE;
+false		return TOK_FALSE;
+nil		return TOK_NIL;
+any		return ANY;
+all		return ALL;
+"="		return EQUAL;
+":"		return COLON;
+";"		return SEMI;
+"+"		return PLUS;
+"-"		return MINUS;
+"*"		return TIMES;
+"/"		return DIVIDE;
+"!"		return NOT;
+"&&"		return ANDAND;
+"||"		return OROR;
+"<"		return LESS;
+"<="		return LESSEQ;
+"=="		return EQEQ;
+">="		return MOREEQ;
+">"		return MORE;
+"!="		return NOTEQ;
+"?"		return QUEST;
+\"([^\n\"]|\\\")*\"	{
+    			yytext[yyleng - 1] = '\0';
+			yylval.sval = yytext+1;
+			return STRING;
+		}
+[0-9]+		{
+		yylval.ival = strtol (yytext, 0, 10);
+		return INTEGER;
+		}
+(([0-9]+((\.[0-9]*(\{[0-9]+\})?)?))|(\.[0-9]+)|(\.[0-9]*\{[0-9]+\}))(([Ee][-+]?[0-9]+)?) {
+		yylval.dval = strtod (yytext, 0);
+		return DOUBLE;
+		}
+[a-zA-Z][0-9a-zA-Z_]* {
+		if (XftNameConstant (yytext, &yylval.ival))
+		    return INTEGER;
+		yylval.sval = yytext;
+		return NAME;
+		}
+.		;
+"\n"		;
+%%
+static void
+_XftConfigSkipComment (void)
+{
+    int	c;
+
+    c = input();
+    for (;;) {
+	while (c != EOF && c != '*')
+	    c = input();
+	if (c == EOF)
+	    return;
+	c = input();
+	if (c == EOF || c == '/')
+	    return;
+    }
+}
+
+static void
+_XftConfigSkipLine (void)
+{
+    int	    c;
+
+    do {
+	c = input();
+    } while (c != EOF && c != '\n');
+}
+
+Bool
+XftConfigLexFile(char *s)
+{
+    FILE    *f;
+    
+    f = fopen (s, "r");
+    if (f == 0) 
+    {
+	fprintf (stderr, "cannot open file \"%s\"\n", s);
+	return False;
+    }
+    ++XftConfigFiledeep;
+    XftConfigInput = f;
+    XftConfigFile = s;
+    return True;
+}
+	
+Bool
+XftConfigPushInput (char *s, Bool complain)
+{
+    FILE	*f;
+    char	*t;
+    char	*h;
+
+    if (XftConfigInpt == XftConfigInStack) 
+    {
+	(void) fprintf (stderr, "files nested too deeply\n");
+	return False;
+    }
+    t = s;
+    if (*s == '~')
+    {
+	h = getenv ("HOME");
+	if (h)
+	{
+	    t = (char *) malloc (strlen (h) + strlen (s));
+	    if (t)
+	    {
+		strcpy (t, h);
+		strcat (t, s+1);
+	    }
+	    else
+		t = s;
+	}
+    }
+    f = fopen (t, "r");
+    if (t != s)
+	free (t);
+    if (f == 0) 
+    {
+	if (complain)
+	    (void) fprintf (stderr, "cannot open file %s\n", s);
+	return False;
+    }
+    ++XftConfigFiledeep;
+    *--XftConfigInpt = XftConfigInput;
+    *--XftConfigLinenopt = XftConfigLineno;
+    *--XftConfigFileNamePt = XftConfigFile;
+    XftConfigInput = f;
+    XftConfigLineno = 1;
+    XftConfigFile = _XftSaveString (s);
+    return True;
+}
+
+static int
+_XftConfigPopInput (void)
+{
+    int	    c;
+
+    for (;;)
+    {
+	c = getc (XftConfigInput);
+	if (c >= 0)
+	    return c;
+	fclose (XftConfigInput);
+	if (XftConfigInpt == XftConfigInStack + XFT_CONFIG_IN_DEEP)
+	    return EOF;
+	XftConfigInput = *XftConfigInpt++;
+	XftConfigLineno = *XftConfigLinenopt++;
+	free (XftConfigFile);
+	XftConfigFile = *XftConfigFileNamePt++;
+	--XftConfigFiledeep;
+    }
+}
Index: xc/lib/Xft/xftlist.c
diff -u /dev/null xc/lib/Xft/xftlist.c:1.2
--- /dev/null	Mon Dec 18 14:24:43 2000
+++ xc/lib/Xft/xftlist.c	Thu Dec  7 18:57:28 2000
@@ -0,0 +1,328 @@
+/*
+ * $XFree86: xc/lib/Xft/xftlist.c,v 1.2 2000/12/07 23:57:28 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include "xftint.h"
+
+XftObjectSet *
+XftObjectSetCreate (void)
+{
+    XftObjectSet    *os;
+
+    os = (XftObjectSet *) malloc (sizeof (XftObjectSet));
+    if (!os)
+	return 0;
+    os->nobject = 0;
+    os->sobject = 0;
+    os->objects = 0;
+    return os;
+}
+
+Bool
+XftObjectSetAdd (XftObjectSet *os, const char *object)
+{
+    int		s;
+    const char	**objects;
+    
+    if (os->nobject == os->sobject)
+    {
+	s = os->sobject + 4;
+	if (os->objects)
+	    objects = (const char **) realloc ((void *) os->objects,
+					       s * sizeof (const char **));
+	else
+	    objects = (const char **) malloc (s * sizeof (const char **));
+	if (!objects)
+	    return False;
+	os->objects = objects;
+	os->sobject = s;
+    }
+    os->objects[os->nobject++] = object;
+    return True;
+}
+
+void
+XftObjectSetDestroy (XftObjectSet *os)
+{
+    if (os->objects)
+	free ((void *) os->objects);
+    free (os);
+}
+
+#define _XftObjectSetVapBuild(__ret__, __first__, __va__) 		\
+{									\
+    XftObjectSet    *__os__;						\
+    const char	    *__ob__;						\
+									\
+    __ret__ = 0;						    	\
+    __os__ = XftObjectSetCreate ();					\
+    if (!__os__)							\
+	goto _XftObjectSetVapBuild_bail0;				\
+    __ob__ = __first__;							\
+    while (__ob__)							\
+    {									\
+	if (!XftObjectSetAdd (__os__, __ob__))				\
+	    goto _XftObjectSetVapBuild_bail1;				\
+	__ob__ = va_arg (__va__, const char *);				\
+    }									\
+    __ret__ = __os__;							\
+									\
+_XftObjectSetVapBuild_bail1:						\
+    if (!__ret__ && __os__)					    	\
+	XftObjectSetDestroy (__os__);					\
+_XftObjectSetVapBuild_bail0:						\
+    ;									\
+}
+
+XftObjectSet *
+XftObjectSetVaBuild (const char *first, va_list va)
+{
+    XftObjectSet    *ret;
+
+    _XftObjectSetVapBuild (ret, first, va);
+    return ret;
+}
+
+XftObjectSet *
+XftObjectSetBuild (const char *first, ...)
+{
+    va_list	    va;
+    XftObjectSet    *os;
+
+    va_start (va, first);
+    _XftObjectSetVapBuild (os, first, va);
+    va_end (va);
+    return os;
+}
+
+Bool
+XftListValueCompare (XftValue	v1,
+		     XftValue	v2)
+{
+    return _XftConfigCompareValue (v1, XftOpEqual, v2);
+}
+
+Bool
+XftListValueListCompare (XftValueList	*v1orig,
+			 XftValueList	*v2orig,
+			 XftQual	qual)
+{
+    XftValueList    *v1, *v2;
+
+    for (v1 = v1orig; v1; v1 = v1->next)
+    {
+	for (v2 = v2orig; v2; v2 = v2->next)
+	{
+	    if (_XftConfigCompareValue (v1->value, XftOpEqual, v2->value))
+	    {
+		if (qual == XftQualAny)
+		    return True;
+		else
+		    break;
+	    }
+	}
+	if (qual == XftQualAll)
+	{
+	    if (!v2)
+		return False;
+	}
+    }
+    if (qual == XftQualAll)
+	return True;
+    else
+	return False;
+}
+
+/*
+ * True iff all objects in "p" match "font"
+ */
+Bool
+XftListMatch (XftPattern    *p,
+	      XftPattern    *font,
+	      XftQual	    qual)
+{
+    int		    i;
+    XftPatternElt   *e;
+
+    for (i = 0; i < p->num; i++)
+    {
+	e = XftPatternFind (font, p->elts[i].object, False);
+	if (!e)
+	{
+	    if (qual == XftQualAll)
+		continue;
+	    else
+		return False;
+	}
+	if (!XftListValueListCompare (p->elts[i].values, e->values, qual))
+	    return False;
+    }
+    return True;
+}
+
+Bool
+XftListAppend (XftFontSet   *s,
+	       XftPattern   *font,
+	       XftObjectSet *os)
+{
+    int		    f;
+    int		    o;
+    XftPattern	    *l;
+    XftPatternElt   *e;
+    XftValueList    *v;
+
+    for (f = 0; f < s->nfont; f++)
+    {
+	l = s->fonts[f];
+	if (XftListMatch (l, font, XftQualAll))
+	    return True;
+    }
+    l = XftPatternCreate ();
+    if (!l)
+	goto bail0;
+    for (o = 0; o < os->nobject; o++)
+    {
+	e = XftPatternFind (font, os->objects[o], False);
+	if (e)
+	{
+	    for (v = e->values; v; v = v->next)
+	    {
+		if (!XftPatternAdd (l, os->objects[o], v->value, True))
+		    goto bail1;
+	    }
+	}
+    }
+    if (!XftFontSetAdd (s, l))
+	goto bail1;
+    return True;
+bail1:
+    XftPatternDestroy (l);
+bail0:
+    return False;
+}
+
+XftFontSet *
+XftListFontSets (XftFontSet	**sets,
+		 int		nsets,
+		 XftPattern	*p,
+		 XftObjectSet	*os)
+{
+    XftFontSet	*ret;
+    XftFontSet	*s;
+    int		f;
+    int		set;
+
+    ret = XftFontSetCreate ();
+    if (!ret)
+	goto bail0;
+    for (set = 0; set < nsets; set++)
+    {
+	s = sets[set];
+	for (f = 0; f < s->nfont; f++)
+	{
+	    if (XftListMatch (p, s->fonts[f], XftQualAny))
+	    {
+		if (!XftListAppend (ret, s->fonts[f], os))
+		    goto bail1;
+	    }
+	}
+    }
+    return ret;
+bail1:
+    XftFontSetDestroy (ret);
+bail0:
+    return 0;
+}
+
+XftFontSet *
+XftListFontsPatternObjects (Display	    *dpy,
+			    int		    screen,
+			    XftPattern	    *pattern,
+			    XftObjectSet    *os)
+{
+    XftFontSet	*sets[2];
+    int		nsets = 0;
+#ifdef FREETYPE2
+    Bool	core, render;
+    XftResult	result;
+#endif
+
+    if (!XftInit (0))
+	return 0;
+
+#ifdef FREETYPE2
+    render = core = False;
+    result = XftPatternGetBool (pattern, XFT_CORE, 0, &core);
+    if (result != XftResultMatch)
+	core = XftDefaultGetBool (dpy, XFT_CORE, screen,
+				  !XftDefaultHasRender (dpy));
+
+    result = XftPatternGetBool (pattern, XFT_RENDER, 0, &render);
+    if (result != XftResultMatch)
+	render = XftDefaultGetBool (dpy, XFT_RENDER, screen,
+				    XftDefaultHasRender (dpy));
+    if (render)
+    {
+	if (XftInitFtLibrary ())
+	{
+	    sets[nsets] = _XftFontSet;
+	    if (sets[nsets])
+		nsets++;
+	}
+    }
+    if (core)
+#endif
+    {
+	sets[nsets] = XftDisplayGetFontSet (dpy);
+	if (sets[nsets])
+	    nsets++;
+    }
+    return XftListFontSets (sets, nsets, pattern, os);
+}
+
+XftFontSet *
+XftListFonts (Display	*dpy,
+	      int	screen,
+	      ...)
+{
+    va_list	    va;
+    XftFontSet	    *fs;
+    XftObjectSet    *os;
+    XftPattern	    *pattern;
+    const char	    *first;
+
+    va_start (va, screen);
+    
+    _XftPatternVapBuild (pattern, 0, va);
+    
+    first = va_arg (va, const char *);
+    _XftObjectSetVapBuild (os, first, va);
+    
+    va_end (va);
+    
+    fs = XftListFontsPatternObjects (dpy, screen, pattern, os);
+    XftPatternDestroy (pattern);
+    XftObjectSetDestroy (os);
+    return fs;
+}
Index: xc/lib/Xft/xftmatch.c
diff -u /dev/null xc/lib/Xft/xftmatch.c:1.3
--- /dev/null	Mon Dec 18 14:24:44 2000
+++ xc/lib/Xft/xftmatch.c	Thu Dec 14 18:03:55 2000
@@ -0,0 +1,305 @@
+/*
+ * $XFree86: xc/lib/Xft/xftmatch.c,v 1.3 2000/12/14 23:03:55 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <string.h>
+#include <ctype.h>
+#include "xftint.h"
+#include <stdio.h>
+
+/* #define XFT_DEBUG_MATCH */
+
+static double
+_XftCompareInteger (char *object, XftValue value1, XftValue value2)
+{
+    int	v;
+    
+    if (value2.type != XftTypeInteger || value1.type != XftTypeInteger)
+	return -1.0;
+    v = value2.u.i - value1.u.i;
+    if (v < 0)
+	v = -v;
+    return (double) v;
+}
+
+static double
+_XftCompareString (char *object, XftValue value1, XftValue value2)
+{
+    if (value2.type != XftTypeString || value1.type != XftTypeString)
+	return -1.0;
+    return (double) _XftStrCmpIgnoreCase (value1.u.s, value2.u.s) != 0;
+}
+
+static double
+_XftCompareBool (char *object, XftValue value1, XftValue value2)
+{
+    if (value2.type != XftTypeBool || value1.type != XftTypeBool)
+	return -1.0;
+    return (double) value2.u.b != value1.u.b;
+}
+
+static double
+_XftCompareSize (char *object, XftValue value1, XftValue value2)
+{
+    double  v1, v2, v;
+
+    switch (value1.type) {
+    case XftTypeInteger:
+	v1 = value1.u.i;
+	break;
+    case XftTypeDouble:
+	v1 = value1.u.d;
+	break;
+    default:
+	return -1;
+    }
+    switch (value2.type) {
+    case XftTypeInteger:
+	v2 = value2.u.i;
+	break;
+    case XftTypeDouble:
+	v2 = value2.u.d;
+	break;
+    default:
+	return -1;
+    }
+    if (v2 == 0)
+	return 0;
+    v = v2 - v1;
+    if (v < 0)
+	v = -v;
+    return v;
+}
+
+/*
+ * Order is significant, it defines the precedence of
+ * each value, earlier values are more significant than
+ * later values
+ */
+static XftMatcher _XftMatchers [] = {
+    { XFT_FOUNDRY,	_XftCompareString, },
+    { XFT_ENCODING,	_XftCompareString, },
+    { XFT_SPACING,	_XftCompareInteger, },
+    { XFT_ANTIALIAS,	_XftCompareBool, },
+    { XFT_FAMILY,	_XftCompareString, },
+    { XFT_PIXEL_SIZE,	_XftCompareSize, },
+    { XFT_STYLE,	_XftCompareString, },
+    { XFT_SLANT,	_XftCompareInteger, },
+    { XFT_WEIGHT,	_XftCompareInteger, },
+    { XFT_RASTERIZER,	_XftCompareString, },
+    { XFT_OUTLINE,	_XftCompareBool, },
+};
+
+#define NUM_MATCHER (sizeof _XftMatchers / sizeof _XftMatchers[0])
+
+static Bool
+_XftCompareValueList (const char    *object,
+		      XftValueList  *v1orig,	/* pattern */
+		      XftValueList  *v2orig,	/* target */
+		      XftValue	    *bestValue,
+		      double	    *value,
+		      XftResult	    *result)
+{
+    XftValueList    *v1, *v2;
+    double    	    v, best;
+    int		    j;
+    int		    i;
+    
+    for (i = 0; i < NUM_MATCHER; i++)
+    {
+	if (!_XftStrCmpIgnoreCase (_XftMatchers[i].object, object))
+	    break;
+    }
+    if (i == NUM_MATCHER)
+    {
+	if (bestValue)
+	    *bestValue = v2orig->value;
+	return True;
+    }
+    
+    best = 1e99;
+    j = 0;
+    for (v1 = v1orig; v1; v1 = v1->next)
+    {
+	for (v2 = v2orig; v2; v2 = v2->next)
+	{
+	    v = (*_XftMatchers[i].compare) (_XftMatchers[i].object,
+					    v1->value,
+					    v2->value);
+	    if (v < 0)
+	    {
+		*result = XftResultTypeMismatch;
+		return False;
+	    }
+#ifdef XFT_DEBUG_MATCH
+	    printf (" v %g j %d ", v, j);
+#endif
+	    v = v * 100 + j;
+	    if (v < best)
+	    {
+		if (bestValue)
+		    *bestValue = v2->value;
+		best = v;
+	    }
+	}
+	j++;
+    }
+#ifdef XFT_DEBUG_MATCH
+    printf (" %s: %g ", object, best);
+    XftValueListPrint (v1orig);
+    printf (", ");
+    XftValueListPrint (v2orig);
+    printf ("\n");
+#endif
+    value[i] += best;
+    return True;
+}
+
+/*
+ * Return a value indicating the distance between the two lists of
+ * values
+ */
+
+static Bool
+_XftCompare (XftPattern *p1, XftPattern *p2, double *value, XftResult *result)
+{
+    int		    i, i1, i2;
+    
+    for (i = 0; i < NUM_MATCHER; i++)
+	value[i] = 0.0;
+    
+    for (i1 = 0; i1 < p1->num; i1++)
+	for (i2 = 0; i2 < p2->num; i2++)
+	{
+	    if (!_XftStrCmpIgnoreCase (p1->elts[i1].object,
+				       p2->elts[i2].object))
+	    {
+		if (!_XftCompareValueList (p1->elts[i1].object,
+					   p1->elts[i1].values,
+					   p2->elts[i2].values,
+					   0,
+					   value,
+					   result))
+		    return False;
+		break;
+	    }
+	}
+    return True;
+}
+
+XftPattern *
+XftFontSetMatch (XftFontSet	**sets, 
+		 int		nsets, 
+		 XftPattern	*p, 
+		 XftResult	*result)
+{
+    double    	    score[NUM_MATCHER], bestscore[NUM_MATCHER];
+    int		    f;
+    XftFontSet	    *s;
+    XftPattern	    *best;
+    XftPattern	    *new;
+    XftPatternElt   *fe, *pe;
+    XftValue	    v;
+    int		    i;
+    int		    set;
+
+    for (i = 0; i < NUM_MATCHER; i++)
+	bestscore[i] = 0;
+    best = 0;
+#ifdef XFT_DEBUG_MATCH
+    printf ("Match ");
+    XftPatternPrint (p);
+#endif
+    for (set = 0; set < nsets; set++)
+    {
+	s = sets[set];
+	for (f = 0; f < s->nfont; f++)
+	{
+#ifdef XFT_DEBUG_MATCH
+	    printf ("Font %d ", f);
+	    XftPatternPrint (s->fonts[f]);
+#endif
+	    if (!_XftCompare (p, s->fonts[f], score, result))
+		return 0;
+#ifdef XFT_DEBUG_MATCH
+	    printf ("Score");
+	    for (i = 0; i < NUM_MATCHER; i++)
+	    {
+		printf (" %g", score[i]);
+	    }
+	    printf ("\n");
+#endif
+	    for (i = 0; i < NUM_MATCHER; i++)
+	    {
+		if (best && bestscore[i] < score[i])
+		    break;
+		if (!best || score[i] < bestscore[i])
+		{
+		    for (i = 0; i < NUM_MATCHER; i++)
+			bestscore[i] = score[i];
+		    best = s->fonts[f];
+		    break;
+		}
+	    }
+	}
+    }
+#ifdef XFT_DEBUG_MATCH
+    printf ("Best score");
+    for (i = 0; i < NUM_MATCHER; i++)
+	printf (" %g", bestscore[i]);
+    XftPatternPrint (best);
+#endif
+    if (!best)
+    {
+	*result = XftResultNoMatch;
+	return 0;
+    }
+    new = XftPatternCreate ();
+    if (!new)
+	return 0;
+    for (i = 0; i < best->num; i++)
+    {
+	fe = &best->elts[i];
+	pe = XftPatternFind (p, fe->object, False);
+	if (pe)
+	{
+	    if (!_XftCompareValueList (pe->object, pe->values, 
+				       fe->values, &v, score, result))
+	    {
+		XftPatternDestroy (new);
+		return 0;
+	    }
+	}
+	else
+	    v = fe->values->value;
+	XftPatternAdd (new, fe->object, v, True);
+    }
+    for (i = 0; i < p->num; i++)
+    {
+	pe = &p->elts[i];
+	fe = XftPatternFind (best, pe->object, False);
+	if (!fe)
+	    XftPatternAdd (new, pe->object, pe->values->value, True);
+    }
+    return new;
+}
Index: xc/lib/Xft/xftname.c
diff -u /dev/null xc/lib/Xft/xftname.c:1.5
--- /dev/null	Mon Dec 18 14:24:44 2000
+++ xc/lib/Xft/xftname.c	Thu Dec 14 18:03:56 2000
@@ -0,0 +1,253 @@
+/*
+ * $XFree86: xc/lib/Xft/xftname.c,v 1.5 2000/12/14 23:03:56 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "xftint.h"
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct _XftObjectType {
+    const char	*object;
+    XftType	type;
+} XftObjectType;
+
+const XftObjectType _XftObjectTypes[] = {
+    { XFT_FAMILY,	XftTypeString, },
+    { XFT_STYLE,	XftTypeString, },
+    { XFT_SLANT,	XftTypeInteger, },
+    { XFT_WEIGHT,	XftTypeInteger, },
+    { XFT_SIZE,		XftTypeDouble, },
+    { XFT_PIXEL_SIZE,	XftTypeDouble, },
+    { XFT_ENCODING,	XftTypeString, },
+    { XFT_SPACING,	XftTypeInteger, },
+    { XFT_FOUNDRY,	XftTypeString, },
+    { XFT_CORE,		XftTypeBool, },
+    { XFT_ANTIALIAS,	XftTypeBool, },
+    { XFT_XLFD,		XftTypeString, },
+    { XFT_FILE,		XftTypeString, },
+    { XFT_INDEX,	XftTypeInteger, },
+    { XFT_RASTERIZER,	XftTypeString, },
+    { XFT_OUTLINE,	XftTypeBool, },
+    { XFT_SCALABLE,	XftTypeBool, },
+    { XFT_RGBA,		XftTypeInteger, },
+    { XFT_SCALE,	XftTypeDouble, },
+    { XFT_RENDER,	XftTypeBool, },
+};
+
+#define NUM_OBJECT_TYPES    (sizeof _XftObjectTypes / sizeof _XftObjectTypes[0])
+
+static const XftObjectType *
+XftNameGetType (const char *object)
+{
+    int	    i;
+    
+    for (i = 0; i < NUM_OBJECT_TYPES; i++)
+    {
+	if (!_XftStrCmpIgnoreCase (object, _XftObjectTypes[i].object))
+	    return &_XftObjectTypes[i];
+    }
+    return 0;
+}
+
+typedef struct _XftConstant {
+    const char  *name;
+    const char	*object;
+    int		value;
+} XftConstant;
+
+static XftConstant XftConstants[] = {
+    { "light",		"weight",   XFT_WEIGHT_LIGHT, },
+    { "medium",		"weight",   XFT_WEIGHT_MEDIUM, },
+    { "demibold",	"weight",   XFT_WEIGHT_DEMIBOLD, },
+    { "bold",		"weight",   XFT_WEIGHT_BOLD, },
+    { "black",		"weight",   XFT_WEIGHT_BLACK, },
+
+    { "roman",		"slant",    XFT_SLANT_ROMAN, },
+    { "italic",		"slant",    XFT_SLANT_ITALIC, },
+    { "oblique",	"slant",    XFT_SLANT_OBLIQUE, },
+
+    { "proportional",	"spacing",  XFT_PROPORTIONAL, },
+    { "mono",		"spacing",  XFT_MONO, },
+    { "charcell",	"spacing",  XFT_CHARCELL, },
+
+    { "rgb",		"rgba",	    XFT_RGBA_RGB, },
+    { "bgr",		"rgba",	    XFT_RGBA_BGR, },
+};
+
+#define NUM_XFT_CONSTANTS   (sizeof XftConstants/sizeof XftConstants[0])
+
+static XftConstant *
+_XftNameConstantLookup (char *string)
+{
+    int	i;
+    
+    for (i = 0; i < NUM_XFT_CONSTANTS; i++)
+	if (!_XftStrCmpIgnoreCase (string, XftConstants[i].name))
+	    return &XftConstants[i];
+    return 0;
+}
+
+Bool
+XftNameConstant (char *string, int *result)
+{
+    XftConstant	*c;
+
+    if ((c = _XftNameConstantLookup(string)))
+    {
+	*result = c->value;
+	return True;
+    }
+    return False;
+}
+
+static XftValue
+_XftNameConvert (XftType type, char *string)
+{
+    XftValue	v;
+
+    v.type = type;
+    switch (v.type) {
+    case XftTypeInteger:
+	if (!XftNameConstant (string, &v.u.i))
+	    v.u.i = atoi (string);
+	break;
+    case XftTypeString:
+	v.u.s = string;
+	break;
+    case XftTypeBool:
+	v.u.b = XftDefaultParseBool (string);
+	break;
+    case XftTypeDouble:
+	v.u.d = strtod (string, 0);
+	break;
+    default:
+	break;
+    }
+    return v;
+}
+
+static const char *
+_XftNameFindNext (const char *cur, const char *delim, char *save, char *last)
+{
+    char    c;
+    
+    while (*cur && !strchr (delim, *cur))
+    {
+	c = *cur++;
+	*save++ = c;
+    }
+    *save = 0;
+    *last = *cur;
+    if (*cur)
+	cur++;
+    return cur;
+}
+
+XftPattern *
+XftNameParse (const char *name)
+{
+    char		*save;
+    XftPattern		*pat;
+    double		d;
+    char		*e;
+    char		delim;
+    XftValue		v;
+    const XftObjectType	*t;
+    XftConstant		*c;
+
+    save = malloc (strlen (name) + 1);
+    if (!save)
+	goto bail0;
+    pat = XftPatternCreate ();
+    if (!pat)
+	goto bail1;
+
+    for (;;)
+    {
+	name = _XftNameFindNext (name, "-,:", save, &delim);
+	if (save[0])
+	{
+	    if (!XftPatternAddString (pat, XFT_FAMILY, save))
+		goto bail2;
+	}
+	if (delim != ',')
+	    break;
+    }
+    if (delim == '-')
+    {
+	for (;;)
+	{
+	    name = _XftNameFindNext (name, "-,:", save, &delim);
+	    d = strtod (save, &e);
+	    if (e != save)
+	    {
+		if (!XftPatternAddDouble (pat, XFT_SIZE, d))
+		    goto bail2;
+	    }
+	    if (delim != ',')
+		break;
+	}
+    }
+    while (delim == ':')
+    {
+	name = _XftNameFindNext (name, "=-:", save, &delim);
+	if (save[0])
+	{
+	    if (delim == '=' || delim == '-')
+	    {
+		t = XftNameGetType (save);
+		for (;;)
+		{
+		    name = _XftNameFindNext (name, ":,", save, &delim);
+		    if (save[0] && t)
+		    {
+			v = _XftNameConvert (t->type, save);
+			if (!XftPatternAdd (pat, t->object, v, True))
+			    goto bail2;
+		    }
+		    if (delim != ',')
+			break;
+		}
+	    }
+	    else
+	    {
+		if ((c = _XftNameConstantLookup (save)))
+		{
+		    if (!XftPatternAddInteger (pat, c->object, c->value))
+			goto bail2;
+		}
+	    }
+	}
+    }
+
+    free (save);
+    return pat;
+
+bail2:
+    XftPatternDestroy (pat);
+bail1:
+    free (save);
+bail0:
+    return 0;
+}
Index: xc/lib/Xft/xftpat.c
diff -u /dev/null xc/lib/Xft/xftpat.c:1.5
--- /dev/null	Mon Dec 18 14:24:45 2000
+++ xc/lib/Xft/xftpat.c	Thu Dec 14 18:03:56 2000
@@ -0,0 +1,373 @@
+/*
+ * $XFree86: xc/lib/Xft/xftpat.c,v 1.5 2000/12/14 23:03:56 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "xftint.h"
+
+XftPattern *
+XftPatternCreate (void)
+{
+    XftPattern	*p;
+
+    p = (XftPattern *) malloc (sizeof (XftPattern));
+    if (!p)
+	return 0;
+    p->num = 0;
+    p->size = 0;
+    p->elts = 0;
+    return p;
+}
+
+void
+XftValueDestroy (XftValue v)
+{
+    if (v.type == XftTypeString)
+	free (v.u.s);
+}
+
+void
+XftValueListDestroy (XftValueList *l)
+{
+    XftValueList    *next;
+    for (; l; l = next)
+    {
+	if (l->value.type == XftTypeString)
+	    free (l->value.u.s);
+	next = l->next;
+	free (l);
+    }
+}
+
+void
+XftPatternDestroy (XftPattern *p)
+{
+    int		    i;
+    
+    for (i = 0; i < p->num; i++)
+	XftValueListDestroy (p->elts[i].values);
+
+    if (p->elts)
+    {
+	free (p->elts);
+	p->elts = 0;
+    }
+    p->num = p->size = 0;
+    free (p);
+}
+
+XftPatternElt *
+XftPatternFind (XftPattern *p, const char *object, Bool insert)
+{
+    int		    i;
+    int		    s;
+    XftPatternElt   *e;
+    
+    /* match existing */
+    for (i = 0; i < p->num; i++)
+    {
+	if (!_XftStrCmpIgnoreCase (object, p->elts[i].object))
+	    return &p->elts[i];
+    }
+
+    if (!insert)
+	return 0;
+
+    /* grow array */
+    if (i == p->size)
+    {
+	s = p->size + 16;
+	if (p->elts)
+	    e = (XftPatternElt *) realloc (p->elts, s * sizeof (XftPatternElt));
+	else
+	    e = (XftPatternElt *) malloc (s * sizeof (XftPatternElt));
+	if (!e)
+	    return False;
+	p->elts = e;
+	while (p->size < s)
+	{
+	    p->elts[p->size].object = 0;
+	    p->elts[p->size].values = 0;
+	    p->size++;
+	}
+    }
+    
+    /* bump count */
+    p->num++;
+    
+    return &p->elts[i];
+}
+
+Bool
+XftPatternAdd (XftPattern *p, const char *object, XftValue value, Bool append)
+{
+    XftPatternElt   *e;
+    XftValueList    *new, **prev;
+
+    new = (XftValueList *) malloc (sizeof (XftValueList));
+    if (!new)
+	goto bail0;
+
+    /* dup string */
+    if (value.type == XftTypeString)
+    {
+	value.u.s = _XftSaveString (value.u.s);
+	if (!value.u.s)
+	    goto bail1;
+    }
+    new->value = value;
+    new->next = 0;
+    
+    e = XftPatternFind (p, object, True);
+    if (!e)
+	goto bail2;
+    
+    e->object = object;
+    if (append)
+    {
+	for (prev = &e->values; *prev; prev = &(*prev)->next);
+	*prev = new;
+    }
+    else
+    {
+	new->next = e->values;
+	e->values = new;
+    }
+    
+    return True;
+
+bail2:    
+    if (value.type == XftTypeString)
+        free (value.u.s);
+bail1:
+    free (new);
+bail0:
+    return False;
+}
+
+Bool
+XftPatternDel (XftPattern *p, const char *object)
+{
+    XftPatternElt   *e;
+    int		    i;
+
+    e = XftPatternFind (p, object, False);
+    if (!e)
+	return False;
+
+    i = e - p->elts;
+    
+    /* destroy value */
+    XftValueListDestroy (e->values);
+    
+    /* shuffle existing ones down */
+    memmove (e, e+1, (p->elts + p->num - (e + 1)) * sizeof (XftPatternElt));
+    p->num--;
+    p->elts[p->num].object = 0;
+    p->elts[p->num].values = 0;
+    return True;
+}
+
+Bool
+XftPatternAddInteger (XftPattern *p, const char *object, int i)
+{
+    XftValue	v;
+
+    v.type = XftTypeInteger;
+    v.u.i = i;
+    return XftPatternAdd (p, object, v, True);
+}
+
+Bool
+XftPatternAddDouble (XftPattern *p, const char *object, double d)
+{
+    XftValue	v;
+
+    v.type = XftTypeDouble;
+    v.u.d = d;
+    return XftPatternAdd (p, object, v, True);
+}
+
+
+Bool
+XftPatternAddString (XftPattern *p, const char *object, const char *s)
+{
+    XftValue	v;
+
+    v.type = XftTypeString;
+    v.u.s = (char *) s;
+    return XftPatternAdd (p, object, v, True);
+}
+
+
+Bool
+XftPatternAddBool (XftPattern *p, const char *object, Bool b)
+{
+    XftValue	v;
+
+    v.type = XftTypeBool;
+    v.u.b = b;
+    return XftPatternAdd (p, object, v, True);
+}
+
+XftResult
+XftPatternGet (XftPattern *p, const char *object, int id, XftValue *v)
+{
+    XftPatternElt   *e;
+    XftValueList    *l;
+
+    e = XftPatternFind (p, object, False);
+    if (!e)
+	return XftResultNoMatch;
+    for (l = e->values; l; l = l->next)
+    {
+	if (!id)
+	{
+	    *v = l->value;
+	    return XftResultMatch;
+	}
+	id--;
+    }
+    return XftResultNoId;
+}
+
+XftResult
+XftPatternGetInteger (XftPattern *p, const char *object, int id, int *i)
+{
+    XftValue	v;
+    XftResult	r;
+
+    r = XftPatternGet (p, object, id, &v);
+    if (r != XftResultMatch)
+	return r;
+    switch (v.type) {
+    case XftTypeDouble:
+	*i = (int) v.u.d;
+	break;
+    case XftTypeInteger:
+	*i = v.u.i;
+	break;
+    default:
+        return XftResultTypeMismatch;
+    }
+    return XftResultMatch;
+}
+
+XftResult
+XftPatternGetDouble (XftPattern *p, const char *object, int id, double *d)
+{
+    XftValue	v;
+    XftResult	r;
+
+    r = XftPatternGet (p, object, id, &v);
+    if (r != XftResultMatch)
+	return r;
+    switch (v.type) {
+    case XftTypeDouble:
+	*d = v.u.d;
+	break;
+    case XftTypeInteger:
+	*d = (double) v.u.i;
+	break;
+    default:
+        return XftResultTypeMismatch;
+    }
+    return XftResultMatch;
+}
+
+XftResult
+XftPatternGetString (XftPattern *p, const char *object, int id, char **s)
+{
+    XftValue	v;
+    XftResult	r;
+
+    r = XftPatternGet (p, object, id, &v);
+    if (r != XftResultMatch)
+	return r;
+    if (v.type != XftTypeString)
+        return XftResultTypeMismatch;
+    *s = v.u.s;
+    return XftResultMatch;
+}
+
+XftResult
+XftPatternGetBool (XftPattern *p, const char *object, int id, Bool *b)
+{
+    XftValue	v;
+    XftResult	r;
+
+    r = XftPatternGet (p, object, id, &v);
+    if (r != XftResultMatch)
+	return r;
+    if (v.type != XftTypeBool)
+        return XftResultTypeMismatch;
+    *b = v.u.b;
+    return XftResultMatch;
+}
+
+XftPattern *
+XftPatternDuplicate (XftPattern *orig)
+{
+    XftPattern	    *new;
+    int		    i;
+    XftValueList    *l;
+
+    new = XftPatternCreate ();
+    if (!new)
+	goto bail0;
+
+    for (i = 0; i < orig->num; i++)
+    {
+	for (l = orig->elts[i].values; l; l = l->next)
+	    if (!XftPatternAdd (new, orig->elts[i].object, l->value, True))
+		goto bail1;
+    }
+
+    return new;
+
+bail1:
+    XftPatternDestroy (new);
+bail0:
+    return 0;
+}
+
+XftPattern *
+XftPatternVaBuild (XftPattern *orig, va_list va)
+{
+    XftPattern	*ret;
+    
+    _XftPatternVapBuild (ret, orig, va);
+    return ret;
+}
+
+XftPattern *
+XftPatternBuild (XftPattern *orig, ...)
+{
+    va_list	va;
+    
+    va_start (va, orig);
+    _XftPatternVapBuild (orig, orig, va);
+    va_end (va);
+    return orig;
+}
Index: xc/lib/Xft/xftrender.c
diff -u /dev/null xc/lib/Xft/xftrender.c:1.5
--- /dev/null	Mon Dec 18 14:24:46 2000
+++ xc/lib/Xft/xftrender.c	Fri Dec  8 02:51:28 2000
@@ -0,0 +1,292 @@
+/*
+ * $XFree86: xc/lib/Xft/xftrender.c,v 1.5 2000/12/08 07:51:28 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "xftint.h"
+
+void
+XftRenderString8 (Display *dpy, Picture src, 
+		  XftFontStruct *font, Picture dst,
+		  int srcx, int srcy,
+		  int x, int y,
+		  XftChar8 *string, int len)
+{
+    unsigned int    missing[XFT_NMISSING];
+    int		    nmissing;
+    XftChar8	    *s;
+    int		    l;
+
+    s = string;
+    l = len;
+    nmissing = 0;
+    while (l--)
+	XftGlyphCheck (dpy, font, (unsigned int) *s++, missing, &nmissing);
+    if (nmissing)
+	XftGlyphLoad (dpy, font, missing, nmissing);
+    XRenderCompositeString8 (dpy, PictOpOver, src, dst,
+			     font->format, font->glyphset,
+			     srcx, srcy, x, y, (char *) string, len);
+}
+
+void
+XftRenderString16 (Display *dpy, Picture src, 
+		   XftFontStruct *font, Picture dst,
+		   int srcx, int srcy,
+		   int x, int y,
+		   XftChar16 *string, int len)
+{
+    unsigned int    missing[XFT_NMISSING];
+    int		    nmissing;
+    XftChar16	    *s;
+    int		    l;
+
+    s = string;
+    l = len;
+    nmissing = 0;
+    while (l--)
+	XftGlyphCheck (dpy, font, (unsigned int) *s++, missing, &nmissing);
+    if (nmissing)
+	XftGlyphLoad (dpy, font, missing, nmissing);
+    XRenderCompositeString16 (dpy, PictOpOver, src, dst,
+			      font->format, font->glyphset,
+			      srcx, srcy, x, y, string, len);
+}
+
+void
+XftRenderString32 (Display *dpy, Picture src, 
+		   XftFontStruct *font, Picture dst,
+		   int srcx, int srcy,
+		   int x, int y,
+		   unsigned int *string, int len)
+{
+    unsigned int    missing[XFT_NMISSING];
+    int		    nmissing;
+    unsigned int    *s;
+    int		    l;
+
+    s = string;
+    l = len;
+    nmissing = 0;
+    while (l--)
+	XftGlyphCheck (dpy, font, (unsigned int) *s++, missing, &nmissing);
+    if (nmissing)
+	XftGlyphLoad (dpy, font, missing, nmissing);
+    XRenderCompositeString32 (dpy, PictOpOver, src, dst,
+			      font->format, font->glyphset,
+			      srcx, srcy, x, y, string, len);
+}
+
+void
+XftRenderExtents8 (Display	    *dpy,
+		   XftFontStruct    *font,
+		   XftChar8    *string, 
+		   int		    len,
+		   XGlyphInfo	    *extents)
+{
+    unsigned int    missing[XFT_NMISSING];
+    int		    nmissing;
+    XftChar8	    *s, c;
+    int		    l;
+    XGlyphInfo	    *gi;
+    int		    x, y;
+
+    s = string;
+    l = len;
+    nmissing = 0;
+    while (l--)
+	XftGlyphCheck (dpy, font, (unsigned int) *s++, missing, &nmissing);
+    if (nmissing)
+	XftGlyphLoad (dpy, font, missing, nmissing);
+    
+    gi = 0;
+    while (len)
+    {
+	c = *string++;
+	len--;
+	gi = c < font->nrealized ? font->realized[c] : 0;
+	if (gi)
+	    break;
+    }
+    if (len == 0 && !gi)
+    {
+	extents->width = 0;
+	extents->height = 0;
+	extents->x = 0;
+	extents->y = 0;
+	extents->yOff = 0;
+	extents->xOff = 0;
+	return;
+    }
+    *extents = *gi;
+    x = gi->xOff;
+    y = gi->yOff;
+    while (len--)
+    {
+	c = *string++;
+	gi = c < font->nrealized ? font->realized[c] : 0;
+	if (!gi)
+	    continue;
+	if (gi->x + x < extents->x)
+	    extents->x = gi->x + x;
+	if (gi->y + y < extents->y)
+	    extents->y = gi->y + y;
+	if (gi->width + x > extents->width)
+	    extents->width = gi->width + x;
+	if (gi->height + y > extents->height)
+	    extents->height = gi->height + y;
+	x += gi->xOff;
+	y += gi->yOff;
+    }
+    extents->xOff = x;
+    extents->yOff = y;
+}
+
+void
+XftRenderExtents16 (Display	    *dpy,
+		    XftFontStruct   *font,
+		    XftChar16  *string, 
+		    int		    len,
+		    XGlyphInfo	    *extents)
+{
+    unsigned int    missing[XFT_NMISSING];
+    int		    nmissing;
+    XftChar16	    *s, c;
+    int		    l;
+    XGlyphInfo	    *gi;
+    int		    x, y;
+
+    s = string;
+    l = len;
+    nmissing = 0;
+    while (l--)
+	XftGlyphCheck (dpy, font, (unsigned int) *s++, missing, &nmissing);
+    if (nmissing)
+	XftGlyphLoad (dpy, font, missing, nmissing);
+    
+    gi = 0;
+    while (len)
+    {
+	c = *string++;
+	len--;
+	gi = c < font->nrealized ? font->realized[c] : 0;
+	if (gi)
+	    break;
+    }
+    if (len == 0 && !gi)
+    {
+	extents->width = 0;
+	extents->height = 0;
+	extents->x = 0;
+	extents->y = 0;
+	extents->yOff = 0;
+	extents->xOff = 0;
+	return;
+    }
+    *extents = *gi;
+    x = gi->xOff;
+    y = gi->yOff;
+    while (len--)
+    {
+	c = *string++;
+	gi = c < font->nrealized ? font->realized[c] : 0;
+	if (!gi)
+	    continue;
+	if (gi->x + x < extents->x)
+	    extents->x = gi->x + x;
+	if (gi->y + y < extents->y)
+	    extents->y = gi->y + y;
+	if (gi->width + x > extents->width)
+	    extents->width = gi->width + x;
+	if (gi->height + y > extents->height)
+	    extents->height = gi->height + y;
+	x += gi->xOff;
+	y += gi->yOff;
+    }
+    extents->xOff = x;
+    extents->yOff = y;
+}
+
+void
+XftRenderExtents32 (Display	    *dpy,
+		    XftFontStruct   *font,
+		    unsigned int    *string, 
+		    int		    len,
+		    XGlyphInfo	    *extents)
+{
+    unsigned int    missing[XFT_NMISSING];
+    int		    nmissing;
+    unsigned int    *s, c;
+    int		    l;
+    XGlyphInfo	    *gi;
+    int		    x, y;
+
+    s = string;
+    l = len;
+    nmissing = 0;
+    while (l--)
+	XftGlyphCheck (dpy, font, (unsigned int) *s++, missing, &nmissing);
+    if (nmissing)
+	XftGlyphLoad (dpy, font, missing, nmissing);
+    
+    gi = 0;
+    while (len)
+    {
+	c = *string++;
+	len--;
+	gi = c < font->nrealized ? font->realized[c] : 0;
+	if (gi)
+	    break;
+    }
+    if (len == 0 && !gi)
+    {
+	extents->width = 0;
+	extents->height = 0;
+	extents->x = 0;
+	extents->y = 0;
+	extents->yOff = 0;
+	extents->xOff = 0;
+	return;
+    }
+    *extents = *gi;
+    x = gi->xOff;
+    y = gi->yOff;
+    while (len--)
+    {
+	c = *string++;
+	gi = c < font->nrealized ? font->realized[c] : 0;
+	if (!gi)
+	    continue;
+	if (gi->x + x < extents->x)
+	    extents->x = gi->x + x;
+	if (gi->y + y < extents->y)
+	    extents->y = gi->y + y;
+	if (gi->width + x > extents->width)
+	    extents->width = gi->width + x;
+	if (gi->height + y > extents->height)
+	    extents->height = gi->height + y;
+	x += gi->xOff;
+	y += gi->yOff;
+    }
+    extents->xOff = x;
+    extents->yOff = y;
+}
Index: xc/lib/Xft/xftstr.c
diff -u /dev/null xc/lib/Xft/xftstr.c:1.2
--- /dev/null	Mon Dec 18 14:24:46 2000
+++ xc/lib/Xft/xftstr.c	Thu Dec 14 18:03:57 2000
@@ -0,0 +1,152 @@
+/*
+ * $XFree86: xc/lib/Xft/xftstr.c,v 1.2 2000/12/14 23:03:57 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include "xftint.h"
+
+char *
+_XftSaveString (const char *s)
+{
+    char    *r;
+
+    r = (char *) malloc (strlen (s) + 1);
+    if (!r)
+	return 0;
+    strcpy (r, s);
+    return r;
+}
+
+const char *
+_XftGetInt(const char *ptr, int *val)
+{
+    if (*ptr == '*') {
+	*val = -1;
+	ptr++;
+    } else
+	for (*val = 0; *ptr >= '0' && *ptr <= '9';)
+	    *val = *val * 10 + *ptr++ - '0';
+    if (*ptr == '-')
+	return ptr;
+    return (char *) 0;
+}
+
+char *
+_XftSplitStr (const char *field, char *save)
+{
+    char    *s = save;
+    char    c;
+
+    while (*field)
+    {
+	if (*field == '-')
+	    break;
+	c = *field++;
+	*save++ = c;
+    }
+    *save = 0;
+    return s;
+}
+
+char *
+_XftDownStr (const char *field, char *save)
+{
+    char    *s = save;
+    char    c;
+
+    while (*field)
+    {
+	c = *field++;
+	*save++ = c;
+    }
+    *save = 0;
+    return s;
+}
+
+const char *
+_XftSplitField (const char *field, char *save)
+{
+    char    c;
+
+    while (*field)
+    {
+	if (*field == '-' || *field == '=')
+	    break;
+	c = *field++;
+	*save++ = c;
+    }
+    *save = 0;
+    return field;
+}
+
+const char *
+_XftSplitValue (const char *field, char *save)
+{
+    char    c;
+
+    while (*field)
+    {
+	if (*field == '-' || *field == ',')
+	    break;
+	c = *field++;
+	*save++ = c;
+    }
+    *save = 0;
+    if (*field)
+	field++;
+    return field;
+}
+
+int
+_XftMatchSymbolic (XftSymbolic *s, int n, const char *name, int def)
+{
+    while (n--)
+    {
+	if (!_XftStrCmpIgnoreCase (s->name, name))
+	    return s->value;
+	s++;
+    }
+    return def;
+}
+
+int
+_XftStrCmpIgnoreCase (const char *s1, const char *s2)
+{
+    char    c1, c2;
+    
+    for (;;) 
+    {
+	c1 = *s1++;
+	c2 = *s2++;
+	if (!c1 || !c2)
+	    break;
+	if (isupper (c1))
+	    c1 = tolower (c1);
+	if (isupper (c2))
+	    c2 = tolower (c2);
+	if (c1 != c2)
+	    break;
+    }
+    return (int) c2 - (int) c1;
+}
Index: xc/lib/Xft/xftxlfd.c
diff -u /dev/null xc/lib/Xft/xftxlfd.c:1.5
--- /dev/null	Mon Dec 18 14:24:47 2000
+++ xc/lib/Xft/xftxlfd.c	Thu Dec 14 18:03:57 2000
@@ -0,0 +1,266 @@
+/*
+ * $XFree86: xc/lib/Xft/xftxlfd.c,v 1.5 2000/12/14 23:03:57 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "xftint.h"
+
+static XftSymbolic XftXlfdWeights[] = {
+    {	"light",    XFT_WEIGHT_LIGHT	},
+    {	"medium",   XFT_WEIGHT_MEDIUM	},
+    {	"regular",  XFT_WEIGHT_MEDIUM	},
+    {	"demibold", XFT_WEIGHT_DEMIBOLD },
+    {	"bold",	    XFT_WEIGHT_BOLD	},
+    {	"black",    XFT_WEIGHT_BLACK	},
+};
+
+#define NUM_XLFD_WEIGHTS    (sizeof XftXlfdWeights/sizeof XftXlfdWeights[0])
+
+static XftSymbolic XftXlfdSlants[] = {
+    {	"r",	    XFT_SLANT_ROMAN	},
+    {	"i",	    XFT_SLANT_ITALIC	},
+    {	"o",	    XFT_SLANT_OBLIQUE	},
+};
+
+#define NUM_XLFD_SLANTS    (sizeof XftXlfdSlants/sizeof XftXlfdSlants[0])
+
+XftPattern *
+XftXlfdParse (const char *xlfd_orig, Bool ignore_scalable, Bool complete)
+{
+    XftPattern	*pat;
+    const char	*xlfd = xlfd_orig;
+    const char	*foundry;
+    const char	*family;
+    const char	*weight_name;
+    const char	*slant;
+    const char	*registry;
+    const char	*encoding;
+    char	*save;
+    char	style[128];
+    int		pixel;
+    int		point;
+    int		resx;
+    int		resy;
+    int		slant_value, weight_value;
+    double	dpixel;
+
+    if (*xlfd != '-')
+	return 0;
+    if (!(xlfd = strchr (foundry = ++xlfd, '-'))) return 0;
+    if (!(xlfd = strchr (family = ++xlfd, '-'))) return 0;
+    if (!(xlfd = strchr (weight_name = ++xlfd, '-'))) return 0;
+    if (!(xlfd = strchr (slant = ++xlfd, '-'))) return 0;
+    if (!(xlfd = strchr (/* setwidth_name = */ ++xlfd, '-'))) return 0;
+    if (!(xlfd = strchr (/* add_style_name = */ ++xlfd, '-'))) return 0;
+    if (!(xlfd = _XftGetInt (++xlfd, &pixel))) return 0;
+    if (!(xlfd = _XftGetInt (++xlfd, &point))) return 0;
+    if (!(xlfd = _XftGetInt (++xlfd, &resx))) return 0;
+    if (!(xlfd = _XftGetInt (++xlfd, &resy))) return 0;
+    if (!(xlfd = strchr (/* spacing = */ ++xlfd, '-'))) return 0;
+    if (!(xlfd = strchr (/* average_width = */ ++xlfd, '-'))) return 0;
+    if (!(xlfd = strchr (registry = ++xlfd, '-'))) return 0;
+    /* make sure no fields follow this one */
+    if ((xlfd = strchr (encoding = ++xlfd, '-'))) return 0;
+
+    if (ignore_scalable && !pixel)
+	return 0;
+    
+    pat = XftPatternCreate ();
+    if (!pat)
+	return 0;
+    
+    save = (char *) malloc (strlen (foundry) + 1);
+    
+    if (!save)
+	return 0;
+
+    if (!XftPatternAddString (pat, XFT_XLFD, xlfd_orig)) goto bail;
+    
+    _XftSplitStr (foundry, save);
+    if (save[0] && strcmp (save, "*") != 0)
+	if (!XftPatternAddString (pat, XFT_FOUNDRY, save)) goto bail;
+    
+    _XftSplitStr (family, save);
+    if (save[0] && strcmp (save, "*") != 0)
+	if (!XftPatternAddString (pat, XFT_FAMILY, save)) goto bail;
+    
+    weight_value = _XftMatchSymbolic (XftXlfdWeights, NUM_XLFD_WEIGHTS,
+				      _XftSplitStr (weight_name, save),
+				      XFT_WEIGHT_MEDIUM);
+    if (!XftPatternAddInteger (pat, XFT_WEIGHT, weight_value)) 
+	goto bail;
+    
+    slant_value = _XftMatchSymbolic (XftXlfdSlants, NUM_XLFD_SLANTS,
+				     _XftSplitStr (slant, save),
+				     XFT_SLANT_ROMAN);
+    if (!XftPatternAddInteger (pat, XFT_SLANT, slant_value)) 
+	goto bail;
+    
+    dpixel = (double) pixel;
+    
+    if (complete)
+    {
+	/*
+	 * Build a style name
+	 */
+	style[0] = '\0';
+	switch (weight_value) {
+	case XFT_WEIGHT_LIGHT: strcat (style, "light"); break;
+	case XFT_WEIGHT_DEMIBOLD: strcat (style, "demibold"); break;
+	case XFT_WEIGHT_BOLD: strcat (style, "bold"); break;
+	case XFT_WEIGHT_BLACK: strcat (style, "black"); break;
+	}
+	if (slant_value != XFT_SLANT_ROMAN) {
+	    if (style[0])
+		strcat (style, " ");
+	    switch (slant_value) {
+	    case XFT_SLANT_ITALIC: strcat (style, "italic"); break;
+	    case XFT_SLANT_OBLIQUE: strcat (style, "oblique"); break;
+	    }
+	}
+	if (!style[0])
+	    strcat (style, "Regular");
+	
+	if (!XftPatternAddString (pat, XFT_STYLE, style))
+	    goto bail;
+	if (!XftPatternAddBool (pat, XFT_SCALABLE, pixel == 0)) goto bail;
+	if (!XftPatternAddBool (pat, XFT_CORE, True)) goto bail;
+	if (!XftPatternAddBool (pat, XFT_ANTIALIAS, False)) goto bail;
+    }
+    else
+    {
+	if (point > 0)
+	{
+	    if (!XftPatternAddDouble (pat, XFT_SIZE, ((double) point) / 10.0)) goto bail;
+	    if (pixel <= 0 && resy > 0)
+	    {
+		dpixel = (double) point * (double) resy / 720.0;
+	    }
+	}
+    }
+    
+    if (dpixel > 0)
+	if (!XftPatternAddDouble (pat, XFT_PIXEL_SIZE, dpixel)) goto bail;
+    
+    _XftDownStr (registry, save);
+    if (registry[0] && !strchr (registry, '*'))
+	if (!XftPatternAddString (pat, XFT_ENCODING, save)) goto bail;
+
+    free (save);
+    return pat;
+    
+bail:
+    free (save);
+    XftPatternDestroy (pat);
+    return 0;
+}
+
+Bool
+XftCoreAddFonts (XftFontSet *set, Display *dpy, Bool ignore_scalable)
+{
+    char	**xlfds;
+    int		num;
+    int		i;
+    XftPattern	*font;
+    Bool	ret;
+
+    xlfds = XListFonts (dpy,
+			"-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
+			10000, &num);
+    if (!xlfds)
+	return False;
+    ret = True;
+    for (i = 0; ret && i < num; i++)
+    {
+	font = XftXlfdParse (xlfds[i], ignore_scalable, True);
+	if (font)
+	{
+	    if (!XftFontSetAdd (set, font))
+	    {
+		XftPatternDestroy (font);
+		ret = False;
+	    }
+	}
+    }
+    XFreeFontNames (xlfds);
+    return ret;
+}
+
+XFontStruct *
+XftCoreOpen (Display *dpy, XftPattern *pattern)
+{
+    char	*xlfd;
+    char	*xlfd_pixel = 0;
+    char	*i, *o;
+    int		d;
+    Bool	scalable;
+    double	pixel_size;
+    int		pixel_int;
+    XFontStruct	*ret;
+
+#if 0
+    printf ("Core ");
+    XftPatternPrint (pattern);
+#endif
+    if (XftPatternGetString (pattern, XFT_XLFD, 0, &xlfd) != XftResultMatch)
+	return 0;
+    if (XftPatternGetBool (pattern, XFT_SCALABLE, 0, &scalable) != XftResultMatch)
+	return 0;
+    if (scalable)
+    {
+	if (XftPatternGetDouble (pattern, XFT_PIXEL_SIZE, 0, &pixel_size) != XftResultMatch)
+	    return 0;
+	pixel_int = (int) (pixel_size + 0.5);
+	if (pixel_int)
+	{
+	    xlfd_pixel = (char *) malloc (strlen (xlfd) + 32);
+	    i = xlfd;
+	    o = xlfd_pixel;
+	    d = 0;
+	    while (d != 7 && *i)
+	    {
+		if ((*o++ = *i++) == '-')
+		    d++;
+	    }
+	    if (*i)
+	    {
+		sprintf (o, "%d", pixel_int);
+		o += strlen (o);
+		while (*i != '-')
+		    ++i;
+	    }
+	    while ((*o++ = *i++));
+#if 0
+	    printf ("original %s sized %s\n", xlfd, xlfd_pixel);
+#endif
+	    xlfd = xlfd_pixel;
+	}
+    }
+    ret = XLoadQueryFont (dpy, xlfd);
+    if (xlfd_pixel)
+	free (xlfd_pixel);
+    return ret;
+}
+
Index: xc/lib/Xmu/Atoms.c
diff -u xc/lib/Xmu/Atoms.c:3.4 xc/lib/Xmu/Atoms.c:3.5
--- xc/lib/Xmu/Atoms.c:3.4	Sat Oct  3 05:06:20 1998
+++ xc/lib/Xmu/Atoms.c	Tue Nov 28 13:50:07 2000
@@ -21,7 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/Xmu/Atoms.c,v 3.4 1998/10/03 09:06:20 dawes Exp $ */
+/* $XFree86: xc/lib/Xmu/Atoms.c,v 3.5 2000/11/28 18:50:07 dawes Exp $ */
 
 /*
  * This file contains routines to cache atoms, avoiding multiple
@@ -88,6 +88,7 @@
 DeclareAtom(XA_TEXT,			"TEXT"			)
 DeclareAtom(XA_TIMESTAMP,		"TIMESTAMP"		)
 DeclareAtom(XA_USER,			"USER"			)
+DeclareAtom(XA_UTF8_STRING,		"UTF8_STRING"		)
 
 /******************************************************************
 
Index: xc/lib/Xmu/Atoms.h
diff -u xc/lib/Xmu/Atoms.h:1.4 xc/lib/Xmu/Atoms.h:1.5
--- xc/lib/Xmu/Atoms.h:1.4	Sat Oct  3 05:06:21 1998
+++ xc/lib/Xmu/Atoms.h	Tue Nov 28 13:50:09 2000
@@ -21,7 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/Xmu/Atoms.h,v 1.4 1998/10/03 09:06:21 dawes Exp $ */
+/* $XFree86: xc/lib/Xmu/Atoms.h,v 1.5 2000/11/28 18:50:09 dawes Exp $ */
 
 /*
  * The interfaces described by this header file are for miscellaneous utilities
@@ -58,7 +58,8 @@
     _XA_TARGETS,
     _XA_TEXT,
     _XA_TIMESTAMP,
-    _XA_USER;
+    _XA_USER,
+    _XA_UTF8_STRING;
 
 #define XA_ATOM_PAIR(d)		XmuInternAtom(d, _XA_ATOM_PAIR)
 #define XA_CHARACTER_POSITION(d) XmuInternAtom(d, _XA_CHARACTER_POSITION)
@@ -82,6 +83,7 @@
 #define XA_TEXT(d)		XmuInternAtom(d, _XA_TEXT)
 #define XA_TIMESTAMP(d)		XmuInternAtom(d, _XA_TIMESTAMP)
 #define XA_USER(d)		XmuInternAtom(d, _XA_USER)
+#define XA_UTF8_STRING(d)	XmuInternAtom(d, _XA_UTF8_STRING)
 
 _XFUNCPROTOBEGIN
 
Index: xc/lib/Xmu/CvtStdSel.c
diff -u xc/lib/Xmu/CvtStdSel.c:3.13 xc/lib/Xmu/CvtStdSel.c:3.14
--- xc/lib/Xmu/CvtStdSel.c:3.13	Sun Mar 21 02:34:36 1999
+++ xc/lib/Xmu/CvtStdSel.c	Mon Nov  6 14:24:02 2000
@@ -21,7 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/Xmu/CvtStdSel.c,v 3.13 1999/03/21 07:34:36 dawes Exp $ */
+/* $XFree86: xc/lib/Xmu/CvtStdSel.c,v 3.14 2000/11/06 19:24:02 dawes Exp $ */
 
 /*
  * This file contains routines to handle common selection targets.
@@ -83,6 +83,9 @@
 #ifdef ultrix
 #define USE_UNAME
 #endif
+#ifdef CSRG_BASED
+#define USE_UNAME
+#endif
 #endif /*X_OS_FILE*/
 #ifdef USE_UNAME
 #ifdef ultrix
@@ -154,7 +157,7 @@
 #ifdef sun
 	return XtNewString("SunOS");
 #else
-# if !defined(SYSV) && defined(unix)
+# if !defined(SYSV) && (defined(CSRG_BASED) || defined(unix))
 	return XtNewString("BSD");
 # else
 	return NULL;
Index: xc/lib/Xmu/EditresCom.c
diff -u xc/lib/Xmu/EditresCom.c:1.12 xc/lib/Xmu/EditresCom.c:1.14
--- xc/lib/Xmu/EditresCom.c:1.12	Sun Dec 26 19:39:24 1999
+++ xc/lib/Xmu/EditresCom.c	Sun Oct  1 22:32:13 2000
@@ -21,7 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/Xmu/EditresCom.c,v 1.12 1999/12/27 00:39:24 robin Exp $ */
+/* $XFree86: xc/lib/Xmu/EditresCom.c,v 1.14 2000/10/02 02:32:13 tsi Exp $ */
 
 /*
  * Author:  Chris D. Peterson, Dave Sternlicht, MIT X Consortium
@@ -694,7 +694,7 @@
 static int
 qcmp_widget_list(register _Xconst void *left, register _Xconst void *right)
 { 
-  return ((int)*(Widget **)left - (int)*(Widget **)right);
+  return (char *)*(Widget **)left - (char *)*(Widget **)right;
 }
 
 /*
Index: xc/lib/Xmu/Xmu-def.cpp
diff -u /dev/null xc/lib/Xmu/Xmu-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:25:00 2000
+++ xc/lib/Xmu/Xmu-def.cpp	Wed Aug  9 19:40:13 2000
@@ -0,0 +1,100 @@
+LIBRARY libXmu
+VERSION LIBRARY_VERSION
+EXPORTS
+XmuAllStandardColormaps
+XmuGetAtomName
+XmuInternAtom
+XmuInternStrings
+XmuMakeAtom
+XmuNameOfAtom
+XmuClientWindow
+XmuAddCloseDisplayHook
+XmuLookupCloseDisplayHook
+XmuRemoveCloseDisplayHook
+XmuGetColormapAllocation
+XmuCreateColormap
+XmuCreatePixmapFromBitmap
+XmuCursorNameToIndex
+_XmuCCLookupDisplay
+XmuConvertStandardSelection
+XmuPrintDefaultErrorMessage
+XmuSimpleErrorHandler
+XmuDeleteStandardColormap
+XmuDQAddDisplay
+XmuDQCreate
+XmuDQDestroy
+XmuDQLookupDisplay
+XmuDQRemoveDisplay
+XmuDistinguishableColors
+XmuDistinguishablePixels
+XmuDrawLogo
+XmuDrawRoundedRectangle
+XmuFillRoundedRectangle
+_XEditResCheckMessages
+_XEditResGet16
+_XEditResGet32
+_XEditResGet8
+_XEditResGetSigned16
+_XEditResGetString8
+_XEditResGetWidgetInfo
+_XEditResPut16
+_XEditResPut32
+_XEditResPut8
+_XEditResPutString8
+_XEditResPutWidgetInfo
+_XEditResResetStream
+XmuRegisterExternalAgent
+XmuCvtFunctionToCallback
+XmuGetHostname
+XmuCreateStippledPixmap
+XmuReleaseStippledPixmap
+XmuAddInitializer
+XmuCallInitializers
+XmuLocateBitmapFile
+XmuLocatePixmapFile
+_XmuStringToBitmapFreeCache
+_XmuStringToBitmapInitCache
+XmuLookupAPL
+XmuLookupArabic
+XmuLookupCyrillic
+XmuLookupGreek
+XmuLookupHebrew
+XmuLookupJISX0201
+XmuLookupKana
+XmuLookupLatin1
+XmuLookupLatin2
+XmuLookupLatin3
+XmuLookupLatin4
+XmuLookupString
+XmuLookupStandardColormap
+XmuCompareISOLatin1
+XmuCopyISOLatin1Lowered
+XmuCopyISOLatin1Uppered
+XmuReadBitmapData
+XmuReadBitmapDataFromFile
+XmuScreenOfWindow
+XmuReshapeWidget
+XmuStandardColormap
+XmuCvtStringToBackingStore
+XmuCvtStringToBitmap
+XmuCvtStringToColorCursor
+XmuCvtStringToCursor
+XmuCvtStringToGravity
+XmuCvtStringToJustify
+XmuCvtStringToLong
+XmuCvtStringToOrientation
+XmuCvtStringToShapeStyle
+XmuCvtStringToWidget
+XmuNewCvtStringToWidget
+XmuUpdateMapHints
+XmuVisualStandardColormaps
+XmuWnCountOwnedResources
+XmuWnFetchResources
+XmuWnInitializeNodes
+XmuWnNameToNode
+XctCreate
+XctFree
+XctNextItem
+XctReset
+
+/* $XFree86: xc/lib/Xmu/Xmu-def.cpp,v 1.1 2000/08/09 23:40:13 dawes Exp $ */
Index: xc/lib/Xmu/sharedlib.c
diff -u xc/lib/Xmu/sharedlib.c:3.1 xc/lib/Xmu/sharedlib.c:3.2
--- xc/lib/Xmu/sharedlib.c:3.1	Sat Oct  3 05:06:39 1998
+++ xc/lib/Xmu/sharedlib.c	Tue Nov 28 13:50:10 2000
@@ -21,6 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
+/* $XFree86: xc/lib/Xmu/sharedlib.c,v 3.2 2000/11/28 18:50:10 dawes Exp $ */
 
 #if defined(SUNSHLIB) && !defined(SHAREDCODE)
 
@@ -63,5 +64,6 @@
 DeclareAtom(XA_TEXT)
 DeclareAtom(XA_TIMESTAMP)
 DeclareAtom(XA_USER)
+DeclareAtom(XA_UTF8_STRING)
 
 #endif /* SUNSHLIB */
Index: xc/lib/Xp/Xp-def.cpp
diff -u xc/lib/Xp/Xp-def.cpp:1.1.1.1 xc/lib/Xp/Xp-def.cpp:1.2
--- xc/lib/Xp/Xp-def.cpp:1.1.1.1	Sat Dec 21 22:29:30 1996
+++ xc/lib/Xp/Xp-def.cpp	Wed Aug  9 19:40:13 2000
@@ -33,8 +33,10 @@
  XpSendOneTicket
  XpSetAttributes
  XpSetContext
+ XpSetImageResolution
  XpSetLocaleHinter
  XpStartDoc
  XpStartJob
  XpStartPage
 /* $XConsortium: Xp-def.cpp /main/1 1996/11/13 14:44:46 lehors $ */
+/* $XFree86: xc/lib/Xp/Xp-def.cpp,v 1.2 2000/08/09 23:40:13 dawes Exp $ */
Index: xc/lib/Xp/XpAttr.c
diff -u xc/lib/Xp/XpAttr.c:1.4 xc/lib/Xp/XpAttr.c:1.5
--- xc/lib/Xp/XpAttr.c:1.4	Tue Jan 25 13:37:31 2000
+++ xc/lib/Xp/XpAttr.c	Tue Sep 26 11:56:57 2000
@@ -34,13 +34,13 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpAttr.c,v 1.4 2000/01/25 18:37:31 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpAttr.c,v 1.5 2000/09/26 15:56:57 tsi Exp $ */
 
 #define NEED_REPLIES
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 #define _XpPadOut(len) (((len) + 3) & ~3)
 
Index: xc/lib/Xp/XpContext.c
diff -u xc/lib/Xp/XpContext.c:1.3 xc/lib/Xp/XpContext.c:1.4
--- xc/lib/Xp/XpContext.c:1.3	Tue Jan 25 13:37:32 2000
+++ xc/lib/Xp/XpContext.c	Tue Sep 26 11:56:57 2000
@@ -34,13 +34,13 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpContext.c,v 1.3 2000/01/25 18:37:32 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpContext.c,v 1.4 2000/09/26 15:56:57 tsi Exp $ */
 
 #define NEED_REPLIES
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 #define _XpPadOut(len) (((len) + 3) & ~3)
 
Index: xc/lib/Xp/XpDoc.c
diff -u xc/lib/Xp/XpDoc.c:1.1.1.1 xc/lib/Xp/XpDoc.c:1.2
--- xc/lib/Xp/XpDoc.c:1.1.1.1	Sat Dec 21 22:29:29 1996
+++ xc/lib/Xp/XpDoc.c	Tue Sep 26 11:56:57 2000
@@ -34,10 +34,11 @@
  **
  ******************************************************************************
  *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpDoc.c,v 1.2 2000/09/26 15:56:57 tsi Exp $ */
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 typedef struct {
     int event_base_return;
Index: xc/lib/Xp/XpExtUtil.c
diff -u xc/lib/Xp/XpExtUtil.c:1.2 xc/lib/Xp/XpExtUtil.c:1.3
--- xc/lib/Xp/XpExtUtil.c:1.2	Tue Jan 25 13:37:32 2000
+++ xc/lib/Xp/XpExtUtil.c	Tue Sep 26 11:56:57 2000
@@ -34,14 +34,14 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpExtUtil.c,v 1.2 2000/01/25 18:37:32 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpExtUtil.c,v 1.3 2000/09/26 15:56:57 tsi Exp $ */
 
 #define NEED_EVENTS
 #define NEED_REPLIES
 #include <stdio.h>
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 #include <X11/Xos.h>
 
 #define ENQUEUE_EVENT   True
Index: xc/lib/Xp/XpExtUtil.h
diff -u /dev/null xc/lib/Xp/XpExtUtil.h:1.1
--- /dev/null	Mon Dec 18 14:25:04 2000
+++ xc/lib/Xp/XpExtUtil.h	Tue Sep 26 11:56:57 2000
@@ -0,0 +1,35 @@
+/* $XFree86: xc/lib/Xp/XpExtUtil.h,v 1.1 2000/09/26 15:56:57 tsi Exp $ */
+/*
+ * Copyright (C) 2000 The XFree86 Project, Inc.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ */
+
+#ifndef _XPEXTUTIL_H
+#define _XPEXTUTIL_H 1
+
+#include "extutil.h"
+
+extern XEXT_FIND_DISPLAY_PROTO(xp_find_display);
+
+#endif /* _XPEXTUTIL_H */
Index: xc/lib/Xp/XpExtVer.c
diff -u xc/lib/Xp/XpExtVer.c:1.2 xc/lib/Xp/XpExtVer.c:1.3
--- xc/lib/Xp/XpExtVer.c:1.2	Tue Jan 25 13:37:32 2000
+++ xc/lib/Xp/XpExtVer.c	Tue Sep 26 11:56:57 2000
@@ -34,13 +34,13 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpExtVer.c,v 1.2 2000/01/25 18:37:32 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpExtVer.c,v 1.3 2000/09/26 15:56:57 tsi Exp $ */
 
 #define NEED_REPLIES
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 
 Bool
Index: xc/lib/Xp/XpGetData.c
diff -u xc/lib/Xp/XpGetData.c:1.2 xc/lib/Xp/XpGetData.c:1.3
--- xc/lib/Xp/XpGetData.c:1.2	Tue Jan 25 13:37:33 2000
+++ xc/lib/Xp/XpGetData.c	Tue Sep 26 11:56:57 2000
@@ -34,13 +34,13 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpGetData.c,v 1.2 2000/01/25 18:37:33 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpGetData.c,v 1.3 2000/09/26 15:56:57 tsi Exp $ */
 
 #define NEED_REPLIES
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 #define MAX_XP_BUFFER_SIZE 32768
 
Index: xc/lib/Xp/XpImageRes.c
diff -u xc/lib/Xp/XpImageRes.c:1.2 xc/lib/Xp/XpImageRes.c:1.3
--- xc/lib/Xp/XpImageRes.c:1.2	Tue Jan 25 13:37:33 2000
+++ xc/lib/Xp/XpImageRes.c	Tue Sep 26 11:56:57 2000
@@ -34,14 +34,14 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpImageRes.c,v 1.2 2000/01/25 18:37:33 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpImageRes.c,v 1.3 2000/09/26 15:56:57 tsi Exp $ */
 
 
 #define NEED_REPLIES
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 
 Bool
Index: xc/lib/Xp/XpInput.c
diff -u xc/lib/Xp/XpInput.c:1.2 xc/lib/Xp/XpInput.c:1.3
--- xc/lib/Xp/XpInput.c:1.2	Tue Jan 25 13:37:33 2000
+++ xc/lib/Xp/XpInput.c	Tue Sep 26 11:56:57 2000
@@ -34,13 +34,13 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpInput.c,v 1.2 2000/01/25 18:37:33 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpInput.c,v 1.3 2000/09/26 15:56:57 tsi Exp $ */
 
 #define NEED_REPLIES
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 
 void
Index: xc/lib/Xp/XpJob.c
diff -u xc/lib/Xp/XpJob.c:1.2 xc/lib/Xp/XpJob.c:1.3
--- xc/lib/Xp/XpJob.c:1.2	Sun Jan 12 05:39:56 1997
+++ xc/lib/Xp/XpJob.c	Tue Sep 26 11:56:57 2000
@@ -34,7 +34,7 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpJob.c,v 1.2 1997/01/12 10:39:56 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpJob.c,v 1.3 2000/09/26 15:56:57 tsi Exp $ */
 
 #if defined(sun) && defined(i386) && defined(SVR4)
 #define __EXTENSIONS__
@@ -43,7 +43,7 @@
 #include "Printstr.h"
 #include "Xlibint.h"
 #include "X11/Xos.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 #include <limits.h>
 #ifndef WIN32
 #define X_INCLUDE_PWD_H
Index: xc/lib/Xp/XpLocale.c
diff -u xc/lib/Xp/XpLocale.c:1.2 xc/lib/Xp/XpLocale.c:1.3
--- xc/lib/Xp/XpLocale.c:1.2	Sat May 31 09:51:17 1997
+++ xc/lib/Xp/XpLocale.c	Tue Sep 26 11:56:58 2000
@@ -34,10 +34,11 @@
  **
  ******************************************************************************
  *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpLocale.c,v 1.3 2000/09/26 15:56:58 tsi Exp $ */
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 #include <X11/Xlocale.h>
 
Index: xc/lib/Xp/XpPage.c
diff -u xc/lib/Xp/XpPage.c:1.1.1.1 xc/lib/Xp/XpPage.c:1.2
--- xc/lib/Xp/XpPage.c:1.1.1.1	Sat Dec 21 22:29:30 1996
+++ xc/lib/Xp/XpPage.c	Tue Sep 26 11:56:58 2000
@@ -34,10 +34,11 @@
  **
  ******************************************************************************
  *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpPage.c,v 1.2 2000/09/26 15:56:58 tsi Exp $ */
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 
 typedef struct {
Index: xc/lib/Xp/XpPageDim.c
diff -u xc/lib/Xp/XpPageDim.c:1.2 xc/lib/Xp/XpPageDim.c:1.3
--- xc/lib/Xp/XpPageDim.c:1.2	Tue Jan 25 13:37:34 2000
+++ xc/lib/Xp/XpPageDim.c	Tue Sep 26 11:56:58 2000
@@ -34,14 +34,13 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpPageDim.c,v 1.2 2000/01/25 18:37:34 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpPageDim.c,v 1.3 2000/09/26 15:56:58 tsi Exp $ */
 
-
 #define NEED_REPLIES
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 
 Status
Index: xc/lib/Xp/XpPrinter.c
diff -u xc/lib/Xp/XpPrinter.c:1.5 xc/lib/Xp/XpPrinter.c:1.6
--- xc/lib/Xp/XpPrinter.c:1.5	Tue Jan 25 13:37:34 2000
+++ xc/lib/Xp/XpPrinter.c	Tue Sep 26 11:56:58 2000
@@ -34,13 +34,13 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpPrinter.c,v 1.5 2000/01/25 18:37:34 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpPrinter.c,v 1.6 2000/09/26 15:56:58 tsi Exp $ */
 
 #define NEED_REPLIES
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 #define _XpPadOut(len) (((len) + 3) & ~3)
 
@@ -147,7 +147,7 @@
 	    /*
 	     * Pull printer length and then name.
 	     */
-	    _XRead32 (dpy, (char *) &dataLenVR, (long) sizeof(dataLenVR) );
+	    _XRead32 (dpy, (long *) &dataLenVR, (long) sizeof(dataLenVR) );
 
 	    if (dataLenVR) {
 		dataVR = (CARD8 *) Xmalloc( (unsigned) dataLenVR + 1 );
@@ -169,7 +169,7 @@
 	    /*
 	     * Pull localized description length and then description.
 	     */
-	    _XRead32 (dpy, (char *) &dataLenVR, (long) sizeof(dataLenVR) );
+	    _XRead32 (dpy, (long *) &dataLenVR, (long) sizeof(dataLenVR) );
 
 	    if (dataLenVR) {
 		dataVR = (CARD8 *) Xmalloc( (unsigned) dataLenVR + 1 );
Index: xc/lib/Xp/XpPutData.c
diff -u xc/lib/Xp/XpPutData.c:1.1.1.1 xc/lib/Xp/XpPutData.c:1.2
--- xc/lib/Xp/XpPutData.c:1.1.1.1	Sat Dec 21 22:29:30 1996
+++ xc/lib/Xp/XpPutData.c	Tue Sep 26 11:56:58 2000
@@ -34,11 +34,11 @@
  **
  ******************************************************************************
  *****************************************************************************/
+/* $XFree86: xc/lib/Xp/XpPutData.c,v 1.2 2000/09/26 15:56:58 tsi Exp $ */
 
-
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 #define _XpPadOut(len) (((len) + 3) & ~3)
 
Index: xc/lib/Xp/XpScreens.c
diff -u xc/lib/Xp/XpScreens.c:1.2 xc/lib/Xp/XpScreens.c:1.3
--- xc/lib/Xp/XpScreens.c:1.2	Tue Jan 25 13:37:34 2000
+++ xc/lib/Xp/XpScreens.c	Tue Sep 26 11:56:58 2000
@@ -34,13 +34,13 @@
  **
  ******************************************************************************
  *****************************************************************************/
-/* $XFree86: xc/lib/Xp/XpScreens.c,v 1.2 2000/01/25 18:37:34 dawes Exp $ */
+/* $XFree86: xc/lib/Xp/XpScreens.c,v 1.3 2000/09/26 15:56:58 tsi Exp $ */
 
 #define NEED_REPLIES
 
 #include "Printstr.h"
 #include "Xlibint.h"
-#include "extutil.h"
+#include "XpExtUtil.h"
 
 
 Screen **
@@ -94,7 +94,7 @@
 	    /*
 	     * Pull printer length and then name.
 	     */
-	    _XRead32 (dpy, (char *) &rootWindow, (long) sizeof(rootWindow) );
+	    _XRead32 (dpy, (long *) &rootWindow, (long) sizeof(rootWindow) );
 
 	    for ( j = 0; j < XScreenCount(dpy); j++ ) {
 		checkScr = XScreenOfDisplay(dpy, j);
Index: xc/lib/Xpm/Imakefile
diff -u xc/lib/Xpm/Imakefile:1.2 xc/lib/Xpm/Imakefile:1.3
--- xc/lib/Xpm/Imakefile:1.2	Sun Jan 31 07:21:22 1999
+++ xc/lib/Xpm/Imakefile	Tue Sep 19 08:46:06 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/Xpm/Imakefile,v 1.2 1999/01/31 12:21:22 dawes Exp $
+XCOMM $XFree86: xc/lib/Xpm/Imakefile,v 1.3 2000/09/19 12:46:06 eich Exp $
 
 /* This is a simplified version of the standard Xpm Imakefile */
 
@@ -22,8 +22,13 @@
  * if your system doesn't provide pipe add -DNO_ZPIPE
  * if on your system sprintf doesn't return the number of bytes transmitted
  * add -DVOID_SPRINTF
+ * if you want xpm to try name.xpm.Z and name.xpm.gz when asked to read
+ * name.xpm , add -DSTAT_ZFILE
  */
 
+#if defined(LinuxArchitecture)
+ZFILEDEF = -DSTAT_ZFILE
+#endif
 #if defined(UltrixArchitecture) || \
     (defined(MipsArchitecture) && !defined(SGIArchitecture))
 STRDUPDEF = -DNEED_STRDUP
@@ -41,7 +46,7 @@
 ZPIPEDEF = -DNO_ZPIPE
 #endif
 
-DEFINES = $(STRDUPDEF) $(STRCASECMPDEF) $(SPRINTFDEF) $(ZPIPEDEF)
+DEFINES = $(STRDUPDEF) $(STRCASECMPDEF) $(SPRINTFDEF) $(ZPIPEDEF) $(ZFILEDEF)
 
 HEADERS = xpm.h
 
Index: xc/lib/Xpm/Xpm-def.cpp
diff -u /dev/null xc/lib/Xpm/Xpm-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:25:11 2000
+++ xc/lib/Xpm/Xpm-def.cpp	Wed Aug  9 19:40:13 2000
@@ -0,0 +1,39 @@
+LIBRARY Xpm
+VERSION LIBRARY_VERSION
+EXPORTS
+ XpmAttributesSize
+ XpmCreateBufferFromImage
+ XpmCreateBufferFromPixmap
+ XpmCreateBufferFromXpmImage
+ XpmCreateDataFromImage
+ XpmCreateDataFromPixmap
+ XpmCreateDataFromXpmImage
+ XpmCreateImageFromBuffer
+ XpmCreateImageFromData
+ XpmCreateImageFromXpmImage
+ XpmCreatePixmapFromBuffer
+ XpmCreatePixmapFromData
+ XpmCreatePixmapFromXpmImage
+ XpmCreateXpmImageFromBuffer
+ XpmCreateXpmImageFromData
+ XpmCreateXpmImageFromImage
+ XpmCreateXpmImageFromPixmap
+ XpmFree
+ XpmFreeAttributes
+ XpmFreeExtensions
+ XpmFreeXpmImage
+ XpmFreeXpmInfo
+ XpmGetErrorString
+ XpmLibraryVersion
+ XpmReadFileToBuffer
+ XpmReadFileToData
+ XpmReadFileToImage
+ XpmReadFileToPixmap
+ XpmReadFileToXpmImage
+ XpmWriteFileFromBuffer
+ XpmWriteFileFromData
+ XpmWriteFileFromImage
+ XpmWriteFileFromPixmap
+ XpmWriteFileFromXpmImage
+
+/* $XFree86: xc/lib/Xpm/Xpm-def.cpp,v 1.1 2000/08/09 23:40:13 dawes Exp $ */
Index: xc/lib/Xrender/Composite.c
diff -u /dev/null xc/lib/Xrender/Composite.c:1.2
--- /dev/null	Mon Dec 18 14:25:13 2000
+++ xc/lib/Xrender/Composite.c	Sun Aug 27 22:43:13 2000
@@ -0,0 +1,65 @@
+/*
+ * $XFree86: xc/lib/Xrender/Composite.c,v 1.2 2000/08/28 02:43:13 tsi Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "Xrenderint.h"
+
+void
+XRenderComposite (Display   *dpy,
+		  int	    op,
+		  Picture   src,
+		  Picture   mask,
+		  Picture   dst,
+		  int	    src_x,
+		  int	    src_y,
+		  int	    mask_x,
+		  int	    mask_y,
+		  int	    dst_x,
+		  int	    dst_y,
+		  unsigned int	width,
+		  unsigned int	height)
+{
+    XExtDisplayInfo         *info = XRenderFindDisplay (dpy);
+    xRenderCompositeReq	    *req;
+
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    GetReq(RenderComposite, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderComposite;
+    req->op = (CARD8) op;
+    req->src = src;
+    req->mask = mask;
+    req->dst = dst;
+    req->xSrc = src_x;
+    req->ySrc = src_y;
+    req->xMask = mask_x;
+    req->yMask = mask_y;
+    req->xDst = dst_x;
+    req->yDst = dst_y;
+    req->width = width;
+    req->height = height;
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
Index: xc/lib/Xrender/FillRect.c
diff -u /dev/null xc/lib/Xrender/FillRect.c:1.1
--- /dev/null	Mon Dec 18 14:25:13 2000
+++ xc/lib/Xrender/FillRect.c	Mon Nov 20 02:13:09 2000
@@ -0,0 +1,104 @@
+/*
+ * $XFree86: xc/lib/Xrender/FillRect.c,v 1.1 2000/11/20 07:13:09 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "Xrenderint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
+
+void
+XRenderFillRectangle (Display	    *dpy,
+		      int	    op,
+		      Picture	    dst,
+		      XRenderColor  *color,
+		      int	    x,
+		      int	    y,
+		      unsigned int  width,
+		      unsigned int  height)
+{
+    XExtDisplayInfo		*info = XRenderFindDisplay (dpy);
+    xRectangle			*rect;
+    xRenderFillRectanglesReq	*req;
+#ifdef MUSTCOPY
+    xRectangle			rectdata;
+    long			len = SIZEOF(xRectangle);
+
+    rect = &rectdata;
+#endif /* MUSTCOPY */
+
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+
+    req = (xRenderFillRectanglesReq *) dpy->last_req;
+    /* if same as previous request, with same drawable, batch requests */
+    if (req->reqType == info->codes->major_opcode &&
+	req->renderReqType == X_RenderFillRectangles &&
+	req->op == op &&
+	req->dst == dst &&
+	req->color.red == color->red &&
+	req->color.green == color->green &&
+	req->color.blue == color->blue &&
+	req->color.alpha == color->alpha &&
+	dpy->bufptr + SIZEOF(xRectangle) <= dpy->bufmax &&
+	(char *)dpy->bufptr - (char *)req < size)
+    {
+	req->length += SIZEOF(xRectangle) >> 2;
+#ifndef MUSTCOPY
+	rect = (xRectangle *) dpy->bufptr;
+	dpy->bufptr += SIZEOF(xRectangle);
+#endif /* not MUSTCOPY */
+    }
+    else 
+    {
+	GetReqExtra(RenderFillRectangles, SIZEOF(xRectangle), req);
+	
+	req->reqType = info->codes->major_opcode;
+	req->renderReqType = X_RenderFillRectangles;
+	req->op = op;
+	req->dst = dst;
+	req->color.red = color->red;
+	req->color.green = color->green;
+	req->color.blue = color->blue;
+	req->color.alpha = color->alpha;
+	
+#ifdef MUSTCOPY
+	dpy->bufptr -= SIZEOF(xRectangle);
+#else
+	rect = (xRectangle *) NEXTPTR(req,xRenderFillRectanglesReq);
+#endif /* MUSTCOPY */
+    }
+    rect->x = x;
+    rect->y = y;
+    rect->width = width;
+    rect->height = height;
+
+#ifdef MUSTCOPY
+    Data (dpy, (char *) rect, len);
+#endif /* MUSTCOPY */
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
Index: xc/lib/Xrender/FillRects.c
diff -u /dev/null xc/lib/Xrender/FillRects.c:1.1
--- /dev/null	Mon Dec 18 14:25:14 2000
+++ xc/lib/Xrender/FillRects.c	Mon Nov 20 02:13:10 2000
@@ -0,0 +1,77 @@
+/*
+ * $XFree86: xc/lib/Xrender/FillRects.c,v 1.1 2000/11/20 07:13:10 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "Xrenderint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xRenderFillRectanglesReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
+
+void
+XRenderFillRectangles (Display	    *dpy,
+		       int	    op,
+		       Picture	    dst,
+		       XRenderColor *color,
+		       XRectangle   *rectangles,
+		       int	    n_rects)
+{
+    XExtDisplayInfo		*info = XRenderFindDisplay (dpy);
+    xRenderFillRectanglesReq	*req;
+    long			len;
+    int				n;
+
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+
+    while (n_rects) 
+    {
+	GetReq(RenderFillRectangles, req);
+	
+	req->reqType = info->codes->major_opcode;
+	req->renderReqType = X_RenderFillRectangles;
+	req->op = op;
+	req->dst = dst;
+	req->color.red = color->red;
+	req->color.green = color->green;
+	req->color.blue = color->blue;
+	req->color.alpha = color->alpha;
+	
+	n = n_rects;
+	len = ((long)n) << 1;
+	if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) 
+	{
+	    n = (dpy->max_request_size - req->length) >> 1;
+	    len = ((long)n) << 1;
+	}
+	SetReqLen(req, len, len);
+	len <<= 2; /* watch out for macros... */
+	Data16 (dpy, (short *) rectangles, len);
+	n_rects -= n;
+	rectangles += n;
+    }
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
Index: xc/lib/Xrender/Glyph.c
diff -u /dev/null xc/lib/Xrender/Glyph.c:1.5
--- /dev/null	Mon Dec 18 14:25:14 2000
+++ xc/lib/Xrender/Glyph.c	Sat Dec  2 04:38:02 2000
@@ -0,0 +1,376 @@
+/*
+ * $XFree86: xc/lib/Xrender/Glyph.c,v 1.5 2000/12/02 09:38:02 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "Xrenderint.h"
+
+GlyphSet
+XRenderCreateGlyphSet (Display *dpy, XRenderPictFormat *format)
+{
+    XExtDisplayInfo		*info = XRenderFindDisplay (dpy);
+    GlyphSet			gsid;
+    xRenderCreateGlyphSetReq	*req;
+
+    RenderCheckExtension (dpy, info, 0);
+    LockDisplay(dpy);
+    GetReq(RenderCreateGlyphSet, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderCreateGlyphSet;
+    req->gsid = gsid = XAllocID(dpy);
+    req->format = format->id;
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return gsid;
+}
+
+GlyphSet
+XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing)
+{
+    XExtDisplayInfo             *info = XRenderFindDisplay (dpy);
+    GlyphSet                    gsid;
+    xRenderReferenceGlyphSetReq	*req;
+
+    RenderCheckExtension (dpy, info, 0);
+    LockDisplay(dpy);
+    GetReq(RenderReferenceGlyphSet, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderReferenceGlyphSet;
+    req->gsid = gsid = XAllocID(dpy);
+    req->existing = existing;
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return gsid;
+}
+
+void
+XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset)
+{
+    XExtDisplayInfo         *info = XRenderFindDisplay (dpy);
+    xRenderFreeGlyphSetReq  *req;
+
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    GetReq(RenderFreeGlyphSet, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderFreeGlyphSet;
+    req->glyphset = glyphset;
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
+void
+XRenderAddGlyphs (Display	*dpy,
+		  GlyphSet	glyphset,
+		  Glyph		*gids,
+		  XGlyphInfo	*glyphs,
+		  int		nglyphs,
+		  char		*images,
+		  int		nbyte_images)
+{
+    XExtDisplayInfo         *info = XRenderFindDisplay (dpy);
+    xRenderAddGlyphsReq	    *req;
+    long		    len;
+
+    if (nbyte_images & 3)
+	nbyte_images += 4 - (nbyte_images & 3);
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    GetReq(RenderAddGlyphs, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderAddGlyphs;
+    req->glyphset = glyphset;
+    req->nglyphs = nglyphs;
+    len = (nglyphs * (SIZEOF (xGlyphInfo) + 4) + nbyte_images) >> 2;
+    SetReqLen(req, len, len);
+    Data32 (dpy, (long *) gids, nglyphs * 4);
+    Data16 (dpy, (short *) glyphs, nglyphs * SIZEOF (xGlyphInfo));
+    Data (dpy, images, nbyte_images);
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
+void
+XRenderFreeGlyphs (Display   *dpy,
+		   GlyphSet  glyphset,
+		   Glyph     *gids,
+		   int       nglyphs)
+{
+    XExtDisplayInfo         *info = XRenderFindDisplay (dpy);
+    xRenderFreeGlyphsReq    *req;
+    long                    len;
+
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    GetReq(RenderFreeGlyphs, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderFreeGlyphs;
+    len = nglyphs;
+    SetReqLen(req, len, len);
+    len <<= 2;
+    Data32 (dpy, (long *) gids, len);
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+	   
+void
+XRenderCompositeString8 (Display	    *dpy,
+			 int		    op,
+			 Picture	    src,
+			 Picture	    dst,
+			 XRenderPictFormat  *maskFormat,
+			 GlyphSet	    glyphset,
+			 int		    xSrc,
+			 int		    ySrc,
+			 int		    xDst,
+			 int		    yDst,
+			 char		    *string,
+			 int		    nchar)
+{
+    XExtDisplayInfo		*info = XRenderFindDisplay (dpy);
+    xRenderCompositeGlyphs8Req	*req;
+    long			len;
+    xGlyphElt			*elt;
+    int				nbytes;
+
+    if (!nchar)
+	return;
+    
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+
+    GetReq(RenderCompositeGlyphs8, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderCompositeGlyphs8;
+    req->op = op;
+    req->src = src;
+    req->dst = dst;
+    req->maskFormat = maskFormat ? maskFormat->id : None;
+    req->glyphset = glyphset;
+    req->xSrc = xSrc;
+    req->ySrc = ySrc;    
+
+    /*
+     * xGlyphElt must be aligned on a 32-bit boundary; this is
+     * easily done by filling no more than 252 glyphs in each
+     * bucket
+     */
+    
+#define MAX_8 252
+
+    len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar;
+    
+    req->length += (len + 3)>>2;  /* convert to number of 32-bit words */
+    
+    /* 
+     * If the entire request does not fit into the remaining space in the
+     * buffer, flush the buffer first.
+     */
+
+    if (dpy->bufptr + len > dpy->bufmax)
+    	_XFlush (dpy);
+
+    while(nchar > MAX_8)
+    {
+	nbytes = MAX_8 + SIZEOF(xGlyphElt);
+	BufAlloc (xGlyphElt *, elt, nbytes);
+	elt->len = MAX_8;
+	elt->deltax = xDst;
+	elt->deltay = yDst;
+	xDst = 0;
+	yDst = 0;
+	memcpy ((char *) (elt + 1), string, MAX_8);
+	nchar = nchar - MAX_8;
+	string += MAX_8;
+    }
+	
+    if (nchar)
+    {
+	nbytes = (nchar + SIZEOF(xGlyphElt) + 3) & ~3;
+	BufAlloc (xGlyphElt *, elt, nbytes); 
+	elt->len = nchar;
+	elt->deltax = xDst;
+	elt->deltay = yDst;
+	memcpy ((char *) (elt + 1), string, nchar);
+    }
+    
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+void
+XRenderCompositeString16 (Display	    *dpy,
+			  int		    op,
+			  Picture	    src,
+			  Picture	    dst,
+			  XRenderPictFormat *maskFormat,
+			  GlyphSet	    glyphset,
+			  int		    xSrc,
+			  int		    ySrc,
+			  int		    xDst,
+			  int		    yDst,
+			  unsigned short    *string,
+			  int		    nchar)
+{
+    XExtDisplayInfo		*info = XRenderFindDisplay (dpy);
+    xRenderCompositeGlyphs8Req	*req;
+    long			len;
+    xGlyphElt			*elt;
+    int				nbytes;
+
+    if (!nchar)
+	return;
+    
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    
+    GetReq(RenderCompositeGlyphs16, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderCompositeGlyphs16;
+    req->op = op;
+    req->src = src;
+    req->dst = dst;
+    req->maskFormat = maskFormat ? maskFormat->id : None;
+    req->glyphset = glyphset;
+    req->xSrc = xSrc;
+    req->ySrc = ySrc;    
+
+#define MAX_16	254
+
+    len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar * 2;
+    
+    req->length += (len + 3)>>2;  /* convert to number of 32-bit words */
+    
+    /* 
+     * If the entire request does not fit into the remaining space in the
+     * buffer, flush the buffer first.
+     */
+
+    if (dpy->bufptr + len > dpy->bufmax)
+    	_XFlush (dpy);
+
+    while(nchar > MAX_16)
+    {
+	nbytes = MAX_16 * 2 + SIZEOF(xGlyphElt);
+	BufAlloc (xGlyphElt *, elt, nbytes);
+	elt->len = MAX_16;
+	elt->deltax = xDst;
+	elt->deltay = yDst;
+	xDst = 0;
+	yDst = 0;
+	memcpy ((char *) (elt + 1), (char *) string, MAX_16 * 2);
+	nchar = nchar - MAX_16;
+	string += MAX_16;
+    }
+	
+    if (nchar)
+    {
+	nbytes = (nchar * 2 + SIZEOF(xGlyphElt) + 3) & ~3;
+	BufAlloc (xGlyphElt *, elt, nbytes); 
+	elt->len = nchar;
+	elt->deltax = xDst;
+	elt->deltay = yDst;
+	memcpy ((char *) (elt + 1), (char *) string, nchar * 2);
+    }
+    
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
+void
+XRenderCompositeString32 (Display	    *dpy,
+			  int		    op,
+			  Picture	    src,
+			  Picture	    dst,
+			  XRenderPictFormat  *maskFormat,
+			  GlyphSet	    glyphset,
+			  int		    xSrc,
+			  int		    ySrc,
+			  int		    xDst,
+			  int		    yDst,
+			  unsigned int	    *string,
+			  int		    nchar)
+{
+    XExtDisplayInfo		*info = XRenderFindDisplay (dpy);
+    xRenderCompositeGlyphs8Req	*req;
+    long			len;
+    xGlyphElt			*elt;
+    int				nbytes;
+
+    if (!nchar)
+	return;
+    
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    
+    GetReq(RenderCompositeGlyphs32, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderCompositeGlyphs32;
+    req->op = op;
+    req->src = src;
+    req->dst = dst;
+    req->maskFormat = maskFormat ? maskFormat->id : None;
+    req->glyphset = glyphset;
+    req->xSrc = xSrc;
+    req->ySrc = ySrc;    
+
+#define MAX_32	254
+
+    len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar * 4;
+    
+    req->length += (len + 3)>>2;  /* convert to number of 32-bit words */
+    
+    /* 
+     * If the entire request does not fit into the remaining space in the
+     * buffer, flush the buffer first.
+     */
+
+    if (dpy->bufptr + len > dpy->bufmax)
+    	_XFlush (dpy);
+
+    while(nchar > MAX_32)
+    {
+	nbytes = MAX_32 * 4 + SIZEOF(xGlyphElt);
+	BufAlloc (xGlyphElt *, elt, nbytes);
+	elt->len = MAX_32;
+	elt->deltax = xDst;
+	elt->deltay = yDst;
+	xDst = 0;
+	yDst = 0;
+	memcpy ((char *) (elt + 1), (char *) string, MAX_32 * 4);
+	nchar = nchar - MAX_32;
+	string += MAX_32;
+    }
+	
+    if (nchar)
+    {
+	nbytes = nchar * 4 + SIZEOF(xGlyphElt);
+	BufAlloc (xGlyphElt *, elt, nbytes); 
+	elt->len = nchar;
+	elt->deltax = xDst;
+	elt->deltay = yDst;
+	memcpy ((char *) (elt + 1), (char *) string, nchar * 4);
+    }
+    
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
Index: xc/lib/Xrender/Imakefile
diff -u /dev/null xc/lib/Xrender/Imakefile:1.3
--- /dev/null	Mon Dec 18 14:25:15 2000
+++ xc/lib/Xrender/Imakefile	Mon Nov 20 02:13:11 2000
@@ -0,0 +1,46 @@
+XCOMM $XFree86: xc/lib/Xrender/Imakefile,v 1.3 2000/11/20 07:13:11 keithp Exp $
+
+
+#define DoNormalLib NormalLibXrender
+#define DoSharedLib SharedLibXrender
+#define DoDebugLib DebugLibXrender
+#define DoProfileLib ProfileLibXrender
+#define LibName Xrender
+#define SoRev SOXRENDERREV
+#define IncSubdir X11
+#define IncSubSubdir extensions
+
+#include <Threads.tmpl>
+
+#ifdef SharedXrenderReqs
+REQUIREDLIBS = SharedXrenderReqs
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+      DEFINES = $(ALLOC_DEFINES)
+     INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC)
+     
+         SRCS = Xrender.c \
+	 	Composite.c \
+		Glyph.c \
+		Picture.c \
+		FillRect.c \
+		FillRects.c
+		
+         OBJS = Xrender.o \
+	 	Composite.o \
+		Glyph.o \
+		Picture.o \
+		FillRect.o \
+		FillRects.o
+
+     LINTLIBS = $(LINTXLIB)
+
+HEADERS = Xrender.h
+
+#include <Library.tmpl>
+
+DependTarget()
Index: xc/lib/Xrender/Picture.c
diff -u /dev/null xc/lib/Xrender/Picture.c:1.7
--- /dev/null	Mon Dec 18 14:25:15 2000
+++ xc/lib/Xrender/Picture.c	Thu Dec  7 18:55:56 2000
@@ -0,0 +1,213 @@
+/*
+ * $XFree86: xc/lib/Xrender/Picture.c,v 1.7 2000/12/07 23:55:56 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "Xrenderint.h"
+#include "region.h"
+
+static void
+_XRenderProcessPictureAttributes (Display		    *dpy,
+				  xRenderChangePictureReq   *req,
+				  unsigned long		    valuemask,
+				  XRenderPictureAttributes  *attributes)
+{
+    unsigned long values[32];
+    register unsigned long *value = values;
+    unsigned int nvalues;
+    
+    if (valuemask & CPRepeat)
+	*value++ = attributes->repeat;
+    if (valuemask & CPAlphaMap)
+	*value++ = attributes->alpha_map;
+    if (valuemask & CPAlphaXOrigin)
+	*value++ = attributes->alpha_x_origin;
+    if (valuemask & CPAlphaYOrigin)
+	*value++ = attributes->alpha_y_origin;
+    if (valuemask & CPClipXOrigin)
+	*value++ = attributes->clip_x_origin;
+    if (valuemask & CPClipYOrigin)
+	*value++ = attributes->clip_y_origin;
+    if (valuemask & CPClipMask)
+	*value++ = attributes->clip_mask;
+    if (valuemask & CPGraphicsExposure)
+	*value++ = attributes->graphics_exposures;
+    if (valuemask & CPSubwindowMode)
+	*value++ = attributes->subwindow_mode;
+    if (valuemask & CPPolyEdge)
+	*value++ = attributes->poly_edge;
+    if (valuemask & CPPolyMode)
+	*value++ = attributes->poly_mode;
+    if (valuemask & CPDither)
+	*value++ = attributes->dither;
+    if (valuemask & CPComponentAlpha)
+	*value++ = attributes->component_alpha;
+
+    req->length += (nvalues = value - values);
+
+    nvalues <<= 2;			    /* watch out for macros... */
+    Data32 (dpy, (long *) values, (long)nvalues);
+}
+
+Picture
+XRenderCreatePicture (Display			*dpy,
+		      Drawable			drawable,
+		      XRenderPictFormat		*format,
+		      unsigned long		valuemask,
+		      XRenderPictureAttributes	*attributes)
+{
+    XExtDisplayInfo	    *info = XRenderFindDisplay (dpy);
+    Picture		    pid;
+    xRenderCreatePictureReq *req;
+
+    RenderCheckExtension (dpy, info, 0);
+    LockDisplay(dpy);
+    GetReq(RenderCreatePicture, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderCreatePicture;
+    req->pid = pid = XAllocID(dpy);
+    req->drawable = drawable;
+    req->format = format->id;
+    if ((req->mask = valuemask))
+	_XRenderProcessPictureAttributes (dpy,
+					  (xRenderChangePictureReq *) req,
+					  valuemask,
+					  attributes);
+    UnlockDisplay(dpy);
+    SyncHandle();
+    return pid;
+}
+
+void
+XRenderChangePicture (Display                   *dpy,
+		      Picture			picture,
+		      unsigned long             valuemask,
+		      XRenderPictureAttributes  *attributes)
+{
+    XExtDisplayInfo	    *info = XRenderFindDisplay (dpy);
+    xRenderChangePictureReq *req;
+    
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    GetReq(RenderChangePicture, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderChangePicture;
+    req->picture = picture;
+    req->mask = valuemask;
+    _XRenderProcessPictureAttributes (dpy,
+				      req,
+				      valuemask,
+				      attributes);
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
+static void
+_XRenderSetPictureClipRectangles (Display	    *dpy,
+				  XExtDisplayInfo   *info,
+				  Picture	    picture,
+				  int		    xOrigin,
+				  int		    yOrigin,
+				  XRectangle	    *rects,
+				  int		    n)
+{
+    xRenderSetPictureClipRectanglesReq	*req;
+    long				len;
+
+    GetReq (RenderSetPictureClipRectangles, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderSetPictureClipRectangles;
+    req->picture = picture;
+    req->xOrigin = xOrigin;
+    req->yOrigin = yOrigin;
+    len = ((long) n) << 1;
+    SetReqLen (req, len, 1);
+    len <<= 2;
+    Data16 (dpy, (short *) rects, len);
+}
+
+void
+XRenderSetPictureClipRectangles (Display	*dpy,
+				 Picture	picture,
+				 int		xOrigin,
+				 int		yOrigin,
+				 XRectangle	*rects,
+				 int		n)
+{
+    XExtDisplayInfo	    *info = XRenderFindDisplay (dpy);
+    
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    _XRenderSetPictureClipRectangles (dpy, info, picture, 
+				      xOrigin, yOrigin, rects, n);
+    UnlockDisplay (dpy);
+    SyncHandle ();
+}
+
+void
+XRenderSetPictureClipRegion (Display	    *dpy,
+			     Picture	    picture,
+			     Region	    r)
+{
+    XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+    int		    i;
+    XRectangle	    *xr, *pr;
+    BOX		    *pb;
+    unsigned long   total;
+    
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    total = r->numRects * sizeof (XRectangle);
+    if ((xr = (XRectangle *) _XAllocTemp(dpy, total))) {
+	for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
+	    pr->x = pb->x1;
+	    pr->y = pb->y1;
+	    pr->width = pb->x2 - pb->x1;
+	    pr->height = pb->y2 - pb->y1;
+	}
+    }
+    if (xr || !r->numRects)
+	_XRenderSetPictureClipRectangles (dpy, info, picture, 0, 0, 
+					  xr, r->numRects);
+    if (xr)
+	_XFreeTemp(dpy, (char *)xr, total);
+    UnlockDisplay(dpy);
+    SyncHandle();
+}    
+
+void
+XRenderFreePicture (Display                   *dpy,
+		    Picture                   picture)
+{
+    XExtDisplayInfo         *info = XRenderFindDisplay (dpy);
+    xRenderFreePictureReq   *req;
+
+    RenderSimpleCheckExtension (dpy, info);
+    LockDisplay(dpy);
+    GetReq(RenderFreePicture, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderFreePicture;
+    req->picture = picture;
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
Index: xc/lib/Xrender/Xrender-def.cpp
diff -u /dev/null xc/lib/Xrender/Xrender-def.cpp:1.2
--- /dev/null	Mon Dec 18 14:25:16 2000
+++ xc/lib/Xrender/Xrender-def.cpp	Mon Dec  4 16:01:00 2000
@@ -0,0 +1,28 @@
+LIBRARY Xrender
+VERSION LIBRARY_VERSION
+EXPORTS
+	XRenderComposite
+	XRenderFillRectangle
+	XRenderFillRectangles
+	XRenderAddGlyphs
+	XRenderCompositeString16
+	XRenderCompositeString32
+	XRenderCompositeString8
+	XRenderCreateGlyphSet
+	XRenderFreeGlyphSet
+	XRenderFreeGlyphs
+	XRenderReferenceGlyphSet
+	XRenderChangePicture
+	XRenderCreatePicture
+	XRenderFreePicture
+	_XRenderProcessPictureAttributes
+	XRenderFindDisplay
+	XRenderFindFormat
+	XRenderFindVisualFormat
+	XRenderQueryExtension
+	XRenderQueryFormats
+	XRenderQueryVersion
+	_XRenderFindFormat
+	_XRenderFindVisual
+
+/* $XFree86: xc/lib/Xrender/Xrender-def.cpp,v 1.2 2000/12/04 21:01:00 dawes Exp $ */
Index: xc/lib/Xrender/Xrender.c
diff -u /dev/null xc/lib/Xrender/Xrender.c:1.3
--- /dev/null	Mon Dec 18 14:25:16 2000
+++ xc/lib/Xrender/Xrender.c	Fri Dec  1 16:32:00 2000
@@ -0,0 +1,336 @@
+/*
+ * $XFree86: xc/lib/Xrender/Xrender.c,v 1.3 2000/12/01 21:32:00 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "Xrenderint.h"
+
+XExtensionInfo XRenderExtensionInfo;
+char XRenderExtensionName[] = RENDER_NAME;
+
+static int XRenderCloseDisplay(Display *dpy, XExtCodes *codes);
+
+static /* const */ XExtensionHooks render_extension_hooks = {
+    NULL,				/* create_gc */
+    NULL,				/* copy_gc */
+    NULL,				/* flush_gc */
+    NULL,				/* free_gc */
+    NULL,				/* create_font */
+    NULL,				/* free_font */
+    XRenderCloseDisplay,		/* close_display */
+    NULL,				/* wire_to_event */
+    NULL,				/* event_to_wire */
+    NULL,				/* error */
+    NULL,				/* error_string */
+};
+
+XExtDisplayInfo *
+XRenderFindDisplay (Display *dpy)
+{
+    XExtDisplayInfo *dpyinfo;
+
+    dpyinfo = XextFindDisplay (&XRenderExtensionInfo, dpy);
+    if (!dpyinfo)
+	dpyinfo = XextAddDisplay (&XRenderExtensionInfo, dpy, 
+				  XRenderExtensionName,
+				  &render_extension_hooks,
+				  0, 0);
+    return dpyinfo;
+}
+
+static int
+XRenderCloseDisplay (Display *dpy, XExtCodes *codes)
+{
+    XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+    if (info->data) XFree (info->data);
+    
+    return XextRemoveDisplay (&XRenderExtensionInfo, dpy);
+}
+    
+/****************************************************************************
+ *                                                                          *
+ *			    Render public interfaces                         *
+ *                                                                          *
+ ****************************************************************************/
+
+Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+    XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+
+    if (XextHasExtension(info)) {
+	*event_basep = info->codes->first_event;
+	*error_basep = info->codes->first_error;
+	return True;
+    } else {
+	return False;
+    }
+}
+
+
+Status XRenderQueryVersion (Display *dpy,
+			    int	    *major_versionp,
+			    int	    *minor_versionp)
+{
+    XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+    xRenderQueryVersionReply rep;
+    xRenderQueryVersionReq  *req;
+
+    RenderCheckExtension (dpy, info, 0);
+
+    LockDisplay (dpy);
+    GetReq (RenderQueryVersion, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderQueryVersion;
+    req->majorVersion = RENDER_MAJOR;
+    req->minorVersion = RENDER_MINOR;
+    if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+	UnlockDisplay (dpy);
+	SyncHandle ();
+	return 0;
+    }
+    *major_versionp = rep.majorVersion;
+    *minor_versionp = rep.minorVersion;
+    UnlockDisplay (dpy);
+    SyncHandle ();
+    return 1;
+}
+
+static XRenderPictFormat *
+_XRenderFindFormat (XRenderInfo *xri, PictFormat format)
+{
+    int	nf;
+    
+    for (nf = 0; nf < xri->nformat; nf++)
+	if (xri->format[nf].id == format)
+	    return &xri->format[nf];
+    return 0;
+}
+
+static Visual *
+_XRenderFindVisual (Display *dpy, VisualID vid)
+{
+    XVisualInfo	temp, *vi;
+    Visual	*v;
+    int		nvi;
+
+    temp.visualid = vid;
+    vi = XGetVisualInfo (dpy, VisualIDMask, &temp, &nvi);
+    if (vi)
+    {
+	v = vi->visual;
+	XFree (vi);
+    }
+    else
+	v = 0;
+    return v;
+}
+
+Status
+XRenderQueryFormats (Display *dpy)
+{
+    XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+    xRenderQueryPictFormatsReply rep;
+    xRenderQueryPictFormatsReq  *req;
+    XRenderInfo			*xri;
+    XRenderPictFormat		*format;
+    XRenderScreen		*screen;
+    XRenderDepth		*depth;
+    XRenderVisual		*visual;
+    xPictFormInfo		*xFormat;
+    xPictScreen			*xScreen;
+    xPictDepth			*xDepth;
+    xPictVisual			*xVisual;
+    int				nf, ns, nd, nv;
+    int				rlength;
+    
+    RenderCheckExtension (dpy, info, 0);
+    LockDisplay (dpy);
+    GetReq (RenderQueryPictFormats, req);
+    req->reqType = info->codes->major_opcode;
+    req->renderReqType = X_RenderQueryPictFormats;
+    if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+	UnlockDisplay (dpy);
+	SyncHandle ();
+	return 0;
+    }
+    xri = (XRenderInfo *) Xmalloc (sizeof (XRenderInfo) +
+				  rep.numFormats * sizeof (XRenderPictFormat) +
+				  rep.numScreens * sizeof (XRenderScreen) +
+				  rep.numDepths * sizeof (XRenderDepth) +
+				  rep.numVisuals * sizeof (XRenderVisual));
+    xri->format = (XRenderPictFormat *) (xri + 1);
+    xri->nformat = rep.numFormats;
+    xri->screen = (XRenderScreen *) (xri->format + rep.numFormats);
+    xri->nscreen = rep.numScreens;
+    xri->depth = (XRenderDepth *) (xri->screen + rep.numScreens);
+    xri->ndepth = rep.numDepths;
+    xri->visual = (XRenderVisual *) (xri->depth + rep.numDepths);
+    xri->nvisual = rep.numVisuals;
+    rlength = (rep.numFormats * sizeof (xPictFormInfo) +
+	       rep.numScreens * sizeof (xPictScreen) +
+	       rep.numDepths * sizeof (xPictDepth) +
+	       rep.numVisuals * sizeof (xPictVisual));
+    xFormat = (xPictFormInfo *) Xmalloc (rlength);
+    
+    if (!xri || !xFormat)
+    {
+	if (xri) Xfree (xri);
+	if (xFormat) Xfree (xFormat);
+	_XEatData (dpy, rlength);
+	UnlockDisplay (dpy);
+	SyncHandle ();
+	return 0;
+    }
+    _XRead (dpy, (char *) xFormat, rlength);
+    format = xri->format;
+    for (nf = 0; nf < rep.numFormats; nf++)
+    {
+	format->id = xFormat->id;
+	format->type = xFormat->type;
+	format->depth = xFormat->depth;
+	format->direct.red = xFormat->direct.red;
+	format->direct.redMask = xFormat->direct.redMask;
+	format->direct.green = xFormat->direct.green;
+	format->direct.greenMask = xFormat->direct.greenMask;
+	format->direct.blue = xFormat->direct.blue;
+	format->direct.blueMask = xFormat->direct.blueMask;
+	format->direct.alpha = xFormat->direct.alpha;
+	format->direct.alphaMask = xFormat->direct.alphaMask;
+	format->colormap = xFormat->colormap;
+	format++;
+	xFormat++;
+    }
+    xScreen = (xPictScreen *) xFormat;
+    screen = xri->screen;
+    depth = xri->depth;
+    visual = xri->visual;
+    for (ns = 0; ns < xri->nscreen; ns++)
+    {
+	screen->depths = depth;
+	screen->ndepths = xScreen->nDepth;
+	screen->fallback = _XRenderFindFormat (xri, xScreen->fallback);
+	xDepth = (xPictDepth *) (xScreen + 1);
+	for (nd = 0; nd < screen->ndepths; nd++)
+	{
+	    depth->depth = xDepth->depth;
+	    depth->nvisuals = xDepth->nPictVisuals;
+	    depth->visuals = visual;
+	    xVisual = (xPictVisual *) (xDepth + 1);
+	    for (nv = 0; nv < depth->nvisuals; nv++)
+	    {
+		visual->visual = _XRenderFindVisual (dpy, xVisual->visual);
+		visual->format = _XRenderFindFormat (xri, xVisual->format);
+		visual++;
+		xVisual++;
+	    }
+	    depth++;
+	    xDepth = (xPictDepth *) xVisual;
+	}
+	xScreen = (xPictScreen *) xDepth;	    
+    }
+    info->data = (XPointer) xri;
+    return 1;
+}
+
+XRenderPictFormat *
+XRenderFindVisualFormat (Display *dpy, Visual *visual)
+{
+    XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+    int		    nv;
+    XRenderInfo	    *xri;
+    XRenderVisual   *xrv;
+    
+    RenderCheckExtension (dpy, info, 0);
+    if (!info->data)
+    {
+	if (!XRenderQueryFormats (dpy))
+	    return 0;
+    }
+    xri = (XRenderInfo *) info->data;
+    for (nv = 0, xrv = xri->visual; nv < xri->nvisual; nv++, xrv++)
+	if (xrv->visual == visual)
+	    return xrv->format;
+    return 0;
+}
+
+XRenderPictFormat *
+XRenderFindFormat (Display		*dpy,
+		   unsigned long	mask,
+		   XRenderPictFormat	*template,
+		   int			count)
+{
+    XExtDisplayInfo *info = XRenderFindDisplay (dpy);
+    int		    nf;
+    XRenderInfo     *xri;
+    
+    RenderCheckExtension (dpy, info, 0);
+    if (!info->data)
+    {
+	if (!XRenderQueryFormats (dpy))
+	    return 0;
+    }
+    xri = (XRenderInfo *) info->data;
+    for (nf = 0; nf < xri->nformat; nf++)
+    {
+	if (mask & PictFormatID)
+	    if (template->id != xri->format[nf].id)
+		continue;
+	if (mask & PictFormatType)
+	if (template->type != xri->format[nf].type)
+		continue;
+	if (mask & PictFormatDepth)
+	    if (template->depth != xri->format[nf].depth)
+		continue;
+	if (mask & PictFormatRed)
+	    if (template->direct.red != xri->format[nf].direct.red)
+		continue;
+	if (mask & PictFormatRedMask)
+	    if (template->direct.redMask != xri->format[nf].direct.redMask)
+		continue;
+	if (mask & PictFormatGreen)
+	    if (template->direct.green != xri->format[nf].direct.green)
+		continue;
+	if (mask & PictFormatGreenMask)
+	    if (template->direct.greenMask != xri->format[nf].direct.greenMask)
+		continue;
+	if (mask & PictFormatBlue)
+	    if (template->direct.blue != xri->format[nf].direct.blue)
+		continue;
+	if (mask & PictFormatBlueMask)
+	    if (template->direct.blueMask != xri->format[nf].direct.blueMask)
+		continue;
+	if (mask & PictFormatAlpha)
+	    if (template->direct.alpha != xri->format[nf].direct.alpha)
+		continue;
+	if (mask & PictFormatAlphaMask)
+	    if (template->direct.alphaMask != xri->format[nf].direct.alphaMask)
+		continue;
+	if (mask & PictFormatColormap)
+	    if (template->colormap != xri->format[nf].colormap)
+		continue;
+	if (count-- == 0)
+	    return &xri->format[nf];
+    }
+    return 0;
+}
+
Index: xc/lib/Xrender/Xrender.h
diff -u /dev/null xc/lib/Xrender/Xrender.h:1.7
--- /dev/null	Mon Dec 18 14:25:16 2000
+++ xc/lib/Xrender/Xrender.h	Mon Dec  4 22:13:30 2000
@@ -0,0 +1,277 @@
+/*
+ * $XFree86: xc/lib/Xrender/Xrender.h,v 1.7 2000/12/05 03:13:30 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _XRENDER_H_
+#define _XRENDER_H_
+
+#include "render.h"
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+#include <X11/Xutil.h>
+
+typedef struct {
+    short   red;
+    short   redMask;
+    short   green;
+    short   greenMask;
+    short   blue;
+    short   blueMask;
+    short   alpha;
+    short   alphaMask;
+} XRenderDirectFormat;
+
+typedef struct {
+    PictFormat		id;
+    int			type;
+    int			depth;
+    XRenderDirectFormat	direct;
+    Colormap		colormap;
+} XRenderPictFormat;
+
+#define PictFormatID	    (1 << 0)
+#define PictFormatType	    (1 << 1)
+#define PictFormatDepth	    (1 << 2)
+#define PictFormatRed	    (1 << 3)
+#define PictFormatRedMask   (1 << 4)
+#define PictFormatGreen	    (1 << 5)
+#define PictFormatGreenMask (1 << 6)
+#define PictFormatBlue	    (1 << 7)
+#define PictFormatBlueMask  (1 << 8)
+#define PictFormatAlpha	    (1 << 9)
+#define PictFormatAlphaMask (1 << 10)
+#define PictFormatColormap  (1 << 11)
+
+typedef struct {
+    Visual		*visual;
+    XRenderPictFormat	*format;
+} XRenderVisual;
+
+typedef struct {
+    int			depth;
+    int			nvisuals;
+    XRenderVisual	*visuals;
+} XRenderDepth;
+
+typedef struct {
+    XRenderDepth	*depths;
+    int			ndepths;
+    XRenderPictFormat	*fallback;
+} XRenderScreen;
+
+typedef struct _XRenderInfo {
+    XRenderPictFormat	*format;
+    int			nformat;
+    XRenderScreen	*screen;
+    int			nscreen;
+    XRenderDepth	*depth;
+    int			ndepth;
+    XRenderVisual	*visual;
+    int			nvisual;
+} XRenderInfo;
+
+typedef struct _XRenderPictureAttributes {
+    Bool		repeat;
+    Picture		alpha_map;
+    int			alpha_x_origin;
+    int			alpha_y_origin;
+    int			clip_x_origin;
+    int			clip_y_origin;
+    Pixmap		clip_mask;
+    Bool		graphics_exposures;
+    int			subwindow_mode;
+    int			poly_edge;
+    int			poly_mode;
+    Atom		dither;
+    Bool		component_alpha;
+} XRenderPictureAttributes;
+
+typedef struct {
+    unsigned short   red;
+    unsigned short   green;
+    unsigned short   blue;
+    unsigned short   alpha;
+} XRenderColor;
+
+typedef struct _XGlyphInfo {
+    unsigned short  width;
+    unsigned short  height;
+    short	    x;
+    short	    y;
+    short	    xOff;
+    short	    yOff;
+} XGlyphInfo;
+
+_XFUNCPROTOBEGIN
+
+Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep);
+
+Status XRenderQueryVersion (Display *dpy,
+			    int     *major_versionp,
+			    int     *minor_versionp);
+
+Status XRenderQueryFormats (Display *dpy);
+
+XRenderPictFormat *
+XRenderFindVisualFormat (Display *dpy, Visual *visual);
+
+XRenderPictFormat *
+XRenderFindFormat (Display		*dpy,
+		   unsigned long	mask,
+		   XRenderPictFormat	*templ,
+		   int			count);
+    
+Picture
+XRenderCreatePicture (Display			*dpy,
+		      Drawable			drawable,
+		      XRenderPictFormat		*format,
+		      unsigned long		valuemask,
+		      XRenderPictureAttributes	*attributes);
+
+void
+XRenderChangePicture (Display                   *dpy,
+		      Picture			picture,
+		      unsigned long             valuemask,
+		      XRenderPictureAttributes  *attributes);
+
+void
+XRenderSetPictureClipRectangles (Display	*dpy,
+				 Picture	picture,
+				 int		xOrigin,
+				 int		yOrigin,
+				 XRectangle	*rects,
+				 int		n);
+
+void
+XRenderSetPictureClipRegion (Display	    *dpy,
+			     Picture	    picture,
+			     Region	    r);
+
+void
+XRenderFreePicture (Display                   *dpy,
+		    Picture                   picture);
+
+void
+XRenderComposite (Display   *dpy,
+		  int	    op,
+		  Picture   src,
+		  Picture   mask,
+		  Picture   dst,
+		  int	    src_x,
+		  int	    src_y,
+		  int	    mask_x,
+		  int	    mask_y,
+		  int	    dst_x,
+		  int	    dst_y,
+		  unsigned int	width,
+		  unsigned int	height);
+
+GlyphSet
+XRenderCreateGlyphSet (Display *dpy, XRenderPictFormat *format);
+
+GlyphSet
+XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing);
+
+void
+XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset);
+
+void
+XRenderAddGlyphs (Display	*dpy,
+		  GlyphSet	glyphset,
+		  Glyph		*gids,
+		  XGlyphInfo	*glyphs,
+		  int		nglyphs,
+		  char		*images,
+		  int		nbyte_images);
+
+void
+XRenderFreeGlyphs (Display   *dpy,
+		   GlyphSet  glyphset,
+		   Glyph     *gids,
+		   int       nglyphs);
+
+void
+XRenderCompositeString8 (Display	    *dpy,
+			 int		    op,
+			 Picture	    src,
+			 Picture	    dst,
+			 XRenderPictFormat  *maskFormat,
+			 GlyphSet	    glyphset,
+			 int		    xSrc,
+			 int		    ySrc,
+			 int		    xDst,
+			 int		    yDst,
+			 char		    *string,
+			 int		    nchar);
+
+void
+XRenderCompositeString16 (Display	    *dpy,
+			  int		    op,
+			  Picture	    src,
+			  Picture	    dst,
+			  XRenderPictFormat *maskFormat,
+			  GlyphSet	    glyphset,
+			  int		    xSrc,
+			  int		    ySrc,
+			  int		    xDst,
+			  int		    yDst,
+			  unsigned short    *string,
+			  int		    nchar);
+
+void
+XRenderCompositeString32 (Display	    *dpy,
+			  int		    op,
+			  Picture	    src,
+			  Picture	    dst,
+			  XRenderPictFormat *maskFormat,
+			  GlyphSet	    glyphset,
+			  int		    xSrc,
+			  int		    ySrc,
+			  int		    xDst,
+			  int		    yDst,
+			  unsigned int	    *string,
+			  int		    nchar);
+
+void
+XRenderFillRectangle (Display	    *dpy,
+		      int	    op,
+		      Picture	    dst,
+		      XRenderColor  *color,
+		      int	    x,
+		      int	    y,
+		      unsigned int  width,
+		      unsigned int  height);
+
+void
+XRenderFillRectangles (Display	    *dpy,
+		       int	    op,
+		       Picture	    dst,
+		       XRenderColor *color,
+		       XRectangle   *rectangles,
+		       int	    n_rects);
+
+_XFUNCPROTOEND
+
+#endif /* _XRENDER_H_ */
Index: xc/lib/Xrender/Xrenderint.h
diff -u /dev/null xc/lib/Xrender/Xrenderint.h:1.2
--- /dev/null	Mon Dec 18 14:25:17 2000
+++ xc/lib/Xrender/Xrenderint.h	Sun Aug 27 22:43:13 2000
@@ -0,0 +1,50 @@
+/*
+ * $XFree86: xc/lib/Xrender/Xrenderint.h,v 1.2 2000/08/28 02:43:13 tsi Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _XRENDERINT_H_
+#define _XRENDERINT_H_
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xext.h"			/* in ../include */
+#include "extutil.h"			/* in ../include */
+#include "Xrender.h"
+#include "renderproto.h"
+
+extern XExtensionInfo XRenderExtensionInfo;
+extern char XRenderExtensionName[];
+
+#define RenderCheckExtension(dpy,i,val) \
+  XextCheckExtension (dpy, i, XRenderExtensionName, val)
+
+#define RenderSimpleCheckExtension(dpy,i) \
+  XextSimpleCheckExtension (dpy, i, XRenderExtensionName)
+
+XExtDisplayInfo *
+XRenderFindDisplay (Display *dpy);
+
+#endif /* _XRENDERINT_H_ */
Index: xc/lib/Xss/Xss-def.cpp
diff -u /dev/null xc/lib/Xss/Xss-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:25:18 2000
+++ xc/lib/Xss/Xss-def.cpp	Wed Aug  9 19:40:13 2000
@@ -0,0 +1,14 @@
+LIBRARY XSS
+EXPORTS
+	XScreenSaverQueryExtension 
+	XScreenSaverQueryVersion 
+	XScreenSaverAllocInfo 
+	XScreenSaverQueryInfo 
+	XScreenSaverSelectInput 
+	XScreenSaverSetAttributes 
+	XScreenSaverUnsetAttributes 
+	XScreenSaverRegister 
+	XScreenSaverUnregister 
+	XScreenSaverGetRegistered 
+
+/* $XFree86: xc/lib/Xss/Xss-def.cpp,v 1.1 2000/08/09 23:40:13 dawes Exp $ */
Index: xc/lib/Xt/Display.c
diff -u xc/lib/Xt/Display.c:3.8 xc/lib/Xt/Display.c:3.9
--- xc/lib/Xt/Display.c:3.8	Sat Oct  3 05:06:51 1998
+++ xc/lib/Xt/Display.c	Wed Nov  1 21:51:10 2000
@@ -32,7 +32,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/Xt/Display.c,v 3.8 1998/10/03 09:06:51 dawes Exp $ */
+/* $XFree86: xc/lib/Xt/Display.c,v 3.9 2000/11/02 02:51:10 dawes Exp $ */
 
 /*
 
@@ -144,7 +144,14 @@
 	    app->count--;
 	}
 	app->rebuild_fdlist = TRUE;
+#ifndef USE_POLL
+	if ((ConnectionNumber(d) + 1) == app->fds.nfds)
+	    app->fds.nfds--;
+	else			/* Unnecessary, just to be fool-proof */
+	    FD_CLR(ConnectionNumber(d), &app->fds.rmask);
+#else
 	app->fds.nfds--;
+#endif
 }
 
 static XtPerDisplay NewPerDisplay(dpy)
Index: xc/lib/Xt/Geometry.c
diff -u xc/lib/Xt/Geometry.c:1.4 xc/lib/Xt/Geometry.c:1.8
--- xc/lib/Xt/Geometry.c:1.4	Sat Oct  3 05:06:53 1998
+++ xc/lib/Xt/Geometry.c	Fri Oct 20 23:16:16 2000
@@ -54,6 +54,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
+/* $XFree86: xc/lib/Xt/Geometry.c,v 1.8 2000/10/21 03:16:16 keithp Exp $ */
 
 #include "IntrinsicI.h"
 #include "ShellP.h"
@@ -95,7 +96,7 @@
     Boolean * clear_rect_obj;
 {
     XtWidgetGeometry    junk;
-    XtGeometryHandler manager;
+    XtGeometryHandler manager = (XtGeometryHandler) NULL;
     XtGeometryResult returnCode;
     Widget parent = widget->core.parent;
     Boolean managed, parentRealized, rgm = False;
@@ -152,32 +153,52 @@
 			  "non-shell has no parent in XtMakeGeometryRequest",
 			  (String *)NULL, (Cardinal *)NULL);
 
-	/* 
-	 * This shouldn't ever happen, we only test for this to pass VSW5.
-	 * Normally managing the widget will catch this, but VSW5 does
-	 * some really screwy stuff to get here.
-	 */
-	if (!XtIsComposite(parent))
+	managed = XtIsManaged(widget);
+	parentRealized = XtIsRealized(parent);
+	if (XtIsComposite(parent))
+	{
+	    LOCK_PROCESS;
+	    manager = ((CompositeWidgetClass) (parent->core.widget_class))
+		      ->composite_class.geometry_manager;
+	    UNLOCK_PROCESS;
+	}
+    }
+
+#if 0
+    /*
+     * The Xt spec says that these conditions must generate
+     * error messages (not warnings), but many Xt applications
+     * and toolkits (including parts of Xaw, Motif and Netscape)
+     * depend on the previous Xt behaviour.  Thus, these tests
+     * should probably remain disabled.
+     */
+    if (parentRealized && managed) {
+	if (parent && !XtIsComposite(parent))
+	{
+	    /*
+	     * This shouldn't ever happen, we only test for this to pass
+	     * VSW5.  Normally managing the widget will catch this, but VSW5
+	     * does some really screwy stuff to get here.
+	     */
 	    XtAppErrorMsg(XtWidgetToApplicationContext(widget),
 			  "invalidParent", "xtMakeGeometryRequest",
 			  XtCXtToolkitError,
 			  "XtMakeGeometryRequest - parent not composite",
 			  (String *)NULL, (Cardinal *)NULL);
-
-	managed = XtIsManaged(widget);
-	parentRealized = XtIsRealized(parent);
-	LOCK_PROCESS;
-	manager = ((CompositeWidgetClass) (parent->core.widget_class))
-		    ->composite_class.geometry_manager;
-	UNLOCK_PROCESS;
-    }
-
-    if (managed && manager == (XtGeometryHandler) NULL) {
-	XtErrorMsg("invalidGeometryManager","xtMakeGeometryRequest",
-                 XtCXtToolkitError,
-                 "XtMakeGeometryRequest - parent has no geometry manager",
-                  (String *)NULL, (Cardinal *)NULL);
+	}
+	else if (manager == (XtGeometryHandler) NULL)
+	{
+	    XtAppErrorMsg(XtWidgetToApplicationContext(widget),
+			  "invalidGeometryManager","xtMakeGeometryRequest",
+			  XtCXtToolkitError,
+			  "XtMakeGeometryRequest - parent has no geometry manager",
+			  (String *)NULL, (Cardinal *)NULL);
+	}
     }
+#else
+    if (!manager)
+	managed = False;
+#endif
 
     if (widget->core.being_destroyed) {
 	CALLGEOTAT(_XtGeoTab(-1));
Index: xc/lib/Xt/Intrinsic.c
diff -u xc/lib/Xt/Intrinsic.c:3.14 xc/lib/Xt/Intrinsic.c:3.16
--- xc/lib/Xt/Intrinsic.c:3.14	Wed Apr  5 14:13:19 2000
+++ xc/lib/Xt/Intrinsic.c	Wed Sep 27 14:49:59 2000
@@ -32,7 +32,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/Xt/Intrinsic.c,v 3.14 2000/04/05 18:13:19 dawes Exp $ */
+/* $XFree86: xc/lib/Xt/Intrinsic.c,v 3.16 2000/09/27 18:49:59 keithp Exp $ */
 
 /*
 
@@ -1176,68 +1176,81 @@
     String	lang;
 {
 
-#if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) || defined(sgi) || defined(__osf__) || defined(AIXV3) || defined(ultrix) || defined(WIN32) || defined(__EMX__)
-#ifdef hpux
+#if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) || defined(sgi) || defined(__osf__) || defined(AIXV3) || defined(ultrix) || defined(WIN32) || defined(__EMX__) || defined (linux)
+# ifdef hpux
 /* 
  * We need to discriminated between HPUX 9 and HPUX 10. The equivalent 
  * code in Xlib in SetLocale.c does include locale.h via X11/Xlocale.h. 
  */ 
-#include <locale.h>
-#ifndef _LastCategory
-/* HPUX 9 and earlier */
-#define SKIPCOUNT 2
-#define STARTCHAR ':'
-#define ENDCHAR ';'
-#else
-/* HPUX 10 */
-#define ENDCHAR ' '
-#endif
-#else
-#ifdef ultrix
-#define SKIPCOUNT 2
-#define STARTCHAR '\001'
-#define ENDCHAR '\001'
-#else
-#if defined(WIN32) || defined(__EMX__)
-#define SKIPCOUNT 1
-#define STARTCHAR '='
-#define ENDCHAR ';'
-#define WHITEFILL
-#else
-#if defined(__osf__) || (defined(AIXV3) && !defined(AIXV4))
-#define STARTCHAR ' '
-#define ENDCHAR ' '
-#else
-#if !defined(sun) || defined(SVR4)
-#define STARTCHAR '/'
-#endif
-#define ENDCHAR '/'
-#endif
-#endif
-#endif
-#endif
+#  include <locale.h>
+#  ifndef _LastCategory
+   /* HPUX 9 and earlier */
+#   define SKIPCOUNT 2
+#   define STARTCHAR ':'
+#   define ENDCHAR ';'
+#  else
+   /* HPUX 10 */
+    #define ENDCHAR ' '
+   #endif
+# else
+#  ifdef ultrix
+#   define SKIPCOUNT 2
+#   define STARTCHAR '\001'
+#   define ENDCHAR '\001'
+#  else
+#   if defined(WIN32) || defined(__EMX__)
+#    define SKIPCOUNT 1
+#    define STARTCHAR '='
+#    define ENDCHAR ';'
+#    define WHITEFILL
+#   else
+#    if defined(__osf__) || (defined(AIXV3) && !defined(AIXV4))
+#     define STARTCHAR ' '
+#     define ENDCHAR ' '
+#    else
+#     if defined(linux)
+#      define STARTSTR "LC_CTYPE="
+#      define ENDCHAR ';'
+#     else
+#      if !defined(sun) || defined(SVR4)
+#       define STARTCHAR '/'
+#       define ENDCHAR '/'
+#      endif
+#     endif
+#    endif
+#   endif
+#  endif
+# endif
 
     char           *start;
     char           *end;
     int             len;
-#ifdef SKIPCOUNT
+# ifdef SKIPCOUNT
     int		    n;
-#endif
+# endif
     static char*    buf = NULL;
 
     start = lang;
-#ifdef SKIPCOUNT
+# ifdef SKIPCOUNT
     for (n = SKIPCOUNT;
 	 --n >= 0 && start && (start = strchr (start, STARTCHAR));
 	 start++)
 	;
     if (!start)
 	start = lang;
-#endif
-#ifdef STARTCHAR
-    if (start && (start = strchr (start, STARTCHAR))) {
-        start++;
-#endif
+# endif
+# ifdef STARTCHAR
+    if (start && (start = strchr (start, STARTCHAR))) 
+# elif  defined (STARTSTR)
+    if (start && (start = strstr (start,STARTSTR)))
+# endif
+    {
+# ifdef STARTCHAR
+	start++;
+# elif defined (STARTSTR)
+	start += strlen(STARTSTR);
+# endif
+
 	if (end = strchr (start, ENDCHAR)) {
 	    len = end - start;
 	    if (buf != NULL) XtFree (buf);
@@ -1245,16 +1258,15 @@
 	    if (buf == NULL) return NULL;
 	    strncpy(buf, start, len);
 	    *(buf + len) = '\0';
-#ifdef WHITEFILL
+# ifdef WHITEFILL
 	    for (start = buf; start = strchr(start, ' '); )
 		*start++ = '-';
-#endif
+# endif
 	    return buf;
-	}
-#ifdef STARTCHAR
+	} else  /* if no ENDCHAR is found we are at the end of the line */
+	    return start;
     }
-#endif
-#ifdef WHITEFILL
+# ifdef WHITEFILL
     if (strchr(lang, ' ')) {
 	if (buf != NULL) XtFree (buf);
 	else buf = XtMalloc (strlen (lang) + 1);
@@ -1264,10 +1276,10 @@
 	    *start++ = '-';
 	return buf;
     }
-#endif
-#undef STARTCHAR
-#undef ENDCHAR
-#undef WHITEFILL
+# endif
+# undef STARTCHAR
+# undef ENDCHAR
+# undef WHITEFILL
 #endif
 
     return lang;
Index: xc/lib/Xt/Intrinsic.h
diff -u xc/lib/Xt/Intrinsic.h:3.4 xc/lib/Xt/Intrinsic.h:3.5
--- xc/lib/Xt/Intrinsic.h:3.4	Sat Oct  3 05:06:55 1998
+++ xc/lib/Xt/Intrinsic.h	Fri Dec 15 17:48:39 2000
@@ -44,7 +44,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/Xt/Intrinsic.h,v 3.4 1998/10/03 09:06:55 dawes Exp $ */
+/* $XFree86: xc/lib/Xt/Intrinsic.h,v 3.5 2000/12/15 22:48:39 dawes Exp $ */
 
 #ifndef _XtIntrinsic_h
 #define _XtIntrinsic_h
@@ -2054,7 +2054,7 @@
 #define XtDefaultFont		"XtDefaultFont"
 #define XtDefaultFontSet	"XtDefaultFontSet"
 
-#if defined(CRAY) || defined(__arm) || defined(__ACK)
+#if defined(CRAY) || defined(__ACK)
 #if __STDC__ && !defined(__ACK)
 #define XtOffset(p_type,field) _Offsetof(p_type,field)
 #else
Index: xc/lib/Xt/Xtos.h
diff -u xc/lib/Xt/Xtos.h:3.3 xc/lib/Xt/Xtos.h:3.4
--- xc/lib/Xt/Xtos.h:3.3	Sat Oct  3 05:07:03 1998
+++ xc/lib/Xt/Xtos.h	Wed Aug 23 18:10:03 2000
@@ -44,7 +44,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/lib/Xt/Xtos.h,v 3.3 1998/10/03 09:07:03 dawes Exp $ */
+/* $XFree86: xc/lib/Xt/Xtos.h,v 3.4 2000/08/23 22:10:03 tsi Exp $ */
 
 #ifndef _Xtos_h
 #define _Xtos_h
@@ -57,7 +57,8 @@
 #define WORD64
 #endif
 
-#if defined(__alpha) || defined(__alpha__)
+#if defined(__alpha) || defined(__alpha__) || \
+    defined(__ia64__) || defined(ia64)
 #define LONG64
 #endif
 
Index: xc/lib/Xxf86dga/XF86DGA2.c
diff -u xc/lib/Xxf86dga/XF86DGA2.c:1.14 xc/lib/Xxf86dga/XF86DGA2.c:1.16
--- xc/lib/Xxf86dga/XF86DGA2.c:1.14	Tue May 23 00:47:35 2000
+++ xc/lib/Xxf86dga/XF86DGA2.c	Thu Sep 28 20:53:57 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/Xxf86dga/XF86DGA2.c,v 1.14 2000/05/23 04:47:35 dawes Exp $ */
+/* $XFree86: xc/lib/Xxf86dga/XF86DGA2.c,v 1.16 2000/09/29 00:53:57 keithp Exp $ */
 /*
 
 Copyright (c) 1995  Jon Tombs
@@ -46,9 +46,9 @@
  *                                                                           *
  *****************************************************************************/
 
-static int xdga_close_display();
-static Bool xdga_wire_to_event();
-static Status xdga_event_to_wire();
+static int xdga_close_display(Display *dpy, XExtCodes *codes);
+static Bool xdga_wire_to_event(Display *dpy, XEvent *event, xEvent *wire_ev);
+static Status xdga_event_to_wire(Display *dpy, XEvent *event, xEvent *wire_ev);
 
 static XExtensionHooks xdga_extension_hooks = {
     NULL,				/* create_gc */
@@ -70,14 +70,14 @@
 XEXT_GENERATE_FIND_DISPLAY (xdga_find_display, xdga_info, 
 				   "XFree86-DGA", 
 				   &xdga_extension_hooks, 
-				   XF86DGANumberEvents, NULL)
+				   0, NULL)
 
 
 static Status
 xdga_event_to_wire(
   Display *dpy,
   XEvent *event,
-  dgaEvent *wire
+  xEvent *wire_ev
 ){
     return True;
 }
@@ -86,8 +86,9 @@
 xdga_wire_to_event(
   Display *dpy,
   XEvent *event,
-  dgaEvent *wire
+  xEvent *wire_ev
 ){
+  dgaEvent *wire = (dgaEvent *) wire_ev;
   XDGAButtonEvent *bevent;
   XDGAKeyEvent *kevent;
   XDGAMotionEvent *mevent;
@@ -177,7 +178,18 @@
     UnlockDisplay(dpy);
     SyncHandle();
     if (*majorVersion >= 2)
+    {
+	int i, j;
+
+	for (i = 0, j = info->codes->first_event;
+	     i < XF86DGANumberEvents;
+	     i++, j++) 
+	{
+	    XESetWireToEvent (dpy, j, xdga_wire_to_event);
+	    XESetEventToWire (dpy, j, xdga_event_to_wire);
+	}
 	XDGASetClientVersion(dpy);
+    }
     return True;
 }
 
@@ -228,7 +240,8 @@
 	_XRead(dpy, deviceName, rep.length << 2);
     }
 
-    ret = XDGAMapFramebuffer(screen, deviceName, (unsigned char*)rep.mem1, 
+    ret = XDGAMapFramebuffer(screen, deviceName,
+				(unsigned char*)(long)rep.mem1, 
 				rep.size, rep.offset, rep.extra);
 
     if(deviceName)
Index: xc/lib/Xxf86dga/Xxf86dga-def.cpp
diff -u /dev/null xc/lib/Xxf86dga/Xxf86dga-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:25:34 2000
+++ xc/lib/Xxf86dga/Xxf86dga-def.cpp	Wed Aug  9 19:40:14 2000
@@ -0,0 +1,16 @@
+LIBRARY libXxf86dga
+EXPORTS
+	XF86DGAQueryExtension 
+	XF86DGAQueryDirectVideo
+	XF86DGAQueryVersion
+	XF86DGAInstallColormap
+	XF86DGAGetVideoLL 
+	XF86DGADirectVideoLL 
+;	XF86DGAGetViewPort
+	XF86DGASetViewPort 
+	XF86DGAGetVidPage 
+	XF86DGASetVidPage 
+	XF86DGADirectVideo 
+	XF86DGAGetVideo 
+
+/* $XFree86: xc/lib/Xxf86dga/Xxf86dga-def.cpp,v 1.1 2000/08/09 23:40:14 dawes Exp $ */
Index: xc/lib/Xxf86misc/Xxf86misc-def.cpp
diff -u /dev/null xc/lib/Xxf86misc/Xxf86misc-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:25:34 2000
+++ xc/lib/Xxf86misc/Xxf86misc-def.cpp	Wed Aug  9 19:40:14 2000
@@ -0,0 +1,13 @@
+LIBRARY XXF86MISC
+EXPORTS
+	XF86MiscQueryExtension 
+	XF86MiscQueryVersion
+	XF86MiscSetKbdSettings
+	XF86MiscGetKbdSettings
+	XF86MiscSetMouseSettings
+	XF86MiscGetMouseSettings
+;	XF86MiscSetSaver 
+;	XF86MiscGetSaver 
+
+
+/* $XFree86: xc/lib/Xxf86misc/Xxf86misc-def.cpp,v 1.1 2000/08/09 23:40:14 dawes Exp $ */
Index: xc/lib/Xxf86rush/XF86Rush.c
diff -u xc/lib/Xxf86rush/XF86Rush.c:1.4 xc/lib/Xxf86rush/XF86Rush.c:1.5
--- xc/lib/Xxf86rush/XF86Rush.c:1.4	Mon Feb 28 22:09:06 2000
+++ xc/lib/Xxf86rush/XF86Rush.c	Tue Sep 26 11:56:59 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/Xxf86rush/XF86Rush.c,v 1.4 2000/02/29 03:09:06 dawes Exp $ */
+/* $XFree86: xc/lib/Xxf86rush/XF86Rush.c,v 1.5 2000/09/26 15:56:59 tsi Exp $ */
 /*
 
 Copyright (c) 1998 Daryll Strauss
@@ -112,7 +112,7 @@
     return False;
   }
   if (addr)
-      *addr = (void *)rep.addr;
+      *addr = (void *)(long)rep.addr;
   UnlockDisplay(dpy);
   SyncHandle();
   return True;
Index: xc/lib/Xxf86vm/XF86VMode.c
diff -u xc/lib/Xxf86vm/XF86VMode.c:3.27 xc/lib/Xxf86vm/XF86VMode.c:3.29
--- xc/lib/Xxf86vm/XF86VMode.c:3.27	Mon Jul 19 09:36:06 1999
+++ xc/lib/Xxf86vm/XF86VMode.c	Tue Aug 22 12:14:47 2000
@@ -1,5 +1,5 @@
 /* $XConsortium: XF86VMode.c /main/2 1995/11/14 18:17:58 kaleb $ */
-/* $XFree86: xc/lib/Xxf86vm/XF86VMode.c,v 3.27 1999/07/19 13:36:06 dawes Exp $ */
+/* $XFree86: xc/lib/Xxf86vm/XF86VMode.c,v 3.29 2000/08/22 16:14:47 alanh Exp $ */
 /*
 
 Copyright (c) 1995  Kaleb S. KEITHLEY
@@ -239,18 +239,18 @@
 	    SyncHandle();
 	    return False;
 	}
-	*dotclock = rep.dotclock;
-	modeline->hdisplay   = rep.hdisplay;
-	modeline->hsyncstart = rep.hsyncstart;
-	modeline->hsyncend   = rep.hsyncend;
-	modeline->htotal     = rep.htotal;
+	*dotclock = oldrep.dotclock;
+	modeline->hdisplay   = oldrep.hdisplay;
+	modeline->hsyncstart = oldrep.hsyncstart;
+	modeline->hsyncend   = oldrep.hsyncend;
+	modeline->htotal     = oldrep.htotal;
 	modeline->hskew      = 0;
-	modeline->vdisplay   = rep.vdisplay;
-	modeline->vsyncstart = rep.vsyncstart;
-	modeline->vsyncend   = rep.vsyncend;
-	modeline->vtotal     = rep.vtotal;
-	modeline->flags      = rep.flags;
-	modeline->privsize   = rep.privsize;
+	modeline->vdisplay   = oldrep.vdisplay;
+	modeline->vsyncstart = oldrep.vsyncstart;
+	modeline->vsyncend   = oldrep.vsyncend;
+	modeline->vtotal     = oldrep.vtotal;
+	modeline->flags      = oldrep.flags;
+	modeline->privsize   = oldrep.privsize;
     } else {
 	if (!_XReply(dpy, (xReply *)&rep, 
             (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xReply)) >> 2, xFalse)) {
@@ -272,13 +272,13 @@
 	modeline->privsize   = rep.privsize;
     }
     
-    if (rep.privsize > 0) {
-	if (!(modeline->private = Xcalloc(rep.privsize, sizeof(INT32)))) {
-	    _XEatData(dpy, (rep.privsize) * sizeof(INT32));
+    if (modeline->privsize > 0) {
+	if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) {
+	    _XEatData(dpy, (modeline->privsize) * sizeof(INT32));
 	    Xfree(modeline->private);
 	    return False;
 	}
-	_XRead32(dpy, modeline->private, rep.privsize * sizeof(INT32));
+	_XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
     } else {
 	modeline->private = NULL;
     }
@@ -354,7 +354,7 @@
     for (i = 0; i < rep.modecount; i++) {
         modelines[i] = mdinfptr++;
 	if (majorVersion < 2) {
-            _XRead32(dpy, &oldxmdline, sizeof(xXF86OldVidModeModeInfo));
+            _XRead(dpy, (char*)&oldxmdline, sizeof(xXF86OldVidModeModeInfo));
 	    modelines[i]->dotclock   = oldxmdline.dotclock;
 	    modelines[i]->hdisplay   = oldxmdline.hdisplay;
 	    modelines[i]->hsyncstart = oldxmdline.hsyncstart;
@@ -377,7 +377,7 @@
 			_XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32));
 			Xfree(modelines[i]->private);
 		    } else {
-			_XRead32(dpy, modelines[i]->private,
+			_XRead(dpy, (char*)modelines[i]->private,
 			     oldxmdline.privsize * sizeof(INT32));
 		    }
 		} else {
@@ -385,7 +385,7 @@
 		}
 	    }
 	} else {
-            _XRead32(dpy, &xmdline, sizeof(xXF86VidModeModeInfo));
+            _XRead(dpy, (char*)&xmdline, sizeof(xXF86VidModeModeInfo));
 	    modelines[i]->dotclock   = xmdline.dotclock;
 	    modelines[i]->hdisplay   = xmdline.hdisplay;
 	    modelines[i]->hsyncstart = xmdline.hsyncstart;
@@ -408,7 +408,7 @@
 			_XEatData(dpy, (xmdline.privsize) * sizeof(INT32));
 			Xfree(modelines[i]->private);
 		    } else {
-			_XRead32(dpy, modelines[i]->private,
+			_XRead(dpy, (char*)modelines[i]->private,
 			     xmdline.privsize * sizeof(INT32));
 		    }
 		} else {
@@ -962,12 +962,12 @@
 	return False;
     }
     for (i = 0; i < rep.nhsync; i++) {
-	_XRead32(dpy, (long *)&syncrange, 4);
+	_XRead(dpy, (char *)&syncrange, 4);
 	monitor->hsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0;
 	monitor->hsync[i].hi = (float)(syncrange >> 16) / 100.0;
     }
     for (i = 0; i < rep.nvsync; i++) {
-	_XRead32(dpy, (long *)&syncrange, 4);
+	_XRead(dpy, (char *)&syncrange, 4);
 	monitor->vsync[i].lo = (float)(syncrange & 0xFFFF) / 100.0;
 	monitor->vsync[i].hi = (float)(syncrange >> 16) / 100.0;
     }
@@ -1100,7 +1100,7 @@
     }
 
     for (i = 0; i < rep.clocks; i++) {
-        _XRead32(dpy, &dotclk, 4);
+        _XRead(dpy, (char*)&dotclk, 4);
 	dotclocks[i] = dotclk;
     }
     *clocksPtr = dotclocks;
Index: xc/lib/Xxf86vm/Xxf86vm-def.cpp
diff -u /dev/null xc/lib/Xxf86vm/Xxf86vm-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:25:36 2000
+++ xc/lib/Xxf86vm/Xxf86vm-def.cpp	Wed Aug  9 19:40:14 2000
@@ -0,0 +1,16 @@
+LIBRARY XXF86VM
+EXPORTS
+	XF86VidModeQueryExtension 
+	XF86VidModeQueryVersion 
+	XF86VidModeGetModeLine 
+	XF86VidModeGetAllModeLines
+	XF86VidModeModModeLine 
+	XF86VidModeSwitchMode 
+	XF86VidModeLockModeSwitch 
+	XF86VidModeGetMonitor
+	XF86VidModeGetGamma
+	XF86VidModeSetGamma
+	XF86VidModeSwitchToMode
+	XF86VidModeAddModeLine
+	
+/* $XFree86: xc/lib/Xxf86vm/Xxf86vm-def.cpp,v 1.1 2000/08/09 23:40:14 dawes Exp $ */
Index: xc/lib/dps/csconndi.c
diff -u xc/lib/dps/csconndi.c:1.3 xc/lib/dps/csconndi.c:1.5
--- xc/lib/dps/csconndi.c:1.3	Thu May 18 19:46:12 2000
+++ xc/lib/dps/csconndi.c	Wed Aug 23 17:06:19 2000
@@ -47,7 +47,7 @@
  *  
  * Author:  Adobe Systems Incorporated and MIT X Consortium
  */
-/* $XFree86: xc/lib/dps/csconndi.c,v 1.3 2000/05/18 23:46:12 dawes Exp $ */
+/* $XFree86: xc/lib/dps/csconndi.c,v 1.5 2000/08/23 21:06:19 dawes Exp $ */
 
 #if defined(sun) && !defined(SVR4)
 #define memmove(t,f,c) bcopy(f,t,c)
@@ -417,7 +417,9 @@
 #include <netinet/tcp.h>
 #endif /* NO_TCP_H */
 #else  /* apollo */
+#ifndef __CYGWIN__
 #include <netinet/tcp.h>
+#endif /* __CYGWIN__ */
 #endif /* apollo */
 #endif
 #endif /* NEED_BSDISH */
@@ -479,7 +481,10 @@
 
 
 #ifdef UNIXCONN
+
+#ifndef __CYGWIN__ /* causes conflicts with cygwin headers */
 #include <sys/un.h>
+#endif
 
 #ifndef CSDPS_UNIX_PATH
 #ifdef hpux
Index: xc/lib/dps/csfindNX.c
diff -u xc/lib/dps/csfindNX.c:1.4 xc/lib/dps/csfindNX.c:1.5
--- xc/lib/dps/csfindNX.c:1.4	Thu May 18 19:46:12 2000
+++ xc/lib/dps/csfindNX.c	Tue Sep 26 11:56:59 2000
@@ -35,7 +35,7 @@
  * 
  * Author:  Adobe Systems Incorporated
  */
-/* $XFree86: xc/lib/dps/csfindNX.c,v 1.4 2000/05/18 23:46:12 dawes Exp $ */
+/* $XFree86: xc/lib/dps/csfindNX.c,v 1.5 2000/09/26 15:56:59 tsi Exp $ */
 
 #include <sys/param.h>				/* for MAXHOSTNAMELEN */
 #include <stdlib.h>
@@ -578,11 +578,11 @@
       *cpp = strcpy(*cpp, *execInfo);
     }
   } else if (arg == XDPSNX_AUTO_LAUNCH) {
-    gXDPSNXAutoLaunch = (Bool) value;
+    gXDPSNXAutoLaunch = (Bool)(long) value;
   } else if (arg == XDPSNX_LAUNCHED_AGENT_TRANS) {
-    gXDPSNXLaunchedAgentTrans = (int) value;
+    gXDPSNXLaunchedAgentTrans = (long) value;
   } else if (arg == XDPSNX_LAUNCHED_AGENT_PORT) {
-    gXDPSNXLaunchedAgentPort = (int) value;
+    gXDPSNXLaunchedAgentPort = (long) value;
   } else if (arg == XDPSNX_REQUEST_XSYNC) {
     dpy = (Display *) value;
     if (dpy == (Display *)NULL)
@@ -609,7 +609,7 @@
         return(Success);
     XDPSLSetGCFlushMode(dpy, XDPSNX_GC_UPDATES_FAST);
   } else if (arg == XDPSNX_SEND_BUF_SIZE) {
-    int i = (int) value;
+    int i = (long)value;
     if (i >= 4096 && i <= 65536) gNXSndBufSize = i;
   }
   return(Success);
@@ -648,10 +648,10 @@
   } else if (arg == XDPSNX_EXEC_ARGS) {
     *value = (void *) gXDPSNXExecArgs;
   } else if (arg == XDPSNX_AUTO_LAUNCH) {
-    *value = (void *) gXDPSNXAutoLaunch;
+    *value = (void *) (long)gXDPSNXAutoLaunch;
   } else if (arg == XDPSNX_LAUNCHED_AGENT_TRANS) {
-    *value = (void *) gXDPSNXLaunchedAgentTrans;
+    *value = (void *) (long)gXDPSNXLaunchedAgentTrans;
   } else if (arg == XDPSNX_LAUNCHED_AGENT_PORT) {
-    *value = (void *) gXDPSNXLaunchedAgentPort;
+    *value = (void *) (long)gXDPSNXLaunchedAgentPort;
   }
 }
Index: xc/lib/dps/dps-def.cpp
diff -u /dev/null xc/lib/dps/dps-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:25:39 2000
+++ xc/lib/dps/dps-def.cpp	Wed Aug  9 19:40:14 2000
@@ -0,0 +1,991 @@
+LIBRARY Dps
+VERSION LIBRARY_VERSION
+EXPORTS
+DPSAddContextExtensionRec
+DPSAwaitReturnValues
+DPSBinObjSeqWrite
+DPSChainContext
+DPSCheckInitClientGlobals
+DPSCheckRaiseError
+DPSCreateContext
+DPSCreateTextContext
+DPSDefaultErrorProc
+DPSDestroyContext
+DPSDestroySpace
+DPSFlushContext
+DPSGenerateExtensionRecID
+DPSGetContextExtensionRec
+DPSGetContextType
+DPSGetCurrentContext
+DPSGetCurrentErrorBackstop
+DPSGetCurrentTextBackstop
+DPSInitCommonContextProcs
+DPSInitCommonSpaceProcs
+DPSInitCommonTextContextProcs
+DPSInitialize
+DPSInterruptContext
+DPSKnownContext
+DPSKnownSpace
+DPSMapNames
+DPSNameFromIndex
+DPSPrivCurrentContext
+DPSRemoveContextExtensionRec
+DPSResetContext
+DPSSafeSetLastNameIndex
+DPSSetAbbrevMode
+DPSSetContext
+DPSSetErrorBackstop
+DPSSetNumStringConversion
+DPSSetResultTable
+DPSSetTextBackstop
+DPSSetWh
+DPSSetWrapSynchronization
+DPSSuppressBinaryConversion
+DPSUnchainContext
+DPSUpdateNameMap
+DPSWaitContext
+DPSWriteData
+DPSWriteNumString
+DPSWritePostScript
+DPSWriteStringChars
+DPSWriteTypedObjectArray
+DPScalloc
+DPSclientPrintProc
+DPSPrintf
+DPSRaise
+DPSCreatePSWDict
+DPSDestroyPSWDict
+DPSMakeAtom
+DPSWDictEnter
+DPSWDictLookup
+DPSWDictRemove
+DPSFetchAbbrevList
+DPSGetOperatorAbbrev
+DPSGetSysnameAbbrev
+DPSCantHappen
+DPSChangeEncoding
+DPSCheckShared
+DPSContextFromContextID
+DPSDefaultPrivateHandler
+DPSFatalProc
+DPSHandleBogusError
+DPSInitPrivateContextFields
+DPSInitPrivateContextProcs
+DPSInitPrivateSpaceFields
+DPSInitPrivateTextContextFields
+DPSNewUserObjectIndex
+DPSPrivateCheckWait
+DPSPrivateDestroyContext
+DPSPrivateDestroySpace
+DPSServicePostScript
+DPSWarnProc
+DPSinnerProcWriteData
+XDPSContextFromSharedID
+XDPSContextFromXID
+XDPSCreateContext
+XDPSCreateSecureContext
+XDPSCreateSimpleContext
+XDPSDispatchEvent
+XDPSFindContext
+XDPSGetContextStatus
+XDPSGetProtocolVersion
+XDPSIsDPSEvent
+XDPSIsOutputEvent
+XDPSIsReadyEvent
+XDPSIsStatusEvent
+XDPSNotifyWhenReady
+XDPSReadyEventHandler
+XDPSRegisterReadyProc
+XDPSRegisterStatusProc
+XDPSSetEventDelivery
+XDPSSetProcs
+XDPSSetStatusMask
+XDPSSpaceFromSharedID
+XDPSSpaceFromXID
+XDPSStatusEventHandler
+XDPSUnfreezeContext
+XDPSXIDFromContext
+XDPSXIDFromSpace
+DPSInitSysNames
+DPSCreatePrivContext
+DPSDefaultTextBackstop
+DPSIncludePrivContext
+DPSInitClient
+DPSOutOfMemory
+DPSSendDestroySpace
+DPSSendEOF
+DPSSendInterrupt
+DPSSendPostScript
+DPSSendTerminate
+XDPSCreatePrivContextRec
+XDPSForceEvents
+XDPSNumFormat
+XDPSPrivZapDpy
+XDPSSendUnfreeze
+XDPSSetContextEncoding
+XDPSLCAPNotify
+XDPSLCallOutputEventHandler
+XDPSLCallReadyEventHandler
+XDPSLCallStatusEventHandler
+XDPSLCleanAll
+XDPSLCleanContext
+XDPSLContextFromXID
+XDPSLCreateContext
+XDPSLCreateContextAndSpace
+XDPSLCreateContextFromID
+XDPSLCreateSpace
+XDPSLDestroySpace
+XDPSLDispatchCSDPSFakeEvent
+XDPSLFlush
+XDPSLFlushGC
+XDPSLGetCSDPSFakeEventType
+XDPSLGetCSDPSReady
+XDPSLGetCSDPSStatus
+XDPSLGetCodes
+XDPSLGetGCFlushMode
+XDPSLGetPassEventsFlag
+XDPSLGetShunt
+XDPSLGetStatus
+XDPSLGetSyncMask
+XDPSLGetVersion
+XDPSLGetWrapWaitingFlag
+XDPSLGiveInput
+XDPSLIDFromContext
+XDPSLInit
+XDPSLInitDisplayFlags
+XDPSLNotifyContext
+XDPSLNotifyWhenReady
+XDPSLReconcileRequests
+XDPSLReset
+XDPSLSetAfterProc
+XDPSLSetAgentArg
+XDPSLSetAgentName
+XDPSLSetClientMessageHandler
+XDPSLSetCodes
+XDPSLSetGCFlushMode
+XDPSLSetPassEventsFlag
+XDPSLSetReadyEventHandler
+XDPSLSetShunt
+XDPSLSetStatusEventHandler
+XDPSLSetStatusMask
+XDPSLSetSyncMask
+XDPSLSetTextEventHandler
+XDPSLSetVersion
+XDPSLSetWrapWaitingFlag
+XDPSLSync
+XDPSLSyncGCClip
+XDPSLTestErrorCode
+XDPSLUpdateAgentArgs
+XDPSSetXtEventDispatching
+;XDPSCreateStandardColormaps
+XDPSGetDefaultColorMaps
+CSDPSHeadOfDpyExt
+CSDPSInit
+DPSCAPChangeGC
+DPSCAPCloseDisplayProc
+DPSCAPCopyGCProc
+DPSCAPCreate
+DPSCAPDestroy
+DPSCAPFlushGCProc
+DPSCAPFreeGCProc
+DPSCAPStartUp
+DPSCAPWrite
+XDPSFlushGC
+XDPSNXSetAgentArg
+XDPSReconcileRequests
+XDPSSyncGCClip
+DPSCAPCloseAgent
+DPSCAPOpenAgent
+DPSCAPConnect
+N_XDisconnectDisplay
+N_XWaitForReadable
+N_XWaitForWritable
+StartXDPSNX
+XDPSNXRecommendPort
+XDPSGetNXArg
+XDPSNXFindNX
+XDPSNXSetClientArg
+NXProcData
+N_XANYSET
+N_XFlush
+N_XGetHostname
+N_XRead
+N_XReadPad
+N_XReply
+N_XSend
+N_XUnknownNativeEvent
+N_XUnknownWireEvent
+DPScolorimage
+DPScurrentblackgeneration
+DPScurrentcmykcolor
+DPScurrentcolorscreen
+DPScurrentcolortransfer
+DPScurrentundercolorremoval
+DPSsetblackgeneration
+DPSsetcmykcolor
+DPSsetcolorscreen
+DPSsetcolortransfer
+DPSsetundercolorremoval
+DPSeq
+DPSexit
+DPSfalse
+DPSfor
+DPSforall
+DPSge
+DPSgt
+DPSif
+DPSifelse
+DPSle
+DPSloop
+DPSlt
+DPSne
+DPSnot
+DPSor
+DPSrepeat
+DPSstop
+DPSstopped
+DPStrue
+DPSUserObjects
+DPScondition
+DPScurrentcontext
+DPScurrentobjectformat
+DPSdefineusername
+DPSdefineuserobject
+DPSdetach
+DPSexecuserobject
+DPSfork
+DPSjoin
+DPSlock
+DPSmonitor
+DPSnotify
+DPSsetobjectformat
+DPSsetvmthreshold
+DPSundefineuserobject
+DPSwait
+DPSyield
+DPSaload
+DPSanchorsearch
+DPSarray
+DPSastore
+DPSbegin
+DPSclear
+DPScleartomark
+DPScopy
+DPScount
+DPScounttomark
+DPScvi
+DPScvlit
+DPScvn
+DPScvr
+DPScvrs
+DPScvs
+DPScvx
+DPSdef
+DPSdict
+DPSdictstack
+DPSdup
+DPSend
+DPSexch
+DPSexecstack
+DPSexecuteonly
+DPSget
+DPSgetinterval
+DPSindex
+DPSknown
+DPSlength
+DPSload
+DPSmark
+DPSmatrix
+DPSmaxlength
+DPSnoaccess
+DPSnull
+DPSpackedarray
+DPSpop
+DPSput
+DPSputinterval
+DPSrcheck
+DPSreadonly
+DPSroll
+DPSscheck
+DPSsearch
+DPSshareddict
+DPSstatusdict
+DPSstore
+DPSstring
+DPSstringwidth
+DPSsystemdict
+DPSuserdict
+DPSwcheck
+DPSwhere
+DPSxcheck
+DPSFontDirectory
+DPSISOLatin1Encoding
+DPSSharedFontDirectory
+DPSStandardEncoding
+DPScachestatus
+DPScurrentcacheparams
+DPScurrentfont
+DPSdefinefont
+DPSfindfont
+DPSmakefont
+DPSscalefont
+DPSselectfont
+DPSsetcachedevice
+DPSsetcachelimit
+DPSsetcacheparams
+DPSsetcharwidth
+DPSsetfont
+DPSundefinefont
+DPSconcat
+DPScurrentdash
+DPScurrentflat
+DPScurrentgray
+DPScurrentgstate
+DPScurrenthalftone
+DPScurrenthalftonephase
+DPScurrenthsbcolor
+DPScurrentlinecap
+DPScurrentlinejoin
+DPScurrentlinewidth
+DPScurrentmatrix
+DPScurrentmiterlimit
+DPScurrentpoint
+DPScurrentrgbcolor
+DPScurrentscreen
+DPScurrentstrokeadjust
+DPScurrenttransfer
+DPSdefaultmatrix
+DPSgrestore
+DPSgrestoreall
+DPSgsave
+DPSgstate
+DPSinitgraphics
+DPSinitmatrix
+DPSrotate
+DPSscale
+DPSsetdash
+DPSsetflat
+DPSsetgray
+DPSsetgstate
+DPSsethalftone
+DPSsethalftonephase
+DPSsethsbcolor
+DPSsetlinecap
+DPSsetlinejoin
+DPSsetlinewidth
+DPSsetmatrix
+DPSsetmiterlimit
+DPSsetrgbcolor
+DPSsetscreen
+DPSsetstrokeadjust
+DPSsettransfer
+DPStranslate
+DPSbytesavailable
+DPSclosefile
+DPScurrentfile
+DPSdeletefile
+DPSecho
+DPSequals
+DPSequalsequals
+DPSfile
+DPSfilenameforall
+DPSfileposition
+DPSflush
+DPSflushfile
+DPSprint
+DPSprintobject
+DPSpstack
+DPSread
+DPSreadhexstring
+DPSreadline
+DPSreadstring
+DPSrenamefile
+DPSresetfile
+DPSsetfileposition
+DPSstack
+DPSstatus
+DPStoken
+DPSwrite
+DPSwritehexstring
+DPSwriteobject
+DPSwritestring
+DPSabs
+DPSadd
+DPSand
+DPSatan
+DPSbitshift
+DPSceiling
+DPScos
+DPSdiv
+DPSexp
+DPSfloor
+DPSidiv
+DPSln
+DPSlog
+DPSmod
+DPSmul
+DPSneg
+DPSround
+DPSsin
+DPSsqrt
+DPSsub
+DPStruncate
+DPSxor
+DPSconcatmatrix
+DPSdtransform
+DPSidentmatrix
+DPSidtransform
+DPSinvertmatrix
+DPSitransform
+DPStransform
+DPSbanddevice
+DPSframedevice
+DPSnulldevice
+DPSrenderbands
+DPSashow
+DPSawidthshow
+DPScopypage
+DPSeofill
+DPSerasepage
+DPSfill
+DPSimage
+DPSimagemask
+DPSkshow
+DPSrectfill
+DPSrectstroke
+DPSshow
+DPSshowpage
+DPSstroke
+DPSstrokepath
+DPSueofill
+DPSufill
+DPSustroke
+DPSustrokepath
+DPSwidthshow
+DPSxshow
+DPSxyshow
+DPSyshow
+DPSarc
+DPSarcn
+DPSarct
+DPSarcto
+DPScharpath
+DPSclip
+DPSclippath
+DPSclosepath
+DPScurveto
+DPSeoclip
+DPSeoviewclip
+DPSflattenpath
+DPSinitclip
+DPSinitviewclip
+DPSlineto
+DPSmoveto
+DPSnewpath
+DPSpathbbox
+DPSpathforall
+DPSrcurveto
+DPSrectclip
+DPSrectviewclip
+DPSreversepath
+DPSrlineto
+DPSrmoveto
+DPSsetbbox
+DPSsetucacheparams
+DPSuappend
+DPSucache
+DPSucachestatus
+DPSupath
+DPSviewclip
+DPSviewclippath
+DPSbind
+DPScleardictstack
+DPScountdictstack
+DPScountexecstack
+DPScurrentdict
+DPScurrentpacking
+DPScurrentshared
+DPSdeviceinfo
+DPSerrordict
+DPSexec
+DPSprompt
+DPSquit
+DPSrand
+DPSrealtime
+DPSrestore
+DPSrrand
+DPSrun
+DPSsave
+DPSsetpacking
+DPSsetshared
+DPSsrand
+DPSstart
+DPStype
+DPSundef
+DPSusertime
+DPSversion
+DPSvmreclaim
+DPSvmstatus
+DPSineofill
+DPSinfill
+DPSinstroke
+DPSinueofill
+DPSinufill
+DPSinustroke
+DPSwtranslation
+DPSgetboolean
+DPSgetchararray
+DPSgetfloat
+DPSgetfloatarray
+DPSgetint
+DPSgetintarray
+DPSgetstring
+DPSsendboolean
+DPSsendchararray
+DPSsendfloat
+DPSsendfloatarray
+DPSsendint
+DPSsendintarray
+DPSsendstring
+DPSclientXready
+DPSclientsync
+DPScurrentXdrawingfunction
+DPScurrentXgcdrawable
+DPScurrentXgcdrawablecolor
+DPScurrentXoffset
+DPSsetXdrawingfunction
+DPSsetXgcdrawable
+DPSsetXgcdrawablecolor
+DPSsetXoffset
+DPSsetXrgbactual
+DPSGlobalFontDirectory
+DPScshow
+DPScurrentcolor
+DPScurrentcolorrendering
+DPScurrentcolorspace
+DPScurrentdevparams
+DPScurrentglobal
+DPScurrentoverprint
+DPScurrentpagedevice
+DPScurrentsystemparams
+DPScurrentuserparams
+DPSdefineresource
+DPSexecform
+DPSfilter
+DPSfindencoding
+DPSfindresource
+DPSgcheck
+DPSglobaldict
+DPSglyphshow
+DPSlanguagelevel
+DPSleftbracket
+DPSleftleft
+DPSmakepattern
+DPSproduct
+DPSresourceforall
+DPSresourcestatus
+DPSrevision
+DPSrightbracket
+DPSrightright
+DPSrootfont
+DPSserialnumber
+DPSsetcolor
+DPSsetcolorrendering
+DPSsetcolorspace
+DPSsetdevparams
+DPSsetglobal
+DPSsetoverprint
+DPSsetpagedevice
+DPSsetpattern
+DPSsetsystemparams
+DPSsetuserparams
+DPSstartjob
+DPSundefineresource
+PScolorimage
+PScurrentblackgeneration
+PScurrentcmykcolor
+PScurrentcolorscreen
+PScurrentcolortransfer
+PScurrentundercolorremoval
+PSsetblackgeneration
+PSsetcmykcolor
+PSsetcolorscreen
+PSsetcolortransfer
+PSsetundercolorremoval
+PSeq
+PSexit
+PSfalse
+PSfor
+PSforall
+PSge
+PSgt
+PSif
+PSifelse
+PSle
+PSloop
+PSlt
+PSne
+PSnot
+PSor
+PSrepeat
+PSstop
+PSstopped
+PStrue
+PSUserObjects
+PScondition
+PScurrentcontext
+PScurrentobjectformat
+PSdefineusername
+PSdefineuserobject
+PSdetach
+PSexecuserobject
+PSfork
+PSjoin
+PSlock
+PSmonitor
+PSnotify
+PSsetobjectformat
+PSsetvmthreshold
+PSundefineuserobject
+PSwait
+PSyield
+PSaload
+PSanchorsearch
+PSarray
+PSastore
+PSbegin
+PSclear
+PScleartomark
+PScopy
+PScount
+PScounttomark
+PScvi
+PScvlit
+PScvn
+PScvr
+PScvrs
+PScvs
+PScvx
+PSdef
+PSdict
+PSdictstack
+PSdup
+PSend
+PSexch
+PSexecstack
+PSexecuteonly
+PSget
+PSgetinterval
+PSindex
+PSknown
+PSlength
+PSload
+PSmark
+PSmatrix
+PSmaxlength
+PSnoaccess
+PSnull
+PSpackedarray
+PSpop
+PSput
+PSputinterval
+PSrcheck
+PSreadonly
+PSroll
+PSscheck
+PSsearch
+PSshareddict
+PSstatusdict
+PSstore
+PSstring
+PSstringwidth
+PSsystemdict
+PSuserdict
+PSwcheck
+PSwhere
+PSxcheck
+PSFontDirectory
+PSISOLatin1Encoding
+PSSharedFontDirectory
+PSStandardEncoding
+PScachestatus
+PScurrentcacheparams
+PScurrentfont
+PSdefinefont
+PSfindfont
+PSmakefont
+PSscalefont
+PSselectfont
+PSsetcachedevice
+PSsetcachelimit
+PSsetcacheparams
+PSsetcharwidth
+PSsetfont
+PSundefinefont
+PSconcat
+PScurrentdash
+PScurrentflat
+PScurrentgray
+PScurrentgstate
+PScurrenthalftone
+PScurrenthalftonephase
+PScurrenthsbcolor
+PScurrentlinecap
+PScurrentlinejoin
+PScurrentlinewidth
+PScurrentmatrix
+PScurrentmiterlimit
+PScurrentpoint
+PScurrentrgbcolor
+PScurrentscreen
+PScurrentstrokeadjust
+PScurrenttransfer
+PSdefaultmatrix
+PSgrestore
+PSgrestoreall
+PSgsave
+PSgstate
+PSinitgraphics
+PSinitmatrix
+PSrotate
+PSscale
+PSsetdash
+PSsetflat
+PSsetgray
+PSsetgstate
+PSsethalftone
+PSsethalftonephase
+PSsethsbcolor
+PSsetlinecap
+PSsetlinejoin
+PSsetlinewidth
+PSsetmatrix
+PSsetmiterlimit
+PSsetrgbcolor
+PSsetscreen
+PSsetstrokeadjust
+PSsettransfer
+PStranslate
+PSbytesavailable
+PSclosefile
+PScurrentfile
+PSdeletefile
+PSecho
+PSequals
+PSequalsequals
+PSfile
+PSfilenameforall
+PSfileposition
+PSflush
+PSflushfile
+PSprint
+PSprintobject
+PSpstack
+PSread
+PSreadhexstring
+PSreadline
+PSreadstring
+PSrenamefile
+PSresetfile
+PSsetfileposition
+PSstack
+PSstatus
+PStoken
+PSwrite
+PSwritehexstring
+PSwriteobject
+PSwritestring
+PSabs
+PSadd
+PSand
+PSatan
+PSbitshift
+PSceiling
+PScos
+PSdiv
+PSexp
+PSfloor
+PSidiv
+PSln
+PSlog
+PSmod
+PSmul
+PSneg
+PSround
+PSsin
+PSsqrt
+PSsub
+PStruncate
+PSxor
+PSconcatmatrix
+PSdtransform
+PSidentmatrix
+PSidtransform
+PSinvertmatrix
+PSitransform
+PStransform
+PSbanddevice
+PSframedevice
+PSnulldevice
+PSrenderbands
+PSashow
+PSawidthshow
+PScopypage
+PSeofill
+PSerasepage
+PSfill
+PSimage
+PSimagemask
+PSkshow
+PSrectfill
+PSrectstroke
+PSshow
+PSshowpage
+PSstroke
+PSstrokepath
+PSueofill
+PSufill
+PSustroke
+PSustrokepath
+PSwidthshow
+PSxshow
+PSxyshow
+PSyshow
+PSarc
+PSarcn
+PSarct
+PSarcto
+PScharpath
+PSclip
+PSclippath
+PSclosepath
+PScurveto
+PSeoclip
+PSeoviewclip
+PSflattenpath
+PSinitclip
+PSinitviewclip
+PSlineto
+PSmoveto
+PSnewpath
+PSpathbbox
+PSpathforall
+PSrcurveto
+PSrectclip
+PSrectviewclip
+PSreversepath
+PSrlineto
+PSrmoveto
+PSsetbbox
+PSsetucacheparams
+PSuappend
+PSucache
+PSucachestatus
+PSupath
+PSviewclip
+PSviewclippath
+PSbind
+PScleardictstack
+PScountdictstack
+PScountexecstack
+PScurrentdict
+PScurrentpacking
+PScurrentshared
+PSdeviceinfo
+PSerrordict
+PSexec
+PSprompt
+PSquit
+PSrand
+PSrealtime
+PSrestore
+PSrrand
+PSrun
+PSsave
+PSsetpacking
+PSsetshared
+PSsrand
+PSstart
+PStype
+PSundef
+PSusertime
+PSversion
+PSvmreclaim
+PSvmstatus
+PSineofill
+PSinfill
+PSinstroke
+PSinueofill
+PSinufill
+PSinustroke
+PSwtranslation
+PSgetboolean
+PSgetchararray
+PSgetfloat
+PSgetfloatarray
+PSgetint
+PSgetintarray
+PSgetstring
+PSsendboolean
+PSsendchararray
+PSsendfloat
+PSsendfloatarray
+PSsendint
+PSsendintarray
+PSsendstring
+PSclientXready
+PSclientsync
+PScurrentXdrawingfunction
+PScurrentXgcdrawable
+PScurrentXgcdrawablecolor
+PScurrentXoffset
+PSsetXdrawingfunction
+PSsetXgcdrawable
+PSsetXgcdrawablecolor
+PSsetXoffset
+PSsetXrgbactual
+PSGlobalFontDirectory
+PScshow
+PScurrentcolor
+PScurrentcolorrendering
+PScurrentcolorspace
+PScurrentdevparams
+PScurrentglobal
+PScurrentoverprint
+PScurrentpagedevice
+PScurrentsystemparams
+PScurrentuserparams
+PSdefineresource
+PSexecform
+PSfilter
+PSfindencoding
+PSfindresource
+PSgcheck
+PSglobaldict
+PSglyphshow
+PSlanguagelevel
+PSleftbracket
+PSleftleft
+PSmakepattern
+PSproduct
+PSresourceforall
+PSresourcestatus
+PSrevision
+PSrightbracket
+PSrightright
+PSrootfont
+PSserialnumber
+PSsetcolor
+PSsetcolorrendering
+PSsetcolorspace
+PSsetdevparams
+PSsetglobal
+PSsetoverprint
+PSsetpagedevice
+PSsetpattern
+PSsetsystemparams
+PSsetuserparams
+PSstartjob
+PSundefineresource
+
+/* $XFree86: xc/lib/dps/dps-def.cpp,v 1.1 2000/08/09 23:40:14 dawes Exp $ */
Index: xc/lib/dps/dpsXclient.c
diff -u xc/lib/dps/dpsXclient.c:1.2 xc/lib/dps/dpsXclient.c:1.3
--- xc/lib/dps/dpsXclient.c:1.2	Thu May 18 19:46:13 2000
+++ xc/lib/dps/dpsXclient.c	Tue Sep 26 11:56:59 2000
@@ -35,10 +35,12 @@
  * 
  * Author:  Adobe Systems Incorporated
  */
+/* $XFree86: xc/lib/dps/dpsXclient.c,v 1.3 2000/09/26 15:56:59 tsi Exp $ */
 
 #include <stdlib.h>
 #include <unistd.h>	/* sleep() */
 #include <stdio.h>
+#include <string.h>
 #include <ctype.h>
 
 #ifdef VMS
Index: xc/lib/dps/dpsXcmu.c
diff -u xc/lib/dps/dpsXcmu.c:1.2 xc/lib/dps/dpsXcmu.c:1.4
--- xc/lib/dps/dpsXcmu.c:1.2	Thu May 18 19:46:13 2000
+++ xc/lib/dps/dpsXcmu.c	Tue Sep 26 11:56:59 2000
@@ -54,6 +54,7 @@
  *
  * Author: Adobe Systems Incorporated and Donna Converse, MIT X Consortium
  */
+/* $XFree86: xc/lib/dps/dpsXcmu.c,v 1.4 2000/09/26 15:56:59 tsi Exp $ */
 
 #include <X11/X.h>
 #include <X11/Xlib.h>
@@ -104,7 +105,7 @@
 static Bool CubicCube(XStandardColormap *);
 static Bool GetColorCubeFromProperty(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap **, int *);
 static Bool GetGrayRampFromProperty(Display *, XVisualInfo *, XStandardColormap *, XStandardColormap **, int *);
-static Status XDPSCreateStandardColormaps(Display *, Drawable, Visual *, int, int, int, int, XStandardColormap *, XStandardColormap *, Bool);
+Status XDPSCreateStandardColormaps(Display *, Drawable, Visual *, int, int, int, int, XStandardColormap *, XStandardColormap *, Bool);
 static Status contiguous(unsigned long *, int, int *, unsigned long, int *, int *);
 static XVisualInfo *PickCorrectVisual(Display *, XVisualInfo *, int, Colormap);
 static int FindRampSize(XColor *, XColor *);
@@ -168,7 +169,7 @@
 				       0, 0, 0, 0, colorCube, grayRamp, True);
 }
 
-static Status XDPSCreateStandardColormaps(
+Status XDPSCreateStandardColormaps(
     Display *dpy,
     Drawable drawable,
     Visual *visual,
Index: xc/lib/dps/dpsclient.c
diff -u xc/lib/dps/dpsclient.c:1.2 xc/lib/dps/dpsclient.c:1.3
--- xc/lib/dps/dpsclient.c:1.2	Thu May 18 19:46:13 2000
+++ xc/lib/dps/dpsclient.c	Tue Sep 26 11:56:59 2000
@@ -35,10 +35,12 @@
  * 
  * Author:  Adobe Systems Incorporated
  */
+/* $XFree86: xc/lib/dps/dpsclient.c,v 1.3 2000/09/26 15:56:59 tsi Exp $ */
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <string.h>
 
 #include "dpsXpriv.h"
 #include "DPS/dpsclient.h"
Index: xc/lib/dps/dpsdict.c
diff -u xc/lib/dps/dpsdict.c:1.2 xc/lib/dps/dpsdict.c:1.3
--- xc/lib/dps/dpsdict.c:1.2	Thu May 18 19:46:13 2000
+++ xc/lib/dps/dpsdict.c	Tue Sep 26 11:57:00 2000
@@ -35,12 +35,14 @@
  * 
  * Author:  Adobe Systems Incorporated
  */
+/* $XFree86: xc/lib/dps/dpsdict.c,v 1.3 2000/09/26 15:57:00 tsi Exp $ */
 
 /***********/
 /* Imports */
 /***********/
 
 #include <stdlib.h>
+#include <string.h>
 
 #include "dpsint.h"
 
Index: xc/lib/dps/dpsprintf.c
diff -u xc/lib/dps/dpsprintf.c:1.2 xc/lib/dps/dpsprintf.c:1.3
--- xc/lib/dps/dpsprintf.c:1.2	Thu May 18 19:46:14 2000
+++ xc/lib/dps/dpsprintf.c	Tue Sep 26 11:57:00 2000
@@ -35,8 +35,10 @@
  * 
  * Author:  Adobe Systems Incorporated
  */
+/* $XFree86: xc/lib/dps/dpsprintf.c,v 1.3 2000/09/26 15:57:00 tsi Exp $ */
 
 #include <stdio.h>
+#include <string.h>
 
 #include "publictypes.h"
 #include "DPS/dpsclient.h"
Index: xc/lib/dpstk/XDPSshare.c
diff -u xc/lib/dpstk/XDPSshare.c:1.2 xc/lib/dpstk/XDPSshare.c:1.3
--- xc/lib/dpstk/XDPSshare.c:1.2	Wed Jun  7 18:03:01 2000
+++ xc/lib/dpstk/XDPSshare.c	Tue Sep 26 11:57:00 2000
@@ -35,7 +35,7 @@
  * 
  * Author:  Adobe Systems Incorporated
  */
-/* $XFree86: xc/lib/dpstk/XDPSshare.c,v 1.2 2000/06/07 22:03:01 tsi Exp $ */
+/* $XFree86: xc/lib/dpstk/XDPSshare.c,v 1.3 2000/09/26 15:57:00 tsi Exp $ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -576,7 +576,6 @@
 		XFreeGC(display, d->gcForDepth[i][j]);
 	    }
 	}
-	free((char *) d->depthsForScreen[i]);
     }
 
     free((char *) d->depthsForScreen);
Index: xc/lib/dpstk/dpstk-def.cpp
diff -u /dev/null xc/lib/dpstk/dpstk-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:25:46 2000
+++ xc/lib/dpstk/dpstk-def.cpp	Wed Aug  9 19:40:14 2000
@@ -0,0 +1,65 @@
+LIBRARY DPSTK
+VERSION LIBRARY_VERSION
+EXPORTS
+_DPSPCheckForError
+_DPSPClearArea
+_DPSPDefineExecFunction
+_DPSPSaveBeforeExec
+_DPSPSetMaskTransfer
+_DPSPSetMatrix
+_DPSSCaptureGState
+_DPSSDefineUserObject
+_DPSSInstallDPSlibDict
+_DPSSRestoreGState
+_DPSSSetContextDrawable
+_DPSSSetContextParameters
+_DPSSUndefineUserObject
+_DPSSUpdateGState
+DPSDefineAsUserObj
+DPSRedefineUserObj
+DPSReserveUserObjIndices
+DPSReturnUserObjIndices
+DPSUndefineUserObj
+PSDefineAsUserObj
+PSRedefineUserObj
+PSReserveUserObjIndices
+PSReturnUserObjIndices
+PSUndefineUserObj
+XDPSCaptureContextGState
+XDPSChainTextContext
+XDPSDestroySharedContext
+XDPSExtensionPresent
+XDPSFreeContextGState
+XDPSFreeDisplayInfo
+XDPSGetSharedContext
+XDPSPopContextGState
+XDPSPopContextParameters
+XDPSPushContextGState
+XDPSPushContextParameters
+XDPSRegisterContext
+XDPSSetContextDepth
+XDPSSetContextDrawable
+XDPSSetContextGState
+XDPSSetContextGrayMap
+XDPSSetContextParameters
+XDPSSetContextRGBMap
+XDPSUnregisterContext
+XDPSUpdateContextGState
+_XDPSSetComponentInitialized
+_XDPSTestComponentInitialized
+XDPSCheckImagingResults
+XDPSCreatePixmapForEPSF
+XDPSEmbeddedEPSFRewindFunc
+XDPSEmbeddedGetsFunc
+XDPSFileGetsFunc
+XDPSFileRewindFunc
+XDPSImageFileIntoDrawable
+XDPSPixelsPerPoint
+XDPSSetFileFunctions
+XDPSSetImagingTimeout
+DPSDoUserPath
+DPSHitUserPath
+PSDoUserPath
+PSHitUserPath
+
+/* $XFree86: xc/lib/dpstk/dpstk-def.cpp,v 1.1 2000/08/09 23:40:14 dawes Exp $ */
Index: xc/lib/font/Imakefile
diff -u xc/lib/font/Imakefile:3.29 xc/lib/font/Imakefile:3.30
--- xc/lib/font/Imakefile:3.29	Sun Feb 13 01:15:23 2000
+++ xc/lib/font/Imakefile	Tue Sep 19 08:46:06 2000
@@ -1,5 +1,5 @@
 XCOMM $TOG: Imakefile /main/14 1998/06/16 15:23:15 msr $
-XCOMM $XFree86: xc/lib/font/Imakefile,v 3.29 2000/02/13 06:15:23 dawes Exp $
+XCOMM $XFree86: xc/lib/font/Imakefile,v 3.30 2000/09/19 12:46:06 eich Exp $
 #include <Server.tmpl>
 
 #define	IHaveSubdirs
@@ -95,7 +95,7 @@
 		 $(FREETYPEDONES) $(XTTDONES) \
 		 $(BUILTINDONES) util/DONE
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
       BASEDIRS = fontfile fc util fontcache
    BASELIBOBJS = fontfile/$(STATIC_OBJSDIR)?*.o fc/$(STATIC_OBJSDIR)?*.o \
 		 util/$(STATIC_OBJSDIR)?*.o fontcache/$(STATIC_OBJSDIR)?*.o 
@@ -138,7 +138,7 @@
 InstallLibrary($(LIBNAME)_p,$(USRLIBDIR))
 #endif /* ProfileLibFont */
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 NormalDepLibraryTarget(fontbase,$(BASEDIRS) $(BASEDONES),$(BASELIBOBJS))
 NormalDepRelocatableTarget(fontbase,$(BASEDIRS) $(BASEDONES),$(BASEOBJS))
 #endif
Index: xc/lib/font/FreeType/Imakefile
diff -u xc/lib/font/FreeType/Imakefile:1.15 xc/lib/font/FreeType/Imakefile:1.16
--- xc/lib/font/FreeType/Imakefile:1.15	Sun Aug 29 21:24:57 1999
+++ xc/lib/font/FreeType/Imakefile	Tue Sep 19 08:46:06 2000
@@ -1,10 +1,10 @@
-XCOMM $XFree86: xc/lib/font/FreeType/Imakefile,v 1.15 1999/08/30 01:24:57 dawes Exp $
+XCOMM $XFree86: xc/lib/font/FreeType/Imakefile,v 1.16 2000/09/19 12:46:06 eich Exp $
 
 XCOMM Imakefile created for the Freetype TrueType renderer.
 XCOMM Mark Leisher <mleisher@crl.nmsu.edu>
 XCOMM Juliusz Chroboczek <jec@dcs.ed.ac.uk>
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 #define IHaveSubdirs
 #define NoLibSubdirs
 #define PassCDebugFlags
@@ -48,7 +48,7 @@
 LinkSourceFile(freetype.c,$(FTSOURCEDIR)/lib/arch/unix)
 LinkSourceFile(ftxcmap.c,$(FTSOURCEDIR)/lib/extend)
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
 #endif
Index: xc/lib/font/FreeType/ft.h
diff -u xc/lib/font/FreeType/ft.h:1.12 xc/lib/font/FreeType/ft.h:1.13
--- xc/lib/font/FreeType/ft.h:1.12	Wed Oct 13 00:20:49 1999
+++ xc/lib/font/FreeType/ft.h	Tue Nov 14 11:54:42 2000
@@ -1,6 +1,6 @@
 /*
 Copyright (c) 1997 by Mark Leisher
-Copyright (c) 1998 by Juliusz Chroboczek
+Copyright (c) 1998-2000 by Juliusz Chroboczek
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -21,14 +21,13 @@
 THE SOFTWARE.
 */
 
-/* $XFree86: xc/lib/font/FreeType/ft.h,v 1.12 1999/10/13 04:20:49 dawes Exp $ */
+/* $XFree86: xc/lib/font/FreeType/ft.h,v 1.13 2000/11/14 16:54:42 dawes Exp $ */
 
 #undef DEBUG_TRUETYPE
 
-/* if stderr, the output will go to the errors file */
 #ifdef DEBUG_TRUETYPE
-#define MUMBLE(s) (printf((s)))
-#define MUMBLE1(s,x) (printf((s),(x)))
+#define MUMBLE(s) (ErrorF((s)))
+#define MUMBLE1(s,x) (ErrorF((s),(x)))
 #else
 #define MUMBLE(s)
 #define MUMBLE1(s,x)
Index: xc/lib/font/FreeType/ft_conf.h
diff -u xc/lib/font/FreeType/ft_conf.h:1.7 xc/lib/font/FreeType/ft_conf.h:1.9
--- xc/lib/font/FreeType/ft_conf.h:1.7	Sun Apr 25 06:01:35 1999
+++ xc/lib/font/FreeType/ft_conf.h	Tue Nov 28 14:09:28 2000
@@ -1,6 +1,6 @@
 /* ft_conf.h.  Xserver-specific version. */
 
-/* $XFree86: xc/lib/font/FreeType/ft_conf.h,v 1.7 1999/04/25 10:01:35 dawes Exp $ */
+/* $XFree86: xc/lib/font/FreeType/ft_conf.h,v 1.9 2000/11/28 19:09:28 dawes Exp $ */
 
 /* we need the following because there are some typedefs in this file */
 #ifndef FT_CONF_H
@@ -107,22 +107,15 @@
 /* by the engine and need no extensions, undefine this configuration     */
 /* macro to save a few more bytes.                                       */
 
-/* we're using ftxcmap.h */
+/* #undef  TT_CONFIG_OPTION_EXTEND_ENGINE */
 
-#define  TT_CONFIG_OPTION_EXTEND_ENGINE
 
-
 /*************************************************************************/
 /* Define this if you want to generate code to support gray-scaling,     */
 /* a.k.a. font-smoothing or anti-aliasing. Default is on, but you can    */
 /* disable it if you don't need it.                                      */
 
-#ifdef ANTI_ALIASING
-#define  TT_CONFIG_OPTION_GRAY_SCALING
-#else
 #undef  TT_CONFIG_OPTION_GRAY_SCALING
-#endif
-
 
 /*************************************************************************/
 /* Define this if you want to use a big 'switch' statement within the    */
Index: xc/lib/font/FreeType/ftfuncs.c
diff -u xc/lib/font/FreeType/ftfuncs.c:1.14 xc/lib/font/FreeType/ftfuncs.c:1.16
--- xc/lib/font/FreeType/ftfuncs.c:1.14	Wed Apr  5 14:13:24 2000
+++ xc/lib/font/FreeType/ftfuncs.c	Tue Nov 14 11:54:42 2000
@@ -1,6 +1,6 @@
 /*
 Copyright (c) 1997 by Mark Leisher
-Copyright (c) 1998, 1999 by Juliusz Chroboczek
+Copyright (c) 1998-2000 by Juliusz Chroboczek
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -21,7 +21,7 @@
 THE SOFTWARE.
 */
 
-/* $XFree86: xc/lib/font/FreeType/ftfuncs.c,v 1.14 2000/04/05 18:13:24 dawes Exp $ */
+/* $XFree86: xc/lib/font/FreeType/ftfuncs.c,v 1.16 2000/11/14 16:54:42 dawes Exp $ */
 
 #ifndef FONT_MODULE
 #include <string.h>
@@ -34,7 +34,6 @@
 #include "fontutil.h"
 #include "FSproto.h"
 #include "freetype.h"
-#include "ftxcmap.h"
 
 #include "ttconfig.h"
 #include "fontenc.h"
@@ -82,7 +81,7 @@
   if(x>=0)
     return x/y;
   else
-    return x/y+1;
+    return x/y-1;
 }
 
 static int
@@ -143,6 +142,7 @@
   if(ttf_checkForTTCName(fileName, &realFileName, &faceNumber)) {
     ftrc=TT_Open_Collection(ftypeEngine, realFileName, faceNumber,
                             &face->face);
+    xfree(realFileName);
   } else {
     ftrc=TT_Open_Face(ftypeEngine, fileName, &face->face);
   }
@@ -194,8 +194,7 @@
       if(otherFace && otherFace->next)
         otherFace->next=otherFace->next->next;
       else
-        fprintf(stderr,
-                "Congratulations, \
+        ErrorF("Congratulations, \
 you've found a bug in the TrueType backend: freeing unknown face\n");
     }
     MUMBLE1("Closing face: %s\n", face->filename);
@@ -301,10 +300,6 @@
   instance->nglyphs=properties->num_Glyphs;
   instance->glyphs=0;
   instance->available=0;
-#ifdef ANTI_ALIASING
-  instance->glyphsAnti=0;
-  instance->availableAnti=0;
-#endif
 
   if(ftrc=TT_New_Instance(instance->face->face, &instance->instance)) {
     MUMBLE("Couldn't create instance\n");
@@ -464,28 +459,15 @@
 }
 
 static int
-FreeTypeInstanceGetGlyph(unsigned idx, CharInfoPtr *g, TTFInstance *instance,
-                         int nlevels)
+FreeTypeInstanceGetGlyph(unsigned idx, CharInfoPtr *g, TTFInstance *instance)
 {
   int found, segment, offset;
   int xrc, ftrc;
   int ***available;
   CharInfoPtr **glyphs;
 
-  switch(nlevels) {
-  case 1: 
-    available=&instance->available;
-    glyphs=&instance->glyphs;
-    break;
-#ifdef ANTI_ALIASING
-  case 4:
-    available=&instance->availableAnti;
-    glyphs=&instance->glyphsAnti;
-    break;
-#endif
-  default:
-    return BadFontFormat;
-  }
+  available=&instance->available;
+  glyphs=&instance->glyphs;
 
   if((xrc=FreeTypeInstanceFindGlyph(idx, instance, glyphs, available,
                                     &found, &segment, &offset))
@@ -512,7 +494,7 @@
            sizeof(xCharInfo));
 
   xrc=FreeTypeRasteriseGlyph(&(*glyphs)[segment][offset],
-                             instance, instance->monospaced==2, nlevels);
+                             instance, instance->monospaced==2);
   if(xrc!=Successful)
     return xrc;
   else
@@ -553,7 +535,7 @@
     
   if(instance->available[segment][offset]==0) {
     if(instance->monospaced<2) { /* not a charcell instance */
-      if((xrc=FreeTypeInstanceGetGlyph(idx, &g, instance, 1))!=Successful)
+      if((xrc=FreeTypeInstanceGetGlyph(idx, &g, instance))!=Successful)
         return xrc;
     } else {
       memcpy((char*)&instance->glyphs[segment][offset].metrics,
@@ -573,7 +555,7 @@
     
 int
 FreeTypeRasteriseGlyph(CharInfoPtr tgp, TTFInstance *instance, 
-                       int hasMetrics, int nlevels)
+                       int hasMetrics)
 {
 #define TRANSFORM_X(x_value) \
   ((int)floor((((double)(x_value)*(double)instance->transformation.matrix.xx)/\
@@ -598,15 +580,6 @@
     ascent, descent;
   int i=0;
 
-  if(nlevels!=1
-#ifdef ANTI_ALIASING
-     && nlevels!=4
-#endif
-     ) {
-    MUMBLE1("Bad number of levels: %d\n", nlevels);
-    return BadFontFormat;       /* is there anything better? */
-  }
-
   face=instance->face;
 
   TT_Get_Glyph_Metrics(face->glyph, &metrics);
@@ -642,63 +615,21 @@
     raster.flow = TT_Flow_Down;
     raster.rows=ht;
     raster.width=wd;
-#ifdef ANTI_ALIASING
-    if(nlevels==1)
-#endif
-      raster.cols=bpr;
-#ifdef ANTI_ALIASING
-    else
-      raster.cols=(wd+3)&-4;
-#endif
+    raster.cols=bpr;
     raster.size = (long)raster.rows*raster.cols;
     raster.bitmap = (void*)xalloc(ht*raster.cols);
     if(raster.bitmap==NULL) return AllocError;
     memset(raster.bitmap,0,(int)raster.size);
 
-#ifdef ANTI_ALIASING
-    if(nlevels==1)
-#endif
-      ftrc=TT_Get_Glyph_Bitmap(face->glyph,&raster,xoff,yoff);
-#ifdef ANTI_ALIASING
-    else
-      ftrc=TT_Get_Glyph_Pixmap(face->glyph,&raster,xoff,yoff);
-#endif
+    ftrc=TT_Get_Glyph_Bitmap(face->glyph,&raster,xoff,yoff);
     if(ftrc) {
       MUMBLE("Failed to draw bitmap\n");
       /* Ignore error, return blank bitmap */
     }
-#ifdef ANTI_ALIASING
-    if(nlevels==1)
-#endif
-      tgp->bits=raster.bitmap;
-#ifdef ANTI_ALIASING
-    else {
-      /* Need to convert pixmap to family of bitmaps */
-      tgp->bits=(char*)xalloc(nlevels*ht*bpr);
-      if(tgp->bits==0) {
-        xfree(raster.bitmap);
-        return AllocError;
-      }
-      memset(tgp->bits, 0, nlevels*ht*bpr);
-
-      for(i=0; i<nlevels; i++) {
-        int j,k;
-        for(j=0; j<raster.width; j++)
-          for(k=0; k<ht; k++) {
-            if(((char*)raster.bitmap)[j+raster.cols*k]==i+1)
-              tgp->bits[i*ht*bpr+k*bpr+j/8]|= 1<<(8-j%8);
-          }
-      }
-      xfree(raster.bitmap);
-    }
-#endif
+    tgp->bits=raster.bitmap;
 
-    i=0;
     if(instance->bmfmt.bit==LSBFirst) {
-#ifdef ANTI_ALIASING      
-      for(i=0; i<nlevels; i++)
-#endif
-        BitOrderInvert((unsigned char*)(tgp->bits)+i*ht*bpr, ht*bpr);
+      BitOrderInvert((unsigned char*)(tgp->bits)+i*ht*bpr, ht*bpr);
     }
     
     if(instance->bmfmt.byte!=instance->bmfmt.bit)
@@ -706,31 +637,22 @@
       case 1:
         break;
       case 2:
-#ifdef ANTI_ALIASING      
-        for(i=0; i<nlevels; i++)
-#endif
-          TwoByteSwap((unsigned char*)(tgp->bits)+i*ht*bpr, ht*bpr);
+        TwoByteSwap((unsigned char*)(tgp->bits)+i*ht*bpr, ht*bpr);
         break;
       case 4:
-#ifdef ANTI_ALIASING      
-        for(i=0; i<nlevels; i++)
-#endif
-          FourByteSwap((unsigned char*)(tgp->bits)+i*ht*bpr, ht*bpr);
+        FourByteSwap((unsigned char*)(tgp->bits)+i*ht*bpr, ht*bpr);
         break;
       case 8:                   /* no util function for 64 bits! */
-#ifdef ANTI_ALIASING      
-        for(i=0; i<nlevels; i++)
-#endif
-          {
-            int j,k;
-            char c, *cp=tgp->bits+i*ht*bpr;
-            for(j=ht*bpr; j>=0; j-=8, cp+=8)
-              for(k=0; k<4; k++) {
-                c=cp[k];
-                cp[k]=cp[7-k];
-                cp[7-k]=cp[k];
-              }
-          }
+        {
+          int j,k;
+          char c, *cp=tgp->bits+i*ht*bpr;
+          for(j=ht*bpr; j>=0; j-=8, cp+=8)
+            for(k=0; k<4; k++) {
+              c=cp[k];
+              cp[k]=cp[7-k];
+              cp[7-k]=cp[k];
+            }
+        }
         break;
       default:
         ;
@@ -857,9 +779,6 @@
   maxprops=
     1+                          /* NAME */
     (xlfdProps?14:0)+          /* from XLFD */
-#ifdef ANTI_ALIASING
-    1+
-#endif
     (hheaProps?5:0)+           /* from `hhea' table */
     3+                          /* from `name' table */
     (os2Props?6:0)+            /* from `os/2' table */
@@ -924,14 +843,6 @@
     i++;
   }
 
-#ifdef ANTI_ALIASING
-  info->props[i].name = MakeAtom("ANTI_ALIASING_LEVELS", 20, TRUE); 
-  info->props[i].value = MakeAtom("1 4", 3, TRUE);
-  info->isStringProp[i] = 1;
-  i++;
-#endif
-
-
   /* the following two have already been properly scaled */
 
   if(hheaProps) {
@@ -1065,14 +976,14 @@
 }
 
 static int
-FreeTypeFontGetGlyph(unsigned code, CharInfoPtr *g, TTFFont *font, int nlevels)
+FreeTypeFontGetGlyph(unsigned code, CharInfoPtr *g, TTFFont *font)
 {
   unsigned idx;
   int i;
 
-  /* As a special case, we pass 0 even when its not in the ranges;
-   * this will allow for the default glyph, which should exist in
-   * any TrueType font. */
+  /* As a special case, we pass 0 even when it is not in the ranges;
+   * this will allow for the default glyph, which should exist in any
+   * TrueType font. */
 
   if(code>0 && font->nranges) {
     for(i=0; i<font->nranges; i++)
@@ -1090,11 +1001,15 @@
 
   idx=ttf_remap(code, &font->mapping);
 
-  if(idx==0 && code!=0) {
+  /* Only pass the default glyph if there is no first index */
+  if(idx==0 &&
+     (code != 0 ||
+      (font->mapping.encoding->first != 0 || 
+       font->mapping.encoding->first_col != 0))) {
     *g=0;
     return Successful;
   } else {
-    return FreeTypeInstanceGetGlyph(idx, g, font->instance, nlevels);
+    return FreeTypeInstanceGetGlyph(idx, g, font->instance);
   }
 }
 
@@ -1104,9 +1019,9 @@
   unsigned idx;
   int i;
 
-  /* As a special case, we pass 0 even when its not in the ranges;
-   * this will allow for the default glyph, which should exist in
-   * any TrueType font. */
+  /* As a special case, we pass 0 even when it is not in the ranges;
+   * this will allow for the default glyph, which should exist in any
+   * TrueType font. */
 
   if(code>0 && font->nranges) {
     for(i=0; i<font->nranges; i++)
@@ -1133,12 +1048,19 @@
 }
 
 static int
-FreeTypeFontGetDefaultGlyph(CharInfoPtr *g, TTFFont *font, int nlevels)
+FreeTypeFontGetDefaultGlyph(CharInfoPtr *g, TTFFont *font)
 {
+  /* Disable default glyph generation if there is a first index */
+  if(font->mapping.encoding && 
+     (font->mapping.encoding->first || font->mapping.encoding->first_col)) {
+    *g=0;
+    return Successful;
+  }
+    
   /* Using FreeTypeInstanceGetGlyph(0,...) would cause inconsistencies
    * between metrics and glyphs in the unlikely case that 0 is not
    * mapped to 0. */
-  return FreeTypeFontGetGlyph(0, g, font, nlevels);
+  return FreeTypeFontGetGlyph(0, g, font);
 }
 
 static int
@@ -1368,7 +1290,7 @@
   TT_Face_Properties *properties;
   int xrc, ftrc, i;
   int charcell, constantWidth;
-  long rawWidth, rawAverageWidth, aw, code, lastCode;
+  long rawWidth, rawAverageWidth, aw, code, lastCode, firstCode;
   int upm, minLsb, maxRsb, ascent, descent, width, averageWidth;
   
 
@@ -1421,15 +1343,18 @@
       TRANSFORM_FUNITS_Y(properties->horizontal->Ascender);
     info->fontDescent = 
       -TRANSFORM_FUNITS_Y(properties->horizontal->Descender);
+    firstCode=0;
+    lastCode=0xFFFFL;
     if(font->nranges) {
       lastCode=0;
+      /* The ranges information does not have an effect on firstCode,
+         as we pass the default glyph at position 0. */
       for(i=0; i<font->nranges; i++) {
         code=font->ranges[i].max_char_low+(font->ranges[i].max_char_high<<8);
         if(lastCode<code)
           lastCode=code;
       }
-    } else
-      lastCode=0xFFFFL;
+    }
 
     if(!font->mapping.encoding || font->mapping.encoding->row_size == 0) {
       /* linear indexing */
@@ -1437,20 +1362,25 @@
                    font->mapping.encoding ?
                    font->mapping.encoding->size-1 :
                    (font->mapping.has_cmap ? 0xFF : 0xFFFF));
-
-      info->firstRow=0;
+      if(font->mapping.encoding && font->mapping.encoding->first)
+        firstCode=font->mapping.encoding->first;
+      info->firstRow=firstCode/0x100;
       info->lastRow=lastCode/0x100;
-      info->firstCol=0;
-      info->lastCol=info->lastRow?0xFF:(lastCode&0xFF);
+      info->firstCol=
+        (info->firstRow || info->lastRow) ? 0 : (firstCode & 0xFF);
+      info->lastCol=info->lastRow ? 0xFF : (lastCode & 0xFF);
     } else {
       /* matrix indexing */
-      info->firstRow=0;
+      info->firstRow=font->mapping.encoding->first;
       info->lastRow=MIN(font->mapping.encoding->size-1, lastCode/0x100);
-      info->firstCol=0;
+      info->firstCol=font->mapping.encoding->first_col;
       info->lastCol=MIN(font->mapping.encoding->row_size-1, 
                         lastCode<0x100?lastCode:0xFF);
     }
 
+    /* firstCode and lastCode are not valid in case of a matrix
+       encoding */
+
     transformBBox(&instance->transformation, upm,
                   instance->imetrics.x_ppem, instance->imetrics.y_ppem,
                   charcell? 0 :
@@ -1577,9 +1507,9 @@
 }
 
 static int
-FreeTypeGetGlyphsAnti(FontPtr pFont, unsigned long count, unsigned char *chars,
-                      FontEncoding charEncoding, unsigned long *glyphCount,
-                      CharInfoPtr *glyphs, int nlevels)
+FreeTypeGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
+                  FontEncoding charEncoding, unsigned long *glyphCount,
+                  CharInfoPtr *glyphs)
 {
   unsigned code;
   TTFFont *tf;
@@ -1600,25 +1530,15 @@
       break;
     }
       
-    if(FreeTypeFontGetGlyph(code, &g, tf, nlevels)==Successful && g!=0) {
+    if(FreeTypeFontGetGlyph(code, &g, tf)==Successful && g!=0) {
       *gp++ = g;
     } else
-      if(FreeTypeFontGetDefaultGlyph(&g, tf, nlevels)==Successful && g!=0)
+      if(FreeTypeFontGetDefaultGlyph(&g, tf)==Successful && g!=0)
         *gp++ = g;
   }
     
   *glyphCount = gp - glyphs;
   return Successful;
-}
-
-static int
-FreeTypeGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
-                  FontEncoding charEncoding, unsigned long *glyphCount,
-                  CharInfoPtr *glyphs)
-{
-  return FreeTypeGetGlyphsAnti(pFont, count, chars,
-                               charEncoding, glyphCount,
-                               glyphs, 1);
 }
 
 static int
Index: xc/lib/font/FreeType/ftfuncs.h
diff -u xc/lib/font/FreeType/ftfuncs.h:1.8 xc/lib/font/FreeType/ftfuncs.h:1.9
--- xc/lib/font/FreeType/ftfuncs.h:1.8	Wed Oct 13 00:20:50 1999
+++ xc/lib/font/FreeType/ftfuncs.h	Tue Nov 14 11:54:43 2000
@@ -1,5 +1,27 @@
-/* $XFree86: xc/lib/font/FreeType/ftfuncs.h,v 1.8 1999/10/13 04:20:50 dawes Exp $ */
+/*
+Copyright (c) 1998-2000 by Juliusz Chroboczek
 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/* $XFree86: xc/lib/font/FreeType/ftfuncs.h,v 1.9 2000/11/14 16:54:43 dawes Exp $ */
+
 /* Number of buckets in the hashtable holding faces */
 #define NUMFACEBUCKETS 32
 
@@ -61,10 +83,6 @@
                                 /* 1=known not to exist */
                                 /* 2=known to exist, not rasterised */
                                 /* 3=rasterised, glyph available */
-#ifdef ANTI_ALIASING
-  CharInfoPtr *glyphsAnti;
-  int **availableAnti;
-#endif
   int refcount;
   struct TTFInstance_s *next;   /* link to next instance */
 } TTFInstance;
@@ -89,11 +107,9 @@
                       int charcell, FontBitmapFormat *bmfmt);
 static void FreeTypeFreeInstance(TTFInstance *instance);
 static int
- FreeTypeInstanceGetGlyph(unsigned idx, CharInfoPtr *g, TTFInstance *instance,
-                          int nlevels);
+ FreeTypeInstanceGetGlyph(unsigned idx, CharInfoPtr *g, TTFInstance *instance);
 static int 
-FreeTypeRasteriseGlyph(CharInfoPtr tgp, TTFInstance *instance,
-                       int hasMetrics, int nlevels);
+FreeTypeRasteriseGlyph(CharInfoPtr tgp, TTFInstance *instance, int hasMetrics);
 static void FreeTypeFreeFont(TTFFont *font);
 static void FreeTypeFreeXFont(FontPtr pFont, int freeProps);
 static void FreeTypeUnloadXFont(FontPtr pFont);
@@ -101,8 +117,8 @@
 FreeTypeAddProperties(TTFFont *font, FontScalablePtr vals, FontInfoPtr info, 
                       char *fontname, 
                       int rawAverageWidth);
-static int FreeTypeFontGetGlyph(unsigned code, CharInfoPtr *g, TTFFont *font, int nlevels);
-static int FreeTypeFontGetDefaultGlyph(CharInfoPtr *g, TTFFont *font, int nlevels);
+static int FreeTypeFontGetGlyph(unsigned code, CharInfoPtr *g, TTFFont *font);
+static int FreeTypeFontGetDefaultGlyph(CharInfoPtr *g, TTFFont *font);
 static int
 FreeTypeLoadFont(TTFFont **fontp, char *fileName,
                  FontScalablePtr vals, FontEntryPtr entry,
Index: xc/lib/font/FreeType/ftutil.c
diff -u xc/lib/font/FreeType/ftutil.c:1.10 xc/lib/font/FreeType/ftutil.c:1.11
--- xc/lib/font/FreeType/ftutil.c:1.10	Wed Oct 13 00:20:50 1999
+++ xc/lib/font/FreeType/ftutil.c	Fri Aug 11 17:12:42 2000
@@ -21,7 +21,7 @@
 THE SOFTWARE.
 */
 
-/* $XFree86: xc/lib/font/FreeType/ftutil.c,v 1.10 1999/10/13 04:20:50 dawes Exp $ */
+/* $XFree86: xc/lib/font/FreeType/ftutil.c,v 1.11 2000/08/11 21:12:42 dawes Exp $ */
 
 #ifndef FONTMODULE
 #include <ctype.h>
@@ -210,30 +210,42 @@
 {
   int length;
   int fn;
-  int i;
+  int i, j;
+  char *start, *realName;
 
   length=strlen(fileName);
-  if(length<3)
+  if(length<4)
+    return 0;
+
+  if(strcasecmp(fileName+(length-4), ".ttc"))
     return 0;
 
-  if(strcasecmp(fileName+(length-3), ".ttc"))
+  if (!(realName = xalloc(length + 1)))
     return 0;
 
-  if(fileName[0]==':') {
+  strcpy(realName, fileName);
+  *realFileName=realName;
+  start = strchr(realName, ':');
+  if (start) {
     fn=0;
     i=1;
-    while(isdigit(fileName[i])) {
+    while(isdigit(start[i])) {
       fn*=10;
-      fn+=fileName[i]-'0';
+      fn+=start[i]-'0';
+      i++;
     }
-    if(fileName[i]==':') {
+    if(start[i]==':') {
       *faceNumber=fn;
-      *realFileName=&(fileName[i+1]);
+      i++;
+      j = 0;
+      while (start[i]) {
+	start[j++] = start[i++];
+      }
+      start[j] = '\0';
       return 1;
     }
   }
 
   *faceNumber=0;
-  *realFileName=fileName;
   return 1;
 }
Index: xc/lib/font/FreeType/module/ftmodule.c
diff -u xc/lib/font/FreeType/module/ftmodule.c:1.7 xc/lib/font/FreeType/module/ftmodule.c:1.8
--- xc/lib/font/FreeType/module/ftmodule.c:1.7	Wed Oct 13 00:20:51 1999
+++ xc/lib/font/FreeType/module/ftmodule.c	Tue Nov 14 11:54:44 2000
@@ -23,7 +23,7 @@
  * dealings in this Software without prior written authorization from the
  * XFree86 Project.
  */
-/* $XFree86: xc/lib/font/FreeType/module/ftmodule.c,v 1.7 1999/10/13 04:20:51 dawes Exp $ */
+/* $XFree86: xc/lib/font/FreeType/module/ftmodule.c,v 1.8 2000/11/14 16:54:44 dawes Exp $ */
 
 #include "misc.h"
 
@@ -44,7 +44,7 @@
 	MODINFOSTRING1,
 	MODINFOSTRING2,
 	XF86_VERSION_CURRENT,
-	1, 1, 7,
+	1, 1, 8,
 	ABI_CLASS_FONT,			/* Font module */
 	ABI_FONT_VERSION,
 	MOD_CLASS_FONT,
Index: xc/lib/font/Speedo/Imakefile
diff -u xc/lib/font/Speedo/Imakefile:1.7 xc/lib/font/Speedo/Imakefile:1.8
--- xc/lib/font/Speedo/Imakefile:1.7	Mon Mar  1 21:49:14 1999
+++ xc/lib/font/Speedo/Imakefile	Tue Sep 19 08:46:07 2000
@@ -1,7 +1,7 @@
 XCOMM $XConsortium: Imakefile,v 1.10 93/09/04 16:42:59 rws Exp $
-XCOMM $XFree86: xc/lib/font/Speedo/Imakefile,v 1.7 1999/03/02 02:49:14 dawes Exp $
+XCOMM $XFree86: xc/lib/font/Speedo/Imakefile,v 1.8 2000/09/19 12:46:07 eich Exp $
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 #define IHaveSubdirs
 #define NoLibSubdirs
 #define PassCDebugFlags
@@ -32,7 +32,7 @@
 SubdirLibraryRule($(OBJS))
 NormalLintTarget($(SRCS))
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
 #endif
Index: xc/lib/font/Type1/Imakefile
diff -u xc/lib/font/Type1/Imakefile:1.8 xc/lib/font/Type1/Imakefile:1.9
--- xc/lib/font/Type1/Imakefile:1.8	Mon May  3 01:58:44 1999
+++ xc/lib/font/Type1/Imakefile	Tue Sep 19 08:46:07 2000
@@ -1,7 +1,7 @@
 XCOMM $XConsortium: Imakefile,v 1.5 93/09/04 16:43:32 rws Exp $
-XCOMM $XFree86: xc/lib/font/Type1/Imakefile,v 1.8 1999/05/03 05:58:44 dawes Exp $
+XCOMM $XFree86: xc/lib/font/Type1/Imakefile,v 1.9 2000/09/19 12:46:07 eich Exp $
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 #define IHaveSubdirs
 #define NoLibSubdirs
 #define PassCDebugFlags
@@ -77,7 +77,7 @@
 SubdirLibraryRule($(OBJS))
 NormalLintTarget($(SRCS))
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
 #endif
Index: xc/lib/font/Type1/regions.h
diff -u xc/lib/font/Type1/regions.h:1.5 xc/lib/font/Type1/regions.h:1.6
--- xc/lib/font/Type1/regions.h:1.5	Fri Apr 28 14:19:20 2000
+++ xc/lib/font/Type1/regions.h	Wed Aug  9 19:40:15 2000
@@ -26,7 +26,7 @@
  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  * THIS SOFTWARE.
  */
-/* $XFree86: xc/lib/font/Type1/regions.h,v 1.5 2000/04/28 18:19:20 eich Exp $ */
+/* $XFree86: xc/lib/font/Type1/regions.h,v 1.6 2000/08/09 23:40:15 dawes Exp $ */
 /*SHARED*/
  
 #define   Interior(p,rule)        t1_Interior(p,rule)
@@ -43,6 +43,10 @@
 struct region *t1_Intersect();  /* set intersection of regions                */
 struct region *t1_Complement();  /* complement of a region                    */
 int t1_Overlap();             /* returns a Boolean; TRUE if regions overlap   */
+#endif
+
+#ifdef __CYGWIN__
+#define __STRICT_ANSI__
 #endif
 
 #define   TT_INFINITY    t1_Infinity
Index: xc/lib/font/Type1/t1funcs.c
diff -u xc/lib/font/Type1/t1funcs.c:3.21 xc/lib/font/Type1/t1funcs.c:3.22
--- xc/lib/font/Type1/t1funcs.c:3.21	Sat Sep 25 10:36:39 1999
+++ xc/lib/font/Type1/t1funcs.c	Tue Sep 26 11:57:00 2000
@@ -71,7 +71,7 @@
  * The Original Software is CID font code that was developed by Silicon
  * Graphics, Inc.
  */
-/* $XFree86: xc/lib/font/Type1/t1funcs.c,v 3.21 1999/09/25 14:36:39 dawes Exp $ */
+/* $XFree86: xc/lib/font/Type1/t1funcs.c,v 3.22 2000/09/26 15:57:00 tsi Exp $ */
 
 /*
 
@@ -987,7 +987,7 @@
             if (c >= firstCol && c <= pFont->info.lastCol) {
                 code = c - firstCol;
                 if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
-                    (pci && (int)pci->bits == CID_BITMAP_UNDEFINED)) {
+                    ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
                     /* load font if not already loaded */
                     if(!cid_valid) {
                         if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) {                            FontP = NULL;
@@ -1022,7 +1022,7 @@
                 char_col = char_col - pFont->info.firstCol;
                 code = char_row * code + char_col;
                 if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
-                    (pci && (int)pci->bits == CID_BITMAP_UNDEFINED)) {
+                    ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
                     /* load font if not already loaded */
                     if(!cid_valid) {
                         if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) {                            FontP = NULL;
@@ -1060,7 +1060,7 @@
                 char_col = char_col - pFont->info.firstCol;
                 code = char_row * code + char_col;
                 if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
-                    (pci && (int)pci->bits == CID_BITMAP_UNDEFINED)) {
+                    ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
                     /* load font if not already loaded */
                     if(!cid_valid) {
                         if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) {                            FontP = NULL;
@@ -1564,7 +1564,7 @@
 
        addmemory(pool, size);
 
-       if (pci && (int)pci->bits == CID_BITMAP_UNDEFINED)
+       if (pci && (long)pci->bits == CID_BITMAP_UNDEFINED)
            glyphs = pci;
        else {
            if (!(glyphs = (CharInfoRec *)xalloc(sizeof(CharInfoRec)))) {
Index: xc/lib/font/X-TrueType/Imakefile
diff -u xc/lib/font/X-TrueType/Imakefile:1.5 xc/lib/font/X-TrueType/Imakefile:1.7
--- xc/lib/font/X-TrueType/Imakefile:1.5	Sun Feb 13 01:15:24 2000
+++ xc/lib/font/X-TrueType/Imakefile	Tue Nov 28 14:09:30 2000
@@ -1,10 +1,10 @@
 XCOMM X-TrueType Server - TrueType rasterizer for X
-XCOMM $XFree86: xc/lib/font/X-TrueType/Imakefile,v 1.5 2000/02/13 06:15:24 dawes Exp $
+XCOMM $XFree86: xc/lib/font/X-TrueType/Imakefile,v 1.7 2000/11/28 19:09:30 dawes Exp $
 
 #define IHaveSubdirs
 #define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 MODULE_SUBDIRS = module
 #endif
 
@@ -13,7 +13,8 @@
            -I$(FTSOURCEDIR)/lib -I$(FTSOURCEDIR)/lib/extend \
            -I$(FTSOURCEDIR)/lib/arch/unix -I$(FONTLIBSRC)/FreeType
 
-DEFINES = -DTT_MAKE_OPTION_SINGLE_OBJECT=1  $(FONTMODULEDEF) \
+DEFINES = -DTT_MAKE_OPTION_SINGLE_OBJECT=1  -DTT_CONFIG_OPTION_EXTEND_ENGINE \
+	  $(FONTMODULEDEF) \
 	  $(XTT_DEBUG_FLAGS) $(XTT_CCONV_MOUDLE_DEFINES) \
 	  $(XTT_USE_OPT_ENC_DEFINES)
 
Index: xc/lib/font/X-TrueType/cconvversion.h
diff -u xc/lib/font/X-TrueType/cconvversion.h:1.3 xc/lib/font/X-TrueType/cconvversion.h:1.4
--- xc/lib/font/X-TrueType/cconvversion.h:1.3	Sun Feb 13 01:50:34 2000
+++ xc/lib/font/X-TrueType/cconvversion.h	Tue Sep 26 11:57:01 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/font/X-TrueType/cconvversion.h,v 1.4 2000/09/26 15:57:01 tsi Exp $ */
 #if (!defined(__CODECONV_H))
 #define __CODECONV_H
 
@@ -67,7 +68,7 @@
 name ## Setup(pointer module, pointer opts, int *errmaj, int *errmin) \
 { \
 	ModuleSetupArg *moduleArg = (ModuleSetupArg*)opts; \
-	return (pointer) name ## _entrypoint (\
+	return (pointer)(long) name ## _entrypoint (\
 		moduleArg->charSetHints,\
 		moduleArg->refCodeConverterInfo,\
 		moduleArg->refMapID); \
@@ -78,7 +79,7 @@
 name ## Setup(pointer module, pointer opts, int *errmaj, int *errmin) \
 { \
 	ModuleSetupArg *moduleArg = (ModuleSetupArg*)opts; \
-	return (pointer) name ## _entrypoint (\
+	return (pointer)(long) name ## _entrypoint (\
 		moduleArg->charSetHints,\
 		moduleArg->refCodeConverterInfo,\
 		moduleArg->refMapID); \
Index: xc/lib/font/X-TrueType/module/Imakefile
diff -u xc/lib/font/X-TrueType/module/Imakefile:1.6 xc/lib/font/X-TrueType/module/Imakefile:1.7
--- xc/lib/font/X-TrueType/module/Imakefile:1.6	Sun Feb 13 01:50:35 2000
+++ xc/lib/font/X-TrueType/module/Imakefile	Tue Nov 28 14:09:30 2000
@@ -1,5 +1,5 @@
 XCOMM X-TrueType Server - TrueType rasterizer for X
-XCOMM $XFree86: xc/lib/font/X-TrueType/module/Imakefile,v 1.6 2000/02/13 06:50:35 dawes Exp $
+XCOMM $XFree86: xc/lib/font/X-TrueType/module/Imakefile,v 1.7 2000/11/28 19:09:30 dawes Exp $
 
 #define IHaveModules
 #include <Server.tmpl>
@@ -21,7 +21,8 @@
 #endif
 XTT_CCONV_MOUDLE_DEFINES = -DCCONV_MODULE -DCCONV_MODULE_DIR=\"$(MODULEDIR)/codeconv\"
 
-DEFINES = -DTT_MAKE_OPTION_SINGLE_OBJECT=1 -DFONTMODULE \
+DEFINES = -DTT_MAKE_OPTION_SINGLE_OBJECT=1 -DTT_CONFIG_OPTION_EXTEND_ENGINE \
+	  -DFONTMODULE \
 	  $(XTT_DEBUG_FLAGS) $(XTT_CCONV_MOUDLE_DEFINES) \
 	  $(XTT_USE_OPT_ENC_DEFINES)
 
Index: xc/lib/font/bitmap/Imakefile
diff -u xc/lib/font/bitmap/Imakefile:1.8 xc/lib/font/bitmap/Imakefile:1.9
--- xc/lib/font/bitmap/Imakefile:1.8	Fri Nov 19 08:53:27 1999
+++ xc/lib/font/bitmap/Imakefile	Tue Sep 19 08:46:07 2000
@@ -1,7 +1,7 @@
 XCOMM $XConsortium: Imakefile /main/9 1996/11/03 19:31:58 kaleb $
-XCOMM $XFree86: xc/lib/font/bitmap/Imakefile,v 1.8 1999/11/19 13:53:27 hohndel Exp $
+XCOMM $XFree86: xc/lib/font/bitmap/Imakefile,v 1.9 2000/09/19 12:46:07 eich Exp $
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 #define IHaveSubdirs
 #define NoLibSubdirs
 #define PassCDebugFlags
@@ -52,7 +52,7 @@
 SubdirLibraryRule($(OBJS))
 NormalLintTarget($(SRCS))
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
 #endif
Index: xc/lib/font/bitmap/pcfread.c
diff -u xc/lib/font/bitmap/pcfread.c:1.12 xc/lib/font/bitmap/pcfread.c:1.13
--- xc/lib/font/bitmap/pcfread.c:1.12	Fri Nov 19 08:53:29 1999
+++ xc/lib/font/bitmap/pcfread.c	Tue Sep 19 08:46:07 2000
@@ -23,7 +23,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/font/bitmap/pcfread.c,v 1.12 1999/11/19 13:53:29 hohndel Exp $ */
+/* $XFree86: xc/lib/font/bitmap/pcfread.c,v 1.13 2000/09/19 12:46:07 eich Exp $ */
 
 /*
  * Author:  Keith Packard, MIT X Consortium
@@ -32,6 +32,7 @@
 #include "fntfilst.h"
 #include "bitmap.h"
 #include "pcf.h"
+
 #ifndef MAX
 #define   MAX(a,b)    (((a)>(b)) ? a : b)
 #endif
@@ -41,6 +42,11 @@
 static void pcfUnloadFont ( FontPtr pFont );
 static int  position;
 
+
+#define IS_EOF(file) ((file)->eof == BUFFILEEOF)
+
+#define FONT_FILE_GETC_ERR(f)  (tmp = FontFileGetc(f), BAIL_ON_EOF)
+
 static int
 pcfGetLSB32(FontFilePtr file)
 {
@@ -105,6 +111,7 @@
     if (version != PCF_FILE_VERSION)
 	return (PCFTablePtr) NULL;
     count = pcfGetLSB32(file);
+    if (IS_EOF(file)) return (PCFTablePtr) NULL;
     tables = (PCFTablePtr) xalloc(count * sizeof(PCFTableRec));
     if (!tables)
 	return (PCFTablePtr) NULL;
@@ -113,9 +120,15 @@
 	tables[i].format = pcfGetLSB32(file);
 	tables[i].size = pcfGetLSB32(file);
 	tables[i].offset = pcfGetLSB32(file);
+	if (IS_EOF(file)) goto Bail;
     }
+
     *countp = count;
     return tables;
+
+ Bail:
+    xfree(tables);
+    return (PCFTablePtr) NULL;
 }
 
 /*
@@ -125,7 +138,7 @@
  * metrics
  */
 
-static void
+static Bool
 pcfGetMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
 {
     metric->leftSideBearing = pcfGetINT16(file, format);
@@ -134,9 +147,12 @@
     metric->ascent = pcfGetINT16(file, format);
     metric->descent = pcfGetINT16(file, format);
     metric->attributes = pcfGetINT16(file, format);
+    if (IS_EOF(file)) return FALSE;
+
+    return TRUE;
 }
 
-static void
+static Bool
 pcfGetCompressedMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
 {
     metric->leftSideBearing = pcfGetINT8(file, format) - 0x80;
@@ -145,6 +161,9 @@
     metric->ascent = pcfGetINT8(file, format) - 0x80;
     metric->descent = pcfGetINT8(file, format) - 0x80;
     metric->attributes = 0;
+    if (IS_EOF(file)) return FALSE;
+
+    return TRUE;
 }
 
 /*
@@ -210,6 +229,7 @@
     if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
 	goto Bail;
     nprops = pcfGetINT32(file, format);
+    if (IS_EOF(file)) goto Bail;
     props = (FontPropPtr) xalloc(nprops * sizeof(FontPropRec));
     if (!props)
 	goto Bail;
@@ -220,6 +240,7 @@
 	props[i].name = pcfGetINT32(file, format);
 	isStringProp[i] = pcfGetINT8(file, format);
 	props[i].value = pcfGetINT32(file, format);
+	if (IS_EOF(file)) goto Bail;
     }
     /* pad the property array */
     /*
@@ -232,12 +253,15 @@
 	(void)FontFileSkip(file, i);
 	position += i;
     }
+    if (IS_EOF(file)) goto Bail;
     string_size = pcfGetINT32(file, format);
+    if (IS_EOF(file)) goto Bail;
     strings = (char *) xalloc(string_size);
     if (!strings) {
 	goto Bail;
     }
     FontFileRead(file, strings, string_size);
+    if (IS_EOF(file)) goto Bail;
     position += string_size;
     for (i = 0; i < nprops; i++) {
 	props[i].name = MakeAtom(strings + props[i].name,
@@ -273,7 +297,8 @@
     CARD32      format;
     CARD32	size;
 
-    if (!pcfSeekToType(file, tables, ntables, type, &format, &size))
+    if (!pcfSeekToType(file, tables, ntables, type, &format, &size) ||
+	IS_EOF(file))
 	goto Bail;
     format = pcfGetLSB32(file);
     if (!PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT) &&
@@ -294,11 +319,16 @@
     pFontInfo->fontAscent = pcfGetINT32(file, format);
     pFontInfo->fontDescent = pcfGetINT32(file, format);
     pFontInfo->maxOverlap = pcfGetINT32(file, format);
-    pcfGetMetric(file, format, &pFontInfo->minbounds);
-    pcfGetMetric(file, format, &pFontInfo->maxbounds);
+    if (IS_EOF(file)) goto Bail;
+    if (!pcfGetMetric(file, format, &pFontInfo->minbounds))
+	goto Bail;
+    if (!pcfGetMetric(file, format, &pFontInfo->maxbounds))
+	goto Bail;
     if (PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) {
-	pcfGetMetric(file, format, &pFontInfo->ink_minbounds);
-	pcfGetMetric(file, format, &pFontInfo->ink_maxbounds);
+	if (!pcfGetMetric(file, format, &pFontInfo->ink_minbounds))
+	    goto Bail;
+	if (!pcfGetMetric(file, format, &pFontInfo->ink_maxbounds))
+	    goto Bail;
     } else {
 	pFontInfo->ink_minbounds = pFontInfo->minbounds;
 	pFontInfo->ink_maxbounds = pFontInfo->maxbounds;
@@ -362,16 +392,20 @@
 	nmetrics = pcfGetINT32(file, format);
     else
 	nmetrics = pcfGetINT16(file, format);
+    if (IS_EOF(file)) goto Bail;
     metrics = (CharInfoPtr) xalloc(nmetrics * sizeof(CharInfoRec));
     if (!metrics) {
 	goto Bail;
     }
     for (i = 0; i < nmetrics; i++)
-	if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
-	    pcfGetMetric(file, format, &(metrics + i)->metrics);
-	else
-	    pcfGetCompressedMetric(file, format, &(metrics + i)->metrics);
-
+	if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+	    if (!pcfGetMetric(file, format, &(metrics + i)->metrics))
+		goto Bail;
+	} else {
+	    if (!pcfGetCompressedMetric(file, format, &(metrics + i)->metrics))
+		goto Bail;
+	}
+    
     /* bitmaps */
 
     if (!pcfSeekToType(file, tables, ntables, PCF_BITMAPS, &format, &size))
@@ -381,24 +415,30 @@
 	goto Bail;
 
     nbitmaps = pcfGetINT32(file, format);
-    if (nbitmaps != nmetrics)
+    if (nbitmaps != nmetrics || IS_EOF(file))
 	goto Bail;
 
     offsets = (CARD32 *) xalloc(nbitmaps * sizeof(CARD32));
     if (!offsets)
 	goto Bail;
 
-    for (i = 0; i < nbitmaps; i++)
+    for (i = 0; i < nbitmaps; i++) {
 	offsets[i] = pcfGetINT32(file, format);
+	if (IS_EOF(file)) goto Bail;
+    }
 
-    for (i = 0; i < GLYPHPADOPTIONS; i++)
+    for (i = 0; i < GLYPHPADOPTIONS; i++) {
 	bitmapSizes[i] = pcfGetINT32(file, format);
+	if (IS_EOF(file)) goto Bail;
+    }
+    
     sizebitmaps = bitmapSizes[PCF_GLYPH_PAD_INDEX(format)];
     /* guard against completely empty font */
     bitmaps = xalloc(sizebitmaps ? sizebitmaps : 1);
     if (!bitmaps)
 	goto Bail;
     FontFileRead(file, bitmaps, sizebitmaps);
+    if (IS_EOF(file)) goto Bail;
     position += sizebitmaps;
 
     if (PCF_BIT_ORDER(format) != bit)
@@ -459,16 +499,20 @@
 	    nink_metrics = pcfGetINT32(file, format);
 	else
 	    nink_metrics = pcfGetINT16(file, format);
+	if (IS_EOF(file)) goto Bail;
 	if (nink_metrics != nmetrics)
 	    goto Bail;
 	ink_metrics = (xCharInfo *) xalloc(nink_metrics * sizeof(xCharInfo));
 	if (!ink_metrics)
 	    goto Bail;
 	for (i = 0; i < nink_metrics; i++)
-	    if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
-		pcfGetMetric(file, format, ink_metrics + i);
-	    else
-		pcfGetCompressedMetric(file, format, ink_metrics + i);
+	    if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+		if (!pcfGetMetric(file, format, ink_metrics + i))
+		    goto Bail;
+	    } else {
+		if (!pcfGetCompressedMetric(file, format, ink_metrics + i))
+		    goto Bail;
+	    }
     }
 
     /* encoding */
@@ -484,6 +528,7 @@
     pFont->info.firstRow = pcfGetINT16(file, format);
     pFont->info.lastRow = pcfGetINT16(file, format);
     pFont->info.defaultCh = pcfGetINT16(file, format);
+    if (IS_EOF(file)) goto Bail;
 
     nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
 	(pFont->info.lastRow - pFont->info.firstRow + 1);
@@ -496,6 +541,7 @@
     pFont->info.allExist = TRUE;
     for (i = 0; i < nencoding; i++) {
 	encodingOffset = pcfGetINT16(file, format);
+	if (IS_EOF(file)) goto Bail;
 	if (encodingOffset == 0xFFFF) {
 	    pFont->info.allExist = FALSE;
 	} else {
@@ -563,12 +609,13 @@
     }
     xfree(encoding);
     xfree(bitmaps);
-    xfree(offsets);
     xfree(metrics);
     xfree(pFont->info.props);
     pFont->info.props = 0;
+    xfree (pFont->info.isStringProp);
     xfree(bitmapFont);
     xfree(tables);
+    xfree(offsets);
     return AllocError;
 }
 
@@ -613,6 +660,7 @@
     pFontInfo->firstRow = pcfGetINT16(file, format);
     pFontInfo->lastRow = pcfGetINT16(file, format);
     pFontInfo->defaultCh = pcfGetINT16(file, format);
+    if (IS_EOF(file)) goto Bail;
 
     nencoding = (pFontInfo->lastCol - pFontInfo->firstCol + 1) *
 	(pFontInfo->lastRow - pFontInfo->firstRow + 1);
@@ -621,7 +669,9 @@
     while (nencoding--) {
 	if (pcfGetINT16(file, format) == 0xFFFF)
 	    pFontInfo->allExist = FALSE;
+	if (IS_EOF(file)) goto Bail;
     }
+    if (IS_EOF(file)) goto Bail;
 
     /* BDF style accelerators (i.e. bounds based on encoded glyphs) */
 
@@ -684,6 +734,7 @@
     CharInfoPtr pci;
 
     pFont->info.props = 0;
+
     if (!(tables = pcfReadTOC(file, &ntables)))
 	goto Bail;
 
@@ -713,16 +764,20 @@
 	nmetrics = pcfGetINT32(file, format);
     else
 	nmetrics = pcfGetINT16(file, format);
+    if (IS_EOF(file)) goto Bail;
     metrics = (CharInfoPtr) xalloc(nmetrics * sizeof(CharInfoRec));
     if (!metrics) {
 	goto Bail;
     }
     for (i = 0; i < nmetrics; i++)
-	if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
-	    pcfGetMetric(file, format, &(metrics + i)->metrics);
-	else
-	    pcfGetCompressedMetric(file, format, &(metrics + i)->metrics);
-
+	if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+	    if (!pcfGetMetric(file, format, &(metrics + i)->metrics))
+		goto Bail;
+	} else {
+	    if (!pcfGetCompressedMetric(file, format, &(metrics + i)->metrics))
+		goto Bail;
+	}
+    
     /* Set the bitmaps to all point to the same zero filled array 
      * that is the size of the largest bitmap.
      */
@@ -764,14 +819,18 @@
 	    nink_metrics = pcfGetINT16(file, format);
 	if (nink_metrics != nmetrics)
 	    goto Bail;
+	if (IS_EOF(file)) goto Bail;
 	ink_metrics = (xCharInfo *) xalloc(nink_metrics * sizeof(xCharInfo));
 	if (!ink_metrics)
 	    goto Bail;
 	for (i = 0; i < nink_metrics; i++)
-	    if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT))
-		pcfGetMetric(file, format, ink_metrics + i);
-	    else
-		pcfGetCompressedMetric(file, format, ink_metrics + i);
+	    if (PCF_FORMAT_MATCH(format, PCF_DEFAULT_FORMAT)) {
+		if (!pcfGetMetric(file, format, ink_metrics + i))
+		    goto Bail;
+	    } else {
+		if (!pcfGetCompressedMetric(file, format, ink_metrics + i))
+		    goto Bail;
+	    }
     }
 
     /* encoding */
@@ -787,6 +846,7 @@
     pFont->info.firstRow = pcfGetINT16(file, format);
     pFont->info.lastRow = pcfGetINT16(file, format);
     pFont->info.defaultCh = pcfGetINT16(file, format);
+    if (IS_EOF(file)) goto Bail;
 
     nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
 	(pFont->info.lastRow - pFont->info.firstRow + 1);
@@ -799,6 +859,7 @@
     pFont->info.allExist = TRUE;
     for (i = 0; i < nencoding; i++) {
 	encodingOffset = pcfGetINT16(file, format);
+	if (IS_EOF(file)) goto Bail;
 	if (encodingOffset == 0xFFFF) {
 	    pFont->info.allExist = FALSE;
 	    encoding[i] = 0;
@@ -812,6 +873,7 @@
             }
 	    ACCESSENCODINGL(encoding, i) = metrics + encodingOffset;
     }
+    if (IS_EOF(file)) goto Bail;
 
     /* BDF style accelerators (i.e. bounds based on encoded glyphs) */
 
@@ -865,10 +927,12 @@
             xfree(encoding[i]);
     }
     xfree(encoding);
+    xfree(bitmaps);
     xfree(metrics);
     xfree(pFont->info.props);
-    xfree(bitmapFont);
     pFont->info.props = 0;
+    xfree (pFont->info.isStringProp);
+    xfree(bitmapFont);
     xfree(tables);
     return AllocError;
 }
Index: xc/lib/font/fc/fsio.c
diff -u xc/lib/font/fc/fsio.c:3.11 xc/lib/font/fc/fsio.c:3.12
--- xc/lib/font/fc/fsio.c:3.11	Sun Dec 26 20:14:10 1999
+++ xc/lib/font/fc/fsio.c	Tue Nov 28 12:25:09 2000
@@ -23,7 +23,7 @@
  *
  * Author:  	Dave Lemke, Network Computing Devices, Inc
  */
-/* $XFree86: xc/lib/font/fc/fsio.c,v 3.11 1999/12/27 01:14:10 robin Exp $ */
+/* $XFree86: xc/lib/font/fc/fsio.c,v 3.12 2000/11/28 17:25:09 dawes Exp $ */
 /*
  * font server i/o routines
  */
@@ -107,7 +107,8 @@
 {
     XtransConnInfo  trans_conn;		/* transport connection object */
     int		    ret;
-    int		    i;
+    int		    i = 0;
+    int		    retries = 5;
 
     /*
      * Open the network connection.
@@ -123,10 +124,12 @@
      */
 
     _FontTransSetOption(trans_conn, TRANS_NONBLOCKING, 1);
-    
-    do
+
+    do {
+	if (i == TRANS_TRY_CONNECT_AGAIN)
+	    sleep(1);
 	i = _FontTransConnect(trans_conn,servername);
-    while (i == TRANS_TRY_CONNECT_AGAIN);
+    } while ((i == TRANS_TRY_CONNECT_AGAIN) && (retries-- > 0));
 
     if (i < 0)
     {
Index: xc/lib/font/fontcache/fontcache.c
diff -u xc/lib/font/fontcache/fontcache.c:1.2 xc/lib/font/fontcache/fontcache.c:1.3
--- xc/lib/font/fontcache/fontcache.c:1.2	Wed Feb 23 15:29:38 2000
+++ xc/lib/font/fontcache/fontcache.c	Tue Sep 26 11:57:01 2000
@@ -26,6 +26,7 @@
  *
  *	Id: fontcache.c,v 1.19 1999/01/31 13:06:00 akiyama Exp $
  */
+/* $XFree86: xc/lib/font/fontcache/fontcache.c,v 1.3 2000/09/26 15:57:01 tsi Exp $ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -235,7 +236,7 @@
             return NULL;
     }
 
-    linesize = (int) arg;
+    linesize = (long)arg;
 #if defined(HASH_DEBUG) || defined(DEBUG)
 fprintf(stderr, "FontCacheOpenCache: line size=%d\n", linesize);
 #endif
Index: xc/lib/font/fontfile/Imakefile
diff -u xc/lib/font/fontfile/Imakefile:3.16 xc/lib/font/fontfile/Imakefile:3.17
--- xc/lib/font/fontfile/Imakefile:3.16	Sun Feb 13 01:15:28 2000
+++ xc/lib/font/fontfile/Imakefile	Tue Sep 19 08:46:08 2000
@@ -1,8 +1,8 @@
 XCOMM $XConsortium: Imakefile /main/14 1996/11/03 19:58:41 kaleb $
-XCOMM $XFree86: xc/lib/font/fontfile/Imakefile,v 3.16 2000/02/13 06:15:28 dawes Exp $
+XCOMM $XFree86: xc/lib/font/fontfile/Imakefile,v 3.17 2000/09/19 12:46:08 eich Exp $
 #include <Server.tmpl>
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 #define IHaveSubdirs
 #define NoLibSubdirs
 SUBDIRS = module
@@ -66,7 +66,7 @@
 SubdirLibraryRule($(OBJS))
 NormalLintTarget($(SRCS))
 
-#if DoLoadableServer
+#if BuildServer && DoLoadableServer
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
 #endif
Index: xc/lib/font/fontfile/bufio.c
diff -u xc/lib/font/fontfile/bufio.c:3.5 xc/lib/font/fontfile/bufio.c:3.6
--- xc/lib/font/fontfile/bufio.c:3.5	Sat Jul 17 01:30:39 1999
+++ xc/lib/font/fontfile/bufio.c	Tue Sep 19 08:46:08 2000
@@ -23,7 +23,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/font/fontfile/bufio.c,v 3.5 1999/07/17 05:30:39 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/bufio.c,v 3.6 2000/09/19 12:46:08 eich Exp $ */
 
 /*
  * Author:  Keith Packard, MIT X Consortium
@@ -56,6 +56,7 @@
     f->input = input;
     f->output = output;
     f->skip = skip;
+    f->eof  = 0;
     f->close = close;
     return f;
 }
Index: xc/lib/font/fontfile/decompress.c
diff -u xc/lib/font/fontfile/decompress.c:1.2 xc/lib/font/fontfile/decompress.c:1.3
--- xc/lib/font/fontfile/decompress.c:1.2	Sat Jul 17 01:30:39 1999
+++ xc/lib/font/fontfile/decompress.c	Tue Sep 19 08:46:08 2000
@@ -41,7 +41,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/font/fontfile/decompress.c,v 1.2 1999/07/17 05:30:39 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/decompress.c,v 1.3 2000/09/19 12:46:08 eich Exp $ */
 /* 
  * decompress - cat a compressed file
  */
@@ -147,6 +147,8 @@
 	return 0;
     }
     code = BufFileGet (f);
+    if (code == BUFFILEEOF) return 0;
+    
     maxbits = code & BIT_MASK;
     if (maxbits > BITS || maxbits < 12)
 	return 0;
@@ -392,7 +394,7 @@
     inputraw = BufFileOpenRead (0);
     input = BufFilePushCompressed (inputraw);
     output = BufFileOpenWrite (1);
-    while ((c = BufFileGet (input)) != -1)
+    while ((c = BufFileGet (input)) != BUFFILEEOF)
 	BufFilePut (c, output);
     BufFileClose (input, FALSE);
     BufFileClose (output, FALSE);
Index: xc/lib/font/fontfile/encparse.c
diff -u xc/lib/font/fontfile/encparse.c:1.12 xc/lib/font/fontfile/encparse.c:1.14
--- xc/lib/font/fontfile/encparse.c:1.12	Sat Aug 21 09:48:02 1999
+++ xc/lib/font/fontfile/encparse.c	Tue Nov 14 11:54:45 2000
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 1998 by Juliusz Chroboczek
+Copyright (c) 1998-2000 by Juliusz Chroboczek
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -20,7 +20,7 @@
 THE SOFTWARE.
 */
 
-/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.12 1999/08/21 13:48:02 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.14 2000/11/14 16:54:45 dawes Exp $ */
 
 /* Parser for encoding files */
 
@@ -55,6 +55,7 @@
 #define NAME_LINE 7
 #define SIZE_LINE 8
 #define ALIAS_LINE 9
+#define FIRSTINDEX_LINE 10
 
 /* Return from lexer */
 #define MAXKEYWORDLEN 100
@@ -71,7 +72,7 @@
 skipEndOfLine(FontFilePtr f, int c)
 {
   if(c==0)
-    c==FontFileGetc(f);
+    c=FontFileGetc(f);
   
   for(;;)
     if(c<=0 || c=='\n')
@@ -266,6 +267,26 @@
         skipEndOfLine(f,c);
         return ERROR_LINE;
       }
+    } else if(!strcasecmp(keyword_value, "FIRSTINDEX")) {
+      token=gettoken(f,c,&c);
+      if(token==NUMBER_TOKEN) {
+        value1=number_value;
+        token=gettoken(f,c,&c);
+        switch(token) {
+        case NUMBER_TOKEN:
+          value2=number_value;
+          return FIRSTINDEX_LINE;
+        case EOL_TOKEN:
+          value2=0;
+          return FIRSTINDEX_LINE;
+        default:
+          skipEndOfLine(f,c);
+          return ERROR_LINE;
+        }
+      } else {
+        skipEndOfLine(f,c);
+        return ERROR_LINE;
+      }
     } else if(!strcasecmp(keyword_value, "STARTMAPPING")) {
       keyword_value[0]=0;
       value1=0; value1=0;
@@ -440,6 +461,7 @@
     encoding->row_size=0;
     encoding->mappings=NULL;
     encoding->next=NULL;
+    encoding->first=encoding->first_col=0;
     goto no_mapping;
   default:
     goto error;
@@ -462,6 +484,10 @@
     encoding->size=value1;
     encoding->row_size=value2;
     goto no_mapping;
+  case FIRSTINDEX_LINE:
+    encoding->first=value1;
+    encoding->first_col=value2;
+    goto no_mapping;
   case STARTMAPPING_LINE:
     if(headerOnly)
       goto done;
@@ -783,7 +809,7 @@
 }
 
 /* Return a NULL-terminated array of encoding names.  Note that this
- * file has incestuous knowledge of the allocations done by
+ * function has incestuous knowledge of the allocations done by
  * parseEncodingFile. */
 
 char **
Index: xc/lib/font/fontfile/filewr.c
diff -u xc/lib/font/fontfile/filewr.c:3.3 xc/lib/font/fontfile/filewr.c:3.4
--- xc/lib/font/fontfile/filewr.c:3.3	Sat Aug 21 09:48:03 1999
+++ xc/lib/font/fontfile/filewr.c	Wed Aug  9 19:40:15 2000
@@ -21,7 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/lib/font/fontfile/filewr.c,v 3.3 1999/08/21 13:48:03 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/filewr.c,v 3.4 2000/08/09 23:40:15 dawes Exp $ */
 
 /*
  * Author:  Keith Packard, MIT X Consortium
@@ -35,7 +35,7 @@
 {
     int	fd;
 
-#if defined(WIN32) || defined(__EMX__)
+#if defined(WIN32) || defined(__EMX__) || defined(__CYGWIN__)
     fd = open (name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0666);
 #else
     fd = creat (name, 0666);
Index: xc/lib/font/fontfile/fontenc.c
diff -u xc/lib/font/fontfile/fontenc.c:1.9 xc/lib/font/fontfile/fontenc.c:1.10
--- xc/lib/font/fontfile/fontenc.c:1.9	Wed Oct 13 00:20:51 1999
+++ xc/lib/font/fontfile/fontenc.c	Tue Nov 14 11:54:45 2000
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 1998 by Juliusz Chroboczek
+Copyright (c) 1998-2000 by Juliusz Chroboczek
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -20,7 +20,7 @@
 THE SOFTWARE.
 */
 
-/* $XFree86: xc/lib/font/fontfile/fontenc.c,v 1.9 1999/10/13 04:20:51 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/fontenc.c,v 1.10 2000/11/14 16:54:45 dawes Exp $ */
 
 /* Backend-independent encoding code */
 
@@ -538,26 +538,26 @@
 
 static struct font_encoding initial_encodings[]=
 {
-  {"iso10646-1",0,256*256,0,iso10646,0}, /* Unicode */
-  {"iso8859-1",0,256,0,iso8859_1,0},  /* Latin 1 (West European) */
-  {"iso8859-2",0,256,0,iso8859_2,0},  /* Latin 2 (East European) */
-  {"iso8859-3",0,256,0,iso8859_3,0},  /* Latin 3 (South European) */
-  {"iso8859-4",0,256,0,iso8859_4,0},  /* Latin 4 (North European) */
-  {"iso8859-5",0,256,0,iso8859_5,0},  /* Cyrillic */
-  {"iso8859-6",0,256,0,iso8859_6,0},  /* Arabic */
-  {"iso8859-7",0,256,0,iso8859_7,0},  /* Greek */
-  {"iso8859-8",0,256,0,iso8859_8,0},  /* Hebrew */
-  {"iso8859-9",0,256,0,iso8859_9,0},  /* Latin 5 (Turkish) */
-  {"iso8859-10",0,256,0,iso8859_10,0},/* Latin 6 (Nordic) */
-  {"iso8859-15",iso8859_15_aliases,256,0,iso8859_15,0}, /* Latin 9 */
-  {"koi8-r",0,256,0,koi8_r,0},        /* Russian */
-  {"koi8-ru",0,256,0,koi8_ru,0},      /* Ukrainian */
-  {"koi8-uni",0,256,0,koi8_uni,0},    /* Russian/Ukrainian/Bielorussian */
-  {"koi8-e",0,256,0,koi8_e,0},        /* ``European'' */
-  {"koi8-u",0,256,0,koi8_u,0},        /* Ukrainian too */
-  {"microsoft-symbol",0,256,0,microsoft_symbol,0},
-  {"apple-roman",0,256,0,apple_roman,0},
-  {0,0,0,0,0}
+  {"iso10646-1",0,256*256,0,iso10646,0,0,0}, /* Unicode */
+  {"iso8859-1",0,256,0,iso8859_1,0,0,0}, /* Latin 1 (West European) */
+  {"iso8859-2",0,256,0,iso8859_2,0,0,0}, /* Latin 2 (East European) */
+  {"iso8859-3",0,256,0,iso8859_3,0,0,0}, /* Latin 3 (South European) */
+  {"iso8859-4",0,256,0,iso8859_4,0,0,0}, /* Latin 4 (North European) */
+  {"iso8859-5",0,256,0,iso8859_5,0,0,0}, /* Cyrillic */
+  {"iso8859-6",0,256,0,iso8859_6,0,0,0}, /* Arabic */
+  {"iso8859-7",0,256,0,iso8859_7,0,0,0}, /* Greek */
+  {"iso8859-8",0,256,0,iso8859_8,0,0,0}, /* Hebrew */
+  {"iso8859-9",0,256,0,iso8859_9,0,0,0}, /* Latin 5 (Turkish) */
+  {"iso8859-10",0,256,0,iso8859_10,0,0,0}, /* Latin 6 (Nordic) */
+  {"iso8859-15",iso8859_15_aliases,256,0,iso8859_15,0,0,0}, /* Latin 9 */
+  {"koi8-r",0,256,0,koi8_r,0,0,0},       /* Russian */
+  {"koi8-ru",0,256,0,koi8_ru,0,0,0},     /* Ukrainian */
+  {"koi8-uni",0,256,0,koi8_uni,0,0,0},   /* Russian/Ukrainian/Bielorussian */
+  {"koi8-e",0,256,0,koi8_e,0,0,0},       /* ``European'' */
+  {"koi8-u",0,256,0,koi8_u,0,0,0},       /* Ukrainian too */
+  {"microsoft-symbol",0,256,0,microsoft_symbol,0,0,0},
+  {"apple-roman",0,256,0,apple_roman,0,0,0},
+  {0,0,0,0,0,0,0}
 };
 
 static struct font_encoding *font_encodings=NULL;
@@ -629,10 +629,17 @@
                      struct font_encoding_mapping *mapping)
 {
   if(mapping->recode) {
-    if((encoding->row_size==0 && code>=encoding->size) ||
-       (encoding->row_size!=0 &&
-        (code/0x100>=encoding->size || ((code&0xFF)>=encoding->row_size))))
-      return 0;
+    if(encoding->row_size==0) {
+      /* linear encoding */
+      if(code < encoding->first || code>=encoding->size)
+        return 0;
+    } else {
+      /* matrix encoding */
+      int row=code/0x100, col=code&0xFF;
+      if(row < encoding->first || row >= encoding->size ||
+         col < encoding->first_col || col >= encoding->row_size)
+        return 0;
+    }
     return (*mapping->recode)(code, mapping->client_data);
   } else
     return code;
@@ -683,8 +690,49 @@
   if((encoding=loadEncodingFile(encoding_name, filename))==NULL) {
     return 0;
   } else {
+    char **alias;
+    int found = 0;
+
+    /* Check whether the name is already known for this encoding */
+    if(strcasecmp(encoding->name, encoding_name) == 0) {
+      found = 1;
+    } else {
+      for(alias=encoding->aliases; *alias; alias++)
+        if(!strcasecmp(*alias, encoding_name)) {
+          found = 1;
+          break;
+        }
+    }
+
+    if(!found) {
+      /* Add a new alias.  This works because the encoding has been
+         allocated dynamically */
+      char **new_aliases;
+      char *new_name;
+      int numaliases = 0;
+
+      new_name = xalloc(strlen(encoding_name + 1));
+      if(new_name == NULL)
+        return NULL;
+      strcpy(new_name, encoding_name);
+      for(alias = encoding->aliases; *alias; alias++)
+        numaliases++;
+      new_aliases = (char**)xalloc((numaliases+2)*sizeof(char*));
+      if(new_aliases == NULL) {
+        xfree(new_name);
+        return NULL;
+      }
+      memcpy(new_aliases, encoding->aliases, numaliases*sizeof(char*));
+      new_aliases[numaliases] = new_name;
+      new_aliases[numaliases+1] = NULL;
+      xfree(encoding->aliases);
+      encoding->aliases = new_aliases;
+    }
+          
+    /* register the new encoding */
     encoding->next=font_encodings;
     font_encodings=encoding;
+
     return encoding;
   }
 }
Index: xc/lib/font/fontfile/gunzip.c
diff -u xc/lib/font/fontfile/gunzip.c:1.3 xc/lib/font/fontfile/gunzip.c:1.4
--- xc/lib/font/fontfile/gunzip.c:1.3	Sat Jul 17 01:30:42 1999
+++ xc/lib/font/fontfile/gunzip.c	Tue Sep 19 08:46:08 2000
@@ -2,7 +2,7 @@
 /* lib/font/fontfile/gunzip.c
    written by Mark Eichin <eichin@kitten.gen.ma.us> September 1996.
    intended for inclusion in X11 public releases. */
-/* $XFree86: xc/lib/font/fontfile/gunzip.c,v 1.3 1999/07/17 05:30:42 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/gunzip.c,v 1.4 2000/09/19 12:46:08 eich Exp $ */
 
 #include "fontmisc.h"
 #include <bufio.h>
@@ -102,7 +102,8 @@
   case Z_STREAM_END:
   case Z_DATA_ERROR:
   case Z_ERRNO:
-    return BUFFILEEOF;
+      f->left = 0;
+      return BUFFILEEOF;
   default:
     return BUFFILEEOF;
   }
Index: xc/lib/font/include/bitmap.h
diff -u xc/lib/font/include/bitmap.h:1.7 xc/lib/font/include/bitmap.h:1.8
--- xc/lib/font/include/bitmap.h:1.7	Sun Aug  1 03:56:57 1999
+++ xc/lib/font/include/bitmap.h	Tue Oct 24 18:45:02 2000
@@ -23,7 +23,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/font/include/bitmap.h,v 1.7 1999/08/01 07:56:57 dawes Exp $ */
+/* $XFree86: xc/lib/font/include/bitmap.h,v 1.8 2000/10/24 22:45:02 dawes Exp $ */
 
 /*
  * Author:  Keith Packard, MIT X Consortium
@@ -68,7 +68,7 @@
 #define ACCESSENCODING(enc,i) \
 (enc[(i)/BITMAP_FONT_SEGMENT_SIZE]?\
 (enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE]):\
-NULL)
+0)
 #define ACCESSENCODINGL(enc,i) \
 (enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE])
 
Index: xc/lib/font/include/bufio.h
diff -u xc/lib/font/include/bufio.h:1.3 xc/lib/font/include/bufio.h:1.4
--- xc/lib/font/include/bufio.h:1.3	Sat Jul 17 01:30:46 1999
+++ xc/lib/font/include/bufio.h	Tue Sep 19 08:46:08 2000
@@ -23,7 +23,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/font/include/bufio.h,v 1.3 1999/07/17 05:30:46 dawes Exp $ */
+/* $XFree86: xc/lib/font/include/bufio.h,v 1.4 2000/09/19 12:46:08 eich Exp $ */
 
 #ifndef ___BUFIO_H___
 #define ___BUFIO_H___ 1
@@ -46,6 +46,7 @@
 typedef struct _buffile {
     BufChar *bufp;
     int	    left;
+    int     eof;
     BufChar buffer[BUFFILESIZE];
     int	    (*input)( BufFilePtr /* f */);
     int     (*output)( int /* c */, BufFilePtr /* f */);
@@ -72,9 +73,9 @@
 extern int BufFileWrite ( BufFilePtr, char*, int );
 extern void BufFileFree ( BufFilePtr );
 
-#define BufFileGet(f)	((f)->left-- ? *(f)->bufp++ : (*(f)->input) (f))
+#define BufFileGet(f)	((f)->left-- ? *(f)->bufp++ : ((f)->eof = (*(f)->input) (f)))
 #define BufFilePut(c,f)	(--(f)->left ? *(f)->bufp++ = (c) : (*(f)->output) (c,f))
-#define BufFileSkip(f,c)    ((*(f)->skip) (f, c))
+#define BufFileSkip(f,c)    ((f)->eof = (*(f)->skip) (f, c))
 
 #ifndef TRUE
 #define TRUE 1
@@ -84,3 +85,4 @@
 #endif
 
 #endif /* ___BUFIO_H___ */
+
Index: xc/lib/font/include/fontenc.h
diff -u xc/lib/font/include/fontenc.h:1.6 xc/lib/font/include/fontenc.h:1.7
--- xc/lib/font/include/fontenc.h:1.6	Mon May  3 08:15:54 1999
+++ xc/lib/font/include/fontenc.h	Tue Nov 14 11:54:45 2000
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 1998 by Juliusz Chroboczek
+Copyright (c) 1998-2000 by Juliusz Chroboczek
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -20,7 +20,7 @@
 THE SOFTWARE.
 */
 
-/* $XFree86: xc/lib/font/include/fontenc.h,v 1.6 1999/05/03 12:15:54 dawes Exp $ */
+/* $XFree86: xc/lib/font/include/fontenc.h,v 1.7 2000/11/14 16:54:45 dawes Exp $ */
 
 /* Header for backend-independent encoding code */
 
@@ -67,6 +67,10 @@
   int row_size;                 /* the size of a row, or 0 if bytes */
   struct font_encoding_mapping *mappings; /* linked list of mappings */
   struct font_encoding *next;   /* link to next element */
+  /* the following two were added in version 0.2 of the font interface */
+  /* they should be kept at the end to preserve binary compatibility */
+  int first;                    /* first byte or row */
+  int first_col;                /* first column in each row */
 };
 
 
@@ -91,5 +95,8 @@
                          struct font_encoding*,
                          struct font_encoding_mapping*);
 
+/* Identify an encoding file.  If fileName doesn't exist, or is not an
+   encoding file, return NULL, otherwise returns a NULL-terminated
+   array of strings. */
 char **identifyEncodingFile(const char *fileName);
 #endif
Index: xc/lib/font/util/Imakefile
diff -u xc/lib/font/util/Imakefile:1.4 xc/lib/font/util/Imakefile:1.6
--- xc/lib/font/util/Imakefile:1.4	Tue Apr 27 03:08:59 1999
+++ xc/lib/font/util/Imakefile	Thu Dec  7 11:40:30 2000
@@ -1,5 +1,5 @@
 XCOMM $XConsortium: Imakefile,v 1.11 94/02/07 16:07:31 gildea Exp $
-XCOMM $XFree86: xc/lib/font/util/Imakefile,v 1.4 1999/04/27 07:08:59 dawes Exp $
+XCOMM $XFree86: xc/lib/font/util/Imakefile,v 1.6 2000/12/07 16:40:30 dawes Exp $
 #include <Server.tmpl>
 
         INCLUDES = -I$(FONTINCSRC) -I../include
@@ -7,7 +7,14 @@
 #ifdef FontFormatDefines
      FORMAT_DEFS = FontFormatDefines
 #endif
-         DEFINES = StrcasecmpDefines
+
+#if defined(SunArchitecture) && (OSMajorVersion == 5) && (OSMinorVersion <= 6)
+    /* Work around a problem with __ctype being a "relocation against
+       allocatable but non-writable section" on Solaris 2.6.  Hopefully
+       it doesn't break anything. */
+     SYS_DEFINES = -D__XPG4_CHAR_CLASS__
+#endif
+         DEFINES = StrcasecmpDefines $(SYS_DEFINES)
 
             SRCS = utilbitmap.c fontnames.c fontutil.c fontxlfd.c format.c \
 		   fontaccel.c atom.c miscutil.c private.c patcache.c
Index: xc/lib/font/util/fontxlfd.c
diff -u xc/lib/font/util/fontxlfd.c:3.7 xc/lib/font/util/fontxlfd.c:3.9
--- xc/lib/font/util/fontxlfd.c:3.7	Sat Aug 21 09:48:09 1999
+++ xc/lib/font/util/fontxlfd.c	Thu Aug 31 15:03:55 2000
@@ -23,7 +23,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/font/util/fontxlfd.c,v 3.7 1999/08/21 13:48:09 dawes Exp $ */
+/* $XFree86: xc/lib/font/util/fontxlfd.c,v 3.9 2000/08/31 19:03:55 tsi Exp $ */
 
 /*
  * Author:  Keith Packard, MIT X Consortium
@@ -201,7 +201,9 @@
       significant digits.  How do you round to n significant digits on
       a binary machine?  */
 
-#if defined(i386) || defined(__i386__) || defined(__alpha__)
+#if defined(i386) || defined(__i386__) || \
+    defined(ia64) || defined(__ia64__) || \
+    defined(__alpha__) || defined(__alpha)
 #if !defined(__EMX__)
 #include <float.h>
 
Index: xc/lib/psres/Imakefile
diff -u xc/lib/psres/Imakefile:1.3 xc/lib/psres/Imakefile:1.4
--- xc/lib/psres/Imakefile:1.3	Mon Feb 14 20:44:57 2000
+++ xc/lib/psres/Imakefile	Wed Aug  9 19:40:15 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/psres/Imakefile,v 1.3 2000/02/15 01:44:57 dawes Exp $
+XCOMM $XFree86: xc/lib/psres/Imakefile,v 1.4 2000/08/09 23:40:15 dawes Exp $
 
 #define DoNormalLib NormalLibPSRes
 #define DoSharedLib SharedLibPSRes
@@ -8,6 +8,10 @@
 #define LibName psres
 #define SoRev SOPSRESREV
 #define LibHeaders NO
+
+#ifdef SharedPSResReqs
+REQUIREDLIBS = SharedPSResReqs
+#endif
 
         PSWRAP = $(TOP)/config/pswrap/pswrap
 
Index: xc/lib/psres/psres-def.cpp
diff -u /dev/null xc/lib/psres/psres-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:26:39 2000
+++ xc/lib/psres/psres-def.cpp	Wed Aug  9 19:40:15 2000
@@ -0,0 +1,11 @@
+LIBRARY psres
+VERSION LIBRARY_VERSION
+EXPORTS
+;TCheckPSResourceTime
+EnumeratePSResourceFiles
+InSavedList
+ListPSResourceFiles
+ListPSResourceTypes
+SetPSResourcePolicy
+
+/* $XFree86: xc/lib/psres/psres-def.cpp,v 1.1 2000/08/09 23:40:15 dawes Exp $ */
Index: xc/lib/xkbfile/xkbout.c
diff -u xc/lib/xkbfile/xkbout.c:3.5 xc/lib/xkbfile/xkbout.c:3.6
--- xc/lib/xkbfile/xkbout.c:3.5	Sun Jun 22 06:16:54 1997
+++ xc/lib/xkbfile/xkbout.c	Tue Oct 24 18:45:02 2000
@@ -24,6 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkbout.c,v 3.6 2000/10/24 22:45:02 dawes Exp $ */
 
 #include <stdio.h>
 #include <ctype.h>
@@ -1100,6 +1101,7 @@
     xkb= result->xkb;
     fprintf(file,"xkb_layout {\n");
     ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv);
+    ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv);
     ok= ok&&XkbWriteXKBSymbols(file,result,False,showImplicit,addOn,priv);
     if (xkb->geom)
 	ok= ok&&XkbWriteXKBGeometry(file,result,False,showImplicit,addOn,priv);
Index: xc/lib/xkbfile/xkbtext.c
diff -u xc/lib/xkbfile/xkbtext.c:3.6 xc/lib/xkbfile/xkbtext.c:3.7
--- xc/lib/xkbfile/xkbtext.c:3.6	Sun Dec 29 08:43:41 1996
+++ xc/lib/xkbfile/xkbtext.c	Tue Oct 24 18:45:02 2000
@@ -24,7 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
-/* $XFree86: xc/lib/xkbfile/xkbtext.c,v 3.6 1996/12/29 13:43:41 dawes Exp $ */
+/* $XFree86: xc/lib/xkbfile/xkbtext.c,v 3.7 2000/10/24 22:45:02 dawes Exp $ */
 
 #include <stdio.h>
 #include <ctype.h>
@@ -1544,7 +1544,7 @@
 	permanent=((behavior->type&XkbKB_Permanent)!=0);
 
 	if (type==XkbKB_Lock) {
-	    sprintf(buf,"lock= %s,",(permanent?"Permanent":"True"));
+	    sprintf(buf,"lock= %s",(permanent?"Permanent":"True"));
 	}
 	else if (type==XkbKB_RadioGroup) {
 	    int 	g;
Index: xc/lib/xkbfile/xkmout.c
diff -u xc/lib/xkbfile/xkmout.c:1.1.1.4 xc/lib/xkbfile/xkmout.c:1.3
--- xc/lib/xkbfile/xkmout.c:1.1.1.4	Wed Jan 24 06:14:33 1996
+++ xc/lib/xkbfile/xkmout.c	Fri Oct 27 20:34:01 2000
@@ -24,6 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkmout.c,v 1.3 2000/10/28 00:34:01 dawes Exp $ */
 
 #include <stdio.h>
 #include <ctype.h>
@@ -666,7 +667,7 @@
     for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++)  {
 	char *typeName[XkbNumKbdGroups];
 	wireMap.width= XkbKeyGroupsWidth(xkb,i);
-	wireMap.num_groups= XkbKeyNumGroups(xkb,i);
+	wireMap.num_groups= XkbKeyGroupInfo(xkb,i);
 	if (xkb->map && xkb->map->modmap)
 	     wireMap.modifier_map= xkb->map->modmap[i];
 	else wireMap.modifier_map= 0;
@@ -705,7 +706,7 @@
 		    size+= xkmPutCountedString(file,typeName[g]);
 	    }
 	}
-	if (wireMap.num_groups>0) {
+	if (XkbNumGroups(wireMap.num_groups)>0) {
 	    KeySym	*sym;
 	    sym= XkbKeySymsPtr(xkb,i);
 	    for (n=XkbKeyNumSyms(xkb,i);n>0;n--,sym++) {
Index: xc/lib/xkbfile/xkmread.c
diff -u xc/lib/xkbfile/xkmread.c:1.1.1.3 xc/lib/xkbfile/xkmread.c:1.3
--- xc/lib/xkbfile/xkmread.c:1.1.1.3	Mon Jan 15 01:55:18 1996
+++ xc/lib/xkbfile/xkmread.c	Fri Oct 27 20:34:02 2000
@@ -24,6 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
+/* $XFree86: xc/lib/xkbfile/xkmread.c,v 1.3 2000/10/28 00:34:02 dawes Exp $ */
 
 #include <stdio.h>
 
@@ -797,13 +798,13 @@
 	    xkb->server->explicit[i]|= XkbExplicitAutoRepeatMask;
 	}
 	xkb->map->modmap[i]= wireMap.modifier_map;
-	if (wireMap.num_groups>0) {
+	if (XkbNumGroups(wireMap.num_groups)>0) {
 	    KeySym	*sym;
 	    int		 nSyms;
 	
-	    if (wireMap.num_groups>xkb->ctrls->num_groups)
+	    if (XkbNumGroups(wireMap.num_groups)>xkb->ctrls->num_groups)
 		xkb->ctrls->num_groups= wireMap.num_groups;
-	    nSyms= wireMap.num_groups*wireMap.width;
+	    nSyms= XkbNumGroups(wireMap.num_groups)*wireMap.width;
 	    sym= XkbResizeKeySyms(xkb,i,nSyms);
 	    if (!sym)
 		return -1;
@@ -820,7 +821,7 @@
 		xkb->server->explicit[i]|= XkbExplicitInterpretMask;
 	    }
 	}
-	for (g=0;g<wireMap.num_groups;g++) {
+	for (g=0;g<XkbNumGroups(wireMap.num_groups);g++) {
 	    if (((xkb->server->explicit[i]&(1<<g))==0)||(type[g]==NULL)) {
 		KeySym *tmpSyms;
 		tmpSyms= XkbKeySymsPtr(xkb,i)+(wireMap.width*g);
Index: xc/lib/xtrans/Xtrans.c
diff -u xc/lib/xtrans/Xtrans.c:3.22 xc/lib/xtrans/Xtrans.c:3.23
--- xc/lib/xtrans/Xtrans.c:3.22	Sun Dec 26 19:39:28 1999
+++ xc/lib/xtrans/Xtrans.c	Tue Oct 24 18:45:02 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/xtrans/Xtrans.c,v 3.22 1999/12/27 00:39:28 robin Exp $ */
+/* $XFree86: xc/lib/xtrans/Xtrans.c,v 3.23 2000/10/24 22:45:02 dawes Exp $ */
 
 /* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
  *
@@ -172,7 +172,7 @@
      * a case insensitive match.
      */
 
-    strncpy (protobuf, protocol, PROTOBUFSIZE);
+    strncpy (protobuf, protocol, PROTOBUFSIZE - 1);
 
     for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++)
 	if (isupper (protobuf[i]))
Index: xc/lib/xtrans/Xtransutil.c
diff -u xc/lib/xtrans/Xtransutil.c:3.15 xc/lib/xtrans/Xtransutil.c:3.16
--- xc/lib/xtrans/Xtransutil.c:3.15	Wed Apr  5 14:13:27 2000
+++ xc/lib/xtrans/Xtransutil.c	Wed Aug  9 19:40:15 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/lib/xtrans/Xtransutil.c,v 3.15 2000/04/05 18:13:27 dawes Exp $ */
+/* $XFree86: xc/lib/xtrans/Xtransutil.c,v 3.16 2000/08/09 23:40:15 dawes Exp $ */
 
 /* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
  *
@@ -56,6 +56,12 @@
 
 #ifdef XTHREADS
 #include <X11/Xthreads.h>
+#endif
+
+#ifdef __CYGWIN__
+#include <sys/unistd.h>
+#define fchown chown
+#define fchmod chmod
 #endif
 
 #ifdef X11_t
Index: xc/lib/zlib/Imakefile
diff -u xc/lib/zlib/Imakefile:1.6 xc/lib/zlib/Imakefile:1.7
--- xc/lib/zlib/Imakefile:1.6	Sat Apr 17 05:08:13 1999
+++ xc/lib/zlib/Imakefile	Wed Aug  9 19:40:16 2000
@@ -4,10 +4,15 @@
 
 
 
-XCOMM $XFree86: xc/lib/zlib/Imakefile,v 1.6 1999/04/17 09:08:13 dawes Exp $
+XCOMM $XFree86: xc/lib/zlib/Imakefile,v 1.7 2000/08/09 23:40:16 dawes Exp $
 
+#ifndef cygwinArchitecture
 #define DoNormalLib   YES
 #define DoSharedLib   NO
+#else
+#define DoNormalLib   NO
+#define DoSharedLib   YES
+#endif
 #define DoExtraLib    NO
 #define DoDebugLib    NO
 #define DoProfileLib  NO
Index: xc/lib/zlib/z-def.cpp
diff -u /dev/null xc/lib/zlib/z-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:26:46 2000
+++ xc/lib/zlib/z-def.cpp	Wed Aug  9 19:40:16 2000
@@ -0,0 +1,47 @@
+#ifdef __CYGWIN__
+LIBRARY ZLIB
+EXPORTS
+	adler32 @ 1 ;
+	compress @ 2 ;
+	compress2 @ 3 ;
+	crc32 @ 4 ;
+	deflate @ 5 ;
+	deflateCopy @ 6 ;
+	deflateEnd @ 7 ;
+	deflateInit2_ @ 8 ;
+	deflateInit_ @ 9 ;
+	deflateParams @ 10 ;
+	deflateReset @ 11 ;
+	deflateSetDictionary @ 12 ;
+	get_crc_table @ 13 ;
+	gzclose @ 14 ;
+	gzdopen @ 15 ;
+	gzeof @ 16 ;
+	gzerror @ 17 ;
+	gzflush @ 18 ;
+	gzgetc @ 19 ;
+;	gzgets @ 20 ;
+	gzopen @ 21 ;
+	gzprintf @ 22 ;
+	gzputc @ 23 ;
+;	gzputs @ 24 ;
+	gzread @ 25 ;
+	gzrewind @ 26 ;
+	gzseek @ 27 ;
+	gzsetparams @ 28 ;
+	gztell @ 29 ;
+	gzwrite @ 30 ;
+	inflate @ 31 ;
+	inflateEnd @ 32 ;
+	inflateInit2_ @ 33 ;
+	inflateInit_ @ 34 ;
+	inflateReset @ 35 ;
+	inflateSetDictionary @ 36 ;
+	inflateSync @ 37 ;
+	inflateSyncPoint @ 38 ;
+	uncompress @ 39 ;
+	zError @ 40 ;
+	zlibVersion @ 41 ;
+#endif
+
+/* $XFree86: xc/lib/zlib/z-def.cpp,v 1.1 2000/08/09 23:40:16 dawes Exp $ */
Index: xc/lib/zlib/zconf.h
diff -u xc/lib/zlib/zconf.h:1.5 xc/lib/zlib/zconf.h:1.6
--- xc/lib/zlib/zconf.h:1.5	Sat Oct  3 05:07:46 1998
+++ xc/lib/zlib/zconf.h	Wed Aug  9 19:40:16 2000
@@ -5,6 +5,8 @@
  * For conditions of distribution and use, see copyright notice in zlib.h 
  */
 
+/* $XFree86: xc/lib/zlib/zconf.h,v 1.6 2000/08/09 23:40:16 dawes Exp $ */
+
 #ifndef _ZCONF_H
 #define _ZCONF_H
 
@@ -47,7 +49,7 @@
 #  define voidp		z_voidp
 #endif
 
-#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
+#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && !defined(__CYGWIN__)
 #  define WIN32
 #endif
 #if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) || defined(__EMX__)
Index: xc/nls/Imakefile
diff -u xc/nls/Imakefile:1.4 xc/nls/Imakefile:1.5
--- xc/nls/Imakefile:1.4	Sun Aug 22 09:04:24 1999
+++ xc/nls/Imakefile	Fri Dec  1 20:16:04 2000
@@ -3,12 +3,15 @@
 
 
 
-XCOMM $XFree86: xc/nls/Imakefile,v 1.4 1999/08/22 13:04:24 dawes Exp $
+XCOMM $XFree86: xc/nls/Imakefile,v 1.5 2000/12/02 01:16:04 dawes Exp $
 #define IHaveSubdirs
 #define PassCDebugFlags
 
         SUBDIRS = XLC_LOCALE Compose
-        DEFINES = -DR63_COMPAT
+#if defined(FreeBSDArchitecture)
+  RU_SU_DEFINES = -DINCLUDE_ru_SU
+#endif
+        DEFINES = -DR63_COMPAT $(RU_SU_DEFINES)
 
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
Index: xc/nls/compose.dir
diff -u xc/nls/compose.dir:1.8 xc/nls/compose.dir:1.12
--- xc/nls/compose.dir:1.8	Tue Feb  8 12:18:46 2000
+++ xc/nls/compose.dir	Wed Dec  6 17:00:42 2000
@@ -4,7 +4,7 @@
 XCOMM	The first word is the compose table file name and
 XCOMM	the second word is full locale name.
 XCOMM
-XCOMM $XFree86: xc/nls/compose.dir,v 1.8 2000/02/08 17:18:46 dawes Exp $
+XCOMM $XFree86: xc/nls/compose.dir,v 1.12 2000/12/06 22:00:42 dawes Exp $
 XCOMM
 #ifdef R63_COMPAT
 XCOMM These entries are in the old format (no ':')
@@ -25,7 +25,11 @@
 iso8859-6/Compose	ar_SA.ISO8859-6
 iso8859-6/Compose	ar_TN.ISO8859-6
 iso8859-6/Compose	ar_YE.ISO8859-6
+iso8859-9e/Compose	az_AZ.ISO8859-9E
+koi8-c/Compose		a3_AZ.KOI8-C
+microsoft-cp1251/Compose	be_BY.CP1251
 iso8859-5/Compose	bg_BG.ISO8859-5
+microsoft-cp1251/Compose	bg_BG.CP1251
 iso8859-1/Compose	br_FR.ISO8859-1
 iso8859-14/Compose	br_FR.ISO8859-14
 iso8859-15/Compose	br_FR.ISO8859-15
@@ -82,10 +86,13 @@
 iso8859-1/Compose	es_SV.ISO8859-1
 iso8859-1/Compose	es_UY.ISO8859-1
 iso8859-1/Compose	es_VE.ISO8859-1
+iso8859-1/Compose	et_EE.ISO8859-1
 iso8859-4/Compose	et_EE.ISO8859-4
+iso8859-13/Compose	et_EE.ISO8859-13
 iso8859-15/Compose	et_EE.ISO8859-15
 iso8859-1/Compose	eu_ES.ISO8859-1
 iso8859-15/Compose	eu_ES.ISO8859-15
+isiri-3342/Compose	fa_IR.ISIRI-3342
 iso8859-1/Compose	fi_FI.ISO8859-1
 iso8859-15/Compose	fi_FI.ISO8859-15
 iso8859-1/Compose	fo_FO.ISO8859-1
@@ -112,6 +119,8 @@
 iso8859-14/Compose	gv_GB.ISO8859-14
 iso8859-15/Compose	gv_GB.ISO8859-15
 iso8859-8/Compose	he_IL.ISO8859-8
+microsoft-cp1255/Compose	he_IL.CP1255
+iscii-dev/Compose	hi_IN.ISCII-DEV
 iso8859-2/Compose	hr_HR.ISO8859-2
 iso8859-2/Compose	hu_HU.ISO8859-2
 armscii-8/Compose	hy_AM.ARMSCII-8
@@ -137,20 +146,31 @@
 ibm-cp1133/Compose	lo_LA.IBM-CP1133
 mulelao-1/Compose	lo_LA.MULELAO-1
 iso8859-1/Compose	lt_LN.ISO8859-1
-iso8859-1/Compose	lt_LT.ISO8859-1
 iso8859-4/Compose	lt_LT.ISO8859-4
-iso8859-15/Compose	lt_LT.ISO8859-15
+iso8859-13/Compose	lt_LT.ISO8859-13
 iso8859-4/Compose	lv_LV.ISO8859-4
+iso8859-13/Compose	lv_LV.ISO8859-13
+iso8859-13/Compose	mi_NZ.ISO8859-13
 iso8859-5/Compose	mk_MK.ISO8859-5
+microsoft-cp1251/Compose	mk_MK.CP1251
+iso8859-1/Compose	ms_MY.ISO8859-1
 iso8859-1/Compose	nl_BE.ISO8859-1
 iso8859-15/Compose	nl_BE.ISO8859-15
 iso8859-1/Compose	nl_NL.ISO8859-1
 iso8859-15/Compose	nl_NL.ISO8859-15
 iso8859-1/Compose	no_NO.ISO8859-1
 iso8859-15/Compose	no_NO.ISO8859-15
+iso8859-1/Compose	nb_NO.ISO8859-1
+iso8859-15/Compose	nb_NO.ISO8859-15
+iso8859-1/Compose	ny_NO.ISO8859-1
+iso8859-15/Compose	ny_NO.ISO8859-15
 iso8859-1/Compose	oc_FR.ISO8859-1
 iso8859-15/Compose	oc_FR.ISO8859-15
+iso8859-1/Compose	pd_DE.ISO8859-1
+iso8859-1/Compose	pd_US.ISO8859-1
+iso8859-1/Compose	ph_PH.ISO8859-1
 iso8859-2/Compose	pl_PL.ISO8859-2
+iso8859-1/Compose	pp_AN.ISO8859-1
 iso8859-1/Compose	pt_BR.ISO8859-1
 iso8859-15/Compose	pt_BR.ISO8859-15
 iso8859-1/Compose	pt_PT.ISO8859-1
@@ -158,6 +178,7 @@
 iso8859-2/Compose	ro_RO.ISO8859-2
 koi8-r/Compose		ru_RU.KOI8-R
 iso8859-5/Compose	ru_RU.ISO8859-5
+microsoft-cp1251/Compose	ru_RU.CP1251
 koi8-u/Compose		ru_UA.KOI8-U
 iso8859-2/Compose 	sh_YU.ISO8859-2
 iso8859-2/Compose 	sk_SK.ISO8859-2
@@ -172,16 +193,24 @@
 iso8859-15/Compose	sv_FI.ISO8859-15
 iso8859-1/Compose	sv_SE.ISO8859-1
 iso8859-15/Compose	sv_SE.ISO8859-15
+tscii-0/Compose		ta_IN.TSCII-0
+koi8-c/Compose		tg_TJ.KOI8-C
+iso8859-1/Compose	tl_PH.ISO8859-1
 th_TH.TACTIS/Compose	th_TH.TACTIS
 iso8859-9/Compose	tr_TR.ISO8859-9
+tatar-cyr/Compose	tt_RU.TATAR-CYR
+koi8-c/Compose		tt_RU.KOI8-C
 koi8-u/Compose		uk_UA.KOI8-U
+microsoft-cp1256/Compose	ur_PK.CP1256
 vi_VN.viscii/Compose	vi_VN.VISCII
 vi_VN.tcvn/Compose	vi_VN.TCVN
 iso8859-1/Compose	wa_BE.ISO8859-1
+microsoft-cp1255/Compose	yi_US.CP1255
 zh/Compose		zh_CN.eucCN
+zh/Compose		zh_CN.GB2312
 zh_TW.big5/Compose	zh_TW.big5
+zh_TW.big5/Compose	zh_TW.Big5
 zh_TW/Compose		zh_TW.eucTW
-en_US.utf/Compose	en_US.utf
 #endif /* R63_COMPAT */
 
 iso8859-1/Compose:	C
@@ -201,7 +230,11 @@
 iso8859-6/Compose:	ar_SA.ISO8859-6
 iso8859-6/Compose:	ar_TN.ISO8859-6
 iso8859-6/Compose:	ar_YE.ISO8859-6
+iso8859-9e/Compose:	az_AZ.ISO8859-9E
+koi8-c/Compose:		a3_AZ.KOI8-C
+microsoft-cp1251/Compose:	be_BY.CP1251
 iso8859-5/Compose:	bg_BG.ISO8859-5
+microsoft-cp1251/Compose:	bg_BG.CP1251
 iso8859-1/Compose:	br_FR.ISO8859-1
 iso8859-14/Compose:	br_FR.ISO8859-14
 iso8859-15/Compose:	br_FR.ISO8859-15
@@ -258,10 +291,13 @@
 iso8859-1/Compose:	es_SV.ISO8859-1
 iso8859-1/Compose:	es_UY.ISO8859-1
 iso8859-1/Compose:	es_VE.ISO8859-1
+iso8859-1/Compose:	et_EE.ISO8859-1
 iso8859-4/Compose:	et_EE.ISO8859-4
+iso8859-13/Compose:	et_EE.ISO8859-13
 iso8859-15/Compose:	et_EE.ISO8859-15
 iso8859-1/Compose:	eu_ES.ISO8859-1
 iso8859-15/Compose:	eu_ES.ISO8859-15
+isiri-3342/Compose:	fa_IR.ISIRI-3342
 iso8859-1/Compose:	fi_FI.ISO8859-1
 iso8859-15/Compose:	fi_FI.ISO8859-15
 iso8859-1/Compose:	fo_FO.ISO8859-1
@@ -288,6 +324,8 @@
 iso8859-14/Compose:	gv_GB.ISO8859-14
 iso8859-15/Compose:	gv_GB.ISO8859-15
 iso8859-8/Compose:	he_IL.ISO8859-8
+microsoft-cp1255/Compose:	he_IL.CP1255
+iscii-dev/Compose:	hi_IN.ISCII-DEV
 iso8859-2/Compose:	hr_HR.ISO8859-2
 iso8859-2/Compose:	hu_HU.ISO8859-2
 armscii-8/Compose:	hy_AM.ARMSCII-8
@@ -313,20 +351,32 @@
 ibm-cp1133/Compose:	lo_LA.IBM-CP1133
 mulelao-1/Compose:	lo_LA.MULELAO-1
 iso8859-1/Compose:	lt_LN.ISO8859-1
-iso8859-1/Compose:	lt_LT.ISO8859-1
 iso8859-4/Compose:	lt_LT.ISO8859-4
-iso8859-15/Compose:	lt_LT.ISO8859-15
+iso8859-13/Compose:	lt_LT.ISO8859-13
 iso8859-4/Compose:	lv_LV.ISO8859-4
+iso8859-13/Compose:	lv_LV.ISO8859-13
+iso8859-13/Compose:	mi_NZ.ISO8859-13
 iso8859-5/Compose:	mk_MK.ISO8859-5
+mk_MK.UTF-8/Compose:	mk_MK.UTF-8
+microsoft-cp1251/Compose:	mk_MK.CP1251
+iso8859-1/Compose:	ms_MY.ISO8859-1
 iso8859-1/Compose:	nl_BE.ISO8859-1
 iso8859-15/Compose:	nl_BE.ISO8859-15
 iso8859-1/Compose:	nl_NL.ISO8859-1
 iso8859-15/Compose:	nl_NL.ISO8859-15
 iso8859-1/Compose:	no_NO.ISO8859-1
 iso8859-15/Compose:	no_NO.ISO8859-15
+iso8859-1/Compose:	nb_NO.ISO8859-1
+iso8859-15/Compose:	nb_NO.ISO8859-15
+iso8859-1/Compose:	ny_NO.ISO8859-1
+iso8859-15/Compose:	ny_NO.ISO8859-15
 iso8859-1/Compose:	oc_FR.ISO8859-1
 iso8859-15/Compose:	oc_FR.ISO8859-15
+iso8859-1/Compose:	pd_DE.ISO8859-1
+iso8859-1/Compose:	pd_US.ISO8859-1
+iso8859-1/Compose:	ph_PH.ISO8859-1
 iso8859-2/Compose:	pl_PL.ISO8859-2
+iso8859-1/Compose:	pp_AN.ISO8859-1
 iso8859-1/Compose:	pt_BR.ISO8859-1
 iso8859-15/Compose:	pt_BR.ISO8859-15
 iso8859-1/Compose:	pt_PT.ISO8859-1
@@ -334,6 +384,7 @@
 iso8859-2/Compose:	ro_RO.ISO8859-2
 koi8-r/Compose:		ru_RU.KOI8-R
 iso8859-5/Compose:	ru_RU.ISO8859-5
+microsoft-cp1251/Compose:	ru_RU.CP1251
 koi8-u/Compose:		ru_UA.KOI8-U
 iso8859-2/Compose: 	sh_YU.ISO8859-2
 iso8859-2/Compose: 	sk_SK.ISO8859-2
@@ -348,13 +399,21 @@
 iso8859-15/Compose:	sv_FI.ISO8859-15
 iso8859-1/Compose:	sv_SE.ISO8859-1
 iso8859-15/Compose:	sv_SE.ISO8859-15
+tscii-0/Compose:	ta_IN.TSCII-0
+koi8-c/Compose:		tg_TJ.KOI8-C
+iso8859-1/Compose:	tl_PH.ISO8859-1
 th_TH.TACTIS/Compose:	th_TH.TACTIS
 iso8859-9/Compose:	tr_TR.ISO8859-9
+tatar-cyr/Compose:	tt_RU.TATAR-CYR
+koi8-c/Compose:		tt_RU.KOI8-C
 koi8-u/Compose:		uk_UA.KOI8-U
+microsoft-cp1256/Compose:	ur_PK.CP1256
 vi_VN.viscii/Compose:	vi_VN.VISCII
 vi_VN.tcvn/Compose:	vi_VN.TCVN
 iso8859-1/Compose:	wa_BE.ISO8859-1
 zh/Compose:		zh_CN.eucCN
+zh/Compose:		zh_CN.GB2312
+microsoft-cp1255/Compose:	yi_US.CP1256
 zh_TW.big5/Compose:	zh_TW.big5
+zh_TW.big5/Compose:	zh_TW.Big5
 zh_TW/Compose:		zh_TW.eucTW
-en_US.utf/Compose:	en_US.utf
Index: xc/nls/locale.alias
diff -u xc/nls/locale.alias:1.24 xc/nls/locale.alias:1.34
--- xc/nls/locale.alias:1.24	Tue Apr  4 15:24:45 2000
+++ xc/nls/locale.alias	Wed Dec  6 17:00:42 2000
@@ -5,7 +5,7 @@
 XCOMM	The first word is the alias name (simplified locale name)
 XCOMM	the second word is full locale name.
 XCOMM
-XCOMM	$XFree86: xc/nls/locale.alias,v 1.24 2000/04/04 19:24:45 dawes Exp $
+XCOMM	$XFree86: xc/nls/locale.alias,v 1.34 2000/12/06 22:00:42 dawes Exp $
 XCOMM
 #ifdef R63_COMPAT
 XCOMM These entries are in the old format (no ':')
@@ -132,7 +132,7 @@
 es_ES.88591.en					es_ES.ISO8859-1
 es_ES.iso88591					es_ES.ISO8859-1
 es_ES.ISO_8859-1				es_ES.ISO8859-1
-es_ES.iso885915				es_ES.ISO8859-15
+es_ES.iso885915					es_ES.ISO8859-15
 es_GT						es_GT.ISO8859-1
 es_GT.iso88591					es_GT.ISO8859-1
 es_MX						es_MX.ISO8859-1
@@ -163,7 +163,9 @@
 #endif
 et						et_EE.ISO8859-15
 et_EE						et_EE.ISO8859-15
+et_EE.iso88591					et_EE.ISO8859-1
 et_EE.iso88594					et_EE.ISO8859-4
+et_EE.iso885913					et_EE.ISO8859-13
 et_EE.iso885915					et_EE.ISO8859-15
 eu						eu_ES.ISO8859-1
 eu_ES						eu_ES.ISO8859-1
@@ -304,6 +306,7 @@
 ko_KR.EUC					ko_KR.eucKR
 ko_KR.euc					ko_KR.eucKR
 ko_KR.euckr					ko_KR.eucKR
+ko_KR.utf8					ko_KR.UTF-8
 kw						kw_GB.ISO8859-1
 kw_GB						kw_GB.ISO8859-1
 kw_GB.iso88591					kw_GB.ISO8859-1
@@ -318,17 +321,19 @@
 XCOMM most locales in FreeBSD 2.1.[56] do not work, allow use of FreeBSD's
 XCOMM generic latin-1 locale name. N.B. "lt" is a bad code to use for a 
 XCOMM generic Latin-1 locale anyway because it is the country code for 
-XCOMM Lithuania, which by default uses Latin-4.
+XCOMM Lithuania, which by default uses Latin-7 (ISO-8859-13).
 lt_LN.ISO_8859-1				lt_LN.ISO8859-1
 #endif
-lt						lt_LT.ISO8859-4
-lt_LT						lt_LT.ISO8859-4
+lt						lt_LT.ISO8859-13
+lt_LT						lt_LT.ISO8859-13
 lt_LT.iso88594					lt_LT.ISO8859-4
 lt_LT.ISO_8859-4				lt_LT.ISO8859-4
-lt_LT.iso885915					lt_LT.ISO8859-15
-lv						lv_LV.ISO8859-4
-lv_LV						lv_LV.ISO8859-4
+lt_LT.iso885913					lt_LT.ISO8859-13
+lt_LT.ISO_8859-13				lt_LT.ISO8859-13
+lv						lv_LV.ISO8859-13
+lv_LV						lv_LV.ISO8859-13
 lv_LV.iso88594					lv_LV.ISO8859-4
+lv_LV.iso885913					lv_LV.ISO8859-13
 mk						mk_MK.ISO8859-5
 mk_MK						mk_MK.ISO8859-5
 mk_MK.iso88595					mk_MK.ISO8859-5
@@ -439,13 +444,13 @@
 zh						zh_CN.eucCN
 zh_CN						zh_CN.eucCN
 zh_CN.big5					zh_TW.big5
+zh_CN.Big5					zh_TW.big5
 zh_CN.EUC					zh_CN.eucCN
 zh_CN.euc					zh_CN.eucCN
 zh_CN.gb2312					zh_CN.eucCN
 zh_TW						zh_TW.big5
 zh_TW.EUC					zh_TW.eucTW
 zh_TW.euc					zh_TW.eucTW
-zh_TW.big5					zh_TW.big5
 
 XCOMM The following locale names are used in SCO 3.0
 english_uk.8859					en_GB.ISO8859-1
@@ -493,13 +498,9 @@
 spanish.iso88591				es_ES.ISO8859-1
 swedish.iso88591				sv_SE.ISO8859-1
 turkish.iso88599				tr_TR.ISO8859-9
-univ.utf8					en_US.utf
+univ.utf8					en_US.UTF-8
 XCOMM Digital Unix utf
-universal.utf8@ucs4				en_US.utf
-#if defined(SVR4) && defined(sun)
-XCOMM Solaris 2.6
-en_US.UTF-8					en_US.utf
-#endif
+universal.utf8@ucs4				en_US.UTF-8
 XCOMM Solaris and SunOS have iso_8859_1 LC_CTYPES to augment LANG=C
 iso_8859_1					en_US.ISO8859-1
 XCOMM Other miscellaneous locale names
@@ -531,8 +532,24 @@
 ar_SA.iso88596:					ar_SA.ISO8859-6
 ar_EG:						ar_EG.ISO8859-6
 ar_EG.iso88596:					ar_EG.ISO8859-6
-bg:						bg_BG.ISO8859-5
-bg_BG:						bg_BG.ISO8859-5
+az:						az_AZ.ISO8859-9E
+az_AZ:						az_AZ.ISO8859-9E
+az_AZ.iso88599e:				az_AZ.ISO8859-9E
+a3:						a3_AZKOI8-C
+a3_AZ:						a3_AZ.KOI8-C
+a3_AZ.koi8c:					a3_AZ.KOI8-C
+be:						be_BY.CP1251
+be_BY:						be_BY.CP1251
+be_BY.cp1251:					be_BY.CP1251
+be_BY.microsoftcp1251:				be_BY.CP1251
+be_BY.microsoft-cp1251:				be_BY.CP1251
+be_BY.MICROSOFT-CP1251:				be_BY.CP1251
+bg:						bg_BG.CP1251
+bg_BG:						bg_BG.CP1251
+bg_BG.cp1251:					bg_BG.CP1251
+bg_BG.microsoftcp1251:				bg_BG.CP1251
+bg_BG.microsoft-cp1251:				bg_BG.CP1251
+bg_BG.MICROSOFT-CP1251:				bg_BG.CP1251
 bg_BG.iso88595:					bg_BG.ISO8859-5
 br:						br_FR.ISO8859-1
 br_FR:						br_FR.ISO8859-1
@@ -612,8 +629,7 @@
 en_US.iso88591:					en_US.ISO8859-1
 en_US.ISO_8859-1:				en_US.ISO8859-1
 #if defined(SVR4) && defined(sun)
-en_US.UTF-8:					en_US.utf
-en_US.utf8:					en_US.utf
+en_US.utf8:					en_US.UTF-8
 #endif
 eo:						eo_XX.ISO8859-3
 eo_XX:						eo_XX.ISO8859-3
@@ -665,20 +681,22 @@
 XCOMM language; however this is clearly incorrect according to ISO8859.
 #endif
 XCOMM According to Estonian local standards, ISO8859-4 is not recommended
-XCOMM charset. The older EVS8:1993 standard specifies slightly modified
-XCOMM (icelandic letters are replaced with scaron and zcaron) ISO8859-1
-XCOMM as a base charset. The newer (but not yet official as of january 2000)
-XCOMM EVS8:1999 defines ISO8859-15 to be the base charset.
+XCOMM charset. EVS8:2000 specifies ISO8859-15 as base charset.
 et:						et_EE.ISO8859-15
 et_EE:						et_EE.ISO8859-15
+et_EE.iso88591:					et_EE.ISO8859-1
 et_EE.iso88594:					et_EE.ISO8859-4
+et_EE.iso885913:				et_EE.ISO8859-13
 et_EE.iso885915:				et_EE.ISO8859-15
 eu:						eu_ES.ISO8859-1
 eu_ES:						eu_ES.ISO8859-1
 eu_ES.iso88591:					eu_ES.ISO8859-1
 eu_ES.iso885915:				eu_ES.ISO8859-15
-fi:						fi_FI.ISO8859-1
-fi_FI:						fi_FI.ISO8859-1
+fa:						fa_IR.ISIRI-3342
+fa_IR:						fa_IR.ISIRI-3342
+fa_IR.isiri3342:				fa_IR.ISIRI-3342
+fi:						fi_FI.ISO8859-15
+fi_FI:						fi_FI.ISO8859-15
 fi_FI.88591:					fi_FI.ISO8859-1
 fi_FI.88591.en:					fi_FI.ISO8859-1
 fi_FI.iso88591:					fi_FI.ISO8859-1
@@ -730,6 +748,13 @@
 he:						he_IL.ISO8859-8
 he_IL:						he_IL.ISO8859-8
 he_IL.iso88598:					he_IL.ISO8859-8
+he_IL.cp1255:					he_IL.CP1255
+he_IL.microsoftcp1255:				he_IL.CP1255
+he_IL.microsoft-cp1255:				he_IL.CP1255
+he_IL.MICROSOFT-CP1255:				he_IL.CP1255
+hi:						hi_IN.ISCII-DEV
+hi_IN:						hi_IN.ISCII-DEV
+hi_IN.isciidev:					hi_IN.ISCII-DEV
 hr:						hr_HR.ISO8859-2
 hr_HR:						hr_HR.ISO8859-2
 hr_HR.iso88592:					hr_HR.ISO8859-2
@@ -751,18 +776,18 @@
 is_IS:						is_IS.ISO8859-1
 is_IS.iso88591:					is_IS.ISO8859-1
 is_IS.ISO_8859-1:				is_IS.ISO8859-1
-is_IS.iso885915:					is_IS.ISO8859-15
+is_IS.iso885915:				is_IS.ISO8859-15
 it:						it_IT.ISO8859-1
 it_CH:						it_CH.ISO8859-1
 it_CH.iso88591:					it_CH.ISO8859-1
 it_CH.ISO_8859-1:				it_CH.ISO8859-1
-it_CH.iso885915:					it_CH.ISO8859-15
+it_CH.iso885915:				it_CH.ISO8859-15
 it_IT:						it_IT.ISO8859-1
 it_IT.88591:					it_IT.ISO8859-1
 it_IT.88591.en:					it_IT.ISO8859-1
 it_IT.iso88591:					it_IT.ISO8859-1
 it_IT.ISO_8859-1:				it_IT.ISO8859-1
-it_IT.iso885915:					it_IT.ISO8859-15
+it_IT.iso885915:				it_IT.ISO8859-15
 iu:						iu_CA.NUNACOM-8
 iu_CA:						iu_CA.NUNACOM-8
 iu_CA.nunacom8:					iu_CA.NUNACOM-8
@@ -807,6 +832,7 @@
 ko_KR.EUC:					ko_KR.eucKR
 ko_KR.euc:					ko_KR.eucKR
 ko_KR.euckr:					ko_KR.eucKR
+ko_KR.utf8:					ko_KR.UTF-8
 lo:						lo_LA.MULELAO-1
 lo_LA:						lo_LA.MULELAO-1
 lo_LA.cp1133:					lo_LA.IBM-CP1133
@@ -816,20 +842,33 @@
 XCOMM most locales in FreeBSD 2.1.[56] do not work, allow use of FreeBSD's
 XCOMM generic latin-1 locale name. N.B. "lt" is a bad code to use for a 
 XCOMM generic Latin-1 locale anyway because it is the country code for 
-XCOMM Lithuania, which by default uses Latin-4.
+XCOMM Lithuania, which by default uses Latin-7 (ISO-8859-13).
 lt_LN.ISO_8859-1:				lt_LN.ISO8859-1
 #endif
-lt:						lt_LT.ISO8859-4
-lt_LT:						lt_LT.ISO8859-4
+lt:						lt_LT.ISO8859-13
+lt_LT:						lt_LT.ISO8859-13
 lt_LT.iso88594:					lt_LT.ISO8859-4
 lt_LT.ISO_8859-4:				lt_LT.ISO8859-4
-lt_LT.iso885915:				lt_LT.ISO8859-15
-lv:						lv_LV.ISO8859-4
-lv_LV:						lv_LV.ISO8859-4
+lt_LT.iso885913:				lt_LT.ISO8859-13
+lt_LT.ISO_8859-13:				lt_LT.ISO8859-13
+lv:						lv_LV.ISO8859-13
+lv_LV:						lv_LV.ISO8859-13
 lv_LV.iso88594:					lv_LV.ISO8859-4
+lv_LV.iso885913:				lt_LT.ISO8859-13
+mi:						mi_NZ.ISO8859-1
+mi_NZ:						mi_NZ.ISO8859-1
+mi_NZ.iso88591:					mi_NZ.ISO8859-1
 mk:						mk_MK.ISO8859-5
 mk_MK:						mk_MK.ISO8859-5
 mk_MK.iso88595:					mk_MK.ISO8859-5
+mk_MK.cp1251:					mk_MK.CP1251
+mk_MK.microsoftcp1251:				mk_MK.CP1251
+mk_MK.microsoft-cp1251:				mk_MK.CP1251
+mk_MK.MICROSOFT-CP1251:				mk_MK.CP1251
+mk_MK.utf8:					mk_MK.UTF-8
+ms:						ms_NY.ISO8859-1
+ms_NY:						ms_NY.ISO8859-1
+ms_NY.iso88591:					ms_NY.ISO8859-1
 nl:						nl_NL.ISO8859-1
 nl_BE:						nl_BE.ISO8859-1
 nl_BE.88591:					nl_BE.ISO8859-1
@@ -844,20 +883,41 @@
 nl_NL.ISO_8859-1:				nl_NL.ISO8859-1
 nl_NL.iso885915:				nl_NL.ISO8859-15
 no:						no_NO.ISO8859-1
+nb:						nb_NO.ISO8859-1
+ny:						ny_NO.ISO8859-1
 no_NO:						no_NO.ISO8859-1
+nb_NO:						nb_NO.ISO8859-1
+ny_NO:						ny_NO.ISO8859-1
 no_NO.88591:					no_NO.ISO8859-1
+nb_NO.88591:					nb_NO.ISO8859-1
+ny_NO.88591:					ny_NO.ISO8859-1
 no_NO.88591.en:					no_NO.ISO8859-1
 no_NO.iso88591:					no_NO.ISO8859-1
 no_NO.ISO_8859-1:				no_NO.ISO8859-1
 no_NO.iso885915:				no_NO.ISO8859-15
-no@nynorsk:					no_NO.ISO8859-1
+nb_NO.iso885915:				nb_NO.ISO8859-15
+ny_NO.iso885915:				ny_NO.ISO8859-15
+no@nynorsk:					ny_NO.ISO8859-1
 oc:						oc_FR.ISO8859-1
 oc_FR:						oc_FR.ISO8859-1
 oc_FR.iso88591:					oc_FR.ISO8859-1
 oc_FR.iso885915:				oc_FR.ISO8859-15
+pd:						pd_US.ISO8859-1
+pd_DE:						pd_DE.ISO8859-1
+pd_US:						pd_US.ISO8859-1
+pd_DE.iso88591:					pd_DE.ISO8859-1
+pd_US.iso88591:					pd_US.ISO8859-1
+pd_DE.iso885915:				pd_DE.ISO8859-15
+pd_US.iso885915:				pd_US.ISO8859-15
+ph:						ph_PH.ISO8859-1
+ph_PH:						ph_PH.ISO8859-1
+ph_PH.iso88591:					ph_PH.ISO8859-1
 pl:						pl_PL.ISO8859-2
 pl_PL:						pl_PL.ISO8859-2
 pl_PL.iso88592:					pl_PL.ISO8859-2
+pp:						pp_AN.ISO8859-1
+pp_AN:						pp_AN.ISO8859-1
+pp_AN.iso88591:					pp_AN.ISO8859-1
 pt:						pt_PT.ISO8859-1
 pt_BR:						pt_BR.ISO8859-1
 pt_BR.iso88591:					pt_BR.ISO8859-1
@@ -875,6 +935,10 @@
 ru_RU:						ru_RU.KOI8-R
 ru_RU.iso88595:					ru_RU.ISO8859-5
 ru_RU.koi8r:					ru_RU.KOI8-R
+ru_RU.cp1251:					ru_RU.CP1251
+ru_RU.microsoftcp1251:				ru_RU.CP1251
+ru_RU.microsoft-cp1251:				ru_RU.CP1251
+ru_RU.MICROSOFT-CP1251:				ru_RU.CP1251
 #if defined(INCLUDE_ru_SU)
 XCOMM ru_SU is redundant now
 ru_SU:						ru_RU.KOI8-R
@@ -883,6 +947,10 @@
 #endif
 ru_UA:						ru_UA.KOI8-U
 ru_UA.koi8u:					ru_UA.KOI8-U
+ru_UA.cp1251:					ru_UA.CP1251
+ru_UA.microsoftcp1251:				ru_UA.CP1251
+ru_UA.microsoft-cp1251:				ru_UA.CP1251
+ru_UA.MICROSOFT-CP1251:				ru_UA.CP1251
 sh:						sh_YU.ISO8859-2
 sh_HR.iso88592:					sh_HR.ISO8859-2
 sh_YU:						sh_YU.ISO8859-2
@@ -900,8 +968,8 @@
 sq_AL:						sq_AL.ISO8859-2
 sq_AL.iso88592:					sq_AL.ISO8859-2
 sr_SP:						sr_SP.ISO8859-2
-sr:						sr_YU.ISO8859-5
-sr_YU:						sr_YU.ISO8859-5
+sr:						sr_YU.ISO8859-2
+sr_YU:						sr_YU.ISO8859-2
 sr_YU.iso88592:					sr_YU.ISO8859-2
 sr_YU.iso88595:					sr_YU.ISO8859-5
 sv:						sv_SE.ISO8859-1
@@ -914,16 +982,40 @@
 sv_SE.iso88591:					sv_SE.ISO8859-1
 sv_SE.ISO_8859-1:				sv_SE.ISO8859-1
 sv_SE.iso885915:				sv_SE.ISO8859-15
+ta:						ta_IN.TSCII-0
+ta_IN:						ta_IN.TSCII-0
+ta_IN.tscii:					ta_IN.TSCII-0
+ta_IN.tscii0:					ta_IN.TSCII-0
+tg:						tg_TJ.KOI8-C
+tg_TJ:						tg_TJ.KOI8-C
+tg_TJ.koi8c:					tg_TJ.KOI8-C
 th:						th_TH.TACTIS
 th_TH:						th_TH.TACTIS
 th_TH.tis620:					th_TH.TACTIS
+tl:						tl_PH.ISO8859-1
+tl_PH:						tl_PH.ISO8859-1
+tl_PH.iso88591:					tl_PH.ISO8859-1
 tr:						tr_TR.ISO8859-9
 tr_TR:						tr_TR.ISO8859-9
 tr_TR.iso88599:					tr_TR.ISO8859-9
+tt:						tt_RU.TATAR-CYR
+tt_RU:						tt_RU.TATAR-CYR
+tt_RU.tatarcyr:					tt_RU.TATAR-CYR
+tt_RU.koi8c:					tt_RU.KOI8-C
 uk:						uk_UA.KOI8-U
 uk_UA:						uk_UA.KOI8-U
 uk_UA.iso88595:					uk_UA.ISO8859-5
 uk_UA.koi8u:					uk_UA.KOI8-U
+uk_UA.cp1251:					uk_UA.CP1251
+uk_UA.microsoftcp1251:				uk_UA.CP1251
+uk_UA.microsoft-cp1251:				uk_UA.CP1251
+uk_UA.MICROSOFT-CP1251:				uk_UA.CP1251
+ur:						ur_PK.CP1256
+ur_PK:						ur_PK.CP1256
+ur_PK.cp1256:					ur_PK.CP1256
+ur_PK.microsoftcp1256:				ur_PK.CP1256
+ur_PK.microsoft-cp1256:				ur_PK.CP1256
+ur_PK.MICROSOFT-CP1256:				ur_PK.CP1256
 vi:						vi_VN.TCVN
 vi_VN:						vi_VN.TCVN
 vi_VN.tcvn:					vi_VN.TCVN
@@ -934,9 +1026,16 @@
 wa_BE:						wa_BE.ISO8859-1
 wa_BE.iso88591:					wa_BE.ISO8859-1
 wa_BE.iso885915:				wa_BE.ISO8859-15
+yi:						yi_US.CP1255
+yi_US:						yi_US.CP1255
+yi_US.cp1255:					yi_US.CP1255
+yi_US.microsoftcp1255:				yi_US.CP1255
+yi_US.microsoft-cp1255:				yi_US.CP1255
+yi_US.MICROSOFT-CP1255:				yi_US.CP1255
 zh:						zh_CN.eucCN
 zh_CN:						zh_CN.eucCN
 zh_CN.big5:					zh_TW.big5
+zh_CN.Big5:					zh_TW.big5
 zh_CN.EUC:					zh_CN.eucCN
 zh_CN.euc:					zh_CN.eucCN
 zh_CN.gb2312:					zh_CN.eucCN
@@ -991,13 +1090,9 @@
 spanish.iso88591:				es_ES.ISO8859-1
 swedish.iso88591:				sv_SE.ISO8859-1
 turkish.iso88599:				tr_TR.ISO8859-9
-univ.utf8:					en_US.utf
+univ.utf8:					en_US.UTF-8
 XCOMM Digital Unix utf
-universal.utf8@ucs4:				en_US.utf
-#if defined(SVR4) && defined(sun)
-XCOMM Solaris 2.6
-en_US.UTF-8:					en_US.utf
-#endif
+universal.utf8@ucs4:				en_US.UTF-8
 XCOMM Solaris and SunOS have iso_8859_1 LC_CTYPES to augment LANG=C
 iso_8859_1:					en_US.ISO8859-1
 #ifdef WIN32
@@ -1059,7 +1154,7 @@
 Spanish_El Salvador.1252:			es_SV.iso8859-1
 Spanish_Uruguay.1252:				es_UY.iso8859-1
 Spanish_Venezuela.1252:				es_VE.iso8859-1
-Estonian_Estonia.1257				et_EE.iso8859-4
+Estonian_Estonia.1257:				et_EE.iso8859-13
 Basque_Spain.1252:				eu_ES.iso8859-1
 Finnish_Finland.1252:				fi_FI.iso8859-1
 French_Belgium.1252:				fr_BE.iso8859-1
@@ -1077,8 +1172,8 @@
 Italian_Italy.1252:				it_IT.iso8859-1
 Japanese_Japan.932:				ja_JP.SJIS
 Korean_Korea.949:				ko_KR.EUC
-Lithuanian_Lithuania.1257			lt_LT.iso8859-4
-Latvian_Latvia.1257:				lv_LV.iso8859-4
+Lithuanian_Lithuania.1257:			lt_LT.iso8859-13
+Latvian_Latvia.1257:				lv_LV.iso8859-13
 Dutch_Belgium.1252:				nl_BE.iso8859-1
 Dutch_Netherlands.1252:				nl_NL.iso8859-1
 Norwegian (Nynorsk)_Norway.1252:		no_NO.iso8859-1
Index: xc/nls/locale.dir
diff -u xc/nls/locale.dir:1.12 xc/nls/locale.dir:1.19
--- xc/nls/locale.dir:1.12	Fri Feb 11 21:54:28 2000
+++ xc/nls/locale.dir	Wed Dec  6 17:00:42 2000
@@ -4,13 +4,12 @@
 XCOMM	The first word is the locale database file name and
 XCOMM	the second word is full locale name.
 XCOMM
-XCOMM	$XFree86: xc/nls/locale.dir,v 1.12 2000/02/12 02:54:28 dawes Exp $
+XCOMM	$XFree86: xc/nls/locale.dir,v 1.19 2000/12/06 22:00:42 dawes Exp $
 XCOMM
 #ifdef R63_COMPAT
 XCOMM These entries are in the old format (no ':')
 C/XLC_LOCALE	C
 iso8859-1/XLC_LOCALE	af_ZA.ISO8859-1
-iso8859-6/XLC_LOCALE	ar_AA.ISO8859-6
 iso8859-6/XLC_LOCALE	ar_BH.ISO8859-6
 iso8859-6/XLC_LOCALE	ar_DZ.ISO8859-6
 iso8859-6/XLC_LOCALE	ar_EG.ISO8859-6
@@ -25,7 +24,11 @@
 iso8859-6/XLC_LOCALE	ar_SA.ISO8859-6
 iso8859-6/XLC_LOCALE	ar_TN.ISO8859-6
 iso8859-6/XLC_LOCALE	ar_YE.ISO8859-6
+iso8859-9e/XLC_LOCALE	az_AZ.ISO8859-9E
+koi8-c/XLC_LOCALE		a3_AZ.KOI8-C
+microsoft-cp1251/XLC_LOCALE	be_BY.CP1251
 iso8859-5/XLC_LOCALE	bg_BG.ISO8859-5
+microsoft-cp1251/XLC_LOCALE	bg_BG.CP1251
 iso8859-1/XLC_LOCALE	br_FR.ISO8859-1
 iso8859-14/XLC_LOCALE	br_FR.ISO8859-14
 iso8859-15/XLC_LOCALE	br_FR.ISO8859-15
@@ -48,6 +51,7 @@
 iso8859-1/XLC_LOCALE	en_BZ.ISO8859-1
 iso8859-1/XLC_LOCALE	en_CA.ISO8859-1
 iso8859-1/XLC_LOCALE	en_GB.ISO8859-1
+iso8859-15/XLC_LOCALE	en_GB.ISO8859-15
 iso8859-1/XLC_LOCALE	en_IE.ISO8859-1
 iso8859-1/XLC_LOCALE	en_JM.ISO8859-1
 iso8859-1/XLC_LOCALE	en_NZ.ISO8859-1
@@ -76,8 +80,11 @@
 iso8859-1/XLC_LOCALE	es_SV.ISO8859-1
 iso8859-1/XLC_LOCALE	es_UY.ISO8859-1
 iso8859-1/XLC_LOCALE	es_VE.ISO8859-1
+iso8859-1/XLC_LOCALE	et_EE.ISO8859-1
 iso8859-4/XLC_LOCALE 	et_EE.ISO8859-4
+iso8859-13/XLC_LOCALE 	et_EE.ISO8859-13
 iso8859-15/XLC_LOCALE	et_EE.ISO8859-15
+isiri-3342/XLC_LOCALE	fa_IR.ISIRI-3342
 iso8859-1/XLC_LOCALE	eu_ES.ISO8859-1
 iso8859-15/XLC_LOCALE	eu_ES.ISO8859-15
 iso8859-1/XLC_LOCALE	fi_FI.ISO8859-1
@@ -106,6 +113,8 @@
 iso8859-14/XLC_LOCALE	gv_GB.ISO8859-14
 iso8859-15/XLC_LOCALE	gv_GB.ISO8859-15
 iso8859-8/XLC_LOCALE	he_IL.ISO8859-8
+microsoft-cp1255/XLC_LOCALE	he_IL.CP1255
+iscii-dev/XLC_LOCALE	hi_IN.ISCII-DEV
 iso8859-2/XLC_LOCALE	hr_HR.ISO8859-2
 iso8859-2/XLC_LOCALE	hu_HU.ISO8859-2
 armscii-8/XLC_LOCALE	hy_AM.ARMSCII-8
@@ -114,7 +123,6 @@
 iso8859-15/XLC_LOCALE	is_IS.ISO8859-15
 iso8859-1/XLC_LOCALE	it_CH.ISO8859-1
 iso8859-1/XLC_LOCALE	it_IT.ISO8859-1
-nunacom-8/XLC_LOCALE	iu_CA.NUNACOM-8
 ja/XLC_LOCALE		ja_JP.eucJP
 ja.SJIS/XLC_LOCALE	ja_JP.SJIS
 ja.JIS/XLC_LOCALE	ja_JP.JIS7
@@ -128,19 +136,35 @@
 ibm-cp1133/XLC_LOCALE	lo_LA.IBM-CP1133
 mulelao-1/XLC_LOCALE	lo_LA.MULELAO-1
 iso8859-1/XLC_LOCALE	lt_LN.ISO8859-1
-iso8859-1/XLC_LOCALE	lt_LT.ISO8859-4
-iso8859-1/XLC_LOCALE	lv_LV.ISO8859-4
+iso8859-4/XLC_LOCALE	lt_LT.ISO8859-4
+iso8859-13/XLC_LOCALE	lt_LT.ISO8859-13
+iso8859-4/XLC_LOCALE	lv_LV.ISO8859-4
+iso8859-13/XLC_LOCALE	lv_LV.ISO8859-13
+iso8859-13/XLC_LOCALE	mi_NZ.ISO8859-13
 iso8859-5/XLC_LOCALE	mk_MK.ISO8859-5
+microsoft-cp1251/XLC_LOCALE	mk_MK.CP1251
+iso8859-1/XLC_LOCALE	ms_MY.ISO8859-1
 iso8859-1/XLC_LOCALE	nl_BE.ISO8859-1
 iso8859-1/XLC_LOCALE	nl_NL.ISO8859-1
 iso8859-1/XLC_LOCALE	no_NO.ISO8859-1
+iso8859-1/XLC_LOCALE	no_NO.ISO8859-15
+iso8859-1/XLC_LOCALE	nb_NO.ISO8859-1
+iso8859-1/XLC_LOCALE	nb_NO.ISO8859-15
+iso8859-1/XLC_LOCALE	ny_NO.ISO8859-1
+iso8859-1/XLC_LOCALE	ny_NO.ISO8859-15
 iso8859-1/XLC_LOCALE	oc_FR.ISO8859-1
 iso8859-15/XLC_LOCALE	oc_FR.ISO8859-15
+iso8859-1/XLC_LOCALE	pd_US.ISO8859-1
+iso8859-1/XLC_LOCALE	pd_DE.ISO8859-1
+iso8859-1/XLC_LOCALE	ph_PH.ISO8859-1
 iso8859-2/XLC_LOCALE 	pl_PL.ISO8859-2
+iso8859-1/XLC_LOCALE	pp_AN.ISO8859-1
 iso8859-1/XLC_LOCALE	pt_BR.ISO8859-1
 iso8859-1/XLC_LOCALE	pt_PT.ISO8859-1
+iso8859-1/XLC_LOCALE	pt_PT.ISO8859-15
 iso8859-2/XLC_LOCALE	ro_RO.ISO8859-2
 iso8859-5/XLC_LOCALE 	ru_RU.ISO8859-5
+microsoft-cp1251/XLC_LOCALE 	ru_RU.CP1251
 koi8-r/XLC_LOCALE 	ru_RU.KOI8-R
 koi8-u/XLC_LOCALE	ru_UA.KOI8-U
 iso8859-2/XLC_LOCALE 	sh_YU.ISO8859-2
@@ -156,18 +180,27 @@
 iso8859-15/XLC_LOCALE	sv_FI.ISO8859-15
 iso8859-1/XLC_LOCALE	sv_SE.ISO8859-1
 iso8859-15/XLC_LOCALE	sv_SE.ISO8859-15
-th_TH/XLC_LOCALE	th_TH.TACTIS
+tscii-0/XLC_LOCALE	ta_IN.TSCII-0
+koi8-c/XLC_LOCALE	tg_TJ.KOI8-C
+th_TH.TACTIS/XLC_LOCALE	th_TH.TACTIS
+iso8859-1/XLC_LOCALE 	tl_PH.ISO8859-1
 iso8859-9/XLC_LOCALE 	tr_TR.ISO8859-9
+tatar-cyr/XLC_LOCALE	tt_RU.TATAR-CYR
+koi8-c/XLC_LOCALE		tt_RU.KOI8-C
 iso8859-5/XLC_LOCALE 	uk_UA.ISO8859-5
+microsoft-cp1251/XLC_LOCALE 	uk_UA.CP1251
 koi8-u/XLC_LOCALE	uk_UA.KOI8-U
+microsoft-cp1256/XLC_LOCALE		ur_PK.CP1256
 vi_VN.tcvn/XLC_LOCALE	vi_VN.TCVN
 vi_VN.viscii/XLC_LOCALE	vi_VN.VISCII
 iso8859-1/XLC_LOCALE	wa_BE.ISO8859-1
 iso8859-15/XLC_LOCALE	wa_BE.ISO8859-15
+microsoft-cp1255/XLC_LOCALE	yi_US.CP1255
 zh/XLC_LOCALE		zh_CN.eucCN
+zh/XLC_LOCALE		zh_CN.GB2312
 zh_TW.big5/XLC_LOCALE	zh_TW.big5
-zh_TW.cns11643/XLC_LOCALE	zh_TW.eucTW
-en_US.utf/XLC_LOCALE	en_US.utf
+zh_TW.big5/XLC_LOCALE	zh_TW.Big5
+zh_TW/XLC_LOCALE	zh_TW.eucTW
 XCOMM Note: The UTF-8 locales don't work correctly yet. Work in progress.
 en_US.UTF-8/XLC_LOCALE	af_ZA.UTF-8
 en_US.UTF-8/XLC_LOCALE	ar_AA.UTF-8
@@ -185,6 +218,9 @@
 en_US.UTF-8/XLC_LOCALE	ar_SA.UTF-8
 en_US.UTF-8/XLC_LOCALE	ar_TN.UTF-8
 en_US.UTF-8/XLC_LOCALE	ar_YE.UTF-8
+en_US.UTF-8/XLC_LOCALE	az_AZ.UTF-8
+en_US.UTF-8/XLC_LOCALE	a3_AZ.UTF-8
+en_US.UTF-8/XLC_LOCALE	be_BY.UTF-8
 en_US.UTF-8/XLC_LOCALE	bg_BG.UTF-8
 en_US.UTF-8/XLC_LOCALE	br_FR.UTF-8
 en_US.UTF-8/XLC_LOCALE	ca_ES.UTF-8
@@ -232,6 +268,7 @@
 en_US.UTF-8/XLC_LOCALE	es_VE.UTF-8
 en_US.UTF-8/XLC_LOCALE	et_EE.UTF-8
 en_US.UTF-8/XLC_LOCALE	eu_ES.UTF-8
+en_US.UTF-8/XLC_LOCALE	fa_IR.UTF-8
 en_US.UTF-8/XLC_LOCALE	fi_FI.UTF-8
 en_US.UTF-8/XLC_LOCALE	fo_FO.UTF-8
 en_US.UTF-8/XLC_LOCALE	fr_BE.UTF-8
@@ -244,6 +281,7 @@
 en_US.UTF-8/XLC_LOCALE	gl_ES.UTF-8
 en_US.UTF-8/XLC_LOCALE	gv_GB.UTF-8
 en_US.UTF-8/XLC_LOCALE	he_IL.UTF-8
+en_US.UTF-8/XLC_LOCALE	hi_IN.UTF-8
 en_US.UTF-8/XLC_LOCALE	hr_HR.UTF-8
 en_US.UTF-8/XLC_LOCALE	hu_HU.UTF-8
 en_US.UTF-8/XLC_LOCALE	hy_AM.UTF-8
@@ -260,12 +298,20 @@
 en_US.UTF-8/XLC_LOCALE	lo_LA.UTF-8
 en_US.UTF-8/XLC_LOCALE	lt_LT.UTF-8
 en_US.UTF-8/XLC_LOCALE	lv_LV.UTF-8
+en_US.UTF-8/XLC_LOCALE	mi_NZ.UTF-8
 en_US.UTF-8/XLC_LOCALE	mk_MK.UTF-8
+en_US.UTF-8/XLC_LOCALE	ms_MY.UTF-8
 en_US.UTF-8/XLC_LOCALE	nl_BE.UTF-8
 en_US.UTF-8/XLC_LOCALE	nl_NL.UTF-8
 en_US.UTF-8/XLC_LOCALE	no_NO.UTF-8
+en_US.UTF-8/XLC_LOCALE	nb_NO.UTF-8
+en_US.UTF-8/XLC_LOCALE	ny_NO.UTF-8
 en_US.UTF-8/XLC_LOCALE	oc_FR.UTF-8
+en_US.UTF-8/XLC_LOCALE	pd_DE.UTF-8
+en_US.UTF-8/XLC_LOCALE	pd_US.UTF-8
+en_US.UTF-8/XLC_LOCALE	ph_PH.UTF-8
 en_US.UTF-8/XLC_LOCALE	pl_PL.UTF-8
+en_US.UTF-8/XLC_LOCALE	pp_AN.UTF-8
 en_US.UTF-8/XLC_LOCALE	pt_BR.UTF-8
 en_US.UTF-8/XLC_LOCALE	pt_PT.UTF-8
 en_US.UTF-8/XLC_LOCALE	ro_RO.UTF-8
@@ -277,11 +323,17 @@
 en_US.UTF-8/XLC_LOCALE	sr_YU.UTF-8
 en_US.UTF-8/XLC_LOCALE	sv_FI.UTF-8
 en_US.UTF-8/XLC_LOCALE	sv_SE.UTF-8
+en_US.UTF-8/XLC_LOCALE	ta_IN.UTF-8
+en_US.UTF-8/XLC_LOCALE	tg_TJ.UTF-8
 en_US.UTF-8/XLC_LOCALE	th_TH.UTF-8
+en_US.UTF-8/XLC_LOCALE	tl_PH.UTF-8
 en_US.UTF-8/XLC_LOCALE	tr_TR.UTF-8
+en_US.UTF-8/XLC_LOCALE	tt_RU.UTF-8
 en_US.UTF-8/XLC_LOCALE	uk_UA.UTF-8
+en_US.UTF-8/XLC_LOCALE	ur_PK.UTF-8
 en_US.UTF-8/XLC_LOCALE	vi_VN.UTF-8
 en_US.UTF-8/XLC_LOCALE	wa_BE.UTF-8
+en_US.UTF-8/XLC_LOCALE	yi_US.UTF-8
 en_US.UTF-8/XLC_LOCALE	zh_CN.UTF-8
 en_US.UTF-8/XLC_LOCALE	zh_TW.UTF-8
 #ifdef __uxp__
@@ -307,7 +359,11 @@
 iso8859-6/XLC_LOCALE:	ar_SA.ISO8859-6
 iso8859-6/XLC_LOCALE:	ar_TN.ISO8859-6
 iso8859-6/XLC_LOCALE:	ar_YE.ISO8859-6
+iso8859-9e/XLC_LOCALE:	az_AZ.ISO8859-9E
+koi8-c/XLC_LOCALE:		a3_AZ.KOI8-C
+microsoft-cp1251/XLC_LOCALE:	be_BY.CP1251
 iso8859-5/XLC_LOCALE:	bg_BG.ISO8859-5
+microsoft-cp1251/XLC_LOCALE:	bg_BG.CP1251
 iso8859-1/XLC_LOCALE:	br_FR.ISO8859-1
 iso8859-14/XLC_LOCALE:	br_FR.ISO8859-14
 iso8859-15/XLC_LOCALE:	br_FR.ISO8859-15
@@ -330,6 +386,7 @@
 iso8859-1/XLC_LOCALE:	en_BZ.ISO8859-1
 iso8859-1/XLC_LOCALE:	en_CA.ISO8859-1
 iso8859-1/XLC_LOCALE:	en_GB.ISO8859-1
+iso8859-15/XLC_LOCALE:	en_GB.ISO8859-15
 iso8859-1/XLC_LOCALE:	en_IE.ISO8859-1
 iso8859-1/XLC_LOCALE:	en_JM.ISO8859-1
 iso8859-1/XLC_LOCALE:	en_NZ.ISO8859-1
@@ -358,10 +415,13 @@
 iso8859-1/XLC_LOCALE:	es_SV.ISO8859-1
 iso8859-1/XLC_LOCALE:	es_UY.ISO8859-1
 iso8859-1/XLC_LOCALE:	es_VE.ISO8859-1
+iso8859-1/XLC_LOCALE:	et_EE.ISO8859-1
 iso8859-4/XLC_LOCALE: 	et_EE.ISO8859-4
+iso8859-13/XLC_LOCALE: 	et_EE.ISO8859-13
 iso8859-15/XLC_LOCALE:	et_EE.ISO8859-15
 iso8859-1/XLC_LOCALE:	eu_ES.ISO8859-1
 iso8859-15/XLC_LOCALE:	eu_ES.ISO8859-15
+isiri-3342/XLC_LOCALE:	fa_IR.ISIRI-3342
 iso8859-1/XLC_LOCALE:	fi_FI.ISO8859-1
 iso8859-15/XLC_LOCALE:	fi_FI.ISO8859-15
 iso8859-1/XLC_LOCALE:	fo_FO.ISO8859-1
@@ -388,6 +448,8 @@
 iso8859-14/XLC_LOCALE:	gv_GB.ISO8859-14
 iso8859-15/XLC_LOCALE:	gv_GB.ISO8859-15
 iso8859-8/XLC_LOCALE:	he_IL.ISO8859-8
+microsoft-cp1255/XLC_LOCALE:	he_IL.CP1255
+iscii-dev/XLC_LOCALE:	hi_IN.ISCII-DEV
 iso8859-2/XLC_LOCALE:	hr_HR.ISO8859-2
 iso8859-2/XLC_LOCALE:	hu_HU.ISO8859-2
 armscii-8/XLC_LOCALE:	hy_AM.ARMSCII-8
@@ -396,7 +458,6 @@
 iso8859-15/XLC_LOCALE:	is_IS.ISO8859-15
 iso8859-1/XLC_LOCALE:	it_CH.ISO8859-1
 iso8859-1/XLC_LOCALE:	it_IT.ISO8859-1
-nunacom-8/XLC_LOCALE:	iu_CA.NUNACOM-8
 ja/XLC_LOCALE:		ja_JP.eucJP
 ja.SJIS/XLC_LOCALE:	ja_JP.SJIS
 ja.JIS/XLC_LOCALE:	ja_JP.JIS7
@@ -409,20 +470,35 @@
 iso8859-15/XLC_LOCALE:	kw_GB.ISO8859-15
 ibm-cp1133/XLC_LOCALE:	lo_LA.IBM-CP1133
 mulelao-1/XLC_LOCALE:	lo_LA.MULELAO-1
-iso8859-1/XLC_LOCALE:	lt_LN.ISO8859-1
-iso8859-1/XLC_LOCALE:	lt_LT.ISO8859-4
-iso8859-1/XLC_LOCALE:	lv_LV.ISO8859-4
+iso8859-4/XLC_LOCALE:	lt_LT.ISO8859-4
+iso8859-13/XLC_LOCALE:	lt_LT.ISO8859-13
+iso8859-4/XLC_LOCALE:	lv_LV.ISO8859-4
+iso8859-13/XLC_LOCALE:	lv_LV.ISO8859-13
+iso8859-13/XLC_LOCALE:	mi_NZ.ISO8859-13
 iso8859-5/XLC_LOCALE:	mk_MK.ISO8859-5
+miscrosoft-cp1251/XLC_LOCALE:	mk_MK.CP1251
+iso8859-1/XLC_LOCALE:	ms_MY.ISO8859-1
 iso8859-1/XLC_LOCALE:	nl_BE.ISO8859-1
 iso8859-1/XLC_LOCALE:	nl_NL.ISO8859-1
 iso8859-1/XLC_LOCALE:	no_NO.ISO8859-1
+iso8859-1/XLC_LOCALE:	no_NO.ISO8859-15
+iso8859-1/XLC_LOCALE:	nb_NO.ISO8859-1
+iso8859-1/XLC_LOCALE:	nb_NO.ISO8859-15
+iso8859-1/XLC_LOCALE:	ny_NO.ISO8859-1
+iso8859-1/XLC_LOCALE:	ny_NO.ISO8859-15
 iso8859-1/XLC_LOCALE:	oc_FR.ISO8859-1
 iso8859-15/XLC_LOCALE:	oc_FR.ISO8859-15
-iso8859-2/XLC_LOCALE: 	pl_PL.ISO8859-2
+iso8859-1/XLC_LOCALE:	pd_US.ISO8859-1
+iso8859-1/XLC_LOCALE:	pd_DE.ISO8859-1
+iso8859-1/XLC_LOCALE:	ph_PH.ISO8859-1
+iso8859-2/XLC_LOCALE:   pl_PL.ISO8859-2
+iso8859-1/XLC_LOCALE:	pp_AN.ISO8859-1
 iso8859-1/XLC_LOCALE:	pt_BR.ISO8859-1
 iso8859-1/XLC_LOCALE:	pt_PT.ISO8859-1
+iso8859-15/XLC_LOCALE:	pt_PT.ISO8859-15
 iso8859-2/XLC_LOCALE:	ro_RO.ISO8859-2
 iso8859-5/XLC_LOCALE: 	ru_RU.ISO8859-5
+microsoft-cp1251/XLC_LOCALE: 	ru_RU.CP1251
 koi8-r/XLC_LOCALE: 	ru_RU.KOI8-R
 koi8-u/XLC_LOCALE:	ru_UA.KOI8-U
 iso8859-2/XLC_LOCALE: 	sh_YU.ISO8859-2
@@ -438,18 +514,27 @@
 iso8859-15/XLC_LOCALE:	sv_FI.ISO8859-15
 iso8859-1/XLC_LOCALE:	sv_SE.ISO8859-1
 iso8859-15/XLC_LOCALE:	sv_SE.ISO8859-15
-th_TH/XLC_LOCALE:	th_TH.TACTIS
-iso8859-9/XLC_LOCALE: 	tr_TR.ISO8859-9
+tscii-0/XLC_LOCALE:		ta_IN.TSCII-0
+koi8-c/XLC_LOCALE:		tg_TJ.KOI8-C
+th_TH.TACTIS/XLC_LOCALE:		th_TH.TACTIS
+iso8859-1/XLC_LOCALE: 	tl_PH.ISO8859-1
+iso8859-9/XLC_LOCALE:	tr_TR.ISO8859-9
+tatar-cyr/XLC_LOCALE:	tt_RU.TATAR-CYR
+koi8-c/XLC_LOCALE:		tt_RU.KOI8-C
 iso8859-5/XLC_LOCALE: 	uk_UA.ISO8859-5
+microsoft-cp1251/XLC_LOCALE: 	uk_UA.CP1251
 koi8-u/XLC_LOCALE:	uk_UA.KOI8-U
+microsoft-cp1256/XLC_LOCALE:	ur_PK.CP1256
 vi_VN.tcvn/XLC_LOCALE:	vi_VN.TCVN
 vi_VN.viscii/XLC_LOCALE:	vi_VN.VISCII
 iso8859-1/XLC_LOCALE:	wa_BE.ISO8859-1
 iso8859-15/XLC_LOCALE:	wa_BE.ISO8859-15
+microsoft-cp1255/XLC_LOCALE:	yi_US.CP1255
 zh/XLC_LOCALE:		zh_CN.eucCN
+zh/XLC_LOCALE:		zh_CN.GB2312
 zh_TW.big5/XLC_LOCALE:	zh_TW.big5
-zh_TW.cns11643/XLC_LOCALE:	zh_TW.eucTW
-en_US.utf/XLC_LOCALE:	en_US.utf
+zh_TW.big5/XLC_LOCALE:	zh_TW.Big5
+zh_TW/XLC_LOCALE:	zh_TW.eucTW
 XCOMM Note: The UTF-8 locales don't work correctly yet. Work in progress.
 en_US.UTF-8/XLC_LOCALE:	af_ZA.UTF-8
 en_US.UTF-8/XLC_LOCALE:	ar_AA.UTF-8
@@ -467,6 +552,9 @@
 en_US.UTF-8/XLC_LOCALE:	ar_SA.UTF-8
 en_US.UTF-8/XLC_LOCALE:	ar_TN.UTF-8
 en_US.UTF-8/XLC_LOCALE:	ar_YE.UTF-8
+en_US.UTF-8/XLC_LOCALE:	az_AZ.UTF-8
+en_US.UTF-8/XLC_LOCALE:	a3_AZ.UTF-8
+en_US.UTF-8/XLC_LOCALE:	be_BY.UTF-8
 en_US.UTF-8/XLC_LOCALE:	bg_BG.UTF-8
 en_US.UTF-8/XLC_LOCALE:	br_FR.UTF-8
 en_US.UTF-8/XLC_LOCALE:	ca_ES.UTF-8
@@ -514,6 +602,7 @@
 en_US.UTF-8/XLC_LOCALE:	es_VE.UTF-8
 en_US.UTF-8/XLC_LOCALE:	et_EE.UTF-8
 en_US.UTF-8/XLC_LOCALE:	eu_ES.UTF-8
+en_US.UTF-8/XLC_LOCALE:	fa_IR.UTF-8
 en_US.UTF-8/XLC_LOCALE:	fi_FI.UTF-8
 en_US.UTF-8/XLC_LOCALE:	fo_FO.UTF-8
 en_US.UTF-8/XLC_LOCALE:	fr_BE.UTF-8
@@ -526,6 +615,7 @@
 en_US.UTF-8/XLC_LOCALE:	gl_ES.UTF-8
 en_US.UTF-8/XLC_LOCALE:	gv_GB.UTF-8
 en_US.UTF-8/XLC_LOCALE:	he_IL.UTF-8
+en_US.UTF-8/XLC_LOCALE:	hi_IN.UTF-8
 en_US.UTF-8/XLC_LOCALE:	hr_HR.UTF-8
 en_US.UTF-8/XLC_LOCALE:	hu_HU.UTF-8
 en_US.UTF-8/XLC_LOCALE:	hy_AM.UTF-8
@@ -542,12 +632,20 @@
 en_US.UTF-8/XLC_LOCALE:	lo_LA.UTF-8
 en_US.UTF-8/XLC_LOCALE:	lt_LT.UTF-8
 en_US.UTF-8/XLC_LOCALE:	lv_LV.UTF-8
+en_US.UTF-8/XLC_LOCALE:	mi_NZ.UTF-8
 en_US.UTF-8/XLC_LOCALE:	mk_MK.UTF-8
+en_US.UTF-8/XLC_LOCALE:	ms_MY.UTF-8
 en_US.UTF-8/XLC_LOCALE:	nl_BE.UTF-8
 en_US.UTF-8/XLC_LOCALE:	nl_NL.UTF-8
 en_US.UTF-8/XLC_LOCALE:	no_NO.UTF-8
+en_US.UTF-8/XLC_LOCALE:	nb_NO.UTF-8
+en_US.UTF-8/XLC_LOCALE:	ny_NO.UTF-8
 en_US.UTF-8/XLC_LOCALE:	oc_FR.UTF-8
+en_US.UTF-8/XLC_LOCALE:	pd_DE.UTF-8
+en_US.UTF-8/XLC_LOCALE:	pd_US.UTF-8
+en_US.UTF-8/XLC_LOCALE:	ph_PH.UTF-8
 en_US.UTF-8/XLC_LOCALE:	pl_PL.UTF-8
+en_US.UTF-8/XLC_LOCALE:	pp_AN.UTF-8
 en_US.UTF-8/XLC_LOCALE:	pt_BR.UTF-8
 en_US.UTF-8/XLC_LOCALE:	pt_PT.UTF-8
 en_US.UTF-8/XLC_LOCALE:	ro_RO.UTF-8
@@ -559,11 +657,17 @@
 en_US.UTF-8/XLC_LOCALE:	sr_YU.UTF-8
 en_US.UTF-8/XLC_LOCALE:	sv_FI.UTF-8
 en_US.UTF-8/XLC_LOCALE:	sv_SE.UTF-8
+en_US.UTF-8/XLC_LOCALE:	ta_IN.UTF-8
+en_US.UTF-8/XLC_LOCALE:	tg_TJ.UTF-8
 en_US.UTF-8/XLC_LOCALE:	th_TH.UTF-8
+en_US.UTF-8/XLC_LOCALE:	tl_PH.UTF-8
 en_US.UTF-8/XLC_LOCALE:	tr_TR.UTF-8
+en_US.UTF-8/XLC_LOCALE:	tt_RU.UTF-8
 en_US.UTF-8/XLC_LOCALE:	uk_UA.UTF-8
+en_US.UTF-8/XLC_LOCALE:	ur_PK.UTF-8
 en_US.UTF-8/XLC_LOCALE:	vi_VN.UTF-8
 en_US.UTF-8/XLC_LOCALE:	wa_BE.UTF-8
+en_US.UTF-8/XLC_LOCALE:	yi_US.UTF-8
 en_US.UTF-8/XLC_LOCALE:	zh_CN.UTF-8
 en_US.UTF-8/XLC_LOCALE:	zh_TW.UTF-8
 #ifdef __uxp__
Index: xc/nls/Compose/Imakefile
diff -u xc/nls/Compose/Imakefile:1.9 xc/nls/Compose/Imakefile:1.12
--- xc/nls/Compose/Imakefile:1.9	Thu Mar 16 16:59:40 2000
+++ xc/nls/Compose/Imakefile	Wed Dec  6 17:00:43 2000
@@ -1,5 +1,5 @@
 XCOMM $TOG: Imakefile /main/9 1998/06/29 09:17:20 kaleb $
-XCOMM $XFree86: xc/nls/Compose/Imakefile,v 1.9 2000/03/16 21:59:40 dawes Exp $
+XCOMM $XFree86: xc/nls/Compose/Imakefile,v 1.12 2000/12/06 22:00:43 dawes Exp $
 
 #ifndef Win32Architecture
 #ifndef OS2Architecture
@@ -27,7 +27,6 @@
 #endif
 
 ComposeTarget(armscii-8)
-ComposeTarget(en_US.utf)
 ComposeTarget(georgian-academy)
 ComposeTarget(georgian-ps)
 ComposeTarget(ibm-cp1133)
@@ -41,14 +40,18 @@
 ComposeTarget(iso8859-8)
 ComposeTarget(iso8859-9)
 ComposeTarget(iso8859-10)
+ComposeTarget(iso8859-13)
 ComposeTarget(iso8859-14)
 ComposeTarget(iso8859-15)
+ComposeTarget(iso8859-9e)
 ComposeTarget(ja)
 ComposeTarget(ja.JIS)
 ComposeTarget(ja.SJIS)
 ComposeTarget(ko)
 ComposeTarget(koi8-r)
 ComposeTarget(koi8-u)
+ComposeTarget(koi8-c)
+ComposeTarget(mk_MK.UTF-8)
 ComposeTarget(mulelao-1)
 ComposeTarget(th_TH.TACTIS)
 ComposeTarget(vi_VN.tcvn)
Index: xc/nls/Compose/en_US.utf
diff -u xc/nls/Compose/en_US.utf:1.1 xc/nls/Compose/en_US.utf:removed
--- xc/nls/Compose/en_US.utf:1.1	Sat Aug 28 05:00:34 1999
+++ xc/nls/Compose/en_US.utf	Mon Dec 18 14:26:49 2000
@@ -1,15 +0,0 @@
-#
-# en_US.utf Compose Sequence
-#
-# Sequence Definition
-#
-# $XFree86: xc/nls/Compose/en_US.utf,v 1.1 1999/08/28 09:00:34 dawes Exp $
-#
-# This file currently has no entries.  It appears that a compose file (even
-# just an empty one) is required for the appropriate keysyms to work for
-# this encoding.
-#
-# <Multi_key> Means <Compose>
-# Special Character
-
-# End of Sequence Definition
Index: xc/nls/Compose/iso8859-1
diff -u xc/nls/Compose/iso8859-1:1.4 xc/nls/Compose/iso8859-1:1.5
--- xc/nls/Compose/iso8859-1:1.4	Tue Jun 13 19:15:49 2000
+++ xc/nls/Compose/iso8859-1	Fri Oct 27 14:30:50 2000
@@ -3,7 +3,7 @@
 # ISO 8859-1 (Latin1) Compose Sequence
 #
 #
-# $XFree86: xc/nls/Compose/iso8859-1,v 1.4 2000/06/13 23:15:49 dawes Exp $
+# $XFree86: xc/nls/Compose/iso8859-1,v 1.5 2000/10/27 18:30:50 dawes Exp $
 #
 # Sequence Definition
 #
@@ -12,7 +12,7 @@
 <Multi_key> <plus> <plus>		: "#"	numbersign
 <Multi_key> <apostrophe> <space>	: "'"	apostrophe
 <Multi_key> <space> <apostrophe>	: "'"	apostrophe
-<Multi_key> <A> <A>			: "@"	at
+<Multi_key> <A> <T>			: "@"	at
 <Multi_key> <parenleft> <parenleft>	: "["	bracketleft
 <Multi_key> <slash> <slash>		: "\\"	backslash
 <Multi_key> <slash> <less>		: "\\"	backslash
@@ -99,6 +99,7 @@
 <Multi_key> <0> <c>			: "\251"	copyright
 <Multi_key> <C> <0>			: "\251"	copyright
 <Multi_key> <0> <C>			: "\251"	copyright
+<Multi_key> <parenleft> <c>		: "\251"	copyright
 <Multi_key> <a> <underscore>		: "\252"	ordfeminine
 <Multi_key> <underscore> <a>		: "\252"	ordfeminine
 <Multi_key> <A> <underscore>		: "\252"	ordfeminine
@@ -161,6 +162,7 @@
 <Multi_key> <minus> <minus>		: "\255"	hyphen
 <Multi_key> <R> <O>			: "\256"	registered
 <Multi_key> <O> <R>			: "\256"	registered
+<Multi_key> <parenleft> <r>		: "\256"	registered
 <Multi_key> <minus> <asciicircum>	: "\257"	macron
 <Multi_key> <asciicircum> <minus>	: "\257"	macron
 <Multi_key> <underscore> <asciicircum>	: "\257"	macron
@@ -193,6 +195,8 @@
 <Multi_key> <diaeresis> <A>		: "\304"	Adiaeresis
 <Multi_key> <A> <asterisk>		: "\305"	Aring
 <Multi_key> <asterisk> <A>		: "\305"	Aring
+<Multi_key> <A> <A>			: "\305"	Aring
+<Multi_key> <A> <O>			: "\305"	Aring
 <Multi_key> <A> <E>			: "\306"	AE
 <Multi_key> <a> <grave>			: "\340"	agrave
 <Multi_key> <grave> <a>			: "\340"	agrave
@@ -214,6 +218,8 @@
 <Multi_key> <diaeresis> <a>		: "\344"	adiaeresis
 <Multi_key> <a> <asterisk>		: "\345"	aring
 <Multi_key> <asterisk> <a>		: "\345"	aring
+<Multi_key> <a> <a>			: "\345"	aring
+<Multi_key> <a> <o>			: "\345"	aring
 <Multi_key> <a> <e>			: "\346"	ae
 <Multi_key> <acute> <C>                 : "\307"        Ccedilla
 <Multi_key> <acute> <c>                 : "\347"        ccedilla
@@ -385,6 +391,8 @@
 <dead_grave> <space>			: "`"	grave
 <dead_acute> <space>			: "'"	apostrophe
 <dead_doubleacute> <space>		: "\""	quotedbl
+<dead_abovering> <space>		: "\260"	degree
+<dead_abovering> <dead_abovering>	: "\260"	degree
 <dead_circumflex> <0>			: "\260"	degree
 <dead_circumflex> <1>			: "\271"	onesuperior
 <dead_circumflex> <2>			: "\262"	twosuperior
@@ -398,11 +406,13 @@
 <dead_cedilla> <comma>			: "\270"	cedilla
 <dead_diaeresis> <quotedbl>		: "\250"	diaeresis
 # Accented Alphabet
+<dead_abovering> <A>			: "\305"	Aring
 <dead_grave> <A>			: "\300"	Agrave
 <dead_acute> <A>			: "\301"	Aacute
 <dead_circumflex> <A>			: "\302"	Acircumflex
 <dead_tilde> <A>			: "\303"	Atilde
 <dead_diaeresis> <A>			: "\304"	Adiaeresis
+<dead_abovering> <a>			: "\345"	aring
 <dead_grave> <a>			: "\340"	agrave
 <dead_acute> <a>			: "\341"	aacute
 <dead_circumflex> <a>			: "\342"	acircumflex
@@ -451,10 +461,12 @@
 <dead_acute> <Y>			: "\335"	Yacute
 <dead_acute> <y>			: "\375"	yacute
 <dead_diaeresis> <y>			: "\377"	ydiaeresis
+# Useful for portuguese language
 <dead_acute> <C>                        : "\307"        Ccedilla
 <dead_acute> <c>                        : "\347"        ccedilla
 <dead_acute> <dead_acute>               : "'"           apostrophe
 <dead_grave> <dead_grave>               : "`"           grave
+# These are for us_intl, that does not has diaeresis, etc
 <dead_diaeresis> <space>                : "\""          quotedbl
 <dead_diaeresis> <dead_diaeresis>       : "\""          quotedbl
 <dead_tilde> <dead_tilde>               : "~"           asciitilde
@@ -646,6 +658,8 @@
 Ctrl<T> <diaeresis> <A>			: "\304"	Adiaeresis
 Ctrl<T> <A> <asterisk>			: "\305"	Aring
 Ctrl<T> <asterisk> <A>			: "\305"	Aring
+Ctrl<T> <A> <A>				: "\305"	Aring
+Ctrl<T> <A> <O>				: "\305"	Aring
 Ctrl<T> <A> <E>				: "\306"	AE
 Ctrl<T> <a> <grave>			: "\340"	agrave
 Ctrl<T> <grave> <a>			: "\340"	agrave
@@ -667,6 +681,8 @@
 Ctrl<T> <diaeresis> <a>			: "\344"	adiaeresis
 Ctrl<T> <a> <asterisk>			: "\345"	aring
 Ctrl<T> <asterisk> <a>			: "\345"	aring
+Ctrl<T> <a> <a>				: "\345"	aring
+Ctrl<T> <a> <o>				: "\345"	aring
 Ctrl<T> <a> <e>				: "\346"	ae
 Ctrl<T> <C> <comma>			: "\307"	Ccedilla
 Ctrl<T> <comma> <C>			: "\307"	Ccedilla
Index: xc/nls/Compose/iso8859-13
diff -u /dev/null xc/nls/Compose/iso8859-13:1.1
--- /dev/null	Mon Dec 18 14:26:50 2000
+++ xc/nls/Compose/iso8859-13	Fri Oct 27 14:30:50 2000
@@ -0,0 +1,433 @@
+# $XFree86: xc/nls/Compose/iso8859-13,v 1.1 2000/10/27 18:30:50 dawes Exp $
+#
+# ISO 8859-13 (Latin7) Compose Sequence
+#
+# Sequence Definition
+#
+# <Multi_key> Means <Compose>
+# Special Character
+# Right-hand side (Accented Alphabet)
+# These compose sequences are pure supposition on my part.
+# It would be nice to know what the real cultural conventions
+# are for compose sequences.
+<Multi_key> <plus> <plus>               : "#"   numbersign
+<Multi_key> <apostrophe> <space>        : "'"   apostrophe
+<Multi_key> <space> <apostrophe>        : "'"   apostrophe
+<Multi_key> <A> <T>                     : "@"   at
+<Multi_key> <parenleft> <parenleft>     : "["   bracketleft
+<Multi_key> <slash> <slash>             : "\\"  backslash
+<Multi_key> <slash> <less>              : "\\"  backslash
+<Multi_key> <less> <slash>              : "\\"  backslash
+<Multi_key> <parenright> <parenright>   : "]"   bracketright
+<Multi_key> <asciicircum> <space>       : "^"   asciicircum
+<Multi_key> <space> <asciicircum>       : "^"   asciicircum
+<Multi_key> <greater> <space>           : "^"   asciicircum
+<Multi_key> <space> <greater>           : "^"   asciicircum
+<Multi_key> <grave> <space>             : "`"   grave
+<Multi_key> <space> <grave>             : "`"   grave
+<Multi_key> <less> <apostrophe>         : "`"   grave
+<Multi_key> <apostrophe> <less>         : "`"   grave
+<Multi_key> <parenleft> <minus>         : "{"   braceleft
+<Multi_key> <minus> <parenleft>         : "{"   braceleft
+<Multi_key> <slash> <asciicircum>       : "|"   bar
+<Multi_key> <asciicircum> <slash>       : "|"   bar
+<Multi_key> <parenright> <minus>        : "}"   braceright
+<Multi_key> <minus> <parenright>        : "}"   braceright
+<Multi_key> <asciitilde> <space>        : "~"   asciitilde
+<Multi_key> <space> <asciitilde>        : "~"   asciitilde
+<Multi_key> <minus> <space>             : "~"   asciitilde
+<Multi_key> <space> <minus>             : "~"   asciitilde
+<Multi_key> <greater> <quotedbl>	: "\241"	rightdoublequotemark
+<Multi_key> <quotedbl> <greater>	: "\241"	rightdoublequotemark
+<Multi_key> <greater> <comma>		: "\245"	doublelowquotemark
+<Multi_key> <comma> <greater>		: "\245"	doublelowquotemark
+<Multi_key> <less> <quotedbl>		: "\264"	leftdoublequotemark
+<Multi_key> <quotedbl> <less>		: "\264"	leftdoublequotemark
+<Multi_key> <less> <less>               : "\253"        guillemotleft
+<Multi_key> <greater> <greater>         : "\273"        guillemotright
+<Multi_key> <apostrophe> <apostrophe>	: "\377"	rightsinglequotemark
+<Multi_key> <greater> <apostrophe> 	: "\377"	rightsinglequotemark
+<Multi_key> <apostrophe> <greater>	: "\377"	rightsinglequotemark
+<Multi_key> <c> <slash>                 : "\242"        cent
+<Multi_key> <slash> <c>                 : "\242"        cent
+<Multi_key> <C> <slash>                 : "\242"        cent
+<Multi_key> <slash> <C>                 : "\242"        cent
+<Multi_key> <C> <bar>                   : "\242"        cent
+<Multi_key> <bar> <C>                   : "\242"        cent
+<Multi_key> <c> <bar>                   : "\242"        cent
+<Multi_key> <bar> <c>                   : "\242"        cent
+<Multi_key> <l> <minus>                 : "\243"        sterling
+<Multi_key> <minus> <l>                 : "\243"        sterling
+<Multi_key> <L> <minus>                 : "\243"        sterling
+<Multi_key> <minus> <L>                 : "\243"        sterling
+<Multi_key> <l> <equal>                 : "\243"        sterling
+<Multi_key> <equal> <l>                 : "\243"        sterling
+<Multi_key> <L> <equal>                 : "\243"        sterling
+<Multi_key> <equal> <L>                 : "\243"        sterling
+<Multi_key> <c> <o>                     : "\251"        copyright
+<Multi_key> <o> <c>                     : "\251"        copyright
+<Multi_key> <C> <O>                     : "\251"        copyright
+<Multi_key> <O> <C>                     : "\251"        copyright
+<Multi_key> <c> <O>                     : "\251"        copyright
+<Multi_key> <O> <c>                     : "\251"        copyright
+<Multi_key> <C> <o>                     : "\251"        copyright
+<Multi_key> <o> <C>                     : "\251"        copyright
+<Multi_key> <c> <0>                     : "\251"        copyright
+<Multi_key> <0> <c>                     : "\251"        copyright
+<Multi_key> <C> <0>                     : "\251"        copyright
+<Multi_key> <0> <C>                     : "\251"        copyright
+<Multi_key> <parenleft> <c>             : "\251"        copyright
+<Multi_key> <s> <o>                     : "\247"        section
+<Multi_key> <o> <s>                     : "\247"        section
+<Multi_key> <S> <O>                     : "\247"        section
+<Multi_key> <O> <S>                     : "\247"        section
+<Multi_key> <S> <exclam>                : "\247"        section
+<Multi_key> <exclam> <S>                : "\247"        section
+<Multi_key> <s> <exclam>                : "\247"        section
+<Multi_key> <exclam> <s>                : "\247"        section
+<Multi_key> <S> <0>                     : "\247"        section
+<Multi_key> <0> <S>                     : "\247"        section
+<Multi_key> <s> <0>                     : "\247"        section
+<Multi_key> <0> <s>                     : "\247"        section
+<Multi_key> <x> <o>                     : "\244"        currency
+<Multi_key> <o> <x>                     : "\244"        currency
+<Multi_key> <X> <O>                     : "\244"        currency
+<Multi_key> <O> <X>                     : "\244"        currency
+<Multi_key> <x> <O>                     : "\244"        currency
+<Multi_key> <O> <x>                     : "\244"        currency
+<Multi_key> <X> <o>                     : "\244"        currency
+<Multi_key> <o> <X>                     : "\244"        currency
+<Multi_key> <x> <0>                     : "\244"        currency
+<Multi_key> <0> <x>                     : "\244"        currency
+<Multi_key> <X> <0>                     : "\244"        currency
+<Multi_key> <0> <X>                     : "\244"        currency
+<Multi_key> <0> <asciicircum>           : "\260"        degree
+<Multi_key> <asciicircum> <0>           : "\260"        degree
+<Multi_key> <0> <asterisk>              : "\260"        degree
+<Multi_key> <asterisk> <0>              : "\260"        degree
+<Multi_key> <plus> <minus>              : "\261"        plusminus
+<Multi_key> <minus> <plus>              : "\261"        plusminus
+<Multi_key> <m> <u> 	                : "\265"        mu
+<Multi_key> <slash> <u>                 : "\265"        mu
+<Multi_key> <u> <slash>                 : "\265"        mu
+<Multi_key> <slash> <U>                 : "\265"        mu
+<Multi_key> <U> <slash>                 : "\265"        mu
+<Multi_key> <1> <asciicircum>           : "\271"        onesuperior
+<Multi_key> <asciicircum> <1>           : "\271"        onesuperior
+<Multi_key> <S> <1>                     : "\271"        onesuperior
+<Multi_key> <1> <S>                     : "\271"        onesuperior
+<Multi_key> <s> <1>                     : "\271"        onesuperior
+<Multi_key> <1> <s>                     : "\271"        onesuperior
+<Multi_key> <2> <asciicircum>           : "\262"        twosuperior
+<Multi_key> <asciicircum> <2>           : "\262"        twosuperior
+<Multi_key> <S> <2>                     : "\262"        twosuperior
+<Multi_key> <2> <S>                     : "\262"        twosuperior
+<Multi_key> <s> <2>                     : "\262"        twosuperior
+<Multi_key> <2> <s>                     : "\262"        twosuperior
+<Multi_key> <3> <asciicircum>           : "\263"        threesuperior
+<Multi_key> <asciicircum> <3>           : "\263"        threesuperior
+<Multi_key> <S> <3>                     : "\263"        threesuperior
+<Multi_key> <3> <S>                     : "\263"        threesuperior
+<Multi_key> <s> <3>                     : "\263"        threesuperior
+<Multi_key> <3> <s>                     : "\263"        threesuperior
+<Multi_key> <p> <exclam>                : "\266"        paragraph
+<Multi_key> <exclam> <p>                : "\266"        paragraph
+<Multi_key> <P> <exclam>                : "\266"        paragraph
+<Multi_key> <exclam> <P>                : "\266"        paragraph
+<Multi_key> <period> <asciicircum>      : "\267"        periodcentered
+<Multi_key> <asciicircum> <period>      : "\267"        periodcentered
+<Multi_key> <period> <period>           : "\267"        periodcentered
+<Multi_key> <1> <4>                     : "\274"        onequarter
+<Multi_key> <1> <2>                     : "\275"        onehalf
+<Multi_key> <3> <4>                     : "\276"        threequarters
+<Multi_key> <question> <question>       : "\277"        questiondown
+<Multi_key> <space> <space>             : "\240"        nobreakspace
+<Multi_key> <bar> <bar>                 : "\246"        brokenbar
+<Multi_key> <exclam> <asciicircum>      : "\246"        brokenbar
+<Multi_key> <asciicircum> <exclam>      : "\246"        brokenbar
+<Multi_key> <V> <B>                     : "\246"        brokenbar
+<Multi_key> <B> <V>                     : "\246"        brokenbar
+<Multi_key> <v> <b>                     : "\246"        brokenbar
+<Multi_key> <b> <v>                     : "\246"        brokenbar
+<Multi_key> <minus> <comma>             : "\254"        notsign
+<Multi_key> <comma> <minus>             : "\254"        notsign
+<Multi_key> <minus> <minus>             : "\255"        hyphen
+<Multi_key> <R> <O>                     : "\256"        registered
+<Multi_key> <O> <R>                     : "\256"        registered
+<Multi_key> <parenleft> <r>             : "\256"        registered
+<Multi_key> <minus> <colon>             : "\367"        division
+<Multi_key> <colon> <minus>             : "\367"        division
+<Multi_key> <x> <x>                     : "\327"        multiply
+# Accented Alphabet
+<Multi_key> <A> <semicolon>		: "\300"	Aogonek
+<Multi_key> <semicolon> <A>		: "\300"	Aogonek
+<Multi_key> <A> <comma>			: "\300"	Aogonek
+<Multi_key> <comma> <A>			: "\300"	Aogonek
+<Multi_key> <R> <comma>			: "\252"	Rcedilla
+<Multi_key> <comma> <R>			: "\252"	Rcedilla
+<Multi_key> <L> <comma>			: "\317"	Lcedilla
+<Multi_key> <comma> <L>			: "\317"	Lcedilla
+<Multi_key> <S> <exclam>		: "\247"	section
+<Multi_key> <exclam> <S>		: "\247"	section
+<Multi_key> <s> <exclam>		: "\247"	section
+<Multi_key> <exclam> <s>		: "\247"	section
+<Multi_key> <S> <less>			: "\320"	Scaron
+<Multi_key> <less> <S>			: "\320"	Scaron
+<Multi_key> <E> <minus>			: "\307"	Emacron
+<Multi_key> <minus> <E>			: "\307"	Emacron
+<Multi_key> <E> <underscore>		: "\307"	Emacron
+<Multi_key> <underscore> <E>		: "\307"	Emacron
+<Multi_key> <G> <comma>			: "\314"	Gcedilla
+<Multi_key> <comma> <G>			: "\314"	Gcedilla
+<Multi_key> <minus> <minus>		: "\255"	hyphen
+<Multi_key> <Z> <less>			: "\336"	Zcaron
+<Multi_key> <less> <Z>			: "\336"	Zcaron
+<Multi_key> <0> <asterisk>		: "\260"	degree
+<Multi_key> <asterisk> <0>		: "\260"	degree
+<Multi_key> <a> <semicolon>		: "\340"	aogonek
+<Multi_key> <semicolon> <a>		: "\340"	aogonek
+<Multi_key> <a> <comma>			: "\340"	aogonek
+<Multi_key> <comma> <a>			: "\340"	aogonek
+<Multi_key> <r> <comma>			: "\272"	rcedilla
+<Multi_key> <comma> <r>			: "\272"	rcedilla
+<Multi_key> <l> <comma>			: "\357"	lcedilla
+<Multi_key> <comma> <l>			: "\357"	lcedilla
+<Multi_key> <s> <less>			: "\360"	scaron
+<Multi_key> <less> <s>			: "\360"	scaron
+<Multi_key> <e> <minus>			: "\347"	emacron
+<Multi_key> <minus> <e>			: "\347"	emacron
+<Multi_key> <e> <underscore>		: "\347"	emacron
+<Multi_key> <underscore> <e>		: "\347"	emacron
+<Multi_key> <g> <comma>			: "\354"	gcedilla
+<Multi_key> <comma> <g>			: "\354"	gcedilla
+<Multi_key> <z> <less>			: "\376"	zcaron
+<Multi_key> <less> <z>			: "\376"	zcaron
+<Multi_key> <A> <underscore>		: "\302"	Amacron
+<Multi_key> <underscore> <A>		: "\302"	Amacron
+<Multi_key> <A> <minus>			: "\302"	Amacron
+<Multi_key> <minus> <A>			: "\302"	Amacron
+<Multi_key> <A> <quotedbl>		: "\304"	Adiaeresis
+<Multi_key> <quotedbl> <A>		: "\304"	Adiaeresis
+<Multi_key> <A> <asterisk>		: "\305"	Aring
+<Multi_key> <asterisk> <A>		: "\305"	Aring
+<Multi_key> <A> <A>			: "\305"	Aring
+<Multi_key> <A> <O>			: "\305"	Aring
+<Multi_key> <A> <E>			: "\257"	AE
+<Multi_key> <I> <semicolon>		: "\301"	Iogonek
+<Multi_key> <semicolon> <I>		: "\301"	Iogonek
+<Multi_key> <I> <comma>			: "\301"	Iogonek
+<Multi_key> <comma> <I>			: "\301"	Iogonek
+<Multi_key> <C> <less>			: "\310"	Ccaron
+<Multi_key> <less> <C>			: "\310"	Ccaron
+<Multi_key> <E> <acute>			: "\311"	Eacute
+<Multi_key> <acute> <E>			: "\311"	Eacute
+<Multi_key> <E> <apostrophe>		: "\311"	Eacute
+<Multi_key> <apostrophe> <E>		: "\311"	Eacute
+<Multi_key> <E> <semicolon>		: "\306"	Eogonek
+<Multi_key> <semicolon> <E>		: "\306"	Eogonek
+<Multi_key> <E> <comma>			: "\306"	Eogonek
+<Multi_key> <comma> <E>			: "\306"	Eogonek
+<Multi_key> <E> <period>		: "\313"	Eabovedot
+<Multi_key> <period> <E>		: "\313"	Eabovedot
+<Multi_key> <I> <minus>			: "\316"	Imacron
+<Multi_key> <minus> <I>			: "\316"	Imacron
+<Multi_key> <I> <underscore>		: "\316"	Imacron
+<Multi_key> <underscore> <I>		: "\316"	Imacron
+<Multi_key> <N> <comma>			: "\322"	Ncedilla
+<Multi_key> <comma> <N>			: "\322"	Ncedilla
+<Multi_key> <O> <underscore>		: "\324"	Omacron
+<Multi_key> <underscore> <O>		: "\324"	Omacron
+<Multi_key> <O> <minus>			: "\324"	Omacron
+<Multi_key> <minus> <O>			: "\324"	Omacron
+<Multi_key> <K> <comma>			: "\315"	Kcedilla
+<Multi_key> <comma> <K>			: "\315"	Kcedilla
+<Multi_key> <O> <asciitilde>		: "\325"	Otilde
+<Multi_key> <asciitilde> <O>		: "\325"	Otilde
+<Multi_key> <O> <quotedbl>		: "\326"	Odiaeresis
+<Multi_key> <quotedbl> <O>		: "\326"	Odiaeresis
+<Multi_key> <x> <x>			: "\327"	multiply
+<Multi_key> <O> <slash>			: "\250"	Ooblique
+<Multi_key> <slash> <O>			: "\250"	Ooblique
+<Multi_key> <o> <slash>			: "\270"	oslash
+<Multi_key> <slash> <o>			: "\270"	oslash
+<Multi_key> <U> <semicolon>		: "\330"	Uogonek
+<Multi_key> <semicolon> <U>		: "\330"	Uogonek
+<Multi_key> <U> <comma>			: "\330"	Uogonek
+<Multi_key> <comma> <U>			: "\330"	Uogonek
+<Multi_key> <U> <quotedbl>		: "\334"	Udiaeresis
+<Multi_key> <quotedbl> <U>		: "\334"	Udiaeresis
+<Multi_key> <U> <underscore>		: "\333"	Umacron
+<Multi_key> <underscore> <U>		: "\333"	Umacron
+<Multi_key> <U> <minus>			: "\333"	Umacron
+<Multi_key> <minus> <U>			: "\333"	Umacron
+<Multi_key> <s> <s>			: "\337"	ssharp
+<Multi_key> <a> <underscore>		: "\342"	amacron
+<Multi_key> <underscore> <a>		: "\342"	amacron
+<Multi_key> <a> <minus>			: "\342"	amacron
+<Multi_key> <minus> <a>			: "\342"	amacron
+<Multi_key> <a> <quotedbl>		: "\344"	adiaeresis
+<Multi_key> <quotedbl> <a>		: "\344"	adiaeresis
+<Multi_key> <a> <asterisk>		: "\345"	aring
+<Multi_key> <asterisk> <a>		: "\345"	aring
+<Multi_key> <a> <a>			: "\345"	aring
+<Multi_key> <a> <o>			: "\345"	aring
+<Multi_key> <a> <e>			: "\277"	ae
+<Multi_key> <i> <semicolon>		: "\341"	iogonek
+<Multi_key> <semicolon> <i>		: "\341"	iogonek
+<Multi_key> <i> <comma>			: "\341"	iogonek
+<Multi_key> <comma> <i>			: "\341"	iogonek
+<Multi_key> <c> <less>			: "\350"	ccaron
+<Multi_key> <less> <c>			: "\350"	ccaron
+<Multi_key> <e> <acute>			: "\351"	eacute
+<Multi_key> <acute> <e>			: "\351"	eacute
+<Multi_key> <e> <apostrophe>		: "\351"	eacute
+<Multi_key> <apostrophe> <e>		: "\351"	eacute
+<Multi_key> <e> <semicolon>		: "\346"	eogonek
+<Multi_key> <semicolon> <e>		: "\346"	eogonek
+<Multi_key> <e> <comma>			: "\346"	eogonek
+<Multi_key> <comma> <e>			: "\346"	eogonek
+<Multi_key> <e> <period>		: "\353"	eabovedot
+<Multi_key> <period> <e>		: "\353"	eabovedot
+<Multi_key> <i> <minus>			: "\356"	imacron
+<Multi_key> <minus> <i>			: "\356"	imacron
+<Multi_key> <i> <underscore>		: "\356"	imacron
+<Multi_key> <underscore> <i>		: "\356"	imacron
+<Multi_key> <n> <comma>			: "\362"	ncedilla
+<Multi_key> <comma> <n>			: "\362"	ncedilla
+<Multi_key> <o> <underscore>		: "\364"	omacron
+<Multi_key> <underscore> <o>		: "\364"	omacron
+<Multi_key> <o> <minus>			: "\364"	omacron
+<Multi_key> <minus> <o>			: "\364"	omacron
+<Multi_key> <k> <comma>			: "\355"	kcedilla
+<Multi_key> <comma> <k>			: "\355"	kcedilla
+<Multi_key> <o> <asciitilde>		: "\365"	otilde
+<Multi_key> <asciitilde> <o>		: "\365"	otilde
+<Multi_key> <o> <quotedbl>		: "\366"	odiaeresis
+<Multi_key> <quotedbl> <o>		: "\366"	odiaeresis
+<Multi_key> <o> <slash>			: "\270"	ooblique
+<Multi_key> <slash> <o>			: "\270"	ooblique
+<Multi_key> <u> <semicolon>		: "\370"	uogonek
+<Multi_key> <semicolon> <u>		: "\370"	uogonek
+<Multi_key> <u> <comma>			: "\370"	uogonek
+<Multi_key> <comma> <u>			: "\370"	uogonek
+<Multi_key> <u> <quotedbl>		: "\374"	udiaeresis
+<Multi_key> <quotedbl> <u>		: "\374"	udiaeresis
+<Multi_key> <u> <underscore>		: "\373"	umacron
+<Multi_key> <underscore> <u>		: "\373"	umacron
+<Multi_key> <u> <minus>			: "\373"	umacron
+<Multi_key> <minus> <u>			: "\373"	umacron
+<Multi_key> <C> <apostrophe>		: "\303"	Cacute
+<Multi_key> <apostrophe> <C>		: "\303"	Cacute
+<Multi_key> <c> <apostrophe>		: "\343"	cacute
+<Multi_key> <apostrophe> <c>		: "\343"	cacute
+<Multi_key> <O> <apostrophe>		: "\323"	Oacute
+<Multi_key> <apostrophe> <O>		: "\323"	Oacute
+<Multi_key> <o> <apostrophe>		: "\363"	oacute
+<Multi_key> <apostrophe> <o>		: "\363"	oacute
+<Multi_key> <Z> <apostrophe>		: "\312"	Zacute
+<Multi_key> <apostrophe> <Z>		: "\312"	Zacute
+<Multi_key> <z> <apostrophe>		: "\352"	zacute
+<Multi_key> <apostrophe> <z>		: "\352"	zacute
+<Multi_key> <N> <apostrophe>		: "\321"	Nacute
+<Multi_key> <apostrophe> <N>		: "\321"	Nacute
+<Multi_key> <n> <apostrophe>		: "\361"	nacute
+<Multi_key> <apostrophe> <n>		: "\361"	nacute
+<Multi_key> <L> <minus>			: "\331"	Lstroke
+<Multi_key> <minus> <L>			: "\331"	Lstroke
+<Multi_key> <L> <slash>			: "\331"	Lstroke
+<Multi_key> <slash> <L>			: "\331"	Lstroke
+<Multi_key> <l> <minus>			: "\371"	lstroke
+<Multi_key> <minus> <l>			: "\371"	lstroke
+<Multi_key> <l> <slash>			: "\371"	lstroke
+<Multi_key> <slash> <l>			: "\371"	lstroke
+<Multi_key> <S> <apostrophe>		: "\332"	Sacute
+<Multi_key> <apostrophe> <S>		: "\332"	Sacute
+<Multi_key> <s> <apostrophe>		: "\372"	sacute
+<Multi_key> <apostrophe> <s>		: "\372"	sacute
+<Multi_key> <Z> <period>		: "\335"	Zabovedot
+<Multi_key> <period> <Z>		: "\335"	Zabovedot
+<Multi_key> <z> <period>		: "\375"	zabovedot
+<Multi_key> <period> <z>		: "\375"	zabovedot
+
+<dead_abovedot> <E> 			: "\313"	Eabovedot
+<dead_abovedot> <e>			: "\353"	eabovedot
+<dead_abovedot> <Z>			: "\335"	Zabovedot
+<dead_abovedot> <z>			: "\375"	zabovedot
+<dead_abovedot> <dead_abovedot>		: "\267"	abovedot
+<dead_abovering> <A>			: "\305"	Aring
+<dead_abovering> <a>			: "\345"	aring
+<dead_abovering> <E> 			: "\313"	Eabovedot
+<dead_abovering> <e>			: "\353"	eabovedot
+<dead_abovering> <Z>			: "\335"	Zabovedot
+<dead_abovering> <z>			: "\375"	zabovedot
+<dead_abovedot> <A>			: "\305"	Aring
+<dead_abovedot> <a>			: "\345"	aring
+<dead_acute> <dead_acute>		: "\377"	rightsinglequotemark
+<dead_acute> <C>			: "\303"	Cacute
+<dead_acute> <E>			: "\311"	Eacute
+<dead_acute> <Z>			: "\312"	Zacute
+<dead_acute> <N>			: "\321"	Nacute
+<dead_acute> <O>			: "\323"	Oacute
+<dead_acute> <S>			: "\332"	Sacute
+<dead_acute> <c>			: "\343"	cacute
+<dead_acute> <e>			: "\351"	eacute
+<dead_acute> <z>			: "\352"	zacute
+<dead_acute> <n>			: "\361"	nacute
+<dead_acute> <o>			: "\363"	oacute
+<dead_acute> <s>			: "\372"	sacute
+<dead_caron> <C>			: "\310"	Ccaron
+<dead_caron> <S>			: "\320"	Scaron
+<dead_caron> <Z>			: "\336"	Zcaron
+<dead_caron> <s>			: "\350"	ccaron
+<dead_caron> <s>			: "\360"	scaron
+<dead_caron> <z>			: "\376"	zcaron
+<dead_cedilla> <R>			: "\252"	Rcedilla
+<dead_cedilla> <G>			: "\314"	Gcedilla
+<dead_cedilla> <K>			: "\315"	Kcedilla
+<dead_cedilla> <L>			: "\317"	Lcedilla
+<dead_cedilla> <N>			: "\322"	Ncedilla
+<dead_cedilla> <r>			: "\272"	rcedilla
+<dead_cedilla> <g>			: "\354"	gcedilla
+<dead_cedilla> <k>			: "\355"	kcedilla
+<dead_cedilla> <l>			: "\357"	lcedilla
+<dead_cedilla> <n>			: "\362"	ncedilla
+<dead_diaeresis> <A>			: "\304"	Adiaeresis
+<dead_diaeresis> <O>			: "\326"	Odiaeresis
+<dead_diaeresis> <U>			: "\334"	Udiaeresis
+<dead_diaeresis> <a>			: "\344"	adiaeresis
+<dead_diaeresis> <o>			: "\366"	odiaeresis
+<dead_diaeresis> <u>			: "\374"	udiaeresis
+<dead_macron> <A>			: "\302"	Amacron
+<dead_macron> <E>			: "\307"	Emacron
+<dead_macron> <I>			: "\316"	Imacron
+<dead_macron> <O>			: "\324"	Omacron
+<dead_macron> <U>			: "\333"	Umacron
+<dead_macron> <a>			: "\342"	amacron
+<dead_macron> <e>			: "\347"	emacron
+<dead_macron> <i>			: "\356"	imacron
+<dead_macron> <o>			: "\364"	omacron
+<dead_macron> <u>			: "\373"	umacron
+<dead_macron> <macron>			: "\255"	macron
+<dead_macron> <dead_macron>		: "\255"	macron
+<dead_ogonek> <A>			: "\300"	Aogonek
+<dead_ogonek> <I>			: "\301"	Iogonek
+<dead_ogonek> <E>			: "\306"	Eogonek
+<dead_ogonek> <U>			: "\330"	Uogonek
+<dead_ogonek> <a>			: "\340"	aogonek
+<dead_ogonek> <i>			: "\341"	iogonek
+<dead_ogonek> <e>			: "\346"	eogonek
+<dead_ogonek> <u>			: "\370"	uogonek
+<dead_abovering> <A>			: "\305"	Aring
+<dead_abovering> <a>			: "\345"	aring
+<dead_abovering> <E>	 		: "\313"	Eabovedot
+<dead_abovering> <e>			: "\353"	eabovedot
+<dead_abovering> <Z>			: "\335"	Zabovedot
+<dead_abovering> <z>			: "\375"	zabovedot
+<dead_abovering> <ring>			: "\260"	ring
+<dead_abovering> <dead_abovering>	: "\260"	ring
+<dead_tilde> <O>			: "\325"	Otilde
+<dead_tilde> <o>			: "\365"	otilde
+<dead_tilde> <asciitilde>		: "~"		asciitilde
+<dead_tilde> <dead_tilde>		: "~"		asciitilde
+
+# End of Sequence Definition
Index: xc/nls/Compose/iso8859-14
diff -u xc/nls/Compose/iso8859-14:1.2 xc/nls/Compose/iso8859-14:1.3
--- xc/nls/Compose/iso8859-14:1.2	Tue Feb  8 12:18:48 2000
+++ xc/nls/Compose/iso8859-14	Fri Oct 27 14:30:51 2000
@@ -3,7 +3,7 @@
 #
 # ISO 8859-14 (Latin-8) Compose Sequence
 #
-# $XFree86: xc/nls/Compose/iso8859-14,v 1.2 2000/02/08 17:18:48 dawes Exp $
+# $XFree86: xc/nls/Compose/iso8859-14,v 1.3 2000/10/27 18:30:51 dawes Exp $
 #
 # The following is from the Latin-1 definitions
 # Sequence Definition
@@ -13,7 +13,7 @@
 <Multi_key> <plus> <plus>		: "#"	numbersign
 <Multi_key> <apostrophe> <space>	: "'"	apostrophe
 <Multi_key> <space> <apostrophe>	: "'"	apostrophe
-<Multi_key> <A> <A>			: "@"	at
+<Multi_key> <A> <T>			: "@"	at
 <Multi_key> <parenleft> <parenleft>	: "["	bracketleft
 <Multi_key> <slash> <slash>		: "\\"	backslash
 <Multi_key> <slash> <less>		: "\\"	backslash
@@ -21,8 +21,8 @@
 <Multi_key> <parenright> <parenright>	: "]"	bracketright
 <Multi_key> <asciicircum> <space>	: "^"	asciicircum
 <Multi_key> <space> <asciicircum>	: "^"	asciicircum
-<Multi_key> <greater> <space>		: "^"	asciicirum
-<Multi_key> <space> <greater>		: "^"	asciicirum
+<Multi_key> <greater> <space>		: "^"	asciicircum
+<Multi_key> <space> <greater>		: "^"	asciicircum
 <Multi_key> <grave> <space>		: "`"	grave
 <Multi_key> <space> <grave>		: "`"	grave
 <Multi_key> <parenleft> <minus>		: "{"	braceleft
@@ -349,10 +349,6 @@
 <Multi_key> <acute> <Y>			: "\335"	Yacute
 <Multi_key> <Y> <apostrophe>		: "\335"	Yacute
 <Multi_key> <apostrophe> <Y>		: "\335"	Yacute
-<Multi_key> <Y> <quotedbl>		: "\276"	Ydiaeresis
-<Multi_key> <quotedbl> <Y>		: "\276"	Ydiaeresis
-<Multi_key> <Y> <diaeresis>		: "\276"	Ydiaeresis
-<Multi_key> <diaeresis> <Y>		: "\276"	Ydiaeresis
 <Multi_key> <y> <acute>			: "\375"	yacute
 <Multi_key> <acute> <y>			: "\375"	yacute
 <Multi_key> <y> <apostrophe>		: "\375"	yacute
@@ -439,7 +435,6 @@
 <dead_circumflex> <u>			: "\373"	ucircumflex
 <dead_diaeresis> <u>			: "\374"	udiaeresis
 <dead_acute> <Y>			: "\335"	Yacute
-<dead_diaeresis> <Y>			: "\276"	Ydiaeresis
 <dead_acute> <y>			: "\375"	yacute
 <dead_diaeresis> <y>			: "\377"	ydiaeresis
 <dead_caron> <Z>			: "\264"	Zcaron
@@ -448,51 +443,146 @@
 # The following is Celtic character support
 #
 
-<Multi_Key> <.> <b>			: "¢"	bdotabove
-<Multi_Key> <.> <B>			: "¡"   Bdotabove
-<Multi_Key> <.> <c>			: "¥"   cdotabove
-<Multi_Key> <.> <C>			: "¤"   Cdotabove
-<Multi_Key> <.> <d>			: "«"   ddotabove
-<Multi_Key> <.> <D>			: "¦"   Ddotabove
-<Multi_Key> <.> <f>			: "¯"   fdotabove
-<Multi_Key> <.> <F>			: "°"   Fdotabove
-<Multi_Key> <.> <g>			: "³"   gdotabove
-<Multi_Key> <.> <G>			: "²"   Gdotabove
-<Multi_Key> <.> <m>			: "µ"   mdotabove
-<Multi_Key> <.> <M>			: "´"   Mdotabove
-<Multi_Key> <.> <p>			: "¹"   pdotabove
-<Multi_Key> <.> <P>			: "·"   Pdotabove
-<Multi_Key> <.> <s>			: "¿"   sdotabove
-<Multi_Key> <.> <S>			: "»"   Sdotabove
-<Multi_Key> <.> <t>			: "÷"   tdotabove
-<Multi_Key> <.> <T>			: "×"   Tdotabove
-<Multi_Key> <b> <.>			: "¢"   bdotabove
-<Multi_Key> <B> <.>			: "¡"   Bdotabove
-<Multi_Key> <c> <.>			: "¥"   cdotabove
-<Multi_Key> <C> <.>			: "¤"   Cdotabove
-<Multi_Key> <d> <.>			: "«"   ddotabove
-<Multi_Key> <D> <.>			: "¦"   Ddotabove
-<Multi_Key> <f> <.>			: "¯"   fdotabove
-<Multi_Key> <F> <.>			: "°"   Fdotabove
-<Multi_Key> <g> <.>			: "³"   gdotabove
-<Multi_Key> <G> <.>			: "²"   Gdotabove
-<Multi_Key> <m> <.>			: "µ"   mdotabove
-<Multi_Key> <M> <.>			: "´"   Mdotabove
-<Multi_Key> <p> <.>			: "¹"   pdotabove
-<Multi_Key> <P> <.>			: "·"   Pdotabove
-<Multi_Key> <s> <.>			: "¿"   sdotabove
-<Multi_Key> <S> <.>			: "»"   Sdotabove
-<Multi_Key> <t> <.>			: "÷"   tdotabove
-<Multi_Key> <T> <.>			: "×"   Tdotabove
-
-<Multi_Key> <y> <asciicircum>		: "\376" ycircumflex
-<Multi_Key> <asciicircum> <y>           : "\376" ycircumflex
-<Multi_Key> <Y> <asciicircum>           : "\336" Ycircumflex
-<Multi_Key> <asciicircum> <Y>           : "\336" Ycircumflex
-<Multi_Key> <w> <asciicircum>		: "\360" wcircumflex
-<Multi_Key> <asciicircum> <w>           : "\360" wcircumflex
-<Multi_Key> <W> <asciicircum>           : "\320" Wcircumflex
-<Multi_Key> <asciicircum> <W>           : "\320" Wcircumflex
+<Multi_key> <period> <b>			: "¢"	bdotabove
+<Multi_key> <period> <B>			: "¡"   Bdotabove
+<Multi_key> <period> <c>			: "¥"   cdotabove
+<Multi_key> <period> <C>			: "¤"   Cdotabove
+<Multi_key> <period> <d>			: "«"   ddotabove
+<Multi_key> <period> <D>			: "¦"   Ddotabove
+<Multi_key> <period> <f>			: "¯"   fdotabove
+<Multi_key> <period> <F>			: "°"   Fdotabove
+<Multi_key> <period> <g>			: "³"   gdotabove
+<Multi_key> <period> <G>			: "²"   Gdotabove
+<Multi_key> <period> <m>			: "µ"   mdotabove
+<Multi_key> <period> <M>			: "´"   Mdotabove
+<Multi_key> <period> <p>			: "¹"   pdotabove
+<Multi_key> <period> <P>			: "·"   Pdotabove
+<Multi_key> <period> <s>			: "¿"   sdotabove
+<Multi_key> <period> <S>			: "»"   Sdotabove
+<Multi_key> <period> <t>			: "÷"   tdotabove
+<Multi_key> <period> <T>			: "×"   Tdotabove
+<Multi_key> <b> <period>			: "¢"   bdotabove
+<Multi_key> <B> <period>			: "¡"   Bdotabove
+<Multi_key> <c> <period>			: "¥"   cdotabove
+<Multi_key> <C> <period>			: "¤"   Cdotabove
+<Multi_key> <d> <period>			: "«"   ddotabove
+<Multi_key> <D> <period>			: "¦"   Ddotabove
+<Multi_key> <f> <period>			: "¯"   fdotabove
+<Multi_key> <F> <period>			: "°"   Fdotabove
+<Multi_key> <g> <period>			: "³"   gdotabove
+<Multi_key> <G> <period>			: "²"   Gdotabove
+<Multi_key> <m> <period>			: "µ"   mdotabove
+<Multi_key> <M> <period>			: "´"   Mdotabove
+<Multi_key> <p> <period>			: "¹"   pdotabove
+<Multi_key> <P> <period>			: "·"   Pdotabove
+<Multi_key> <s> <period>			: "¿"   sdotabove
+<Multi_key> <S> <period>			: "»"   Sdotabove
+<Multi_key> <t> <period>			: "÷"   tdotabove
+<Multi_key> <T> <period>			: "×"   Tdotabove
 
+<Multi_key> <y> <asciicircum>		: "\376" ycircumflex
+<Multi_key> <asciicircum> <y>           : "\376" ycircumflex
+<Multi_key> <Y> <asciicircum>           : "\336" Ycircumflex
+<Multi_key> <asciicircum> <Y>           : "\336" Ycircumflex
+<Multi_key> <w> <asciicircum>		: "\360" wcircumflex
+<Multi_key> <asciicircum> <w>           : "\360" wcircumflex
+<Multi_key> <W> <asciicircum>           : "\320" Wcircumflex
+<Multi_key> <asciicircum> <W>           : "\320" Wcircumflex
+
+<Multi_key> <Y> <quotedbl>		: "\257"	Ydiaeresis
+<Multi_key> <quotedbl> <Y>		: "\257"	Ydiaeresis
+<Multi_key> <Y> <diaeresis>		: "\257"	Ydiaeresis
+<Multi_key> <diaeresis> <Y>		: "\257"	Ydiaeresis
+<Multi_key> <W> <quotedbl>		: "½"	Wdiaeresis
+<Multi_key> <quotedbl> <W>		: "½"	Wdiaeresis
+<Multi_key> <W> <diaeresis>		: "½"	Wdiaeresis
+<Multi_key> <diaeresis> <W>		: "½"	Wdiaeresis
+<Multi_key> <w> <quotedbl>		: "¾"	wdiaeresis
+<Multi_key> <quotedbl> <w>		: "¾"	wdiaeresis
+<Multi_key> <w> <diaeresis>		: "¾"	wdiaeresis
+<Multi_key> <diaeresis> <w>		: "¾"	wdiaeresis
+
+<Multi_key> <Y> <grave>			: "¬"	Ygrave
+<Multi_key> <grave> <Y>			: "¬"	Ygrave
+<Multi_key> <y> <grave>			: "¼"	ygrave
+<Multi_key> <grave> <y>			: "¼"	ygrave
+<Multi_key> <W> <grave>			: "¨"	Wgrave
+<Multi_key> <grave> <w>			: "¨"	Wgrave
+<Multi_key> <W> <grave>			: "¸"	wgrave
+<Multi_key> <grave> <w>			: "¸"	wgrave
+
+
+
+<dead_abovedot> <b>			: "¢"	bdotabove
+<dead_abovedot> <B>			: "¡"   Bdotabove
+<dead_abovedot> <c>			: "¥"   cdotabove
+<dead_abovedot> <C>			: "¤"   Cdotabove
+<dead_abovedot> <d>			: "«"   ddotabove
+<dead_abovedot> <D>			: "¦"   Ddotabove
+<dead_abovedot> <f>			: "¯"   fdotabove
+<dead_abovedot> <F>			: "°"   Fdotabove
+<dead_abovedot> <g>			: "³"   gdotabove
+<dead_abovedot> <G>			: "²"   Gdotabove
+<dead_abovedot> <m>			: "µ"   mdotabove
+<dead_abovedot> <M>			: "´"   Mdotabove
+<dead_abovedot> <p>			: "¹"   pdotabove
+<dead_abovedot> <P>			: "·"   Pdotabove
+<dead_abovedot> <s>			: "¿"   sdotabove
+<dead_abovedot> <S>			: "»"   Sdotabove
+<dead_abovedot> <t>			: "÷"   tdotabove
+<dead_abovedot> <T>			: "×"   Tdotabove
+
+<dead_circumflex> <y>           : "\376" ycircumflex
+<dead_circumflex> <Y>           : "\336" Ycircumflex
+<dead_circumflex> <w>           : "\360" wcircumflex
+<dead_circumflex> <W>           : "\320" Wcircumflex
+<dead_circumflex> <b>			: "¢"	bdotabove
+<dead_circumflex> <B>			: "¡"   Bdotabove
+<dead_circumflex> <c>			: "¥"   cdotabove
+<dead_circumflex> <C>			: "¤"   Cdotabove
+<dead_circumflex> <d>			: "«"   ddotabove
+<dead_circumflex> <D>			: "¦"   Ddotabove
+<dead_circumflex> <f>			: "¯"   fdotabove
+<dead_circumflex> <F>			: "°"   Fdotabove
+<dead_circumflex> <g>			: "³"   gdotabove
+<dead_circumflex> <G>			: "²"   Gdotabove
+<dead_circumflex> <m>			: "µ"   mdotabove
+<dead_circumflex> <M>			: "´"   Mdotabove
+<dead_circumflex> <p>			: "¹"   pdotabove
+<dead_circumflex> <P>			: "·"   Pdotabove
+<dead_circumflex> <s>			: "¿"   sdotabove
+<dead_circumflex> <S>			: "»"   Sdotabove
+<dead_circumflex> <t>			: "÷"   tdotabove
+<dead_circumflex> <T>			: "×"   Tdotabove
+
+<dead_acute> <w>			: "ª"	wacute
+<dead_acute> <W>			: "º"   Wacute
+<dead_acute> <b>			: "¢"	bdotabove
+<dead_acute> <B>			: "¡"   Bdotabove
+<dead_acute> <c>			: "¥"   cdotabove
+<dead_acute> <C>			: "¤"   Cdotabove
+<dead_acute> <d>			: "«"   ddotabove
+<dead_acute> <D>			: "¦"   Ddotabove
+<dead_acute> <f>			: "¯"   fdotabove
+<dead_acute> <F>			: "°"   Fdotabove
+<dead_acute> <g>			: "³"   gdotabove
+<dead_acute> <G>			: "²"   Gdotabove
+<dead_acute> <m>			: "µ"   mdotabove
+<dead_acute> <M>			: "´"   Mdotabove
+<dead_acute> <p>			: "¹"   pdotabove
+<dead_acute> <P>			: "·"   Pdotabove
+<dead_acute> <s>			: "¿"   sdotabove
+<dead_acute> <S>			: "»"   Sdotabove
+<dead_acute> <t>			: "÷"   tdotabove
+<dead_acute> <T>			: "×"   Tdotabove
+
+<dead_diaeresis> <Y>			: "\257"	Ydiaeresis
+<dead_diaeresis> <w>			: "½"	wdiaeresis
+<dead_diaeresis> <W>			: "¾"   Wdiaeresis
+
+<dead_grave> <Y>			: "¬"	Ygrave
+<dead_grave> <y>			: "¼"	ygrave
+<dead_grave> <w>			: "¨"	Wgrave
+<dead_grave> <w>			: "¸"	wgrave
 
 # End of Sequence Definition
Index: xc/nls/Compose/iso8859-15
diff -u xc/nls/Compose/iso8859-15:1.2 xc/nls/Compose/iso8859-15:1.3
--- xc/nls/Compose/iso8859-15:1.2	Sat Aug 28 05:00:35 1999
+++ xc/nls/Compose/iso8859-15	Fri Oct 27 14:30:51 2000
@@ -2,7 +2,7 @@
 #
 # ISO 8859-15 (Latin1) Compose Sequence
 #
-# $XFree86: xc/nls/Compose/iso8859-15,v 1.2 1999/08/28 09:00:35 dawes Exp $
+# $XFree86: xc/nls/Compose/iso8859-15,v 1.3 2000/10/27 18:30:51 dawes Exp $
 #
 # Sequence Definition
 #
@@ -11,7 +11,7 @@
 <Multi_key> <plus> <plus>		: "#"	numbersign
 <Multi_key> <apostrophe> <space>	: "'"	apostrophe
 <Multi_key> <space> <apostrophe>	: "'"	apostrophe
-<Multi_key> <A> <A>			: "@"	at
+<Multi_key> <A> <T>			: "@"	at
 <Multi_key> <parenleft> <parenleft>	: "["	bracketleft
 <Multi_key> <slash> <slash>		: "\\"	backslash
 <Multi_key> <slash> <less>		: "\\"	backslash
@@ -56,6 +56,8 @@
 <Multi_key> <equal> <L>			: "\243"	sterling
 <Multi_key> <C> <equal>			: "\244"	EuroSign
 <Multi_key> <equal> <C>			: "\244"	EuroSign
+<Multi_key> <E> <equal>			: "\244"	EuroSign
+<Multi_key> <e> <equal>			: "\244"	EuroSign
 <Multi_key> <y> <minus>			: "\245"	yen
 <Multi_key> <minus> <y>			: "\245"	yen
 <Multi_key> <Y> <minus>			: "\245"	yen
@@ -88,6 +90,8 @@
 <Multi_key> <0> <c>			: "\251"	copyright
 <Multi_key> <C> <0>			: "\251"	copyright
 <Multi_key> <0> <C>			: "\251"	copyright
+<Multi_key> <parenleft> <c>		: "\251"	copyright
+<Multi_key> <parenleft> <C>		: "\251"	copyright
 <Multi_key> <a> <underscore>		: "\252"	ordfeminine
 <Multi_key> <underscore> <a>		: "\252"	ordfeminine
 <Multi_key> <A> <underscore>		: "\252"	ordfeminine
@@ -140,6 +144,7 @@
 <Multi_key> <minus> <minus>		: "\255"	hyphen
 <Multi_key> <R> <O>			: "\256"	registered
 <Multi_key> <O> <R>			: "\256"	registered
+<Multi_key> <parenleft> <r>		: "\256"	registered
 <Multi_key> <minus> <asciicircum>	: "\257"	macron
 <Multi_key> <asciicircum> <minus>	: "\257"	macron
 <Multi_key> <underscore> <asciicircum>	: "\257"	macron
@@ -172,6 +177,8 @@
 <Multi_key> <diaeresis> <A>		: "\304"	Adiaeresis
 <Multi_key> <A> <asterisk>		: "\305"	Aring
 <Multi_key> <asterisk> <A>		: "\305"	Aring
+<Multi_key> <A> <A>			: "\305"	Aring
+<Multi_key> <A> <O>			: "\305"	Aring
 <Multi_key> <A> <E>			: "\306"	AE
 <Multi_key> <a> <grave>			: "\340"	agrave
 <Multi_key> <grave> <a>			: "\340"	agrave
@@ -193,7 +200,11 @@
 <Multi_key> <diaeresis> <a>		: "\344"	adiaeresis
 <Multi_key> <a> <asterisk>		: "\345"	aring
 <Multi_key> <asterisk> <a>		: "\345"	aring
+<Multi_key> <a> <a>			: "\345"	aring
+<Multi_key> <a> <o>			: "\345"	aring
 <Multi_key> <a> <e>			: "\346"	ae
+<Multi_key> <acute> <C>			: "\307"	Ccedilla
+<Multi_key> <acute> <c>			: "\347"	ccedilla
 <Multi_key> <C> <comma>			: "\307"	Ccedilla
 <Multi_key> <comma> <C>			: "\307"	Ccedilla
 <Multi_key> <c> <comma>			: "\347"	ccedilla
@@ -386,11 +397,13 @@
 <dead_cedilla> <comma>			: "\270"	cedilla
 <dead_diaeresis> <quotedbl>		: "\250"	diaeresis
 # Accented Alphabet
+<dead_abovering> <A>			: "\305"	Aring
 <dead_grave> <A>			: "\300"	Agrave
 <dead_acute> <A>			: "\301"	Aacute
 <dead_circumflex> <A>			: "\302"	Acircumflex
 <dead_tilde> <A>			: "\303"	Atilde
 <dead_diaeresis> <A>			: "\304"	Adiaeresis
+<dead_abovering> <a>			: "\345"	aring
 <dead_grave> <a>			: "\340"	agrave
 <dead_acute> <a>			: "\341"	aacute
 <dead_circumflex> <a>			: "\342"	acircumflex
@@ -428,6 +441,8 @@
 <dead_diaeresis> <o>			: "\366"	odiaeresis
 <dead_caron> <S>			: "\246"	Scaron
 <dead_caron> <s>			: "\250"	scaron
+<dead_circumflex> <S>			: "\246"	Scaron
+<dead_circumflex> <s>			: "\250"	scaron
 <dead_grave> <U>			: "\331"	Ugrave
 <dead_acute> <U>			: "\332"	Uacute
 <dead_circumflex> <U>			: "\333"	Ucircumflex
@@ -442,4 +457,11 @@
 <dead_diaeresis> <y>			: "\377"	ydiaeresis
 <dead_caron> <Z>			: "\264"	Zcaron
 <dead_caron> <z>			: "\270"	zcaron
+<dead_circumflex> <Z>			: "\264"	Zcaron
+<dead_circumflex> <z>			: "\270"	zcaron
+# Useful for portuguese language
+<dead_acute> <C>			: "\307"	Ccedilla
+<dead_acute> <c>			: "\347"	ccedilla
+<dead_acute> <dead_acute>		: "'"		apostrophe
+<dead_grave> <dead_grave>		: "`"		grave
 # End of Sequence Definition
Index: xc/nls/Compose/iso8859-2
diff -u xc/nls/Compose/iso8859-2:1.1.1.2 xc/nls/Compose/iso8859-2:1.3
--- xc/nls/Compose/iso8859-2:1.1.1.2	Sun Sep 27 07:06:14 1998
+++ xc/nls/Compose/iso8859-2	Fri Oct 27 20:34:02 2000
@@ -2,6 +2,8 @@
 #
 # ISO 8859-2 (Latin2) Compose Sequence
 #
+# $XFree86: xc/nls/Compose/iso8859-2,v 1.3 2000/10/28 00:34:02 dawes Exp $
+#
 # Sequence Definition
 #
 # <Multi_key> Means <Compose>
@@ -447,4 +449,9 @@
 <dead_ogonek> <E>			: "\312"	Eogonek
 <dead_ogonek> <a>			: "\261"	aogonek
 <dead_ogonek> <e>			: "\352"	eogonek
+# those are for ease of use
+<dead_abovedot> <U>			: "\331"	Uring
+<dead_abovedot> <u>			: "\371"	uring
+<dead_caron> <U>			: "\331"	Uring
+<dead_caron> <u>			: "\371"	uring
 # End of Sequence Definition
Index: xc/nls/Compose/iso8859-4
diff -u xc/nls/Compose/iso8859-4:1.1 xc/nls/Compose/iso8859-4:1.2
--- xc/nls/Compose/iso8859-4:1.1	Sat Jan 10 22:48:18 1998
+++ xc/nls/Compose/iso8859-4	Fri Oct 27 14:30:51 2000
@@ -1,4 +1,4 @@
-# $XFree86: xc/nls/Compose/iso8859-4,v 1.1 1998/01/11 03:48:18 dawes Exp $
+# $XFree86: xc/nls/Compose/iso8859-4,v 1.2 2000/10/27 18:30:51 dawes Exp $
 #
 # ISO 8859-4 (Latin4) Compose Sequence
 #
@@ -341,8 +341,8 @@
 <dead_ogonek> <i>			: "\347"	iogonek
 <dead_ogonek> <e>			: "\352"	eogonek
 <dead_ogonek> <u>			: "\371"	uogonek
-<dead_ring> <ring>			: "\260"	ring
-<dead_ring> <dead_ring>			: "\260"	ring
+<dead_abovering> <ring>			: "\260"	ring
+<dead_abovering> <dead_abovering>	: "\260"	ring
 <dead_tilde> <I>			: "\245"	Itilde
 <dead_tilde> <i>			: "\265"	itilde
 <dead_tilde> <A>			: "\303"	Atilde
Index: xc/nls/Compose/iso8859-7
diff -u xc/nls/Compose/iso8859-7:1.1 xc/nls/Compose/iso8859-7:1.2
--- xc/nls/Compose/iso8859-7:1.1	Sat Aug 28 05:00:36 1999
+++ xc/nls/Compose/iso8859-7	Fri Oct 27 14:30:51 2000
@@ -1,15 +1,247 @@
+# $TOG: iso8859-7 /main/7 1998/05/20 15:33:23 kaleb $
 #
-# ISO 8859-7 Compose Sequence
+# ISO 8859-7 (Greek) Compose Sequence
 #
-# Sequence Definition
 #
-# $XFree86: xc/nls/Compose/iso8859-7,v 1.1 1999/08/28 09:00:36 dawes Exp $
+# $XFree86: xc/nls/Compose/iso8859-7,v 1.2 2000/10/27 18:30:51 dawes Exp $
 #
-# This file currently has no entries.  It appears that a compose file (even
-# just an empty one) is required for the appropriate keysyms to work for
-# this encoding.
+# Sequence Definition
 #
 # <Multi_key> Means <Compose>
 # Special Character
+<Multi_key> <plus> <plus>               : "#"   numbersign
+<Multi_key> <apostrophe> <space>	: "'"	apostrophe
+<Multi_key> <space> <apostrophe>	: "'"	apostrophe
+<Multi_key> <A> <T>			: "@"	at
+<Multi_key> <parenleft> <parenleft>	: "["	bracketleft
+<Multi_key> <slash> <slash>		: "\\"	backslash
+<Multi_key> <slash> <less>		: "\\"	backslash
+<Multi_key> <less> <slash>		: "\\"	backslash
+<Multi_key> <parenright> <parenright>	: "]"	bracketright
+<Multi_key> <asciicircum> <space>	: "^"	asciicircum
+<Multi_key> <space> <asciicircum>	: "^"	asciicircum
+<Multi_key> <greater> <space>		: "^"	asciicircum
+<Multi_key> <space> <greater>		: "^"	asciicircum
+<Multi_key> <grave> <space>		: "`"	grave
+<Multi_key> <space> <grave>		: "`"	grave
+<Multi_key> <parenleft> <minus>		: "{"	braceleft
+<Multi_key> <minus> <parenleft>		: "{"	braceleft
+<Multi_key> <slash> <asciicircum>	: "|"	bar
+<Multi_key> <asciicircum> <slash>	: "|"	bar
+<Multi_key> <V> <L>			: "|"	bar
+<Multi_key> <L> <V>			: "|"	bar
+<Multi_key> <v> <l>			: "|"	bar
+<Multi_key> <l> <v>			: "|"	bar
+<Multi_key> <parenright> <minus>	: "}"	braceright
+<Multi_key> <minus> <parenright>	: "}"	braceright
+<Multi_key> <asciitilde> <space>	: "~"	asciitilde
+<Multi_key> <space> <asciitilde>	: "~"	asciitilde
+<Multi_key> <minus> <space>		: "~"	asciitilde
+<Multi_key> <space> <minus>		: "~"	asciitilde
+
+<Multi_key> <l> <minus>			: "\243"	sterling
+<Multi_key> <minus> <l>			: "\243"	sterling
+<Multi_key> <L> <minus>			: "\243"	sterling
+<Multi_key> <minus> <L>			: "\243"	sterling
+<Multi_key> <l> <equal>			: "\243"	sterling
+<Multi_key> <equal> <l>			: "\243"	sterling
+<Multi_key> <L> <equal>			: "\243"	sterling
+<Multi_key> <equal> <L>			: "\243"	sterling
+<Multi_key> <y> <minus>			: "\245"	yen
+<Multi_key> <minus> <y>			: "\245"	yen
+<Multi_key> <Y> <minus>			: "\245"	yen
+<Multi_key> <minus> <Y>			: "\245"	yen
+<Multi_key> <y> <equal>			: "\245"	yen
+<Multi_key> <equal> <y>			: "\245"	yen
+<Multi_key> <Y> <equal>			: "\245"	yen
+<Multi_key> <equal> <Y>			: "\245"	yen
+<Multi_key> <s> <o>			: "\247"	section
+<Multi_key> <o> <s>			: "\247"	section
+<Multi_key> <S> <O>			: "\247"	section
+<Multi_key> <O> <S>			: "\247"	section
+<Multi_key> <S> <exclam>		: "\247"	section
+<Multi_key> <exclam> <S>		: "\247"	section
+<Multi_key> <s> <exclam>		: "\247"	section
+<Multi_key> <exclam> <s>		: "\247"	section
+<Multi_key> <S> <0>			: "\247"	section
+<Multi_key> <0> <S>			: "\247"	section
+<Multi_key> <s> <0>			: "\247"	section
+<Multi_key> <0> <s>			: "\247"	section
+<Multi_key> <x> <o>			: "\244"	currency
+<Multi_key> <o> <x>			: "\244"	currency
+<Multi_key> <X> <O>			: "\244"	currency
+<Multi_key> <O> <X>			: "\244"	currency
+<Multi_key> <x> <O>			: "\244"	currency
+<Multi_key> <O> <x>			: "\244"	currency
+<Multi_key> <X> <o>			: "\244"	currency
+<Multi_key> <o> <X>			: "\244"	currency
+<Multi_key> <x> <0>			: "\244"	currency
+<Multi_key> <0> <x>			: "\244"	currency
+<Multi_key> <X> <0>			: "\244"	currency
+<Multi_key> <0> <X>			: "\244"	currency
+<Multi_key> <c> <o>			: "\251"	copyright
+<Multi_key> <o> <c>			: "\251"	copyright
+<Multi_key> <C> <O>			: "\251"	copyright
+<Multi_key> <O> <C>			: "\251"	copyright
+<Multi_key> <c> <O>			: "\251"	copyright
+<Multi_key> <O> <c>			: "\251"	copyright
+<Multi_key> <C> <o>			: "\251"	copyright
+<Multi_key> <o> <C>			: "\251"	copyright
+<Multi_key> <c> <0>			: "\251"	copyright
+<Multi_key> <0> <c>			: "\251"	copyright
+<Multi_key> <C> <0>			: "\251"	copyright
+<Multi_key> <0> <C>			: "\251"	copyright
+<Multi_key> <parenleft> <c>		: "\251"	copyright
+<Multi_key> <a> <underscore>		: "\252"	ordfeminine
+<Multi_key> <underscore> <a>		: "\252"	ordfeminine
+<Multi_key> <A> <underscore>		: "\252"	ordfeminine
+<Multi_key> <underscore> <A>		: "\252"	ordfeminine
+<Multi_key> <less> <less>		: "\253"	guillemotleft
+<Multi_key> <greater> <greater>		: "\273"	guillemotright
+<Multi_key> <0> <asciicircum>		: "\260"	degree
+<Multi_key> <asciicircum> <0>		: "\260"	degree
+<Multi_key> <0> <asterisk>		: "\260"	degree
+<Multi_key> <asterisk> <0>		: "\260"	degree
+<Multi_key> <plus> <minus>		: "\261"	plusminus
+<Multi_key> <minus> <plus>		: "\261"	plusminus
+<Multi_key> <2> <asciicircum>		: "\262"	twosuperior
+<Multi_key> <asciicircum> <2>		: "\262"	twosuperior
+<Multi_key> <S> <2>			: "\262"	twosuperior
+<Multi_key> <2> <S>			: "\262"	twosuperior
+<Multi_key> <s> <2>			: "\262"	twosuperior
+<Multi_key> <2> <s>			: "\262"	twosuperior
+<Multi_key> <3> <asciicircum>		: "\263"	threesuperior
+<Multi_key> <asciicircum> <3>		: "\263"	threesuperior
+<Multi_key> <S> <3>			: "\263"	threesuperior
+<Multi_key> <3> <S>			: "\263"	threesuperior
+<Multi_key> <s> <3>			: "\263"	threesuperior
+<Multi_key> <3> <s>			: "\263"	threesuperior
+<Multi_key> <period> <asciicircum>	: "\267"	periodcentered
+<Multi_key> <asciicircum> <period>	: "\267"	periodcentered
+<Multi_key> <period> <period>		: "\267"	periodcentered
+<Multi_key> <1> <2>			: "\275"	onehalf
+<Multi_key> <space> <space>		: "\240"	nobreakspace
+<Multi_key> <bar> <bar>			: "\246"	brokenbar
+<Multi_key> <exclam> <asciicircum>	: "\246"	brokenbar
+<Multi_key> <asciicircum> <exclam>	: "\246"	brokenbar
+<Multi_key> <V> <B>			: "\246"	brokenbar
+<Multi_key> <B> <V>			: "\246"	brokenbar
+<Multi_key> <v> <b>			: "\246"	brokenbar
+<Multi_key> <b> <v>			: "\246"	brokenbar
+<Multi_key> <minus> <comma>		: "\254"	notsign
+<Multi_key> <comma> <minus>		: "\254"	notsign
+<Multi_key> <minus> <minus>		: "\255"	hyphen
+<Multi_key> <minus> <asciicircum>	: "\257"	macron
+<Multi_key> <asciicircum> <minus>	: "\257"	macron
+<Multi_key> <underscore> <asciicircum>	: "\257"	macron
+<Multi_key> <asciicircum> <underscore>	: "\257"	macron
+<Multi_key> <underscore> <underscore>	: "\257"	macron
+# should be Greek tonos but not defined in X11
+<Multi_key> <apostrophe> <apostrophe>	: "\264"	acute
+# should be Greek dialitika but not defined in X11
+<Multi_key> <quotedbl> <quotedbl>	: "\250"	diaeresis
+
+# Accented Alphabet
+<Multi_key> <Greek_ALPHA> <apostrophe>	: "\266" Greek_ALPHAaccent
+<Multi_key> <apostrophe> <Greek_ALPHA>	: "\266" Greek_ALPHAaccent
+<Multi_key> <Greek_EPSILON> <apostrophe>: "\270" Greek_EPSILONaccent
+<Multi_key> <apostrophe> <Greek_EPSILON>: "\270" Greek_EPSILONaccent
+<Multi_key> <Greek_ETA> <apostrophe>	: "\271" Greek_ETAaccent
+<Multi_key> <apostrophe> <Greek_ETA>	: "\271" Greek_ETAaccent
+<Multi_key> <Greek_IOTA> <apostrophe>	: "\272" Greek_IOTAaccent
+<Multi_key> <apostrophe> <Greek_IOTA>	: "\272" Greek_IOTAaccent
+<Multi_key> <Greek_OMICRON> <apostrophe>: "\274" Greek_OMICRONaccent
+<Multi_key> <apostrophe> <Greek_OMICRON>: "\274" Greek_OMICRONaccent
+<Multi_key> <Greek_UPSILON> <apostrophe>: "\276" Greek_UPSILONaccent
+<Multi_key> <apostrophe> <Greek_UPSILON>: "\276" Greek_UPSILONaccent
+<Multi_key> <Greek_OMEGA> <apostrophe>	: "\277" Greek_OMEGAaccent
+<Multi_key> <apostrophe> <Greek_OMEGA>	: "\277" Greek_OMEGAaccent
+<Multi_key> <Greek_IOTA> <quotedbl>	: "\332" Greek_IOTAdiaeresis
+<Multi_key> <quotedbl> <Greek_IOTA>	: "\332" Greek_IOTAdiaeresis
+<Multi_key> <Greek_IOTA> <quotedbl>	: "\332" Greek_IOTAdieresis
+<Multi_key> <quotedbl> <Greek_IOTA>	: "\332" Greek_IOTAdieresis
+<Multi_key> <Greek_UPSILON> <quotedbl>	: "\333" Greek_UPSILONdieresis
+<Multi_key> <quotedbl> <Greek_UPSILON>	: "\333" Greek_UPSILONdieresis
+
+<Multi_key> <Greek_alpha> <apostrophe>	: "\334" Greek_alphaaccent
+<Multi_key> <apostrophe> <Greek_alpha>	: "\334" Greek_alphaaccent
+<Multi_key> <Greek_epsilon> <apostrophe>: "\335" Greek_epsilonaccent
+<Multi_key> <apostrophe> <Greek_epsilon>: "\335" Greek_epsilonaccent
+<Multi_key> <Greek_eta> <apostrophe>	: "\336" Greek_etaaccent
+<Multi_key> <apostrophe> <Greek_eta>	: "\336" Greek_etaaccent
+<Multi_key> <Greek_iota> <apostrophe>	: "\337" Greek_iotaaccent
+<Multi_key> <apostrophe> <Greek_iota>	: "\337" Greek_iotaaccent
+<Multi_key> <Greek_omicron> <apostrophe>: "\374" Greek_omicronaccent
+<Multi_key> <apostrophe> <Greek_omicron>: "\374" Greek_omicronaccent
+<Multi_key> <Greek_upsilon> <apostrophe>: "\375" Greek_upsilonaccent
+<Multi_key> <apostrophe> <Greek_upsilon>: "\375" Greek_upsilonaccent
+<Multi_key> <Greek_omega> <apostrophe>	: "\376" Greek_omegaaccent
+<Multi_key> <apostrophe> <Greek_omega>	: "\376" Greek_omegaaccent
+<Multi_key> <Greek_iota> <quotedbl>	: "\372" Greek_iotadieresis
+<Multi_key> <quotedbl> <Greek_iota>	: "\372" Greek_iotadieresis
+<Multi_key> <Greek_upsilon> <quotedbl>	: "\373" Greek_upsilondieresis
+<Multi_key> <quotedbl> <Greek_upsilon>	: "\373" Greek_upsilondieresis
+
+<Multi_key> <Greek_iota> <asciicircum>	: "\300" Greek_iotaaccentdieresis
+<Multi_key> <asciicircum> <Greek_iota>	: "\300" Greek_iotaaccentdieresis
+<Multi_key> <Greek_upsilon> <asciicircum>: "\340" Greek_upsilonaccentdieresis
+<Multi_key> <asciicircum> <Greek_upsilon>: "\340" Greek_upsilonaccentdieresis
+
+#
+#
+# dead key accent keysyms
+# Special Character
+<dead_circumflex>  <slash>		: "|"	bar
+<dead_grave> <space>			: "`"	grave
+<dead_acute> <space>			: "'"	apostrophe
+<dead_diaeresis> <space>		: "\250"	diaeresis
+<dead_circumflex> <space>		: "^"	asciicircum
+<dead_tilde> <space>			: "~"	asciitilde
+<dead_grave> <space>			: "`"	grave
+<dead_acute> <space>			: "'"	apostrophe
+<dead_doubleacute> <space>		: "\""	quotedbl
+<dead_abovering> <space>		: "\260"	degree
+<dead_abovering> <dead_abovering>	: "\260"	degree
+<dead_circumflex> <0>			: "\260"	degree
+<dead_circumflex> <1>			: "\271"	onesuperior
+<dead_circumflex> <2>			: "\262"	twosuperior
+<dead_circumflex> <3>			: "\263"	threesuperior
+<dead_circumflex> <period>		: "\267"	periodcentered
+<dead_circumflex> <exclam>		: "\246"	brokenbar
+<dead_cedilla> <minus>			: "\254"	notsign
+<dead_circumflex> <minus>		: "\257"	macron
+<dead_circumflex> <underscore>		: "\257"	macron
+<dead_acute> <apostrophe>		: "\264"	acute
+<dead_diaeresis> <quotedbl>		: "\250"	diaeresis
+
+# Accented Alphabet
+<dead_acute> <Greek_ALPHA>		: "\266" Greek_ALPHAaccent
+<dead_acute> <Greek_EPSILON>		: "\270" Greek_EPSILONaccent
+<dead_acute> <Greek_ETA>		: "\271" Greek_ETAaccent
+<dead_acute> <Greek_IOTA>		: "\272" Greek_IOTAaccent
+<dead_acute> <Greek_OMICRON>		: "\274" Greek_OMICRONaccent
+<dead_acute> <Greek_UPSILON>		: "\276" Greek_UPSILONaccent
+<dead_acute> <Greek_OMEGA>		: "\277" Greek_OMEGAaccent
+<dead_diaeresis> <Greek_IOTA>		: "\332" Greek_IOTAdiaeresis
+<dead_diaeresis> <Greek_IOTA>		: "\332" Greek_IOTAdieresis
+<dead_diaeresis> <Greek_UPSILON>	: "\333" Greek_UPSILONdieresis
+
+<dead_acute> <Greek_alpha>		: "\334" Greek_alphaaccent
+<dead_acute> <Greek_epsilon>		: "\335" Greek_epsilonaccent
+<dead_acute> <Greek_eta>		: "\336" Greek_etaaccent
+<dead_acute> <Greek_iota>		: "\337" Greek_iotaaccent
+<dead_acute> <Greek_omicron>		: "\374" Greek_omicronaccent
+<dead_acute> <Greek_upsilon>		: "\375" Greek_upsilonaccent
+<dead_acute> <Greek_omega>		: "\376" Greek_omegaaccent
+<dead_diaeresis> <Greek_iota>		: "\372" Greek_iotadieresis
+<dead_diaeresis> <Greek_upsilon>	: "\373" Greek_upsilondieresis
+
+<dead_circumflex> <Greek_iota>		: "\300" Greek_iotaaccentdieresis
+<dead_circumflex> <Greek_upsilon>	: "\340" Greek_upsilonaccentdieresis
+
+<dead_acute> <dead_diaeresis> <Greek_iota>	: "\300" Greek_iotaaccentdieresis
+<dead_acute> <dead_diaeresis> <Greek_upsilon>	: "\340" Greek_upsilonaccentdieresis
+
+<dead_acute> <Greek_sigma>		: "\362" Greek_finalsmallsigma
+<dead_diaeresis> <Greek_sigma>		: "\362" Greek_finalsmallsigma
 
-# End of Sequence Definition
Index: xc/nls/Compose/iso8859-9e
diff -u /dev/null xc/nls/Compose/iso8859-9e:1.1
--- /dev/null	Mon Dec 18 14:26:53 2000
+++ xc/nls/Compose/iso8859-9e	Fri Oct 27 14:30:51 2000
@@ -0,0 +1,489 @@
+#
+# ISO 8859-9e (Latin??) Compose Sequence
+#
+# Sequence Definition
+#
+# $XFree86: xc/nls/Compose/iso8859-9e,v 1.1 2000/10/27 18:30:51 dawes Exp $
+#
+# <Multi_key> Means <Compose>
+# Special Character
+<Multi_key> <plus> <plus>		: "#"	numbersign
+<Multi_key> <apostrophe> <space>	: "'"	apostrophe
+<Multi_key> <space> <apostrophe>	: "'"	apostrophe
+<Multi_key> <A> <A>			: "@"	at
+<Multi_key> <parenleft> <parenleft>	: "["	bracketleft
+<Multi_key> <slash> <slash>		: "\\"	backslash
+<Multi_key> <slash> <less>		: "\\"	backslash
+<Multi_key> <less> <slash>		: "\\"	backslash
+<Multi_key> <parenright> <parenright>	: "]"	bracketright
+<Multi_key> <asciicircum> <space>	: "^"	asciicircum
+<Multi_key> <space> <asciicircum>	: "^"	asciicircum
+<Multi_key> <greater> <space>		: "^"	asciicirum
+<Multi_key> <space> <greater>		: "^"	asciicirum
+<Multi_key> <grave> <space>		: "`"	grave
+<Multi_key> <space> <grave>		: "`"	grave
+<Multi_key> <parenleft> <minus>		: "{"	braceleft
+<Multi_key> <minus> <parenleft>		: "{"	braceleft
+<Multi_key> <slash> <asciicircum>	: "|"	bar
+<Multi_key> <asciicircum> <slash>	: "|"	bar
+<Multi_key> <V> <L>			: "|"	bar
+<Multi_key> <L> <V>			: "|"	bar
+<Multi_key> <v> <l>			: "|"	bar
+<Multi_key> <l> <v>			: "|"	bar
+<Multi_key> <parenright> <minus>	: "}"	braceright
+<Multi_key> <minus> <parenright>	: "}"	braceright
+<Multi_key> <asciitilde> <space>	: "~"	asciitilde
+<Multi_key> <space> <asciitilde>	: "~"	asciitilde
+<Multi_key> <minus> <space>		: "~"	asciitilde
+<Multi_key> <space> <minus>		: "~"	asciitilde
+<Multi_key> <exclam> <exclam>		: "\241"	exclamdown
+<Multi_key> <c> <slash>			: "\242"	cent
+<Multi_key> <slash> <c>			: "\242"	cent
+<Multi_key> <C> <slash>			: "\242"	cent
+<Multi_key> <slash> <C>			: "\242"	cent
+<Multi_key> <C> <bar>			: "\242"	cent
+<Multi_key> <bar> <C>			: "\242"	cent
+<Multi_key> <c> <bar>			: "\242"	cent
+<Multi_key> <bar> <c>			: "\242"	cent
+<Multi_key> <l> <minus>			: "\243"	sterling
+<Multi_key> <minus> <l>			: "\243"	sterling
+<Multi_key> <L> <minus>			: "\243"	sterling
+<Multi_key> <minus> <L>			: "\243"	sterling
+<Multi_key> <l> <equal>			: "\243"	sterling
+<Multi_key> <equal> <l>			: "\243"	sterling
+<Multi_key> <L> <equal>			: "\243"	sterling
+<Multi_key> <equal> <L>			: "\243"	sterling
+<Multi_key> <C> <equal>			: "\244"	EuroSign
+<Multi_key> <equal> <C>			: "\244"	EuroSign
+<Multi_key> <e> <equal>                 : "\244"        EuroSign
+<Multi_key> <equal> <e>                 : "\244"        EuroSign
+<Multi_key> <y> <minus>			: "\245"	yen
+<Multi_key> <minus> <y>			: "\245"	yen
+<Multi_key> <Y> <minus>			: "\245"	yen
+<Multi_key> <minus> <Y>			: "\245"	yen
+<Multi_key> <y> <equal>			: "\245"	yen
+<Multi_key> <equal> <y>			: "\245"	yen
+<Multi_key> <Y> <equal>			: "\245"	yen
+<Multi_key> <equal> <Y>			: "\245"	yen
+<Multi_key> <s> <o>			: "\247"	section
+<Multi_key> <o> <s>			: "\247"	section
+<Multi_key> <S> <O>			: "\247"	section
+<Multi_key> <O> <S>			: "\247"	section
+<Multi_key> <S> <exclam>		: "\247"	section
+<Multi_key> <exclam> <S>		: "\247"	section
+<Multi_key> <s> <exclam>		: "\247"	section
+<Multi_key> <exclam> <s>		: "\247"	section
+<Multi_key> <S> <0>			: "\247"	section
+<Multi_key> <0> <S>			: "\247"	section
+<Multi_key> <s> <0>			: "\247"	section
+<Multi_key> <0> <s>			: "\247"	section
+<Multi_key> <c> <o>			: "\251"	copyright
+<Multi_key> <o> <c>			: "\251"	copyright
+<Multi_key> <C> <O>			: "\251"	copyright
+<Multi_key> <O> <C>			: "\251"	copyright
+<Multi_key> <c> <O>			: "\251"	copyright
+<Multi_key> <O> <c>			: "\251"	copyright
+<Multi_key> <C> <o>			: "\251"	copyright
+<Multi_key> <o> <C>			: "\251"	copyright
+<Multi_key> <c> <0>			: "\251"	copyright
+<Multi_key> <0> <c>			: "\251"	copyright
+<Multi_key> <C> <0>			: "\251"	copyright
+<Multi_key> <0> <C>			: "\251"	copyright
+<Multi_key> <parenleft> <c>             : "\251"        copyright
+<Multi_key> <a> <underscore>		: "\252"	ordfeminine
+<Multi_key> <underscore> <a>		: "\252"	ordfeminine
+<Multi_key> <A> <underscore>		: "\252"	ordfeminine
+<Multi_key> <underscore> <A>		: "\252"	ordfeminine
+<Multi_key> <o> <underscore>		: "\272"	masculine
+<Multi_key> <underscore> <o>		: "\272"	masculine
+<Multi_key> <O> <underscore>		: "\272"	masculine
+<Multi_key> <underscore> <O>		: "\272"	masculine
+<Multi_key> <less> <less>		: "\253"	guillemotleft
+<Multi_key> <greater> <greater>		: "\273"	guillemotright
+<Multi_key> <0> <asciicircum>		: "\260"	degree
+<Multi_key> <asciicircum> <0>		: "\260"	degree
+<Multi_key> <0> <asterisk>		: "\260"	degree
+<Multi_key> <asterisk> <0>		: "\260"	degree
+<Multi_key> <plus> <minus>		: "\261"	plusminus
+<Multi_key> <minus> <plus>		: "\261"	plusminus
+<Multi_key> <slash> <u>			: "\265"	mu
+<Multi_key> <u> <slash>			: "\265"	mu
+<Multi_key> <slash> <U>			: "\265"	mu
+<Multi_key> <U> <slash>			: "\265"	mu
+<Multi_key> <1> <asciicircum>		: "\271"	onesuperior
+<Multi_key> <asciicircum> <1>		: "\271"	onesuperior
+<Multi_key> <S> <1>			: "\271"	onesuperior
+<Multi_key> <1> <S>			: "\271"	onesuperior
+<Multi_key> <s> <1>			: "\271"	onesuperior
+<Multi_key> <1> <s>			: "\271"	onesuperior
+<Multi_key> <2> <asciicircum>		: "\262"	twosuperior
+<Multi_key> <asciicircum> <2>		: "\262"	twosuperior
+<Multi_key> <S> <2>			: "\262"	twosuperior
+<Multi_key> <2> <S>			: "\262"	twosuperior
+<Multi_key> <s> <2>			: "\262"	twosuperior
+<Multi_key> <2> <s>			: "\262"	twosuperior
+<Multi_key> <3> <asciicircum>		: "\263"	threesuperior
+<Multi_key> <asciicircum> <3>		: "\263"	threesuperior
+<Multi_key> <S> <3>			: "\263"	threesuperior
+<Multi_key> <3> <S>			: "\263"	threesuperior
+<Multi_key> <s> <3>			: "\263"	threesuperior
+<Multi_key> <3> <s>			: "\263"	threesuperior
+<Multi_key> <p> <exclam>		: "\266"	paragraph
+<Multi_key> <exclam> <p>		: "\266"	paragraph
+<Multi_key> <P> <exclam>		: "\266"	paragraph
+<Multi_key> <exclam> <P>		: "\266"	paragraph
+<Multi_key> <period> <asciicircum>	: "\267"	periodcentered
+<Multi_key> <asciicircum> <period>	: "\267"	periodcentered
+<Multi_key> <period> <period>		: "\267"	periodcentered
+<Multi_key> <question> <question>	: "\277"	questiondown
+<Multi_key> <space> <space>		: "\240"	nobreakspace
+<Multi_key> <minus> <comma>		: "\254"	notsign
+<Multi_key> <comma> <minus>		: "\254"	notsign
+<Multi_key> <minus> <minus>		: "\255"	hyphen
+<Multi_key> <R> <O>			: "\256"	registered
+<Multi_key> <O> <R>			: "\256"	registered
+<Multi_key> <parenleft> <r>             : "\256"        registered
+<Multi_key> <minus> <asciicircum>	: "\257"	macron
+<Multi_key> <asciicircum> <minus>	: "\257"	macron
+<Multi_key> <underscore> <asciicircum>	: "\257"	macron
+<Multi_key> <asciicircum> <underscore>	: "\257"	macron
+<Multi_key> <underscore> <underscore>	: "\257"	macron
+<Multi_key> <minus> <colon>		: "\367"	division
+<Multi_key> <colon> <minus>		: "\367"	division
+<Multi_key> <x> <x>			: "\327"	multiply
+<Multi_key> <apostrophe> <apostrophe>	: "\264"	acute
+<Multi_key> <comma> <comma>		: "\270"	cedilla
+<Multi_key> <quotedbl> <quotedbl>	: "\250"	diaeresis
+# Accented Alphabet
+<Multi_key> <A> <grave>			: "\300"	Agrave
+<Multi_key> <grave> <A>			: "\300"	Agrave
+<Multi_key> <A> <acute>			: "\301"	Aacute
+<Multi_key> <acute> <A>			: "\301"	Aacute
+<Multi_key> <A> <apostrophe>		: "\301"	Aacute
+<Multi_key> <apostrophe> <A>		: "\301"	Aacute
+<Multi_key> <A> <asciicircum>		: "\302"	Acircumflex
+<Multi_key> <asciicircum> <A>		: "\302"	Acircumflex
+<Multi_key> <A> <greater>		: "\302"	Acircumflex
+<Multi_key> <greater> <A>		: "\302"	Acircumflex
+<Multi_key> <A> <asciitilde>		: "\303"	Atilde
+<Multi_key> <asciitilde> <A>		: "\303"	Atilde
+<Multi_key> <A> <minus>			: "\303"	Atilde
+<Multi_key> <minus> <A>			: "\303"	Atilde
+<Multi_key> <A> <quotedbl>		: "\304"	Adiaeresis
+<Multi_key> <quotedbl> <A>		: "\304"	Adiaeresis
+<Multi_key> <A> <diaeresis>		: "\304"	Adiaeresis
+<Multi_key> <diaeresis> <A>		: "\304"	Adiaeresis
+<Multi_key> <A> <asterisk>		: "\305"	Aring
+<Multi_key> <asterisk> <A>		: "\305"	Aring
+<Multi_key> <A> <A>			: "\305"        Aring
+<Multi_key> <E> <E>			: "\306"	SCHWA
+<Multi_key> <a> <grave>			: "\340"	agrave
+<Multi_key> <grave> <a>			: "\340"	agrave
+<Multi_key> <a> <acute>			: "\341"	aacute
+<Multi_key> <acute> <a>			: "\341"	aacute
+<Multi_key> <a> <apostrophe>		: "\341"	aacute
+<Multi_key> <apostrophe> <a>		: "\341"	aacute
+<Multi_key> <a> <asciicircum>		: "\342"	acircumflex
+<Multi_key> <asciicircum> <a>		: "\342"	acircumflex
+<Multi_key> <a> <greater>		: "\342"	acircumflex
+<Multi_key> <greater> <a>		: "\342"	acircumflex
+<Multi_key> <a> <asciitilde>		: "\343"	atilde
+<Multi_key> <asciitilde> <a>		: "\343"	atilde
+<Multi_key> <a> <minus>			: "\343"	atilde
+<Multi_key> <minus> <a>			: "\343"	atilde
+<Multi_key> <a> <quotedbl>		: "\344"	adiaeresis
+<Multi_key> <quotedbl> <a>		: "\344"	adiaeresis
+<Multi_key> <a> <diaeresis>		: "\344"	adiaeresis
+<Multi_key> <diaeresis> <a>		: "\344"	adiaeresis
+<Multi_key> <a> <asterisk>		: "\345"	aring
+<Multi_key> <asterisk> <a>		: "\345"	aring
+<Multi_key> <a> <a>			: "\345"        aring
+<Multi_key> <e> <e>			: "\346"	schwa
+<Multi_key> <C> <comma>			: "\307"	Ccedilla
+<Multi_key> <comma> <C>			: "\307"	Ccedilla
+<Multi_key> <c> <comma>			: "\347"	ccedilla
+<Multi_key> <comma> <c>			: "\347"	ccedilla
+<Multi_key> <minus> <D>			: "\320"	ETH
+<Multi_key> <D> <minus>			: "\320"	ETH
+<Multi_key> <minus> <d>			: "\360"	eth
+<Multi_key> <d> <minus>			: "\360"	eth
+<Multi_key> <E> <grave>			: "\310"	Egrave
+<Multi_key> <grave> <E>			: "\310"	Egrave
+<Multi_key> <E> <acute>			: "\311"	Eacute
+<Multi_key> <acute> <E>			: "\311"	Eacute
+<Multi_key> <E> <apostrophe>		: "\311"	Eacute
+<Multi_key> <apostrophe> <E>		: "\311"	Eacute
+<Multi_key> <E> <asciicircum>		: "\312"	Ecircumflex
+<Multi_key> <asciicircum> <E>		: "\312"	Ecircumflex
+<Multi_key> <E> <greater>		: "\312"	Ecircumflex
+<Multi_key> <greater> <E>		: "\312"	Ecircumflex
+<Multi_key> <E> <quotedbl>		: "\313"	Ediaeresis
+<Multi_key> <quotedbl> <E>		: "\313"	Ediaeresis
+<Multi_key> <E> <diaeresis>		: "\313"	Ediaeresis
+<Multi_key> <diaeresis> <E>		: "\313"	Ediaeresis
+<Multi_key> <e> <grave>			: "\350"	egrave
+<Multi_key> <grave> <e>			: "\350"	egrave
+<Multi_key> <e> <acute>			: "\351"	eacute
+<Multi_key> <acute> <e>			: "\351"	eacute
+<Multi_key> <e> <apostrophe>		: "\351"	eacute
+<Multi_key> <apostrophe> <e>		: "\351"	eacute
+<Multi_key> <e> <asciicircum>		: "\352"	ecircumflex
+<Multi_key> <asciicircum> <e>		: "\352"	ecircumflex
+<Multi_key> <e> <greater>		: "\352"	ecircumflex
+<Multi_key> <greater> <e>		: "\352"	ecircumflex
+<Multi_key> <e> <quotedbl>		: "\353"	ediaeresis
+<Multi_key> <quotedbl> <e>		: "\353"	ediaeresis
+<Multi_key> <e> <diaeresis>		: "\353"	ediaeresis
+<Multi_key> <diaeresis> <e>		: "\353"	ediaeresis
+<Multi_key> <G> <U>                     : "\320"        Gbreve
+<Multi_key> <G> <parenleft>             : "\320"        Gbreve
+<Multi_key> <parenleft> <G>             : "\320"        Gbreve
+<Multi_key> <G> <breve>                 : "\320"        Gbreve
+<Multi_key> <breve> <G>                 : "\320"        Gbreve
+<Multi_key> <g> <U>                     : "\360"        gbreve
+<Multi_key> <g> <parenleft>             : "\360"        gbreve
+<Multi_key> <parenleft> <g>             : "\360"        gbreve
+<Multi_key> <g> <breve>                 : "\360"        gbreve
+<Multi_key> <breve> <g>                 : "\360"        gbreve
+<Multi_key> <I> <grave>			: "\314"	Igrave
+<Multi_key> <grave> <I>			: "\314"	Igrave
+<Multi_key> <I> <acute>			: "\315"	Iacute
+<Multi_key> <acute> <I>			: "\315"	Iacute
+<Multi_key> <I> <apostrophe>		: "\315"	Iacute
+<Multi_key> <apostrophe> <I>		: "\315"	Iacute
+<Multi_key> <I> <asciicircum>		: "\316"	Icircumflex
+<Multi_key> <asciicircum> <I>		: "\316"	Icircumflex
+<Multi_key> <I> <greater>		: "\316"	Icircumflex
+<Multi_key> <greater> <I>		: "\316"	Icircumflex
+<Multi_key> <I> <quotedbl>		: "\317"	Idiaeresis
+<Multi_key> <quotedbl> <I>		: "\317"	Idiaeresis
+<Multi_key> <I> <diaeresis>		: "\317"	Idiaeresis
+<Multi_key> <diaeresis> <I>		: "\317"	Idiaeresis
+<Multi_key> <I> <period>                : "\335"        Iabovedot
+<Multi_key> <period> <I>                : "\335"        Iabovedot
+<Multi_key> <i> <grave>			: "\354"	igrave
+<Multi_key> <grave> <i>			: "\354"	igrave
+<Multi_key> <i> <acute>			: "\355"	iacute
+<Multi_key> <acute> <i>			: "\355"	iacute
+<Multi_key> <i> <apostrophe>		: "\355"	iacute
+<Multi_key> <apostrophe> <i>		: "\355"	iacute
+<Multi_key> <i> <asciicircum>		: "\356"	icircumflex
+<Multi_key> <asciicircum> <i>		: "\356"	icircumflex
+<Multi_key> <i> <greater>		: "\356"	icircumflex
+<Multi_key> <greater> <i>		: "\356"	icircumflex
+<Multi_key> <i> <quotedbl>		: "\357"	idiaeresis
+<Multi_key> <quotedbl> <i>		: "\357"	idiaeresis
+<Multi_key> <i> <diaeresis>		: "\357"	idiaeresis
+<Multi_key> <diaeresis> <i>		: "\357"	idiaeresis
+<Multi_key> <i> <period>                : "\375"        idotless
+<Multi_key> <period> <i>                : "\375"        idotless
+<Multi_key> <N> <asciitilde>		: "\321"	Ntilde
+<Multi_key> <asciitilde> <N>		: "\321"	Ntilde
+<Multi_key> <N> <minus>			: "\321"	Ntilde
+<Multi_key> <minus> <N>			: "\321"	Ntilde
+<Multi_key> <n> <asciitilde>		: "\361"	ntilde
+<Multi_key> <asciitilde> <n>		: "\361"	ntilde
+<Multi_key> <n> <minus>			: "\361"	ntilde
+<Multi_key> <minus> <n>			: "\361"	ntilde
+<Multi_key> <O> <grave>			: "\322"	Ograve
+<Multi_key> <grave> <O>			: "\322"	Ograve
+<Multi_key> <O> <acute>			: "\323"	Oacute
+<Multi_key> <acute> <O>			: "\323"	Oacute
+<Multi_key> <O> <apostrophe>		: "\323"	Oacute
+<Multi_key> <apostrophe> <O>		: "\323"	Oacute
+<Multi_key> <O> <asciicircum>		: "\324"	Ocircumflex
+<Multi_key> <asciicircum> <O>		: "\324"	Ocircumflex
+<Multi_key> <O> <greater>		: "\324"	Ocircumflex
+<Multi_key> <greater> <O>		: "\324"	Ocircumflex
+<Multi_key> <O> <asciitilde>		: "\325"	Otilde
+<Multi_key> <asciitilde> <O>		: "\325"	Otilde
+<Multi_key> <O> <minus>			: "\325"	Otilde
+<Multi_key> <minus> <O>			: "\325"	Otilde
+<Multi_key> <O> <quotedbl>		: "\326"	Odiaeresis
+<Multi_key> <quotedbl> <O>		: "\326"	Odiaeresis
+<Multi_key> <O> <diaeresis>		: "\326"	Odiaeresis
+<Multi_key> <diaeresis> <O>		: "\326"	Odiaeresis
+<Multi_key> <O> <slash>			: "\330"	Ooblique
+<Multi_key> <slash> <O>			: "\330"	Ooblique
+<Multi_key> <O> <E>			: "\274"	OE
+<Multi_key> <o> <grave>			: "\362"	ograve
+<Multi_key> <grave> <o>			: "\362"	ograve
+<Multi_key> <o> <acute>			: "\363"	oacute
+<Multi_key> <acute> <o>			: "\363"	oacute
+<Multi_key> <o> <apostrophe>		: "\363"	oacute
+<Multi_key> <apostrophe> <o>		: "\363"	oacute
+<Multi_key> <o> <asciicircum>		: "\364"	ocircumflex
+<Multi_key> <asciicircum> <o>		: "\364"	ocircumflex
+<Multi_key> <o> <greater>		: "\364"	ocircumflex
+<Multi_key> <greater> <o>		: "\364"	ocircumflex
+<Multi_key> <o> <asciitilde>		: "\365"	otilde
+<Multi_key> <asciitilde> <o>		: "\365"	otilde
+<Multi_key> <o> <minus>			: "\365"	otilde
+<Multi_key> <minus> <o>			: "\365"	otilde
+<Multi_key> <o> <quotedbl>		: "\366"	odiaeresis
+<Multi_key> <quotedbl> <o>		: "\366"	odiaeresis
+<Multi_key> <o> <diaeresis>		: "\366"	odiaeresis
+<Multi_key> <diaeresis> <o>		: "\366"	odiaeresis
+<Multi_key> <o> <slash>			: "\370"	oslash
+<Multi_key> <slash> <o>			: "\370"	oslash
+<Multi_key> <S> <cedilla>               : "\336"        Scedilla
+<Multi_key> <S> <comma>                 : "\336"        Scedilla
+<Multi_key> <cedilla> <S>               : "\336"        Scedilla
+<Multi_key> <cedilla> <s>               : "\376"        scedilla
+<Multi_key> <comma> <S>                 : "\336"        Scedilla
+<Multi_key> <comma> <s>                 : "\376"        scedilla
+<Multi_key> <s> <cedilla>               : "\376"        scedilla
+<Multi_key> <s> <comma>                 : "\376"        scedilla
+<Multi_key> <U> <grave>			: "\331"	Ugrave
+<Multi_key> <grave> <U>			: "\331"	Ugrave
+<Multi_key> <U> <acute>			: "\332"	Uacute
+<Multi_key> <acute> <U>			: "\332"	Uacute
+<Multi_key> <U> <apostrophe>		: "\332"	Uacute
+<Multi_key> <apostrophe> <U>		: "\332"	Uacute
+<Multi_key> <U> <asciicircum>		: "\333"	Ucircumflex
+<Multi_key> <asciicircum> <U>		: "\333"	Ucircumflex
+<Multi_key> <U> <greater>		: "\333"	Ucircumflex
+<Multi_key> <greater> <U>		: "\333"	Ucircumflex
+<Multi_key> <U> <quotedbl>		: "\334"	Udiaeresis
+<Multi_key> <quotedbl> <U>		: "\334"	Udiaeresis
+<Multi_key> <U> <diaeresis>		: "\334"	Udiaeresis
+<Multi_key> <diaeresis> <U>		: "\334"	Udiaeresis
+<Multi_key> <u> <grave>			: "\371"	ugrave
+<Multi_key> <grave> <u>			: "\371"	ugrave
+<Multi_key> <u> <acute>			: "\372"	uacute
+<Multi_key> <acute> <u>			: "\372"	uacute
+<Multi_key> <u> <apostrophe>		: "\372"	uacute
+<Multi_key> <apostrophe> <u>		: "\372"	uacute
+<Multi_key> <u> <asciicircum>		: "\373"	ucircumflex
+<Multi_key> <asciicircum> <u>		: "\373"	ucircumflex
+<Multi_key> <u> <greater>		: "\373"	ucircumflex
+<Multi_key> <greater> <u>		: "\373"	ucircumflex
+<Multi_key> <u> <quotedbl>		: "\374"	udiaeresis
+<Multi_key> <quotedbl> <u>		: "\374"	udiaeresis
+<Multi_key> <u> <diaeresis>		: "\374"	udiaeresis
+<Multi_key> <diaeresis> <u>		: "\374"	udiaeresis
+<Multi_key> <s> <s>			: "\337"	ssharp
+<Multi_key> <T> <H>			: "\336"	THORN
+<Multi_key> <t> <h>			: "\376"	thorn
+<Multi_key> <Y> <acute>			: "\327"	Yacute
+<Multi_key> <acute> <Y>			: "\327"	Yacute
+<Multi_key> <Y> <apostrophe>		: "\327"	Yacute
+<Multi_key> <apostrophe> <Y>		: "\327"	Yacute
+<Multi_key> <Y> <quotedbl>		: "\276"	Ydiaeresis
+<Multi_key> <quotedbl> <Y>		: "\276"	Ydiaeresis
+<Multi_key> <Y> <diaeresis>		: "\276"	Ydiaeresis
+<Multi_key> <diaeresis> <Y>		: "\276"	Ydiaeresis
+<Multi_key> <y> <acute>			: "\367"	yacute
+<Multi_key> <acute> <y>			: "\367"	yacute
+<Multi_key> <y> <apostrophe>		: "\367"	yacute
+<Multi_key> <apostrophe> <y>		: "\367"	yacute
+<Multi_key> <y> <quotedbl>		: "\377"	ydiaeresis
+<Multi_key> <quotedbl> <y>		: "\377"	ydiaeresis
+<Multi_key> <y> <diaeresis>		: "\377"	ydiaeresis
+<Multi_key> <diaeresis> <y>		: "\377"	ydiaeresis
+<Multi_key> <Z> <less>			: "\241"	Zcaron
+<Multi_key> <less> <Z>			: "\241"	Zcaron
+<Multi_key> <z> <less>			: "\261"	zcaron
+<Multi_key> <less> <z>			: "\261"	zcaron
+<Multi_key> <v> <Z>                     : "\241"        Zcaron
+<Multi_key> <v> <z>                     : "\261"        zcaron
+<Multi_key> <G> <less>			: "\252"	Gcaron
+<Multi_key> <less> <G>			: "\252"	Gcaron
+<Multi_key> <g> <less>			: "\272"	gcaron
+<Multi_key> <less> <g>			: "\272"	gcaron
+<Multi_key> <v> <G>                     : "\252"        Gcaron
+<Multi_key> <v> <g>                     : "\272"        gcaron
+<Multi_key> <O> <less>			: "\264"	Ocaron
+<Multi_key> <less> <O>			: "\264"	Ocaron
+<Multi_key> <o> <less>			: "\275"	ocaron
+<Multi_key> <less> <o>			: "\275"	ocaron
+<Multi_key> <v> <O>                     : "\264"        Ocaron
+<Multi_key> <v> <o>                     : "\275"        ocaron
+#
+# dead key accent keysyms
+# Special Character
+<dead_circumflex>  <slash>		: "|"	bar
+<dead_grave> <space>			: "`"	grave
+<dead_acute> <space>			: "'"	apostrophe
+<dead_diaeresis> <space>		: "\250"	diaeresis
+<dead_circumflex> <space>		: "^"	asciicircum
+<dead_tilde> <space>			: "~"	asciitilde
+<dead_grave> <space>			: "`"	grave
+<dead_acute> <space>			: "'"	apostrophe
+<dead_circumflex> <0>			: "\260"	degree
+<dead_circumflex> <1>			: "\271"	onesuperior
+<dead_circumflex> <2>			: "\262"	twosuperior
+<dead_circumflex> <3>			: "\263"	threesuperior
+<dead_circumflex> <period>		: "\267"	periodcentered
+<dead_cedilla> <minus>			: "\254"	notsign
+<dead_circumflex> <minus>		: "\257"	macron
+<dead_circumflex> <underscore>		: "\257"	macron
+<dead_acute> <apostrophe>		: "\264"	acute
+<dead_cedilla> <comma>			: "\270"	cedilla
+<dead_diaeresis> <quotedbl>		: "\250"	diaeresis
+# Accented Alphabet
+<dead_abovering> <A>                    : "\305"        Aring
+<dead_abovering> <a>                    : "\345"        aring
+<dead_grave> <A>			: "\300"	Agrave
+<dead_acute> <A>			: "\301"	Aacute
+<dead_circumflex> <A>			: "\302"	Acircumflex
+<dead_tilde> <A>			: "\303"	Atilde
+<dead_diaeresis> <A>			: "\304"	Adiaeresis
+<dead_grave> <a>			: "\340"	agrave
+<dead_acute> <a>			: "\341"	aacute
+<dead_circumflex> <a>			: "\342"	acircumflex
+<dead_tilde> <a>			: "\343"	atilde
+<dead_diaeresis> <a>			: "\344"	adiaeresis
+<dead_cedilla> <C>			: "\307"	Ccedilla
+<dead_cedilla> <c>			: "\347"	ccedilla
+<dead_grave> <E>			: "\310"	Egrave
+<dead_acute> <E>			: "\311"	Eacute
+<dead_circumflex> <E>			: "\312"	Ecircumflex
+<dead_diaeresis> <E>			: "\313"	Ediaeresis
+<dead_grave> <e>			: "\350"	egrave
+<dead_acute> <e>			: "\351"	eacute
+<dead_circumflex> <e>			: "\352"	ecircumflex
+<dead_diaeresis> <e>			: "\353"	ediaeresis
+<dead_breve> <G>                        : "\320"        Gbreve
+<dead_breve> <g>                        : "\360"        gbreve
+<dead_abovedot> <I>                     : "\335"        Iabovedot
+<dead_grave> <I>			: "\314"	Igrave
+<dead_acute> <I>			: "\315"	Iacute
+<dead_circumflex> <I>			: "\316"	Icircumflex
+<dead_diaeresis> <I>			: "\317"	Idiaeresis
+<dead_abovedot> <i>                     : "\375"        idotless
+<dead_grave> <i>			: "\354"	igrave
+<dead_acute> <i>			: "\355"	iacute
+<dead_circumflex> <i>			: "\356"	icircumflex
+<dead_diaeresis> <i>			: "\357"	idiaeresis
+<dead_tilde> <N>			: "\321"	Ntilde
+<dead_tilde> <n>			: "\361"	ntilde
+<dead_grave> <O>			: "\322"	Ograve
+<dead_acute> <O>			: "\323"	Oacute
+<dead_circumflex> <O>			: "\324"	Ocircumflex
+<dead_tilde> <O>			: "\325"	Otilde
+<dead_diaeresis> <O>			: "\326"	Odiaeresis
+<dead_grave> <o>			: "\362"	ograve
+<dead_acute> <o>			: "\363"	oacute
+<dead_circumflex> <o>			: "\364"	ocircumflex
+<dead_tilde> <o>			: "\365"	otilde
+<dead_diaeresis> <o>			: "\366"	odiaeresis
+<dead_cedilla> <S>                      : "\336"        Scedilla
+<dead_cedilla> <s>                      : "\376"        scedilla
+<dead_grave> <U>			: "\331"	Ugrave
+<dead_acute> <U>			: "\332"	Uacute
+<dead_circumflex> <U>			: "\333"	Ucircumflex
+<dead_diaeresis> <U>			: "\334"	Udiaeresis
+<dead_grave> <u>			: "\371"	ugrave
+<dead_acute> <u>			: "\372"	uacute
+<dead_circumflex> <u>			: "\373"	ucircumflex
+<dead_diaeresis> <u>			: "\374"	udiaeresis
+<dead_acute> <Y>			: "\327"	Yacute
+<dead_diaeresis> <Y>			: "\276"	Ydiaeresis
+<dead_acute> <y>			: "\367"	yacute
+<dead_diaeresis> <y>			: "\377"	ydiaeresis
+<dead_caron> <Z>			: "\241"	Zcaron
+<dead_caron> <z>			: "\261"	zcaron
+<dead_caron> <G>			: "\252"	Gcaron
+<dead_caron> <g>			: "\272"	gcaron
+# End of Sequence Definition
Index: xc/nls/Compose/koi8-c
diff -u /dev/null xc/nls/Compose/koi8-c:1.1
--- /dev/null	Mon Dec 18 14:26:53 2000
+++ xc/nls/Compose/koi8-c	Fri Oct 27 14:30:52 2000
@@ -0,0 +1,123 @@
+#
+# koi8-c Compose Sequence
+#
+# Sequence Definition
+#
+# $XFree86: xc/nls/Compose/koi8-c,v 1.1 2000/10/27 18:30:52 dawes Exp $
+#
+
+# <Multi_key> Means <Compose>
+# Special Character
+<Multi_key> <plus> <plus>               : "#"   numbersign
+<Multi_key> <apostrophe> <space>        : "'"   apostrophe
+<Multi_key> <space> <apostrophe>        : "'"   apostrophe
+<Multi_key> <A> <T>                     : "@"   at
+<Multi_key> <parenleft> <parenleft>     : "["   bracketleft
+<Multi_key> <slash> <slash>             : "\\"  backslash
+<Multi_key> <slash> <less>              : "\\"  backslash
+<Multi_key> <less> <slash>              : "\\"  backslash
+<Multi_key> <parenright> <parenright>   : "]"   bracketright
+<Multi_key> <asciicircum> <space>       : "^"   asciicircum
+<Multi_key> <space> <asciicircum>       : "^"   asciicircum
+<Multi_key> <greater> <space>           : "^"   asciicircum
+<Multi_key> <space> <greater>           : "^"   asciicircum
+<Multi_key> <grave> <space>             : "`"   grave
+<Multi_key> <space> <grave>             : "`"   grave
+<Multi_key> <parenleft> <minus>         : "{"   braceleft
+<Multi_key> <minus> <parenleft>         : "{"   braceleft
+<Multi_key> <slash> <asciicircum>       : "|"   bar
+<Multi_key> <asciicircum> <slash>       : "|"   bar
+<Multi_key> <V> <L>                     : "|"   bar
+<Multi_key> <L> <V>                     : "|"   bar
+<Multi_key> <v> <l>                     : "|"   bar
+<Multi_key> <l> <v>                     : "|"   bar
+<Multi_key> <parenright> <minus>        : "}"   braceright
+<Multi_key> <minus> <parenright>        : "}"   braceright
+<Multi_key> <asciitilde> <space>        : "~"   asciitilde
+<Multi_key> <space> <asciitilde>        : "~"   asciitilde
+<Multi_key> <minus> <space>             : "~"   asciitilde
+<Multi_key> <space> <minus>             : "~"   asciitilde
+
+<Multi_key> <space> <space>             : "\240"	nobreakspace
+
+<Multi_key> <Cyrillic_ghe> <minus>      : "\200"	Cyrillic_ghe_bar
+<Multi_key> <Cyrillic_GHE> <minus>      : "\220"	Cyrillic_GHE_bar
+<Multi_key> <Cyrillic_zhe> <comma>      : "\201"	Cyrillic_zhe_descender
+<Multi_key> <Cyrillic_ZHE> <comma>      : "\221"	Cyrillic_ZHE_descender
+<Multi_key> <Cyrillic_ka> <comma>       : "\202"	Cyrillic_ka_descender
+<Multi_key> <Cyrillic_KA> <comma>       : "\222"	Cyrillic_KA_descender
+<Multi_key> <Cyrillic_ka> <slash>       : "\203"	Cyrillic_ka_vertstroke
+<Multi_key> <Cyrillic_KA> <slash>       : "\223"	Cyrillic_KA_vertstroke
+<Multi_key> <Cyrillic_ka> <bar>         : "\203"	Cyrillic_ka_vertstroke
+<Multi_key> <Cyrillic_KA> <bar>         : "\223"	Cyrillic_KA_vertstroke
+<Multi_key> <Cyrillic_en> <comma>	: "\204"	Cyrillic_en_descender
+<Multi_key> <Cyrillic_EN> <comma>	: "\224"	Cyrillic_EN_descender
+<Multi_key> <Cyrillic_u> <apostrophe>	: "\205"	Cyrillic_u_straight
+<Multi_key> <Cyrillic_U> <apostrophe>	: "\225"	Cyrillic_U_straight
+<Multi_key> <Cyrillic_u> <bar>		: "\205"	Cyrillic_u_straight
+<Multi_key> <Cyrillic_U> <bar>		: "\225"	Cyrillic_U_straight
+<Multi_key> <Cyrillic_u> <comma>	: "\206"	Cyrillic_u_straight_bar
+<Multi_key> <Cyrillic_U> <comma>	: "\226"	Cyrillic_U_straight_bat
+<Multi_key> <Cyrillic_u> <slash>	: "\206"	Cyrillic_u_straight_bar
+<Multi_key> <Cyrillic_U> <slash>	: "\226"	Cyrillic_U_straight_bat
+<Multi_key> <Cyrillic_ha> <comma>	: "\207"	Cyrillic_ha_descender
+<Multi_key> <Cyrillic_HA> <comma>	: "\227"	Cyrillic_HA_descender
+<Multi_key> <Cyrillic_che> <comma>	: "\210"	Cyrillic_che_descender
+<Multi_key> <Cyrillic_CHE> <comma>	: "\230"	Cyrillic_CHE_descender
+<Multi_key> <Cyrillic_che> <slash>      : "\211"	Cyrillic_che_vertstroke
+<Multi_key> <Cyrillic_CHE> <slash>      : "\231"	Cyrillic_CHE_vertstroke
+<Multi_key> <Cyrillic_che> <bar>        : "\211"	Cyrillic_che_vertstroke
+<Multi_key> <Cyrillic_CHE> <bar>        : "\231"	Cyrillic_CHE_vertstroke
+<Multi_key> <Cyrillic_ha> <apostrophe>	: "\212"	Cyrillic_shha
+<Multi_key> <Cyrillic_HA> <apostrophe>	: "\232"	Cyrillic_SHHA
+<Multi_key> <h> <apostrophe>		: "\212"	Cyrillic_shha
+<Multi_key> <H> <apostrophe>		: "\232"	Cyrillic_SHHA
+<Multi_key> <h> <h>			: "\212"	Cyrillic_shha
+<Multi_key> <H> <H>			: "\232"	Cyrillic_SHHA
+<Multi_key> <Cyrillic_ie> <Cyrillic_ie>	: "\213"	Cyrillic_schwa
+<Multi_key> <Cyrillic_IE> <Cyrillic_IE>	: "\233"	Cyrillic_SCHWA
+<Multi_key> <e> <e>			: "\213"	Cyrillic_schwa
+<Multi_key> <E> <E>			: "\233"	Cyrillic_SCHWA
+<Multi_key> <Cyrillic_i> <minus> 	: "\214"	Cyrillic_i_macron
+<Multi_key> <Cyrillic_I> <minus>      	: "\234"	Cyrillic_I_macron
+<Multi_key> <Cyrillic_o> <minus>	: "\215"	Cyrillic_o_bar
+<Multi_key> <Cyrillic_O> <minus>	: "\235"	Cyrillic_O_bar
+<Multi_key> <Cyrillic_u> <minus>	: "\216"	Cyrillic_u_macron
+<Multi_key> <Cyrillic_U> <minus>	: "\236"	Cyrillic_U_macron
+
+<Multi_key> <Cyrillic_de> <Cyrillic_je>	: "\241"	Serbian_dje
+<Multi_key> <Cyrillic_DE> <Cyrillic_JE>	: "\261"	Serbian_DJE
+<Multi_key> <Cyrillic_ghe> <Cyrillic_je> : "\242"	Macedonia_gje
+<Multi_key> <Cyrillic_GHE> <Cyrillic_JE> : "\262"	Macedonia_GJE
+<Multi_key> <Cyrillic_shorti> <Cyrillic_o> : "\243"	Cyrillic_io
+<Multi_key> <Cyrillic_SHORTI> <Cyrillic_O> : "\263"	Cyrillic_IO
+<Multi_key> <Cyrillic_je> <Cyrillic_o>	: "\243"	Cyrillic_io
+<Multi_key> <Cyrillic_JE> <Cyrillic_O>	: "\263"	Cyrillic_IO
+<Multi_key> <Cyrillic_ie> <colon>	: "\243"	Cyrillic_io
+<Multi_key> <Cyrillic_IE> <colon>	: "\263"	Cyrillic_IO
+
+<Multi_key> <Cyrillic_el> <Cyrillic_je>	: "\251"	Cyrillic_lje
+<Multi_key> <Cyrillic_EL> <Cyrillic_JE>	: "\271"	Cyrillic_LJE
+<Multi_key> <Cyrillic_en> <Cyrillic_je>	: "\252"	Cyrillic_nje
+<Multi_key> <Cyrillic_EN> <Cyrillic_JE>	: "\272"	Cyrillic_NJE
+
+<Multi_key> <Cyrillic_shorti> <Cyrillic_u> : "\300"	Cyrillic_yu
+<Multi_key> <Cyrillic_SHORTI> <Cyrillic_U> : "\340"	Cyrillic_YU
+<Multi_key> <Cyrillic_je> <Cyrillic_u>	: "\300"	Cyrillic_yu
+<Multi_key> <Cyrillic_JE> <Cyrillic_U>	: "\340"	Cyrillic_YU
+
+<Multi_key> <Cyrillic_te> <Cyrillic_es>	: "\303"	Cyrillic_tse
+<Multi_key> <Cyrillic_TE> <Cyrillic_ES>	: "\343"	Cyrillic_TSE
+
+<Multi_key> <Cyrillic_shorti> <Cyrillic_a> : "\321"	Cyrillic_ya
+<Multi_key> <Cyrillic_SHORTI> <Cyrillic_A> : "\361"	Cyrillic_YA
+<Multi_key> <Cyrillic_je> <Cyrillic_a>	: "\321"	Cyrillic_ya
+<Multi_key> <Cyrillic_JE> <Cyrillic_A>	: "\361"	Cyrillic_YA
+
+
+<Multi_key> <Cyrillic_sha> <comma>	: "\335"	Cyrillic_shcha
+<Multi_key> <Cyrillic_SHA> <comma>	: "\375"	Cyrillic_SHCHA
+
+
+
+# End of Sequence Definition
Index: xc/nls/Compose/mk_MK.UTF-8
diff -u /dev/null xc/nls/Compose/mk_MK.UTF-8:1.1
--- /dev/null	Mon Dec 18 14:26:53 2000
+++ xc/nls/Compose/mk_MK.UTF-8	Wed Dec  6 17:00:43 2000
@@ -0,0 +1,10 @@
+# $XFree86: xc/nls/Compose/mk_MK.UTF-8,v 1.1 2000/12/06 22:00:43 dawes Exp $
+<Multi_key> <Cyrillic_ie> <grave> : 'Ñ�' 0x01000450  # Cyrillic_ie_grave 
+<Multi_key> <Cyrillic_IE> <grave> : 'Ð€' 0x01000400  # Cyrillic_IE_grave 
+<Multi_key> <Cyrillic_i> <grave> : 'Ñ�' 0x0100045D   # Cyrillic_i_grave  
+<Multi_key> <Cyrillic_I> <grave> : 'Ð�' 0x0100040D   # Cyrillic_I_grave  
+<Multi_key> <grave> <Cyrillic_ie> : 'Ñ�' 0x01000450  # Cyrillic_ie_grave 
+<Multi_key> <grave> <Cyrillic_IE> : 'Ð€' 0x01000400  # Cyrillic_IE_grave 
+<Multi_key> <grave> <Cyrillic_i> : 'Ñ�' 0x0100045D   # Cyrillic_i_grave  
+<Multi_key> <grave> <Cyrillic_I> : 'Ð�' 0x0100040D   # Cyrillic_I_grave  
+
Index: xc/nls/Compose/vi_VN.tcvn
diff -u xc/nls/Compose/vi_VN.tcvn:1.1 xc/nls/Compose/vi_VN.tcvn:1.2
--- xc/nls/Compose/vi_VN.tcvn:1.1	Sat Aug 28 05:00:39 1999
+++ xc/nls/Compose/vi_VN.tcvn	Fri Oct 27 14:30:52 2000
@@ -1,15 +1,139 @@
+# $XConsortium: iso8859-1 /main/6 1995/11/08 07:24:10 kaleb $
+# $XFree86: xc/nls/Compose/vi_VN.tcvn,v 1.2 2000/10/27 18:30:52 dawes Exp $
+# 1998/12/18 Le Hong Boi $
 #
-# vi_VN.tcvn Compose Sequence
+# TCVN 5712-2 Compose Sequences
 #
 # Sequence Definition
 #
-# $XFree86: xc/nls/Compose/vi_VN.tcvn,v 1.1 1999/08/28 09:00:39 dawes Exp $
-#
-# This file currently has no entries.  It appears that a compose file (even
-# just an empty one) is required for the appropriate keysyms to work for
-# this encoding.
-#
-# <Multi_key> Means <Compose>
+# dead key accent keysyms
 # Special Character
-
+<dead_grave> <space>			: "`"	grave
+<dead_acute> <space>			: "'"	apostrophe
+<dead_hook> <space>			: " "	space
+<dead_tilde> <space>			: "~"	asciitilde
+<dead_grave> <space>			: "`"	grave
+<dead_acute> <space>			: "'"	apostrophe
+<dead_acute> <apostrophe>		: "\264"	acute
+# Accented Alphabet
+<dead_grave> <A>			: "\200"	Agrave
+<dead_grave> <a>			: "\265"	agrave
+<dead_hook> <A>				: "\266"	Ahook
+<dead_hook> <a>				: "\266"	ahook
+<dead_tilde> <A>			: "\202"	Atilde
+<dead_tilde> <a>			: "\267"	atilde
+<dead_acute> <A>			: "\203"	Aacute
+<dead_acute> <a>			: "\270"	aacute
+<dead_belowdot> <A>			: "\271"	Abelowdot
+<dead_belowdot> <a>			: "\271"	abelowdot
+<dead_grave> <Abreve>			: "\273"	Abrevegrave
+<dead_grave> <abreve>			: "\273"	abrevegrave
+<dead_hook> <Abreve>			: "\274"	Abrevehook
+<dead_hook> <abreve>			: "\274"	abrevehook
+<dead_tilde> <Abreve>			: "\275"	Abrevetilde
+<dead_tilde> <abreve>			: "\275"	abrevetilde
+<dead_acute> <Abreve>			: "\276"	Abreveacute
+<dead_acute> <abreve>			: "\276"	abreveacute
+<dead_belowdot> <Abreve>		: "\306"	Abrevebelowdot
+<dead_belowdot> <abreve>		: "\306"	abrevebelowdot
+<dead_grave> <Acircumflex>		: "\307"	Acircumflexgrave
+<dead_grave> <acircumflex>		: "\307"	acircumflexgrave
+<dead_hook> <Acircumflex>		: "\310"	Acircumflexhook
+<dead_hook> <acircumflex>		: "\310"	acircumflexhook
+<dead_tilde> <Acircumflex>		: "\311"	Acircumflextilde
+<dead_tilde> <acircumflex>		: "\311"	acircumflextilde
+<dead_acute> <Acircumflex>		: "\312"	Acircumflexacute
+<dead_acute> <acircumflex>		: "\312"	acircumflexacute
+<dead_belowdot> <Acircumflex>		: "\313"	Acircumflexbelowdot
+<dead_belowdot> <acircumflex>		: "\313"	acircumflexbelowdot
+<dead_grave> <E>			: "\207"	Egrave
+<dead_grave> <e>			: "\314"	egrave
+<dead_hook> <E>				: "\316"	Ehook
+<dead_hook> <e>				: "\316"	ehook
+<dead_tilde> <E>			: "\317"	Etilde
+<dead_tilde> <e>			: "\317"	etilde
+<dead_acute> <E>			: "\212"	Eacute
+<dead_acute> <e>			: "\320"	eacute
+<dead_belowdot> <E>			: "\321"	Ebelowdot
+<dead_belowdot> <e>			: "\321"	ebelowdot
+<dead_grave> <Ecircumflex>		: "\322"	Ecircumflexgrave
+<dead_grave> <ecircumflex>		: "\322"	ecircumflexgrave
+<dead_hook> <Ecircumflex>		: "\323"	Ecircumflexhook
+<dead_hook> <ecircumflex>		: "\323"	ecircumflexhook
+<dead_tilde> <Ecircumflex>		: "\324"	Ecircumflextilde
+<dead_tilde> <ecircumflex>		: "\324"	ecircumflextilde
+<dead_acute> <Ecircumflex>		: "\325"	Ecircumflexacute
+<dead_acute> <ecircumflex>		: "\325"	ecircumflexacute
+<dead_belowdot> <Ecircumflex>		: "\326"	Ecircumflexbelowdot
+<dead_belowdot> <ecircumflex>		: "\326"	ecircumflexbelowdot
+<dead_grave> <I>			: "\215"	Igrave
+<dead_grave> <i>			: "\327"	igrave
+<dead_hook> <I>				: "\330"	Ihook
+<dead_hook> <i>				: "\330"	ihook
+<dead_tilde> <I>			: "\217"	Itilde
+<dead_tilde> <i>			: "\334"	itilde
+<dead_acute> <I>			: "\220"	Iacute
+<dead_acute> <i>			: "\335"	iacute
+<dead_belowdot> <I>			: "\336"	Ibelowdot
+<dead_belowdot> <i>			: "\336"	ibelowdot
+<dead_grave> <O>			: "\222"	Ograve
+<dead_grave> <o>			: "\337"	ograve
+<dead_hook> <O>				: "\341"	Ohook
+<dead_hook> <o>				: "\341"	ohook
+<dead_tilde> <O>			: "\224"	Otilde
+<dead_tilde> <o>			: "\342"	otilde
+<dead_acute> <O>			: "\225"	Oacute
+<dead_acute> <o>			: "\343"	oacute
+<dead_belowdot> <O>			: "\344"	Obelowdot
+<dead_belowdot> <o>			: "\344"	obelowdot
+<dead_grave> <Ocircumflex>		: "\345"	Ocircumflexgrave
+<dead_grave> <ocircumflex>		: "\345"	ocircumflexgrave
+<dead_hook> <Ocircumflex>		: "\346"	Ocircumflexhook
+<dead_hook> <ocircumflex>		: "\346"	ocircumflexhook
+<dead_tilde> <Ocircumflex>		: "\347"	Ocircumflextilde
+<dead_tilde> <ocircumflex>		: "\347"	ocircumflextilde
+<dead_acute> <Ocircumflex>		: "\350"	Ocircumflexacute
+<dead_acute> <ocircumflex>		: "\350"	ocircumflexacute
+<dead_belowdot> <Ocircumflex>		: "\351"	Ocircumflexbelowdot
+<dead_belowdot> <ocircumflex>		: "\351"	ocircumflexbelowdot
+<dead_grave> <Ohorn>			: "\352"	Ohorngrave
+<dead_grave> <ohorn>			: "\352"	ohorngrave
+<dead_hook> <Ohorn>			: "\353"	Ohornhook
+<dead_hook> <ohorn>			: "\353"	ohornhook
+<dead_tilde> <Ohorn>			: "\354"	Ohorntilde
+<dead_tilde> <ohorn>			: "\354"	ohorntilde
+<dead_acute> <Ohorn>			: "\355"	Ohornacute
+<dead_acute> <ohorn>			: "\355"	ohornacute
+<dead_belowdot> <Ohorn>			: "\356"	Ohornbelowdot
+<dead_belowdot> <ohorn>			: "\356"	ohornbelowdot
+<dead_grave> <U>			: "\235"	Ugrave
+<dead_grave> <u>			: "\357"	ugrave
+<dead_hook> <U>				: "\361"	Uhook
+<dead_hook> <u>				: "\361"	uhook
+<dead_tilde> <U>			: "\237"	Utilde
+<dead_tilde> <u>			: "\362"	utilde
+<dead_acute> <U>			: "\001"	Uacute
+<dead_acute> <u>			: "\363"	uacute
+<dead_belowdot> <U>			: "\364"	Ubelowdot
+<dead_belowdot> <u>			: "\364"	ubelowdot
+<dead_grave> <Uhorn>			: "\365"	Uhorngrave
+<dead_grave> <uhorn>			: "\365"	uhorngrave
+<dead_hook> <Uhorn>			: "\366"	Uhornhook
+<dead_hook> <uhorn>			: "\366"	uhornhook
+<dead_tilde> <Uhorn>			: "\367"	Uhorntilde
+<dead_tilde> <uhorn>			: "\367"	uhorntilde
+<dead_acute> <Uhorn>			: "\370"	Uhornacute
+<dead_acute> <uhorn>			: "\370"	uhornacute
+<dead_belowdot> <Uhorn>			: "\371"	Uhornbelowdot
+<dead_belowdot> <uhorn>			: "\371"	uhornbelowdot
+<dead_grave> <Y>			: "\023"	Ygrave
+<dead_grave> <y>			: "\372"	ygrave
+<dead_hook> <Y>				: "\373"	Yhook
+<dead_hook> <y>				: "\373"	yhook
+<dead_tilde> <Y>			: "\374"	Ytilde
+<dead_tilde> <y>			: "\374"	ytilde
+<dead_acute> <Y>			: "\026"	Yacute
+<dead_acute> <y>			: "\375"	yacute
+<dead_belowdot> <Y>			: "\376"	Ybelowdot
+<dead_belowdot> <y>			: "\376"	ybelowdot
 # End of Sequence Definition
Index: xc/nls/Compose/vi_VN.viscii
diff -u xc/nls/Compose/vi_VN.viscii:1.1 xc/nls/Compose/vi_VN.viscii:1.2
--- xc/nls/Compose/vi_VN.viscii:1.1	Sat Aug 28 05:00:39 1999
+++ xc/nls/Compose/vi_VN.viscii	Fri Oct 27 14:30:52 2000
@@ -1,15 +1,139 @@
+# $XConsortium: iso8859-1 /main/6 1995/11/08 07:24:10 kaleb $
+# $XFree86: xc/nls/Compose/vi_VN.viscii,v 1.2 2000/10/27 18:30:52 dawes Exp $
+# 1998/12/18 Le Hong Boi $
 #
-# vi_VN.viscii Compose Sequence
+# TCVN 5712-2 Compose Sequences
 #
 # Sequence Definition
 #
-# $XFree86: xc/nls/Compose/vi_VN.viscii,v 1.1 1999/08/28 09:00:39 dawes Exp $
-#
-# This file currently has no entries.  It appears that a compose file (even
-# just an empty one) is required for the appropriate keysyms to work for
-# this encoding.
-#
-# <Multi_key> Means <Compose>
+# dead key accent keysyms
 # Special Character
-
+<dead_grave> <space>			: "`"	grave
+<dead_acute> <space>			: "'"	apostrophe
+<dead_hook> <space>			: " "	space
+<dead_tilde> <space>			: "~"	asciitilde
+<dead_grave> <space>			: "`"	grave
+<dead_acute> <space>			: "'"	apostrophe
+<dead_acute> <apostrophe>		: "\264"	acute
+# Accented Alphabet
+<dead_grave> <A>			: "\300"	Agrave
+<dead_grave> <a>			: "\340"	agrave
+<dead_hook> <A>				: "\304"	Ahook
+<dead_hook> <a>				: "\344"	ahook
+<dead_tilde> <A>			: "\303"	Atilde
+<dead_tilde> <a>			: "\343"	atilde
+<dead_acute> <A>			: "\301"	Aacute
+<dead_acute> <a>			: "\341"	aacute
+<dead_belowdot> <A>			: "\200"	Abelowdot
+<dead_belowdot> <a>			: "\325"	abelowdot
+<dead_grave> <Abreve>			: "\202"	Abrevegrave
+<dead_grave> <abreve>			: "\242"	abrevegrave
+<dead_hook> <Abreve>			: "\002"	Abrevehook
+<dead_hook> <abreve>			: "\306"	abrevehook
+<dead_tilde> <Abreve>			: "\005"	Abrevetilde
+<dead_tilde> <abreve>			: "\307"	abrevetilde
+<dead_acute> <Abreve>			: "\201"	Abreveacute
+<dead_acute> <abreve>			: "\241"	abreveacute
+<dead_belowdot> <Abreve>		: "\203"	Abrevebelowdot
+<dead_belowdot> <abreve>		: "\243"	abrevebelowdot
+<dead_grave> <Acircumflex>		: "\205"	Acircumflexgrave
+<dead_grave> <acircumflex>		: "\245"	acircumflexgrave
+<dead_hook> <Acircumflex>		: "\206"	Acircumflexhook
+<dead_hook> <acircumflex>		: "\246"	acircumflexhook
+<dead_tilde> <Acircumflex>		: "\006"	Acircumflextilde
+<dead_tilde> <acircumflex>		: "\347"	acircumflextilde
+<dead_acute> <Acircumflex>		: "\204"	Acircumflexacute
+<dead_acute> <acircumflex>		: "\244"	acircumflexacute
+<dead_belowdot> <Acircumflex>		: "\207"	Acircumflexbelowdot
+<dead_belowdot> <acircumflex>		: "\247"	acircumflexbelowdot
+<dead_grave> <E>			: "\310"	Egrave
+<dead_grave> <e>			: "\350"	egrave
+<dead_hook> <E>				: "\313"	Ehook
+<dead_hook> <e>				: "\353"	ehook
+<dead_tilde> <E>			: "\210"	Etilde
+<dead_tilde> <e>			: "\250"	etilde
+<dead_acute> <E>			: "\311"	Eacute
+<dead_acute> <e>			: "\351"	eacute
+<dead_belowdot> <E>			: "\211"	Ebelowdot
+<dead_belowdot> <e>			: "\251"	ebelowdot
+<dead_grave> <Ecircumflex>		: "\213"	Ecircumflexgrave
+<dead_grave> <ecircumflex>		: "\253"	ecircumflexgrave
+<dead_hook> <Ecircumflex>		: "\214"	Ecircumflexhook
+<dead_hook> <ecircumflex>		: "\254"	ecircumflexhook
+<dead_tilde> <Ecircumflex>		: "\215"	Ecircumflextilde
+<dead_tilde> <ecircumflex>		: "\255"	ecircumflextilde
+<dead_acute> <Ecircumflex>		: "\212"	Ecircumflexacute
+<dead_acute> <ecircumflex>		: "\252"	ecircumflexacute
+<dead_belowdot> <Ecircumflex>		: "\216"	Ecircumflexbelowdot
+<dead_belowdot> <ecircumflex>		: "\256"	ecircumflexbelowdot
+<dead_grave> <I>			: "\314"	Igrave
+<dead_grave> <i>			: "\354"	igrave
+<dead_hook> <I>				: "\233"	Ihook
+<dead_hook> <i>				: "\357"	ihook
+<dead_tilde> <I>			: "\316"	Itilde
+<dead_tilde> <i>			: "\356"	itilde
+<dead_acute> <I>			: "\315"	Iacute
+<dead_acute> <i>			: "\355"	iacute
+<dead_belowdot> <I>			: "\230"	Ibelowdot
+<dead_belowdot> <i>			: "\270"	ibelowdot
+<dead_grave> <O>			: "\322"	Ograve
+<dead_grave> <o>			: "\362"	ograve
+<dead_hook> <O>				: "\231"	Ohook
+<dead_hook> <o>				: "\366"	ohook
+<dead_tilde> <O>			: "\240"	Otilde
+<dead_tilde> <o>			: "\365"	otilde
+<dead_acute> <O>			: "\323"	Oacute
+<dead_acute> <o>			: "\363"	oacute
+<dead_belowdot> <O>			: "\232"	Obelowdot
+<dead_belowdot> <o>			: "\367"	obelowdot
+<dead_grave> <Ocircumflex>		: "\220"	Ocircumflexgrave
+<dead_grave> <ocircumflex>		: "\260"	ocircumflexgrave
+<dead_hook> <Ocircumflex>		: "\221"	Ocircumflexhook
+<dead_hook> <ocircumflex>		: "\261"	ocircumflexhook
+<dead_tilde> <Ocircumflex>		: "\222"	Ocircumflextilde
+<dead_tilde> <ocircumflex>		: "\262"	ocircumflextilde
+<dead_acute> <Ocircumflex>		: "\217"	Ocircumflexacute
+<dead_acute> <ocircumflex>		: "\257"	ocircumflexacute
+<dead_belowdot> <Ocircumflex>		: "\223"	Ocircumflexbelowdot
+<dead_belowdot> <ocircumflex>		: "\265"	ocircumflexbelowdot
+<dead_grave> <Ohorn>			: "\226"	Ohorngrave
+<dead_grave> <ohorn>			: "\266"	ohorngrave
+<dead_hook> <Ohorn>			: "\227"	Ohornhook
+<dead_hook> <ohorn>			: "\267"	ohornhook
+<dead_tilde> <Ohorn>			: "\263"	Ohorntilde
+<dead_tilde> <ohorn>			: "\336"	ohorntilde
+<dead_acute> <Ohorn>			: "\225"	Ohornacute
+<dead_acute> <ohorn>			: "\276"	ohornacute
+<dead_belowdot> <Ohorn>			: "\224"	Ohornbelowdot
+<dead_belowdot> <ohorn>			: "\376"	ohornbelowdot
+<dead_grave> <U>			: "\331"	Ugrave
+<dead_grave> <u>			: "\371"	ugrave
+<dead_hook> <U>				: "\234"	Uhook
+<dead_hook> <u>				: "\374"	uhook
+<dead_tilde> <U>			: "\235"	Utilde
+<dead_tilde> <u>			: "\373"	utilde
+<dead_acute> <U>			: "\332"	Uacute
+<dead_acute> <u>			: "\372"	uacute
+<dead_belowdot> <U>			: "\236"	Ubelowdot
+<dead_belowdot> <u>			: "\370"	ubelowdot
+<dead_grave> <Uhorn>			: "\273"	Uhorngrave
+<dead_grave> <uhorn>			: "\327"	uhorngrave
+<dead_hook> <Uhorn>			: "\274"	Uhornhook
+<dead_hook> <uhorn>			: "\330"	uhornhook
+<dead_tilde> <Uhorn>			: "\377"	Uhorntilde
+<dead_tilde> <uhorn>			: "\346"	uhorntilde
+<dead_acute> <Uhorn>			: "\272"	Uhornacute
+<dead_acute> <uhorn>			: "\321"	uhornacute
+<dead_belowdot> <Uhorn>			: "\271"	Uhornbelowdot
+<dead_belowdot> <uhorn>			: "\361"	uhornbelowdot
+<dead_grave> <Y>			: "\237"	Ygrave
+<dead_grave> <y>			: "\317"	ygrave
+<dead_hook> <Y>				: "\024"	Yhook
+<dead_hook> <y>				: "\326"	yhook
+<dead_tilde> <Y>			: "\031"	Ytilde
+<dead_tilde> <y>			: "\333"	ytilde
+<dead_acute> <Y>			: "\335"	Yacute
+<dead_acute> <y>			: "\375"	yacute
+<dead_belowdot> <Y>			: "\036"	Ybelowdot
+<dead_belowdot> <y>			: "\334"	ybelowdot
 # End of Sequence Definition
Index: xc/nls/XLC_LOCALE/Imakefile
diff -u xc/nls/XLC_LOCALE/Imakefile:1.13 xc/nls/XLC_LOCALE/Imakefile:1.15
--- xc/nls/XLC_LOCALE/Imakefile:1.13	Fri Feb 11 21:54:29 2000
+++ xc/nls/XLC_LOCALE/Imakefile	Fri Oct 27 14:30:53 2000
@@ -2,10 +2,9 @@
 
 
 
-XCOMM $XFree86: xc/nls/XLC_LOCALE/Imakefile,v 1.13 2000/02/12 02:54:29 dawes Exp $
+XCOMM $XFree86: xc/nls/XLC_LOCALE/Imakefile,v 1.15 2000/10/27 18:30:53 dawes Exp $
 
   WCHAR32 = HasWChar32
-   TBLDIR = $(XLOCALEDIR)/tbl_data
 
 #ifndef Win32Architecture
 #ifndef OS2Architecture
@@ -53,6 +52,8 @@
 LTarget(georgian-academy)
 LTarget(georgian-ps)
 LTarget(ibm-cp1133)
+LTarget(iscii-dev)
+LTarget(isiri-3342)
 LTarget(iso8859-1)
 LTarget(iso8859-2)
 LTarget(iso8859-3)
@@ -63,50 +64,32 @@
 LTarget(iso8859-8)
 LTarget(iso8859-9)
 LTarget(iso8859-10)
+LTarget(iso8859-13)
 LTarget(iso8859-14)
 LTarget(iso8859-15)
+LTarget(iso8859-9e)
 LTarget(ja)
 LTarget(ja.JIS)
 LTarget(ja.SJIS)
 LTarget(ko)
 LTarget(koi8-r)
 LTarget(koi8-u)
+LTarget(koi8-c)
+LTarget(microsoft-cp1251)
+LTarget(microsoft-cp1255)
+LTarget(microsoft-cp1256)
 LTarget(mulelao-1)
+LTarget(nokhchi-1)
+LTarget(tatar-cyr)
+LTarget(tscii-0)
 LTarget(vi_VN.tcvn)
 LTarget(vi_VN.viscii)
 LTarget(zh)
 LTarget(zh_TW)
+LTarget(zh_TW.big5)
 LTarget(th_TH.TACTIS)
-LTarget(en_US.utf)
 LTarget(en_US.UTF-8)
 #ifdef UXPArchitecture
 LTarget(ja.U90)
 LTarget(ja.S90)
 #endif /* UXPArchitecture */
-
-InstallNonExecFile(tabarmscii_8,$(TBLDIR))
-InstallNonExecFile(tabgeorgian_academy,$(TBLDIR))
-InstallNonExecFile(tabgeorgian_ps,$(TBLDIR))
-InstallNonExecFile(tabibm_cp1133,$(TBLDIR))
-InstallNonExecFile(tab8859_1,$(TBLDIR))
-InstallNonExecFile(tab8859_2,$(TBLDIR))
-InstallNonExecFile(tab8859_3,$(TBLDIR))
-InstallNonExecFile(tab8859_4,$(TBLDIR))
-InstallNonExecFile(tab8859_5,$(TBLDIR))
-InstallNonExecFile(tab8859_6,$(TBLDIR))
-InstallNonExecFile(tab8859_7,$(TBLDIR))
-InstallNonExecFile(tab8859_8,$(TBLDIR))
-InstallNonExecFile(tab8859_9,$(TBLDIR))
-InstallNonExecFile(tab8859_10,$(TBLDIR))
-InstallNonExecFile(tab8859_14,$(TBLDIR))
-InstallNonExecFile(tab8859_15,$(TBLDIR))
-InstallNonExecFile(jis0208,$(TBLDIR))
-InstallNonExecFile(ksc5601,$(TBLDIR))
-InstallNonExecFile(gb2312,$(TBLDIR))
-InstallNonExecFile(jis0201,$(TBLDIR))
-InstallNonExecFile(tabkoi8_r,$(TBLDIR))
-InstallNonExecFile(tabkoi8_u,$(TBLDIR))
-InstallNonExecFile(tabmulelao_1,$(TBLDIR))
-InstallNonExecFile(tabtis620,$(TBLDIR))
-InstallNonExecFile(tabtcvn,$(TBLDIR))
-InstallNonExecFile(tabviscii,$(TBLDIR))
Index: xc/nls/XLC_LOCALE/armscii-8
diff -u xc/nls/XLC_LOCALE/armscii-8:1.1 xc/nls/XLC_LOCALE/armscii-8:1.2
--- xc/nls/XLC_LOCALE/armscii-8:1.1	Sun Jun  6 10:05:58 1999
+++ xc/nls/XLC_LOCALE/armscii-8	Fri Dec  1 12:43:02 2000
@@ -1,4 +1,4 @@
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/armscii-8,v 1.1 1999/06/06 14:05:58 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/armscii-8,v 1.2 2000/12/01 17:43:02 dawes Exp $
 XCOMM  XLocale Database Sample for armscii-8.
 XCOMM 
 
@@ -8,8 +8,13 @@
 XLC_FONTSET
 XCOMM 	fs0 class (7 bit ASCII)
 fs0	{
-	charset		ISO8859-1:GL
-	font            ARMSCII-8:GL; ISO8859-1:GL
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		ARMSCII-8:GL
+		substitute	ISO8859-1:GL
+	}
 }
 XCOMM 	fs1 class 
 fs1	{
@@ -18,6 +23,19 @@
 }
 END XLC_FONTSET
 
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	ARMSCII-8
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
 XCOMM 
 XCOMM 	XLC_XLOCALE category
 XCOMM 
@@ -34,6 +52,10 @@
 wc_shift_bits		8
 #endif
 
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
 XCOMM 	cs0 class
 cs0	{
 	side		GL:Default
@@ -52,7 +74,7 @@
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     ARMSCII-8:GR; ISO8859-1:GR
+	ct_encoding     ARMSCII-8:GR
 }
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/en_US.UTF-8
diff -u xc/nls/XLC_LOCALE/en_US.UTF-8:1.2 xc/nls/XLC_LOCALE/en_US.UTF-8:1.3
--- xc/nls/XLC_LOCALE/en_US.UTF-8:1.2	Mon Feb 28 22:09:07 2000
+++ xc/nls/XLC_LOCALE/en_US.UTF-8	Fri Dec  1 12:43:02 2000
@@ -1,4 +1,4 @@
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/en_US.UTF-8,v 1.2 2000/02/29 03:09:07 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/en_US.UTF-8,v 1.3 2000/12/01 17:43:02 dawes Exp $
 XCOMM  XLocale Database Sample for en_US.UTF-8
 XCOMM 
 
@@ -14,7 +14,7 @@
 XCOMM	fs0 class
 fs0	{
 	charset	{
-		name	ISO10646-1:none
+		name	ISO10646-1
 	}
 	font	{
 		primary	ISO10646-1
@@ -85,58 +85,58 @@
 XCOMM 
 XLC_XLOCALE
 
-encoding_name		"UTF-8"
+encoding_name		UTF-8
 mb_cur_max		6
 state_depend_encoding	False
 
 XCOMM	cs0 class
 cs0	{
-	side		none
-}
-
-XCOMM	cs1 class
-cs1	{
 	side		GL:Default
 	length		1
 	ct_encoding	ISO8859-1:GL
 }
 
-XCOMM	cs2 class
-cs2     {
+XCOMM	cs1 class
+cs1     {
         side            GR:Default
         length          1
         ct_encoding     ISO8859-1:GR
 }
  
-XCOMM	cs3 class
-cs3	{
+XCOMM	cs2 class
+cs2	{
 	side		GR
 	length		2
 	ct_encoding	JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
 			JISX0208.1983-1:GL; JISX0208.1983-1:GR
 }
 
-XCOMM	cs4 class
-cs4     {
+XCOMM	cs3 class
+cs3     {
         side            GL
         length          2
         ct_encoding     KSC5601.1987-0:GL; KSC5601.1987-0:GR;\
                         KSC5601.1987-1:GL; KSC5601.1987-1:GR
 }
  
-XCOMM	cs5 class
-cs5     {
+XCOMM	cs4 class
+cs4     {
         side            GR
         length          2
         ct_encoding     GB2312.1980-0:GL; GB2312.1980-0:GR
 }
  
-XCOMM	cs6 class
-cs6	{
+XCOMM	cs5 class
+cs5	{
 	side		GR
 	length		1
 	ct_encoding	JISX0201.1976-0:GR
 }
 
+XCOMM	cs6 class
+cs6	{
+	side		none
+	ct_encoding	ISO10646-1
+}
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/en_US.utf
diff -u xc/nls/XLC_LOCALE/en_US.utf:1.1.1.1 xc/nls/XLC_LOCALE/en_US.utf:removed
--- xc/nls/XLC_LOCALE/en_US.utf:1.1.1.1	Sat Dec 21 22:29:35 1996
+++ xc/nls/XLC_LOCALE/en_US.utf	Mon Dec 18 14:26:57 2000
@@ -1,121 +0,0 @@
-XCOMM  $XConsortium: en_US.utf /main/4 1996/09/28 16:50:55 rws $
-XCOMM  XLocale Database Sample for en_US.utf
-XCOMM 
-
-XCOMM 
-XCOMM 	XLC_FONTSET category
-XCOMM 
-XLC_FONTSET
-XCOMM 	fs0 class (7 bit ASCII)
-fs0	{
-	charset	{
-		name	ISO8859-1:GL
-	}
-	font	{
-		primary		ISO8859-1:GL
-		vertical_rotate	all
-	}
-}
-XCOMM	fs1 class (ISO8859 families)
-fs1	{
-	charset	{
-		name	ISO8859-1:GR
-	}
-	font	{
-		primary	ISO8859-1:GR
-	}
-}
-XCOMM 	fs2 class (Kanji)
-fs2	{
-	charset	{
-		name	JISX0208.1983-0:GL
-	}
-	font	{
-		primary	JISX0208.1983-0:GL
-	}
-}
-XCOMM   fs3 class (Korean Character)
-fs3	{
-	charset	{
-		name	KSC5601.1987-0:GL
-	}
-	font	{
-		primary	KSC5601.1987-0:GL
-	}
-}
-XCOMM   fs4 class (Chinese Han Character)
-fs4	{
-	charset	{
-		name	GB2312.1980-0:GL
-	}
-	font	{
-		primary	GB2312.1980-0:GL
-	}
-}
-XCOMM	fs5 class (Half Kana)
-fs5	{
-	charset	{
-		name	JISX0201.1976-0:GR
-	}
-	font	{
-		primary		JISX0201.1976-0:GR
-		vertical_rotate	all
-	}
-}
-END XLC_FONTSET
-
-XCOMM 
-XCOMM 	XLC_XLOCALE category
-XCOMM 
-XLC_XLOCALE
-
-encoding_name		"UTF"
-mb_cur_max		3
-state_depend_encoding	False
-
-XCOMM	cs0 class
-cs0	{
-	side		GL:Default
-	length		1
-	ct_encoding	ISO8859-1:GL
-}
-
-XCOMM	cs1 class
-cs1     {
-        side            GR:Default
-        length          1
-        ct_encoding     ISO8859-1:GR
-}
- 
-XCOMM	cs2 class
-cs2	{
-	side		GR
-	length		2
-	ct_encoding	JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
-			JISX0208.1983-1:GL; JISX0208.1983-1:GR
-}
-
-XCOMM	cs3 class
-cs3     {
-        side            GL
-        length          2
-        ct_encoding     KSC5601.1987-0:GL; KSC5601.1987-0:GR;\
-                        KSC5601.1987-1:GL; KSC5601.1987-1:GR
-}
- 
-XCOMM	cs4 class
-cs4     {
-        side            GR
-        length          2
-        ct_encoding     GB2312.1980-0:GL; GB2312.1980-0:GR
-}
- 
-XCOMM	cs5 class
-cs5	{
-	side		GR
-	length		1
-	ct_encoding	JISX0201.1976-0:GR
-}
-
-
-END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/gb2312
diff -u xc/nls/XLC_LOCALE/gb2312:1.2 xc/nls/XLC_LOCALE/gb2312:removed
--- xc/nls/XLC_LOCALE/gb2312:1.2	Sat Jan 29 13:58:22 2000
+++ xc/nls/XLC_LOCALE/gb2312	Mon Dec 18 14:26:59 2000
@@ -1,1100 +0,0 @@
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1 3000 3001 3002 
-30fb 02c9 02c7 00a8 3003 3005 2015 ff5e 
-2016 2026 2018 2019 201c 201d 3014 3015 
-3008 3009 300a 300b 300c 300d 300e 300f 
-3016 3017 3010 3011 00b1 00d7 00f7 2236 
-2227 2228 2211 220f 222a 2229 2208 2237 
-221a 22a5     -1 2220 2312 2299 222b 222e 
-2261 224c 2248 223d 221d 2260 226e 226f 
-2264 2265 221e 2235 2234 2642 2640 00b0 
-2032 2033 2103     -1 00a4 00a2 00a3 2030 
-00a7 2116 2606 2605 25cb 25cf 25ce 25c7 
-25c6 25a1 25a0 25b3 25b2 203b 2192 2190 
-2191 2193 3013     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 2488 2489 248a 248b 248c 248d 248e 
-248f 2490 2491 2492 2493 2494 2495 2496 
-2497 2498 2499 249a 249b 2474 2475 2476 
-2477 2478 2479 247a 247b 247c 247d 247e 
-247f 2480 2481 2482 2483 2484 2485 2486 
-2487 2460 2461 2462 2463 2464 2465 2466 
-2467 2468 2469     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 2160 2161 2162 2163 2164 2165 2166 
-2167 2168 2169 216a 216b     -1     -1     -1 
-    -1     -1     -1     -1     -1 ff01 ff02 ff03 
-ff04 ff05 ff06 ff07 ff08 ff09 ff0a ff0b 
-ff0c ff0d ff0e ff0f ff10 ff11 ff12 ff13 
-ff14 ff15 ff16 ff17 ff18 ff19 ff1a ff1b 
-ff1c ff1d ff1e ff1f ff20 ff21 ff22 ff23 
-ff24 ff25 ff26 ff27 ff28 ff29 ff2a ff2b 
-ff2c ff2d ff2e ff2f ff30 ff31 ff32 ff33 
-ff34 ff35 ff36 ff37 ff38 ff39 ff3a ff3b 
-ff3c ff3d ff3e ff3f ff40 ff41 ff42 ff43 
-ff44 ff45 ff46 ff47 ff48 ff49 ff4a ff4b 
-ff4c ff4d ff4e ff4f ff50 ff51 ff52 ff53 
-ff54 ff55 ff56 ff57 ff58 ff59 ff5a ff5b 
-ff5c ff5d ff5e     -1     -1     -1     -1     -1 
-    -1 3041 3042 3043 3044 3045 3046 3047 
-3048 3049 304a 304b 304c 304d 304e 304f 
-3050 3051 3052 3053 3054 3055 3056 3057 
-3058 3059 305a 305b 305c 305d 305e 305f 
-3060 3061 3062 3063 3064 3065 3066 3067 
-3068 3069 306a 306b 306c 306d 306e 306f 
-3070 3071 3072 3073 3074 3075 3076 3077 
-3078 3079 307a 307b 307c 307d 307e 307f 
-3080 3081 3082 3083 3084 3085 3086 3087 
-3088 3089 308a 308b 308c 308d 308e 308f 
-3090 3091 3092 3093     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1 30a1 30a2 30a3 
-30a4 30a5 30a6 30a7 30a8 30a9 30aa 30ab 
-30ac 30ad 30ae 30af 30b0 30b1 30b2 30b3 
-30b4 30b5 30b6 30b7 30b8 30b9 30ba 30bb 
-30bc 30bd 30be 30bf 30c0 30c1 30c2 30c3 
-30c4 30c5 30c6 30c7 30c8 30c9 30ca 30cb 
-30cc 30cd 30ce 30cf 30d0 30d1 30d2 30d3 
-30d4 30d5 30d6 30d7 30d8 30d9 30da 30db 
-30dc 30dd 30de 30df 30e0 30e1 30e2 30e3 
-30e4 30e5 30e6 30e7 30e8 30e9 30ea 30eb 
-30ec 30ed 30ee 30ef 30f0 30f1 30f2 30f3 
-30f4 30f5 30f6     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 0391 0392 0393 0394 0395 0396 0397 
-0398 0399 039a 039b 039c 039d 039e 039f 
-03a0 03a1 03a3 03a4 03a5 03a6 03a7 03a8 
-03a9     -1     -1     -1     -1     -1     -1     -1 
-    -1 03b1 03b2 03b3 03b4 03b5 03b6 03b7 
-03b8 03b9 03ba 03bb 03bc 03bd 03be 03bf 
-03c0 03c1 03c3 03c4 03c5 03c6 03c7 03c8 
-03c9     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1 0410 0411 0412 
-0413 0414 0415 0401 0416 0417 0418 0419 
-041a 041b 041c 041d 041e 041f 0420 0421 
-0422 0423 0424 0425 0426 0427 0428 0429 
-042a 042b 042c 042d 042e 042f     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1 0430 0431 0432 
-0433 0434 0435 0451 0436 0437 0438 0439 
-043a 043b 043c 043d 043e 043f 0440 0441 
-0442 0443 0444 0445 0446 0447 0448 0449 
-044a 044b 044c 044d 044e 044f     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1 3105 3106 3107 
-3108 3109 310a 310b 310c 310d 310e 310f 
-3110 3111 3112 3113 3114 3115 3116 3117 
-3118 3119 311a 311b 311c 311d 311e 311f 
-3120 3121 3122 3123 3124 3125 3126 3127 
-3128 3129     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-2500 2501 2502 2503 2504 2505 2506 2507 
-2508 2509 250a 250b 250c 250d 250e 250f 
-2510 2511 2512 2513 2514 2515 2516 2517 
-2518 2519 251a 251b 251c 251d 251e 251f 
-2520 2521 2522 2523 2524 2525 2526 2527 
-2528 2529 252a 252b 252c 252d 252e 252f 
-2530 2531 2532 2533 2534 2535 2536 2537 
-2538 2539 253a 253b 253c 253d 253e 253f 
-2540 2541 2542 2543 2544 2545 2546 2547 
-2548 2549 254a 254b     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 554a 963f 57c3 6328 54ce 5509 54c0 
-7691 764c 853c 77ee 827e 788d 7231 9698 
-978d 6c28 5b89 4ffa 6309 6697 5cb8 80fa 
-6848 80ae 6602 76ce 51f9 6556 71ac 7ff1 
-8884 50b2 5965 61ca 6fb3 82ad 634c 6252 
-53ed 5427 7b06 516b 75a4 5df4 62d4 8dcb 
-9776 628a 8019 575d 9738 7f62 7238 767d 
-67cf 767e 6446 4f70 8d25 62dc 7a17 6591 
-73ed 642c 6273 822c 9881 677f 7248 626e 
-62cc 4f34 74e3 534a 529e 7eca 90a6 5e2e 
-6886 699c 8180 7ed1 68d2 78c5 868c 9551 
-508d 8c24 82de 80de 5305 8912 5265     -1 
-    -1     -1     -1     -1     -1 8584 96f9 4fdd 
-5821 9971 5b9d 62b1 62a5 66b4 8c79 9c8d 
-7206 676f 7891 60b2 5351 5317 8f88 80cc 
-8d1d 94a1 500d 72c8 5907 60eb 7119 88ab 
-5954 82ef 672c 7b28 5d29 7ef7 752d 6cf5 
-8e66 8ff8 903c 9f3b 6bd4 9119 7b14 5f7c 
-78a7 84d6 853d 6bd5 6bd9 6bd6 5e01 5e87 
-75f9 95ed 655d 5f0a 5fc5 8f9f 58c1 81c2 
-907f 965b 97ad 8fb9 7f16 8d2c 6241 4fbf 
-53d8 535e 8fa8 8fa9 8fab 904d 6807 5f6a 
-8198 8868 9cd6 618b 522b 762a 5f6c 658c 
-6fd2 6ee8 5bbe 6448 5175 51b0 67c4 4e19 
-79c9 997c 70b3     -1     -1     -1     -1     -1 
-    -1 75c5 5e76 73bb 83e0 64ad 62e8 94b5 
-6ce2 535a 52c3 640f 94c2 7b94 4f2f 5e1b 
-8236 8116 818a 6e24 6cca 9a73 6355 535c 
-54fa 8865 57e0 4e0d 5e03 6b65 7c3f 90e8 
-6016 64e6 731c 88c1 6750 624d 8d22 776c 
-8e29 91c7 5f69 83dc 8521 9910 53c2 8695 
-6b8b 60ed 60e8 707f 82cd 8231 4ed3 6ca7 
-85cf 64cd 7cd9 69fd 66f9 8349 5395 7b56 
-4fa7 518c 6d4b 5c42 8e6d 63d2 53c9 832c 
-8336 67e5 78b4 643d 5bdf 5c94 5dee 8be7 
-62c6 67f4 8c7a 6400 63ba 8749 998b 8c17 
-7f20 94f2 4ea7 9610 98a4 660c 7316     -1 
-    -1     -1     -1     -1     -1 573a 5c1d 5e38 
-957f 507f 80a0 5382 655e 7545 5531 5021 
-8d85 6284 949e 671d 5632 6f6e 5de2 5435 
-7092 8f66 626f 64a4 63a3 5f7b 6f88 90f4 
-81e3 8fb0 5c18 6668 5ff1 6c89 9648 8d81 
-886c 6491 79f0 57ce 6a59 6210 5448 4e58 
-7a0b 60e9 6f84 8bda 627f 901e 9a8b 79e4 
-5403 75f4 6301 5319 6c60 8fdf 5f1b 9a70 
-803b 9f7f 4f88 5c3a 8d64 7fc5 65a5 70bd 
-5145 51b2 866b 5d07 5ba0 62bd 916c 7574 
-8e0c 7a20 6101 7b79 4ec7 7ef8 7785 4e11 
-81ed 521d 51fa 6a71 53a8 8e87 9504 96cf 
-6ec1 9664 695a     -1     -1     -1     -1     -1 
-    -1 7840 50a8 77d7 6410 89e6 5904 63e3 
-5ddd 7a7f 693d 4f20 8239 5598 4e32 75ae 
-7a97 5e62 5e8a 95ef 521b 5439 708a 6376 
-9524 5782 6625 693f 9187 5507 6df3 7eaf 
-8822 6233 7ef0 75b5 8328 78c1 96cc 8f9e 
-6148 74f7 8bcd 6b64 523a 8d50 6b21 806a 
-8471 56f1 5306 4ece 4e1b 51d1 7c97 918b 
-7c07 4fc3 8e7f 7be1 7a9c 6467 5d14 50ac 
-8106 7601 7cb9 6dec 7fe0 6751 5b58 5bf8 
-78cb 64ae 6413 63aa 632b 9519 642d 8fbe 
-7b54 7629 6253 5927 5446 6b79 50a3 6234 
-5e26 6b86 4ee3 8d37 888b 5f85 902e     -1 
-    -1     -1     -1     -1     -1 6020 803d 62c5 
-4e39 5355 90f8 63b8 80c6 65e6 6c2e 4f46 
-60ee 6de1 8bde 5f39 86cb 5f53 6321 515a 
-8361 6863 5200 6363 8e48 5012 5c9b 7977 
-5bfc 5230 7a3b 60bc 9053 76d7 5fb7 5f97 
-7684 8e6c 706f 767b 7b49 77aa 51f3 9093 
-5824 4f4e 6ef4 8fea 654c 7b1b 72c4 6da4 
-7fdf 5ae1 62b5 5e95 5730 8482 7b2c 5e1d 
-5f1f 9012 7f14 98a0 6382 6ec7 7898 70b9 
-5178 975b 57ab 7535 4f43 7538 5e97 60e6 
-5960 6dc0 6bbf 7889 53fc 96d5 51cb 5201 
-6389 540a 9493 8c03 8dcc 7239 789f 8776 
-8fed 8c0d 53e0     -1     -1     -1     -1     -1 
-    -1 4e01 76ef 53ee 9489 9876 9f0e 952d 
-5b9a 8ba2 4e22 4e1c 51ac 8463 61c2 52a8 
-680b 4f97 606b 51bb 6d1e 515c 6296 6597 
-9661 8c46 9017 75d8 90fd 7763 6bd2 728a 
-72ec 8bfb 5835 7779 8d4c 675c 9540 809a 
-5ea6 6e21 5992 7aef 77ed 953b 6bb5 65ad 
-7f0e 5806 5151 961f 5bf9 58a9 5428 8e72 
-6566 987f 56e4 949d 76fe 9041 6387 54c6 
-591a 593a 579b 8eb2 6735 8dfa 8235 5241 
-60f0 5815 86fe 5ce8 9e45 4fc4 989d 8bb9 
-5a25 6076 5384 627c 904f 9102 997f 6069 
-800c 513f 8033 5c14 9975 6d31 4e8c     -1 
-    -1     -1     -1     -1     -1 8d30 53d1 7f5a 
-7b4f 4f10 4e4f 9600 6cd5 73d0 85e9 5e06 
-756a 7ffb 6a0a 77fe 9492 7e41 51e1 70e6 
-53cd 8fd4 8303 8d29 72af 996d 6cdb 574a 
-82b3 65b9 80aa 623f 9632 59a8 4eff 8bbf 
-7eba 653e 83f2 975e 5561 98de 80a5 532a 
-8bfd 5420 80ba 5e9f 6cb8 8d39 82ac 915a 
-5429 6c1b 5206 7eb7 575f 711a 6c7e 7c89 
-594b 4efd 5fff 6124 7caa 4e30 5c01 67ab 
-8702 5cf0 950b 98ce 75af 70fd 9022 51af 
-7f1d 8bbd 5949 51e4 4f5b 5426 592b 6577 
-80a4 5b75 6276 62c2 8f90 5e45 6c1f 7b26 
-4f0f 4fd8 670d     -1     -1     -1     -1     -1 
-    -1 6d6e 6daa 798f 88b1 5f17 752b 629a 
-8f85 4fef 91dc 65a7 812f 8151 5e9c 8150 
-8d74 526f 8986 8d4b 590d 5085 4ed8 961c 
-7236 8179 8d1f 5bcc 8ba3 9644 5987 7f1a 
-5490 5676 560e 8be5 6539 6982 9499 76d6 
-6e89 5e72 7518 6746 67d1 7aff 809d 8d76 
-611f 79c6 6562 8d63 5188 521a 94a2 7f38 
-809b 7eb2 5c97 6e2f 6760 7bd9 768b 9ad8 
-818f 7f94 7cd5 641e 9550 7a3f 544a 54e5 
-6b4c 6401 6208 9e3d 80f3 7599 5272 9769 
-845b 683c 86e4 9601 9694 94ec 4e2a 5404 
-7ed9 6839 8ddf 8015 66f4 5e9a 7fb9     -1 
-    -1     -1     -1     -1     -1 57c2 803f 6897 
-5de5 653b 529f 606d 9f9a 4f9b 8eac 516c 
-5bab 5f13 5de9 6c5e 62f1 8d21 5171 94a9 
-52fe 6c9f 82df 72d7 57a2 6784 8d2d 591f 
-8f9c 83c7 5495 7b8d 4f30 6cbd 5b64 59d1 
-9f13 53e4 86ca 9aa8 8c37 80a1 6545 987e 
-56fa 96c7 522e 74dc 5250 5be1 6302 8902 
-4e56 62d0 602a 68fa 5173 5b98 51a0 89c2 
-7ba1 9986 7f50 60ef 704c 8d2f 5149 5e7f 
-901b 7470 89c4 572d 7845 5f52 9f9f 95fa 
-8f68 9b3c 8be1 7678 6842 67dc 8dea 8d35 
-523d 8f8a 6eda 68cd 9505 90ed 56fd 679c 
-88f9 8fc7 54c8     -1     -1     -1     -1     -1 
-    -1 9ab8 5b69 6d77 6c26 4ea5 5bb3 9a87 
-9163 61a8 90af 97e9 542b 6db5 5bd2 51fd 
-558a 7f55 7ff0 64bc 634d 65f1 61be 608d 
-710a 6c57 6c49 592f 676d 822a 58d5 568e 
-8c6a 6beb 90dd 597d 8017 53f7 6d69 5475 
-559d 8377 83cf 6838 79be 548c 4f55 5408 
-76d2 8c89 9602 6cb3 6db8 8d6b 8910 9e64 
-8d3a 563f 9ed1 75d5 5f88 72e0 6068 54fc 
-4ea8 6a2a 8861 6052 8f70 54c4 70d8 8679 
-9e3f 6d2a 5b8f 5f18 7ea2 5589 4faf 7334 
-543c 539a 5019 540e 547c 4e4e 5ffd 745a 
-58f6 846b 80e1 8774 72d0 7cca 6e56     -1 
-    -1     -1     -1     -1     -1 5f27 864e 552c 
-62a4 4e92 6caa 6237 82b1 54d7 534e 733e 
-6ed1 753b 5212 5316 8bdd 69d0 5f8a 6000 
-6dee 574f 6b22 73af 6853 8fd8 7f13 6362 
-60a3 5524 75ea 8c62 7115 6da3 5ba6 5e7b 
-8352 614c 9ec4 78fa 8757 7c27 7687 51f0 
-60f6 714c 6643 5e4c 604d 8c0e 7070 6325 
-8f89 5fbd 6062 86d4 56de 6bc1 6094 6167 
-5349 60e0 6666 8d3f 79fd 4f1a 70e9 6c47 
-8bb3 8bf2 7ed8 8364 660f 5a5a 9b42 6d51 
-6df7 8c41 6d3b 4f19 706b 83b7 6216 60d1 
-970d 8d27 7978 51fb 573e 57fa 673a 7578 
-7a3d 79ef 7b95     -1     -1     -1     -1     -1 
-    -1 808c 9965 8ff9 6fc0 8ba5 9e21 59ec 
-7ee9 7f09 5409 6781 68d8 8f91 7c4d 96c6 
-53ca 6025 75be 6c72 5373 5ac9 7ea7 6324 
-51e0 810a 5df1 84df 6280 5180 5b63 4f0e 
-796d 5242 60b8 6d4e 5bc4 5bc2 8ba1 8bb0 
-65e2 5fcc 9645 5993 7ee7 7eaa 5609 67b7 
-5939 4f73 5bb6 52a0 835a 988a 8d3e 7532 
-94be 5047 7a3c 4ef7 67b6 9a7e 5ac1 6b7c 
-76d1 575a 5c16 7b3a 95f4 714e 517c 80a9 
-8270 5978 7f04 8327 68c0 67ec 78b1 7877 
-62e3 6361 7b80 4fed 526a 51cf 8350 69db 
-9274 8df5 8d31 89c1 952e 7bad 4ef6     -1 
-    -1     -1     -1     -1     -1 5065 8230 5251 
-996f 6e10 6e85 6da7 5efa 50f5 59dc 5c06 
-6d46 6c5f 7586 848b 6868 5956 8bb2 5320 
-9171 964d 8549 6912 7901 7126 80f6 4ea4 
-90ca 6d47 9a84 5a07 56bc 6405 94f0 77eb 
-4fa5 811a 72e1 89d2 997a 7f34 7ede 527f 
-6559 9175 8f7f 8f83 53eb 7a96 63ed 63a5 
-7686 79f8 8857 9636 622a 52ab 8282 6854 
-6770 6377 776b 7aed 6d01 7ed3 89e3 59d0 
-6212 85c9 82a5 754c 501f 4ecb 75a5 8beb 
-5c4a 5dfe 7b4b 65a4 91d1 4eca 6d25 895f 
-7d27 9526 4ec5 8c28 8fdb 9773 664b 7981 
-8fd1 70ec 6d78     -1     -1     -1     -1     -1 
-    -1 5c3d 52b2 8346 5162 830e 775b 6676 
-9cb8 4eac 60ca 7cbe 7cb3 7ecf 4e95 8b66 
-666f 9888 9759 5883 656c 955c 5f84 75c9 
-9756 7adf 7ade 51c0 70af 7a98 63ea 7a76 
-7ea0 7396 97ed 4e45 7078 4e5d 9152 53a9 
-6551 65e7 81fc 8205 548e 5c31 759a 97a0 
-62d8 72d9 75bd 5c45 9a79 83ca 5c40 5480 
-77e9 4e3e 6cae 805a 62d2 636e 5de8 5177 
-8ddd 8e1e 952f 4ff1 53e5 60e7 70ac 5267 
-6350 9e43 5a1f 5026 7737 5377 7ee2 6485 
-652b 6289 6398 5014 7235 89c9 51b3 8bc0 
-7edd 5747 83cc 94a7 519b 541b 5cfb     -1 
-    -1     -1     -1     -1     -1 4fca 7ae3 6d5a 
-90e1 9a8f 5580 5496 5361 54af 5f00 63e9 
-6977 51ef 6168 520a 582a 52d8 574e 780d 
-770b 5eb7 6177 7ce0 625b 6297 4ea2 7095 
-8003 62f7 70e4 9760 5777 82db 67ef 68f5 
-78d5 9897 79d1 58f3 54b3 53ef 6e34 514b 
-523b 5ba2 8bfe 80af 5543 57a6 6073 5751 
-542d 7a7a 6050 5b54 63a7 62a0 53e3 6263 
-5bc7 67af 54ed 7a9f 82e6 9177 5e93 88e4 
-5938 57ae 630e 8de8 80ef 5757 7b77 4fa9 
-5feb 5bbd 6b3e 5321 7b50 72c2 6846 77ff 
-7736 65f7 51b5 4e8f 76d4 5cbf 7aa5 8475 
-594e 9b41 5080     -1     -1     -1     -1     -1 
-    -1 9988 6127 6e83 5764 6606 6346 56f0 
-62ec 6269 5ed3 9614 5783 62c9 5587 8721 
-814a 8fa3 5566 83b1 6765 8d56 84dd 5a6a 
-680f 62e6 7bee 9611 5170 6f9c 8c30 63fd 
-89c8 61d2 7f06 70c2 6ee5 7405 6994 72fc 
-5eca 90ce 6717 6d6a 635e 52b3 7262 8001 
-4f6c 59e5 916a 70d9 6d9d 52d2 4e50 96f7 
-956d 857e 78ca 7d2f 5121 5792 64c2 808b 
-7c7b 6cea 68f1 695e 51b7 5398 68a8 7281 
-9ece 7bf1 72f8 79bb 6f13 7406 674e 91cc 
-9ca4 793c 8389 8354 540f 6817 4e3d 5389 
-52b1 783e 5386 5229 5088 4f8b 4fd0     -1 
-    -1     -1     -1     -1     -1 75e2 7acb 7c92 
-6ca5 96b6 529b 7483 54e9 4fe9 8054 83b2 
-8fde 9570 5ec9 601c 6d9f 5e18 655b 8138 
-94fe 604b 70bc 7ec3 7cae 51c9 6881 7cb1 
-826f 4e24 8f86 91cf 667e 4eae 8c05 64a9 
-804a 50da 7597 71ce 5be5 8fbd 6f66 4e86 
-6482 9563 5ed6 6599 5217 88c2 70c8 52a3 
-730e 7433 6797 78f7 9716 4e34 90bb 9cde 
-6dcb 51db 8d41 541d 62ce 73b2 83f1 96f6 
-9f84 94c3 4f36 7f9a 51cc 7075 9675 5cad 
-9886 53e6 4ee4 6e9c 7409 69b4 786b 998f 
-7559 5218 7624 6d41 67f3 516d 9f99 804b 
-5499 7b3c 7abf     -1     -1     -1     -1     -1 
-    -1 9686 5784 62e2 9647 697c 5a04 6402 
-7bd3 6f0f 964b 82a6 5362 9885 5e90 7089 
-63b3 5364 864f 9c81 9e93 788c 9732 8def 
-8d42 9e7f 6f5e 7984 5f55 9646 622e 9a74 
-5415 94dd 4fa3 65c5 5c65 5c61 7f15 8651 
-6c2f 5f8b 7387 6ee4 7eff 5ce6 631b 5b6a 
-6ee6 5375 4e71 63a0 7565 62a1 8f6e 4f26 
-4ed1 6ca6 7eb6 8bba 841d 87ba 7f57 903b 
-9523 7ba9 9aa1 88f8 843d 6d1b 9a86 7edc 
-5988 9ebb 739b 7801 8682 9a6c 9a82 561b 
-5417 57cb 4e70 9ea6 5356 8fc8 8109 7792 
-9992 86ee 6ee1 8513 66fc 6162 6f2b     -1 
-    -1     -1     -1     -1     -1 8c29 8292 832b 
-76f2 6c13 5fd9 83bd 732b 8305 951a 6bdb 
-77db 94c6 536f 8302 5192 5e3d 8c8c 8d38 
-4e48 73ab 679a 6885 9176 9709 7164 6ca1 
-7709 5a92 9541 6bcf 7f8e 6627 5bd0 59b9 
-5a9a 95e8 95f7 4eec 840c 8499 6aac 76df 
-9530 731b 68a6 5b5f 772f 919a 9761 7cdc 
-8ff7 8c1c 5f25 7c73 79d8 89c5 6ccc 871c 
-5bc6 5e42 68c9 7720 7ef5 5195 514d 52c9 
-5a29 7f05 9762 82d7 63cf 7784 85d0 79d2 
-6e3a 5e99 5999 8511 706d 6c11 62bf 76bf 
-654f 60af 95fd 660e 879f 9e23 94ed 540d 
-547d 8c2c 6478     -1     -1     -1     -1     -1 
-    -1 6479 8611 6a21 819c 78e8 6469 9b54 
-62b9 672b 83ab 58a8 9ed8 6cab 6f20 5bde 
-964c 8c0b 725f 67d0 62c7 7261 4ea9 59c6 
-6bcd 5893 66ae 5e55 52df 6155 6728 76ee 
-7766 7267 7a46 62ff 54ea 5450 94a0 90a3 
-5a1c 7eb3 6c16 4e43 5976 8010 5948 5357 
-7537 96be 56ca 6320 8111 607c 95f9 6dd6 
-5462 9981 5185 5ae9 80fd 59ae 9713 502a 
-6ce5 5c3c 62df 4f60 533f 817b 9006 6eba 
-852b 62c8 5e74 78be 64b5 637b 5ff5 5a18 
-917f 9e1f 5c3f 634f 8042 5b7d 556e 954a 
-954d 6d85 60a8 67e0 72de 51dd 5b81     -1 
-    -1     -1     -1     -1     -1 62e7 6cde 725b 
-626d 94ae 7ebd 8113 6d53 519c 5f04 5974 
-52aa 6012 5973 6696 8650 759f 632a 61e6 
-7cef 8bfa 54e6 6b27 9e25 6bb4 85d5 5455 
-5076 6ca4 556a 8db4 722c 5e15 6015 7436 
-62cd 6392 724c 5f98 6e43 6d3e 6500 6f58 
-76d8 78d0 76fc 7554 5224 53db 4e53 5e9e 
-65c1 802a 80d6 629b 5486 5228 70ae 888d 
-8dd1 6ce1 5478 80da 57f9 88f4 8d54 966a 
-914d 4f69 6c9b 55b7 76c6 7830 62a8 70f9 
-6f8e 5f6d 84ec 68da 787c 7bf7 81a8 670b 
-9e4f 6367 78b0 576f 7812 9739 6279 62ab 
-5288 7435 6bd7     -1     -1     -1     -1     -1 
-    -1 5564 813e 75b2 76ae 5339 75de 50fb 
-5c41 8b6c 7bc7 504f 7247 9a97 98d8 6f02 
-74e2 7968 6487 77a5 62fc 9891 8d2b 54c1 
-8058 4e52 576a 82f9 840d 5e73 51ed 74f6 
-8bc4 5c4f 5761 6cfc 9887 5a46 7834 9b44 
-8feb 7c95 5256 6251 94fa 4ec6 8386 8461 
-83e9 84b2 57d4 6734 5703 666e 6d66 8c31 
-66dd 7011 671f 6b3a 6816 621a 59bb 4e03 
-51c4 6f06 67d2 6c8f 5176 68cb 5947 6b67 
-7566 5d0e 8110 9f50 65d7 7948 7941 9a91 
-8d77 5c82 4e5e 4f01 542f 5951 780c 5668 
-6c14 8fc4 5f03 6c7d 6ce3 8bab 6390     -1 
-    -1     -1     -1     -1     -1 6070 6d3d 7275 
-6266 948e 94c5 5343 8fc1 7b7e 4edf 8c26 
-4e7e 9ed4 94b1 94b3 524d 6f5c 9063 6d45 
-8c34 5811 5d4c 6b20 6b49 67aa 545b 8154 
-7f8c 5899 8537 5f3a 62a2 6a47 9539 6572 
-6084 6865 77a7 4e54 4fa8 5de7 9798 64ac 
-7fd8 5ced 4fcf 7a8d 5207 8304 4e14 602f 
-7a83 94a6 4fb5 4eb2 79e6 7434 52e4 82b9 
-64d2 79bd 5bdd 6c81 9752 8f7b 6c22 503e 
-537f 6e05 64ce 6674 6c30 60c5 9877 8bf7 
-5e86 743c 7a77 79cb 4e18 90b1 7403 6c42 
-56da 914b 6cc5 8d8b 533a 86c6 66f2 8eaf 
-5c48 9a71 6e20     -1     -1     -1     -1     -1 
-    -1 53d6 5a36 9f8b 8da3 53bb 5708 98a7 
-6743 919b 6cc9 5168 75ca 62f3 72ac 5238 
-529d 7f3a 7094 7638 5374 9e4a 69b7 786e 
-96c0 88d9 7fa4 7136 71c3 5189 67d3 74e4 
-58e4 6518 56b7 8ba9 9976 6270 7ed5 60f9 
-70ed 58ec 4ec1 4eba 5fcd 97e7 4efb 8ba4 
-5203 598a 7eab 6254 4ecd 65e5 620e 8338 
-84c9 8363 878d 7194 6eb6 5bb9 7ed2 5197 
-63c9 67d4 8089 8339 8815 5112 5b7a 5982 
-8fb1 4e73 6c5d 5165 8925 8f6f 962e 854a 
-745e 9510 95f0 6da6 82e5 5f31 6492 6d12 
-8428 816e 9cc3 585e 8d5b 4e09 53c1     -1 
-    -1     -1     -1     -1     -1 4f1e 6563 6851 
-55d3 4e27 6414 9a9a 626b 5ac2 745f 8272 
-6da9 68ee 50e7 838e 7802 6740 5239 6c99 
-7eb1 50bb 5565 715e 7b5b 6652 73ca 82eb 
-6749 5c71 5220 717d 886b 95ea 9655 64c5 
-8d61 81b3 5584 6c55 6247 7f2e 5892 4f24 
-5546 8d4f 664c 4e0a 5c1a 88f3 68a2 634e 
-7a0d 70e7 828d 52fa 97f6 5c11 54e8 90b5 
-7ecd 5962 8d4a 86c7 820c 820d 8d66 6444 
-5c04 6151 6d89 793e 8bbe 7837 7533 547b 
-4f38 8eab 6df1 5a20 7ec5 795e 6c88 5ba1 
-5a76 751a 80be 614e 6e17 58f0 751f 7525 
-7272 5347 7ef3     -1     -1     -1     -1     -1 
-    -1 7701 76db 5269 80dc 5723 5e08 5931 
-72ee 65bd 6e7f 8bd7 5c38 8671 5341 77f3 
-62fe 65f6 4ec0 98df 8680 5b9e 8bc6 53f2 
-77e2 4f7f 5c4e 9a76 59cb 5f0f 793a 58eb 
-4e16 67ff 4e8b 62ed 8a93 901d 52bf 662f 
-55dc 566c 9002 4ed5 4f8d 91ca 9970 6c0f 
-5e02 6043 5ba4 89c6 8bd5 6536 624b 9996 
-5b88 5bff 6388 552e 53d7 7626 517d 852c 
-67a2 68b3 6b8a 6292 8f93 53d4 8212 6dd1 
-758f 4e66 8d4e 5b70 719f 85af 6691 66d9 
-7f72 8700 9ecd 9f20 5c5e 672f 8ff0 6811 
-675f 620d 7ad6 5885 5eb6 6570 6f31     -1 
-    -1     -1     -1     -1     -1 6055 5237 800d 
-6454 8870 7529 5e05 6813 62f4 971c 53cc 
-723d 8c01 6c34 7761 7a0e 542e 77ac 987a 
-821c 8bf4 7855 6714 70c1 65af 6495 5636 
-601d 79c1 53f8 4e1d 6b7b 8086 5bfa 55e3 
-56db 4f3a 4f3c 9972 5df3 677e 8038 6002 
-9882 9001 5b8b 8bbc 8bf5 641c 8258 64de 
-55fd 82cf 9165 4fd7 7d20 901f 7c9f 50f3 
-5851 6eaf 5bbf 8bc9 8083 9178 849c 7b97 
-867d 968b 968f 7ee5 9ad3 788e 5c81 7a57 
-9042 96a7 795f 5b59 635f 7b0b 84d1 68ad 
-5506 7f29 7410 7d22 9501 6240 584c 4ed6 
-5b83 5979 5854     -1     -1     -1     -1     -1 
-    -1 736d 631e 8e4b 8e0f 80ce 82d4 62ac 
-53f0 6cf0 915e 592a 6001 6c70 574d 644a 
-8d2a 762b 6ee9 575b 6a80 75f0 6f6d 8c2d 
-8c08 5766 6bef 8892 78b3 63a2 53f9 70ad 
-6c64 5858 642a 5802 68e0 819b 5510 7cd6 
-5018 8eba 6dcc 8d9f 70eb 638f 6d9b 6ed4 
-7ee6 8404 6843 9003 6dd8 9676 8ba8 5957 
-7279 85e4 817e 75bc 8a8a 68af 5254 8e22 
-9511 63d0 9898 8e44 557c 4f53 66ff 568f 
-60d5 6d95 5243 5c49 5929 6dfb 586b 7530 
-751c 606c 8214 8146 6311 6761 8fe2 773a 
-8df3 8d34 94c1 5e16 5385 542c 70c3     -1 
-    -1     -1     -1     -1     -1 6c40 5ef7 505c 
-4ead 5ead 633a 8247 901a 6850 916e 77b3 
-540c 94dc 5f64 7ae5 6876 6345 7b52 7edf 
-75db 5077 6295 5934 900f 51f8 79c3 7a81 
-56fe 5f92 9014 6d82 5c60 571f 5410 5154 
-6e4d 56e2 63a8 9893 817f 8715 892a 9000 
-541e 5c6f 81c0 62d6 6258 8131 9e35 9640 
-9a6e 9a7c 692d 59a5 62d3 553e 6316 54c7 
-86d9 6d3c 5a03 74e6 889c 6b6a 5916 8c4c 
-5f2f 6e7e 73a9 987d 4e38 70f7 5b8c 7897 
-633d 665a 7696 60cb 5b9b 5a49 4e07 8155 
-6c6a 738b 4ea1 6789 7f51 5f80 65fa 671b 
-5fd8 5984 5a01     -1     -1     -1     -1     -1 
-    -1 5dcd 5fae 5371 97e6 8fdd 6845 56f4 
-552f 60df 4e3a 6f4d 7ef4 82c7 840e 59d4 
-4f1f 4f2a 5c3e 7eac 672a 851a 5473 754f 
-80c3 5582 9b4f 4f4d 6e2d 8c13 5c09 6170 
-536b 761f 6e29 868a 6587 95fb 7eb9 543b 
-7a33 7d0a 95ee 55e1 7fc1 74ee 631d 8717 
-6da1 7a9d 6211 65a1 5367 63e1 6c83 5deb 
-545c 94a8 4e4c 6c61 8bec 5c4b 65e0 829c 
-68a7 543e 5434 6bcb 6b66 4e94 6342 5348 
-821e 4f0d 4fae 575e 620a 96fe 6664 7269 
-52ff 52a1 609f 8bef 6614 7199 6790 897f 
-7852 77fd 6670 563b 5438 9521 727a     -1 
-    -1     -1     -1     -1     -1 7a00 606f 5e0c 
-6089 819d 5915 60dc 7184 70ef 6eaa 6c50 
-7280 6a84 88ad 5e2d 4e60 5ab3 559c 94e3 
-6d17 7cfb 9699 620f 7ec6 778e 867e 5323 
-971e 8f96 6687 5ce1 4fa0 72ed 4e0b 53a6 
-590f 5413 6380 9528 5148 4ed9 9c9c 7ea4 
-54b8 8d24 8854 8237 95f2 6d8e 5f26 5acc 
-663e 9669 73b0 732e 53bf 817a 9985 7fa1 
-5baa 9677 9650 7ebf 76f8 53a2 9576 9999 
-7bb1 8944 6e58 4e61 7fd4 7965 8be6 60f3 
-54cd 4eab 9879 5df7 6a61 50cf 5411 8c61 
-8427 785d 9704 524a 54ee 56a3 9500 6d88 
-5bb5 6dc6 6653     -1     -1     -1     -1     -1 
-    -1 5c0f 5b5d 6821 8096 5578 7b11 6548 
-6954 4e9b 6b47 874e 978b 534f 631f 643a 
-90aa 659c 80c1 8c10 5199 68b0 5378 87f9 
-61c8 6cc4 6cfb 8c22 5c51 85aa 82af 950c 
-6b23 8f9b 65b0 5ffb 5fc3 4fe1 8845 661f 
-8165 7329 60fa 5174 5211 578b 5f62 90a2 
-884c 9192 5e78 674f 6027 59d3 5144 51f6 
-80f8 5308 6c79 96c4 718a 4f11 4fee 7f9e 
-673d 55c5 9508 79c0 8896 7ee3 589f 620c 
-9700 865a 5618 987b 5f90 8bb8 84c4 9157 
-53d9 65ed 5e8f 755c 6064 7d6e 5a7f 7eea 
-7eed 8f69 55a7 5ba3 60ac 65cb 7384     -1 
-    -1     -1     -1     -1     -1 9009 7663 7729 
-7eda 9774 859b 5b66 7a74 96ea 8840 52cb 
-718f 5faa 65ec 8be2 5bfb 9a6f 5de1 6b89 
-6c5b 8bad 8baf 900a 8fc5 538b 62bc 9e26 
-9e2d 5440 4e2b 82bd 7259 869c 5d16 8859 
-6daf 96c5 54d1 4e9a 8bb6 7109 54bd 9609 
-70df 6df9 76d0 4e25 7814 8712 5ca9 5ef6 
-8a00 989c 960e 708e 6cbf 5944 63a9 773c 
-884d 6f14 8273 5830 71d5 538c 781a 96c1 
-5501 5f66 7130 5bb4 8c1a 9a8c 6b83 592e 
-9e2f 79e7 6768 626c 4f6f 75a1 7f8a 6d0b 
-9633 6c27 4ef0 75d2 517b 6837 6f3e 9080 
-8170 5996 7476     -1     -1     -1     -1     -1 
-    -1 6447 5c27 9065 7a91 8c23 59da 54ac 
-8200 836f 8981 8000 6930 564e 8036 7237 
-91ce 51b6 4e5f 9875 6396 4e1a 53f6 66f3 
-814b 591c 6db2 4e00 58f9 533b 63d6 94f1 
-4f9d 4f0a 8863 9890 5937 9057 79fb 4eea 
-80f0 7591 6c82 5b9c 59e8 5f5d 6905 8681 
-501a 5df2 4e59 77e3 4ee5 827a 6291 6613 
-9091 5c79 4ebf 5f79 81c6 9038 8084 75ab 
-4ea6 88d4 610f 6bc5 5fc6 4e49 76ca 6ea2 
-8be3 8bae 8c0a 8bd1 5f02 7ffc 7fcc 7ece 
-8335 836b 56e0 6bb7 97f3 9634 59fb 541f 
-94f6 6deb 5bc5 996e 5c39 5f15 9690     -1 
-    -1     -1     -1     -1     -1 5370 82f1 6a31 
-5a74 9e70 5e94 7f28 83b9 8424 8425 8367 
-8747 8fce 8d62 76c8 5f71 9896 786c 6620 
-54df 62e5 4f63 81c3 75c8 5eb8 96cd 8e0a 
-86f9 548f 6cf3 6d8c 6c38 607f 52c7 7528 
-5e7d 4f18 60a0 5fe7 5c24 7531 90ae 94c0 
-72b9 6cb9 6e38 9149 6709 53cb 53f3 4f51 
-91c9 8bf1 53c8 5e7c 8fc2 6de4 4e8e 76c2 
-6986 865e 611a 8206 4f59 4fde 903e 9c7c 
-6109 6e1d 6e14 9685 4e88 5a31 96e8 4e0e 
-5c7f 79b9 5b87 8bed 7fbd 7389 57df 828b 
-90c1 5401 9047 55bb 5cea 5fa1 6108 6b32 
-72f1 80b2 8a89     -1     -1     -1     -1     -1 
-    -1 6d74 5bd3 88d5 9884 8c6b 9a6d 9e33 
-6e0a 51a4 5143 57a3 8881 539f 63f4 8f95 
-56ed 5458 5706 733f 6e90 7f18 8fdc 82d1 
-613f 6028 9662 66f0 7ea6 8d8a 8dc3 94a5 
-5cb3 7ca4 6708 60a6 9605 8018 4e91 90e7 
-5300 9668 5141 8fd0 8574 915d 6655 97f5 
-5b55 531d 7838 6742 683d 54c9 707e 5bb0 
-8f7d 518d 5728 54b1 6512 6682 8d5e 8d43 
-810f 846c 906d 7cdf 51ff 85fb 67a3 65e9 
-6fa1 86a4 8e81 566a 9020 7682 7076 71e5 
-8d23 62e9 5219 6cfd 8d3c 600e 589e 618e 
-66fe 8d60 624e 55b3 6e23 672d 8f67     -1 
-    -1     -1     -1     -1     -1 94e1 95f8 7728 
-6805 69a8 548b 4e4d 70b8 8bc8 6458 658b 
-5b85 7a84 503a 5be8 77bb 6be1 8a79 7c98 
-6cbe 76cf 65a9 8f97 5d2d 5c55 8638 6808 
-5360 6218 7ad9 6e5b 7efd 6a1f 7ae0 5f70 
-6f33 5f20 638c 6da8 6756 4e08 5e10 8d26 
-4ed7 80c0 7634 969c 62db 662d 627e 6cbc 
-8d75 7167 7f69 5146 8087 53ec 906e 6298 
-54f2 86f0 8f99 8005 9517 8517 8fd9 6d59 
-73cd 659f 771f 7504 7827 81fb 8d1e 9488 
-4fa6 6795 75b9 8bca 9707 632f 9547 9635 
-84b8 6323 7741 5f81 72f0 4e89 6014 6574 
-62ef 6b63 653f     -1     -1     -1     -1     -1 
-    -1 5e27 75c7 90d1 8bc1 829d 679d 652f 
-5431 8718 77e5 80a2 8102 6c41 4e4b 7ec7 
-804c 76f4 690d 6b96 6267 503c 4f84 5740 
-6307 6b62 8dbe 53ea 65e8 7eb8 5fd7 631a 
-63b7 81f3 81f4 7f6e 5e1c 5cd9 5236 667a 
-79e9 7a1a 8d28 7099 75d4 6ede 6cbb 7a92 
-4e2d 76c5 5fe0 949f 8877 7ec8 79cd 80bf 
-91cd 4ef2 4f17 821f 5468 5dde 6d32 8bcc 
-7ca5 8f74 8098 5e1a 5492 76b1 5b99 663c 
-9aa4 73e0 682a 86db 6731 732a 8bf8 8bdb 
-9010 7af9 70db 716e 62c4 77a9 5631 4e3b 
-8457 67f1 52a9 86c0 8d2e 94f8 7b51     -1 
-    -1     -1     -1     -1     -1 4f4f 6ce8 795d 
-9a7b 6293 722a 62fd 4e13 7816 8f6c 64b0 
-8d5a 7bc6 6869 5e84 88c5 5986 649e 58ee 
-72b6 690e 9525 8ffd 8d58 5760 7f00 8c06 
-51c6 6349 62d9 5353 684c 7422 8301 914c 
-5544 7740 707c 6d4a 5179 54a8 8d44 59ff 
-6ecb 6dc4 5b5c 7d2b 4ed4 7c7d 6ed3 5b50 
-81ea 6e0d 5b57 9b03 68d5 8e2a 5b97 7efc 
-603b 7eb5 90b9 8d70 594f 63cd 79df 8db3 
-5352 65cf 7956 8bc5 963b 7ec4 94bb 7e82 
-5634 9189 6700 7f6a 5c0a 9075 6628 5de6 
-4f50 67de 505a 4f5c 5750 5ea7     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 4e8d 4e0c 5140 4e10 5eff 5345 4e15 
-4e98 4e1e 9b32 5b6c 5669 4e28 79ba 4e3f 
-5315 4e47 592d 723b 536e 6c10 56df 80e4 
-9997 6bd3 777e 9f17 4e36 4e9f 9f10 4e5c 
-4e69 4e93 8288 5b5b 556c 560f 4ec4 538d 
-539d 53a3 53a5 53ae 9765 8d5d 531a 53f5 
-5326 532e 533e 8d5c 5366 5363 5202 5208 
-520e 522d 5233 523f 5240 524c 525e 5261 
-525c 84af 527d 5282 5281 5290 5293 5182 
-7f54 4ebb 4ec3 4ec9 4ec2 4ee8 4ee1 4eeb 
-4ede 4f1b 4ef3 4f22 4f64 4ef5 4f25 4f27 
-4f09 4f2b 4f5e 4f67 6538 4f5a 4f5d     -1 
-    -1     -1     -1     -1     -1 4f5f 4f57 4f32 
-4f3d 4f76 4f74 4f91 4f89 4f83 4f8f 4f7e 
-4f7b 4faa 4f7c 4fac 4f94 4fe6 4fe8 4fea 
-4fc5 4fda 4fe3 4fdc 4fd1 4fdf 4ff8 5029 
-504c 4ff3 502c 500f 502e 502d 4ffe 501c 
-500c 5025 5028 507e 5043 5055 5048 504e 
-506c 507b 50a5 50a7 50a9 50ba 50d6 5106 
-50ed 50ec 50e6 50ee 5107 510b 4edd 6c3d 
-4f58 4f65 4fce 9fa0 6c46 7c74 516e 5dfd 
-9ec9 9998 5181 5914 52f9 530d 8a07 5310 
-51eb 5919 5155 4ea0 5156 4eb3 886e 88a4 
-4eb5 8114 88d2 7980 5b34 8803 7fb8 51ab 
-51b1 51bd 51bc     -1     -1     -1     -1     -1 
-    -1 51c7 5196 51a2 51a5 8ba0 8ba6 8ba7 
-8baa 8bb4 8bb5 8bb7 8bc2 8bc3 8bcb 8bcf 
-8bce 8bd2 8bd3 8bd4 8bd6 8bd8 8bd9 8bdc 
-8bdf 8be0 8be4 8be8 8be9 8bee 8bf0 8bf3 
-8bf6 8bf9 8bfc 8bff 8c00 8c02 8c04 8c07 
-8c0c 8c0f 8c11 8c12 8c14 8c15 8c16 8c19 
-8c1b 8c18 8c1d 8c1f 8c20 8c21 8c25 8c27 
-8c2a 8c2b 8c2e 8c2f 8c32 8c33 8c35 8c36 
-5369 537a 961d 9622 9621 9631 962a 963d 
-963c 9642 9649 9654 965f 9667 966c 9672 
-9674 9688 968d 9697 96b0 9097 909b 909d 
-9099 90ac 90a1 90b4 90b3 90b6 90ba     -1 
-    -1     -1     -1     -1     -1 90b8 90b0 90cf 
-90c5 90be 90d0 90c4 90c7 90d3 90e6 90e2 
-90dc 90d7 90db 90eb 90ef 90fe 9104 9122 
-911e 9123 9131 912f 9139 9143 9146 520d 
-5942 52a2 52ac 52ad 52be 54ff 52d0 52d6 
-52f0 53df 71ee 77cd 5ef4 51f5 51fc 9b2f 
-53b6 5f01 755a 5def 574c 57a9 57a1 587e 
-58bc 58c5 58d1 5729 572c 572a 5733 5739 
-572e 572f 575c 573b 5742 5769 5785 576b 
-5786 577c 577b 5768 576d 5776 5773 57ad 
-57a4 578c 57b2 57cf 57a7 57b4 5793 57a0 
-57d5 57d8 57da 57d9 57d2 57b8 57f4 57ef 
-57f8 57e4 57dd     -1     -1     -1     -1     -1 
-    -1 580b 580d 57fd 57ed 5800 581e 5819 
-5844 5820 5865 586c 5881 5889 589a 5880 
-99a8 9f19 61ff 8279 827d 827f 828f 828a 
-82a8 8284 828e 8291 8297 8299 82ab 82b8 
-82be 82b0 82c8 82ca 82e3 8298 82b7 82ae 
-82cb 82cc 82c1 82a9 82b4 82a1 82aa 829f 
-82c4 82ce 82a4 82e1 8309 82f7 82e4 830f 
-8307 82dc 82f4 82d2 82d8 830c 82fb 82d3 
-8311 831a 8306 8314 8315 82e0 82d5 831c 
-8351 835b 835c 8308 8392 833c 8334 8331 
-839b 835e 832f 834f 8347 8343 835f 8340 
-8317 8360 832d 833a 8333 8366 8365     -1 
-    -1     -1     -1     -1     -1 8368 831b 8369 
-836c 836a 836d 836e 83b0 8378 83b3 83b4 
-83a0 83aa 8393 839c 8385 837c 83b6 83a9 
-837d 83b8 837b 8398 839e 83a8 83ba 83bc 
-83c1 8401 83e5 83d8 5807 8418 840b 83dd 
-83fd 83d6 841c 8438 8411 8406 83d4 83df 
-840f 8403 83f8 83f9 83ea 83c5 83c0 8426 
-83f0 83e1 845c 8451 845a 8459 8473 8487 
-8488 847a 8489 8478 843c 8446 8469 8476 
-848c 848e 8431 846d 84c1 84cd 84d0 84e6 
-84bd 84d3 84ca 84bf 84ba 84e0 84a1 84b9 
-84b4 8497 84e5 84e3 850c 750d 8538 84f0 
-8539 851f 853a     -1     -1     -1     -1     -1 
-    -1 8556 853b 84ff 84fc 8559 8548 8568 
-8564 855e 857a 77a2 8543 8572 857b 85a4 
-85a8 8587 858f 8579 85ae 859c 8585 85b9 
-85b7 85b0 85d3 85c1 85dc 85ff 8627 8605 
-8629 8616 863c 5efe 5f08 593c 5941 8037 
-5955 595a 5958 530f 5c22 5c25 5c2c 5c34 
-624c 626a 629f 62bb 62ca 62da 62d7 62ee 
-6322 62f6 6339 634b 6343 63ad 63f6 6371 
-637a 638e 63b4 636d 63ac 638a 6369 63ae 
-63bc 63f2 63f8 63e0 63ff 63c4 63de 63ce 
-6452 63c6 63be 6445 6441 640b 641b 6420 
-640c 6426 6421 645e 6484 646d 6496     -1 
-    -1     -1     -1     -1     -1 647a 64b7 64b8 
-6499 64ba 64c0 64d0 64d7 64e4 64e2 6509 
-6525 652e 5f0b 5fd2 7519 5f11 535f 53f1 
-53fd 53e9 53e8 53fb 5412 5416 5406 544b 
-5452 5453 5454 5456 5443 5421 5457 5459 
-5423 5432 5482 5494 5477 5471 5464 549a 
-549b 5484 5476 5466 549d 54d0 54ad 54c2 
-54b4 54d2 54a7 54a6 54d3 54d4 5472 54a3 
-54d5 54bb 54bf 54cc 54d9 54da 54dc 54a9 
-54aa 54a4 54dd 54cf 54de 551b 54e7 5520 
-54fd 5514 54f3 5522 5523 550f 5511 5527 
-552a 5567 558f 55b5 5549 556d 5541 5555 
-553f 5550 553c     -1     -1     -1     -1     -1 
-    -1 5537 5556 5575 5576 5577 5533 5530 
-555c 558b 55d2 5583 55b1 55b9 5588 5581 
-559f 557e 55d6 5591 557b 55df 55bd 55be 
-5594 5599 55ea 55f7 55c9 561f 55d1 55eb 
-55ec 55d4 55e6 55dd 55c4 55ef 55e5 55f2 
-55f3 55cc 55cd 55e8 55f5 55e4 8f94 561e 
-5608 560c 5601 5624 5623 55fe 5600 5627 
-562d 5658 5639 5657 562c 564d 5662 5659 
-565c 564c 5654 5686 5664 5671 566b 567b 
-567c 5685 5693 56af 56d4 56d7 56dd 56e1 
-56f5 56eb 56f9 56ff 5704 570a 5709 571c 
-5e0f 5e19 5e14 5e11 5e31 5e3b 5e3c     -1 
-    -1     -1     -1     -1     -1 5e37 5e44 5e54 
-5e5b 5e5e 5e61 5c8c 5c7a 5c8d 5c90 5c96 
-5c88 5c98 5c99 5c91 5c9a 5c9c 5cb5 5ca2 
-5cbd 5cac 5cab 5cb1 5ca3 5cc1 5cb7 5cc4 
-5cd2 5ce4 5ccb 5ce5 5d02 5d03 5d27 5d26 
-5d2e 5d24 5d1e 5d06 5d1b 5d58 5d3e 5d34 
-5d3d 5d6c 5d5b 5d6f 5d5d 5d6b 5d4b 5d4a 
-5d69 5d74 5d82 5d99 5d9d 8c73 5db7 5dc5 
-5f73 5f77 5f82 5f87 5f89 5f8c 5f95 5f99 
-5f9c 5fa8 5fad 5fb5 5fbc 8862 5f61 72ad 
-72b0 72b4 72b7 72b8 72c3 72c1 72ce 72cd 
-72d2 72e8 72ef 72e9 72f2 72f4 72f7 7301 
-72f3 7303 72fa     -1     -1     -1     -1     -1 
-    -1 72fb 7317 7313 7321 730a 731e 731d 
-7315 7322 7339 7325 732c 7338 7331 7350 
-734d 7357 7360 736c 736f 737e 821b 5925 
-98e7 5924 5902 9963 9967 9968 9969 996a 
-996b 996c 9974 9977 997d 9980 9984 9987 
-998a 998d 9990 9991 9993 9994 9995 5e80 
-5e91 5e8b 5e96 5ea5 5ea0 5eb9 5eb5 5ebe 
-5eb3 8d53 5ed2 5ed1 5edb 5ee8 5eea 81ba 
-5fc4 5fc9 5fd6 5fcf 6003 5fee 6004 5fe1 
-5fe4 5ffe 6005 6006 5fea 5fed 5ff8 6019 
-6035 6026 601b 600f 600d 6029 602b 600a 
-603f 6021 6078 6079 607b 607a 6042     -1 
-    -1     -1     -1     -1     -1 606a 607d 6096 
-609a 60ad 609d 6083 6092 608c 609b 60ec 
-60bb 60b1 60dd 60d8 60c6 60da 60b4 6120 
-6126 6115 6123 60f4 6100 610e 612b 614a 
-6175 61ac 6194 61a7 61b7 61d4 61f5 5fdd 
-96b3 95e9 95eb 95f1 95f3 95f5 95f6 95fc 
-95fe 9603 9604 9606 9608 960a 960b 960c 
-960d 960f 9612 9615 9616 9617 9619 961a 
-4e2c 723f 6215 6c35 6c54 6c5c 6c4a 6ca3 
-6c85 6c90 6c94 6c8c 6c68 6c69 6c74 6c76 
-6c86 6ca9 6cd0 6cd4 6cad 6cf7 6cf8 6cf1 
-6cd7 6cb2 6ce0 6cd6 6cfa 6ceb 6cee 6cb1 
-6cd3 6cef 6cfe     -1     -1     -1     -1     -1 
-    -1 6d39 6d27 6d0c 6d43 6d48 6d07 6d04 
-6d19 6d0e 6d2b 6d4d 6d2e 6d35 6d1a 6d4f 
-6d52 6d54 6d33 6d91 6d6f 6d9e 6da0 6d5e 
-6d93 6d94 6d5c 6d60 6d7c 6d63 6e1a 6dc7 
-6dc5 6dde 6e0e 6dbf 6de0 6e11 6de6 6ddd 
-6dd9 6e16 6dab 6e0c 6dae 6e2b 6e6e 6e4e 
-6e6b 6eb2 6e5f 6e86 6e53 6e54 6e32 6e25 
-6e44 6edf 6eb1 6e98 6ee0 6f2d 6ee2 6ea5 
-6ea7 6ebd 6ebb 6eb7 6ed7 6eb4 6ecf 6e8f 
-6ec2 6e9f 6f62 6f46 6f47 6f24 6f15 6ef9 
-6f2f 6f36 6f4b 6f74 6f2a 6f09 6f29 6f89 
-6f8d 6f8c 6f78 6f72 6f7c 6f7a 6fd1     -1 
-    -1     -1     -1     -1     -1 6fc9 6fa7 6fb9 
-6fb6 6fc2 6fe1 6fee 6fde 6fe0 6fef 701a 
-7023 701b 7039 7035 704f 705e 5b80 5b84 
-5b95 5b93 5ba5 5bb8 752f 9a9e 6434 5be4 
-5bee 8930 5bf0 8e47 8b07 8fb6 8fd3 8fd5 
-8fe5 8fee 8fe4 8fe9 8fe6 8ff3 8fe8 9005 
-9004 900b 9026 9011 900d 9016 9021 9035 
-9036 902d 902f 9044 9051 9052 9050 9068 
-9058 9062 905b 66b9 9074 907d 9082 9088 
-9083 908b 5f50 5f57 5f56 5f58 5c3b 54ab 
-5c50 5c59 5b71 5c63 5c66 7fbc 5f2a 5f29 
-5f2d 8274 5f3c 9b3b 5c6e 5981 5983 598d 
-59a9 59aa 59a3     -1     -1     -1     -1     -1 
-    -1 5997 59ca 59ab 599e 59a4 59d2 59b2 
-59af 59d7 59be 5a05 5a06 59dd 5a08 59e3 
-59d8 59f9 5a0c 5a09 5a32 5a34 5a11 5a23 
-5a13 5a40 5a67 5a4a 5a55 5a3c 5a62 5a75 
-80ec 5aaa 5a9b 5a77 5a7a 5abe 5aeb 5ab2 
-5ad2 5ad4 5ab8 5ae0 5ae3 5af1 5ad6 5ae6 
-5ad8 5adc 5b09 5b17 5b16 5b32 5b37 5b40 
-5c15 5c1c 5b5a 5b65 5b73 5b51 5b53 5b62 
-9a75 9a77 9a78 9a7a 9a7f 9a7d 9a80 9a81 
-9a85 9a88 9a8a 9a90 9a92 9a93 9a96 9a98 
-9a9b 9a9c 9a9d 9a9f 9aa0 9aa2 9aa3 9aa5 
-9aa7 7e9f 7ea1 7ea3 7ea5 7ea8 7ea9     -1 
-    -1     -1     -1     -1     -1 7ead 7eb0 7ebe 
-7ec0 7ec1 7ec2 7ec9 7ecb 7ecc 7ed0 7ed4 
-7ed7 7edb 7ee0 7ee1 7ee8 7eeb 7eee 7eef 
-7ef1 7ef2 7f0d 7ef6 7efa 7efb 7efe 7f01 
-7f02 7f03 7f07 7f08 7f0b 7f0c 7f0f 7f11 
-7f12 7f17 7f19 7f1c 7f1b 7f1f 7f21 7f22 
-7f23 7f24 7f25 7f26 7f27 7f2a 7f2b 7f2c 
-7f2d 7f2f 7f30 7f31 7f32 7f33 7f35 5e7a 
-757f 5ddb 753e 9095 738e 7391 73ae 73a2 
-739f 73cf 73c2 73d1 73b7 73b3 73c0 73c9 
-73c8 73e5 73d9 987c 740a 73e9 73e7 73de 
-73ba 73f2 740f 742a 745b 7426 7425 7428 
-7430 742e 742c     -1     -1     -1     -1     -1 
-    -1 741b 741a 7441 745c 7457 7455 7459 
-7477 746d 747e 749c 748e 7480 7481 7487 
-748b 749e 74a8 74a9 7490 74a7 74d2 74ba 
-97ea 97eb 97ec 674c 6753 675e 6748 6769 
-67a5 6787 676a 6773 6798 67a7 6775 67a8 
-679e 67ad 678b 6777 677c 67f0 6809 67d8 
-680a 67e9 67b0 680c 67d9 67b5 67da 67b3 
-67dd 6800 67c3 67b8 67e2 680e 67c1 67fd 
-6832 6833 6860 6861 684e 6862 6844 6864 
-6883 681d 6855 6866 6841 6867 6840 683e 
-684a 6849 6829 68b5 688f 6874 6877 6893 
-686b 68c2 696e 68fc 691f 6920 68f9     -1 
-    -1     -1     -1     -1     -1 6924 68f0 690b 
-6901 6957 68e3 6910 6971 6939 6960 6942 
-695d 6984 696b 6980 6998 6978 6934 69cc 
-6987 6988 69ce 6989 6966 6963 6979 699b 
-69a7 69bb 69ab 69ad 69d4 69b1 69c1 69ca 
-69df 6995 69e0 698d 69ff 6a2f 69ed 6a17 
-6a18 6a65 69f2 6a44 6a3e 6aa0 6a50 6a5b 
-6a35 6a8e 6a79 6a3d 6a28 6a58 6a7c 6a91 
-6a90 6aa9 6a97 6aab 7337 7352 6b81 6b82 
-6b87 6b84 6b92 6b93 6b8d 6b9a 6b9b 6ba1 
-6baa 8f6b 8f6d 8f71 8f72 8f73 8f75 8f76 
-8f78 8f77 8f79 8f7a 8f7c 8f7e 8f81 8f82 
-8f84 8f87 8f8b     -1     -1     -1     -1     -1 
-    -1 8f8d 8f8e 8f8f 8f98 8f9a 8ece 620b 
-6217 621b 621f 6222 6221 6225 6224 622c 
-81e7 74ef 74f4 74ff 750f 7511 7513 6534 
-65ee 65ef 65f0 660a 6619 6772 6603 6615 
-6600 7085 66f7 661d 6634 6631 6636 6635 
-8006 665f 6654 6641 664f 6656 6661 6657 
-6677 6684 668c 66a7 669d 66be 66db 66dc 
-66e6 66e9 8d32 8d33 8d36 8d3b 8d3d 8d40 
-8d45 8d46 8d48 8d49 8d47 8d4d 8d55 8d59 
-89c7 89ca 89cb 89cc 89ce 89cf 89d0 89d1 
-726e 729f 725d 7266 726f 727e 727f 7284 
-728b 728d 728f 7292 6308 6332 63b0     -1 
-    -1     -1     -1     -1     -1 643f 64d8 8004 
-6bea 6bf3 6bfd 6bf5 6bf9 6c05 6c07 6c06 
-6c0d 6c15 6c18 6c19 6c1a 6c21 6c29 6c24 
-6c2a 6c32 6535 6555 656b 724d 7252 7256 
-7230 8662 5216 809f 809c 8093 80bc 670a 
-80bd 80b1 80ab 80ad 80b4 80b7 80e7 80e8 
-80e9 80ea 80db 80c2 80c4 80d9 80cd 80d7 
-6710 80dd 80eb 80f1 80f4 80ed 810d 810e 
-80f2 80fc 6715 8112 8c5a 8136 811e 812c 
-8118 8132 8148 814c 8153 8174 8159 815a 
-8171 8160 8169 817c 817d 816d 8167 584d 
-5ab5 8188 8182 8191 6ed5 81a3 81aa 81cc 
-6726 81ca 81bb     -1     -1     -1     -1     -1 
-    -1 81c1 81a6 6b24 6b37 6b39 6b43 6b46 
-6b59 98d1 98d2 98d3 98d5 98d9 98da 6bb3 
-5f40 6bc2 89f3 6590 9f51 6593 65bc 65c6 
-65c4 65c3 65cc 65ce 65d2 65d6 7080 709c 
-7096 709d 70bb 70c0 70b7 70ab 70b1 70e8 
-70ca 7110 7113 7116 712f 7131 7173 715c 
-7168 7145 7172 714a 7178 717a 7198 71b3 
-71b5 71a8 71a0 71e0 71d4 71e7 71f9 721d 
-7228 706c 7118 7166 71b9 623e 623d 6243 
-6248 6249 793b 7940 7946 7949 795b 795c 
-7953 795a 7962 7957 7960 796f 7967 797a 
-7985 798a 799a 79a7 79b3 5fd1 5fd0     -1 
-    -1     -1     -1     -1     -1 603c 605d 605a 
-6067 6041 6059 6063 60ab 6106 610d 615d 
-61a9 619d 61cb 61d1 6206 8080 807f 6c93 
-6cf6 6dfc 77f6 77f8 7800 7809 7817 7818 
-7811 65ab 782d 781c 781d 7839 783a 783b 
-781f 783c 7825 782c 7823 7829 784e 786d 
-7856 7857 7826 7850 7847 784c 786a 789b 
-7893 789a 7887 789c 78a1 78a3 78b2 78b9 
-78a5 78d4 78d9 78c9 78ec 78f2 7905 78f4 
-7913 7924 791e 7934 9f9b 9ef9 9efb 9efc 
-76f1 7704 770d 76f9 7707 7708 771a 7722 
-7719 772d 7726 7735 7738 7750 7751 7747 
-7743 775a 7768     -1     -1     -1     -1     -1 
-    -1 7762 7765 777f 778d 777d 7780 778c 
-7791 779f 77a0 77b0 77b5 77bd 753a 7540 
-754e 754b 7548 755b 7572 7579 7583 7f58 
-7f61 7f5f 8a48 7f68 7f74 7f71 7f79 7f81 
-7f7e 76cd 76e5 8832 9485 9486 9487 948b 
-948a 948c 948d 948f 9490 9494 9497 9495 
-949a 949b 949c 94a3 94a4 94ab 94aa 94ad 
-94ac 94af 94b0 94b2 94b4 94b6 94b7 94b8 
-94b9 94ba 94bc 94bd 94bf 94c4 94c8 94c9 
-94ca 94cb 94cc 94cd 94ce 94d0 94d1 94d2 
-94d5 94d6 94d7 94d9 94d8 94db 94de 94df 
-94e0 94e2 94e4 94e5 94e7 94e8 94ea     -1 
-    -1     -1     -1     -1     -1 94e9 94eb 94ee 
-94ef 94f3 94f4 94f5 94f7 94f9 94fc 94fd 
-94ff 9503 9502 9506 9507 9509 950a 950d 
-950e 950f 9512 9513 9514 9515 9516 9518 
-951b 951d 951e 951f 9522 952a 952b 9529 
-952c 9531 9532 9534 9536 9537 9538 953c 
-953e 953f 9542 9535 9544 9545 9546 9549 
-954c 954e 954f 9552 9553 9554 9556 9557 
-9558 9559 955b 955e 955f 955d 9561 9562 
-9564 9565 9566 9567 9568 9569 956a 956b 
-956c 956f 9571 9572 9573 953a 77e7 77ec 
-96c9 79d5 79ed 79e3 79eb 7a06 5d47 7a03 
-7a02 7a1e 7a14     -1     -1     -1     -1     -1 
-    -1 7a39 7a37 7a51 9ecf 99a5 7a70 7688 
-768e 7693 7699 76a4 74de 74e0 752c 9e20 
-9e22 9e28 9e29 9e2a 9e2b 9e2c 9e32 9e31 
-9e36 9e38 9e37 9e39 9e3a 9e3e 9e41 9e42 
-9e44 9e46 9e47 9e48 9e49 9e4b 9e4c 9e4e 
-9e51 9e55 9e57 9e5a 9e5b 9e5c 9e5e 9e63 
-9e66 9e67 9e68 9e69 9e6a 9e6b 9e6c 9e71 
-9e6d 9e73 7592 7594 7596 75a0 759d 75ac 
-75a3 75b3 75b4 75b8 75c4 75b1 75b0 75c3 
-75c2 75d6 75cd 75e3 75e8 75e6 75e4 75eb 
-75e7 7603 75f1 75fc 75ff 7610 7600 7605 
-760c 7617 760a 7625 7618 7615 7619     -1 
-    -1     -1     -1     -1     -1 761b 763c 7622 
-7620 7640 762d 7630 763f 7635 7643 763e 
-7633 764d 765e 7654 765c 7656 766b 766f 
-7fca 7ae6 7a78 7a79 7a80 7a86 7a88 7a95 
-7aa6 7aa0 7aac 7aa8 7aad 7ab3 8864 8869 
-8872 887d 887f 8882 88a2 88c6 88b7 88bc 
-88c9 88e2 88ce 88e3 88e5 88f1 891a 88fc 
-88e8 88fe 88f0 8921 8919 8913 891b 890a 
-8934 892b 8936 8941 8966 897b 758b 80e5 
-76b2 76b4 77dc 8012 8014 8016 801c 8020 
-8022 8025 8026 8027 8029 8028 8031 800b 
-8035 8043 8046 804d 8052 8069 8071 8983 
-9878 9880 9883     -1     -1     -1     -1     -1 
-    -1 9889 988c 988d 988f 9894 989a 989b 
-989e 989f 98a1 98a2 98a5 98a6 864d 8654 
-866c 866e 867f 867a 867c 867b 86a8 868d 
-868b 86ac 869d 86a7 86a3 86aa 8693 86a9 
-86b6 86c4 86b5 86ce 86b0 86ba 86b1 86af 
-86c9 86cf 86b4 86e9 86f1 86f2 86ed 86f3 
-86d0 8713 86de 86f4 86df 86d8 86d1 8703 
-8707 86f8 8708 870a 870d 8709 8723 873b 
-871e 8725 872e 871a 873e 8748 8734 8731 
-8729 8737 873f 8782 8722 877d 877e 877b 
-8760 8770 874c 876e 878b 8753 8763 877c 
-8764 8759 8765 8793 87af 87a8 87d2     -1 
-    -1     -1     -1     -1     -1 87c6 8788 8785 
-87ad 8797 8783 87ab 87e5 87ac 87b5 87b3 
-87cb 87d3 87bd 87d1 87c0 87ca 87db 87ea 
-87e0 87ee 8816 8813 87fe 880a 881b 8821 
-8839 883c 7f36 7f42 7f44 7f45 8210 7afa 
-7afd 7b08 7b03 7b04 7b15 7b0a 7b2b 7b0f 
-7b47 7b38 7b2a 7b19 7b2e 7b31 7b20 7b25 
-7b24 7b33 7b3e 7b1e 7b58 7b5a 7b45 7b75 
-7b4c 7b5d 7b60 7b6e 7b7b 7b62 7b72 7b71 
-7b90 7ba6 7ba7 7bb8 7bac 7b9d 7ba8 7b85 
-7baa 7b9c 7ba2 7bab 7bb4 7bd1 7bc1 7bcc 
-7bdd 7bda 7be5 7be6 7bea 7c0c 7bfe 7bfc 
-7c0f 7c16 7c0b     -1     -1     -1     -1     -1 
-    -1 7c1f 7c2a 7c26 7c38 7c41 7c40 81fe 
-8201 8202 8204 81ec 8844 8221 8222 8223 
-822d 822f 8228 822b 8238 823b 8233 8234 
-823e 8244 8249 824b 824f 825a 825f 8268 
-887e 8885 8888 88d8 88df 895e 7f9d 7f9f 
-7fa7 7faf 7fb0 7fb2 7c7c 6549 7c91 7c9d 
-7c9c 7c9e 7ca2 7cb2 7cbc 7cbd 7cc1 7cc7 
-7ccc 7ccd 7cc8 7cc5 7cd7 7ce8 826e 66a8 
-7fbf 7fce 7fd5 7fe5 7fe1 7fe6 7fe9 7fee 
-7ff3 7cf8 7d77 7da6 7dae 7e47 7e9b 9eb8 
-9eb4 8d73 8d84 8d94 8d91 8db1 8d67 8d6d 
-8c47 8c49 914a 9150 914e 914f 9164     -1 
-    -1     -1     -1     -1     -1 9162 9161 9170 
-9169 916f 917d 917e 9172 9174 9179 918c 
-9185 9190 918d 9191 91a2 91a3 91aa 91ad 
-91ae 91af 91b5 91b4 91ba 8c55 9e7e 8db8 
-8deb 8e05 8e59 8e69 8db5 8dbf 8dbc 8dba 
-8dc4 8dd6 8dd7 8dda 8dde 8dce 8dcf 8ddb 
-8dc6 8dec 8df7 8df8 8de3 8df9 8dfb 8de4 
-8e09 8dfd 8e14 8e1d 8e1f 8e2c 8e2e 8e23 
-8e2f 8e3a 8e40 8e39 8e35 8e3d 8e31 8e49 
-8e41 8e42 8e51 8e52 8e4a 8e70 8e76 8e7c 
-8e6f 8e74 8e85 8e8f 8e94 8e90 8e9c 8e9e 
-8c78 8c82 8c8a 8c85 8c98 8c94 659b 89d6 
-89de 89da 89dc     -1     -1     -1     -1     -1 
-    -1 89e5 89eb 89ef 8a3e 8b26 9753 96e9 
-96f3 96ef 9706 9701 9708 970f 970e 972a 
-972d 9730 973e 9f80 9f83 9f85 9f86 9f87 
-9f88 9f89 9f8a 9f8c 9efe 9f0b 9f0d 96b9 
-96bc 96bd 96ce 96d2 77bf 96e0 928e 92ae 
-92c8 933e 936a 93ca 938f 943e 946b 9c7f 
-9c82 9c85 9c86 9c87 9c88 7a23 9c8b 9c8e 
-9c90 9c91 9c92 9c94 9c95 9c9a 9c9b 9c9e 
-9c9f 9ca0 9ca1 9ca2 9ca3 9ca5 9ca6 9ca7 
-9ca8 9ca9 9cab 9cad 9cae 9cb0 9cb1 9cb2 
-9cb3 9cb4 9cb5 9cb6 9cb7 9cba 9cbb 9cbc 
-9cbd 9cc4 9cc5 9cc6 9cc7 9cca 9ccb     -1 
-    -1     -1     -1     -1     -1 9ccc 9ccd 9cce 
-9ccf 9cd0 9cd3 9cd4 9cd5 9cd7 9cd8 9cd9 
-9cdc 9cdd 9cdf 9ce2 977c 9785 9791 9792 
-9794 97af 97ab 97a3 97b2 97b4 9ab1 9ab0 
-9ab7 9e58 9ab6 9aba 9abc 9ac1 9ac0 9ac5 
-9ac2 9acb 9acc 9ad1 9b45 9b43 9b47 9b49 
-9b48 9b4d 9b51 98e8 990d 992e 9955 9954 
-9adf 9ae1 9ae6 9aef 9aeb 9afb 9aed 9af9 
-9b08 9b0f 9b13 9b1f 9b23 9ebd 9ebe 7e3b 
-9e82 9e87 9e88 9e8b 9e92 93d6 9e9d 9e9f 
-9edb 9edc 9edd 9ee0 9edf 9ee2 9ee9 9ee7 
-9ee5 9eea 9eef 9f22 9f2c 9f2f 9f39 9f37 
-9f3d 9f3e 9f44 
Index: xc/nls/XLC_LOCALE/georgian-academy
diff -u xc/nls/XLC_LOCALE/georgian-academy:1.1 xc/nls/XLC_LOCALE/georgian-academy:1.2
--- xc/nls/XLC_LOCALE/georgian-academy:1.1	Sun Jun  6 10:05:58 1999
+++ xc/nls/XLC_LOCALE/georgian-academy	Fri Dec  1 12:43:02 2000
@@ -1,4 +1,4 @@
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/georgian-academy,v 1.1 1999/06/06 14:05:58 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/georgian-academy,v 1.2 2000/12/01 17:43:02 dawes Exp $
 XCOMM  XLocale Database Sample for georgian-academy
 XCOMM 
 
@@ -8,8 +8,13 @@
 XLC_FONTSET
 XCOMM 	fs0 class (7 bit ASCII)
 fs0	{
-	charset		ISO8859-1:GL
-	font            GEORGIAN-ACADEMY:GL; ISO8859-1:GL
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		GEORGIAN-ACADEMY:GL
+		substitute	ISO8859-1:GL
+	}
 }
 XCOMM 	fs1 class 
 fs1	{
@@ -18,6 +23,19 @@
 }
 END XLC_FONTSET
 
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	GEORGIAN-ACADEMY
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
 XCOMM 
 XCOMM 	XLC_XLOCALE category
 XCOMM 
@@ -34,6 +52,10 @@
 wc_shift_bits		8
 #endif
 
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
 XCOMM 	cs0 class
 cs0	{
 	side		GL:Default
@@ -52,7 +74,7 @@
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     GEORGIAN-ACADEMY:GR; ISO8859-1:GR
+	ct_encoding     GEORGIAN-ACADEMY:GR
 }
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/georgian-ps
diff -u xc/nls/XLC_LOCALE/georgian-ps:1.1 xc/nls/XLC_LOCALE/georgian-ps:1.2
--- xc/nls/XLC_LOCALE/georgian-ps:1.1	Sun Jun  6 10:05:58 1999
+++ xc/nls/XLC_LOCALE/georgian-ps	Fri Dec  1 12:43:02 2000
@@ -1,4 +1,4 @@
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/georgian-ps,v 1.1 1999/06/06 14:05:58 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/georgian-ps,v 1.2 2000/12/01 17:43:02 dawes Exp $
 XCOMM  XLocale Database Sample for georgian-ps
 XCOMM 
 
@@ -8,8 +8,13 @@
 XLC_FONTSET
 XCOMM 	fs0 class (7 bit ASCII)
 fs0	{
-	charset		ISO8859-1:GL
-	font            GEORGIAN-PS:GL; ISO8859-1:GL
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		GEORGIAN-PS:GL 
+		substitute	ISO8859-1:GL
+	}
 }
 XCOMM 	fs1 class 
 fs1	{
@@ -18,6 +23,19 @@
 }
 END XLC_FONTSET
 
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	GEORGIAN-PS
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
 XCOMM 
 XCOMM 	XLC_XLOCALE category
 XCOMM 
@@ -34,6 +52,10 @@
 wc_shift_bits		8
 #endif
 
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
 XCOMM 	cs0 class
 cs0	{
 	side		GL:Default
@@ -52,7 +74,7 @@
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     GEORGIAN-PS:GR; ISO8859-1:GR
+	ct_encoding     GEORGIAN-PS:GR
 }
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/ibm-cp1133
diff -u xc/nls/XLC_LOCALE/ibm-cp1133:1.1 xc/nls/XLC_LOCALE/ibm-cp1133:1.2
--- xc/nls/XLC_LOCALE/ibm-cp1133:1.1	Sun Jun  6 10:05:59 1999
+++ xc/nls/XLC_LOCALE/ibm-cp1133	Fri Dec  1 12:43:03 2000
@@ -1,4 +1,4 @@
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/ibm-cp1133,v 1.1 1999/06/06 14:05:59 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/ibm-cp1133,v 1.2 2000/12/01 17:43:03 dawes Exp $
 XCOMM  XLocale Database Sample for ibm-cp1133.
 XCOMM 
 
@@ -8,8 +8,13 @@
 XLC_FONTSET
 XCOMM 	fs0 class (7 bit ASCII)
 fs0	{
-	charset		ISO8859-1:GL
-	font            IBM-CP1133:GL; ISO8859-1:GL
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		IBM-CP1133:GL
+		substitute	ISO8859-1:GL
+	}
 }
 XCOMM 	fs1 class 
 fs1	{
@@ -18,6 +23,19 @@
 }
 END XLC_FONTSET
 
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	IBM-CP1133
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
 XCOMM 
 XCOMM 	XLC_XLOCALE category
 XCOMM 
@@ -34,6 +52,10 @@
 wc_shift_bits		8
 #endif
 
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
 XCOMM 	cs0 class
 cs0	{
 	side		GL:Default
@@ -52,7 +74,7 @@
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     IBM-CP1133:GR; ISO8859-1:GR
+	ct_encoding     IBM-CP1133:GR
 }
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/iscii-dev
diff -u /dev/null xc/nls/XLC_LOCALE/iscii-dev:1.2
--- /dev/null	Mon Dec 18 14:27:00 2000
+++ xc/nls/XLC_LOCALE/iscii-dev	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,80 @@
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/iscii-dev,v 1.2 2000/12/01 17:43:03 dawes Exp $
+XCOMM  XLocale Database Sample for mulelao-1.
+XCOMM 
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class (7 bit ASCII)
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		ISCII-DEV:GL
+		substitute	ISO8859-1:GL
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset         ISCII-DEV:GR
+	font            ISCII-DEV:GR
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	ISCII-DEV
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name           ISCII-DEV
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding     ISCII-DEV:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding     ISCII-DEV:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/isiri-3342
diff -u /dev/null xc/nls/XLC_LOCALE/isiri-3342:1.2
--- /dev/null	Mon Dec 18 14:27:00 2000
+++ xc/nls/XLC_LOCALE/isiri-3342	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,80 @@
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/isiri-3342,v 1.2 2000/12/01 17:43:03 dawes Exp $
+XCOMM  XLocale Database Sample for mulelao-1.
+XCOMM 
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class (7 bit ASCII)
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		ISIRI-3342:GL 
+		substitute	ISO8859-1:GL
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset         ISIRI-3342:GR
+	font            ISIRI-3342:GR
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	ISIRI-3342
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name           ISIRI-3342
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding     ISIRI-3342:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding     ISIRI-3342:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/iso8859-13
diff -u /dev/null xc/nls/XLC_LOCALE/iso8859-13:1.1
--- /dev/null	Mon Dec 18 14:27:00 2000
+++ xc/nls/XLC_LOCALE/iso8859-13	Fri Oct 27 14:30:56 2000
@@ -0,0 +1,74 @@
+XCOMM  $TOG: iso8859-13 /main/1 1998/05/20 13:49:21 kaleb $
+XCOMM  XLocale Database Sample for iso8859-13.
+XCOMM 
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/iso8859-13,v 1.1 2000/10/27 18:30:56 dawes Exp $
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class 
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		ISO8859-13:GL
+		substitute	ISO8859-1:GL
+		vertical_rotate	all
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset	{
+		name		ISO8859-13:GR
+	}
+	font	{
+		primary		ISO8859-13:GR
+	}
+}
+END XLC_FONTSET
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name		ISO8859-13
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+force_convert_to_mb	True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding	ISO8859-13:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding	ISO8859-13:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/iso8859-9e
diff -u /dev/null xc/nls/XLC_LOCALE/iso8859-9e:1.3
--- /dev/null	Mon Dec 18 14:27:01 2000
+++ xc/nls/XLC_LOCALE/iso8859-9e	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,86 @@
+XCOMM  $XConsortium: iso8859-9e /main/7 1996/09/28 16:51:50 rws $
+XCOMM  XLocale Database Sample for iso8859-9e.
+XCOMM 
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/iso8859-9e,v 1.3 2000/12/01 17:43:03 dawes Exp $
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class 
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		ISO8859-9E:GL
+		substitute	ISO8859-1:GL
+		vertical_rotate	all
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset	{
+		name		ISO8859-9E:GR
+	}
+	font	{
+		primary		ISO8859-9E:GR
+	}
+}
+END XLC_FONTSET
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	ISO8859-9E
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name		ISO8859-9E
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+force_convert_to_mb	True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding	ISO8859-9E:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding	ISO8859-9E:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/jis0201
diff -u xc/nls/XLC_LOCALE/jis0201:1.1.1.1 xc/nls/XLC_LOCALE/jis0201:removed
--- xc/nls/XLC_LOCALE/jis0201:1.1.1.1	Sat Dec 21 22:29:38 1996
+++ xc/nls/XLC_LOCALE/jis0201	Mon Dec 18 14:27:01 2000
@@ -1,32 +0,0 @@
-00	01	02	03	04	05	06	07
-08	09	0A	0B	0C	0D	0E	0F
-10	11	12	13	14	15	16	17
-18	19	1A	1B	1C	1D	1E	1F
-20	21	22	23	24	25	26	27
-28	29	2A	2B	2C	2D	2E	2F
-30	31	32	33	34	35	36	37
-38	39	3A	3B	3C	3D	3E	3F
-40	41	42	43	44	45	46	47
-48	49	4A	4B	4C	4D	4E	4F
-50	51	52	53	54	55	56	57
-58	59	5A	5B	A5	5D	5E	5F
-60	61	62	63	64	65	66	67
-68	69	6A	6B	6C	6D	6E	6F
-70	71	72	73	74	75	76	77
-78	79	7A	7B	7C	7D	203E	7F
-80	81	82	83	84	85	86	87
-88	89	8A	8B	8C	8D	8E	8F
-90	91	92	93	94	95	96	97
-98	99	9A	9B	9C	9D	9E	9F
-A0	FF61	FF62	FF63	FF64	FF65	FF66	FF67
-FF68	FF69	FF6A	FF6B	FF6C	FF6D	FF6E	FF6F
-FF70	FF71	FF72	FF73	FF74	FF75	FF76	FF77
-FF78	FF79	FF7A	FF7B	FF7C	FF7D	FF7E	FF7F
-FF80	FF81	FF82	FF83	FF84	FF85	FF86	FF87
-FF88	FF89	FF8A	FF8B	FF8C	FF8D	FF8E	FF8F
-FF90	FF91	FF92	FF93	FF94	FF95	FF96	FF97
-FF98	FF99	FF9A	FF9B	FF9C	FF9D	FF9E	FF9F
--1	-1	-1	-1	-1	-1	-1	-1
--1	-1	-1	-1	-1	-1	-1	-1
--1	-1	-1	-1	-1	-1	-1	-1
--1	-1	-1	-1	-1	-1	-1	-1
Index: xc/nls/XLC_LOCALE/jis0208
diff -u xc/nls/XLC_LOCALE/jis0208:1.1.1.1 xc/nls/XLC_LOCALE/jis0208:removed
--- xc/nls/XLC_LOCALE/jis0208:1.1.1.1	Sat Dec 21 22:29:37 1996
+++ xc/nls/XLC_LOCALE/jis0208	Mon Dec 18 14:27:01 2000
@@ -1,1051 +0,0 @@
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1 3000 3001 3002 
-ff0c ff0e 30fb ff1a ff1b ff1f ff01 309b 
-309c 00b4 ff40 00a8 ff3e 203e ff3f 30fd 
-30fe 309d 309e 3003 4edd 3005 3006 3007 
-30fc 2015 00ad ff0f ff3c ff5e 2225 ff5c 
-2026 2025 2018 2019 201c 201d ff08 ff09 
-3014 3015 ff3b ff3d ff5b ff5d 3008 3009 
-300a 300b 300c 300d 300e 300f 3010 3011 
-ff0b ff0d 00b1 00d7 00f7 ff1d 2260 ff1c 
-ff1e 2264 2265 221e 2234 2642 2640 00b0 
-2032 2033 2103 00a5 ff04 00a2 00a3 ff05 
-ff03 ff06 ff0a ff20 00a7 2606 2605 25cb 
-25cf 25ce 25c7     -1     -1     -1     -1     -1 
-    -1 25c6 25a1 25a0 25b3 25b2 25bd 25bc 
-203b 3012 2192 2190 2191 2193 3013     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1 2208 220b 2286 2287 2282 2283 
-222a 2229     -1     -1     -1     -1     -1     -1 
-    -1     -1 2227 2228 00ac 21d2 21d4 2200 
-2203     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1 2220 22a5 2040 2202 
-2207 2261 2252 226a 226b 221a 224c 221d 
-2235 222b 222c     -1     -1     -1     -1     -1 
-    -1     -1 212b 2030 266f 266d 266a 2020 
-2021 00b6     -1     -1     -1     -1 20dd     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1 ff10 ff11 ff12 ff13 
-ff14 ff15 ff16 ff17 ff18 ff19     -1     -1 
-    -1     -1     -1     -1     -1 ff21 ff22 ff23 
-ff24 ff25 ff26 ff27 ff28 ff29 ff2a ff2b 
-ff2c ff2d ff2e ff2f ff30 ff31 ff32 ff33 
-ff34 ff35 ff36 ff37 ff38 ff39 ff3a     -1 
-    -1     -1     -1     -1     -1 ff41 ff42 ff43 
-ff44 ff45 ff46 ff47 ff48 ff49 ff4a ff4b 
-ff4c ff4d ff4e ff4f ff50 ff51 ff52 ff53 
-ff54 ff55 ff56 ff57 ff58 ff59 ff5a     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 3041 3042 3043 3044 3045 3046 3047 
-3048 3049 304a 304b 304c 304d 304e 304f 
-3050 3051 3052 3053 3054 3055 3056 3057 
-3058 3059 305a 305b 305c 305d 305e 305f 
-3060 3061 3062 3063 3064 3065 3066 3067 
-3068 3069 306a 306b 306c 306d 306e 306f 
-3070 3071 3072 3073 3074 3075 3076 3077 
-3078 3079 307a 307b 307c 307d 307e 307f 
-3080 3081 3082 3083 3084 3085 3086 3087 
-3088 3089 308a 308b 308c 308d 308e 308f 
-3090 3091 3092 3093     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1 30a1 30a2 30a3 
-30a4 30a5 30a6 30a7 30a8 30a9 30aa 30ab 
-30ac 30ad 30ae 30af 30b0 30b1 30b2 30b3 
-30b4 30b5 30b6 30b7 30b8 30b9 30ba 30bb 
-30bc 30bd 30be 30bf 30c0 30c1 30c2 30c3 
-30c4 30c5 30c6 30c7 30c8 30c9 30ca 30cb 
-30cc 30cd 30ce 30cf 30d0 30d1 30d2 30d3 
-30d4 30d5 30d6 30d7 30d8 30d9 30da 30db 
-30dc 30dd 30de 30df 30e0 30e1 30e2 30e3 
-30e4 30e5 30e6 30e7 30e8 30e9 30ea 30eb 
-30ec 30ed 30ee 30ef 30f0 30f1 30f2 30f3 
-30f4 30f5 30f6     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 0391 0392 0393 0394 0395 0396 0397 
-0398 0399 039a 039b 039c 039d 039e 039f 
-03a0 03a1 03a3 03a4 03a5 03a6 03a7 03a8 
-03a9     -1     -1     -1     -1     -1     -1     -1 
-    -1 03b1 03b2 03b3 03b4 03b5 03b6 03b7 
-03b8 03b9 03ba 03bb 03bc 03bd 03be 03bf 
-03c0 03c1 03c3 03c4 03c5 03c6 03c7 03c8 
-03c9     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1 0410 0411 0412 
-0413 0414 0415 0401 0416 0417 0418 0419 
-041a 041b 041c 041d 041e 041f 0420 0421 
-0422 0423 0424 0425 0426 0427 0428 0429 
-042a 042b 042c 042d 042e 042f     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1 0430 0431 0432 
-0433 0434 0435 0451 0436 0437 0438 0439 
-043a 043b 043c 043d 043e 043f 0440 0441 
-0442 0443 0444 0445 0446 0447 0448 0449 
-044a 044b 044c 044d 044e 044f     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 2500 2502 250c 2510 2518 2514 251c 
-252c 2524 2534 253c 2501 2503 250f 2513 
-251b 2517 2523 2533 252b 253b 254b 2520 
-252f 2528 2537 253f 251d 2530 2525 2538 
-2542     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 4e9c 5516 5a03 963f 54c0 611b 6328 
-59f6 9022 8475 831c 7a50 60aa 63e1 6e25 
-65ed 8466 82a6 9bf5 6893 5727 65a1 6271 
-5b9b 59d0 867b 98f4 7d62 7dbe 9b8e 6216 
-7c9f 88b7 5b89 5eb5 6309 6697 6848 95c7 
-978d 674f 4ee5 4f0a 4f4d 4f9d 5049 56f2 
-5937 59d4 5a01 5c09 60df 610f 6170 6613 
-6905 70ba 754f 7570 79fb 7dad 7def 80c3 
-840e 8863 8b02 9055 907a 533b 4e95 4ea5 
-57df 80b2 90c1 78ef 4e00 58f1 6ea2 9038 
-7a32 8328 828b 9c2f 5141 5370 54bd 54e1 
-56e0 59fb 5f15 98f2 6deb 80e4 852d     -1 
-    -1     -1     -1     -1     -1 9662 9670 96a0 
-97fb 540b 53f3 5b87 70cf 7fbd 8fc2 96e8 
-536f 9d5c 7aba 4e11 7893 81fc 6e26 5618 
-5504 6b1d 851a 9c3b 59e5 53a9 6d66 74dc 
-958f 5642 4e91 904b 96f2 834f 990c 53e1 
-55b6 5b30 5f71 6620 66f3 6804 6c38 6cf3 
-6d29 745b 76c8 7a4e 9834 82f1 885b 8a60 
-92ed 6db2 75ab 76ca 99c5 60a6 8b01 8d8a 
-95b2 698e 53ad 5186 5712 5830 5944 5bb4 
-5ef6 6028 63a9 63f4 6cbf 6f14 708e 7114 
-7159 71d5 733f 7e01 8276 82d1 8597 9060 
-925b 9d1b 5869 65bc 6c5a 7525 51f9 592e 
-5965 5f80 5fdc     -1     -1     -1     -1     -1 
-    -1 62bc 65fa 6a2a 6b27 6bb4 738b 7fc1 
-8956 9d2c 9d0e 9ec4 5ca1 6c96 837b 5104 
-5c4b 61b6 81c6 6876 7261 4e59 4ffa 5378 
-6069 6e29 7a4f 97f3 4e0b 5316 4eee 4f55 
-4f3d 4fa1 4f73 52a0 53ef 5609 590f 5ac1 
-5bb6 5be1 79d1 6687 679c 67b6 6b4c 6cb3 
-706b 73c2 798d 79be 7a3c 7b87 82b1 82db 
-8304 8377 83ef 83d3 8766 8ab2 5629 8ca8 
-8fe6 904e 971e 868a 4fc4 5ce8 6211 7259 
-753b 81e5 82bd 86fe 8cc0 96c5 9913 99d5 
-4ecb 4f1a 89e3 56de 584a 58ca 5efb 5feb 
-602a 6094 6062 61d0 6212 62d0 6539     -1 
-    -1     -1     -1     -1     -1 9b41 6666 68b0 
-6d77 7070 754c 7686 7d75 82a5 87f9 958b 
-968e 8c9d 51f1 52be 5916 54b3 5bb3 5d16 
-6168 6982 6daf 788d 84cb 8857 8a72 93a7 
-9ab8 6d6c 99a8 86d9 57a3 67ff 86ce 920e 
-5283 5687 5404 5ed3 62e1 64b9 683c 6838 
-6bbb 7372 78ba 7a6b 899a 89d2 8d6b 8f03 
-90ed 95a3 9694 9769 5b66 5cb3 697d 984d 
-984e 639b 7b20 6a2b 6a7f 68b6 9c0d 6f5f 
-5272 559d 6070 62ec 6d3b 6e07 6ed1 845b 
-8910 8f44 4e14 9c39 53f6 691b 6a3a 9784 
-682a 515c 7ac3 84b2 91dc 938c 565b 9d28 
-6822 8305 8431     -1     -1     -1     -1     -1 
-    -1 7ca5 5208 82c5 74e6 4e7e 4f83 51a0 
-5bd2 520a 52d8 52e7 5dfb 559a 582a 59e6 
-5b8c 5b98 5bdb 5e72 5e79 60a3 611f 6163 
-61be 63db 6562 67d1 6853 68fa 6b3e 6b53 
-6c57 6f22 6f97 6f45 74b0 7518 76e3 770b 
-7aff 7ba1 7c21 7de9 7f36 7ff0 809d 8266 
-839e 89b3 8acc 8cab 9084 9451 9593 9591 
-95a2 9665 97d3 9928 8218 4e38 542b 5cb8 
-5dcc 73a9 764c 773c 5ca9 7feb 8d0b 96c1 
-9811 9854 9858 4f01 4f0e 5371 559c 5668 
-57fa 5947 5b09 5bc4 5c90 5e0c 5e7e 5fcc 
-63ee 673a 65d7 65e2 671f 68cb 68c4     -1 
-    -1     -1     -1     -1     -1 6a5f 5e30 6bc5 
-6c17 6c7d 757f 7948 5b63 7a00 7d00 5fbd 
-898f 8a18 8cb4 8d77 8ecc 8f1d 98e2 9a0e 
-9b3c 4e80 507d 5100 5993 5b9c 622f 6280 
-64ec 6b3a 72a0 7591 7947 7fa9 87fb 8abc 
-8b70 63ac 83ca 97a0 5409 5403 55ab 6854 
-6a58 8a70 7827 6775 9ecd 5374 5ba2 811a 
-8650 9006 4e18 4e45 4ec7 4f11 53ca 5438 
-5bae 5f13 6025 6551 673d 6c42 6c72 6ce3 
-7078 7403 7a76 7aae 7b08 7d1a 7cfe 7d66 
-65e7 725b 53bb 5c45 5de8 62d2 62e0 6319 
-6e20 865a 8a31 8ddd 92f8 6f01 79a6 9b5a 
-4ea8 4eab 4eac     -1     -1     -1     -1     -1 
-    -1 4f9b 4fa0 50d1 5147 7af6 5171 51f6 
-5354 5321 537f 53eb 55ac 5883 5ce1 5f37 
-5f4a 602f 6050 606d 631f 6559 6a4b 6cc1 
-72c2 72ed 77ef 80f8 8105 8208 854e 90f7 
-93e1 97ff 9957 9a5a 4ef0 51dd 5c2d 6681 
-696d 5c40 66f2 6975 7389 6850 7c81 50c5 
-52e4 5747 5dfe 9326 65a4 6b23 6b3d 7434 
-7981 79bd 7b4b 7dca 82b9 83cc 887f 895f 
-8b39 8fd1 91d1 541f 9280 4e5d 5036 53e5 
-533a 72d7 7396 77e9 82e6 8eaf 99c6 99c8 
-99d2 5177 611a 865e 55b0 7a7a 5076 5bd3 
-9047 9685 4e32 6adb 91e7 5c51 5c48     -1 
-    -1     -1     -1     -1     -1 6398 7a9f 6c93 
-9774 8f61 7aaa 718a 9688 7c82 6817 7e70 
-6851 936c 52f2 541b 85ab 8a13 7fa4 8ecd 
-90e1 5366 8888 7941 4fc2 50be 5211 5144 
-5553 572d 73ea 578b 5951 5f62 5f84 6075 
-6176 6167 61a9 63b2 643a 656c 666f 6842 
-6e13 7566 7a3d 7cfb 7d4c 7d99 7e4b 7f6b 
-830e 834a 86cd 8a08 8a63 8b66 8efd 981a 
-9d8f 82b8 8fce 9be8 5287 621f 6483 6fc0 
-9699 6841 5091 6b20 6c7a 6f54 7a74 7d50 
-8840 8a23 6708 4ef6 5039 5026 5065 517c 
-5238 5263 55a7 570f 5805 5acc 5efa 61b2 
-61f8 62f3 6372     -1     -1     -1     -1     -1 
-    -1 691c 6a29 727d 72ac 732e 7814 786f 
-7d79 770c 80a9 898b 8b19 8ce2 8ed2 9063 
-9375 967a 9855 9a13 9e78 5143 539f 53b3 
-5e7b 5f26 6e1b 6e90 7384 73fe 7d43 8237 
-8a00 8afa 9650 4e4e 500b 53e4 547c 56fa 
-59d1 5b64 5df1 5eab 5f27 6238 6545 67af 
-6e56 72d0 7cca 88b4 80a1 80e1 83f0 864e 
-8a87 8de8 9237 96c7 9867 9f13 4e94 4e92 
-4f0d 5348 5449 543e 5a2f 5f8c 5fa1 609f 
-68a7 6a8e 745a 7881 8a9e 8aa4 8b77 9190 
-4e5e 9bc9 4ea4 4f7c 4faf 5019 5016 5149 
-516c 529f 52b9 52fe 539a 53e3 5411     -1 
-    -1     -1     -1     -1     -1 540e 5589 5751 
-57a2 597d 5b54 5b5d 5b8f 5de5 5de7 5df7 
-5e78 5e83 5e9a 5eb7 5f18 6052 614c 6297 
-62d8 63a7 653b 6602 6643 66f4 676d 6821 
-6897 69cb 6c5f 6d2a 6d69 6e2f 6e9d 7532 
-7687 786c 7a3f 7ce0 7d05 7d18 7d5e 7db1 
-8015 8003 80af 80b1 8154 818f 822a 8352 
-884c 8861 8b1b 8ca2 8cfc 90ca 9175 9271 
-783f 92fc 95a4 964d 9805 9999 9ad8 9d3b 
-525b 52ab 53f7 5408 58d5 62f7 6fe0 8c6a 
-8f5f 9eb9 514b 523b 544a 56fd 7a40 9177 
-9d60 9ed2 7344 6f09 8170 7511 5ffd 60da 
-9aa8 72db 8fbc     -1     -1     -1     -1     -1 
-    -1 6b64 9803 4eca 56f0 5764 58be 5a5a 
-6068 61c7 660f 6606 6839 68b1 6df7 75d5 
-7d3a 826e 9b42 4e9b 4f50 53c9 5506 5d6f 
-5de6 5dee 67fb 6c99 7473 7802 8a50 9396 
-88df 5750 5ea7 632b 50b5 50ac 518d 6700 
-54c9 585e 59bb 5bb0 5f69 624d 63a1 683d 
-6b73 6e08 707d 91c7 7280 7815 7826 796d 
-658e 7d30 83dc 88c1 8f09 969b 5264 5728 
-6750 7f6a 8ca1 51b4 5742 962a 583a 698a 
-80b4 54b2 5d0e 57fc 7895 9dfa 4f5c 524a 
-548b 643e 6628 6714 67f5 7a84 7b56 7d22 
-932f 685c 9bad 7b39 5319 518a 5237     -1 
-    -1     -1     -1     -1     -1 5bdf 62f6 64ae 
-64e6 672d 6bba 85a9 96d1 7690 9bd6 634c 
-9306 9bab 76bf 6652 4e09 5098 53c2 5c71 
-60e8 6492 6563 685f 71e6 73ca 7523 7b97 
-7e82 8695 8b83 8cdb 9178 9910 65ac 66ab 
-6b8b 4ed5 4ed4 4f3a 4f7f 523a 53f8 53f2 
-55e3 56db 58eb 59cb 59c9 59ff 5b50 5c4d 
-5e02 5e2b 5fd7 601d 6307 652f 5b5c 65af 
-65bd 65e8 679d 6b62 6b7b 6c0f 7345 7949 
-79c1 7cf8 7d19 7d2b 80a2 8102 81f3 8996 
-8a5e 8a69 8a66 8a8c 8aee 8cc7 8cdc 96cc 
-98fc 6b6f 4e8b 4f3c 4f8d 5150 5b57 5bfa 
-6148 6301 6642     -1     -1     -1     -1     -1 
-    -1 6b21 6ecb 6cbb 723e 74bd 75d4 78c1 
-793a 800c 8033 81ea 8494 8f9e 6c50 9e7f 
-5f0f 8b58 9d2b 7afa 8ef8 5b8d 96eb 4e03 
-53f1 57f7 5931 5ac9 5ba4 6089 6e7f 6f06 
-75be 8cea 5b9f 8500 7be0 5072 67f4 829d 
-5c61 854a 7e1e 820e 5199 5c04 6368 8d66 
-659c 716e 793e 7d17 8005 8b1d 8eca 906e 
-86c7 90aa 501f 52fa 5c3a 6753 707c 7235 
-914c 91c8 932b 82e5 5bc2 5f31 60f9 4e3b 
-53d6 5b88 624b 6731 6b8a 72e9 73e0 7a2e 
-816b 8da3 9152 9996 5112 53d7 546a 5bff 
-6388 6a39 7dac 9700 56da 53ce 5468     -1 
-    -1     -1     -1     -1     -1 5b97 5c31 5dde 
-4fee 6101 62fe 6d32 79c0 79cb 7d42 7e4d 
-7fd2 81ed 821f 8490 8846 8972 8b90 8e74 
-8f2f 9031 914b 916c 96c6 919c 4ec0 4f4f 
-5145 5341 5f93 620e 67d4 6c41 6e0b 7363 
-7e26 91cd 9283 53d4 5919 5bbf 6dd1 795d 
-7e2e 7c9b 587e 719f 51fa 8853 8ff0 4fca 
-5cfb 6625 77ac 7ae3 821c 99ff 51c6 5faa 
-65ec 696f 6b89 6df3 6e96 6f64 76fe 7d14 
-5de1 9075 9187 9806 51e6 521d 6240 6691 
-66d9 6e1a 5eb6 7dd2 7f72 66f8 85af 85f7 
-8af8 52a9 53d9 5973 5e8f 5f90 6055 92e4 
-9664 50b7 511f     -1     -1     -1     -1     -1 
-    -1 52dd 5320 5347 53ec 54e8 5546 5531 
-5617 5968 59be 5a3c 5bb5 5c06 5c0f 5c11 
-5c1a 5e84 5e8a 5ee0 5f70 627f 6284 62db 
-638c 6377 6607 660c 662d 6676 677e 68a2 
-6a1f 6a35 6cbc 6d88 6e09 6e58 713c 7126 
-7167 75c7 7701 785d 7901 7965 79f0 7ae0 
-7b11 7ca7 7d39 8096 83d6 848b 8549 885d 
-88f3 8a1f 8a3c 8a54 8a73 8c61 8cde 91a4 
-9266 937e 9418 969c 9798 4e0a 4e08 4e1e 
-4e57 5197 5270 57ce 5834 58cc 5b22 5e38 
-60c5 64fe 6761 6756 6d44 72b6 7573 7a63 
-84b8 8b72 91b8 9320 5631 57f4 98fe     -1 
-    -1     -1     -1     -1     -1 62ed 690d 6b96 
-71ed 7e54 8077 8272 89e6 98df 8755 8fb1 
-5c3b 4f38 4fe1 4fb5 5507 5a20 5bdd 5be9 
-5fc3 614e 632f 65b0 664b 68ee 699b 6d78 
-6df1 7533 75b9 771f 795e 79e6 7d33 81e3 
-82af 85aa 89aa 8a3a 8eab 8f9b 9032 91dd 
-9707 4eba 4ec1 5203 5875 58ec 5c0b 751a 
-5c3d 814e 8a0a 8fc5 9663 976d 7b25 8acf 
-9808 9162 56f3 53a8 9017 5439 5782 5e25 
-63a8 6c34 708a 7761 7c8b 7fe0 8870 9042 
-9154 9310 9318 968f 745e 9ac4 5d07 5d69 
-6570 67a2 8da8 96db 636e 6749 6919 83c5 
-9817 96c0 88fe     -1     -1     -1     -1     -1 
-    -1 6f84 647a 5bf8 4e16 702c 755d 662f 
-51c4 5236 52e2 59d3 5f81 6027 6210 653f 
-6574 661f 6674 68f2 6816 6b63 6e05 7272 
-751f 76db 7cbe 8056 58f0 88fd 897f 8aa0 
-8a93 8acb 901d 9192 9752 9759 6589 7a0e 
-8106 96bb 5e2d 60dc 621a 65a5 6614 6790 
-77f3 7a4d 7c4d 7e3e 810a 8cac 8d64 8de1 
-8e5f 78a9 5207 62d9 63a5 6442 6298 8a2d 
-7a83 7bc0 8aac 96ea 7d76 820c 8749 4ed9 
-5148 5343 5360 5ba3 5c02 5c16 5ddd 6226 
-6247 64b0 6813 6834 6cc9 6d45 6d17 67d3 
-6f5c 714e 717d 65cb 7a7f 7bad 7dda     -1 
-    -1     -1     -1     -1     -1 7e4a 7fa8 817a 
-821b 8239 85a6 8a6e 8cce 8df5 9078 9077 
-92ad 9291 9583 9bae 524d 5584 6f38 7136 
-5168 7985 7e55 81b3 7cce 564c 5851 5ca8 
-63aa 66fe 66fd 695a 72d9 758f 758e 790e 
-7956 79df 7c97 7d20 7d44 8607 8a34 963b 
-9061 9f20 50e7 5275 53cc 53e2 5009 55aa 
-58ee 594f 723d 5b8b 5c64 531d 60e3 60f3 
-635c 6383 633f 63bb 64cd 65e9 66f9 5de3 
-69cd 69fd 6f15 71e5 4e89 75e9 76f8 7a93 
-7cdf 7dcf 7d9c 8061 8349 8358 846c 84bc 
-85fb 88c5 8d70 9001 906d 9397 971c 9a12 
-50cf 5897 618e     -1     -1     -1     -1     -1 
-    -1 81d3 8535 8d08 9020 4fc3 5074 5247 
-5373 606f 6349 675f 6e2c 8db3 901f 4fd7 
-5c5e 8cca 65cf 7d9a 5352 8896 5176 63c3 
-5b58 5b6b 5c0a 640d 6751 905c 4ed6 591a 
-592a 6c70 8a51 553e 5815 59a5 60f0 6253 
-67c1 8235 6955 9640 99c4 9a28 4f53 5806 
-5bfe 8010 5cb1 5e2f 5f85 6020 614b 6234 
-66ff 6cf0 6ede 80ce 817f 82d4 888b 8cb8 
-9000 902e 968a 9edb 9bdb 4ee3 53f0 5927 
-7b2c 918d 984c 9df9 6edd 7027 5353 5544 
-5b85 6258 629e 62d3 6ca2 6fef 7422 8a17 
-9438 6fc1 8afe 8338 51e7 86f8 53ea     -1 
-    -1     -1     -1     -1     -1 53e9 4f46 9054 
-8fb0 596a 8131 5dfd 7aea 8fbf 68da 8c37 
-72f8 9c48 6a3d 8ab0 4e39 5358 5606 5766 
-62c5 63a2 65e6 6b4e 6de1 6e5b 70ad 77ed 
-7aef 7baa 7dbb 803d 80c6 86cb 8a95 935b 
-56e3 58c7 5f3e 65ad 6696 6a80 6bb5 7537 
-8ac7 5024 77e5 5730 5f1b 6065 667a 6c60 
-75f4 7a1a 7f6e 81f4 8718 9045 99b3 7bc9 
-755c 7af9 7b51 84c4 9010 79e9 7a92 8336 
-5ae1 7740 4e2d 4ef2 5b99 5fe0 62bd 663c 
-67f1 6ce8 866b 8877 8a3b 914e 92f3 99d0 
-6a17 7026 732a 82e7 8457 8caf 4e01 5146 
-51cb 558b 5bf5     -1     -1     -1     -1     -1 
-    -1 5e16 5e33 5e81 5f14 5f35 5f6b 5fb4 
-61f2 6311 66a2 671d 6f6e 7252 753a 773a 
-8074 8139 8178 8776 8abf 8adc 8d85 8df3 
-929a 9577 9802 9ce5 52c5 6357 76f4 6715 
-6c88 73cd 8cc3 93ae 9673 6d25 589c 690e 
-69cc 8ffd 939a 75db 901a 585a 6802 63b4 
-69fb 4f43 6f2c 67d8 8fbb 8526 7db4 9354 
-693f 6f70 576a 58f7 5b2c 7d2c 722a 540a 
-91e3 9db4 4ead 4f4e 505c 5075 5243 8c9e 
-5448 5824 5b9a 5e1d 5e95 5ead 5ef7 5f1f 
-608c 62b5 633a 63d0 68af 6c40 7887 798e 
-7a0b 7de0 8247 8a02 8ae6 8e44 9013     -1 
-    -1     -1     -1     -1     -1 90b8 912d 91d8 
-9f0e 6ce5 6458 64e2 6575 6ef4 7684 7b1b 
-9069 93d1 6eba 54f2 5fb9 64a4 8f4d 8fed 
-9244 5178 586b 5929 5c55 5e97 6dfb 7e8f 
-751c 8cbc 8ee2 985b 70b9 4f1d 6bbf 6fb1 
-7530 96fb 514e 5410 5835 5857 59ac 5c60 
-5f92 6597 675c 6e21 767b 83df 8ced 9014 
-90fd 934d 7825 783a 52aa 5ea6 571f 5974 
-6012 5012 515a 51ac 51cd 5200 5510 5854 
-5858 5957 5b95 5cf6 5d8b 60bc 6295 642d 
-6771 6843 68bc 68df 76d7 6dd8 6e6f 6d9b 
-706f 71c8 5f53 75d8 7977 7b49 7b54 7b52 
-7cd6 7d71 5230     -1     -1     -1     -1     -1 
-    -1 8463 8569 85e4 8a0e 8b04 8c46 8e0f 
-9003 900f 9419 9676 982d 9a30 95d8 50cd 
-52d5 540c 5802 5c0e 61a7 649e 6d1e 77b3 
-7ae5 80f4 8404 9053 9285 5ce0 9d07 533f 
-5f97 5fb3 6d9c 7279 7763 79bf 7be4 6bd2 
-72ec 8aad 6803 6a61 51f8 7a81 6934 5c4a 
-9cf6 82eb 5bc5 9149 701e 5678 5c6f 60c7 
-6566 6c8c 8c5a 9041 9813 5451 66c7 920d 
-5948 90a3 5185 4e4d 51ea 8599 8b0e 7058 
-637a 934b 6962 99b4 7e04 7577 5357 6960 
-8edf 96e3 6c5d 4e8c 5c3c 5f10 8fe9 5302 
-8cd1 8089 8679 5eff 65e5 4e73 5165     -1 
-    -1     -1     -1     -1     -1 5982 5c3f 97ee 
-4efb 598a 5fcd 8a8d 6fe1 79b0 7962 5be7 
-8471 732b 71b1 5e74 5ff5 637b 649a 71c3 
-7c98 4e43 5efc 4e4b 57dc 56a2 60a9 6fc3 
-7d0d 80fd 8133 81bf 8fb2 8997 86a4 5df4 
-628a 64ad 8987 6777 6ce2 6d3e 7436 7834 
-5a46 7f75 82ad 99ac 4ff3 5ec3 62dd 6392 
-6557 676f 76c3 724c 80cc 80ba 8f29 914d 
-500d 57f9 5a92 6885 6973 7164 72fd 8cb7 
-58f2 8ce0 966a 9019 877f 79e4 77e7 8429 
-4f2f 5265 535a 62cd 67cf 6cca 767d 7b94 
-7c95 8236 8584 8feb 66dd 6f20 7206 7e1b 
-83ab 99c1 9ea6     -1     -1     -1     -1     -1 
-    -1 51fd 7bb1 7872 7bb8 8087 7b48 6ae8 
-5e61 808c 7551 7560 516b 9262 6e8c 767a 
-9197 9aea 4f10 7f70 629c 7b4f 95a5 9ce9 
-567a 5859 86e4 96bc 4f34 5224 534a 53cd 
-53db 5e06 642c 6591 677f 6c3e 6c4e 7248 
-72af 73ed 7554 7e41 822c 85e9 8ca9 7bc4 
-91c6 7169 9812 98ef 633d 6669 756a 76e4 
-78d0 8543 86ee 532a 5351 5426 5983 5e87 
-5f7c 60b2 6249 6279 62ab 6590 6bd4 6ccc 
-75b2 76ae 7891 79d8 7dcb 7f77 80a5 88ab 
-8ab9 8cbb 907f 975e 98db 6a0b 7c38 5099 
-5c3e 5fae 6787 6bd8 7435 7709 7f8e     -1 
-    -1     -1     -1     -1     -1 9f3b 67ca 7a17 
-5339 758b 9aed 5f66 819d 83f1 8098 5f3c 
-5fc5 7562 7b46 903c 6867 59eb 5a9b 7d10 
-767e 8b2c 4ff5 5f6a 6a19 6c37 6f02 74e2 
-7968 8868 8a55 8c79 5edf 63cf 75c5 79d2 
-82d7 9328 92f2 849c 86ed 9c2d 54c1 5f6c 
-658c 6d5c 7015 8ca7 8cd3 983b 654f 74f6 
-4e0d 4ed8 57e0 592b 5a66 5bcc 51a8 5e03 
-5e9c 6016 6276 6577 65a7 666e 6d6e 7236 
-7b26 8150 819a 8299 8b5c 8ca0 8ce6 8d74 
-961c 9644 4fae 64ab 6b66 821e 8461 856a 
-90e8 5c01 6953 98a8 847a 8557 4f0f 526f 
-5fa9 5e45 670d     -1     -1     -1     -1     -1 
-    -1 798f 8179 8907 8986 6df5 5f17 6255 
-6cb8 4ecf 7269 9b92 5206 543b 5674 58b3 
-61a4 626e 711a 596e 7c89 7cde 7d1b 96f0 
-6587 805e 4e19 4f75 5175 5840 5e63 5e73 
-5f0a 67c4 4e26 853d 9589 965b 7c73 9801 
-50fb 58c1 7656 78a7 5225 77a5 8511 7b86 
-504f 5909 7247 7bc7 7de8 8fba 8fd4 904d 
-4fbf 52c9 5a29 5f01 97ad 4fdd 8217 92ea 
-5703 6355 6b69 752b 88dc 8f14 7a42 52df 
-5893 6155 620a 66ae 6bcd 7c3f 83e9 5023 
-4ff8 5305 5446 5831 5949 5b9d 5cf0 5cef 
-5d29 5e96 62b1 6367 653e 65b9 670b     -1 
-    -1     -1     -1     -1     -1 6cd5 6ce1 70f9 
-7832 7e2b 80de 82b3 840c 84ec 8702 8912 
-8a2a 8c4a 90a6 92d2 98fd 9cf3 9d6c 4e4f 
-4ea1 508d 5256 574a 59a8 5e3d 5fd8 5fd9 
-623f 66b4 671b 67d0 68d2 5192 7d21 80aa 
-81a8 8b00 8c8c 8cbf 927e 9632 5420 982c 
-5317 50d5 535c 58a8 64b2 6734 7267 7766 
-7a46 91e6 52c3 6ca1 6b86 5800 5e4c 5954 
-672c 7ffb 51e1 76c6 6469 78e8 9b54 9ebb 
-57cb 59b9 6627 679a 6bce 54e9 69d9 5e55 
-819c 6795 9baa 67fe 9c52 685d 4ea6 4fe3 
-53c8 62b9 672b 6cab 8fc4 4fad 7e6d 9ebf 
-4e07 6162 6e80     -1     -1     -1     -1     -1 
-    -1 6f2b 8513 5473 672a 9b45 5df3 7b95 
-5cac 5bc6 871c 6e4a 84d1 7a14 8108 5999 
-7c8d 6c11 7720 52d9 5922 7121 725f 77db 
-9727 9d61 690b 5a7f 5a18 51a5 540d 547d 
-660e 76df 8ff7 9298 9cf4 59ea 725d 6ec5 
-514d 68c9 7dbf 7dec 9762 9eba 6478 6a21 
-8302 5984 5b5f 6bdb 731b 76f2 7db2 8017 
-8499 5132 6728 9ed9 76ee 6762 52ff 9905 
-5c24 623b 7c7e 8cb0 554f 60b6 7d0b 9580 
-5301 4e5f 51b6 591c 723a 8036 91ce 5f25 
-77e2 5384 5f79 7d04 85ac 8a33 8e8d 9756 
-67f3 85ae 9453 6109 6108 6cb9 7652     -1 
-    -1     -1     -1     -1     -1 8aed 8f38 552f 
-4f51 512a 52c7 53cb 5ba5 5e7d 60a0 6182 
-63d6 6709 67da 6e67 6d8c 7336 7337 7531 
-7950 88d5 8a98 904a 9091 90f5 96c4 878d 
-5915 4e88 4f59 4e0e 8a89 8f3f 9810 50ad 
-5e7c 5996 5bb9 5eb8 63da 63fa 64c1 66dc 
-694a 69d8 6d0b 6eb6 7194 7528 7aaf 7f8a 
-8000 8449 84c9 8981 8b21 8e0a 9065 967d 
-990a 617e 6291 6b32 6c83 6d74 7fcc 7ffc 
-6dc0 7f85 87ba 88f8 6765 83b1 983c 96f7 
-6d1b 7d61 843d 916a 4e71 5375 5d50 6b04 
-6feb 85cd 862d 89a7 5229 540f 5c65 674e 
-68a8 7406 7483     -1     -1     -1     -1     -1 
-    -1 75e2 88cf 88e1 91cc 96e2 9678 5f8b 
-7387 7acb 844e 63a0 7565 5289 6d41 6e9c 
-7409 7559 786b 7c92 9686 7adc 9f8d 4fb6 
-616e 65c5 865c 4e86 4eae 50da 4e21 51cc 
-5bee 6599 6881 6dbc 731f 7642 77ad 7a1c 
-7ce7 826f 8ad2 907c 91cf 9675 9818 529b 
-7dd1 502b 5398 6797 6dcb 71d0 7433 81e8 
-8f2a 96a3 9c57 9e9f 7460 5841 6d99 7d2f 
-985e 4ee4 4f36 4f8b 51b7 52b1 5dba 601c 
-73b2 793c 82d3 9234 96b7 96f6 970a 9e97 
-9f62 66a6 6b74 5217 52a3 70c8 88c2 5ec9 
-604b 6190 6f23 7149 7c3e 7df4 806f     -1 
-    -1     -1     -1     -1     -1 84ee 9023 932c 
-5442 9b6f 6ad3 7089 8cc2 8def 9732 52b4 
-5a41 5eca 5f04 6717 697c 6994 6d6a 6f0f 
-7262 72fc 7bed 8001 807e 874b 90ce 516d 
-9e93 7984 808b 9332 8ad6 502d 548c 8a71 
-6b6a 8cc4 8107 60d1 67a0 9df2 4e99 4e98 
-9c10 8a6b 85c1 8568 6900 6e7e 7897 8155 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1 5f0c 4e10 4e15 4e2a 4e31 4e36 4e3c 
-4e3f 4e42 4e56 4e58 4e82 4e85 8c6b 4e8a 
-8212 5f0d 4e8e 4e9e 4e9f 4ea0 4ea2 4eb0 
-4eb3 4eb6 4ece 4ecd 4ec4 4ec6 4ec2 4ed7 
-4ede 4eed 4edf 4ef7 4f09 4f5a 4f30 4f5b 
-4f5d 4f57 4f47 4f76 4f88 4f8f 4f98 4f7b 
-4f69 4f70 4f91 4f6f 4f86 4f96 5118 4fd4 
-4fdf 4fce 4fd8 4fdb 4fd1 4fda 4fd0 4fe4 
-4fe5 501a 5028 5014 502a 5025 5005 4f1c 
-4ff6 5021 5029 502c 4ffe 4fef 5011 5006 
-5043 5047 6703 5055 5050 5048 505a 5056 
-506c 5078 5080 509a 5085 50b4 50b2     -1 
-    -1     -1     -1     -1     -1 50c9 50ca 50b3 
-50c2 50d6 50de 50e5 50ed 50e3 50ee 50f9 
-50f5 5109 5101 5102 5116 5115 5114 511a 
-5121 513a 5137 513c 513b 513f 5140 5152 
-514c 5154 5162 7af8 5169 516a 516e 5180 
-5182 56d8 518c 5189 518f 5191 5193 5195 
-5196 51a4 51a6 51a2 51a9 51aa 51ab 51b3 
-51b1 51b2 51b0 51b5 51bd 51c5 51c9 51db 
-51e0 8655 51e9 51ed 51f0 51f5 51fe 5204 
-520b 5214 520e 5227 522a 522e 5233 5239 
-524f 5244 524b 524c 525e 5254 526a 5274 
-5269 5273 527f 527d 528d 5294 5292 5271 
-5288 5291 8fa8     -1     -1     -1     -1     -1 
-    -1 8fa7 52ac 52ad 52bc 52b5 52c1 52cd 
-52d7 52de 52e3 52e6 98ed 52e0 52f3 52f5 
-52f8 52f9 5306 5308 7538 530d 5310 530f 
-5315 531a 5323 532f 5331 5333 5338 5340 
-5346 5345 4e17 5349 534d 51d6 535e 5369 
-536e 5918 537b 5377 5382 5396 53a0 53a6 
-53a5 53ae 53b0 53b6 53c3 7c12 96d9 53df 
-66fc 71ee 53ee 53e8 53ed 53fa 5401 543d 
-5440 542c 542d 543c 542e 5436 5429 541d 
-544e 548f 5475 548e 545f 5471 5477 5470 
-5492 547b 5480 5476 5484 5490 5486 54c7 
-54a2 54b8 54a5 54ac 54c4 54c8 54a8     -1 
-    -1     -1     -1     -1     -1 54ab 54c2 54a4 
-54be 54bc 54d8 54e5 54e6 550f 5514 54fd 
-54ee 54ed 54fa 54e2 5539 5540 5563 554c 
-552e 555c 5545 5556 5557 5538 5533 555d 
-5599 5580 54af 558a 559f 557b 557e 5598 
-559e 55ae 557c 5583 55a9 5587 55a8 55da 
-55c5 55df 55c4 55dc 55e4 55d4 5614 55f7 
-5616 55fe 55fd 561b 55f9 564e 5650 71df 
-5634 5636 5632 5638 566b 5664 562f 566c 
-566a 5686 5680 568a 56a0 5694 568f 56a5 
-56ae 56b6 56b4 56c2 56bc 56c1 56c3 56c0 
-56c8 56ce 56d1 56d3 56d7 56ee 56f9 5700 
-56ff 5704 5709     -1     -1     -1     -1     -1 
-    -1 5708 570b 570d 5713 5718 5716 55c7 
-571c 5726 5737 5738 574e 573b 5740 574f 
-5769 57c0 5788 5761 577f 5789 5793 57a0 
-57b3 57a4 57aa 57b0 57c3 57c6 57d4 57d2 
-57d3 580a 57d6 57e3 580b 5819 581d 5872 
-5821 5862 584b 5870 6bc0 5852 583d 5879 
-5885 58b9 589f 58ab 58ba 58de 58bb 58b8 
-58ae 58c5 58d3 58d1 58d7 58d9 58d8 58e5 
-58dc 58e4 58df 58ef 58fa 58f9 58fb 58fc 
-58fd 5902 590a 5910 591b 68a6 5925 592c 
-592d 5932 5938 593e 7ad2 5955 5950 594e 
-595a 5958 5962 5960 5967 596c 5969     -1 
-    -1     -1     -1     -1     -1 5978 5981 599d 
-4f5e 4fab 59a3 59b2 59c6 59e8 59dc 598d 
-59d9 59da 5a25 5a1f 5a11 5a1c 5a09 5a1a 
-5a40 5a6c 5a49 5a35 5a36 5a62 5a6a 5a9a 
-5abc 5abe 5acb 5ac2 5abd 5ae3 5ad7 5ae6 
-5ae9 5ad6 5afa 5afb 5b0c 5b0b 5b16 5b32 
-5ad0 5b2a 5b36 5b3e 5b43 5b45 5b40 5b51 
-5b55 5b5a 5b5b 5b65 5b69 5b70 5b73 5b75 
-5b78 6588 5b7a 5b80 5b83 5ba6 5bb8 5bc3 
-5bc7 5bc9 5bd4 5bd0 5be4 5be6 5be2 5bde 
-5be5 5beb 5bf0 5bf6 5bf3 5c05 5c07 5c08 
-5c0d 5c13 5c20 5c22 5c28 5c38 5c39 5c41 
-5c46 5c4e 5c53     -1     -1     -1     -1     -1 
-    -1 5c50 5c4f 5b71 5c6c 5c6e 4e62 5c76 
-5c79 5c8c 5c91 5c94 599b 5cab 5cbb 5cb6 
-5cbc 5cb7 5cc5 5cbe 5cc7 5cd9 5ce9 5cfd 
-5cfa 5ced 5d8c 5cea 5d0b 5d15 5d17 5d5c 
-5d1f 5d1b 5d11 5d14 5d22 5d1a 5d19 5d18 
-5d4c 5d52 5d4e 5d4b 5d6c 5d73 5d76 5d87 
-5d84 5d82 5da2 5d9d 5dac 5dae 5dbd 5d90 
-5db7 5dbc 5dc9 5dcd 5dd3 5dd2 5dd6 5ddb 
-5deb 5df2 5df5 5e0b 5e1a 5e19 5e11 5e1b 
-5e36 5e37 5e44 5e43 5e40 5e4e 5e57 5e54 
-5e5f 5e62 5e64 5e47 5e75 5e76 5e7a 9ebc 
-5e7f 5ea0 5ec1 5ec2 5ec8 5ed0 5ecf     -1 
-    -1     -1     -1     -1     -1 5ed6 5ee3 5edd 
-5eda 5edb 5ee2 5ee1 5ee8 5ee9 5eec 5ef1 
-5ef3 5ef0 5ef4 5ef8 5efe 5f03 5f09 5f5d 
-5f5c 5f0b 5f11 5f16 5f29 5f2d 5f38 5f41 
-5f48 5f4c 5f4e 5f2f 5f51 5f56 5f57 5f59 
-5f61 5f6d 5f73 5f77 5f83 5f82 5f7f 5f8a 
-5f88 5f91 5f87 5f9e 5f99 5f98 5fa0 5fa8 
-5fad 5fbc 5fd6 5ffb 5fe4 5ff8 5ff1 5fdd 
-60b3 5fff 6021 6060 6019 6010 6029 600e 
-6031 601b 6015 602b 6026 600f 603a 605a 
-6041 606a 6077 605f 604a 6046 604d 6063 
-6043 6064 6042 606c 606b 6059 6081 608d 
-60e7 6083 609a     -1     -1     -1     -1     -1 
-    -1 6084 609b 6096 6097 6092 60a7 608b 
-60e1 60b8 60e0 60d3 60b4 5ff0 60bd 60c6 
-60b5 60d8 614d 6115 6106 60f6 60f7 6100 
-60f4 60fa 6103 6121 60fb 60f1 610d 610e 
-6147 613e 6128 6127 614a 613f 613c 612c 
-6134 613d 6142 6144 6173 6177 6158 6159 
-615a 616b 6174 616f 6165 6171 615f 615d 
-6153 6175 6199 6196 6187 61ac 6194 619a 
-618a 6191 61ab 61ae 61cc 61ca 61c9 61f7 
-61c8 61c3 61c6 61ba 61cb 7f79 61cd 61e6 
-61e3 61f6 61fa 61f4 61ff 61fd 61fc 61fe 
-6200 6208 6209 620d 620c 6214 621b     -1 
-    -1     -1     -1     -1     -1 621e 6221 622a 
-622e 6230 6232 6233 6241 624e 625e 6263 
-625b 6260 6268 627c 6282 6289 627e 6292 
-6293 6296 62d4 6283 6294 62d7 62d1 62bb 
-62cf 62ff 62c6 64d4 62c8 62dc 62cc 62ca 
-62c2 62c7 629b 62c9 630c 62ee 62f1 6327 
-6302 6308 62ef 62f5 6350 633e 634d 641c 
-634f 6396 638e 6380 63ab 6376 63a3 638f 
-6389 639f 63b5 636b 6369 63be 63e9 63c0 
-63c6 63e3 63c9 63d2 63f6 63c4 6416 6434 
-6406 6413 6426 6436 651d 6417 6428 640f 
-6467 646f 6476 644e 652a 6495 6493 64a5 
-64a9 6488 64bc     -1     -1     -1     -1     -1 
-    -1 64da 64d2 64c5 64c7 64bb 64d8 64c2 
-64f1 64e7 8209 64e0 64e1 62ac 64e3 64ef 
-652c 64f6 64f4 64f2 64fa 6500 64fd 6518 
-651c 6505 6524 6523 652b 6534 6535 6537 
-6536 6538 754b 6548 6556 6555 654d 6558 
-655e 655d 6572 6578 6582 6583 8b8a 659b 
-659f 65ab 65b7 65c3 65c6 65c1 65c4 65cc 
-65d2 65db 65d9 65e0 65e1 65f1 6772 660a 
-6603 65fb 6773 6635 6636 6634 661c 664f 
-6644 6649 6641 665e 665d 6664 6667 6668 
-665f 6662 6670 6683 6688 668e 6689 6684 
-6698 669d 66c1 66b9 66c9 66be 66bc     -1 
-    -1     -1     -1     -1     -1 66c4 66b8 66d6 
-66da 66e0 663f 66e6 66e9 66f0 66f5 66f7 
-670f 6716 671e 6726 6727 9738 672e 673f 
-6736 6741 6738 6737 6746 675e 6760 6759 
-6763 6764 6789 6770 67a9 677c 676a 678c 
-678b 67a6 67a1 6785 67b7 67ef 67b4 67ec 
-67b3 67e9 67b8 67e4 67de 67dd 67e2 67ee 
-67b9 67ce 67c6 67e7 6a9c 681e 6846 6829 
-6840 684d 6832 684e 68b3 682b 6859 6863 
-6877 687f 689f 688f 68ad 6894 689d 689b 
-6883 6aae 68b9 6874 68b5 68a0 68ba 690f 
-688d 687e 6901 68ca 6908 68d8 6922 6926 
-68e1 690c 68cd     -1     -1     -1     -1     -1 
-    -1 68d4 68e7 68d5 6936 6912 6904 68d7 
-68e3 6925 68f9 68e0 68ef 6928 692a 691a 
-6923 6921 68c6 6979 6977 695c 6978 696b 
-6954 697e 696e 6939 6974 693d 6959 6930 
-6961 695e 695d 6981 696a 69b2 69ae 69d0 
-69bf 69c1 69d3 69be 69ce 5be8 69ca 69dd 
-69bb 69c3 69a7 6a2e 6991 69a0 699c 6995 
-69b4 69de 69e8 6a02 6a1b 69ff 6b0a 69f9 
-69f2 69e7 6a05 69b1 6a1e 69ed 6a14 69eb 
-6a0a 6a12 6ac1 6a23 6a13 6a44 6a0c 6a72 
-6a36 6a78 6a47 6a62 6a59 6a66 6a48 6a38 
-6a22 6a90 6a8d 6aa0 6a84 6aa2 6aa3     -1 
-    -1     -1     -1     -1     -1 6a97 8617 6abb 
-6ac3 6ac2 6ab8 6ab3 6aac 6ade 6ad1 6adf 
-6aaa 6ada 6aea 6afb 6b05 8616 6afa 6b12 
-6b16 9b31 6b1f 6b38 6b37 76dc 6b39 98ee 
-6b47 6b43 6b49 6b50 6b59 6b54 6b5b 6b5f 
-6b61 6b78 6b79 6b7f 6b80 6b84 6b83 6b8d 
-6b98 6b95 6b9e 6ba4 6baa 6bab 6baf 6bb2 
-6bb1 6bb3 6bb7 6bbc 6bc6 6bcb 6bd3 6bdf 
-6bec 6beb 6bf3 6bef 9ebe 6c08 6c13 6c14 
-6c1b 6c24 6c23 6c5e 6c55 6c62 6c6a 6c82 
-6c8d 6c9a 6c81 6c9b 6c7e 6c68 6c73 6c92 
-6c90 6cc4 6cf1 6cd3 6cbd 6cd7 6cc5 6cdd 
-6cae 6cb1 6cbe     -1     -1     -1     -1     -1 
-    -1 6cba 6cdb 6cef 6cd9 6cea 6d1f 884d 
-6d36 6d2b 6d3d 6d38 6d19 6d35 6d33 6d12 
-6d0c 6d63 6d93 6d64 6d5a 6d79 6d59 6d8e 
-6d95 6fe4 6d85 6df9 6e15 6e0a 6db5 6dc7 
-6de6 6db8 6dc6 6dec 6dde 6dcc 6de8 6dd2 
-6dc5 6dfa 6dd9 6de4 6dd5 6dea 6dee 6e2d 
-6e6e 6e2e 6e19 6e72 6e5f 6e3e 6e23 6e6b 
-6e2b 6e76 6e4d 6e1f 6e43 6e3a 6e4e 6e24 
-6eff 6e1d 6e38 6e82 6eaa 6e98 6ec9 6eb7 
-6ed3 6ebd 6eaf 6ec4 6eb2 6ed4 6ed5 6e8f 
-6ea5 6ec2 6e9f 6f41 6f11 704c 6eec 6ef8 
-6efe 6f3f 6ef2 6f31 6eef 6f32 6ecc     -1 
-    -1     -1     -1     -1     -1 6f3e 6f13 6ef7 
-6f86 6f7a 6f78 6f81 6f80 6f6f 6f5b 6ff3 
-6f6d 6f82 6f7c 6f58 6f8e 6f91 6fc2 6f66 
-6fb3 6fa3 6fa1 6fa4 6fb9 6fc6 6faa 6fdf 
-6fd5 6fec 6fd4 6fd8 6ff1 6fee 6fdb 7009 
-700b 6ffa 7011 7001 700f 6ffe 701b 701a 
-6f74 701d 7018 701f 7030 703e 7032 7051 
-7063 7099 7092 70af 70f1 70ac 70b8 70b3 
-70ae 70df 70cb 70dd 70d9 7109 70fd 711c 
-7119 7165 7155 7188 7166 7162 714c 7156 
-716c 718f 71fb 7184 7195 71a8 71ac 71d7 
-71b9 71be 71d2 71c9 71d4 71ce 71e0 71ec 
-71e7 71f5 71fc     -1     -1     -1     -1     -1 
-    -1 71f9 71ff 720d 7210 721b 7228 722d 
-722c 7230 7232 723b 723c 723f 7240 7246 
-724b 7258 7274 727e 7282 7281 7287 7292 
-7296 72a2 72a7 72b9 72b2 72c3 72c6 72c4 
-72ce 72d2 72e2 72e0 72e1 72f9 72f7 500f 
-7317 730a 731c 7316 731d 7334 732f 7329 
-7325 733e 734e 734f 9ed8 7357 736a 7368 
-7370 7378 7375 737b 737a 73c8 73b3 73ce 
-73bb 73c0 73e5 73ee 73de 74a2 7405 746f 
-7425 73f8 7432 743a 7455 743f 745f 7459 
-7441 745c 7469 7470 7463 746a 7476 747e 
-748b 749e 74a7 74ca 74cf 74d4 73f1     -1 
-    -1     -1     -1     -1     -1 74e0 74e3 74e7 
-74e9 74ee 74f2 74f0 74f1 74f8 74f7 7504 
-7503 7505 750c 750e 750d 7515 7513 751e 
-7526 752c 753c 7544 754d 754a 7549 755b 
-7546 755a 7569 7564 7567 756b 756d 7578 
-7576 7586 7587 7574 758a 7589 7582 7594 
-759a 759d 75a5 75a3 75c2 75b3 75c3 75b5 
-75bd 75b8 75bc 75b1 75cd 75ca 75d2 75d9 
-75e3 75de 75fe 75ff 75fc 7601 75f0 75fa 
-75f2 75f3 760b 760d 7609 761f 7627 7620 
-7621 7622 7624 7634 7630 763b 7647 7648 
-7646 765c 7658 7661 7662 7668 7669 766a 
-7667 766c 7670     -1     -1     -1     -1     -1 
-    -1 7672 7676 7678 767c 7680 7683 7688 
-768b 768e 7696 7693 7699 769a 76b0 76b4 
-76b8 76b9 76ba 76c2 76cd 76d6 76d2 76de 
-76e1 76e5 76e7 76ea 862f 76fb 7708 7707 
-7704 7729 7724 771e 7725 7726 771b 7737 
-7738 7747 775a 7768 776b 775b 7765 777f 
-777e 7779 778e 778b 7791 77a0 779e 77b0 
-77b6 77b9 77bf 77bc 77bd 77bb 77c7 77cd 
-77d7 77da 77dc 77e3 77ee 77fc 780c 7812 
-7926 7820 792a 7845 788e 7874 7886 787c 
-789a 788c 78a3 78b5 78aa 78af 78d1 78c6 
-78cb 78d4 78be 78bc 78c5 78ca 78ec     -1 
-    -1     -1     -1     -1     -1 78e7 78da 78fd 
-78f4 7907 7912 7911 7919 792c 792b 7940 
-7960 7957 795f 795a 7955 7953 797a 797f 
-798a 799d 79a7 9f4b 79aa 79ae 79b3 79b9 
-79ba 79c9 79d5 79e7 79ec 79e1 79e3 7a08 
-7a0d 7a18 7a19 7a20 7a1f 7980 7a31 7a3b 
-7a3e 7a37 7a43 7a57 7a49 7a61 7a62 7a69 
-9f9d 7a70 7a79 7a7d 7a88 7a97 7a95 7a98 
-7a96 7aa9 7ac8 7ab0 7ab6 7ac5 7ac4 7abf 
-9083 7ac7 7aca 7acd 7acf 7ad5 7ad3 7ad9 
-7ada 7add 7ae1 7ae2 7ae6 7aed 7af0 7b02 
-7b0f 7b0a 7b06 7b33 7b18 7b19 7b1e 7b35 
-7b28 7b36 7b50     -1     -1     -1     -1     -1 
-    -1 7b7a 7b04 7b4d 7b0b 7b4c 7b45 7b75 
-7b65 7b74 7b67 7b70 7b71 7b6c 7b6e 7b9d 
-7b98 7b9f 7b8d 7b9c 7b9a 7b8b 7b92 7b8f 
-7b5d 7b99 7bcb 7bc1 7bcc 7bcf 7bb4 7bc6 
-7bdd 7be9 7c11 7c14 7be6 7be5 7c60 7c00 
-7c07 7c13 7bf3 7bf7 7c17 7c0d 7bf6 7c23 
-7c27 7c2a 7c1f 7c37 7c2b 7c3d 7c4c 7c43 
-7c54 7c4f 7c40 7c50 7c58 7c5f 7c64 7c56 
-7c65 7c6c 7c75 7c83 7c90 7ca4 7cad 7ca2 
-7cab 7ca1 7ca8 7cb3 7cb2 7cb1 7cae 7cb9 
-7cbd 7cc0 7cc5 7cc2 7cd8 7cd2 7cdc 7ce2 
-9b3b 7cef 7cf2 7cf4 7cf6 7cfa 7d06     -1 
-    -1     -1     -1     -1     -1 7d02 7d1c 7d15 
-7d0a 7d45 7d4b 7d2e 7d32 7d3f 7d35 7d46 
-7d73 7d56 7d4e 7d72 7d68 7d6e 7d4f 7d63 
-7d93 7d89 7d5b 7d8f 7d7d 7d9b 7dba 7dae 
-7da3 7db5 7dc7 7dbd 7dab 7e3d 7da2 7daf 
-7ddc 7db8 7d9f 7db0 7dd8 7ddd 7de4 7dde 
-7dfb 7df2 7de1 7e05 7e0a 7e23 7e21 7e12 
-7e31 7e1f 7e09 7e0b 7e22 7e46 7e66 7e3b 
-7e35 7e39 7e43 7e37 7e32 7e3a 7e67 7e5d 
-7e56 7e5e 7e59 7e5a 7e79 7e6a 7e69 7e7c 
-7e7b 7e83 7dd5 7e7d 8fae 7e7f 7e88 7e89 
-7e8c 7e92 7e90 7e93 7e94 7e96 7e8e 7e9b 
-7e9c 7f38 7f3a     -1     -1     -1     -1     -1 
-    -1 7f45 7f4c 7f4d 7f4e 7f50 7f51 7f55 
-7f54 7f58 7f5f 7f60 7f68 7f69 7f67 7f78 
-7f82 7f86 7f83 7f88 7f87 7f8c 7f94 7f9e 
-7f9d 7f9a 7fa3 7faf 7fb2 7fb9 7fae 7fb6 
-7fb8 8b71 7fc5 7fc6 7fca 7fd5 7fd4 7fe1 
-7fe6 7fe9 7ff3 7ff9 98dc 8006 8004 800b 
-8012 8018 8019 801c 8021 8028 803f 803b 
-804a 8046 8052 8058 805a 805f 8062 8068 
-8073 8072 8070 8076 8079 807d 807f 8084 
-8086 8085 809b 8093 809a 80ad 5190 80ac 
-80db 80e5 80d9 80dd 80c4 80da 80d6 8109 
-80ef 80f1 811b 8129 8123 812f 814b     -1 
-    -1     -1     -1     -1     -1 968b 8146 813e 
-8153 8151 80fc 8171 816e 8165 8166 8174 
-8183 8188 818a 8180 8182 81a0 8195 81a4 
-81a3 815f 8193 81a9 81b0 81b5 81be 81b8 
-81bd 81c0 81c2 81ba 81c9 81cd 81d1 81d9 
-81d8 81c8 81da 81df 81e0 81e7 81fa 81fb 
-81fe 8201 8202 8205 8207 820a 820d 8210 
-8216 8229 822b 8238 8233 8240 8259 8258 
-825d 825a 825f 8264 8262 8268 826a 826b 
-822e 8271 8277 8278 827e 828d 8292 82ab 
-829f 82bb 82ac 82e1 82e3 82df 82d2 82f4 
-82f3 82fa 8393 8303 82fb 82f9 82de 8306 
-82dc 8309 82d9     -1     -1     -1     -1     -1 
-    -1 8335 8334 8316 8332 8331 8340 8339 
-8350 8345 832f 832b 8317 8318 8385 839a 
-83aa 839f 83a2 8396 8323 838e 8387 838a 
-837c 83b5 8373 8375 83a0 8389 83a8 83f4 
-8413 83eb 83ce 83fd 8403 83d8 840b 83c1 
-83f7 8407 83e0 83f2 840d 8422 8420 83bd 
-8438 8506 83fb 846d 842a 843c 855a 8484 
-8477 846b 84ad 846e 8482 8469 8446 842c 
-846f 8479 8435 84ca 8462 84b9 84bf 849f 
-84d9 84cd 84bb 84da 84d0 84c1 84c6 84d6 
-84a1 8521 84ff 84f4 8517 8518 852c 851f 
-8515 8514 84fc 8540 8563 8558 8548     -1 
-    -1     -1     -1     -1     -1 8541 8602 854b 
-8555 8580 85a4 8588 8591 858a 85a8 856d 
-8594 859b 85ea 8587 859c 8577 857e 8590 
-85c9 85ba 85cf 85b9 85d0 85d5 85dd 85e5 
-85dc 85f9 860a 8613 860b 85fe 85fa 8606 
-8622 861a 8630 863f 864d 4e55 8654 865f 
-8667 8671 8693 86a3 86a9 86aa 868b 868c 
-86b6 86af 86c4 86c6 86b0 86c9 8823 86ab 
-86d4 86de 86e9 86ec 86df 86db 86ef 8712 
-8706 8708 8700 8703 86fb 8711 8709 870d 
-86f9 870a 8734 873f 8737 873b 8725 8729 
-871a 8760 875f 8778 874c 874e 8774 8757 
-8768 876e 8759     -1     -1     -1     -1     -1 
-    -1 8753 8763 876a 8805 87a2 879f 8782 
-87af 87cb 87bd 87c0 87d0 96d6 87ab 87c4 
-87b3 87c7 87c6 87bb 87ef 87f2 87e0 880f 
-880d 87fe 87f6 87f7 880e 87d2 8811 8816 
-8815 8822 8821 8831 8836 8839 8827 883b 
-8844 8842 8852 8859 885e 8862 886b 8881 
-887e 889e 8875 887d 88b5 8872 8882 8897 
-8892 88ae 8899 88a2 888d 88a4 88b0 88bf 
-88b1 88c3 88c4 88d4 88d8 88d9 88dd 88f9 
-8902 88fc 88f4 88e8 88f2 8904 890c 890a 
-8913 8943 891e 8925 892a 892b 8941 8944 
-893b 8936 8938 894c 891d 8960 895e     -1 
-    -1     -1     -1     -1     -1 8966 8964 896d 
-896a 896f 8974 8977 897e 8983 8988 898a 
-8993 8998 89a1 89a9 89a6 89ac 89af 89b2 
-89ba 89bd 89bf 89c0 89da 89dc 89dd 89e7 
-89f4 89f8 8a03 8a16 8a10 8a0c 8a1b 8a1d 
-8a25 8a36 8a41 8a5b 8a52 8a46 8a48 8a7c 
-8a6d 8a6c 8a62 8a85 8a82 8a84 8aa8 8aa1 
-8a91 8aa5 8aa6 8a9a 8aa3 8ac4 8acd 8ac2 
-8ada 8aeb 8af3 8ae7 8ae4 8af1 8b14 8ae0 
-8ae2 8af7 8ade 8adb 8b0c 8b07 8b1a 8ae1 
-8b16 8b10 8b17 8b20 8b33 97ab 8b26 8b2b 
-8b3e 8b28 8b41 8b4c 8b4f 8b4e 8b49 8b56 
-8b5b 8b5a 8b6b     -1     -1     -1     -1     -1 
-    -1 8b5f 8b6c 8b6f 8b74 8b7d 8b80 8b8c 
-8b8e 8b92 8b93 8b96 8b99 8b9a 8c3a 8c41 
-8c3f 8c48 8c4c 8c4e 8c50 8c55 8c62 8c6c 
-8c78 8c7a 8c82 8c89 8c85 8c8a 8c8d 8c8e 
-8c94 8c7c 8c98 621d 8cad 8caa 8cbd 8cb2 
-8cb3 8cae 8cb6 8cc8 8cc1 8ce4 8ce3 8cda 
-8cfd 8cfa 8cfb 8d04 8d05 8d0a 8d07 8d0f 
-8d0d 8d10 9f4e 8d13 8ccd 8d14 8d16 8d67 
-8d6d 8d71 8d73 8d81 8d99 8dc2 8dbe 8dba 
-8dcf 8dda 8dd6 8dcc 8ddb 8dcb 8dea 8deb 
-8ddf 8de3 8dfc 8e08 8e09 8dff 8e1d 8e1e 
-8e10 8e1f 8e42 8e35 8e30 8e34 8e4a     -1 
-    -1     -1     -1     -1     -1 8e47 8e49 8e4c 
-8e50 8e48 8e59 8e64 8e60 8e2a 8e63 8e55 
-8e76 8e72 8e7c 8e81 8e87 8e85 8e84 8e8b 
-8e8a 8e93 8e91 8e94 8e99 8eaa 8ea1 8eac 
-8eb0 8ec6 8eb1 8ebe 8ec5 8ec8 8ecb 8edb 
-8ee3 8efc 8efb 8eeb 8efe 8f0a 8f05 8f15 
-8f12 8f19 8f13 8f1c 8f1f 8f1b 8f0c 8f26 
-8f33 8f3b 8f39 8f45 8f42 8f3e 8f4c 8f49 
-8f46 8f4e 8f57 8f5c 8f62 8f63 8f64 8f9c 
-8f9f 8fa3 8fad 8faf 8fb7 8fda 8fe5 8fe2 
-8fea 8fef 9087 8ff4 9005 8ff9 8ffa 9011 
-9015 9021 900d 901e 9016 900b 9027 9036 
-9035 9039 8ff8     -1     -1     -1     -1     -1 
-    -1 904f 9050 9051 9052 900e 9049 903e 
-9056 9058 905e 9068 906f 9076 96a8 9072 
-9082 907d 9081 9080 908a 9089 908f 90a8 
-90af 90b1 90b5 90e2 90e4 6248 90db 9102 
-9112 9119 9132 9130 914a 9156 9158 9163 
-9165 9169 9173 9172 918b 9189 9182 91a2 
-91ab 91af 91aa 91b5 91b4 91ba 91c0 91c1 
-91c9 91cb 91d0 91d6 91df 91e1 91db 91fc 
-91f5 91f6 921e 91ff 9214 922c 9215 9211 
-925e 9257 9245 9249 9264 9248 9295 923f 
-924b 9250 929c 9296 9293 929b 925a 92cf 
-92b9 92b7 92e9 930f 92fa 9344 932e     -1 
-    -1     -1     -1     -1     -1 9319 9322 931a 
-9323 933a 9335 933b 935c 9360 937c 936e 
-9356 93b0 93ac 93ad 9394 93b9 93d6 93d7 
-93e8 93e5 93d8 93c3 93dd 93d0 93c8 93e4 
-941a 9414 9413 9403 9407 9410 9436 942b 
-9435 9421 943a 9441 9452 9444 945b 9460 
-9462 945e 946a 9229 9470 9475 9477 947d 
-945a 947c 947e 9481 947f 9582 9587 958a 
-9594 9596 9598 9599 95a0 95a8 95a7 95ad 
-95bc 95bb 95b9 95be 95ca 6ff6 95c3 95cd 
-95cc 95d5 95d4 95d6 95dc 95e1 95e5 95e2 
-9621 9628 962e 962f 9642 964c 964f 964b 
-9677 965c 965e     -1     -1     -1     -1     -1 
-    -1 965d 965f 9666 9672 966c 968d 9698 
-9695 9697 96aa 96a7 96b1 96b2 96b0 96b4 
-96b6 96b8 96b9 96ce 96cb 96c9 96cd 894d 
-96dc 970d 96d5 96f9 9704 9706 9708 9713 
-970e 9711 970f 9716 9719 9724 972a 9730 
-9739 973d 973e 9744 9746 9748 9742 9749 
-975c 9760 9764 9766 9768 52d2 976b 9771 
-9779 9785 977c 9781 977a 9786 978b 978f 
-9790 979c 97a8 97a6 97a3 97b3 97b4 97c3 
-97c6 97c8 97cb 97dc 97ed 9f4f 97f2 7adf 
-97f6 97f5 980f 980c 9838 9824 9821 9837 
-983d 9846 984f 984b 986b 986f 9870     -1 
-    -1     -1     -1     -1     -1 9871 9874 9873 
-98aa 98af 98b1 98b6 98c4 98c3 98c6 98e9 
-98eb 9903 9909 9912 9914 9918 9921 991d 
-991e 9924 9920 992c 992e 993d 993e 9942 
-9949 9945 9950 994b 9951 9952 994c 9955 
-9997 9998 99a5 99ad 99ae 99bc 99df 99db 
-99dd 99d8 99d1 99ed 99ee 99f1 99f2 99fb 
-99f8 9a01 9a0f 9a05 99e2 9a19 9a2b 9a37 
-9a45 9a42 9a40 9a43 9a3e 9a55 9a4d 9a5b 
-9a57 9a5f 9a62 9a65 9a64 9a69 9a6b 9a6a 
-9aad 9ab0 9abc 9ac0 9acf 9ad1 9ad3 9ad4 
-9ade 9adf 9ae2 9ae3 9ae6 9aef 9aeb 9aee 
-9af4 9af1 9af7     -1     -1     -1     -1     -1 
-    -1 9afb 9b06 9b18 9b1a 9b1f 9b22 9b23 
-9b25 9b27 9b28 9b29 9b2a 9b2e 9b2f 9b32 
-9b44 9b43 9b4f 9b4d 9b4e 9b51 9b58 9b74 
-9b93 9b83 9b91 9b96 9b97 9b9f 9ba0 9ba8 
-9bb4 9bc0 9bca 9bb9 9bc6 9bcf 9bd1 9bd2 
-9be3 9be2 9be4 9bd4 9be1 9c3a 9bf2 9bf1 
-9bf0 9c15 9c14 9c09 9c13 9c0c 9c06 9c08 
-9c12 9c0a 9c04 9c2e 9c1b 9c25 9c24 9c21 
-9c30 9c47 9c32 9c46 9c3e 9c5a 9c60 9c67 
-9c76 9c78 9ce7 9cec 9cf0 9d09 9d08 9ceb 
-9d03 9d06 9d2a 9d26 9daf 9d23 9d1f 9d44 
-9d15 9d12 9d41 9d3f 9d3e 9d46 9d48     -1 
-    -1     -1     -1     -1     -1 9d5d 9d5e 9d64 
-9d51 9d50 9d59 9d72 9d89 9d87 9dab 9d6f 
-9d7a 9d9a 9da4 9da9 9db2 9dc4 9dc1 9dbb 
-9db8 9dba 9dc6 9dcf 9dc2 9dd9 9dd3 9df8 
-9de6 9ded 9def 9dfd 9e1a 9e1b 9e1e 9e75 
-9e79 9e7d 9e81 9e88 9e8b 9e8c 9e92 9e95 
-9e91 9e9d 9ea5 9ea9 9eb8 9eaa 9ead 9761 
-9ecc 9ece 9ecf 9ed0 9ed4 9edc 9ede 9edd 
-9ee0 9ee5 9ee8 9eef 9ef4 9ef6 9ef7 9ef9 
-9efb 9efc 9efd 9f07 9f08 76b7 9f15 9f21 
-9f2c 9f3e 9f4a 9f52 9f54 9f63 9f5f 9f60 
-9f61 9f66 9f67 9f6c 9f6a 9f77 9f72 9f76 
-9f95 9f9c 9fa0     -1     -1     -1     -1     -1 
-    -1 582f 69c7 9059 7464 51dc 7199 
Index: xc/nls/XLC_LOCALE/koi8-c
diff -u /dev/null xc/nls/XLC_LOCALE/koi8-c:1.2
--- /dev/null	Mon Dec 18 14:27:02 2000
+++ xc/nls/XLC_LOCALE/koi8-c	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,80 @@
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/koi8-c,v 1.2 2000/12/01 17:43:03 dawes Exp $
+XCOMM  XLocale Database Sample for koi8-c.
+XCOMM 
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class (7 bit ASCII)
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		KOI8-C:GL
+		substitute	ISO8859-1:GL
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset         KOI8-C:GR
+	font            KOI8-C:GR
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	KOI8-C
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name           KOI8-C
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding     KOI8-C:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding     KOI8-C:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/koi8-r
diff -u xc/nls/XLC_LOCALE/koi8-r:3.2 xc/nls/XLC_LOCALE/koi8-r:3.3
--- xc/nls/XLC_LOCALE/koi8-r:3.2	Sun Nov 16 01:17:47 1997
+++ xc/nls/XLC_LOCALE/koi8-r	Fri Dec  1 12:43:03 2000
@@ -2,7 +2,7 @@
 XCOMM  XLocale Database Sample for koi8-r.
 XCOMM 
 XCOMM 
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/koi8-r,v 3.2 1997/11/16 06:17:47 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/koi8-r,v 3.3 2000/12/01 17:43:03 dawes Exp $
 
 XCOMM 
 XCOMM 	XLC_FONTSET category
@@ -10,8 +10,13 @@
 XLC_FONTSET
 XCOMM 	fs0 class (7 bit ASCII)
 fs0	{
-	charset		ISO8859-1:GL
-	font            KOI8-R:GL; ISO8859-1:GL
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		KOI8-R:GL
+		substitute	ISO8859-1:GL
+	}
 }
 XCOMM 	fs1 class 
 fs1	{
@@ -20,6 +25,19 @@
 }
 END XLC_FONTSET
 
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	KOI8-R
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
 XCOMM 
 XCOMM 	XLC_XLOCALE category
 XCOMM 
@@ -36,6 +54,10 @@
 wc_shift_bits		8
 #endif
 
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
 XCOMM 	cs0 class
 cs0	{
 	side		GL:Default
@@ -54,7 +76,7 @@
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     KOI8-R:GR; ISO8859-1:GR
+	ct_encoding     KOI8-R:GR
 }
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/koi8-u
diff -u xc/nls/XLC_LOCALE/koi8-u:1.1 xc/nls/XLC_LOCALE/koi8-u:1.2
--- xc/nls/XLC_LOCALE/koi8-u:1.1	Sat May 29 22:28:03 1999
+++ xc/nls/XLC_LOCALE/koi8-u	Fri Dec  1 12:43:03 2000
@@ -1,4 +1,4 @@
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/koi8-u,v 1.1 1999/05/30 02:28:03 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/koi8-u,v 1.2 2000/12/01 17:43:03 dawes Exp $
 XCOMM  XLocale Database Sample for koi8-u.
 XCOMM 
 
@@ -8,8 +8,13 @@
 XLC_FONTSET
 XCOMM 	fs0 class (7 bit ASCII)
 fs0	{
-	charset		ISO8859-1:GL
-	font            KOI8-U:GL; ISO8859-1:GL
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		KOI8-U:GL
+		substitute	ISO8859-1:GL
+	}
 }
 XCOMM 	fs1 class 
 fs1	{
@@ -18,6 +23,19 @@
 }
 END XLC_FONTSET
 
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	KOI8-U
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
 XCOMM 
 XCOMM 	XLC_XLOCALE category
 XCOMM 
@@ -34,6 +52,10 @@
 wc_shift_bits		8
 #endif
 
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
 XCOMM 	cs0 class
 cs0	{
 	side		GL:Default
@@ -52,7 +74,7 @@
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     KOI8-U:GR; ISO8859-1:GR
+	ct_encoding     KOI8-U:GR
 }
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/ksc5601
diff -u xc/nls/XLC_LOCALE/ksc5601:1.1.1.1 xc/nls/XLC_LOCALE/ksc5601:removed
--- xc/nls/XLC_LOCALE/ksc5601:1.1.1.1	Sat Dec 21 22:29:37 1996
+++ xc/nls/XLC_LOCALE/ksc5601	Mon Dec 18 14:27:03 2000
@@ -1,973 +0,0 @@
-	3000  3001  3002  00b7  2025  2026  00a8  3003  00ad  
-	2015  2225  ff3c  223c  2018  2019  201c  201d  3014  
-	3015  3008  3009  300a  300b  300c  300d  300e  300f  
-	3010  3011  00b1  00d7  00f7  2260  2264  2265  221e  
-	2234  00b0  2032  2033  2103  212b  ffe0  ffe1  ffe5  
-	2642  2640  2220  22a5  2312  2202  2207  2261  2252  
-	00a7  203b  2606  2605  25cb  25cf  25ce  25c7  25c6  
-	25a1  25a0  25b3  25b2  25bd  25bc  2192  2190  2191  
-	2193  2194  3013  226a  226b  221a  223d  221d  2235  
-	222b  222c  2208  220b  2286  2287  2282  2283  222a  
-	2229  2227  2228  ffe2  21d2  21d4  2200  2203  00b4  
-	ff5e  02c7  02d8  02dd  02da  02d9  00b8  02db  00a1  
-	00bf  02d0  222e  2211  220f  00a4  2109  2030  25c1  
-	25c0  25b7  25b6  2664  2660  2661  2665  2667  2663  
-	25c9  25c8  25a3  25d0  25d1  2592  25a4  25a5  25a8  
-	25a7  25a6  25a9  2668  260f  260e  261c  261e  00b6  
-	2020  2021  2195  2197  2199  2196  2198  266d  2669  
-	266a  266c  327f  321c  2116  33c7  2122  33c2  33d8  
-	2121  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  ff01  
-	ff02  ff03  ff04  ff05  ff06  ff07  ff08  ff09  ff0a  
-	ff0b  ff0c  ff0d  ff0e  ff0f  ff10  ff11  ff12  ff13  
-	ff14  ff15  ff16  ff17  ff18  ff19  ff1a  ff1b  ff1c  
-	ff1d  ff1e  ff1f  ff20  ff21  ff22  ff23  ff24  ff25  
-	ff26  ff27  ff28  ff29  ff2a  ff2b  ff2c  ff2d  ff2e  
-	ff2f  ff30  ff31  ff32  ff33  ff34  ff35  ff36  ff37  
-	ff38  ff39  ff3a  ff3b  ffe6  ff3d  ff3e  ff3f  ff40  
-	ff41  ff42  ff43  ff44  ff45  ff46  ff47  ff48  ff49  
-	ff4a  ff4b  ff4c  ff4d  ff4e  ff4f  ff50  ff51  ff52  
-	ff53  ff54  ff55  ff56  ff57  ff58  ff59  ff5a  ff5b  
-	ff5c  ff5d  ffe3  3131  3132  3133  3134  3135  3136  
-	3137  3138  3139  313a  313b  313c  313d  313e  313f  
-	3140  3141  3142  3143  3144  3145  3146  3147  3148  
-	3149  314a  314b  314c  314d  314e  314f  3150  3151  
-	3152  3153  3154  3155  3156  3157  3158  3159  315a  
-	315b  315c  315d  315e  315f  3160  3161  3162  3163  
-	3164  3165  3166  3167  3168  3169  316a  316b  316c  
-	316d  316e  316f  3170  3171  3172  3173  3174  3175  
-	3176  3177  3178  3179  317a  317b  317c  317d  317e  
-	317f  3180  3181  3182  3183  3184  3185  3186  3187  
-	3188  3189  318a  318b  318c  318d  318e  2170  2171  
-	2172  2173  2174  2175  2176  2177  2178  2179  0000  
-	0000  0000  0000  0000  2160  2161  2162  2163  2164  
-	2165  2166  2167  2168  2169  0000  0000  0000  0000  
-	0000  0000  0000  0391  0392  0393  0394  0395  0396  
-	0397  0398  0399  039a  039b  039c  039d  039e  039f  
-	03a0  03a1  03a3  03a4  03a5  03a6  03a7  03a8  03a9  
-	0000  0000  0000  0000  0000  0000  0000  0000  03b1  
-	03b2  03b3  03b4  03b5  03b6  03b7  03b8  03b9  03ba  
-	03bb  03bc  03bd  03be  03bf  03c0  03c1  03c3  03c4  
-	03c5  03c6  03c7  03c8  03c9  0000  0000  0000  0000  
-	0000  0000  2500  2502  250c  2510  2518  2514  251c  
-	252c  2524  2534  253c  2501  2503  250f  2513  251b  
-	2517  2523  2533  252b  253b  254b  2520  252f  2528  
-	2537  253f  251d  2530  2525  2538  2542  2512  2511  
-	251a  2519  2516  2515  250e  250d  251e  251f  2521  
-	2522  2526  2527  2529  252a  252d  252e  2531  2532  
-	2535  2536  2539  253a  253d  253e  2540  2541  2543  
-	2544  2545  2546  2547  2548  2549  254a  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  3395  3396  3397  
-	2113  3398  33c4  33a3  33a4  33a5  33a6  3399  339a  
-	339b  339c  339d  339e  339f  33a0  33a1  33a2  33ca  
-	338d  338e  338f  33cf  3388  3389  33c8  33a7  33a8  
-	33b0  33b1  33b2  33b3  33b4  33b5  33b6  33b7  33b8  
-	33b9  3380  3381  3382  3383  3384  33ba  33bb  33bc  
-	33bd  33be  33bf  3390  3391  3392  3393  3394  2126  
-	33c0  33c1  338a  338b  338c  33d6  33c5  33ad  33ae  
-	33af  33db  33a9  33aa  33ab  33ac  33dd  33d0  33d3  
-	33c3  33c9  33dc  33c6  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  00c6  00d0  00aa  0126  0000  0132  0000  013f  
-	0141  00d8  0152  00ba  00de  0166  014a  0000  3260  
-	3261  3262  3263  3264  3265  3266  3267  3268  3269  
-	326a  326b  326c  326d  326e  326f  3270  3271  3272  
-	3273  3274  3275  3276  3277  3278  3279  327a  327b  
-	24d0  24d1  24d2  24d3  24d4  24d5  24d6  24d7  24d8  
-	24d9  24da  24db  24dc  24dd  24de  24df  24e0  24e1  
-	24e2  24e3  24e4  24e5  24e6  24e7  24e8  24e9  2460  
-	2461  2462  2463  2464  2465  2466  2467  2468  2469  
-	246a  246b  246c  246d  246e  00bd  2153  2154  00bc  
-	00be  215b  215c  215d  215e  00e6  0111  00f0  0127  
-	0131  0133  0138  0140  0142  00f8  0153  00df  00fe  
-	0167  014b  0149  3200  3201  3202  3203  3204  3205  
-	3206  3207  3208  3209  320a  320b  320c  320d  320e  
-	320f  3210  3211  3212  3213  3214  3215  3216  3217  
-	3218  3219  321a  321b  249c  249d  249e  249f  24a0  
-	24a1  24a2  24a3  24a4  24a5  24a6  24a7  24a8  24a9  
-	24aa  24ab  24ac  24ad  24ae  24af  24b0  24b1  24b2  
-	24b3  24b4  24b5  2474  2475  2476  2477  2478  2479  
-	247a  247b  247c  247d  247e  247f  2480  2481  2482  
-	00b9  00b2  00b3  2074  207f  2081  2082  2083  2084  
-	3041  3042  3043  3044  3045  3046  3047  3048  3049  
-	304a  304b  304c  304d  304e  304f  3050  3051  3052  
-	3053  3054  3055  3056  3057  3058  3059  305a  305b  
-	305c  305d  305e  305f  3060  3061  3062  3063  3064  
-	3065  3066  3067  3068  3069  306a  306b  306c  306d  
-	306e  306f  3070  3071  3072  3073  3074  3075  3076  
-	3077  3078  3079  307a  307b  307c  307d  307e  307f  
-	3080  3081  3082  3083  3084  3085  3086  3087  3088  
-	3089  308a  308b  308c  308d  308e  308f  3090  3091  
-	3092  3093  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  30a1  30a2  30a3  30a4  30a5  
-	30a6  30a7  30a8  30a9  30aa  30ab  30ac  30ad  30ae  
-	30af  30b0  30b1  30b2  30b3  30b4  30b5  30b6  30b7  
-	30b8  30b9  30ba  30bb  30bc  30bd  30be  30bf  30c0  
-	30c1  30c2  30c3  30c4  30c5  30c6  30c7  30c8  30c9  
-	30ca  30cb  30cc  30cd  30ce  30cf  30d0  30d1  30d2  
-	30d3  30d4  30d5  30d6  30d7  30d8  30d9  30da  30db  
-	30dc  30dd  30de  30df  30e0  30e1  30e2  30e3  30e4  
-	30e5  30e6  30e7  30e8  30e9  30ea  30eb  30ec  30ed  
-	30ee  30ef  30f0  30f1  30f2  30f3  30f4  30f5  30f6  
-	0000  0000  0000  0000  0000  0000  0000  0000  0410  
-	0411  0412  0413  0414  0415  0401  0416  0417  0418  
-	0419  041a  041b  041c  041d  041e  041f  0420  0421  
-	0422  0423  0424  0425  0426  0427  0428  0429  042a  
-	042b  042c  042d  042e  042f  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0430  0431  0432  0433  0434  0435  0451  
-	0436  0437  0438  0439  043a  043b  043c  043d  043e  
-	043f  0440  0441  0442  0443  0444  0445  0446  0447  
-	0448  0449  044a  044b  044c  044d  044e  044f  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  3400  3401  3402  
-	3403  3404  3405  3406  3407  3408  3409  340a  340b  
-	340c  340d  340e  340f  3410  3411  3412  3413  3414  
-	3415  3416  3417  3418  3419  341a  341b  341c  341d  
-	341e  341f  3420  3421  3422  3423  3424  3425  3426  
-	3427  3428  3429  342a  342b  342c  342d  342e  342f  
-	3430  3431  3432  3433  3434  3435  3436  3437  3438  
-	3439  343a  343b  343c  343d  343e  343f  3440  3441  
-	3442  3443  3444  3445  3446  3447  3448  3449  344a  
-	344b  344c  344d  344e  344f  3450  3451  3452  3453  
-	3454  3455  3456  3457  3458  3459  345a  345b  345c  
-	345d  345e  345f  3460  3461  3462  3463  3464  3465  
-	3466  3467  3468  3469  346a  346b  346c  346d  346e  
-	346f  3470  3471  3472  3473  3474  3475  3476  3477  
-	3478  3479  347a  347b  347c  347d  347e  347f  3480  
-	3481  3482  3483  3484  3485  3486  3487  3488  3489  
-	348a  348b  348c  348d  348e  348f  3490  3491  3492  
-	3493  3494  3495  3496  3497  3498  3499  349a  349b  
-	349c  349d  349e  349f  34a0  34a1  34a2  34a3  34a4  
-	34a5  34a6  34a7  34a8  34a9  34aa  34ab  34ac  34ad  
-	34ae  34af  34b0  34b1  34b2  34b3  34b4  34b5  34b6  
-	34b7  34b8  34b9  34ba  34bb  34bc  34bd  34be  34bf  
-	34c0  34c1  34c2  34c3  34c4  34c5  34c6  34c7  34c8  
-	34c9  34ca  34cb  34cc  34cd  34ce  34cf  34d0  34d1  
-	34d2  34d3  34d4  34d5  34d6  34d7  34d8  34d9  34da  
-	34db  34dc  34dd  34de  34df  34e0  34e1  34e2  34e3  
-	34e4  34e5  34e6  34e7  34e8  34e9  34ea  34eb  34ec  
-	34ed  34ee  34ef  34f0  34f1  34f2  34f3  34f4  34f5  
-	34f6  34f7  34f8  34f9  34fa  34fb  34fc  34fd  34fe  
-	34ff  3500  3501  3502  3503  3504  3505  3506  3507  
-	3508  3509  350a  350b  350c  350d  350e  350f  3510  
-	3511  3512  3513  3514  3515  3516  3517  3518  3519  
-	351a  351b  351c  351d  351e  351f  3520  3521  3522  
-	3523  3524  3525  3526  3527  3528  3529  352a  352b  
-	352c  352d  352e  352f  3530  3531  3532  3533  3534  
-	3535  3536  3537  3538  3539  353a  353b  353c  353d  
-	353e  353f  3540  3541  3542  3543  3544  3545  3546  
-	3547  3548  3549  354a  354b  354c  354d  354e  354f  
-	3550  3551  3552  3553  3554  3555  3556  3557  3558  
-	3559  355a  355b  355c  355d  355e  355f  3560  3561  
-	3562  3563  3564  3565  3566  3567  3568  3569  356a  
-	356b  356c  356d  356e  356f  3570  3571  3572  3573  
-	3574  3575  3576  3577  3578  3579  357a  357b  357c  
-	357d  357e  357f  3580  3581  3582  3583  3584  3585  
-	3586  3587  3588  3589  358a  358b  358c  358d  358e  
-	358f  3590  3591  3592  3593  3594  3595  3596  3597  
-	3598  3599  359a  359b  359c  359d  359e  359f  35a0  
-	35a1  35a2  35a3  35a4  35a5  35a6  35a7  35a8  35a9  
-	35aa  35ab  35ac  35ad  35ae  35af  35b0  35b1  35b2  
-	35b3  35b4  35b5  35b6  35b7  35b8  35b9  35ba  35bb  
-	35bc  35bd  35be  35bf  35c0  35c1  35c2  35c3  35c4  
-	35c5  35c6  35c7  35c8  35c9  35ca  35cb  35cc  35cd  
-	35ce  35cf  35d0  35d1  35d2  35d3  35d4  35d5  35d6  
-	35d7  35d8  35d9  35da  35db  35dc  35dd  35de  35df  
-	35e0  35e1  35e2  35e3  35e4  35e5  35e6  35e7  35e8  
-	35e9  35ea  35eb  35ec  35ed  35ee  35ef  35f0  35f1  
-	35f2  35f3  35f4  35f5  35f6  35f7  35f8  35f9  35fa  
-	35fb  35fc  35fd  35fe  35ff  3600  3601  3602  3603  
-	3604  3605  3606  3607  3608  3609  360a  360b  360c  
-	360d  360e  360f  3610  3611  3612  3613  3614  3615  
-	3616  3617  3618  3619  361a  361b  361c  361d  361e  
-	361f  3620  3621  3622  3623  3624  3625  3626  3627  
-	3628  3629  362a  362b  362c  362d  362e  362f  3630  
-	3631  3632  3633  3634  3635  3636  3637  3638  3639  
-	363a  363b  363c  363d  363e  363f  3640  3641  3642  
-	3643  3644  3645  3646  3647  3648  3649  364a  364b  
-	364c  364d  364e  364f  3650  3651  3652  3653  3654  
-	3655  3656  3657  3658  3659  365a  365b  365c  365d  
-	365e  365f  3660  3661  3662  3663  3664  3665  3666  
-	3667  3668  3669  366a  366b  366c  366d  366e  366f  
-	3670  3671  3672  3673  3674  3675  3676  3677  3678  
-	3679  367a  367b  367c  367d  367e  367f  3680  3681  
-	3682  3683  3684  3685  3686  3687  3688  3689  368a  
-	368b  368c  368d  368e  368f  3690  3691  3692  3693  
-	3694  3695  3696  3697  3698  3699  369a  369b  369c  
-	369d  369e  369f  36a0  36a1  36a2  36a3  36a4  36a5  
-	36a6  36a7  36a8  36a9  36aa  36ab  36ac  36ad  36ae  
-	36af  36b0  36b1  36b2  36b3  36b4  36b5  36b6  36b7  
-	36b8  36b9  36ba  36bb  36bc  36bd  36be  36bf  36c0  
-	36c1  36c2  36c3  36c4  36c5  36c6  36c7  36c8  36c9  
-	36ca  36cb  36cc  36cd  36ce  36cf  36d0  36d1  36d2  
-	36d3  36d4  36d5  36d6  36d7  36d8  36d9  36da  36db  
-	36dc  36dd  36de  36df  36e0  36e1  36e2  36e3  36e4  
-	36e5  36e6  36e7  36e8  36e9  36ea  36eb  36ec  36ed  
-	36ee  36ef  36f0  36f1  36f2  36f3  36f4  36f5  36f6  
-	36f7  36f8  36f9  36fa  36fb  36fc  36fd  36fe  36ff  
-	3700  3701  3702  3703  3704  3705  3706  3707  3708  
-	3709  370a  370b  370c  370d  370e  370f  3710  3711  
-	3712  3713  3714  3715  3716  3717  3718  3719  371a  
-	371b  371c  371d  371e  371f  3720  3721  3722  3723  
-	3724  3725  3726  3727  3728  3729  372a  372b  372c  
-	372d  372e  372f  3730  3731  3732  3733  3734  3735  
-	3736  3737  3738  3739  373a  373b  373c  373d  373e  
-	373f  3740  3741  3742  3743  3744  3745  3746  3747  
-	3748  3749  374a  374b  374c  374d  374e  374f  3750  
-	3751  3752  3753  3754  3755  3756  3757  3758  3759  
-	375a  375b  375c  375d  375e  375f  3760  3761  3762  
-	3763  3764  3765  3766  3767  3768  3769  376a  376b  
-	376c  376d  376e  376f  3770  3771  3772  3773  3774  
-	3775  3776  3777  3778  3779  377a  377b  377c  377d  
-	377e  377f  3780  3781  3782  3783  3784  3785  3786  
-	3787  3788  3789  378a  378b  378c  378d  378e  378f  
-	3790  3791  3792  3793  3794  3795  3796  3797  3798  
-	3799  379a  379b  379c  379d  379e  379f  37a0  37a1  
-	37a2  37a3  37a4  37a5  37a6  37a7  37a8  37a9  37aa  
-	37ab  37ac  37ad  37ae  37af  37b0  37b1  37b2  37b3  
-	37b4  37b5  37b6  37b7  37b8  37b9  37ba  37bb  37bc  
-	37bd  37be  37bf  37c0  37c1  37c2  37c3  37c4  37c5  
-	37c6  37c7  37c8  37c9  37ca  37cb  37cc  37cd  37ce  
-	37cf  37d0  37d1  37d2  37d3  37d4  37d5  37d6  37d7  
-	37d8  37d9  37da  37db  37dc  37dd  37de  37df  37e0  
-	37e1  37e2  37e3  37e4  37e5  37e6  37e7  37e8  37e9  
-	37ea  37eb  37ec  37ed  37ee  37ef  37f0  37f1  37f2  
-	37f3  37f4  37f5  37f6  37f7  37f8  37f9  37fa  37fb  
-	37fc  37fd  37fe  37ff  3800  3801  3802  3803  3804  
-	3805  3806  3807  3808  3809  380a  380b  380c  380d  
-	380e  380f  3810  3811  3812  3813  3814  3815  3816  
-	3817  3818  3819  381a  381b  381c  381d  381e  381f  
-	3820  3821  3822  3823  3824  3825  3826  3827  3828  
-	3829  382a  382b  382c  382d  382e  382f  3830  3831  
-	3832  3833  3834  3835  3836  3837  3838  3839  383a  
-	383b  383c  383d  383e  383f  3840  3841  3842  3843  
-	3844  3845  3846  3847  3848  3849  384a  384b  384c  
-	384d  384e  384f  3850  3851  3852  3853  3854  3855  
-	3856  3857  3858  3859  385a  385b  385c  385d  385e  
-	385f  3860  3861  3862  3863  3864  3865  3866  3867  
-	3868  3869  386a  386b  386c  386d  386e  386f  3870  
-	3871  3872  3873  3874  3875  3876  3877  3878  3879  
-	387a  387b  387c  387d  387e  387f  3880  3881  3882  
-	3883  3884  3885  3886  3887  3888  3889  388a  388b  
-	388c  388d  388e  388f  3890  3891  3892  3893  3894  
-	3895  3896  3897  3898  3899  389a  389b  389c  389d  
-	389e  389f  38a0  38a1  38a2  38a3  38a4  38a5  38a6  
-	38a7  38a8  38a9  38aa  38ab  38ac  38ad  38ae  38af  
-	38b0  38b1  38b2  38b3  38b4  38b5  38b6  38b7  38b8  
-	38b9  38ba  38bb  38bc  38bd  38be  38bf  38c0  38c1  
-	38c2  38c3  38c4  38c5  38c6  38c7  38c8  38c9  38ca  
-	38cb  38cc  38cd  38ce  38cf  38d0  38d1  38d2  38d3  
-	38d4  38d5  38d6  38d7  38d8  38d9  38da  38db  38dc  
-	38dd  38de  38df  38e0  38e1  38e2  38e3  38e4  38e5  
-	38e6  38e7  38e8  38e9  38ea  38eb  38ec  38ed  38ee  
-	38ef  38f0  38f1  38f2  38f3  38f4  38f5  38f6  38f7  
-	38f8  38f9  38fa  38fb  38fc  38fd  38fe  38ff  3900  
-	3901  3902  3903  3904  3905  3906  3907  3908  3909  
-	390a  390b  390c  390d  390e  390f  3910  3911  3912  
-	3913  3914  3915  3916  3917  3918  3919  391a  391b  
-	391c  391d  391e  391f  3920  3921  3922  3923  3924  
-	3925  3926  3927  3928  3929  392a  392b  392c  392d  
-	392e  392f  3930  3931  3932  3933  3934  3935  3936  
-	3937  3938  3939  393a  393b  393c  393d  393e  393f  
-	3940  3941  3942  3943  3944  3945  3946  3947  3948  
-	3949  394a  394b  394c  394d  394e  394f  3950  3951  
-	3952  3953  3954  3955  3956  3957  3958  3959  395a  
-	395b  395c  395d  395e  395f  3960  3961  3962  3963  
-	3964  3965  3966  3967  3968  3969  396a  396b  396c  
-	396d  396e  396f  3970  3971  3972  3973  3974  3975  
-	3976  3977  3978  3979  397a  397b  397c  397d  397e  
-	397f  3980  3981  3982  3983  3984  3985  3986  3987  
-	3988  3989  398a  398b  398c  398d  398e  398f  3990  
-	3991  3992  3993  3994  3995  3996  3997  3998  3999  
-	399a  399b  399c  399d  399e  399f  39a0  39a1  39a2  
-	39a3  39a4  39a5  39a6  39a7  39a8  39a9  39aa  39ab  
-	39ac  39ad  39ae  39af  39b0  39b1  39b2  39b3  39b4  
-	39b5  39b6  39b7  39b8  39b9  39ba  39bb  39bc  39bd  
-	39be  39bf  39c0  39c1  39c2  39c3  39c4  39c5  39c6  
-	39c7  39c8  39c9  39ca  39cb  39cc  39cd  39ce  39cf  
-	39d0  39d1  39d2  39d3  39d4  39d5  39d6  39d7  39d8  
-	39d9  39da  39db  39dc  39dd  39de  39df  39e0  39e1  
-	39e2  39e3  39e4  39e5  39e6  39e7  39e8  39e9  39ea  
-	39eb  39ec  39ed  39ee  39ef  39f0  39f1  39f2  39f3  
-	39f4  39f5  39f6  39f7  39f8  39f9  39fa  39fb  39fc  
-	39fd  39fe  39ff  3a00  3a01  3a02  3a03  3a04  3a05  
-	3a06  3a07  3a08  3a09  3a0a  3a0b  3a0c  3a0d  3a0e  
-	3a0f  3a10  3a11  3a12  3a13  3a14  3a15  3a16  3a17  
-	3a18  3a19  3a1a  3a1b  3a1c  3a1d  3a1e  3a1f  3a20  
-	3a21  3a22  3a23  3a24  3a25  3a26  3a27  3a28  3a29  
-	3a2a  3a2b  3a2c  3a2d  3a2e  3a2f  3a30  3a31  3a32  
-	3a33  3a34  3a35  3a36  3a37  3a38  3a39  3a3a  3a3b  
-	3a3c  3a3d  3a3e  3a3f  3a40  3a41  3a42  3a43  3a44  
-	3a45  3a46  3a47  3a48  3a49  3a4a  3a4b  3a4c  3a4d  
-	3a4e  3a4f  3a50  3a51  3a52  3a53  3a54  3a55  3a56  
-	3a57  3a58  3a59  3a5a  3a5b  3a5c  3a5d  3a5e  3a5f  
-	3a60  3a61  3a62  3a63  3a64  3a65  3a66  3a67  3a68  
-	3a69  3a6a  3a6b  3a6c  3a6d  3a6e  3a6f  3a70  3a71  
-	3a72  3a73  3a74  3a75  3a76  3a77  3a78  3a79  3a7a  
-	3a7b  3a7c  3a7d  3a7e  3a7f  3a80  3a81  3a82  3a83  
-	3a84  3a85  3a86  3a87  3a88  3a89  3a8a  3a8b  3a8c  
-	3a8d  3a8e  3a8f  3a90  3a91  3a92  3a93  3a94  3a95  
-	3a96  3a97  3a98  3a99  3a9a  3a9b  3a9c  3a9d  3a9e  
-	3a9f  3aa0  3aa1  3aa2  3aa3  3aa4  3aa5  3aa6  3aa7  
-	3aa8  3aa9  3aaa  3aab  3aac  3aad  3aae  3aaf  3ab0  
-	3ab1  3ab2  3ab3  3ab4  3ab5  3ab6  3ab7  3ab8  3ab9  
-	3aba  3abb  3abc  3abd  3abe  3abf  3ac0  3ac1  3ac2  
-	3ac3  3ac4  3ac5  3ac6  3ac7  3ac8  3ac9  3aca  3acb  
-	3acc  3acd  3ace  3acf  3ad0  3ad1  3ad2  3ad3  3ad4  
-	3ad5  3ad6  3ad7  3ad8  3ad9  3ada  3adb  3adc  3add  
-	3ade  3adf  3ae0  3ae1  3ae2  3ae3  3ae4  3ae5  3ae6  
-	3ae7  3ae8  3ae9  3aea  3aeb  3aec  3aed  3aee  3aef  
-	3af0  3af1  3af2  3af3  3af4  3af5  3af6  3af7  3af8  
-	3af9  3afa  3afb  3afc  3afd  3afe  3aff  3b00  3b01  
-	3b02  3b03  3b04  3b05  3b06  3b07  3b08  3b09  3b0a  
-	3b0b  3b0c  3b0d  3b0e  3b0f  3b10  3b11  3b12  3b13  
-	3b14  3b15  3b16  3b17  3b18  3b19  3b1a  3b1b  3b1c  
-	3b1d  3b1e  3b1f  3b20  3b21  3b22  3b23  3b24  3b25  
-	3b26  3b27  3b28  3b29  3b2a  3b2b  3b2c  3b2d  3b2e  
-	3b2f  3b30  3b31  3b32  3b33  3b34  3b35  3b36  3b37  
-	3b38  3b39  3b3a  3b3b  3b3c  3b3d  3b3e  3b3f  3b40  
-	3b41  3b42  3b43  3b44  3b45  3b46  3b47  3b48  3b49  
-	3b4a  3b4b  3b4c  3b4d  3b4e  3b4f  3b50  3b51  3b52  
-	3b53  3b54  3b55  3b56  3b57  3b58  3b59  3b5a  3b5b  
-	3b5c  3b5d  3b5e  3b5f  3b60  3b61  3b62  3b63  3b64  
-	3b65  3b66  3b67  3b68  3b69  3b6a  3b6b  3b6c  3b6d  
-	3b6e  3b6f  3b70  3b71  3b72  3b73  3b74  3b75  3b76  
-	3b77  3b78  3b79  3b7a  3b7b  3b7c  3b7d  3b7e  3b7f  
-	3b80  3b81  3b82  3b83  3b84  3b85  3b86  3b87  3b88  
-	3b89  3b8a  3b8b  3b8c  3b8d  3b8e  3b8f  3b90  3b91  
-	3b92  3b93  3b94  3b95  3b96  3b97  3b98  3b99  3b9a  
-	3b9b  3b9c  3b9d  3b9e  3b9f  3ba0  3ba1  3ba2  3ba3  
-	3ba4  3ba5  3ba6  3ba7  3ba8  3ba9  3baa  3bab  3bac  
-	3bad  3bae  3baf  3bb0  3bb1  3bb2  3bb3  3bb4  3bb5  
-	3bb6  3bb7  3bb8  3bb9  3bba  3bbb  3bbc  3bbd  3bbe  
-	3bbf  3bc0  3bc1  3bc2  3bc3  3bc4  3bc5  3bc6  3bc7  
-	3bc8  3bc9  3bca  3bcb  3bcc  3bcd  3bce  3bcf  3bd0  
-	3bd1  3bd2  3bd3  3bd4  3bd5  3bd6  3bd7  3bd8  3bd9  
-	3bda  3bdb  3bdc  3bdd  3bde  3bdf  3be0  3be1  3be2  
-	3be3  3be4  3be5  3be6  3be7  3be8  3be9  3bea  3beb  
-	3bec  3bed  3bee  3bef  3bf0  3bf1  3bf2  3bf3  3bf4  
-	3bf5  3bf6  3bf7  3bf8  3bf9  3bfa  3bfb  3bfc  3bfd  
-	3bfe  3bff  3c00  3c01  3c02  3c03  3c04  3c05  3c06  
-	3c07  3c08  3c09  3c0a  3c0b  3c0c  3c0d  3c0e  3c0f  
-	3c10  3c11  3c12  3c13  3c14  3c15  3c16  3c17  3c18  
-	3c19  3c1a  3c1b  3c1c  3c1d  3c1e  3c1f  3c20  3c21  
-	3c22  3c23  3c24  3c25  3c26  3c27  3c28  3c29  3c2a  
-	3c2b  3c2c  3c2d  3c2e  3c2f  3c30  3c31  3c32  3c33  
-	3c34  3c35  3c36  3c37  3c38  3c39  3c3a  3c3b  3c3c  
-	3c3d  3c3e  3c3f  3c40  3c41  3c42  3c43  3c44  3c45  
-	3c46  3c47  3c48  3c49  3c4a  3c4b  3c4c  3c4d  3c4e  
-	3c4f  3c50  3c51  3c52  3c53  3c54  3c55  3c56  3c57  
-	3c58  3c59  3c5a  3c5b  3c5c  3c5d  3c5e  3c5f  3c60  
-	3c61  3c62  3c63  3c64  3c65  3c66  3c67  3c68  3c69  
-	3c6a  3c6b  3c6c  3c6d  3c6e  3c6f  3c70  3c71  3c72  
-	3c73  3c74  3c75  3c76  3c77  3c78  3c79  3c7a  3c7b  
-	3c7c  3c7d  3c7e  3c7f  3c80  3c81  3c82  3c83  3c84  
-	3c85  3c86  3c87  3c88  3c89  3c8a  3c8b  3c8c  3c8d  
-	3c8e  3c8f  3c90  3c91  3c92  3c93  3c94  3c95  3c96  
-	3c97  3c98  3c99  3c9a  3c9b  3c9c  3c9d  3c9e  3c9f  
-	3ca0  3ca1  3ca2  3ca3  3ca4  3ca5  3ca6  3ca7  3ca8  
-	3ca9  3caa  3cab  3cac  3cad  3cae  3caf  3cb0  3cb1  
-	3cb2  3cb3  3cb4  3cb5  3cb6  3cb7  3cb8  3cb9  3cba  
-	3cbb  3cbc  3cbd  3cbe  3cbf  3cc0  3cc1  3cc2  3cc3  
-	3cc4  3cc5  3cc6  3cc7  3cc8  3cc9  3cca  3ccb  3ccc  
-	3ccd  3cce  3ccf  3cd0  3cd1  3cd2  3cd3  3cd4  3cd5  
-	3cd6  3cd7  3cd8  3cd9  3cda  3cdb  3cdc  3cdd  3cde  
-	3cdf  3ce0  3ce1  3ce2  3ce3  3ce4  3ce5  3ce6  3ce7  
-	3ce8  3ce9  3cea  3ceb  3cec  3ced  3cee  3cef  3cf0  
-	3cf1  3cf2  3cf3  3cf4  3cf5  3cf6  3cf7  3cf8  3cf9  
-	3cfa  3cfb  3cfc  3cfd  3cfe  3cff  3d00  3d01  3d02  
-	3d03  3d04  3d05  3d06  3d07  3d08  3d09  3d0a  3d0b  
-	3d0c  3d0d  3d0e  3d0f  3d10  3d11  3d12  3d13  3d14  
-	3d15  3d16  3d17  3d18  3d19  3d1a  3d1b  3d1c  3d1d  
-	3d1e  3d1f  3d20  3d21  3d22  3d23  3d24  3d25  3d26  
-	3d27  3d28  3d29  3d2a  3d2b  3d2c  3d2d  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  0000  0000  0000  0000  0000  0000  0000  
-	0000  0000  4f3d  4f73  5047  50f9  52a0  53ef  5475  
-	54e5  5609  5ac1  5bb6  6687  67b6  67b7  67ef  6b4c  
-	73c2  75c2  7a3c  82db  8304  8857  8888  8a36  8cc8  
-	8dcf  8efb  8fe6  99d5  523b  5374  5404  606a  6164  
-	6bbc  73cf  811a  89ba  89d2  95a3  4f83  520a  58be  
-	5978  59e6  5e72  5e79  61c7  63c0  6746  67ec  687f  
-	6f97  764e  770b  78f5  7a08  7aff  7c21  809d  826e  
-	8271  8aeb  9593  4e6b  559d  66f7  6e34  78a3  7aed  
-	845b  8910  874e  97a8  52d8  574e  582a  5d4c  611f  
-	61be  6221  6562  67d1  6a44  6e1b  7518  75b3  76e3  
-	77b0  7d3a  90af  9451  9452  9f95  5323  5cac  7532  
-	80db  9240  9598  525b  5808  59dc  5ca1  5d17  5eb7  
-	5f3a  5f4a  6177  6c5f  757a  7586  7ce0  7d73  7db1  
-	7f8c  8154  8221  8591  8941  8b1b  92fc  964d  9c47  
-	4ecb  4ef7  500b  51f1  584f  6137  613e  6168  6539  
-	69ea  6f11  75a5  7686  76d6  7b87  82a5  84cb  f900  
-	93a7  958b  5580  5ba2  5751  f901  7cb3  7fb9  91b5  
-	5028  53bb  5c45  5de8  62d2  636e  64da  64e7  6e20  
-	70ac  795b  8ddd  8e1e  f902  907d  9245  92f8  4e7e  
-	4ef6  5065  5dfe  5efa  6106  6957  8171  8654  8e47  
-	9375  9a2b  4e5e  5091  6770  6840  5109  528d  5292  
-	6aa2  77bc  9210  9ed4  52ab  602f  8ff2  5048  61a9  
-	63ed  64ca  683c  6a84  6fc0  8188  89a1  9694  5805  
-	727d  72ac  7504  7d79  7e6d  80a9  898b  8b74  9063  
-	9d51  6289  6c7a  6f54  7d50  7f3a  8a23  517c  614a  
-	7b9d  8b19  9257  938c  4eac  4fd3  501e  50be  5106  
-	52c1  52cd  537f  5770  5883  5e9a  5f91  6176  61ac  
-	64ce  656c  666f  66bb  66f4  6897  6d87  7085  70f1  
-	749f  74a5  74ca  75d9  786c  78ec  7adf  7af6  7d45  
-	7d93  8015  803f  811b  8396  8b66  8f15  9015  93e1  
-	9803  9838  9a5a  9be8  4fc2  5553  583a  5951  5b63  
-	5c46  60b8  6212  6842  68b0  68e8  6eaa  754c  7678  
-	78ce  7a3d  7cfb  7e6b  7e7c  8a08  8aa1  8c3f  968e  
-	9dc4  53e4  53e9  544a  5471  56fa  59d1  5b64  5c3b  
-	5eab  62f7  6537  6545  6572  66a0  67af  69c1  6cbd  
-	75fc  7690  777e  7a3f  7f94  8003  80a1  818f  82e6  
-	82fd  83f0  85c1  8831  88b4  8aa5  f903  8f9c  932e  
-	96c7  9867  9ad8  9f13  54ed  659b  66f2  688f  7a40  
-	8c37  9d60  56f0  5764  5d11  6606  68b1  68cd  6efe  
-	7428  889e  9be4  6c68  f904  9aa8  4f9b  516c  5171  
-	529f  5b54  5de5  6050  606d  62f1  63a7  653b  73d9  
-	7a7a  86a3  8ca2  978f  4e32  5be1  6208  679c  74dc  
-	79d1  83d3  8a87  8ab2  8de8  904e  934b  9846  5ed3  
-	69e8  85ff  90ed  f905  51a0  5b98  5bec  6163  68fa  
-	6b3e  704c  742f  74d8  7ba1  7f50  83c5  89c0  8cab  
-	95dc  9928  522e  605d  62ec  9002  4f8a  5149  5321  
-	58d9  5ee3  66e0  6d38  709a  72c2  73d6  7b50  80f1  
-	945b  5366  639b  7f6b  4e56  5080  584a  58de  602a  
-	6127  62d0  69d0  9b41  5b8f  7d18  80b1  8f5f  4ea4  
-	50d1  54ac  55ac  5b0c  5da0  5de7  652a  654e  6821  
-	6a4b  72e1  768e  77ef  7d5e  7ff9  81a0  854e  86df  
-	8f03  8f4e  90ca  9903  9a55  9bab  4e18  4e45  4e5d  
-	4ec7  4ff1  5177  52fe  5340  53e3  53e5  548e  5614  
-	5775  57a2  5bc7  5d87  5ed0  61fc  62d8  6551  67b8  
-	67e9  69cb  6b50  6bc6  6bec  6c42  6e9d  7078  72d7  
-	7396  7403  77bf  77e9  7a76  7d7f  8009  81fc  8205  
-	820a  82df  8862  8b33  8cfc  8ec0  9011  90b1  9264  
-	92b6  99d2  9a45  9ce9  9dd7  9f9c  570b  5c40  83ca  
-	97a0  97ab  9eb4  541b  7a98  7fa4  88d9  8ecd  90e1  
-	5800  5c48  6398  7a9f  5bae  5f13  7a79  7aae  828e  
-	8eac  5026  5238  52f8  5377  5708  62f3  6372  6b0a  
-	6dc3  7737  53a5  7357  8568  8e76  95d5  673a  6ac3  
-	6f70  8a6d  8ecc  994b  f906  6677  6b78  8cb4  9b3c  
-	f907  53eb  572d  594e  63c6  69fb  73ea  7845  7aba  
-	7ac5  7cfe  8475  898f  8d73  9035  95a8  52fb  5747  
-	7547  7b60  83cc  921e  f908  6a58  514b  524b  5287  
-	621f  68d8  6975  9699  50c5  52a4  52e4  61c3  65a4  
-	6839  69ff  747e  7b4b  82b9  83eb  89b2  8b39  8fd1  
-	9949  f909  4eca  5997  64d2  6611  6a8e  7434  7981  
-	79bd  82a9  887e  887f  895f  f90a  9326  4f0b  53ca  
-	6025  6271  6c72  7d1a  7d66  4e98  5162  77dc  80af  
-	4f01  4f0e  5176  5180  55dc  5668  573b  57fa  57fc  
-	5914  5947  5993  5bc4  5c90  5d0e  5df1  5e7e  5fcc  
-	6280  65d7  65e3  671e  671f  675e  68cb  68c4  6a5f  
-	6b3a  6c23  6c7d  6c82  6dc7  7398  7426  742a  7482  
-	74a3  7578  757f  7881  78ef  7941  7947  7948  797a  
-	7b95  7d00  7dba  7f88  8006  802d  808c  8a18  8b4f  
-	8c48  8d77  9321  9324  98e2  9951  9a0e  9a0f  9a65  
-	9e92  7dca  4f76  5409  62ee  6854  91d1  55ab  513a  
-	f90b  f90c  5a1c  61e6  f90d  62cf  62ff  f90e  f90f  
-	f910  f911  f912  f913  90a3  f914  f915  f916  f917  
-	f918  8afe  f919  f91a  f91b  f91c  6696  f91d  7156  
-	f91e  f91f  96e3  f920  634f  637a  5357  f921  678f  
-	6960  6e73  f922  7537  f923  f924  f925  7d0d  f926  
-	f927  8872  56ca  5a18  f928  f929  f92a  f92b  f92c  
-	4e43  f92d  5167  5948  67f0  8010  f92e  5973  5e74  
-	649a  79ca  5ff5  606c  62c8  637b  5be7  5bd7  52aa  
-	f92f  5974  5f29  6012  f930  f931  f932  7459  f933  
-	f934  f935  f936  f937  f938  99d1  f939  f93a  f93b  
-	f93c  f93d  f93e  f93f  f940  f941  f942  f943  6fc3  
-	f944  f945  81bf  8fb2  60f1  f946  f947  8166  f948  
-	f949  5c3f  f94a  f94b  f94c  f94d  f94e  f94f  f950  
-	f951  5ae9  8a25  677b  7d10  f952  f953  f954  f955  
-	f956  f957  80fd  f958  f959  5c3c  6ce5  533f  6eba  
-	591a  8336  4e39  4eb6  4f46  55ae  5718  58c7  5f56  
-	65b7  65e6  6a80  6bb5  6e4d  77ed  7aef  7c1e  7dde  
-	86cb  8892  9132  935b  64bb  6fbe  737a  75b8  9054  
-	5556  574d  61ba  64d4  66c7  6de1  6e5b  6f6d  6fb9  
-	75f0  8043  81bd  8541  8983  8ac7  8b5a  931f  6c93  
-	7553  7b54  8e0f  905d  5510  5802  5858  5e62  6207  
-	649e  68e0  7576  7cd6  87b3  9ee8  4ee3  5788  576e  
-	5927  5c0d  5cb1  5e36  5f85  6234  64e1  73b3  81fa  
-	888b  8cb8  968a  9edb  5b85  5fb7  60b3  5012  5200  
-	5230  5716  5835  5857  5c0e  5c60  5cf6  5d8b  5ea6  
-	5f92  60bc  6311  6389  6417  6843  68f9  6ac2  6dd8  
-	6e21  6ed4  6fe4  71fe  76dc  7779  79b1  7a3b  8404  
-	89a9  8ced  8df3  8e48  9003  9014  9053  90fd  934d  
-	9676  97dc  6bd2  7006  7258  72a2  7368  7763  79bf  
-	7be4  7e9b  8b80  58a9  60c7  6566  65fd  66be  6c8c  
-	711e  71c9  8c5a  9813  4e6d  7a81  4edd  51ac  51cd  
-	52d5  540c  61a7  6771  6850  68df  6d1e  6f7c  75bc  
-	77b3  7ae5  80f4  8463  9285  515c  6597  675c  6793  
-	75d8  7ac7  8373  f95a  8c46  9017  982d  5c6f  81c0  
-	829a  9041  906f  920d  5f97  5d9d  6a59  71c8  767b  
-	7b49  85e4  8b04  9127  9a30  5587  61f6  f95b  7669  
-	7f85  863f  87ba  88f8  908f  f95c  6d1b  70d9  73de  
-	7d61  843d  f95d  916a  99f1  f95e  4e82  5375  6b04  
-	6b12  703e  721b  862d  9e1e  524c  8fa3  5d50  64e5  
-	652c  6b16  6feb  7c43  7e9c  85cd  8964  89bd  62c9  
-	81d8  881f  5eca  6717  6d6a  72fc  7405  746f  8782  
-	90de  4f86  5d0d  5fa0  840a  51b7  63a0  7565  4eae  
-	5006  5169  51c9  6881  6a11  7cae  7cb1  7ce7  826f  
-	8ad2  8f1b  91cf  4fb6  5137  52f5  5442  5eec  616e  
-	623e  65c5  6ada  6ffe  792a  85dc  8823  95ad  9a62  
-	9a6a  9e97  9ece  529b  66c6  6b77  701d  792b  8f62  
-	9742  6190  6200  6523  6f23  7149  7489  7df4  806f  
-	84ee  8f26  9023  934a  51bd  5217  52a3  6d0c  70c8  
-	88c2  5ec9  6582  6bae  6fc2  7c3e  7375  4ee4  4f36  
-	56f9  f95f  5cba  5dba  601c  73b2  7b2d  7f9a  7fce  
-	8046  901e  9234  96f6  9748  9818  9f61  4f8b  6fa7  
-	79ae  91b4  96b7  52de  f960  6488  64c4  6ad3  6f5e  
-	7018  7210  76e7  8001  8606  865c  8def  8f05  9732  
-	9b6f  9dfa  9e75  788c  797f  7da0  83c9  9304  9e7f  
-	9e93  8ad6  58df  5f04  6727  7027  74cf  7c60  807e  
-	5121  7028  7262  78ca  8cc2  8cda  8cf4  96f7  4e86  
-	50da  5bee  5ed6  6599  71ce  7642  77ad  804a  84fc  
-	907c  9b27  9f8d  58d8  5a41  5c62  6a13  6dda  6f0f  
-	763b  7d2f  7e37  851e  8938  93e4  964b  5289  65d2  
-	67f3  69b4  6d41  6e9c  700f  7409  7460  7559  7624  
-	786b  8b2c  985e  516d  622e  9678  4f96  502b  5d19  
-	6dea  7db8  8f2a  5f8b  6144  6817  f961  9686  52d2  
-	808b  51dc  51cc  695e  7a1c  7dbe  83f1  9675  4fda  
-	5229  5398  540f  550e  5c65  60a7  674e  68a8  6d6c  
-	7281  72f8  7406  7483  f962  75e2  7c6c  7f79  7fb8  
-	8389  88cf  88e1  91cc  91d0  96e2  9bc9  541d  6f7e  
-	71d0  7498  85fa  8eaa  96a3  9c57  9e9f  6797  6dcb  
-	7433  81e8  9716  782c  7acb  7b20  7c92  6469  746a  
-	75f2  78bc  78e8  99ac  9b54  9ebb  5bde  5e55  6f20  
-	819c  83ab  9088  4e07  534d  5a29  5dd2  5f4e  6162  
-	633d  6669  66fc  6eff  6f2b  7063  779e  842c  8513  
-	883b  8f13  9945  9c3b  551c  62b9  672b  6cab  8309  
-	896a  977a  4ea1  5984  5fd8  5fd9  671b  7db2  7f54  
-	8292  832b  83bd  8f1e  9099  57cb  59b9  5a92  5bd0  
-	6627  679a  6885  6bcf  7164  7f75  8cb7  8ce3  9081  
-	9b45  8108  8c8a  964c  9a40  9ea5  5b5f  6c13  731b  
-	76f2  76df  840c  51aa  8993  514d  5195  52c9  68c9  
-	6c94  7704  7720  7dbf  7dec  9762  9eb5  6ec5  8511  
-	51a5  540d  547d  660e  669d  6927  6e9f  76bf  7791  
-	8317  84c2  879f  9169  9298  9cf4  8882  4fae  5192  
-	52df  59c6  5e3d  6155  6478  6479  66ae  67d0  6a21  
-	6bcd  6bdb  725f  7261  7441  7738  77db  8017  82bc  
-	8305  8b00  8b28  8c8c  6728  6c90  7267  76ee  7766  
-	7a46  9da9  6b7f  6c92  5922  6726  8499  536f  5893  
-	5999  5edf  63cf  6634  6773  6e3a  732b  7ad7  82d7  
-	9328  52d9  5deb  61ae  61cb  620a  62c7  64ab  65e0  
-	6959  6b66  6bcb  7121  73f7  755d  7e46  821e  8302  
-	856a  8aa3  8cbf  9727  9d61  58a8  9ed8  5011  520e  
-	543b  554f  6587  6c76  7d0a  7d0b  805e  868a  9580  
-	96ef  52ff  6c95  7269  5473  5a9a  5c3e  5d4b  5f4c  
-	5fae  672a  68b6  6963  6e3c  6e44  7709  7c73  7f8e  
-	8587  8b0e  8ff7  9761  9ef4  5cb7  60b6  610d  61ab  
-	654f  65fb  65fc  6c11  6cef  739f  73c9  7de1  9594  
-	5bc6  871c  8b10  525d  535a  62cd  640f  64b2  6734  
-	6a38  6cca  73c0  749e  7b94  7c95  7e1b  818a  8236  
-	8584  8feb  96f9  99c1  4f34  534a  53cd  53db  62cc  
-	642c  6500  6591  69c3  6cee  6f58  73ed  7554  7622  
-	76e4  76fc  78d0  78fb  792c  7d46  822c  87e0  8fd4  
-	9812  98ef  52c3  62d4  64a5  6e24  6f51  767c  8dcb  
-	91b1  9262  9aee  9b43  5023  508d  574a  59a8  5c28  
-	5e47  5f77  623f  653e  65b9  65c1  6609  678b  699c  
-	6ec2  78c5  7d21  80aa  8180  822b  82b3  84a1  868c  
-	8a2a  8b17  90a6  9632  9f90  500d  4ff3  f963  57f9  
-	5f98  62dc  6392  676f  6e43  7119  76c3  80cc  80da  
-	88f4  88f5  8919  8ce0  8f29  914d  966a  4f2f  4f70  
-	5e1b  67cf  6822  767d  767e  9b44  5e61  6a0a  7169  
-	71d4  756a  f964  7e41  8543  85e9  98dc  4f10  7b4f  
-	7f70  95a5  51e1  5e06  68b5  6c3e  6c4e  6cdb  72af  
-	7bc4  8303  6cd5  743a  50fb  5288  58c1  64d8  6a97  
-	74a7  7656  78a7  8617  95e2  9739  f965  535e  5f01  
-	8b8a  8fa8  8faf  908a  5225  77a5  9c49  9f08  4e19  
-	5002  5175  5c5b  5e77  661e  663a  67c4  68c5  70b3  
-	7501  75c5  79c9  7add  8f27  9920  9a08  4fdd  5821  
-	5831  5bf6  666e  6b65  6d11  6e7a  6f7d  73e4  752b  
-	83e9  88dc  8913  8b5c  8f14  4f0f  50d5  5310  535c  
-	5b93  5fa9  670d  798f  8179  832f  8514  8907  8986  
-	8f39  8f3b  99a5  9c12  672c  4e76  4ff8  5949  5c01  
-	5cef  5cf0  6367  68d2  70fd  71a2  742b  7e2b  84ec  
-	8702  9022  92d2  9cf3  4e0d  4ed8  4fef  5085  5256  
-	526f  5426  5490  57e0  592b  5a66  5b5a  5b75  5bcc  
-	5e9c  f966  6276  6577  65a7  6d6e  6ea5  7236  7b26  
-	7c3f  7f36  8150  8151  819a  8240  8299  83a9  8a03  
-	8ca0  8ce6  8cfb  8d74  8dba  90e8  91dc  961c  9644  
-	99d9  9ce7  5317  5206  5429  5674  58b3  5954  596e  
-	5fff  61a4  626e  6610  6c7e  711a  76c6  7c89  7cde  
-	7d1b  82ac  8cc1  96f0  f967  4f5b  5f17  5f7f  62c2  
-	5d29  670b  68da  787c  7e43  9d6c  4e15  5099  5315  
-	532a  5351  5983  5a62  5e87  60b2  618a  6249  6279  
-	6590  6787  69a7  6bd4  6bd6  6bd7  6bd8  6cb8  f968  
-	7435  75fa  7812  7891  79d5  79d8  7c83  7dcb  7fe1  
-	80a5  813e  81c2  83f2  871a  88e8  8ab9  8b6c  8cbb  
-	9119  975e  98db  9f3b  56ac  5b2a  5f6c  658c  6ab3  
-	6baf  6d5c  6ff1  7015  725d  73ad  8ca7  8cd3  983b  
-	6191  6c37  8058  9a01  4e4d  4e8b  4e9b  4ed5  4f3a  
-	4f3c  4f7f  4fdf  50ff  53f2  53f8  5506  55e3  56db  
-	58eb  5962  5a11  5beb  5bfa  5c04  5df3  5e2b  5f99  
-	601d  6368  659c  65af  67f6  67fb  68ad  6b7b  6c99  
-	6cd7  6e23  7009  7345  7802  793e  7940  7960  79c1  
-	7be9  7d17  7d72  8086  820d  838e  84d1  86c7  88df  
-	8a50  8a5e  8b1d  8cdc  8d66  8fad  90aa  98fc  99df  
-	9e9d  524a  f969  6714  f96a  5098  522a  5c71  6563  
-	6c55  73ca  7523  759d  7b97  849c  9178  9730  4e77  
-	6492  6bba  715e  85a9  4e09  f96b  6749  68ee  6e17  
-	829f  8518  886b  63f7  6f81  9212  98af  4e0a  50b7  
-	50cf  511f  5546  55aa  5617  5b40  5c19  5ce0  5e38  
-	5e8a  5ea0  5ec2  60f3  6851  6a61  6e58  723d  7240  
-	72c0  76f8  7965  7bb1  7fd4  88f3  89f4  8a73  8c61  
-	8cde  971c  585e  74bd  8cfd  55c7  f96c  7a61  7d22  
-	8272  7272  751f  7525  f96d  7b19  5885  58fb  5dbc  
-	5e8f  5eb6  5f90  6055  6292  637f  654d  6691  66d9  
-	66f8  6816  68f2  7280  745e  7b6e  7d6e  7dd6  7f72  
-	80e5  8212  85af  897f  8a93  901d  92e4  9ecd  9f20  
-	5915  596d  5e2d  60dc  6614  6673  6790  6c50  6dc5  
-	6f5f  77f3  78a9  84c6  91cb  932b  4ed9  50ca  5148  
-	5584  5b0b  5ba3  6247  657e  65cb  6e32  717d  7401  
-	7444  7487  74bf  766c  79aa  7dda  7e55  7fa8  817a  
-	81b3  8239  861a  87ec  8a75  8de3  9078  9291  9425  
-	994d  9bae  5368  5c51  6954  6cc4  6d29  6e2b  820c  
-	859b  893b  8a2d  8aaa  96ea  9f67  5261  66b9  6bb2  
-	7e96  87fe  8d0d  9583  965d  651d  6d89  71ee  f96e  
-	57ce  59d3  5bac  6027  60fa  6210  661f  665f  7329  
-	73f9  76db  7701  7b6c  8056  8072  8165  8aa0  9192  
-	4e16  52e2  6b72  6d17  7a05  7b39  7d30  f96f  8cb0  
-	53ec  562f  5851  5bb5  5c0f  5c11  5de2  6240  6383  
-	6414  662d  68b3  6cbc  6d88  6eaf  701f  70a4  71d2  
-	7526  758f  758e  7619  7b11  7be0  7c2b  7d20  7d39  
-	852c  856d  8607  8a34  900d  9061  90b5  92b7  97f6  
-	9a37  4fd7  5c6c  675f  6d91  7c9f  7e8c  8b16  8d16  
-	901f  5b6b  5dfd  640d  84c0  905c  98e1  7387  5b8b  
-	609a  677e  6dde  8a1f  8aa6  9001  980c  5237  f970  
-	7051  788e  9396  8870  91d7  4fee  53d7  55fd  56da  
-	5782  58fd  5ac2  5b88  5cab  5cc0  5e25  6101  620d  
-	624b  6388  641c  6536  6578  6a39  6b8a  6c34  6d19  
-	6f31  71e7  72e9  7378  7407  74b2  7626  7761  79c0  
-	7a57  7aea  7cb9  7d8f  7dac  7e61  7f9e  8129  8331  
-	8490  84da  85ea  8896  8ab0  8b90  8f38  9042  9083  
-	916c  9296  92b9  968b  96a7  96a8  96d6  9700  9808  
-	9996  9ad3  9b1a  53d4  587e  5919  5b70  5bbf  6dd1  
-	6f5a  719f  7421  74b9  8085  83fd  5de1  5f87  5faa  
-	6042  65ec  6812  696f  6a53  6b89  6d35  6df3  73e3  
-	76fe  77ac  7b4d  7d14  8123  821c  8340  84f4  8563  
-	8a62  8ac4  9187  931e  9806  99b4  620c  8853  8ff0  
-	9265  5d07  5d27  5d69  745f  819d  8768  6fd5  62fe  
-	7fd2  8936  8972  4e1e  4e58  50e7  52dd  5347  627f  
-	6607  7e69  8805  965e  4f8d  5319  5636  59cb  5aa4  
-	5c38  5c4e  5c4d  5e02  5f11  6043  65bd  662f  6642  
-	67be  67f4  731c  77e2  793a  7fc5  8494  84cd  8996  
-	8a66  8a69  8ae1  8c55  8c7a  57f4  5bd4  5f0f  606f  
-	62ed  690d  6b96  6e5c  7184  7bd2  8755  8b58  8efe  
-	98df  98fe  4f38  4f81  4fe1  547b  5a20  5bb8  613c  
-	65b0  6668  71fc  7533  795e  7d33  814e  81e3  8398  
-	85aa  85ce  8703  8a0a  8eab  8f9b  f971  8fc5  5931  
-	5ba4  5be6  6089  5be9  5c0b  5fc3  6c81  f972  6df1  
-	700b  751a  82af  8af6  4ec0  5341  f973  96d9  6c0f  
-	4e9e  4fc4  5152  555e  5a25  5ce8  6211  7259  82bd  
-	83aa  86fe  8859  8a1d  963f  96c5  9913  9d09  9d5d  
-	580a  5cb3  5dbd  5e44  60e1  6115  63e1  6a02  6e25  
-	9102  9354  984e  9c10  9f77  5b89  5cb8  6309  664f  
-	6848  773c  96c1  978d  9854  9b9f  65a1  8b01  8ecb  
-	95bc  5535  5ca9  5dd6  5eb5  6697  764c  83f4  95c7  
-	58d3  62bc  72ce  9d28  4ef0  592e  600f  663b  6b83  
-	79e7  9d26  5393  54c0  57c3  5d16  611b  66d6  6daf  
-	788d  827e  9698  9744  5384  627c  6396  6db2  7e0a  
-	814b  984d  6afb  7f4c  9daf  9e1a  4e5f  503b  51b6  
-	591c  60f9  63f6  6930  723a  8036  f974  91ce  5f31  
-	f975  f976  7d04  82e5  846f  84bb  85e5  8e8d  f977  
-	4f6f  f978  f979  58e4  5b43  6059  63da  6518  656d  
-	6698  f97a  694a  6a23  6d0b  7001  716c  75d2  760d  
-	79b3  7a70  f97b  7f8a  f97c  8944  f97d  8b93  91c0  
-	967d  f97e  990a  5704  5fa1  65bc  6f01  7600  79a6  
-	8a9e  99ad  9b5a  9f6c  5104  61b6  6291  6a8d  81c6  
-	5043  5830  5f66  7109  8a00  8afa  5b7c  8616  4ffa  
-	513c  56b4  5944  63a9  6df9  5daa  696d  5186  4e88  
-	4f59  f97f  f980  f981  5982  f982  f983  6b5f  6c5d  
-	f984  74b5  7916  f985  8207  8245  8339  8f3f  8f5d  
-	f986  9918  f987  f988  f989  4ea6  f98a  57df  5f79  
-	6613  f98b  f98c  75ab  7e79  8b6f  f98d  9006  9a5b  
-	56a5  5827  59f8  5a1f  5bb4  f98e  5ef6  f98f  f990  
-	6350  633b  f991  693d  6c87  6cbf  6d8e  6d93  6df5  
-	6f14  f992  70df  7136  7159  f993  71c3  71d5  f994  
-	784f  786f  f995  7b75  7de3  f996  7e2f  f997  884d  
-	8edf  f998  f999  f99a  925b  f99b  9cf6  f99c  f99d  
-	f99e  6085  6d85  f99f  71b1  f9a0  f9a1  95b1  53ad  
-	f9a2  f9a3  f9a4  67d3  f9a5  708e  7130  7430  8276  
-	82d2  f9a6  95bb  9ae5  9e7d  66c4  f9a7  71c1  8449  
-	f9a8  f9a9  584b  f9aa  f9ab  5db8  5f71  f9ac  6620  
-	668e  6979  69ae  6c38  6cf3  6e36  6f41  6fda  701b  
-	702f  7150  71df  7370  f9ad  745b  f9ae  74d4  76c8  
-	7a4e  7e93  f9af  f9b0  82f1  8a60  8fce  f9b1  9348  
-	f9b2  9719  f9b3  f9b4  4e42  502a  f9b5  5208  53e1  
-	66f3  6c6d  6fca  730a  777f  7a62  82ae  85dd  8602  
-	f9b6  88d4  8a63  8b7d  8c6b  f9b7  92b3  f9b8  9713  
-	9810  4e94  4f0d  4fc9  50b2  5348  543e  5433  55da  
-	5862  58ba  5967  5a1b  5be4  609f  f9b9  61ca  6556  
-	65ff  6664  68a7  6c5a  6fb3  70cf  71ac  7352  7b7d  
-	8708  8aa4  9c32  9f07  5c4b  6c83  7344  7389  923a  
-	6eab  7465  761f  7a69  7e15  860a  5140  58c5  64c1  
-	74ee  7515  7670  7fc1  9095  96cd  9954  6e26  74e6  
-	7aa9  7aaa  81e5  86d9  8778  8a1b  5a49  5b8c  5b9b  
-	68a1  6900  6d63  73a9  7413  742c  7897  7de9  7feb  
-	8118  8155  839e  8c4c  962e  9811  66f0  5f80  65fa  
-	6789  6c6a  738b  502d  5a03  6b6a  77ee  5916  5d6c  
-	5dcd  7325  754f  f9ba  f9bb  50e5  51f9  582f  592d  
-	5996  59da  5be5  f9bc  f9bd  5da2  62d7  6416  6493  
-	64fe  f9be  66dc  f9bf  6a48  f9c0  71ff  7464  f9c1  
-	7a88  7aaf  7e47  7e5e  8000  8170  f9c2  87ef  8981  
-	8b20  9059  f9c3  9080  9952  617e  6b32  6d74  7e1f  
-	8925  8fb1  4fd1  50ad  5197  52c7  57c7  5889  5bb9  
-	5eb8  6142  6995  6d8c  6e67  6eb6  7194  7462  7528  
-	752c  8073  8338  84c9  8e0a  9394  93de  f9c4  4e8e  
-	4f51  5076  512a  53c8  53cb  53f3  5b87  5bd3  5c24  
-	611a  6182  65f4  725b  7397  7440  76c2  7950  7991  
-	79b9  7d06  7fbd  828b  85d5  865e  8fc2  9047  90f5  
-	91ea  9685  96e8  96e9  52d6  5f67  65ed  6631  682f  
-	715c  7a36  90c1  980a  4e91  f9c5  6a52  6b9e  6f90  
-	7189  8018  82b8  8553  904b  9695  96f2  97fb  851a  
-	9b31  4e90  718a  96c4  5143  539f  54e1  5713  5712  
-	57a3  5a9b  5ac4  5bc3  6028  613f  63f4  6c85  6d39  
-	6e72  6e90  7230  733f  7457  82d1  8881  8f45  9060  
-	f9c6  9662  9858  9d1b  6708  8d8a  925e  4f4d  5049  
-	50de  5371  570d  59d4  5a01  5c09  6170  6690  6e2d  
-	7232  744b  7def  80c3  840e  8466  853f  875f  885b  
-	8918  8b02  9055  97cb  9b4f  4e73  4f91  5112  516a  
-	f9c7  552f  55a9  5b7a  5ba5  5e7c  5e7d  5ebe  60a0  
-	60df  6108  6109  63c4  6538  6709  f9c8  67d4  67da  
-	f9c9  6961  6962  6cb9  6d27  f9ca  6e38  f9cb  6fe1  
-	7336  7337  f9cc  745c  7531  f9cd  7652  f9ce  f9cf  
-	7dad  81fe  8438  88d5  8a98  8adb  8aed  8e30  8e42  
-	904a  903e  907a  9149  91c9  936e  f9d0  f9d1  5809  
-	f9d2  6bd3  8089  80b2  f9d3  f9d4  5141  596b  5c39  
-	f9d5  f9d6  6f64  73a7  80e4  8d07  f9d7  9217  958f  
-	f9d8  f9d9  f9da  f9db  807f  620e  701c  7d68  878d  
-	f9dc  57a0  6069  6147  6bb7  8abe  9280  96b1  4e59  
-	541f  6deb  852d  9670  97f3  98ee  63d6  6ce3  9091  
-	51dd  61c9  81ba  9df9  4f9d  501a  5100  5b9c  610f  
-	61ff  64ec  6905  6bc5  7591  77e3  7fa9  8264  858f  
-	87fb  8863  8abc  8b70  91ab  4e8c  4ee5  4f0a  f9dd  
-	f9de  5937  59e8  f9df  5df2  5f1b  5f5b  6021  f9e0  
-	f9e1  f9e2  f9e3  723e  73e5  f9e4  7570  75cd  f9e5  
-	79fb  f9e6  800c  8033  8084  82e1  8351  f9e7  f9e8  
-	8cbd  8cb3  9087  f9e9  f9ea  98f4  990c  f9eb  f9ec  
-	7037  76ca  7fca  7fcc  7ffc  8b1a  4eba  4ec1  5203  
-	5370  f9ed  54bd  56e0  59fb  5bc5  5f15  5fcd  6e6e  
-	f9ee  f9ef  7d6a  8335  f9f0  8693  8a8d  f9f1  976d  
-	9777  f9f2  f9f3  4e00  4f5a  4f7e  58f9  65e5  6ea2  
-	9038  93b0  99b9  4efb  58ec  598a  59d9  6041  f9f4  
-	f9f5  7a14  f9f6  834f  8cc3  5165  5344  f9f7  f9f8  
-	f9f9  4ecd  5269  5b55  82bf  4ed4  523a  54a8  59c9  
-	59ff  5b50  5b57  5b5c  6063  6148  6ecb  7099  716e  
-	7386  74f7  75b5  78c1  7d2b  8005  81ea  8328  8517  
-	85c9  8aee  8cc7  96cc  4f5c  52fa  56bc  65ab  6628  
-	707c  70b8  7235  7dbd  828d  914c  96c0  9d72  5b71  
-	68e7  6b98  6f7a  76de  5c91  66ab  6f5b  7bb4  7c2a  
-	8836  96dc  4e08  4ed7  5320  5834  58bb  58ef  596c  
-	5c07  5e33  5e84  5f35  638c  66b2  6756  6a1f  6aa3  
-	6b0c  6f3f  7246  f9fa  7350  748b  7ae0  7ca7  8178  
-	81df  81e7  838a  846c  8523  8594  85cf  88dd  8d13  
-	91ac  9577  969c  518d  54c9  5728  5bb0  624d  6750  
-	683d  6893  6e3d  6ed3  707d  7e21  88c1  8ca1  8f09  
-	9f4b  9f4e  722d  7b8f  8acd  931a  4f47  4f4e  5132  
-	5480  59d0  5e95  62b5  6775  696e  6a17  6cae  6e1a  
-	72d9  732a  75bd  7bb8  7d35  82e7  83f9  8457  85f7  
-	8a5b  8caf  8e87  9019  90b8  96ce  9f5f  52e3  540a  
-	5ae1  5bc2  6458  6575  6ef4  72c4  f9fb  7684  7a4d  
-	7b1b  7c4d  7e3e  7fdf  837b  8b2b  8cca  8d64  8de1  
-	8e5f  8fea  8ff9  9069  93d1  4f43  4f7a  50b3  5168  
-	5178  524d  526a  5861  587c  5960  5c08  5c55  5edb  
-	609b  6230  6813  6bbf  6c08  6fb1  714e  7420  7530  
-	7538  7551  7672  7b4c  7b8b  7bad  7bc6  7e8f  8a6e  
-	8f3e  8f49  923f  9293  9322  942b  96fb  985a  986b  
-	991e  5207  622a  6298  6d59  7664  7aca  7bc0  7d76  
-	5360  5cbe  5e97  6f38  70b9  7c98  9711  9b8e  9ede  
-	63a5  647a  8776  4e01  4e95  4ead  505c  5075  5448  
-	59c3  5b9a  5e40  5ead  5ef7  5f81  60c5  633a  653f  
-	6574  65cc  6676  6678  67fe  6968  6a89  6b63  6c40  
-	6dc0  6de8  6e1f  6e5e  701e  70a1  738e  73fd  753a  
-	775b  7887  798e  7a0b  7a7d  7cbe  7d8e  8247  8a02  
-	8aea  8c9e  912d  914a  91d8  9266  92cc  9320  9706  
-	9756  975c  9802  9f0e  5236  5291  557c  5824  5e1d  
-	5f1f  608c  63d0  68af  6fdf  796d  7b2c  81cd  85ba  
-	88fd  8af8  8e44  918d  9664  969b  973d  984c  9f4a  
-	4fce  5146  51cb  52a9  5632  5f14  5f6b  63aa  64cd  
-	65e9  6641  66fa  66f9  671d  689d  68d7  69fd  6f15  
-	6f6e  7167  71e5  722a  74aa  773a  7956  795a  79df  
-	7a20  7a95  7c97  7cdf  7d44  7e70  8087  85fb  86a4  
-	8a54  8abf  8d99  8e81  9020  906d  91e3  963b  96d5  
-	9ce5  65cf  7c07  8db3  93c3  5b58  5c0a  5352  62d9  
-	731d  5027  5b97  5f9e  60b0  616b  68d5  6dd9  742e  
-	7a2e  7d42  7d9c  7e31  816b  8e2a  8e35  937e  9418  
-	4f50  5750  5de6  5ea7  632b  7f6a  4e3b  4f4f  4f8f  
-	505a  59dd  80c4  546a  5468  55fe  594f  5b99  5dde  
-	5eda  665d  6731  67f1  682a  6ce8  6d32  6e4a  6f8d  
-	70b7  73e0  7587  7c4c  7d02  7d2c  7da2  821f  86db  
-	8a3b  8a85  8d70  8e8a  8f33  9031  914e  9152  9444  
-	99d0  7af9  7ca5  4fca  5101  51c6  57c8  5bef  5cfb  
-	6659  6a3d  6d5a  6e96  6fec  710c  756f  7ae3  8822  
-	9021  9075  96cb  99ff  8301  4e2d  4ef2  8846  91cd  
-	537d  6adb  696b  6c41  847a  589e  618e  66fe  62ef  
-	70dd  7511  75c7  7e52  84b8  8b49  8d08  4e4b  53ea  
-	54ab  5730  5740  5fd7  6301  6307  646f  652f  65e8  
-	667a  679d  67b3  6b62  6c60  6c9a  6f2c  77e5  7825  
-	7949  7957  7d19  80a2  8102  81f3  829d  82b7  8718  
-	8a8c  f9fc  8d04  8dbe  9072  76f4  7a19  7a37  7e54  
-	8077  5507  55d4  5875  632f  6422  6649  664b  686d  
-	699b  6b84  6d25  6eb1  73cd  7468  74a1  755b  75b9  
-	76e1  771e  778b  79e6  7e09  7e1d  81fb  852f  8897  
-	8a3a  8cd1  8eeb  8fb0  9032  93ad  9663  9673  9707  
-	4f84  53f1  59ea  5ac9  5e19  684e  74c6  75be  79e9  
-	7a92  81a3  86ed  8cea  8dcc  8fed  659f  6715  f9fd  
-	57f7  6f57  7ddd  8f2f  93f6  96c6  5fb5  61f2  6f84  
-	4e14  4f98  501f  53c9  55df  5d6f  5dee  6b21  6b64  
-	78cb  7b9a  f9fe  8e49  8eca  906e  6349  643e  7740  
-	7a84  932f  947f  9f6a  64b0  6faf  71e6  74a8  74da  
-	7ac4  7c12  7e82  7cb2  7e98  8b9a  8d0a  947d  9910  
-	994c  5239  5bdf  64e6  672d  7d2e  50ed  53c3  5879  
-	6158  6159  61fa  65ac  7ad9  8b92  8b96  5009  5021  
-	5275  5531  5a3c  5ee0  5f70  6134  655e  660c  6636  
-	66a2  69cd  6ec4  6f32  7316  7621  7a93  8139  8259  
-	83d6  84bc  50b5  57f0  5bc0  5be8  5f69  63a1  7826  
-	7db5  83dc  8521  91c7  91f5  518a  67f5  7b56  8cac  
-	51c4  59bb  60bd  8655  501c  f9ff  5254  5c3a  617d  
-	621a  62d3  64f2  65a5  6ecc  7620  810a  8e60  965f  
-	96bb  4edf  5343  5598  5929  5ddd  64c5  6cc9  6dfa  
-	7394  7a7f  821b  85a6  8ce4  8e10  9077  91e7  95e1  
-	9621  97c6  51f8  54f2  5586  5fb9  64a4  6f88  7db4  
-	8f1f  8f4d  9435  50c9  5c16  6cbe  6dfb  751b  77bb  
-	7c3d  7c64  8a79  8ac2  581e  59be  5e16  6377  7252  
-	758a  776b  8adc  8cbc  8f12  5ef3  6674  6df8  807d  
-	83c1  8acb  9751  9bd6  fa00  5243  66ff  6d95  6eef  
-	7de0  8ae6  902e  905e  9ad4  521d  527f  54e8  6194  
-	6284  62db  68a2  6912  695a  6a35  7092  7126  785d  
-	7901  790e  79d2  7a0d  8096  8278  82d5  8349  8549  
-	8c82  8d85  9162  918b  91ae  4fc3  56d1  71ed  77d7  
-	8700  89f8  5bf8  5fd6  6751  90a8  53e2  585a  5bf5  
-	60a4  6181  6460  7e3d  8070  8525  9283  64ae  50ac  
-	5d14  6700  589c  62bd  63a8  690e  6978  6a1e  6e6b  
-	76ba  79cb  82bb  8429  8acf  8da8  8ffd  9112  914b  
-	919c  9310  9318  939a  96db  9a36  9c0d  4e11  755c  
-	795d  7afa  7b51  7bc9  7e2e  84c4  8e59  8e74  8ef8  
-	9010  6625  693f  7443  51fa  672e  9edc  5145  5fe0  
-	6c96  87f2  885d  8877  60b4  81b5  8403  8d05  53d6  
-	5439  5634  5a36  5c31  708a  7fe0  805a  8106  81ed  
-	8da3  9189  9a5f  9df2  5074  4ec4  53a0  60fb  6e2c  
-	5c64  4f88  5024  55e4  5cd9  5e5f  6065  6894  6cbb  
-	6dc4  71be  75d4  75f4  7661  7a1a  7a49  7dc7  7dfb  
-	7f6e  81f4  86a9  8f1c  96c9  99b3  9f52  5247  52c5  
-	98ed  89aa  4e03  67d2  6f06  4fb5  5be2  6795  6c88  
-	6d78  741b  7827  91dd  937c  87c4  79e4  7a31  5feb  
-	4ed6  54a4  553e  58ae  59a5  60f0  6253  62d6  6736  
-	6955  8235  9640  99b1  99dd  502c  5353  5544  577c  
-	fa01  6258  fa02  64e2  666b  67dd  6fc1  6fef  7422  
-	7438  8a17  9438  5451  5606  5766  5f48  619a  6b4e  
-	7058  70ad  7dbb  8a95  596a  812b  63a2  7708  803d  
-	8caa  5854  642d  69bb  5b95  5e11  6e6f  fa03  8569  
-	514c  53f0  592a  6020  614b  6b86  6c70  6cf0  7b1e  
-	80ce  82d4  8dc6  90b0  98b1  fa04  64c7  6fa4  6491  
-	6504  514e  5410  571f  8a0e  615f  6876  fa05  75db  
-	7b52  7d71  901a  5806  69cc  817f  892a  9000  9839  
-	5078  5957  59ac  6295  900f  9b2a  615d  7279  95d6  
-	5761  5a46  5df4  628a  64ad  64fa  6777  6ce2  6d3e  
-	722c  7436  7834  7f77  82ad  8ddb  9817  5224  5742  
-	677f  7248  74e3  8ca9  8fa6  9211  962a  516b  53ed  
-	634c  4f69  5504  6096  6557  6c9b  6d7f  724c  72fd  
-	7a17  8987  8c9d  5f6d  6f8e  70f9  81a8  610e  4fbf  
-	504f  6241  7247  7bc7  7de8  7fe9  904d  97ad  9a19  
-	8cb6  576a  5e73  67b0  840d  8a55  5420  5b16  5e63  
-	5ee2  5f0a  6583  80ba  853d  9589  965b  4f48  5305  
-	530d  530f  5486  54fa  5703  5e03  6016  629b  62b1  
-	6355  fa06  6ce1  6d66  75b1  7832  80de  812f  82de  
-	8461  84b2  888d  8912  900b  92ea  98fd  9b91  5e45  
-	66b4  66dd  7011  7206  fa07  4ff5  527d  5f6a  6153  
-	6753  6a19  6f02  74e2  7968  8868  8c79  98c7  98c4  
-	9a43  54c1  7a1f  6953  8af7  8c4a  98a8  99ae  5f7c  
-	62ab  75b2  76ae  88ab  907f  9642  5339  5f3c  5fc5  
-	6ccc  73cc  7562  758b  7b46  82fe  999d  4e4f  903c  
-	4e0b  4f55  53a6  590f  5ec8  6630  6cb3  7455  8377  
-	8766  8cc0  9050  971e  9c15  58d1  5b78  8650  8b14  
-	9db4  5bd2  6068  608d  65f1  6c57  6f22  6fa3  701a  
-	7f55  7ff0  9591  9592  9650  97d3  5272  8f44  51fd  
-	542b  54b8  5563  558a  6abb  6db5  7dd8  8266  929c  
-	9677  9e79  5408  54c8  76d2  86e4  95a4  95d4  965c  
-	4ea2  4f09  59ee  5ae6  5df7  6052  6297  676d  6841  
-	6c86  6e2f  7f38  809b  822a  fa08  fa09  9805  4ea5  
-	5055  54b3  5793  595a  5b69  5bb3  61c8  6977  6d77  
-	7023  87f9  89e3  8a72  8ae7  9082  99ed  9ab8  52be  
-	6838  5016  5e78  674f  8347  884c  4eab  5411  56ae  
-	73e6  9115  97ff  9909  9957  9999  5653  589f  865b  
-	8a31  61b2  6af6  737b  8ed2  6b47  96aa  9a57  5955  
-	7200  8d6b  9769  4fd4  5cf4  5f26  61f8  665b  6ceb  
-	70ab  7384  73b9  73fe  7729  774d  7d43  7d62  7e23  
-	8237  8852  fa0a  8ce2  9249  986f  5b51  7a74  8840  
-	9801  5acc  4fe0  5354  593e  5cfd  633e  6d79  72f9  
-	8105  8107  83a2  92cf  9830  4ea8  5144  5211  578b  
-	5f62  6cc2  6ece  7005  7050  70af  7192  73e9  7469  
-	834a  87a2  8861  9008  90a2  93a3  99a8  516e  5f57  
-	60e0  6167  66b3  8559  8e4a  91af  978b  4e4e  4e92  
-	547c  58d5  58fa  597d  5cb5  5f27  6236  6248  660a  
-	6667  6beb  6d69  6dcf  6e56  6ef8  6f94  6fe0  6fe9  
-	705d  72d0  7425  745a  74e0  7693  795c  7cca  7e1e  
-	80e1  82a6  846b  84bf  864e  865f  8774  8b77  8c6a  
-	93ac  9800  9865  60d1  6216  9177  5a5a  660f  6df7  
-	6e3e  743f  9b42  5ffd  60da  7b0f  54c4  5f18  6c5e  
-	6cd3  6d2a  70d8  7d05  8679  8a0c  9d3b  5316  548c  
-	5b05  6a3a  706b  7575  798d  79be  82b1  83ef  8a71  
-	8b41  8ca8  9774  fa0b  64f4  652b  78ba  78bb  7a6b  
-	4e38  559a  5950  5ba6  5e7b  60a3  63db  6b61  6665  
-	6853  6e19  7165  74b0  7d08  9084  9a69  9c25  6d3b  
-	6ed1  733e  8c41  95ca  51f0  5e4c  5fa8  604d  60f6  
-	6130  614c  6643  6644  69a5  6cc1  6e5f  6ec9  6f62  
-	714c  749c  7687  7bc1  7c27  8352  8757  9051  968d  
-	9ec3  532f  56de  5efb  5f8a  6062  6094  61f7  6666  
-	6703  6a9c  6dee  6fae  7070  736a  7e6a  81be  8334  
-	86d4  8aa8  8cc4  5283  7372  5b96  6a6b  9404  54ee  
-	5686  5b5d  6548  6585  66c9  689f  6d8d  6dc6  723b  
-	80b4  9175  9a4d  4faf  5019  539a  540e  543c  5589  
-	55c5  5e3f  5f8c  673d  7166  73dd  9005  52db  52f3  
-	5864  58ce  7104  718f  71fb  85b0  8a13  6688  85a8  
-	55a7  6684  714a  8431  5349  5599  6bc1  5f59  5fbd  
-	63ee  6689  7147  8af1  8f1d  9ebe  4f11  643a  70cb  
-	7566  8667  6064  8b4e  9df8  5147  51f6  5308  6d36  
-	80f8  9ed1  6615  6b23  7098  75d5  5403  5c79  7d07  
-	8a16  6b20  6b3d  6b46  5438  6070  6d3d  7fd5  8208  
-	50d6  51de  559c  566b  56cd  59ec  5b09  5e0c  6199  
-	6198  6231  665e  66e6  7199  71b9  71ba  72a7  79a7  
-	7a00  7fb2  8a70  
-	0
Index: xc/nls/XLC_LOCALE/microsoft-cp1251
diff -u /dev/null xc/nls/XLC_LOCALE/microsoft-cp1251:1.2
--- /dev/null	Mon Dec 18 14:27:05 2000
+++ xc/nls/XLC_LOCALE/microsoft-cp1251	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,87 @@
+XCOMM  $TOG: microsoft-cp1251 /main/1 1998/05/20 14:49:21 kaleb $
+XCOMM  XLocale Database Sample for microsoft-cp1251.
+XCOMM 
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/microsoft-cp1251,v 1.2 2000/12/01 17:43:03 dawes Exp $
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class 
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		MICROSOFT-CP1251:GL
+		substitute	ISO8859-1:GL
+		vertical_rotate	all
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset	{
+		name		MICROSOFT-CP1251:GR
+	}
+	font	{
+		primary		MICROSOFT-CP1251:GR
+	}
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	MICROSOFT-CP1251
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name		MICROSOFT-CP1251
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+force_convert_to_mb	True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding	MICROSOFT-CP1251:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding	MICROSOFT-CP1251:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/microsoft-cp1255
diff -u /dev/null xc/nls/XLC_LOCALE/microsoft-cp1255:1.2
--- /dev/null	Mon Dec 18 14:27:06 2000
+++ xc/nls/XLC_LOCALE/microsoft-cp1255	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,87 @@
+XCOMM  $TOG: microsoft-cp1255 /main/1 1998/05/20 14:49:21 kaleb $
+XCOMM  XLocale Database Sample for microsoft-cp1255.
+XCOMM 
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/microsoft-cp1255,v 1.2 2000/12/01 17:43:03 dawes Exp $
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class 
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		MICROSOFT-CP1255:GL
+		substitute	ISO8859-1:GL
+		vertical_rotate	all
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset	{
+		name		MICROSOFT-CP1255:GR
+	}
+	font	{
+		primary		MICROSOFT-CP1255:GR
+	}
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	MICROSOFT-CP1255
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name		MICROSOFT-CP1255
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+force_convert_to_mb	True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding	MICROSOFT-CP1255:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding	MICROSOFT-CP1255:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/microsoft-cp1256
diff -u /dev/null xc/nls/XLC_LOCALE/microsoft-cp1256:1.2
--- /dev/null	Mon Dec 18 14:27:07 2000
+++ xc/nls/XLC_LOCALE/microsoft-cp1256	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,87 @@
+XCOMM  $TOG: microsoft-cp1256 /main/1 1998/05/20 14:49:21 kaleb $
+XCOMM  XLocale Database Sample for microsoft-cp1256.
+XCOMM 
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/microsoft-cp1256,v 1.2 2000/12/01 17:43:03 dawes Exp $
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class 
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		MICROSOFT-CP1256:GL
+		substitute	ISO8859-1:GL
+		vertical_rotate	all
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset	{
+		name		MICROSOFT-CP1256:GR
+	}
+	font	{
+		primary		MICROSOFT-CP1256:GR
+	}
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	MICROSOFT-CP1256
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name		MICROSOFT-CP1256
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+force_convert_to_mb	True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding	MICROSOFT-CP1256:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding	MICROSOFT-CP1256:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/mulelao-1
diff -u xc/nls/XLC_LOCALE/mulelao-1:1.1 xc/nls/XLC_LOCALE/mulelao-1:1.2
--- xc/nls/XLC_LOCALE/mulelao-1:1.1	Sun Jun  6 10:05:59 1999
+++ xc/nls/XLC_LOCALE/mulelao-1	Fri Dec  1 12:43:03 2000
@@ -1,4 +1,4 @@
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/mulelao-1,v 1.1 1999/06/06 14:05:59 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/mulelao-1,v 1.2 2000/12/01 17:43:03 dawes Exp $
 XCOMM  XLocale Database Sample for mulelao-1.
 XCOMM 
 
@@ -8,8 +8,13 @@
 XLC_FONTSET
 XCOMM 	fs0 class (7 bit ASCII)
 fs0	{
-	charset		ISO8859-1:GL
-	font            MULELAO-1:GL; ISO8859-1:GL
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		MULELAO-1:GL
+		substitute	ISO8859-1:GL
+	}
 }
 XCOMM 	fs1 class 
 fs1	{
@@ -18,6 +23,19 @@
 }
 END XLC_FONTSET
 
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	MULELAO-1
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
 XCOMM 
 XCOMM 	XLC_XLOCALE category
 XCOMM 
@@ -34,6 +52,10 @@
 wc_shift_bits		8
 #endif
 
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
 XCOMM 	cs0 class
 cs0	{
 	side		GL:Default
@@ -52,7 +74,7 @@
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     MULELAO-1:GR; ISO8859-1:GR
+	ct_encoding     MULELAO-1:GR
 }
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/nokhchi-1
diff -u /dev/null xc/nls/XLC_LOCALE/nokhchi-1:1.2
--- /dev/null	Mon Dec 18 14:27:09 2000
+++ xc/nls/XLC_LOCALE/nokhchi-1	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,80 @@
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/nokhchi-1,v 1.2 2000/12/01 17:43:03 dawes Exp $
+XCOMM  XLocale Database Sample for mulelao-1.
+XCOMM 
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class (7 bit ASCII)
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		NOKHCHI-1:GL 
+		substitute	ISO8859-1:GL
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset         NOKHCHI-1:GR
+	font            NOKHCHI-1:GR
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	NOKHCHI-1
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name           NOKHCHI-1
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding     NOKHCHI-1:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding     NOKHCHI-1:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/tab8859_1
diff -u xc/nls/XLC_LOCALE/tab8859_1:1.1.1.1 xc/nls/XLC_LOCALE/tab8859_1:removed
--- xc/nls/XLC_LOCALE/tab8859_1:1.1.1.1	Sat Dec 21 22:29:37 1996
+++ xc/nls/XLC_LOCALE/tab8859_1	Mon Dec 18 14:27:10 2000
@@ -1,16 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af 
-b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf 
-c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf 
-d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df 
-e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef 
-f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 
Index: xc/nls/XLC_LOCALE/tab8859_10
diff -u xc/nls/XLC_LOCALE/tab8859_10:1.2 xc/nls/XLC_LOCALE/tab8859_10:removed
--- xc/nls/XLC_LOCALE/tab8859_10:1.2	Mon Aug 30 10:36:15 1999
+++ xc/nls/XLC_LOCALE/tab8859_10	Mon Dec 18 14:27:11 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 0104 0112 0122 012a 0128 0136 00a7 
-013b 0110 0160 0166 017d 00ad 016a 014a 
-00b0 0105 0113 0123 012b 0129 0137 00b7 
-013c 0111 0161 0167 017e 2015 016b 014b 
-0100 00c1 00c2 00c3 00c4 00c5 00c6 012e 
-010c 00c9 0118 00cb 0116 00cd 00ce 00cf 
-00d0 0145 014c 00d3 00d4 00d5 00d6 0168 
-00d8 0172 00da 00db 00dc 00dd 00de 00df 
-0101 00e1 00e2 00e3 00e4 00e5 00e6 012f 
-010d 00e9 0119 00eb 0117 00ed 00ee 00ef 
-00f0 0146 014d 00f3 00f4 00f5 00f6 0169 
-00f8 0173 00fa 00fb 00fc 00fd 00fe 0138 
Index: xc/nls/XLC_LOCALE/tab8859_14
diff -u xc/nls/XLC_LOCALE/tab8859_14:1.1 xc/nls/XLC_LOCALE/tab8859_14:removed
--- xc/nls/XLC_LOCALE/tab8859_14:1.1	Sun Jun  6 10:05:59 1999
+++ xc/nls/XLC_LOCALE/tab8859_14	Mon Dec 18 14:27:12 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 1e02 1e03 00a3 010a 010b 1e0a 00a7 
-1e80 00a9 1e82 1e0b 1ef2 00ad 00ae 0178 
-1e1e 1e1f 0120 0121 1e40 1e41 00b6 1e56 
-1e81 1e57 1e83 1e60 1ef3 1e84 1e85 1e61 
-00c0 00c1 00c2 00c3 00c4 00c5 00c6 00c7 
-00c8 00c9 00ca 00cb 00cc 00cd 00ce 00cf 
-0174 00d1 00d2 00d3 00d4 00d5 00d6 1e6a 
-00d8 00d9 00da 00db 00dc 00dd 0176 00df 
-00e0 00e1 00e2 00e3 00e4 00e5 00e6 00e7 
-00e8 00e9 00ea 00eb 00ec 00ed 00ee 00ef 
-0175 00f1 00f2 00f3 00f4 00f5 00f6 1e6b 
-00f8 00f9 00fa 00fb 00fc 00fd 0177 00ff 
Index: xc/nls/XLC_LOCALE/tab8859_15
diff -u xc/nls/XLC_LOCALE/tab8859_15:1.1 xc/nls/XLC_LOCALE/tab8859_15:removed
--- xc/nls/XLC_LOCALE/tab8859_15:1.1	Sun Sep 27 07:06:15 1998
+++ xc/nls/XLC_LOCALE/tab8859_15	Mon Dec 18 14:27:13 2000
@@ -1,16 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-a0 a1 a2 a3 20ac a5 0160 a7 0161 a9 aa ab ac ad ae af 
-b0 b1 b2 b3 017d b5 b6 b7 017e b9 ba bb 0152 0153 0178 bf 
-c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf 
-d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df 
-e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef 
-f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 
Index: xc/nls/XLC_LOCALE/tab8859_2
diff -u xc/nls/XLC_LOCALE/tab8859_2:1.1.1.1 xc/nls/XLC_LOCALE/tab8859_2:removed
--- xc/nls/XLC_LOCALE/tab8859_2:1.1.1.1	Sat Dec 21 22:29:37 1996
+++ xc/nls/XLC_LOCALE/tab8859_2	Mon Dec 18 14:27:13 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 0104 02d8 0141 00a4 013d 015a 00a7 
-00a8 0160 015e 0164 0179 00ad 017d 017b 
-00b0 0105 02db 0142 00b4 013e 015b 02c7 
-00b8 0161 015f 0165 017a 02dd 017e 017c 
-0154 00c1 00c2 0102 00c4 0139 0106 00c7 
-010c 00c9 0118 00cb 011a 00cd 00ce 010e 
-0110 0143 0147 00d3 00d4 0150 00d6 00d7 
-0158 016e 00da 0170 00dc 00dd 0162 00df 
-0155 00e1 00e2 0103 00e4 013a 0107 00e7 
-010d 00e9 0119 00eb 011b 00ed 00ee 010f 
-0111 0144 0148 00f3 00f4 0151 00f6 00f7 
-0159 016f 00fa 0171 00fc 00fd 0163 02d9 
Index: xc/nls/XLC_LOCALE/tab8859_3
diff -u xc/nls/XLC_LOCALE/tab8859_3:1.1.1.1 xc/nls/XLC_LOCALE/tab8859_3:removed
--- xc/nls/XLC_LOCALE/tab8859_3:1.1.1.1	Sat Dec 21 22:29:37 1996
+++ xc/nls/XLC_LOCALE/tab8859_3	Mon Dec 18 14:27:14 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 0126 02d8 00a3 00a4     -1 0124 00a7 
-00a8 0130 015e 011e 0134 00ad     -1 017b 
-00b0 0127 00b2 00b3 00b4 00b5 0125 00b7 
-00b8 0131 015f 011f 0135 00bd     -1 017c 
-00c0 00c1 00c2     -1 00c4 010a 0108 00c7 
-00c8 00c9 00ca 00cb 00cc 00cd 00ce 00cf 
-    -1 00d1 00d2 00d3 00d4 0120 00d6 00d7 
-011c 00d9 00da 00db 00dc 016c 015c 00df 
-00e0 00e1 00e2     -1 00e4 010b 0109 00e7 
-00e8 00e9 00ea 00eb 00ec 00ed 00ee 00ef 
-    -1 00f1 00f2 00f3 00f4 0121 00f6 00f7 
-011d 00f9 00fa 00fb 00fc 016d 015d 02d9 
Index: xc/nls/XLC_LOCALE/tab8859_4
diff -u xc/nls/XLC_LOCALE/tab8859_4:1.1.1.1 xc/nls/XLC_LOCALE/tab8859_4:removed
--- xc/nls/XLC_LOCALE/tab8859_4:1.1.1.1	Sat Dec 21 22:29:37 1996
+++ xc/nls/XLC_LOCALE/tab8859_4	Mon Dec 18 14:27:14 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 0104 0138 0156 00a4 0128 013b 00a7 
-00a8 0160 0112 0122 0166 00ad 017d 00af 
-00b0 0105 02db 0157 00b4 0129 013c 02c7 
-00b8 0161 0113 0123 0167 014a 017e 014b 
-0100 00c1 00c2 00c3 00c4 00c5 00c6 012e 
-010c 00c9 0118 00cb 0116 00cd 00ce 012a 
-0110 0145 014c 0136 00d4 00d5 00d6 00d7 
-00d8 0172 00da 00db 00dc 0168 016a 00df 
-0101 00e1 00e2 00e3 00e4 00e5 00e6 012f 
-010d 00e9 0119 00eb 0117 00ed 00ee 012b 
-0111 0146 014d 0137 00f4 00f5 00f6 00f7 
-00f8 0173 00fa 00fb 00fc 0169 016b 02d9 
Index: xc/nls/XLC_LOCALE/tab8859_5
diff -u xc/nls/XLC_LOCALE/tab8859_5:1.1.1.1 xc/nls/XLC_LOCALE/tab8859_5:removed
--- xc/nls/XLC_LOCALE/tab8859_5:1.1.1.1	Sat Dec 21 22:29:37 1996
+++ xc/nls/XLC_LOCALE/tab8859_5	Mon Dec 18 14:27:15 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 0401 0402 0403 0404 0405 0406 0407 
-0408 0409 040a 040b 040c 00ad 040e 040f 
-0410 0411 0412 0413 0414 0415 0416 0417 
-0418 0419 041a 041b 041c 041d 041e 041f 
-0420 0421 0422 0423 0424 0425 0426 0427 
-0428 0429 042a 042b 042c 042d 042e 042f 
-0430 0431 0432 0433 0434 0435 0436 0437 
-0438 0439 043a 043b 043c 043d 043e 043f 
-0440 0441 0442 0443 0444 0445 0446 0447 
-0448 0449 044a 044b 044c 044d 044e 044f 
-2116 0451 0452 0453 0454 0455 0456 0457 
-0458 0459 045a 045b 045c 00a7 045e 045f 
Index: xc/nls/XLC_LOCALE/tab8859_6
diff -u xc/nls/XLC_LOCALE/tab8859_6:1.3 xc/nls/XLC_LOCALE/tab8859_6:removed
--- xc/nls/XLC_LOCALE/tab8859_6:1.3	Sat Jan 29 13:58:22 2000
+++ xc/nls/XLC_LOCALE/tab8859_6	Mon Dec 18 14:27:15 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0     -1     -1     -1 00a4     -1     -1     -1 
-    -1     -1     -1     -1 060c 00ad     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1 061b     -1     -1     -1 061f 
-    -1 0621 0622 0623 0624 0625 0626 0627 
-0628 0629 062a 062b 062c 062d 062e 062f 
-0630 0631 0632 0633 0634 0635 0636 0637 
-0638 0639 063a     -1     -1     -1     -1     -1 
-0640 0641 0642 0643 0644 0645 0646 0647 
-0648 0649 064a 064b 064c 064d 064e 064f 
-0650 0651 0652     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
Index: xc/nls/XLC_LOCALE/tab8859_7
diff -u xc/nls/XLC_LOCALE/tab8859_7:1.3 xc/nls/XLC_LOCALE/tab8859_7:removed
--- xc/nls/XLC_LOCALE/tab8859_7:1.3	Sat Jan 29 13:58:22 2000
+++ xc/nls/XLC_LOCALE/tab8859_7	Mon Dec 18 14:27:15 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 2018 2019 00a3     -1     -1 00a6 00a7 
-00a8 00a9     -1 00ab 00ac 00ad     -1 2015 
-00b0 00b1 00b2 00b3 0384 0385 0386 00b7 
-0388 0389 038a 00bb 038c 00bd 038e 038f 
-0390 0391 0392 0393 0394 0395 0396 0397 
-0398 0399 039a 039b 039c 039d 039e 039f 
-03a0 03a1     -1 03a3 03a4 03a5 03a6 03a7 
-03a8 03a9 03aa 03ab 03ac 03ad 03ae 03af 
-03b0 03b1 03b2 03b3 03b4 03b5 03b6 03b7 
-03b8 03b9 03ba 03bb 03bc 03bd 03be 03bf 
-03c0 03c1 03c2 03c3 03c4 03c5 03c6 03c7 
-03c8 03c9 03ca 03cb 03cc 03cd 03ce     -1 
Index: xc/nls/XLC_LOCALE/tab8859_8
diff -u xc/nls/XLC_LOCALE/tab8859_8:1.1.1.1 xc/nls/XLC_LOCALE/tab8859_8:removed
--- xc/nls/XLC_LOCALE/tab8859_8:1.1.1.1	Sat Dec 21 22:29:38 1996
+++ xc/nls/XLC_LOCALE/tab8859_8	Mon Dec 18 14:27:16 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0     -1 00a2 00a3 00a4 00a5 00a6 00a7 
-00a8 00a9 00d7 00ab 00ac 00ad 00ae 203e 
-00b0 00b1 00b2 00b3 00b4 00b5 00b6 00b7 
-00b8 00b9 00f7 00bb 00bc 00bd 00be     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1     -1 
-    -1     -1     -1     -1     -1     -1     -1 2017 
-05d0 05d1 05d2 05d3 05d4 05d5 05d6 05d7 
-05d8 05d9 05da 05db 05dc 05dd 05de 05df 
-05e0 05e1 05e2 05e3 05e4 05e5 05e6 05e7 
-05e8 05e9 05ea     -1     -1     -1     -1     -1 
Index: xc/nls/XLC_LOCALE/tab8859_9
diff -u xc/nls/XLC_LOCALE/tab8859_9:1.1.1.1 xc/nls/XLC_LOCALE/tab8859_9:removed
--- xc/nls/XLC_LOCALE/tab8859_9:1.1.1.1	Sat Dec 21 22:29:38 1996
+++ xc/nls/XLC_LOCALE/tab8859_9	Mon Dec 18 14:27:16 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 00a1 00a2 00a3 00a4 00a5 00a6 00a7 
-00a8 00a9 00aa 00ab 00ac 00ad 00ae 00af 
-00b0 00b1 00b2 00b3 00b4 00b5 00b6 00b7 
-00b8 00b9 00ba 00bb 00bc 00bd 00be 00bf 
-00c0 00c1 00c2 00c3 00c4 00c5 00c6 00c7 
-00c8 00c9 00ca 00cb 00cc 00cd 00ce 00cf 
-011e 00d1 00d2 00d3 00d4 00d5 00d6 00d7 
-00d8 00d9 00da 00db 00dc 0130 015e 00df 
-00e0 00e1 00e2 00e3 00e4 00e5 00e6 00e7 
-00e8 00e9 00ea 00eb 00ec 00ed 00ee 00ef 
-011f 00f1 00f2 00f3 00f4 00f5 00f6 00f7 
-00f8 00f9 00fa 00fb 00fc 0131 015f 00ff 
Index: xc/nls/XLC_LOCALE/tabarmscii_8
diff -u xc/nls/XLC_LOCALE/tabarmscii_8:1.2 xc/nls/XLC_LOCALE/tabarmscii_8:removed
--- xc/nls/XLC_LOCALE/tabarmscii_8:1.2	Sat Jan 29 13:58:23 2000
+++ xc/nls/XLC_LOCALE/tabarmscii_8	Mon Dec 18 14:27:16 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 2741 00a7 0589 0029 0028 00bb 00ab 
-2014 002e 055d 002c 002d 055f 2026 055c 
-055b 055e 0531 0561 0532 0562 0533 0563
-0534 0564 0535 0565 0536 0566 0537 0567 
-0538 0568 0539 0569 053a 056a 053b 056b 
-053c 056c 053d 056d 053e 056e 053f 056f 
-0540 0570 0541 0571 0542 0572 0543 0573 
-0544 0574 0545 0575 0546 0576 0547 0577 
-0548 0578 0549 0579 054a 057a 054b 057b 
-054c 057c 054d 057d 054e 057e 054f 057f 
-0550 0580 0551 0581 0552 0582 0553 0583 
-0554 0584 0555 0585 0556 0586 2019 0027 
Index: xc/nls/XLC_LOCALE/tabgeorgian_academy
diff -u xc/nls/XLC_LOCALE/tabgeorgian_academy:1.2 xc/nls/XLC_LOCALE/tabgeorgian_academy:removed
--- xc/nls/XLC_LOCALE/tabgeorgian_academy:1.2	Sat Jan 29 13:58:23 2000
+++ xc/nls/XLC_LOCALE/tabgeorgian_academy	Mon Dec 18 14:27:17 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-0080 0081 201a 0192 201e 2026 2020 2021 
-02c6 2030 0160 2039 0152 008d 008e 008f 
-0090 2018 2019 201c 201d 2022 2013 2014 
-02dc 2122 0161 203a 0153 009d 009e 0178 
-a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af 
-b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf 
-10d0 10d1 10d2 10d3 10d4 10d5 10d6 10d7 
-10d8 10d9 10da 10db 10dc 10dd 10de 10df 
-10e0 10e1 10e2 10e3 10e4 10e5 10e6 10e7 
-10e8 10e9 10ea 10eb 10ec 10ed 10ee 10ef
-10f0 10f1 10f2 10f3 10f4 10f5 10f6   e7 
-  e8   e9   ea   eb   ec   ed   ee   ef 
-  f0   f1   f2   f3   f4   f5   f6   f7
-  f8   f9   fa   fb   fc   fd   fe   ff 
Index: xc/nls/XLC_LOCALE/tabgeorgian_ps
diff -u xc/nls/XLC_LOCALE/tabgeorgian_ps:1.2 xc/nls/XLC_LOCALE/tabgeorgian_ps:removed
--- xc/nls/XLC_LOCALE/tabgeorgian_ps:1.2	Sat Jan 29 13:58:23 2000
+++ xc/nls/XLC_LOCALE/tabgeorgian_ps	Mon Dec 18 14:27:17 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-0080 0081 201a 0192 201e 2026 2020 2021 
-02c6 2030 0160 2039 0152 008d 008e 008f 
-0090 2018 2019 201c 201d 2022 2013 2014 
-02dc 2122 0161 203a 0153 009d 009e 0178 
-a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af 
-b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf 
-10d0 10d1 10d2 10d3 10d4 10d5 10d6 10f1 
-10d7 10d8 10d9 10da 10db 10dc 10f2 10dd 
-10de 10df 10e0 10e1 10e2 10f3 10e3 10e4
-10e5 10e6 10e7 10e8 10e9 10ea 10eb 10ec
-10ed 10ee 10f4 10ef 10f0 10f5   e6   e7 
-  e8   e9   ea   eb   ec   ed   ee   ef 
-  f0   f1   f2   f3   f4   f5   f6   f7
-  f8   f9   fa   fb   fc   fd   fe   ff 
Index: xc/nls/XLC_LOCALE/tabibm_cp1133
diff -u xc/nls/XLC_LOCALE/tabibm_cp1133:1.2 xc/nls/XLC_LOCALE/tabibm_cp1133:removed
--- xc/nls/XLC_LOCALE/tabibm_cp1133:1.2	Sat Jan 29 13:58:23 2000
+++ xc/nls/XLC_LOCALE/tabibm_cp1133	Mon Dec 18 14:27:17 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 0e81 0e82 0e84 0e87 0e88 0eaa 0e8a 
-0e8d 0e94 0e95 0e96 0e97 0e99 0e9a 0e9b 
-0e9c 0e9d 0e9e 0e9f 0ea1 0ea2 0ea3 0ea5 
-0ea7 0eab 0ead 0eae   -1   -1   -1 0eaf 
-0eb0 0eb2 0eb3 0eb4 0eb5 0eb6 0eb7 0eb8 
-0eb9 0ebc 0eb1 0ebb 0ebd   -1   -1   -1 
-0ec0 0ec1 0ec2 0ec3 0ec4 0ec8 0ec9 0eca 
-0ecb 0ecc 0ecd 0ec6   -1 0edc 0edd 20ad 
-  -1   -1   -1   -1   -1   -1   -1   -1 
-  -1   -1   -1   -1   -1   -1   -1   -1 
-0ed0 0ed1 0ed2 0ed3 0ed4 0ed5 0ed6 0ed7 
-0ed8 0ed9   -1   -1 00a2 00ac 00a6   -1 
Index: xc/nls/XLC_LOCALE/tabkoi8_r
diff -u xc/nls/XLC_LOCALE/tabkoi8_r:1.1 xc/nls/XLC_LOCALE/tabkoi8_r:removed
--- xc/nls/XLC_LOCALE/tabkoi8_r:1.1	Sun Sep 27 07:06:15 1998
+++ xc/nls/XLC_LOCALE/tabkoi8_r	Mon Dec 18 14:27:17 2000
@@ -1,24 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-2500 2502 250c 2510 2514 2518 251c 2524
-252c 2534 253c 2580 2584 2588 258c 2590
-2591 2592 2593 2320 25a0 2219 221a 2248
-2264 2265 00a0 2321 00b0 00b2 00b7 00f7
-2550 2551 2552 0451 2553 2554 2555 2556
-2557 2558 2559 255a 255b 255c 255d 255e
-255f 2560 2561 0401 2562 2563 2564 2565
-2566 2567 2568 2569 256a 256b 256c 00a9
-044e 0430 0431 0446 0434 0435 0444 0433
-0445 0438 0439 043a 043b 043c 043d 043e
-043f 044f 0440 0441 0442 0443 0436 0432
-044c 044b 0437 0448 044d 0449 0447 044a
-042e 0410 0411 0426 0414 0415 0424 0413
-0425 0418 0419 041a 041b 041c 041d 041e
-041f 042f 0420 0421 0422 0423 0416 0412
-042c 042b 0417 0428 042d 0429 0427 042a
Index: xc/nls/XLC_LOCALE/tabkoi8_u
diff -u xc/nls/XLC_LOCALE/tabkoi8_u:1.1 xc/nls/XLC_LOCALE/tabkoi8_u:removed
--- xc/nls/XLC_LOCALE/tabkoi8_u:1.1	Sat May 29 22:28:03 1999
+++ xc/nls/XLC_LOCALE/tabkoi8_u	Mon Dec 18 14:27:18 2000
@@ -1,24 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-2500 2502 250c 2510 2514 2518 251c 2524
-252c 2534 253c 2580 2584 2588 258c 2590
-2591 2592 2593 2320 25a0 2219 221a 2248
-2264 2265 00a0 2321 00b0 00b2 00b7 00f7
-2550 2551 2552 0451 0454 2554 0456 0457
-2557 2558 2559 255a 255b 0491 255d 255e
-255f 2560 2561 0401 0404 2563 0406 0407
-2566 2567 2568 2569 256a 0490 256c 00a9
-044e 0430 0431 0446 0434 0435 0444 0433
-0445 0438 0439 043a 043b 043c 043d 043e
-043f 044f 0440 0441 0442 0443 0436 0432
-044c 044b 0437 0448 044d 0449 0447 044a
-042e 0410 0411 0426 0414 0415 0424 0413
-0425 0418 0419 041a 041b 041c 041d 041e
-041f 042f 0420 0421 0422 0423 0416 0412
-042c 042b 0417 0428 042d 0429 0427 042a
Index: xc/nls/XLC_LOCALE/tabmulelao_1
diff -u xc/nls/XLC_LOCALE/tabmulelao_1:1.2 xc/nls/XLC_LOCALE/tabmulelao_1:removed
--- xc/nls/XLC_LOCALE/tabmulelao_1:1.2	Sat Jan 29 13:58:23 2000
+++ xc/nls/XLC_LOCALE/tabmulelao_1	Mon Dec 18 14:27:18 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-00a0 0e81 0e82   -1 0e84   -1   -1 0e87 
-0e88   -1 0e8a   -1   -1 0e8d   -1   -1 
-  -1   -1   -1   -1 0e94 0e95 0e96 0e97 
-  -1 0e99 0e9a 0e9b 0e9c 0e9d 0e9e 0e9f 
-  -1 0ea1 0ea2 0ea3   -1 0ea5   -1 0ea7 
-  -1   -1 0eaa 0eab   -1 0ead 0eae 0eaf 
-0eb0 0eb1 0eb2 0eb3 0eb4 0eb5 0eb6 0eb7 
-0eb8 0eb9   -1 0ebb 0ebc 0ebd   -1   -1 
-0ec0 0ec1 0ec2 0ec3 0ec4   -1 0ec6   -1 
-0ec8 0ec9 0eca 0ecb 0ecc 0ecd   -1   -1 
-0ed0 0ed1 0ed2 0ed3 0ed4 0ed5 0ed6 0ed7 
-0ed8 0ed9   -1   -1 0edc 0edd   -1   -1 
Index: xc/nls/XLC_LOCALE/tabtcvn
diff -u xc/nls/XLC_LOCALE/tabtcvn:1.3 xc/nls/XLC_LOCALE/tabtcvn:removed
--- xc/nls/XLC_LOCALE/tabtcvn:1.3	Sat Jan 29 13:58:24 2000
+++ xc/nls/XLC_LOCALE/tabtcvn	Mon Dec 18 14:27:18 2000
@@ -1,22 +0,0 @@
-  00 00da 1ee4   03 1eea 1eec 1eee   07   08   09   0a   0b   0c   0d   0e   0f 
-  10 1ee8 1ef0 1ef2 1ef6 1ef8 00dd 1ef4   18   19   1a   1b   1c   1d   1e   1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-00c0 1ea2 00c3 00c1 1ea0 1eb6 1eac 00c8 1eba 1ebc 00c9 1eb8 1ec6 00cc 1ec8 0128 
-00cd 1eca 00d2 1ece 00d5 00d3 1ecc 1ed8 1edc 1ede 1ee0 1eda 1ee2 00d9 1ee6 0168 
-00a0 0102 00c2 00ca 00d4 01a0 01af 0110 
-0103 00e2 00ea 00f4 01a1 01b0 0111 1eb0 
-0300 0309 0303 0301 0323 00e0 1ea3 00e3 
-00e1 1ea1 1eb2 1eb1 1eb3 1eb5 1eaf 1eb4 
-1eae 1ea6 1ea8 1eaa 1ea4 1ec0 1eb7 1ea7 
-1ea9 1eab 1ea5 1ead 00e8 1ec2 1ebb 1ebd 
-00e9 1eb9 1ec1 1ec3 1ec5 1ebf 1ec7 00ec 
-1ec9 1ec4 1ebe 1ed2 0129 00ed 1ecb 00f2 
-1ed4 1ecf 00f5 00f3 1ecd 1ed3 1ed5 1ed7 
-1ed1 1ed9 1edd 1edf 1ee1 1edb 1ee3 00f9 
-1ed6 1ee7 0169 00fa 1ee5 1eeb 1eed 1eef 
-1ee9 1ef1 1ef3 1ef7 1ef9 00fd 1ef5 1ed0 
Index: xc/nls/XLC_LOCALE/tabtis620
diff -u xc/nls/XLC_LOCALE/tabtis620:1.2 xc/nls/XLC_LOCALE/tabtis620:removed
--- xc/nls/XLC_LOCALE/tabtis620:1.2	Sat Jan 29 13:58:24 2000
+++ xc/nls/XLC_LOCALE/tabtis620	Mon Dec 18 14:27:19 2000
@@ -1,22 +0,0 @@
-00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 
-90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f 
-  -1 0e01 0e02 0e03 0e04 0e05 0e06 0e07 
-0e08 0e09 0e0a 0e0b 0e0c 0e0d 0e0e 0e0f 
-0e10 0e11 0e12 0e13 0e14 0e15 0e16 0e17 
-0e18 0e19 0e1a 0e1b 0e1c 0e1d 0e1e 0e1f 
-0e20 0e21 0e22 0e23 0e24 0e25 0e26 0e27 
-0e28 0e29 0e2a 0e2b 0e2c 0e2d 0e2e 0e2f 
-0e30 0e31 0e32 0e33 0e34 0e35 0e36 0e37 
-0e38 0e39 0e3a   -1   -1   -1   -1 0e3f 
-0e40 0e41 0e42 0e43 0e44 0e45 0e46 0e47 
-0e48 0e49 0e4a 0e4b 0e4c 0e4d 0e4e 0e4f 
-0e50 0e51 0e52 0e53 0e54 0e55 0e56 0e57 
-0e58 0e59 0e5a 0e5b   -1   -1   -1   -1 
Index: xc/nls/XLC_LOCALE/tabviscii
diff -u xc/nls/XLC_LOCALE/tabviscii:1.2 xc/nls/XLC_LOCALE/tabviscii:removed
--- xc/nls/XLC_LOCALE/tabviscii:1.2	Sat Jan 29 13:58:24 2000
+++ xc/nls/XLC_LOCALE/tabviscii	Mon Dec 18 14:27:20 2000
@@ -1,24 +0,0 @@
-00 01 1eb2 03 04 1eb4 1eaa 07 08 09 0a 0b 0c 0d 0e 0f 
-10 11 12 13 1ef6 15 16 17 18 1ef8 1a 1b 1c 1d 1ef4 1f 
-20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
-30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
-40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
-50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
-60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
-70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 
-1ea0 1eae 1eb0 1eb6 1ea4 1ea6 1ea8 1eac
-1ebc 1eb8 1ebe 1ec0 1ec2 1ec4 1ec6 1ed0 
-1ed2 1ed4 1ed6 1ed8 1ee2 1eda 1edc 1ede
-1eca 1ece 1ecc 1ec8 1ee6 0168 1ee4 1ef2 
-00d5 1eaf 1eb1 1eb7 1ea5 1ea7 1ea9 1ead 
-1ebd 1eb9 1ebf 1ec1 1ec3 1ec5 1ec7 1ed1 
-1ed3 1ed5 1ed7 1ee0 01a0 1ed9 1edd 1edf 
-1ecb 1ef0 1ee8 1eea 1eec 01a1 1edb 01af 
-00c0 00c1 00c2 00c3 1ea2 0102 1eb3 1eb5 
-00c8 00c9 00ca 1eba 00cc 00cd 0128 1ef3 
-0110 1ee9 00d2 00d3 00d4 1ea1 1ef7 1eeb 
-1eed 00d9 00da 1ef9 1ef5 00dd 1ee1 01b0 
-00e0 00e1 00e2 00e3 1ea3 0103 1eef 1eab 
-00e8 00e9 00ea 1ebb 00ec 00ed 0129 1ec9 
-0111 1ef1 00f2 00f3 00f4 00f5 1ecf 1ecd 
-1ee5 00f9 00fa 0169 1ee7 00fd 1ee3 1eee 
Index: xc/nls/XLC_LOCALE/tatar-cyr
diff -u /dev/null xc/nls/XLC_LOCALE/tatar-cyr:1.2
--- /dev/null	Mon Dec 18 14:27:20 2000
+++ xc/nls/XLC_LOCALE/tatar-cyr	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,87 @@
+XCOMM  $TOG: tatar-cyr /main/1 1998/05/20 14:49:21 kaleb $
+XCOMM  XLocale Database Sample for tatar-cyr.
+XCOMM 
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/tatar-cyr,v 1.2 2000/12/01 17:43:03 dawes Exp $
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class 
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		TATAR-CYR:GL
+		substitute	ISO8859-1:GL
+		vertical_rotate	all
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset	{
+		name		TATAR-CYR:GR
+	}
+	font	{
+		primary		TATAR-CYR:GR
+	}
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	TATAR-CYR
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name		TATAR-CYR
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+force_convert_to_mb	True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding	TATAR-CYR:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding	TATAR-CYR:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/tscii-0
diff -u /dev/null xc/nls/XLC_LOCALE/tscii-0:1.2
--- /dev/null	Mon Dec 18 14:27:22 2000
+++ xc/nls/XLC_LOCALE/tscii-0	Fri Dec  1 12:43:03 2000
@@ -0,0 +1,80 @@
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/tscii-0,v 1.2 2000/12/01 17:43:03 dawes Exp $
+XCOMM  XLocale Database Sample for mulelao-1.
+XCOMM 
+
+XCOMM 
+XCOMM 	XLC_FONTSET category
+XCOMM 
+XLC_FONTSET
+XCOMM 	fs0 class (7 bit ASCII)
+fs0	{
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		TSCII-0:GL
+		substitute	ISO8859-1:GL
+	}
+}
+XCOMM 	fs1 class 
+fs1	{
+	charset         TSCII-0:GR
+	font            TSCII-0:GR
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	TSCII-0
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM 
+XCOMM 	XLC_XLOCALE category
+XCOMM 
+XLC_XLOCALE
+
+encoding_name           TSCII-0
+mb_cur_max		1
+state_depend_encoding	False
+#if WCHAR32
+wc_encoding_mask	\x30000000
+wc_shift_bits		7
+#else
+wc_encoding_mask	\x00008080
+wc_shift_bits		8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
+XCOMM 	cs0 class
+cs0	{
+	side		GL:Default
+	length		1
+	wc_encoding	\x00000000
+	ct_encoding     TSCII-0:GL; ISO8859-1:GL
+}
+
+
+XCOMM 	cs1 class
+cs1	{
+	side		GR:Default
+	length		1
+#if WCHAR32
+	wc_encoding	\x30000000
+#else
+	wc_encoding	\x00008080
+#endif
+	ct_encoding     TSCII-0:GR
+}
+
+END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/vi_VN.tcvn
diff -u xc/nls/XLC_LOCALE/vi_VN.tcvn:1.1 xc/nls/XLC_LOCALE/vi_VN.tcvn:1.2
--- xc/nls/XLC_LOCALE/vi_VN.tcvn:1.1	Sun Jun  6 10:06:02 1999
+++ xc/nls/XLC_LOCALE/vi_VN.tcvn	Fri Dec  1 12:43:03 2000
@@ -1,6 +1,6 @@
 XCOMM  XLocale Database Sample for vi_VN.TCVN
 XCOMM 
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/vi_VN.tcvn,v 1.1 1999/06/06 14:06:02 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/vi_VN.tcvn,v 1.2 2000/12/01 17:43:03 dawes Exp $
 
 XCOMM 
 XCOMM 	XLC_FONTSET category
@@ -8,8 +8,13 @@
 XLC_FONTSET
 XCOMM 	fs0 class (7 bit ASCII)
 fs0	{
-	charset		ISO8859-1:GL
-	font            TCVN-5712:GL; ISO8859-1:GL
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		TCVN-5712:GL
+		substitute	ISO8859-1:GL
+	}
 }
 XCOMM 	fs1 class 
 fs1	{
@@ -18,6 +23,19 @@
 }
 END XLC_FONTSET
 
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	TCVN-5712
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
 XCOMM 
 XCOMM 	XLC_XLOCALE category
 XCOMM 
@@ -34,6 +52,10 @@
 wc_shift_bits		8
 #endif
 
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
 XCOMM 	cs0 class
 cs0	{
 	side		GL:Default
@@ -52,7 +74,7 @@
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     TCVN-5712:GR; ISO8859-1:GR
+	ct_encoding     TCVN-5712:GR
 }
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/vi_VN.viscii
diff -u xc/nls/XLC_LOCALE/vi_VN.viscii:1.1 xc/nls/XLC_LOCALE/vi_VN.viscii:1.2
--- xc/nls/XLC_LOCALE/vi_VN.viscii:1.1	Sun Jun  6 10:06:02 1999
+++ xc/nls/XLC_LOCALE/vi_VN.viscii	Fri Dec  1 12:43:03 2000
@@ -1,6 +1,6 @@
 XCOMM  XLocale Database Sample for vi_VN.VISCII
 XCOMM 
-XCOMM  $XFree86: xc/nls/XLC_LOCALE/vi_VN.viscii,v 1.1 1999/06/06 14:06:02 dawes Exp $
+XCOMM  $XFree86: xc/nls/XLC_LOCALE/vi_VN.viscii,v 1.2 2000/12/01 17:43:03 dawes Exp $
 
 XCOMM 
 XCOMM 	XLC_FONTSET category
@@ -8,8 +8,13 @@
 XLC_FONTSET
 XCOMM 	fs0 class (7 bit ASCII)
 fs0	{
-	charset		ISO8859-1:GL
-	font            VISCII1.1-1:GL; ISO8859-1:GL
+	charset	{
+		name		ISO8859-1:GL
+	}
+	font	{
+		primary		VISCII1.1-1:GL
+		substitute	ISO8859-1:GL
+	}
 }
 XCOMM 	fs1 class 
 fs1	{
@@ -18,6 +23,19 @@
 }
 END XLC_FONTSET
 
+XCOMM
+XCOMM	XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0	{
+	charset_name	VISCII1.1-1
+	side		GR
+	length		1
+	string_encoding	False
+	sequence	\x1b%/1
+}
+END XLC_CHARSET_DEFINE
+
 XCOMM 
 XCOMM 	XLC_XLOCALE category
 XCOMM 
@@ -34,6 +52,10 @@
 wc_shift_bits		8
 #endif
 
+#ifndef X_LOCALE
+use_stdc_env		True
+#endif
+
 XCOMM 	cs0 class
 cs0	{
 	side		GL:Default
@@ -52,7 +74,7 @@
 #else
 	wc_encoding	\x00008080
 #endif
-	ct_encoding     VISCII1.1-1:GR; ISO8859-1:GR
+	ct_encoding     VISCII1.1-1:GR
 }
 
 END XLC_XLOCALE
Index: xc/nls/XLC_LOCALE/zh_TW.big5
diff -u xc/nls/XLC_LOCALE/zh_TW.big5:1.1 xc/nls/XLC_LOCALE/zh_TW.big5:1.2
--- xc/nls/XLC_LOCALE/zh_TW.big5:1.1	Sat Aug 28 05:00:41 1999
+++ xc/nls/XLC_LOCALE/zh_TW.big5	Fri Oct 27 14:30:57 2000
@@ -1,14 +1,14 @@
-#
-# (c) 1996, X11R6 L10N for Taiwan and Big5 Encoding Project
-#
-# modified for X11R6.3 by Hung-Chi Chu <hcchu@r350.ee.ntu.edu.tw> 1998/01/10
-#
-# $XFree86: xc/nls/XLC_LOCALE/zh_TW.big5,v 1.1 1999/08/28 09:00:41 dawes Exp $
-#
-#	XLC_FONTSET category
-#
+XCOMM
+XCOMM (c) 1996, X11R6 L10N for Taiwan and Big5 Encoding Project
+XCOMM
+XCOMM modified for X11R6.3 by Hung-Chi Chu <hcchu@r350.ee.ntu.edu.tw> 1998/01/10
+XCOMM
+XCOMM $XFree86: xc/nls/XLC_LOCALE/zh_TW.big5,v 1.2 2000/10/27 18:30:57 dawes Exp $
+XCOMM
+XCOMM	XLC_FONTSET category
+XCOMM
 XLC_FONTSET
-#       fs0 class (7 bit ASCII)
+XCOMM       fs0 class (7 bit ASCII)
 fs0     {
         charset {
                 name    ISO8859-1:GL
@@ -18,33 +18,36 @@
                 vertical_rotate all
         }
 }
-#       fs1 class
+XCOMM       fs1 class
 fs1     {
         charset {
                 name    BIG5-0:GLGR
         }
         font    {
                 primary BIG5-0:GLGR
+				substitute BIG5-0:GLGR
         }
 }
 END XLC_FONTSET
 
-#
-#	XLC_XLOCALE category
-#
+XCOMM
+XCOMM	XLC_XLOCALE category
+XCOMM
 XLC_XLOCALE
 
-encoding_name		zh_TW.big5
+encoding_name		zh_TW.Big5
 mb_cur_max		2
 state_depend_encoding	False
 
 wc_encoding_mask	\x00008000
 wc_shift_bits		8
 
-#use_stdc_env		False
-#force_convert_to_mb	True
+#ifndef X_LOCALE
+use_stdc_env		True
+force_convert_to_mb	True
+#endif
 
-#	cs0 class
+XCOMM	cs0 class
 cs0	{
 	side		GL:Default
 	length		1
@@ -52,7 +55,7 @@
 	ct_encoding	ISO8859-1:GL
 }
 
-#	cs1 class
+XCOMM	cs1 class
 cs1	{
 	side		none
 	length		2
Index: xc/programs/Imakefile
diff -u xc/programs/Imakefile:3.29 xc/programs/Imakefile:3.31
--- xc/programs/Imakefile:3.29	Thu Jun 15 16:49:59 2000
+++ xc/programs/Imakefile	Fri Sep 22 07:35:41 2000
@@ -2,7 +2,7 @@
 XCOMM
 XCOMM
 XCOMM
-XCOMM $XFree86: xc/programs/Imakefile,v 3.29 2000/06/15 20:49:59 dawes Exp $
+XCOMM $XFree86: xc/programs/Imakefile,v 3.31 2000/09/22 11:35:41 alanh Exp $
 #define IHaveSubdirs
 #define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
 
@@ -46,6 +46,9 @@
 #if BuildXF86VidModeExt
     XGAMMASRCDIR = xgamma
 #endif
+#if BuildXvExt
+    XVINFOSRCDIR = xvinfo
+#endif
      XHOSTSRCDIR = xhost
 #if BuildPlugin
        XRXSRCDIR = xrx
@@ -84,8 +87,9 @@
 	xrefresh $(XRXSRCDIR) xset \
 	xsetroot $(XSMSRCDIR) xstdcmap xsetmode xsetpointer \
 	$(XTERMSRCDIR) $(XVIDTUNESRCDIR) xwd xwininfo xwud \
-	$(XPMCLIENTDIRS) \
-	$(XSSRCDIR) $(XASSRCDIR) $(LBXPROXYSRCDIR) $(SCRIPTSDIR)
+	$(XPMCLIENTDIRS) $(XVINFOSRCDIR) \
+	$(XSSRCDIR) $(XASSRCDIR) $(LBXPROXYSRCDIR) $(SCRIPTSDIR) \
+	glxinfo
 #endif
 
 MakeSubdirs($(SUBDIRS))
Index: xc/programs/Xserver/Imakefile
diff -u xc/programs/Xserver/Imakefile:3.184 xc/programs/Xserver/Imakefile:3.205
--- xc/programs/Xserver/Imakefile:3.184	Fri Jun 16 20:03:10 2000
+++ xc/programs/Xserver/Imakefile	Mon Dec 11 15:29:31 2000
@@ -2,7 +2,7 @@
 /*
  * Server Master Makefile
  */
-XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.184 2000/06/17 00:03:10 martin Exp $
+XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.205 2000/12/11 20:29:31 dawes Exp $
 
 #ifndef InstallXserverSetUID
 #define InstallXserverSetUID NO
@@ -46,6 +46,8 @@
 #define FbPostFbLibs  $(FB) NoMfbPostFbLibs
 #define FBLibs PreFbLibs FbPostFbLibs
 
+#define MiExtLibs $(SHADOW)
+
 #define AllFBLibs PreFbLibs $(FB) $(CFB) PostFbLibs
 
 #if BuildPexExt
@@ -183,20 +185,24 @@
 XPFBLIBS = dix/LibraryTargetName(xpstubs)
 #endif
 
+#if BuildRender
+      RENDERDIR = render
+      RENDERLIB = $(RENDERDIR)/librender.a
+#endif
 #if DoLoadableServer
-     EXTENSIONS = $(OTHEREXTS) 
+     EXTENSIONS = $(OTHEREXTS) $(RENDERLIB)
    LOADABLEEXTS = $(PEXLIBS) $(XIEEXT) $(MISCEXT) $(DBEEXT) $(RECORDEXT) \
                   $(GLXEXT)
         MISCEXT = Xext/LibraryTargetName(ext)
       OTHEREXTS = Xext/LibraryTargetName(exts) $(XKBEXT) $(XINPUTEXT) \
                   $(LBXEXT) $(SITEEXTS)
 #else
-     EXTENSIONS = $(OTHEREXTS) $(PEXLIBS) $(GLXEXT)
+     EXTENSIONS = $(OTHEREXTS) $(PEXLIBS) $(GLXEXT) $(RENDERLIB)
       OTHEREXTS = Xext/LibraryTargetName(ext) $(XKBEXT) $(XINPUTEXT) \
                   $(XIEEXT) $(LBXEXT) $(DBEEXT) $(RECORDEXT) $(SITEEXTS)
 #endif
         EXTDIRS = Xext $(XKBDIR) $(XIDIR) $(XIEDIR) $(PEXDIR) $(GLXDIR) \
-                  $(LBXDIRS) $(DBEDIR) $(RECORDDIR) $(SITEEXTDIRS)
+                  $(LBXDIRS) $(DBEDIR) $(RECORDDIR) $(SITEEXTDIRS) $(RENDERDIR)
          XAULIB = $(XAUTHSRC)/LibraryTargetName(Xau)
        XDMCPLIB = $(XDMCPLIBSRC)/LibraryTargetName(Xdmcp)
 #if BuildLBX || GzipFontCompression
@@ -220,6 +226,7 @@
 		  cfb24/ModuleLibraryTargetName(cfb24)
           CFB32 = cfb/ModuleLibraryTargetName(cfb) \
 		  cfb32/ModuleLibraryTargetName(cfb32)
+         SHADOW = miext/shadow/ModuleLibraryTargetName(shadow)
 #else 
             MFB = mfb/LibraryTargetName(mfb)
              FB = fb/LibraryTargetName(fb)
@@ -230,6 +237,7 @@
           CFB16 = cfb/LibraryTargetName(cfb) cfb16/LibraryTargetName(cfb16)
           CFB24 = cfb/LibraryTargetName(cfb) cfb24/LibraryTargetName(cfb24)
           CFB32 = cfb/LibraryTargetName(cfb) cfb32/LibraryTargetName(cfb32)
+         SHADOW = miext/shadow/LibraryTargetName(shadow)
 #endif
 #if BuildLowMem
          LMFCFB = lmfcfb/LibraryTargetName(cfb)
@@ -239,8 +247,12 @@
             DIX = dix/LibraryTargetName(dix)
        FONTBASE = $(FONTLIBSRC)/fontbase.o \
 		  $(FONTLIBSRC)/LibraryTargetName(fontbase)
-           FONT = $(XFONTLIB) $(XPFBLIBS)
-       FONTLIBS = $(LDPRELIB) $(FONT)
+#if XserverStaticFontLib
+           FONT = $(FONTLIBSRC)/LibraryTargetName(Xfont)
+#else
+           FONT = $(LDPRELIB) $(XFONTLIB)
+#endif
+       FONTLIBS = $(FONT) $(XPFBLIBS)
 #if UsbMouseSupport 
 #if !HasLibUsb
             USB = $(XF86OSSRC)/bsd/libusb/LibraryTargetName(usb)
@@ -251,12 +263,14 @@
 #ifdef ServerExtraSysLibs
    EXTRASYSLIBS = ServerExtraSysLibs
 #endif
-#if SystemV4 || defined(SGIArchitecture) || UseRgbTxt
-        SYSLIBS = $(ZLIB) MathLibrary Krb5Libraries $(USB) $(EXTRASYSLIBS)
-#else
-        SYSLIBS = $(ZLIB) MathLibrary Krb5Libraries DBMLibrary $(USB) \
-	$(EXTRASYSLIBS)
+#if HasPam && HasPamMisc
+        PAMLIBS = PamLibraries PamMiscLibraries
+#endif
+#if !(SystemV4 || defined(SGIArchitecture) || UseRgbTxt)
+       DBMLIBS = DBMLibrary
 #endif
+        SYSLIBS = $(ZLIB) MathLibrary Krb5Libraries $(DBMLIBS) $(USB) \
+	$(PAMLIBS) $(EXTRASYSLIBS)
            CBRT = mi/LibraryTargetName(cbrt)
         STDDIRS = include dix os mi $(XPDDXDIR) $(EXTDIRS)
 
@@ -527,15 +541,21 @@
 #if XF86Server
 XF86SERVER = XFree86
 #endif
-#if XnestServer && !MakeDllModules
+#if XnestServer
 XNEST = Xnest
 #endif
-#if XVirtualFramebufferServer && !MakeDllModules
+#if XVirtualFramebufferServer
 XVFB = Xvfb
 #endif
-#if defined(XF86Server) || (!MakeDllModules && (defined(XnestServer) || defined(XVirtualFramebufferServer)))
-MakeMutex($(XF86SERVER) $(XNEST) $(XVFB))
+#if XWinServer && !MakeDllModules
+XWIN = XWin
 #endif
+#if defined(XF86Server) || \
+    defined(XnestServer) || \
+    defined(XVirtualFramebufferServer) || \
+    (!MakeDllModules && defined(XWinServer))
+MakeMutex($(XF86SERVER) $(XNEST) $(XVFB) $(XWIN))
+#endif
 MakeMutex($(STDDIRS) mfb fb cfb cfb16 cfb24 cfb32)
 #endif
 
@@ -550,11 +570,12 @@
 CFB16DIR = cfb16
 CFB24DIR = cfb24
 CFB32DIR = cfb32
+SHADOWDIR = miext/shadow
 #if XF86AFB
 AFBDIR = afb
 #endif
 DDXDIR1  = hw/xfree86
-XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) $(AFBDIR) $(DDXDIR1) $(DEPDIRS)
+XF86SERVERSUBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) $(AFBDIR) $(SHADOWDIR) $(DDXDIR1) $(DEPDIRS)
 XF86INIT   = $(XF86COMSRC)/xf86Init.o $(XF86COMSRC)/xf86IniExt.o
 XF86COMLIB = $(XF86COMSRC)/LibraryTargetName(xf86)
 XF86PARSLIB= $(XF86PARSERSRC)/LibraryTargetName(xf86config)
@@ -575,6 +596,9 @@
 #if XF4Bpp
 XF4BPPLIB = $(XF86SRC)/xf4bpp/LibraryTargetName(xf4bpp)
 #endif
+#if XF8_32Wid
+XF8_32WIDLIB = $(XF86SRC)/xf8_32wid/LibraryTargetName(xf8_32wid)
+#endif
 #if XF8_32Bpp
 XF8_32BPPLIB = $(XF86SRC)/xf8_32bpp/LibraryTargetName(xf8_32bpp)
 #endif
@@ -600,6 +624,9 @@
 #if XF86DDC
 XF86DDCLIB = $(XF86SRC)/ddc/LibraryTargetName(ddc)
 #endif
+#if XF86VBE
+XF86VBELIB = $(XF86OSSRC)/vbe/vbe.o
+#endif
 #if XF86RAC
 XF86RACLIB = $(XF86SRC)/rac/LibraryTargetName(rac)
 #endif
@@ -613,29 +640,29 @@
 XF86DRVOBJS = $(XF86SRC)/drivers/drvConf.o
 XF86DRVLIBS = $(XF86DRIVERLIB) $(XF86RAMDACLIB) $(XF86DDCLIB) $(XF86I2CLIB) \
               $(XF86XAALIB) $(XF86VGAHWLIB) $(XF86FBDEVHWLIB) \
-              $(XF8_32BPPLIB) $(XF8_16BPPLIB) $(XF24_32BPPLIB) \
+	      $(XF8_32WIDLIB) $(XF8_32BPPLIB) $(XF86VBELIB) \
+	      $(XF8_16BPPLIB) $(XF24_32BPPLIB) \
 	      $(XF4BPPLIB) $(XF1BPPLIB) $(XFSHADOWFBLIB) $(AFBLIB)
 XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o
 XF86IDRVLIBS = $(XF86IDRIVERLIB)
 XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci)
 XF86LIBS  = $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) $(XF86PARSLIB) \
-	    $(XF86OSLIB) $(XF86INT10LIB) $(XF86DDCLIB)
+	    $(XF86OSLIB) $(XF86INT10LIB)
 #else
 XF86LIBS  = $(XF86INIT) $(XF86COMLIB) $(XF86PARSLIB) $(XF86OSLIB) 
 #endif
 #if DoLoadableServer
 XF86LOADERLIB = $(XF86SRC)/loader/LibraryTargetName(loader)
-XF86MAINLIBS = PreFbLibsNoFont $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
+XF86MAINLIBS = MiExtLibs PreFbLibsNoFont $(FONTBASE) $(OTHEREXTS) $(XF86COMLIB) \
 	       NoMfbPostFbLibs
 XF86SERVERSYSLIBS = $(SYSLIBS) $(LIBDL) $(LIBREGEX)
 #else
-XF86MAINLIBS = AllFBLibs $(XF86COMLIB) $(MI)
+XF86MAINLIBS = MiExtLibs AllFBLibs $(XF86COMLIB) $(MI)
 XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX)
 #endif
 XF86SERVEROBJS = $(XF86DRVOBJS) $(XF86IDRVOBJS)
 XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \
-		 $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \
-		 $(XF86DDCLIB)
+		 $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB)
 #if HasParallelMake
 MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS))
 #endif
@@ -652,6 +679,7 @@
 #endif
 #endif        /* XF86Server */
 
+#ifdef KDriveXServer
 XCOMM
 XCOMM Tiny X server section
 XCOMM
@@ -671,13 +699,14 @@
        PSEUDO8 = $(KDRIVE)/pseudo8/LibraryTargetName(pseudo8)
     PSEUDO8DIR = $(KDRIVE)/pseudo8
 #endif
+     SHADOWDIR = miext/shadow
             KD = $(KDRIVE)/LibraryTargetName(kdrive)
        KDFBDEV = $(KDRIVE)/fbdev/LibraryTargetName(fbdev)
-       
 
+
 #define StdKdDirs $(KDRIVE) $(KDOSDIR) $(PSEUDO8DIR) fb $(DEPDIRS)
 #define StdKdSysLibs $(FONTLIBS) $(SYSLIBS)
-#define KdLibs $(KD) $(KDOS) $(PSEUDO8)
+#define KdLibs $(KD) $(KDOS) $(PSEUDO8) MiExtLibs $(RENDERLIB) 
 
 #if XfbdevServer
 XCOMM
@@ -689,7 +718,9 @@
        
       KDDIRS = StdKdDirs
 
-   FBDEVDIRS = $(STDDIRS) $(KDDIRS) $(FBDEVDIR)
+     SHADOWDIR = miext/shadow
+     
+   FBDEVDIRS = $(STDDIRS) $(KDDIRS) $(FBDEVDIR) $(SHADOWDIR)
    
    FBDEVLIBS = PreFbLibs $(FBDEV) KdLibs FbPostFbLibs
 FBDEVSYSLIBS = StdKdSysLibs
@@ -761,14 +792,17 @@
 
       FBDEVDIR = $(KDRIVE)/fbdev
          FBDEV = $(FBDEVDIR)/LibraryTargetName(fbdev)
+       VESADIR = $(KDRIVE)/vesa
+          VESA = $(VESADIR)/LibraryTargetName(vesa)
+     SHADOWDIR = miext/shadow
     TRIDENTDIR = $(KDRIVE)/trident
        TRIDENT = $(TRIDENTDIR)/LibraryTargetName(trident)
 
         KDDIRS = StdKdDirs
   
-   TRIDENTDIRS = $(STDDIRS) $(KDDIRS) $(FBDEVDIR) $(TRIDENTDIR)
+   TRIDENTDIRS = $(STDDIRS) $(KDDIRS) $(FBDEVDIR) $(VESADIR) $(SHADOWDIR) $(TRIDENTDIR)
    
-   TRIDENTLIBS = PreFbLibs $(TRIDENT) $(FBDEV) KdLibs FbPostFbLibs
+   TRIDENTLIBS = PreFbLibs $(TRIDENT) $(FBDEV) $(VESA) KdLibs FbPostFbLibs
 TRIDENTSYSLIBS = StdKdSysLibs
 
 #if HasParallelMake
@@ -886,10 +920,38 @@
 ServerTarget(Xitsy,$(ITSYDIRS),$(ITSYOBJS),$(ITSYLIBS),$(ITSYSYSLIBS))
 #endif /* XItsyServer */
 
+#if XvesaServer
+XCOMM
+XCOMM server with vesa driver only based on Keith's server
+XCOMM
+
+    VESADIR = $(KDRIVE)/vesa
+       VESA = $(VESADIR)/LibraryTargetName(vesa)
+
+      KDDIRS = StdKdDirs
+
+   SHADOWDIR = miext/shadow
+
+    VESADIRS = $(STDDIRS) $(KDDIRS) $(VESADIR) $(SHADOWDIR)
+
+   VESALIBS = PreFbLibs $(VESA) KdLibs FbPostFbLibs
+VESASYSLIBS = StdKdSysLibs
+
+#if HasParallelMake
+MakeMutex($(VESADIRS) $(VESAOBJS) $(VESALIBS) $(VESASYSLIBS))
+#endif
+#if ForceServerRemake
+$(VESAOBJS) $(XVESA) $(VESALIBS) $(VESASYSLIBS):: $(VESADIRS)
+	@if [ -f $@ ]; then touch $@; fi
+#endif
+ServerTarget(Xvesa,$(VESADIRS),$(VESAOBJS),$(VESALIBS),$(VESASYSLIBS))
+#endif /* XvesaServer */
+
 KDRIVEDIRS=$(KDDIRS) $(FBDEVDIR) $(SAVAGEDIR) $(TRIDENTDIR) $(SIS530DIR) \
-	$(TRIODIR) $(TS300DIR) $(ITSYDIR) $(IGSDIR)
+	$(TRIODIR) $(TS300DIR) $(ITSYDIR) $(IGSDIR) $(VESADIR)
+#endif	/* KDriveXServer */
 
-#if XprtServer && !MakeDllModules
+#if XprtServer
 XCOMM
 XCOMM Print Server
 XCOMM
@@ -922,7 +984,7 @@
 ServerTarget(Xprt,$(XPSUBDIRS),$(XPOBJS),$(XPLIBS) $(LOADABLEEXTS) $(LIBCWRAPPER),$(XPSYSLIBS))
 #endif	/* XprtServer */
 
-#if XnestServer && !MakeDllModules
+#if XnestServer
 XCOMM
 XCOMM Server with Xlib-based ddx
 XCOMM
@@ -971,34 +1033,31 @@
 #endif /* XnonServer */
 
 
-#if XVirtualFramebufferServer && !MakeDllModules
+#if XVirtualFramebufferServer
 XCOMM
 XCOMM server with Virtual (malloced) framebuffer
 XCOMM
 MFBDIR   = mfb
-CFB8DIR  = cfb
-CFB16DIR = cfb16
-CFB24DIR = cfb24
-CFB32DIR = cfb32
-#ifndef Win32Architecture
-XVFBDDXDIR = hw/vfb
-#else
+FBDIR  = fb
+#if defined(Win32Architecture)
 XVFBDDXDIR = hw
+#else
+XVFBDDXDIR = hw/vfb
 #endif
-XVFBDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) $(XVFBDDXDIR) $(DEPDIRS)
+XVFBDIRS = $(STDDIRS) $(MFBDIR) $(FBDIR) $(XVFBDDXDIR) $(DEPDIRS)
 #ifndef Win32Architecture
 #if BuildDPMS
-XVFBDPMSSTUBOBJS = hw/vfb/dpmsstubs.o
+XVFBDPMSSTUBOBJS = $(XVFBDDXDIR)/dpmsstubs.o
 #endif
-XVFBOBJS = hw/vfb/stubs.o hw/vfb/miinitext.o $(XVFBDPMSSTUBOBJS)
+XVFBOBJS = $(XVFBDDXDIR)/stubs.o $(XVFBDDXDIR)/miinitext.o $(XVFBDPMSSTUBOBJS)
 #else
 XVFBOBJS = dix/main.o hw/vfb/stubs.o hw/vfb/miinitext.o
 #endif
-XVFB = hw/vfb/LibraryTargetName(vfb)
+XVFB = $(XVFBDDXDIR)/LibraryTargetName(vfb)
 #if DoLoadableServer
-XVFBLIBS = PreFbLibs $(XVFB) $(CFB) PostFbLibs $(MI)
+XVFBLIBS = PreFbLibs $(XVFB) $(FB) PostFbLibs $(MI)
 #else
-XVFBLIBS = PreFbLibs $(XVFB) $(CFB) PostFbLibs $(XF86OSLIB) $(MI)
+XVFBLIBS = PreFbLibs $(XVFB) $(FB) PostFbLibs $(XF86OSLIB) $(MI)
 #endif
 XVFBSYSLIBS = $(FONTLIBS) $(SYSLIBS)
 #if HasParallelMake
@@ -1013,11 +1072,69 @@
 #endif /* XVirtualFramebufferServer */
 
 
+#if XWinServer
+XCOMM
+XCOMM server with DirectX framebuffer for Windows
+XCOMM
+MFBDIR   = mfb
+CFB8DIR  = cfb
+CFB16DIR = cfb16
+CFB24DIR = cfb24
+CFB32DIR = cfb32
+XWINDDXDIR = hw/xwin
+DDXDIR2 = $(XWINDDXDIR)
+XWINDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) $(XWINDDXDIR) $(DEPDIRS)
+#if BuildDPMS
+XWINOBJS = hw/xwin/InitInput.o hw/xwin/InitOutput.o hw/xwin/stubs.o hw/xwin/directx.o hw/xwin/dpmsstubs.o dix/main.o
+#else
+XWINOBJS = hw/xwin/InitInput.o hw/xwin/InitOutput.o hw/xwin/stubs.o hw/xwin/directx.o dix/main.o
+#endif
+XWIN = hw/xwin/LibraryTargetName(XWin)
+XWINLIBS = PreFbLibs $(XWIN) $(CFB) PostFbLibs $(MI) $(SURFLIB) 
+XWINSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(XWINDIRS) $(XWINOBJS) $(XWIN) $(XWINLIBS) $(XWINSYSLIBS))
+#endif
+#if ForceServerRemake
+$(XWINOBJS) $(XWIN) $(XWINLIBS) $(XWINSYSLIBS):: $(XWINDIRS)
+	@if [ -f $@ ]; then touch $@; fi
+#endif
+ServerTarget(XWin,$(XWINDIRS),$(XWINOBJS), \
+	$(XWINLIBS) $(LOADABLEEXTS) $(LIBCWRAPPER),$(XWINSYSLIBS)) 
+
+#ifndef ServerToInstall
+#define ServerToInstall XWin
+#endif
+#endif /* XWinServer */
+
+#if XDarwinServer 
+XCOMM
+XCOMM X Darwin server for Mac OS X / Darwin
+XCOMM
+MFBDIR  = mfb  /* mfb is needed for font stuff, even though we don't support a 1bpp screen */
+CFB8DIR = cfb
+CFB16DIR = cfb16
+CFB32DIR = cfb32
+DDXDIR1 = hw/darwin
+DARWINDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DDXDIR1) $(DEPDIRS)
+DARWINOBJS = 
+DARWINLIBS = PreFbLibs hw/darwin/libdarwin.a $(CFB16) $(CFB32) $(CFB8) PostFbLibs ../../lib/font/libXfont.a ../../lib/font/stubs/libfntstubs.a
+
+XCOMM we need extra link flags for IOKit stuff
+EXTRA_LOAD_FLAGS = -framework IOKit
+SetUIDServerTarget(Xdarwin,$(DARWINDIRS),$(DARWINOBJS),$(DARWINLIBS),$(SYSLIBS))
+
+#define ServerToInstall Xdarwin
+
+#endif /* XDarwinServer */
+
+
 CFBDIRS = $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR)
+MIEXTDIRS = $(SHADOWDIR)
 IPLANDIRS = $(IPLAN2P2DIR) $(IPLAN2P4DIR) $(IPLAN2P8DIR)
 DDXDIRS = $(DDXDIR1) $(DDXDIR2) $(DDXDIR3) $(XVFBDDXDIR) $(XNESTDDXDIR)
 SUBDIRS = $(STDDIRS) $(MFBDIR) $(CFBDIRS) $(IPLANDIRS) $(ILBMDIR) $(AFBDIR) \
-          $(LMFCFBDIR) $(DDXDIRS) $(FBDIR) $(KDRIVEDIRS)
+          $(LMFCFBDIR) $(DDXDIRS) $(FBDIR) $(KDRIVEDIRS) $(MIEXTDIRS)
 
 #if defined(ServerToInstall) && !defined(OS2Architecture) && !defined(QNX4Architecture)
 install::
@@ -1032,4 +1149,5 @@
 
 ForceSubdirs($(DEPDIRS) $(SUBDIRS))
 
+CppManTarget(Xserver,)
 InstallManPage(Xserver,$(MANDIR))
Index: xc/programs/Xserver/Xserver.cpp
diff -u /dev/null xc/programs/Xserver/Xserver.cpp:1.1
--- /dev/null	Mon Dec 18 14:27:25 2000
+++ xc/programs/Xserver/Xserver.cpp	Mon Dec 11 15:29:32 2000
@@ -0,0 +1,698 @@
+.\" $TOG: Xserver.man /main/68 1998/02/09 14:12:35 kaleb $
+.\" Copyright 1984 - 1991, 1993, 1994, 1998  The Open Group
+.\" 
+.\" All Rights Reserved.
+.\" 
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\" 
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\" 
+.\" Except as contained in this notice, the name of The Open Group shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from The Open Group.
+.\" $XFree86: xc/programs/Xserver/Xserver.cpp,v 1.1 2000/12/11 20:29:32 dawes Exp $
+.TH XSERVER 1 "Release 6.4"  "X Version 11"
+.SH NAME
+Xserver \- X Window System display server
+.SH SYNOPSIS
+.B X
+[option ...]
+.SH DESCRIPTION
+.I X
+is the generic name for the X Window System display server.  It is
+frequently a link or a copy of the appropriate server binary for
+driving the most frequently used server on a given machine.
+.SH "STARTING THE SERVER"
+The X server is usually started from the X Display Manager program \fIxdm(1)\fP.
+This utility is run from the system boot files and takes care of keeping
+the server running, prompting for usernames and passwords, and starting up
+the user sessions.
+.PP
+Installations that run more than one window system may need to use the
+\fIxinit(1)\fP utility instead of \fIxdm\fP.  However, \fIxinit\fP is
+to be considered a tool for building startup scripts and is not
+intended for use by end users.  Site administrators are \fBstrongly\fP
+urged to use \fIxdm\fP, or build other interfaces for novice users.
+.PP
+The X server may also be started directly by the user, though this
+method is usually reserved for testing and is not recommended for
+normal operation.  On some platforms, the user must have special
+permission to start the X server, often because access to certain
+devices (e.g. /dev/mouse) is restricted.
+.PP
+When the X server starts up, it typically takes over the display.  If
+you are running on a workstation whose console is the display, you may
+not be able to log into the console while the server is running.
+.SH OPTIONS
+All of the X servers accept the following command line options:
+.TP 8
+.B :\fIdisplaynumber\fP
+the X server runs as the given \fIdisplaynumber\fP, which by default is 0.
+If multiple X servers are to run simultaneously on a host, each must have
+a unique display number.  See the DISPLAY
+NAMES section of the \fIX(1)\fP manual page to learn how to specify
+which display number clients should try to use.
+.TP 8
+.B \-a \fInumber\fP
+sets pointer acceleration (i.e. the ratio of how much is reported to how much
+the user actually moved the pointer).
+.TP 8
+.B \-ac
+disables host-based access control mechanisms.  Enables access by any host,
+and permits any host to modify the access control list.
+Use with extreme caution.
+This option exists primarily for running test suites remotely.
+.TP 8
+.B \-audit \fIlevel\fP
+Sets the audit trail level.  The default level is 1, meaning only connection
+rejections are reported.  Level 2 additionally reports all successful
+connections and disconnects.  Level 4 enables messages from the
+SECURITY extension, if present, including generation and revocation of
+authorizations and violations of the security policy.
+Level 0 turns off the audit trail.
+Audit lines are sent as standard error output.
+.TP 8
+.B \-auth \fIauthorization-file\fP
+Specifies a file which contains a collection of authorization records used
+to authenticate access.  See also the \fIxdm\fP and \fIXsecurity\fP manual
+pages.
+.TP 8
+.B bc
+disables certain kinds of error checking, for bug compatibility with
+previous releases (e.g., to work around bugs in R2 and R3 xterms and toolkits).
+Deprecated.
+.TP 8
+.B \-bs
+disables backing store support on all screens.
+.TP 8
+.B \-c
+turns off key-click.
+.TP 8
+.B c \fIvolume\fP
+sets key-click volume (allowable range: 0-100).
+.TP 8
+.B \-cc \fIclass\fP
+sets the visual class for the root window of color screens.
+The class numbers are as specified in the X protocol.
+Not obeyed by all servers.
+.TP 8
+.B \-co \fIfilename\fP
+sets name of RGB color database.  The default is <XRoot>/lib/X11/rgb,
+where <XRoot> refers to the root of the X11 install tree.
+.ig
+.TP 8
+.B \-config \fIfilename\fP
+reads more options from the given file.  Options in the file may be separated
+by newlines if desired.  If a '#' character appears on a line, all characters
+between it and the next newline are ignored, providing a simple commenting
+facility.  The \fB\-config\fP option itself may appear in the file.
+.BR NOTE :
+This option is disabled when the Xserver is run with an effective uid
+different from the user's real uid.
+..
+.TP 8
+.B \-core
+causes the server to generate a core dump on fatal errors.
+.TP 8
+.B \-dpi \fIresolution\fP
+sets the resolution of the screen, in dots per inch.
+To be used when the server cannot determine the screen size from the hardware.
+.TP 8
+.B \-deferglyphs \fIwhichfonts\fP
+specifies the types of fonts for which the server should attempt to use
+deferred glyph loading.  \fIwhichfonts\fP can be all (all fonts),
+none (no fonts), or 16 (16 bit fonts only).
+.TP 8
+.B \-f \fIvolume\fP
+sets feep (bell) volume (allowable range: 0-100).
+.TP 8
+.B \-fc \fIcursorFont\fP
+sets default cursor font.
+.TP 8
+.B \-fn \fIfont\fP
+sets the default font.
+.TP 8
+.B \-fp \fIfontPath\fP
+sets the search path for fonts.  This path is a comma separated list
+of directories which the X server searches for font databases.
+.TP 8
+.B \-help
+prints a usage message.
+.TP 8
+.B \-I
+causes all remaining command line arguments to be ignored.
+.TP 8
+.B \-kb
+disables the XKEYBOARD extension if present.
+.TP 8
+.B \-nolisten \fItrans-type\fP
+Disable a transport type.  For example, TCP/IP connections can be disabled
+with
+.B \-nolisten tcp
+.TP 8
+.B \-noreset
+prevents a server reset when the last client connection is closed.  This
+overrides a previous
+.B \-terminate
+command line option.
+.TP 8
+.B \-p \fIminutes\fP
+sets screen-saver pattern cycle time in minutes.
+.TP 8
+.B \-pn
+permits the server to continue running if it fails to establish all of
+its well-known sockets (connection points for clients), but
+establishes at least one.
+.TP 8
+.B \-r
+turns off auto-repeat.
+.TP 8
+.B r
+turns on auto-repeat.
+.TP 8
+.B \-s \fIminutes\fP
+sets screen-saver timeout time in minutes.
+.TP 8
+.B \-su
+disables save under support on all screens.
+.TP 8
+.B \-t \fInumber\fP
+sets pointer acceleration threshold in pixels (i.e. after how many pixels
+pointer acceleration should take effect).
+.TP 8
+.B \-terminate
+causes the server to terminate at server reset, instead of continuing to run.
+This overrides a previous
+.B \-noreset
+command line option.
+.TP 8
+.B \-to \fIseconds\fP
+sets default connection timeout in seconds.
+.TP 8
+.B \-tst
+disables all testing extensions (e.g., XTEST, XTrap, XTestExtension1, RECORD).
+.TP 8
+.B tty\fIxx\fP
+ignored, for servers started the ancient way (from init).
+.TP 8
+.B v
+sets video-off screen-saver preference.
+.TP 8
+.B \-v
+sets video-on screen-saver preference.
+.TP 8
+.B \-wm
+forces the default backing-store of all windows to be WhenMapped.  This
+is a backdoor way of getting backing-store to apply to all windows.
+Although all mapped windows will have backing store, the backing store
+attribute value reported by the server for a window will be the last
+value established by a client.  If it has never been set by a client,
+the server will report the default value, NotUseful.  This behavior is
+required by the X protocol, which allows the server to exceed the
+client's backing store expectations but does not provide a way to tell
+the client that it is doing so.
+.TP 8
+.B \-x \fIextension\fP
+loads the specified extension at init.
+This is a no-op for most implementations.
+.TP 8
+.B [+-]xinerama
+enable(+) or disable(-) XINERAMA extension. Default is disabled.
+.SH SERVER DEPENDENT OPTIONS
+Some X servers accept the following options:
+.TP 8
+.B \-ld \fIkilobytes\fP
+sets the data space limit of the server to the specified number of kilobytes.
+A value of zero makes the data size as large as possible.  The default value
+of \-1 leaves the data space limit unchanged.
+.TP 8
+.B \-lf \fIfiles\fP
+sets the number-of-open-files limit of the server to the specified number.
+A value of zero makes the limit as large as possible.  The default value
+of \-1 leaves the limit unchanged.
+.TP 8
+.B \-ls \fIkilobytes\fP
+sets the stack space limit of the server to the specified number of kilobytes.
+A value of zero makes the stack size as large as possible.  The default value
+of \-1 leaves the stack space limit unchanged.
+.TP 8
+.B \-logo
+turns on the X Window System logo display in the screen-saver.
+There is currently no way to change this from a client.
+.TP 8
+.B nologo
+turns off the X Window System logo display in the screen-saver.
+There is currently no way to change this from a client.
+.SH XDMCP OPTIONS
+X servers that support XDMCP have the following options.
+See the \fIX Display Manager Control Protocol\fP specification for more
+information.
+.TP 8
+.B \-query \fIhost-name\fP
+Enable XDMCP and send Query packets to the specified host.
+.TP 8
+.B \-broadcast
+Enable XDMCP and broadcast BroadcastQuery packets to the network.  The
+first responding display manager will be chosen for the session.
+.TP 8
+.B \-indirect \fIhost-name\fP
+Enable XDMCP and send IndirectQuery packets to the specified host.
+.TP 8
+.B \-port \fIport-num\fP
+Use an alternate port number for XDMCP packets.  Must be specified before
+any \-query, \-broadcast or \-indirect options.
+.TP 8
+.B \-once
+Causes the server to terminate (rather than reset) when the XDMCP session ends.
+.TP 8
+.B \-class \fIdisplay-class\fP
+XDMCP has an additional display qualifier used in resource lookup for
+display-specific options.  This option sets that value, by default it 
+is "MIT-Unspecified" (not a very useful value).
+.TP 8
+.B \-cookie \fIxdm-auth-bits\fP
+When testing XDM-AUTHENTICATION-1, a private key is shared between the
+server and the manager.  This option sets the value of that private
+data (not that it is very private, being on the command line!).
+.TP 8
+.B \-displayID \fIdisplay-id\fP
+Yet another XDMCP specific value, this one allows the display manager to
+identify each display so that it can locate the shared key.
+.SH XKEYBOARD OPTIONS
+X servers that support the XKEYBOARD extension accept the following options:
+.TP 8
+.B \-xkbdir \fIdirectory\fP
+base directory for keyboard layout files
+.TP 8
+.B \-xkbmap \fIfilename\fP
+keyboard description to load on startup
+.TP 8
+.B [+-]accessx
+enable(+) or disable(-) AccessX key sequences
+.TP 8
+.B \-ar1 \fImilliseconds\fP
+sets the length of time in milliseconds that a key must be depressed before
+autorepeat starts
+.TP 8
+.B \-ar2 \fImilliseconds\fP
+sets the length of time in milliseconds that should elapse between
+autorepeat-generated keystrokes
+.PP
+Many servers also have device-specific command line options.  See the
+manual pages for the individual servers for more details.
+.SH SECURITY EXTENSION OPTIONS
+X servers that support the SECURITY extension accept the following option:
+.TP 8
+.B \-sp \fIfilename\fP
+causes
+the server to attempt to read and interpret filename as a security policy
+file with the format described below.  The file is read at
+server startup and reread at each server reset.
+.PP
+The syntax of the security policy file is as follows.
+Notation: "*" means zero or more occurrences of the preceding element,
+and "+" means one or more occurrences.  To interpret <foo/bar>, ignore
+the text after the /; it is used to distinguish between instances of
+<foo> in the next section.
+.PP
+.nf
+<policy file> ::= <version line> <other line>*
+
+<version line> ::= <string/v> '\en'
+
+<other line > ::= <comment> | <access rule> | <site policy> | <blank line>
+
+<comment> ::= # <not newline>* '\en'
+
+<blank line> ::= <space> '\en'
+
+<site policy> ::= sitepolicy <string/sp> '\en'
+
+<access rule> ::= property <property/ar> <window> <perms> '\en'
+
+<property> ::= <string>
+
+<window> ::= any | root | <required property>
+
+<required property> ::= <property/rp> | <property with value>
+
+<property with value> ::= <property/rpv> = <string/rv>
+
+<perms> ::= [ <operation> | <action> | <space> ]*
+
+<operation> ::= r | w | d
+
+<action> ::= a | i | e
+
+<string> ::= <dbl quoted string> | <single quoted string> | <unqouted string>
+
+<dbl quoted string> ::= <space> " <not dqoute>* " <space>
+
+<single quoted string> ::= <space> ' <not squote>* ' <space>
+
+<unquoted string> ::= <space> <not space>+ <space>
+
+<space> ::= [ ' ' | '\et' ]*
+
+Character sets:
+
+<not newline> ::= any character except '\en'
+<not dqoute>  ::= any character except "
+<not squote>  ::= any character except '
+<not space>   ::= any character except those in <space>
+.fi
+.PP
+The semantics associated with the above syntax are as follows.
+.PP
+<version line>, the first line in the file, specifies the file format
+version.  If the server does not recognize the version <string/v>, it
+ignores the rest of the file.  The version string for the file format
+described here is "version-1" .
+.PP
+Once past the <version line>, lines that do not match the above syntax
+are ignored.
+.PP
+<comment> lines are ignored.
+.PP
+<sitepolicy> lines are currently ignored.  They are intended to
+specify the site policies used by the XC-QUERY-SECURITY-1
+authorization method.
+.PP
+<access rule> lines specify how the server should react to untrusted
+client requests that affect the X Window property named <property/ar>.
+The rest of this section describes the interpretation of an
+<access rule>.
+.PP
+For an <access rule> to apply to a given instance of <property/ar>,
+<property/ar> must be on a window that is in the set of windows
+specified by <window>.  If <window> is any, the rule applies to
+<property/ar> on any window.  If <window> is root, the rule applies to
+<property/ar> only on root windows.
+.PP
+If <window> is <required property>, the following apply.  If <required
+property> is a <property/rp>, the rule applies when the window also
+has that <property/rp>, regardless of its value.  If <required
+property> is a <property with value>, <property/rpv> must also have
+the value specified by <string/rv>.  In this case, the property must
+have type STRING and format 8, and should contain one or more
+null-terminated strings.  If any of the strings match <string/rv>, the
+rule applies.
+.PP
+The definition of string matching is simple case-sensitive string
+comparison with one elaboration: the occurence of the character '*' in
+<string/rv> is a wildcard meaning "any string."  A <string/rv> can
+contain multiple wildcards anywhere in the string.  For example, "x*"
+matches strings that begin with x, "*x" matches strings that end with
+x, "*x*" matches strings containing x, and "x*y*" matches strings that
+start with x and subsequently contain y.
+.PP
+There may be multiple <access rule> lines for a given <property/ar>.
+The rules are tested in the order that they appear in the file.  The
+first rule that applies is used.
+.PP
+<perms> specify operations that untrusted clients may attempt, and
+the actions that the server should take in response to those operations.
+.PP
+<operation> can be r (read), w (write), or d (delete).  The following
+table shows how X Protocol property requests map to these operations
+in The Open Group server implementation.
+.PP
+.nf
+GetProperty	r, or r and d if delete = True
+ChangeProperty	w
+RotateProperties	r and w
+DeleteProperty	d
+ListProperties	none, untrusted clients can always list all properties
+.fi
+.PP
+<action> can be a (allow), i (ignore), or e (error).  Allow means
+execute the request as if it had been issued by a trusted client.
+Ignore means treat the request as a no-op.  In the case of
+GetProperty, ignore means return an empty property value if the
+property exists, regardless of its actual value.  Error means do not
+execute the request and return a BadAtom error with the atom set to
+the property name.  Error is the default action for all properties,
+including those not listed in the security policy file.
+.PP
+An <action> applies to all <operation>s that follow it, until the next
+<action> is encountered.  Thus, irwad  means ignore read and write,
+allow delete.
+.PP
+GetProperty and RotateProperties may do multiple operations (r and d,
+or r and w).  If different actions apply to the operations, the most
+severe action is applied to the whole request; there is no partial
+request execution.  The severity ordering is: allow < ignore < error.
+Thus, if the <perms> for a property are ired (ignore read, error
+delete), and an untrusted client attempts GetProperty on that property
+with delete = True, an error is returned, but the property value is
+not.  Similarly, if any of the properties in a RotateProperties do not
+allow both read and write, an error is returned without changing any
+property values.
+.PP
+Here is an example security policy file.
+.PP
+.ta 3i 4i
+.nf
+version-1 
+
+# Allow reading of application resources, but not writing.
+property RESOURCE_MANAGER	root	ar iw
+property SCREEN_RESOURCES	root	ar iw
+
+# Ignore attempts to use cut buffers.  Giving errors causes apps to crash,
+# and allowing access may give away too much information.
+property CUT_BUFFER0	root	irw
+property CUT_BUFFER1	root	irw
+property CUT_BUFFER2	root	irw
+property CUT_BUFFER3	root	irw
+property CUT_BUFFER4	root	irw
+property CUT_BUFFER5	root	irw
+property CUT_BUFFER6	root	irw
+property CUT_BUFFER7	root	irw
+
+# If you are using Motif, you probably want these.
+property _MOTIF_DEFAULT_BINDINGS	root	ar iw
+property _MOTIF_DRAG_WINDOW	root	ar iw
+property _MOTIF_DRAG_TARGETS	any 	ar iw
+property _MOTIF_DRAG_ATOMS	any 	ar iw
+property _MOTIF_DRAG_ATOM_PAIRS	any 	ar iw
+
+# The next two rules let xwininfo -tree work when untrusted.
+property WM_NAME	any	ar
+
+# Allow read of WM_CLASS, but only for windows with WM_NAME.
+# This might be more restrictive than necessary, but demonstrates
+# the <required property> facility, and is also an attempt to
+# say "top level windows only."
+property WM_CLASS	WM_NAME	ar
+
+# These next three let xlsclients work untrusted.  Think carefully
+# before including these; giving away the client machine name and command
+# may be exposing too much.
+property WM_STATE	WM_NAME	ar
+property WM_CLIENT_MACHINE	WM_NAME	ar
+property WM_COMMAND	WM_NAME	ar
+
+# To let untrusted clients use the standard colormaps created by
+# xstdcmap, include these lines.
+property RGB_DEFAULT_MAP	root	ar
+property RGB_BEST_MAP	root	ar
+property RGB_RED_MAP	root	ar
+property RGB_GREEN_MAP	root	ar
+property RGB_BLUE_MAP	root	ar
+property RGB_GRAY_MAP	root	ar
+
+# To let untrusted clients use the color management database created
+# by xcmsdb, include these lines.
+property XDCCC_LINEAR_RGB_CORRECTION	root	ar
+property XDCCC_LINEAR_RGB_MATRICES	root	ar
+property XDCCC_GRAY_SCREENWHITEPOINT	root	ar
+property XDCCC_GRAY_CORRECTION	root	ar
+
+# To let untrusted clients use the overlay visuals that many vendors
+# support, include this line.
+property SERVER_OVERLAY_VISUALS	root	ar
+
+# Dumb examples to show other capabilities.
+
+# oddball property names and explicit specification of error conditions
+property "property with spaces"	'property with "'	aw er ed
+
+# Allow deletion of Woo-Hoo if window also has property OhBoy with value
+# ending in "son".  Reads and writes will cause an error.
+property Woo-Hoo	OhBoy = "*son"	ad
+
+.fi
+.SH "NETWORK CONNECTIONS"
+The X server supports client connections via a platform-dependent subset of
+the following transport types: TCP\/IP, Unix Domain sockets, DECnet,
+and several varieties of SVR4 local connections.  See the DISPLAY
+NAMES section of the \fIX(__miscmansuffix__)\fP manual page to learn how to specify
+which transport type clients should try to use.
+.SH GRANTING ACCESS
+The X server implements a platform-dependent subset of the following
+authorization protocols: MIT-MAGIC-COOKIE-1, XDM-AUTHORIZATION-1,
+SUN-DES-1, and MIT-KERBEROS-5.  See the \fIXsecurity(1)\fP manual page
+for information on the operation of these protocols.
+.PP
+Authorization data required by the above protocols is passed to the
+server in a private file named with the \fB\-auth\fP command line
+option.  Each time the server is about to accept the first connection
+after a reset (or when the server is starting), it reads this file.
+If this file contains any authorization records, the local host is not
+automatically allowed access to the server, and only clients which
+send one of the authorization records contained in the file in the
+connection setup information will be allowed access.  See the
+\fIXau\fP manual page for a description of the binary format of this
+file.  See \fIxauth(1)\fP for maintenance of this file, and distribution
+of its contents to remote hosts.
+.PP
+The X server also uses a host-based access control list for deciding
+whether or not to accept connections from clients on a particular machine.
+If no other authorization mechanism is being used,
+this list initially consists of the host on which the server is running as
+well as any machines listed in the file \fI/etc/X\fBn\fI.hosts\fR, where
+\fBn\fP is the display number of the server.  Each line of the file should
+contain either an Internet hostname (e.g. expo.lcs.mit.edu) or a DECnet
+hostname in double colon format (e.g. hydra::).  There should be no leading
+or trailing spaces on any lines.  For example:
+.sp
+.in +8
+.nf 
+joesworkstation
+corporate.company.com
+star::
+bigcpu::
+.fi
+.in -8
+.PP
+Users can add or remove hosts from this list and enable or disable access
+control using the \fIxhost\fP command from the same machine as the server.
+.PP
+If the X FireWall Proxy (\fIxfwp\fP) is being used without a sitepolicy,
+host-based authorization must be turned on for clients to be able to 
+connect to the X server via the \fIxfwp\fP.  If \fIxfwp\fP is run without 
+a configuration file and thus no sitepolicy is defined, if \fIxfwp\fP 
+is using an X server where xhost + has been run to turn off host-based 
+authorization checks, when a client tries to connect to this X server 
+via \fIxfwp\fP, the X server will deny the connection.  See \fIxfwp(1)\fP
+for more information about this proxy.
+.PP
+The X protocol intrinsically does not have any notion of window operation
+permissions or place any restrictions on what a client can do; if a program can
+connect to a display, it has full run of the screen.  
+X servers that support the SECURITY extension fare better because clients
+can be designated untrusted via the authorization they use to connect; see
+the \fIxauth(1)\fP manual page for details.  Restrictions are imposed
+on untrusted clients that curtail the mischief they can do.  See the SECURITY
+extension specification for a complete list of these restrictions.
+.PP
+Sites that have better
+authentication and authorization systems might wish to make
+use of the hooks in the libraries and the server to provide additional
+security models.
+.SH SIGNALS
+The X server attaches special meaning to the following signals:
+.TP 8
+.I SIGHUP
+This signal causes the server to close all existing connections, free all
+resources, and restore all defaults.  It is sent by the display manager
+whenever the main user's main application (usually an \fIxterm\fP or window
+manager) exits to force the server to clean up and prepare for the next
+user.
+.TP 8
+.I SIGTERM
+This signal causes the server to exit cleanly.
+.TP 8
+.I SIGUSR1
+This signal is used quite differently from either of the above.  When the
+server starts, it checks to see if it has inherited SIGUSR1 as SIG_IGN
+instead of the usual SIG_DFL.  In this case, the server sends a SIGUSR1 to
+its parent process after it has set up the various connection schemes.
+\fIXdm\fP uses this feature to recognize when connecting to the server
+is possible.
+.SH FONTS
+The X server
+can obtain fonts from directories and/or from font servers.
+The list of directories and font servers
+the X server uses when trying to open a font is controlled
+by the \fIfont path\fP.  
+.LP
+The default font path is
+"<XRoot>/lib/X11/fonts/misc/,
+<XRoot>/lib/X11/fonts/Speedo/,
+<XRoot>/lib/X11/fonts/Type1/,
+<XRoot>/lib/X11/fonts/75dpi/,
+<XRoot>/lib/X11/fonts/100dpi/" .
+where <XRoot> refers to the root of the X11 install tree.
+.LP
+The font path can be set with the \fB\-fp\fP option or by \fIxset(1)\fP
+after the server has started.
+.SH FILES
+.TP 30
+/etc/X\fBn\fP.hosts
+Initial access control list for display number \fBn\fP
+.TP 30
+<XRoot>/lib/X11/fonts/misc, <XRoot>/lib/X11/fonts/75dpi, <XRoot>/lib/X11/fonts/100dpi 
+Bitmap font directories
+.TP 30
+<XRoot>/lib/X11/fonts/Speedo, <XRoot>/lib/X11/fonts/Type1
+Outline font directories
+.TP 30
+<XRoot>/lib/X11/fonts/PEX
+PEX font directories
+.TP 30
+<XRoot>/lib/X11/rgb.txt
+Color database
+.TP 30
+/tmp/.X11-unix/X\fBn\fP
+Unix domain socket for display number \fBn\fP
+.TP 30
+/tmp/rcX\fBn\fP
+Kerberos 5 replay cache for display number \fBn\fP
+.TP 30
+/usr/adm/X\fBn\fPmsgs
+Error log file for display number \fBn\fP if run from \fIinit(8)\fP
+.TP 30
+<XRoot>/lib/X11/xdm/xdm-errors
+Default error log file if the server is run from \fIxdm(1)\fP
+.LP
+Note: <XRoot> refers to the root of the X11 install tree.
+.SH "SEE ALSO"
+General information: X(__miscmansuffix__)
+.PP
+Protocols:
+.I "X Window System Protocol,"
+.I "The X Font Service Protocol,"
+.I "X Display Manager Control Protocol"
+.PP
+Fonts: bdftopcf(1), mkfontdir(1), xfs(1), xlsfonts(1), xfontsel(1), xfd(1),
+.I "X Logical Font Description Conventions"
+.PP
+Security: Xsecurity(__miscmansuffix__), xauth(1), Xau(1), xdm(1), xhost(1), xfwp(1)
+.I "Security Extension Specification"
+.PP
+Starting the server: xdm(1), xinit(1)
+.PP
+Controlling the server once started: xset(1), xsetroot(1), xhost(1)
+.PP
+Server-specific man pages: 
+Xdec(1), XmacII(1), Xsun(1), Xnest(1), Xvfb(1),
+XFree86(1), Xdarwin(1).
+.PP
+Server internal documentation:
+.I "Definition of the Porting Layer for the X v11 Sample Server"
+.SH AUTHORS
+The sample server was originally written by Susan Angebranndt, Raymond
+Drewry, Philip Karlton, and Todd Newman, from Digital Equipment
+Corporation, with support from a large cast.  It has since been
+extensively rewritten by Keith Packard and Bob Scheifler, from MIT.
+Dave Wiggins took over post-R5 and made substantial improvements.
Index: xc/programs/Xserver/Xserver.man
diff -u xc/programs/Xserver/Xserver.man:3.12 xc/programs/Xserver/Xserver.man:removed
--- xc/programs/Xserver/Xserver.man:3.12	Sat Mar 13 22:21:21 1999
+++ xc/programs/Xserver/Xserver.man	Mon Dec 18 14:27:26 2000
@@ -1,698 +0,0 @@
-.\" $TOG: Xserver.man /main/68 1998/02/09 14:12:35 kaleb $
-.\" Copyright 1984 - 1991, 1993, 1994, 1998  The Open Group
-.\" 
-.\" All Rights Reserved.
-.\" 
-.\" The above copyright notice and this permission notice shall be included
-.\" in all copies or substantial portions of the Software.
-.\" 
-.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-.\" OTHER DEALINGS IN THE SOFTWARE.
-.\" 
-.\" Except as contained in this notice, the name of The Open Group shall
-.\" not be used in advertising or otherwise to promote the sale, use or
-.\" other dealings in this Software without prior written authorization
-.\" from The Open Group.
-.\" $XFree86: xc/programs/Xserver/Xserver.man,v 3.12 1999/03/14 03:21:21 dawes Exp $
-.TH XSERVER 1 "Release 6.4"  "X Version 11"
-.SH NAME
-Xserver \- X Window System display server
-.SH SYNOPSIS
-.B X
-[option ...]
-.SH DESCRIPTION
-.I X
-is the generic name for the X Window System display server.  It is
-frequently a link or a copy of the appropriate server binary for
-driving the most frequently used server on a given machine.
-.SH "STARTING THE SERVER"
-The X server is usually started from the X Display Manager program \fIxdm(1)\fP.
-This utility is run from the system boot files and takes care of keeping
-the server running, prompting for usernames and passwords, and starting up
-the user sessions.
-.PP
-Installations that run more than one window system may need to use the
-\fIxinit(1)\fP utility instead of \fIxdm\fP.  However, \fIxinit\fP is
-to be considered a tool for building startup scripts and is not
-intended for use by end users.  Site administrators are \fBstrongly\fP
-urged to use \fIxdm\fP, or build other interfaces for novice users.
-.PP
-The X server may also be started directly by the user, though this
-method is usually reserved for testing and is not recommended for
-normal operation.  On some platforms, the user must have special
-permission to start the X server, often because access to certain
-devices (e.g. /dev/mouse) is restricted.
-.PP
-When the X server starts up, it typically takes over the display.  If
-you are running on a workstation whose console is the display, you may
-not be able to log into the console while the server is running.
-.SH OPTIONS
-All of the X servers accept the following command line options:
-.TP 8
-.B :\fIdisplaynumber\fP
-the X server runs as the given \fIdisplaynumber\fP, which by default is 0.
-If multiple X servers are to run simultaneously on a host, each must have
-a unique display number.  See the DISPLAY
-NAMES section of the \fIX(1)\fP manual page to learn how to specify
-which display number clients should try to use.
-.TP 8
-.B \-a \fInumber\fP
-sets pointer acceleration (i.e. the ratio of how much is reported to how much
-the user actually moved the pointer).
-.TP 8
-.B \-ac
-disables host-based access control mechanisms.  Enables access by any host,
-and permits any host to modify the access control list.
-Use with extreme caution.
-This option exists primarily for running test suites remotely.
-.TP 8
-.B \-audit \fIlevel\fP
-Sets the audit trail level.  The default level is 1, meaning only connection
-rejections are reported.  Level 2 additionally reports all successful
-connections and disconnects.  Level 4 enables messages from the
-SECURITY extension, if present, including generation and revocation of
-authorizations and violations of the security policy.
-Level 0 turns off the audit trail.
-Audit lines are sent as standard error output.
-.TP 8
-.B \-auth \fIauthorization-file\fP
-Specifies a file which contains a collection of authorization records used
-to authenticate access.  See also the \fIxdm\fP and \fIXsecurity\fP manual
-pages.
-.TP 8
-.B bc
-disables certain kinds of error checking, for bug compatibility with
-previous releases (e.g., to work around bugs in R2 and R3 xterms and toolkits).
-Deprecated.
-.TP 8
-.B \-bs
-disables backing store support on all screens.
-.TP 8
-.B \-c
-turns off key-click.
-.TP 8
-.B c \fIvolume\fP
-sets key-click volume (allowable range: 0-100).
-.TP 8
-.B \-cc \fIclass\fP
-sets the visual class for the root window of color screens.
-The class numbers are as specified in the X protocol.
-Not obeyed by all servers.
-.TP 8
-.B \-co \fIfilename\fP
-sets name of RGB color database.  The default is <XRoot>/lib/X11/rgb,
-where <XRoot> refers to the root of the X11 install tree.
-.ig
-.TP 8
-.B \-config \fIfilename\fP
-reads more options from the given file.  Options in the file may be separated
-by newlines if desired.  If a '#' character appears on a line, all characters
-between it and the next newline are ignored, providing a simple commenting
-facility.  The \fB\-config\fP option itself may appear in the file.
-.BR NOTE :
-This option is disabled when the Xserver is run with an effective uid
-different from the user's real uid.
-..
-.TP 8
-.B \-core
-causes the server to generate a core dump on fatal errors.
-.TP 8
-.B \-dpi \fIresolution\fP
-sets the resolution of the screen, in dots per inch.
-To be used when the server cannot determine the screen size from the hardware.
-.TP 8
-.B \-deferglyphs \fIwhichfonts\fP
-specifies the types of fonts for which the server should attempt to use
-deferred glyph loading.  \fIwhichfonts\fP can be all (all fonts),
-none (no fonts), or 16 (16 bit fonts only).
-.TP 8
-.B \-f \fIvolume\fP
-sets feep (bell) volume (allowable range: 0-100).
-.TP 8
-.B \-fc \fIcursorFont\fP
-sets default cursor font.
-.TP 8
-.B \-fn \fIfont\fP
-sets the default font.
-.TP 8
-.B \-fp \fIfontPath\fP
-sets the search path for fonts.  This path is a comma separated list
-of directories which the X server searches for font databases.
-.TP 8
-.B \-help
-prints a usage message.
-.TP 8
-.B \-I
-causes all remaining command line arguments to be ignored.
-.TP 8
-.B \-kb
-disables the XKEYBOARD extension if present.
-.TP 8
-.B \-nolisten \fItrans-type\fP
-Disable a transport type.  For example, TCP/IP connections can be disabled
-with
-.B \-nolisten tcp
-.TP 8
-.B \-noreset
-prevents a server reset when the last client connection is closed.  This
-overrides a previous
-.B \-terminate
-command line option.
-.TP 8
-.B \-p \fIminutes\fP
-sets screen-saver pattern cycle time in minutes.
-.TP 8
-.B \-pn
-permits the server to continue running if it fails to establish all of
-its well-known sockets (connection points for clients), but
-establishes at least one.
-.TP 8
-.B \-r
-turns off auto-repeat.
-.TP 8
-.B r
-turns on auto-repeat.
-.TP 8
-.B \-s \fIminutes\fP
-sets screen-saver timeout time in minutes.
-.TP 8
-.B \-su
-disables save under support on all screens.
-.TP 8
-.B \-t \fInumber\fP
-sets pointer acceleration threshold in pixels (i.e. after how many pixels
-pointer acceleration should take effect).
-.TP 8
-.B \-terminate
-causes the server to terminate at server reset, instead of continuing to run.
-This overrides a previous
-.B \-noreset
-command line option.
-.TP 8
-.B \-to \fIseconds\fP
-sets default connection timeout in seconds.
-.TP 8
-.B \-tst
-disables all testing extensions (e.g., XTEST, XTrap, XTestExtension1, RECORD).
-.TP 8
-.B tty\fIxx\fP
-ignored, for servers started the ancient way (from init).
-.TP 8
-.B v
-sets video-off screen-saver preference.
-.TP 8
-.B \-v
-sets video-on screen-saver preference.
-.TP 8
-.B \-wm
-forces the default backing-store of all windows to be WhenMapped.  This
-is a backdoor way of getting backing-store to apply to all windows.
-Although all mapped windows will have backing store, the backing store
-attribute value reported by the server for a window will be the last
-value established by a client.  If it has never been set by a client,
-the server will report the default value, NotUseful.  This behavior is
-required by the X protocol, which allows the server to exceed the
-client's backing store expectations but does not provide a way to tell
-the client that it is doing so.
-.TP 8
-.B \-x \fIextension\fP
-loads the specified extension at init.
-This is a no-op for most implementations.
-.TP 8
-.B [+-]xinerama
-enable(+) or disable(-) XINERAMA extension. Default is disabled.
-.SH SERVER DEPENDENT OPTIONS
-Some X servers accept the following options:
-.TP 8
-.B \-ld \fIkilobytes\fP
-sets the data space limit of the server to the specified number of kilobytes.
-A value of zero makes the data size as large as possible.  The default value
-of \-1 leaves the data space limit unchanged.
-.TP 8
-.B \-lf \fIfiles\fP
-sets the number-of-open-files limit of the server to the specified number.
-A value of zero makes the limit as large as possible.  The default value
-of \-1 leaves the limit unchanged.
-.TP 8
-.B \-ls \fIkilobytes\fP
-sets the stack space limit of the server to the specified number of kilobytes.
-A value of zero makes the stack size as large as possible.  The default value
-of \-1 leaves the stack space limit unchanged.
-.TP 8
-.B \-logo
-turns on the X Window System logo display in the screen-saver.
-There is currently no way to change this from a client.
-.TP 8
-.B nologo
-turns off the X Window System logo display in the screen-saver.
-There is currently no way to change this from a client.
-.SH XDMCP OPTIONS
-X servers that support XDMCP have the following options.
-See the \fIX Display Manager Control Protocol\fP specification for more
-information.
-.TP 8
-.B \-query \fIhost-name\fP
-Enable XDMCP and send Query packets to the specified host.
-.TP 8
-.B \-broadcast
-Enable XDMCP and broadcast BroadcastQuery packets to the network.  The
-first responding display manager will be chosen for the session.
-.TP 8
-.B \-indirect \fIhost-name\fP
-Enable XDMCP and send IndirectQuery packets to the specified host.
-.TP 8
-.B \-port \fIport-num\fP
-Use an alternate port number for XDMCP packets.  Must be specified before
-any \-query, \-broadcast or \-indirect options.
-.TP 8
-.B \-once
-Causes the server to terminate (rather than reset) when the XDMCP session ends.
-.TP 8
-.B \-class \fIdisplay-class\fP
-XDMCP has an additional display qualifier used in resource lookup for
-display-specific options.  This option sets that value, by default it 
-is "MIT-Unspecified" (not a very useful value).
-.TP 8
-.B \-cookie \fIxdm-auth-bits\fP
-When testing XDM-AUTHENTICATION-1, a private key is shared between the
-server and the manager.  This option sets the value of that private
-data (not that it is very private, being on the command line!).
-.TP 8
-.B \-displayID \fIdisplay-id\fP
-Yet another XDMCP specific value, this one allows the display manager to
-identify each display so that it can locate the shared key.
-.SH XKEYBOARD OPTIONS
-X servers that support the XKEYBOARD extension accept the following options:
-.TP 8
-.B \-xkbdir \fIdirectory\fP
-base directory for keyboard layout files
-.TP 8
-.B \-xkbmap \fIfilename\fP
-keyboard description to load on startup
-.TP 8
-.B [+-]accessx
-enable(+) or disable(-) AccessX key sequences
-.TP 8
-.B \-ar1 \fImilliseconds\fP
-sets the length of time in milliseconds that a key must be depressed before
-autorepeat starts
-.TP 8
-.B \-ar2 \fImilliseconds\fP
-sets the length of time in milliseconds that should elapse between
-autorepeat-generated keystrokes
-.PP
-Many servers also have device-specific command line options.  See the
-manual pages for the individual servers for more details.
-.SH SECURITY EXTENSION OPTIONS
-X servers that support the SECURITY extension accept the following option:
-.TP 8
-.B \-sp \fIfilename\fP
-causes
-the server to attempt to read and interpret filename as a security policy
-file with the format described below.  The file is read at
-server startup and reread at each server reset.
-.PP
-The syntax of the security policy file is as follows.
-Notation: "*" means zero or more occurrences of the preceding element,
-and "+" means one or more occurrences.  To interpret <foo/bar>, ignore
-the text after the /; it is used to distinguish between instances of
-<foo> in the next section.
-.PP
-.nf
-<policy file> ::= <version line> <other line>*
-
-<version line> ::= <string/v> '\en'
-
-<other line > ::= <comment> | <access rule> | <site policy> | <blank line>
-
-<comment> ::= # <not newline>* '\en'
-
-<blank line> ::= <space> '\en'
-
-<site policy> ::= sitepolicy <string/sp> '\en'
-
-<access rule> ::= property <property/ar> <window> <perms> '\en'
-
-<property> ::= <string>
-
-<window> ::= any | root | <required property>
-
-<required property> ::= <property/rp> | <property with value>
-
-<property with value> ::= <property/rpv> = <string/rv>
-
-<perms> ::= [ <operation> | <action> | <space> ]*
-
-<operation> ::= r | w | d
-
-<action> ::= a | i | e
-
-<string> ::= <dbl quoted string> | <single quoted string> | <unqouted string>
-
-<dbl quoted string> ::= <space> " <not dqoute>* " <space>
-
-<single quoted string> ::= <space> ' <not squote>* ' <space>
-
-<unquoted string> ::= <space> <not space>+ <space>
-
-<space> ::= [ ' ' | '\et' ]*
-
-Character sets:
-
-<not newline> ::= any character except '\en'
-<not dqoute>  ::= any character except "
-<not squote>  ::= any character except '
-<not space>   ::= any character except those in <space>
-.fi
-.PP
-The semantics associated with the above syntax are as follows.
-.PP
-<version line>, the first line in the file, specifies the file format
-version.  If the server does not recognize the version <string/v>, it
-ignores the rest of the file.  The version string for the file format
-described here is "version-1" .
-.PP
-Once past the <version line>, lines that do not match the above syntax
-are ignored.
-.PP
-<comment> lines are ignored.
-.PP
-<sitepolicy> lines are currently ignored.  They are intended to
-specify the site policies used by the XC-QUERY-SECURITY-1
-authorization method.
-.PP
-<access rule> lines specify how the server should react to untrusted
-client requests that affect the X Window property named <property/ar>.
-The rest of this section describes the interpretation of an
-<access rule>.
-.PP
-For an <access rule> to apply to a given instance of <property/ar>,
-<property/ar> must be on a window that is in the set of windows
-specified by <window>.  If <window> is any, the rule applies to
-<property/ar> on any window.  If <window> is root, the rule applies to
-<property/ar> only on root windows.
-.PP
-If <window> is <required property>, the following apply.  If <required
-property> is a <property/rp>, the rule applies when the window also
-has that <property/rp>, regardless of its value.  If <required
-property> is a <property with value>, <property/rpv> must also have
-the value specified by <string/rv>.  In this case, the property must
-have type STRING and format 8, and should contain one or more
-null-terminated strings.  If any of the strings match <string/rv>, the
-rule applies.
-.PP
-The definition of string matching is simple case-sensitive string
-comparison with one elaboration: the occurence of the character '*' in
-<string/rv> is a wildcard meaning "any string."  A <string/rv> can
-contain multiple wildcards anywhere in the string.  For example, "x*"
-matches strings that begin with x, "*x" matches strings that end with
-x, "*x*" matches strings containing x, and "x*y*" matches strings that
-start with x and subsequently contain y.
-.PP
-There may be multiple <access rule> lines for a given <property/ar>.
-The rules are tested in the order that they appear in the file.  The
-first rule that applies is used.
-.PP
-<perms> specify operations that untrusted clients may attempt, and
-the actions that the server should take in response to those operations.
-.PP
-<operation> can be r (read), w (write), or d (delete).  The following
-table shows how X Protocol property requests map to these operations
-in The Open Group server implementation.
-.PP
-.nf
-GetProperty	r, or r and d if delete = True
-ChangeProperty	w
-RotateProperties	r and w
-DeleteProperty	d
-ListProperties	none, untrusted clients can always list all properties
-.fi
-.PP
-<action> can be a (allow), i (ignore), or e (error).  Allow means
-execute the request as if it had been issued by a trusted client.
-Ignore means treat the request as a no-op.  In the case of
-GetProperty, ignore means return an empty property value if the
-property exists, regardless of its actual value.  Error means do not
-execute the request and return a BadAtom error with the atom set to
-the property name.  Error is the default action for all properties,
-including those not listed in the security policy file.
-.PP
-An <action> applies to all <operation>s that follow it, until the next
-<action> is encountered.  Thus, irwad  means ignore read and write,
-allow delete.
-.PP
-GetProperty and RotateProperties may do multiple operations (r and d,
-or r and w).  If different actions apply to the operations, the most
-severe action is applied to the whole request; there is no partial
-request execution.  The severity ordering is: allow < ignore < error.
-Thus, if the <perms> for a property are ired (ignore read, error
-delete), and an untrusted client attempts GetProperty on that property
-with delete = True, an error is returned, but the property value is
-not.  Similarly, if any of the properties in a RotateProperties do not
-allow both read and write, an error is returned without changing any
-property values.
-.PP
-Here is an example security policy file.
-.PP
-.ta 3i 4i
-.nf
-version-1 
-
-# Allow reading of application resources, but not writing.
-property RESOURCE_MANAGER	root	ar iw
-property SCREEN_RESOURCES	root	ar iw
-
-# Ignore attempts to use cut buffers.  Giving errors causes apps to crash,
-# and allowing access may give away too much information.
-property CUT_BUFFER0	root	irw
-property CUT_BUFFER1	root	irw
-property CUT_BUFFER2	root	irw
-property CUT_BUFFER3	root	irw
-property CUT_BUFFER4	root	irw
-property CUT_BUFFER5	root	irw
-property CUT_BUFFER6	root	irw
-property CUT_BUFFER7	root	irw
-
-# If you are using Motif, you probably want these.
-property _MOTIF_DEFAULT_BINDINGS	root	ar iw
-property _MOTIF_DRAG_WINDOW	root	ar iw
-property _MOTIF_DRAG_TARGETS	any 	ar iw
-property _MOTIF_DRAG_ATOMS	any 	ar iw
-property _MOTIF_DRAG_ATOM_PAIRS	any 	ar iw
-
-# The next two rules let xwininfo -tree work when untrusted.
-property WM_NAME	any	ar
-
-# Allow read of WM_CLASS, but only for windows with WM_NAME.
-# This might be more restrictive than necessary, but demonstrates
-# the <required property> facility, and is also an attempt to
-# say "top level windows only."
-property WM_CLASS	WM_NAME	ar
-
-# These next three let xlsclients work untrusted.  Think carefully
-# before including these; giving away the client machine name and command
-# may be exposing too much.
-property WM_STATE	WM_NAME	ar
-property WM_CLIENT_MACHINE	WM_NAME	ar
-property WM_COMMAND	WM_NAME	ar
-
-# To let untrusted clients use the standard colormaps created by
-# xstdcmap, include these lines.
-property RGB_DEFAULT_MAP	root	ar
-property RGB_BEST_MAP	root	ar
-property RGB_RED_MAP	root	ar
-property RGB_GREEN_MAP	root	ar
-property RGB_BLUE_MAP	root	ar
-property RGB_GRAY_MAP	root	ar
-
-# To let untrusted clients use the color management database created
-# by xcmsdb, include these lines.
-property XDCCC_LINEAR_RGB_CORRECTION	root	ar
-property XDCCC_LINEAR_RGB_MATRICES	root	ar
-property XDCCC_GRAY_SCREENWHITEPOINT	root	ar
-property XDCCC_GRAY_CORRECTION	root	ar
-
-# To let untrusted clients use the overlay visuals that many vendors
-# support, include this line.
-property SERVER_OVERLAY_VISUALS	root	ar
-
-# Dumb examples to show other capabilities.
-
-# oddball property names and explicit specification of error conditions
-property "property with spaces"	'property with "'	aw er ed
-
-# Allow deletion of Woo-Hoo if window also has property OhBoy with value
-# ending in "son".  Reads and writes will cause an error.
-property Woo-Hoo	OhBoy = "*son"	ad
-
-.fi
-.SH "NETWORK CONNECTIONS"
-The X server supports client connections via a platform-dependent subset of
-the following transport types: TCP\/IP, Unix Domain sockets, DECnet,
-and several varieties of SVR4 local connections.  See the DISPLAY
-NAMES section of the \fIX(1)\fP manual page to learn how to specify
-which transport type clients should try to use.
-.SH GRANTING ACCESS
-The X server implements a platform-dependent subset of the following
-authorization protocols: MIT-MAGIC-COOKIE-1, XDM-AUTHORIZATION-1,
-SUN-DES-1, and MIT-KERBEROS-5.  See the \fIXsecurity(1)\fP manual page
-for information on the operation of these protocols.
-.PP
-Authorization data required by the above protocols is passed to the
-server in a private file named with the \fB\-auth\fP command line
-option.  Each time the server is about to accept the first connection
-after a reset (or when the server is starting), it reads this file.
-If this file contains any authorization records, the local host is not
-automatically allowed access to the server, and only clients which
-send one of the authorization records contained in the file in the
-connection setup information will be allowed access.  See the
-\fIXau\fP manual page for a description of the binary format of this
-file.  See \fIxauth(1)\fP for maintenance of this file, and distribution
-of its contents to remote hosts.
-.PP
-The X server also uses a host-based access control list for deciding
-whether or not to accept connections from clients on a particular machine.
-If no other authorization mechanism is being used,
-this list initially consists of the host on which the server is running as
-well as any machines listed in the file \fI/etc/X\fBn\fI.hosts\fR, where
-\fBn\fP is the display number of the server.  Each line of the file should
-contain either an Internet hostname (e.g. expo.lcs.mit.edu) or a DECnet
-hostname in double colon format (e.g. hydra::).  There should be no leading
-or trailing spaces on any lines.  For example:
-.sp
-.in +8
-.nf 
-joesworkstation
-corporate.company.com
-star::
-bigcpu::
-.fi
-.in -8
-.PP
-Users can add or remove hosts from this list and enable or disable access
-control using the \fIxhost\fP command from the same machine as the server.
-.PP
-If the X FireWall Proxy (\fIxfwp\fP) is being used without a sitepolicy,
-host-based authorization must be turned on for clients to be able to 
-connect to the X server via the \fIxfwp\fP.  If \fIxfwp\fP is run without 
-a configuration file and thus no sitepolicy is defined, if \fIxfwp\fP 
-is using an X server where xhost + has been run to turn off host-based 
-authorization checks, when a client tries to connect to this X server 
-via \fIxfwp\fP, the X server will deny the connection.  See \fIxfwp(1)\fP
-for more information about this proxy.
-.PP
-The X protocol intrinsically does not have any notion of window operation
-permissions or place any restrictions on what a client can do; if a program can
-connect to a display, it has full run of the screen.  
-X servers that support the SECURITY extension fare better because clients
-can be designated untrusted via the authorization they use to connect; see
-the \fIxauth(1)\fP manual page for details.  Restrictions are imposed
-on untrusted clients that curtail the mischief they can do.  See the SECURITY
-extension specification for a complete list of these restrictions.
-.PP
-Sites that have better
-authentication and authorization systems might wish to make
-use of the hooks in the libraries and the server to provide additional
-security models.
-.SH SIGNALS
-The X server attaches special meaning to the following signals:
-.TP 8
-.I SIGHUP
-This signal causes the server to close all existing connections, free all
-resources, and restore all defaults.  It is sent by the display manager
-whenever the main user's main application (usually an \fIxterm\fP or window
-manager) exits to force the server to clean up and prepare for the next
-user.
-.TP 8
-.I SIGTERM
-This signal causes the server to exit cleanly.
-.TP 8
-.I SIGUSR1
-This signal is used quite differently from either of the above.  When the
-server starts, it checks to see if it has inherited SIGUSR1 as SIG_IGN
-instead of the usual SIG_DFL.  In this case, the server sends a SIGUSR1 to
-its parent process after it has set up the various connection schemes.
-\fIXdm\fP uses this feature to recognize when connecting to the server
-is possible.
-.SH FONTS
-The X server
-can obtain fonts from directories and/or from font servers.
-The list of directories and font servers
-the X server uses when trying to open a font is controlled
-by the \fIfont path\fP.  
-.LP
-The default font path is
-"<XRoot>/lib/X11/fonts/misc/,
-<XRoot>/lib/X11/fonts/Speedo/,
-<XRoot>/lib/X11/fonts/Type1/,
-<XRoot>/lib/X11/fonts/75dpi/,
-<XRoot>/lib/X11/fonts/100dpi/" .
-where <XRoot> refers to the root of the X11 install tree.
-.LP
-The font path can be set with the \fB\-fp\fP option or by \fIxset(1)\fP
-after the server has started.
-.SH FILES
-.TP 30
-/etc/X\fBn\fP.hosts
-Initial access control list for display number \fBn\fP
-.TP 30
-<XRoot>/lib/X11/fonts/misc, <XRoot>/lib/X11/fonts/75dpi, <XRoot>/lib/X11/fonts/100dpi 
-Bitmap font directories
-.TP 30
-<XRoot>/lib/X11/fonts/Speedo, <XRoot>/lib/X11/fonts/Type1
-Outline font directories
-.TP 30
-<XRoot>/lib/X11/fonts/PEX
-PEX font directories
-.TP 30
-<XRoot>/lib/X11/rgb.txt
-Color database
-.TP 30
-/tmp/.X11-unix/X\fBn\fP
-Unix domain socket for display number \fBn\fP
-.TP 30
-/tmp/rcX\fBn\fP
-Kerberos 5 replay cache for display number \fBn\fP
-.TP 30
-/usr/adm/X\fBn\fPmsgs
-Error log file for display number \fBn\fP if run from \fIinit(8)\fP
-.TP 30
-<XRoot>/lib/X11/xdm/xdm-errors
-Default error log file if the server is run from \fIxdm(1)\fP
-.LP
-Note: <XRoot> refers to the root of the X11 install tree.
-.SH "SEE ALSO"
-General information: X(1)
-.PP
-Protocols:
-.I "X Window System Protocol,"
-.I "The X Font Service Protocol,"
-.I "X Display Manager Control Protocol"
-.PP
-Fonts: bdftopcf(1), mkfontdir(1), xfs(1), xlsfonts(1), xfontsel(1), xfd(1),
-.I "X Logical Font Description Conventions"
-.PP
-Security: Xsecurity(1), xauth(1), Xau(1), xdm(1), xhost(1), xfwp(1)
-.I "Security Extension Specification"
-.PP
-Starting the server: xdm(1), xinit(1)
-.PP
-Controlling the server once started: xset(1), xsetroot(1), xhost(1)
-.PP
-Server-specific man pages: 
-Xdec(1), XmacII(1), Xsun(1), Xnest(1), Xvfb(1),
-XF86_Accel(1), XF86_SVGA(1), XFree86(1)
-.PP
-Server internal documentation:
-.I "Definition of the Porting Layer for the X v11 Sample Server"
-.SH AUTHORS
-The sample server was originally written by Susan Angebranndt, Raymond
-Drewry, Philip Karlton, and Todd Newman, from Digital Equipment
-Corporation, with support from a large cast.  It has since been
-extensively rewritten by Keith Packard and Bob Scheifler, from MIT.
-Dave Wiggins took over post-R5 and made substantial improvements.
Index: xc/programs/Xserver/GL/Imakefile
diff -u xc/programs/Xserver/GL/Imakefile:1.6 xc/programs/Xserver/GL/Imakefile:1.7
--- xc/programs/Xserver/GL/Imakefile:1.6	Tue Feb 22 23:46:51 2000
+++ xc/programs/Xserver/GL/Imakefile	Thu Aug 24 18:20:08 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/GL/Imakefile,v 1.6 2000/02/23 04:46:51 martin Exp $
+XCOMM $XFree86: xc/programs/Xserver/GL/Imakefile,v 1.7 2000/08/24 22:20:08 tsi Exp $
 
 #define IHaveModules
 #include <Server.tmpl>
@@ -42,7 +42,7 @@
 
 ModuleObjectRule()
 
-NormalDepLibraryTarget(glx,$(SUBDIRS) $(DONES) $(MOBJS),$(OBJS))
+DepLibraryModuleTarget(glx,$(SUBDIRS) $(DONES) $(MOBJS),$(OBJS))
 
 InstallLibraryModule(glx,$(MODULEDIR),extensions)
 ForceSubdirs($(SUBDIRS))
Index: xc/programs/Xserver/GL/dri/dri-def.cpp
diff -u /dev/null xc/programs/Xserver/GL/dri/dri-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:27:27 2000
+++ xc/programs/Xserver/GL/dri/dri-def.cpp	Wed Aug  9 19:40:16 2000
@@ -0,0 +1,50 @@
+LIBRARY DRI
+VERSION LIBRARY_VERSION
+EXPORTS
+
+XFree86DRIExtensionInit
+DRIAuthConnection
+DRIBlockHandler
+DRIClipNotify
+DRICloseConnection
+DRICloseScreen
+DRIContextPrivDelete
+DRICopyWindow
+DRICreateContext
+DRICreateContextPriv
+DRICreateContextPrivFromHandle
+DRICreateDrawable
+DRICreateInfoRec
+DRIDestroyContext
+DRIDestroyContextPriv
+DRIDestroyDrawable
+DRIDestroyInfoRec
+DRIDoBlockHandler
+DRIDoWakeupHandler
+DRIDrawablePrivDelete
+DRIExtensionInit
+DRIFinishScreenInit
+DRIGetClientDriverName
+DRIGetContext
+DRIGetContextStore
+DRIGetDeviceInfo
+DRIGetDrawableIndex
+DRIGetDrawableInfo
+DRIGetDrawableStamp
+DRIGetSAREAPrivate
+DRIGetWrappedFuncs
+DRILock
+DRIOpenConnection
+DRIPaintWindow
+DRIPostValidateTree
+DRIPrintDrawableLock
+DRIQueryDirectRenderingCapable
+DRIQueryVersion
+DRIReset
+DRIScreenInit
+DRISwapContext
+DRIUnlock
+DRIValidateTree
+DRIWakeupHandler
+
+/* $XFree86: xc/programs/Xserver/GL/dri/dri-def.cpp,v 1.1 2000/08/09 23:40:16 dawes Exp $ */
Index: xc/programs/Xserver/GL/dri/dri.c
diff -u xc/programs/Xserver/GL/dri/dri.c:1.19 xc/programs/Xserver/GL/dri/dri.c:1.24
--- xc/programs/Xserver/GL/dri/dri.c:1.19	Sun Jun 25 12:03:43 2000
+++ xc/programs/Xserver/GL/dri/dri.c	Thu Dec  7 15:26:13 2000
@@ -1,7 +1,8 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/dri.c,v 1.19 2000/06/25 16:03:43 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/GL/dri/dri.c,v 1.24 2000/12/07 20:26:13 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,7 +29,8 @@
 
 /*
  * Authors:
- *   Jens Owen <jens@precisioninsight.com>
+ *   Jens Owen <jens@valinux.com>
+ *   Rickard E. (Rik) Faith <faith@valinux.com>
  *
  */
 
@@ -62,16 +64,21 @@
 #include "xf86drm.h"
 #include "glxserver.h"
 #include "mi.h"
+#include "mipointer.h"
 #include "xf86Priv.h"
 
 static int DRIScreenPrivIndex = -1;
 static int DRIWindowPrivIndex = -1;
 static unsigned long DRIGeneration = 0;
 static unsigned int DRIDrawableValidationStamp = 0;
-/* We know there will be one extra unlock during startup. Setting this to
-   -1, flags that we are in this initialization case */
-static int lockRefCount=-1;
+static int lockRefCount=0;
 
+				/* Support cleanup for fullscreen mode,
+                                   independent of the DRICreateDrawable
+                                   resource management. */
+static Bool    _DRICloseFullScreen(pointer pResource, XID id);
+static RESTYPE DRIFullScreenResType;
+
 static RESTYPE DRIDrawablePrivResType;
 static RESTYPE DRIContextPrivResType;
 
@@ -113,6 +120,8 @@
     if (fd < 0) {
         /* failed to open DRM */
         pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+        DRIDrvMsg(pScreen->myNum, X_INFO,
+                  "[drm] drmOpen failed\n");
         return FALSE;
     }
 
@@ -123,7 +132,7 @@
                  pDRIInfo->drmDriverName);
     }
 
-    pDRIPriv = (DRIScreenPrivPtr) xalloc(sizeof(DRIScreenPrivRec));
+    pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
     if (!pDRIPriv) {
         pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
         return FALSE;
@@ -134,11 +143,15 @@
     pDRIPriv->directRenderingSupport = TRUE;
     pDRIPriv->pDriverInfo = pDRIInfo;
     pDRIPriv->nrWindows = 0;
+    pDRIPriv->fullscreen = NULL;
 
     if (drmSetBusid(pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString) < 0) {
 	pDRIPriv->directRenderingSupport = FALSE;
 	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
 	drmClose(pDRIPriv->drmFD);
+        DRIDrvMsg(pScreen->myNum, X_INFO,
+                  "[drm] drmSetBusid failed (%d, %s)\n",
+                  pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString);
 	return FALSE;
     }
 
@@ -158,6 +171,8 @@
 	pDRIPriv->directRenderingSupport = FALSE;
 	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
 	drmClose(pDRIPriv->drmFD);
+        DRIDrvMsg(pScreen->myNum, X_INFO,
+                  "[drm] drmAddMap failed\n");
 	return FALSE;
     }
     DRIDrvMsg(pScreen->myNum, X_INFO,
@@ -172,8 +187,11 @@
 	pDRIPriv->directRenderingSupport = FALSE;
 	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
 	drmClose(pDRIPriv->drmFD);
+        DRIDrvMsg(pScreen->myNum, X_INFO,
+                  "[drm] drmMap failed\n");
 	return FALSE;
     }
+    memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
     DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA 0x%08lx to %p\n",
 	      pDRIPriv->hSAREA, pDRIPriv->pSAREA);
     
@@ -188,6 +206,8 @@
 	pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
 	drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
 	drmClose(pDRIPriv->drmFD);
+        DRIDrvMsg(pScreen->myNum, X_INFO,
+                  "[drm] drmAddMap failed\n");
 	return FALSE;
     }
     DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = 0x%08lx\n",
@@ -255,6 +275,11 @@
     DRIDrvMsg(pScreen->myNum, X_INFO,
 	      "X context handle = 0x%08lx\n", pDRIPriv->myContext);
 
+    /* Now that we have created the X server's context, we can grab the
+     * hardware lock for the X server.
+     */
+    DRILock(pScreen, 0);
+
     /* pointers so that we can prevent memory leaks later */
     pDRIPriv->hiddenContextStore    = NULL;
     pDRIPriv->partial3DContextStore = NULL;
@@ -267,7 +292,7 @@
 	
 	/* allocate memory for hidden context store */
 	pDRIPriv->hiddenContextStore
-	    = (void *)xalloc(pDRIInfo->contextSize);
+	    = (void *)xcalloc(1, pDRIInfo->contextSize);
 	if (!pDRIPriv->hiddenContextStore) {
 	    DRIDrvMsg(pScreen->myNum, X_ERROR, 
 		      "failed to allocate hidden context\n");
@@ -277,7 +302,7 @@
 
 	/* allocate memory for partial 3D context store */
 	pDRIPriv->partial3DContextStore
-	    = (void *)xalloc(pDRIInfo->contextSize);
+	    = (void *)xcalloc(1, pDRIInfo->contextSize);
 	if (!pDRIPriv->partial3DContextStore) {
 	    DRIDrvMsg(pScreen->myNum, X_ERROR, 
 		      "[DRI] failed to allocate partial 3D context\n");
@@ -346,6 +371,12 @@
     }
     if (pDRIInfo->wrap.ClipNotify)
        miClipNotify(pDRIInfo->wrap.ClipNotify);
+
+    if (pDRIInfo->wrap.AdjustFrame) {
+	ScrnInfoPtr pScrn          = xf86Screens[pScreen->myNum];
+	pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
+	pScrn->AdjustFrame         = pDRIInfo->wrap.AdjustFrame;
+    }
    
     DRIDrvMsg(pScreen->myNum, X_INFO, "[DRI] installation complete\n");
 
@@ -361,6 +392,12 @@
 
     if (pDRIPriv && pDRIPriv->directRenderingSupport) {
 
+	if (pDRIPriv->wrap.AdjustFrame) {
+	    ScrnInfoPtr pScrn          = xf86Screens[pScreen->myNum];
+	    pScrn->AdjustFrame         = pDRIPriv->wrap.AdjustFrame;
+	    pDRIPriv->wrap.AdjustFrame = NULL;
+	}
+
 	if (pDRIPriv->pDriverInfo->driverSwapMethod != DRI_KERNEL_SWAP) {
 	    if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) {
 		DRIDrvMsg(pScreen->myNum, X_ERROR, 
@@ -389,7 +426,7 @@
 	}
 
 	DRIUnlock(pScreen);
-	lockRefCount=-1;
+	lockRefCount=0;
 	DRIDrvMsg(pScreen->myNum, X_INFO,
 		  "[drm] unmapping %d bytes of SAREA 0x%08lx at %p\n",
 		  pDRIPriv->pDriverInfo->SAREASize,
@@ -429,6 +466,7 @@
 
     DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
     DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete);
+    DRIFullScreenResType = CreateNewResourceType(_DRICloseFullScreen);
 
     for (i = 0; i < screenInfo.numScreens; i++)
     {
@@ -547,7 +585,7 @@
 
     contextPrivSize = sizeof(DRIContextPrivRec) +
 			    pDRIPriv->pDriverInfo->contextSize;
-    if (!(pDRIContextPriv = xalloc(contextPrivSize))) {
+    if (!(pDRIContextPriv = xcalloc(1, contextPrivSize))) {
 	return NULL;
     }
     pDRIContextPriv->pContextStore = (void *)(pDRIContextPriv + 1);
@@ -639,11 +677,9 @@
 
     contextStore=DRIGetContextStore(pDRIContextPriv);
     if (pDRIPriv->pDriverInfo->CreateContext) {
-	if (!((*pDRIPriv->pDriverInfo->CreateContext)(pScreen, 
-				                      visual, 
-				                      *pHWContext, 
-				                      *pVisualConfigPriv,
-						      (int)contextStore))) {
+	if (!((*pDRIPriv->pDriverInfo->CreateContext)(pScreen, visual, 
+		*pHWContext, *pVisualConfigPriv,
+		(DRIContextType)(long)contextStore))) {
 	    DRIDestroyContextPriv(pDRIContextPriv);
 	    return FALSE;
 	}
@@ -675,8 +711,7 @@
     if (pDRIPriv->pDriverInfo->DestroyContext) {
       contextStore=DRIGetContextStore(pDRIContextPriv);
       (pDRIPriv->pDriverInfo->DestroyContext)(pDRIContextPriv->pScreen,
-					      pDRIContextPriv->hwContext,
-					      (int)contextStore);
+		pDRIContextPriv->hwContext, (DRIContextType)(long)contextStore);
     }
     return DRIDestroyContextPriv(pDRIContextPriv);
 }
@@ -882,7 +917,7 @@
                    int* numBackClipRects,
                    XF86DRIClipRectPtr* pBackClipRects)
 {
-    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+    DRIScreenPrivPtr    pDRIPriv = DRI_SCREEN_PRIV(pScreen);
     DRIDrawablePrivPtr	pDRIDrawablePriv, pOldDrawPriv;
     WindowPtr		pWin, pOldWin;
     int			i;
@@ -977,6 +1012,17 @@
 	    *H = (int)(pWin->drawable.height);
 	    *numClipRects = REGION_NUM_RECTS(&pWin->clipList);
 	    *pClipRects = (XF86DRIClipRectPtr)REGION_RECTS(&pWin->clipList);
+
+	    if (!*numClipRects && pDRIPriv->fullscreen) {
+				/* use fake full-screen clip rect */
+		pDRIPriv->fullscreen_rect.x1 = *X;
+		pDRIPriv->fullscreen_rect.y1 = *Y;
+		pDRIPriv->fullscreen_rect.x2 = *X + *W;
+		pDRIPriv->fullscreen_rect.y2 = *Y + *H;
+
+		*numClipRects = 1;
+		*pClipRects   = &pDRIPriv->fullscreen_rect;
+	    }
 	    
 	    *backX = *X;
 	    *backY = *Y;
@@ -1044,7 +1090,7 @@
 DRIInfoPtr
 DRICreateInfoRec(void)
 {
-    DRIInfoPtr inforec = (DRIInfoPtr)xalloc(sizeof(DRIInfoRec));
+    DRIInfoPtr inforec = (DRIInfoPtr)xcalloc(1, sizeof(DRIInfoRec));
     if (!inforec) return NULL;
 
     /* Initialize defaults */
@@ -1059,6 +1105,7 @@
     inforec->wrap.ValidateTree          = DRIValidateTree;
     inforec->wrap.PostValidateTree      = DRIPostValidateTree;
     inforec->wrap.ClipNotify            = DRIClipNotify;
+    inforec->wrap.AdjustFrame           = DRIAdjustFrame;
 
     inforec->TransitionTo2d = 0;
     inforec->TransitionTo3d = 0;
@@ -1430,7 +1477,11 @@
 DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */)
 {
     int  count = 10000;
+#ifndef __alpha__
     char ret;
+#else
+    int ret;
+#endif
     long s_secs, s_usecs;
     long f_secs, f_usecs;
     long msecs;
@@ -1604,10 +1655,6 @@
 
     if (lockRefCount>0) lockRefCount--;
     else {
-      if (lockRefCount==-1) {
-	lockRefCount=0;
-	return;
-      }
       ErrorF("DRIUnlock called when not locked\n");
       return;
     }
@@ -1649,4 +1696,146 @@
    *majorVersion = XF86DRI_MAJOR_VERSION;
    *minorVersion = XF86DRI_MINOR_VERSION;
    *patchVersion = XF86DRI_PATCH_VERSION;
+}
+
+static void
+_DRIAdjustFrame(ScrnInfoPtr pScrn, DRIScreenPrivPtr pDRIPriv, int x, int y)
+{
+    pDRIPriv->pSAREA->frame.x      = x;
+    pDRIPriv->pSAREA->frame.y      = y;
+    pDRIPriv->pSAREA->frame.width  = pScrn->frameX1 - x + 1;
+    pDRIPriv->pSAREA->frame.height = pScrn->frameY1 - y + 1;
+}
+
+void
+DRIAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+    ScreenPtr        pScreen  = screenInfo.screens[scrnIndex];
+    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+    ScrnInfoPtr      pScrn    = xf86Screens[pScreen->myNum];
+    int              px, py;
+
+    if (!pDRIPriv || !pDRIPriv->pSAREA) {
+	DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n",
+		  pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL);
+	return;
+    }
+
+    if (pDRIPriv->fullscreen) {
+				/* Fix up frame */
+	pScrn->frameX0 = pDRIPriv->pSAREA->frame.x;
+	pScrn->frameY0 = pDRIPriv->pSAREA->frame.y;
+	pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1;
+	pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1;
+
+				/* Fix up cursor */
+	miPointerPosition(&px, &py);
+	if (px < pScrn->frameX0) px = pScrn->frameX0;
+	if (px > pScrn->frameX1) px = pScrn->frameX1;
+	if (py < pScrn->frameY0) py = pScrn->frameY0;
+	if (py > pScrn->frameY1) py = pScrn->frameY1;
+	pScreen->SetCursorPosition(pScreen, px, py, TRUE);
+	return;
+    }
+
+    if (pDRIPriv->wrap.AdjustFrame) {
+	/* unwrap */
+	pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
+	/* call lower layers */
+	(*pScrn->AdjustFrame)(scrnIndex, x, y, flags);
+	/* rewrap */
+	pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
+	pScrn->AdjustFrame         = DRIAdjustFrame;
+    }
+
+    _DRIAdjustFrame(pScrn, pDRIPriv, x, y);
+}
+
+/* WARNING WARNING WARNING: Just like every other function call in this
+   file, the DRIOpenFullScreen and DRICloseFullScreen calls are for
+   internal use only!  They should be used only by GLX internals and
+   should NEVER be called from a GL application.
+
+   Some time in the future, there will be a (proposed) standard GLX
+   extension that performs expanded functionality, that is designed for
+   used by application-level programs, and that should be portable
+   across multiple GLX implementations. */
+Bool
+DRIOpenFullScreen(ScreenPtr pScreen, DrawablePtr pDrawable)
+{
+    DRIScreenPrivPtr   pDRIPriv    = DRI_SCREEN_PRIV(pScreen);
+    ScrnInfoPtr        pScrn       = xf86Screens[pScreen->myNum];
+    WindowPtr	       pWin        = (WindowPtr)pDrawable;
+    XF86DRIClipRectPtr pClipRects  = (void *)REGION_RECTS(&pWin->clipList);
+    
+    _DRIAdjustFrame(pScrn, pDRIPriv, pScrn->frameX0, pScrn->frameY0);
+
+    if (pDrawable->type != DRAWABLE_WINDOW) return FALSE;
+
+    if (!pScrn->vtSema) return FALSE; /* switched away */
+
+    if (pDrawable->x != pScrn->frameX0
+	|| pDrawable->y != pScrn->frameY0
+	|| pDrawable->width != pScrn->frameX1 - pScrn->frameX0 + 1
+	|| pDrawable->height != pScrn->frameY1 - pScrn->frameY0 + 1) {
+	return FALSE;
+    }
+
+    if (REGION_NUM_RECTS(&pWin->clipList) != 1) return FALSE;
+    if (pDrawable->x != pClipRects[0].x1
+	|| pDrawable->y != pClipRects[0].y1
+	|| pDrawable->width != pClipRects[0].x2 - pClipRects[0].x1
+	|| pDrawable->height != pClipRects[0].y2 - pClipRects[0].y1) {
+	return FALSE;
+    }
+
+    AddResource(pDrawable->id, DRIFullScreenResType, (pointer)pWin);
+
+    xf86EnableVTSwitch(FALSE);
+    pScrn->EnableDisableFBAccess(pScreen->myNum, FALSE);
+    pScrn->vtSema        = FALSE;
+    pDRIPriv->fullscreen = pDrawable;
+    DRIClipNotify(pWin, 0, 0);
+		  
+    if (pDRIPriv->pDriverInfo->OpenFullScreen)
+	pDRIPriv->pDriverInfo->OpenFullScreen(pScreen);
+
+    pDRIPriv->pSAREA->frame.fullscreen = 1;
+    return TRUE;
+}
+
+static Bool
+_DRICloseFullScreen(pointer pResource, XID id)
+{
+    DrawablePtr      pDrawable = (DrawablePtr)pResource;
+    ScreenPtr        pScreen   = pDrawable->pScreen;
+    DRIScreenPrivPtr pDRIPriv  = DRI_SCREEN_PRIV(pScreen);
+    ScrnInfoPtr      pScrn     = xf86Screens[pScreen->myNum];
+    WindowPtr	     pWin      = (WindowPtr)pDrawable;
+    WindowOptPtr     optional  = pWin->optional;
+    Mask             mask      = pWin->eventMask;
+
+    if (pDRIPriv->pDriverInfo->CloseFullScreen)
+	pDRIPriv->pDriverInfo->CloseFullScreen(pScreen);
+
+    pDRIPriv->fullscreen = NULL;
+    pScrn->vtSema        = TRUE;
+
+				/* Turn off expose events for the top window */
+    pWin->eventMask &= ~ExposureMask;
+    pWin->optional   = NULL;
+    pScrn->EnableDisableFBAccess(pScreen->myNum, TRUE);
+    pWin->eventMask  = mask;
+    pWin->optional   = optional;
+    
+    xf86EnableVTSwitch(TRUE);
+    pDRIPriv->pSAREA->frame.fullscreen = 0;
+    return TRUE;
+}
+
+Bool
+DRICloseFullScreen(ScreenPtr pScreen, DrawablePtr pDrawable)
+{
+    FreeResourceByType(pDrawable->id, DRIFullScreenResType, FALSE);
+    return TRUE;
 }
Index: xc/programs/Xserver/GL/dri/dri.h
diff -u xc/programs/Xserver/GL/dri/dri.h:1.12 xc/programs/Xserver/GL/dri/dri.h:1.15
--- xc/programs/Xserver/GL/dri/dri.h:1.12	Fri Jun 23 15:29:41 2000
+++ xc/programs/Xserver/GL/dri/dri.h	Thu Dec  7 15:26:14 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/dri.h,v 1.12 2000/06/23 19:29:41 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/GL/dri/dri.h,v 1.15 2000/12/07 20:26:14 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -36,6 +36,9 @@
 
 #ifndef _DRI_H_
 
+#include "scrnintstr.h"
+#include "xf86dri.h"
+
 typedef int DRISyncType;
 
 #define DRI_NO_SYNC 0
@@ -71,6 +74,7 @@
 
 
 typedef void (*ClipNotifyPtr)( WindowPtr, int, int );
+typedef void (*AdjustFramePtr)(int scrnIndex, int x, int y, int flags);
 
 
 /*
@@ -87,6 +91,7 @@
     ValidateTreeProcPtr          ValidateTree;
     PostValidateTreeProcPtr      PostValidateTree;
     ClipNotifyPtr                ClipNotify;
+    AdjustFramePtr               AdjustFrame;
 } DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
 
 
@@ -110,14 +115,16 @@
 			       void* writeContextStore);
     void	(*InitBuffers)(WindowPtr pWin,
 			       RegionPtr prgn,
-			       CARD32 index);
+			       CARD32 indx);
     void	(*MoveBuffers)(WindowPtr pWin,
 			       DDXPointRec ptOldOrg,
 			       RegionPtr prgnSrc,
-			       CARD32 index);
+			       CARD32 indx);
     void        (*TransitionTo3d)(ScreenPtr pScreen);
     void        (*TransitionTo2d)(ScreenPtr pScreen);
-    void	(*SetDrawableIndex)(WindowPtr pWin, CARD32 index);
+    void	(*SetDrawableIndex)(WindowPtr pWin, CARD32 indx);
+    Bool        (*OpenFullScreen)(ScreenPtr pScreen);
+    Bool        (*CloseFullScreen)(ScreenPtr pScreen);
 
     /* wrapped functions */
     DRIWrappedFuncsRec  wrap;
@@ -193,7 +200,7 @@
 
 extern Bool DRIGetDrawableInfo(ScreenPtr pScreen,
                                DrawablePtr pDrawable,
-                               unsigned int* index,
+                               unsigned int* indx,
                                unsigned int* stamp,
                                int* X,
                                int* Y,
@@ -294,6 +301,11 @@
 extern void DRIQueryVersion(int *majorVersion,
                             int *minorVersion,
                             int *patchVersion);
+
+extern void DRIAdjustFrame(int scrnIndex, int x, int y, int flags);
+
+extern int  DRIOpenFullScreen(ScreenPtr pScreen, DrawablePtr pDrawable);
+extern int  DRICloseFullScreen(ScreenPtr pScreen, DrawablePtr pDrawable);
 
 #define _DRI_H_
 
Index: xc/programs/Xserver/GL/dri/dristruct.h
diff -u xc/programs/Xserver/GL/dri/dristruct.h:1.8 xc/programs/Xserver/GL/dri/dristruct.h:1.9
--- xc/programs/Xserver/GL/dri/dristruct.h:1.8	Fri Jun 16 20:03:12 2000
+++ xc/programs/Xserver/GL/dri/dristruct.h	Thu Dec  7 15:26:14 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/dristruct.h,v 1.8 2000/06/17 00:03:12 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/GL/dri/dristruct.h,v 1.9 2000/12/07 20:26:14 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -89,6 +89,8 @@
     DRIInfoPtr		pDriverInfo;
     int                 nrWindows;
     XF86DRIClipRectRec  private_buffer_rect; /* management of private buffers */
+    DrawablePtr         fullscreen; /* pointer to fullscreen drawable */
+    XF86DRIClipRectRec  fullscreen_rect; /* fake rect for fullscreen mode */
     DRIWrappedFuncsRec	wrap;
     DrawablePtr		DRIDrawables[SAREA_MAX_DRAWABLES];
 } DRIScreenPrivRec, *DRIScreenPrivPtr;
Index: xc/programs/Xserver/GL/dri/sarea.h
diff -u xc/programs/Xserver/GL/dri/sarea.h:1.4 xc/programs/Xserver/GL/dri/sarea.h:1.8
--- xc/programs/Xserver/GL/dri/sarea.h:1.4	Tue Feb 22 23:46:52 2000
+++ xc/programs/Xserver/GL/dri/sarea.h	Thu Dec  7 15:26:14 2000
@@ -1,7 +1,8 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/sarea.h,v 1.4 2000/02/23 04:46:52 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/GL/dri/sarea.h,v 1.8 2000/12/07 20:26:14 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -30,13 +31,24 @@
  * Authors:
  *   Kevin E. Martin <kevin@precisioninsight.com>
  *   Jens Owen <jens@precisioninsight.com>
+ *   Rickard E. (Rik) Faith <faith@valinux.com>
  *
  */
 
 #ifndef _SAREA_H_
 #define _SAREA_H_
 
-#define SAREA_MAX 			0x1000
+#include "xf86drm.h"
+
+/* SAREA area needs to be at least a page */
+#if defined(__alpha__)
+#define SAREA_MAX 			0x2000
+#elif defined(__ia64__)
+#define SAREA_MAX			0x10000		/* 64kB */
+#else
+#define SAREA_MAX			0x1000
+#endif
+
 #define SAREA_MAX_DRAWABLES 		256
 
 #define SAREA_DRAWABLE_CLAIMED_ENTRY	0x80000000
@@ -46,12 +58,21 @@
     unsigned int	flags;
 } XF86DRISAREADrawableRec, *XF86DRISAREADrawablePtr;
 
+typedef struct _XF86DRISAREAFrame {
+    unsigned int        x;
+    unsigned int        y;
+    unsigned int        width;
+    unsigned int        height;
+    unsigned int        fullscreen;
+} XF86DRISAREAFrameRec, *XF86DRISAREAFramePtr;
+
 typedef struct _XF86DRISAREA {
     /* first thing is always the drm locking structure */
     drmLock			lock;
 		/* NOT_DONE: Use readers/writer lock for drawable_lock */
     drmLock			drawable_lock;
     XF86DRISAREADrawableRec	drawableTable[SAREA_MAX_DRAWABLES];
+    XF86DRISAREAFrameRec        frame;
 } XF86DRISAREARec, *XF86DRISAREAPtr;
 
 #endif
Index: xc/programs/Xserver/GL/dri/xf86dri.c
diff -u xc/programs/Xserver/GL/dri/xf86dri.c:1.8 xc/programs/Xserver/GL/dri/xf86dri.c:1.10
--- xc/programs/Xserver/GL/dri/xf86dri.c:1.8	Sun Jun 25 12:03:43 2000
+++ xc/programs/Xserver/GL/dri/xf86dri.c	Thu Dec  7 15:26:14 2000
@@ -1,7 +1,8 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/xf86dri.c,v 1.8 2000/06/25 16:03:43 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/GL/dri/xf86dri.c,v 1.10 2000/12/07 20:26:14 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,8 +29,9 @@
 
 /*
  * Authors:
- *   Kevin E. Martin <kevin@precisioninsight.com>
- *   Jens Owen <jens@precisioninsight.com>
+ *   Kevin E. Martin <martin@valinux.com>
+ *   Jens Owen <jens@valinux.com>
+ *   Rickard E. (Rik) Faith <faith@valinux.com>
  *
  */
 
@@ -73,6 +75,8 @@
 static DISPATCH_PROC(ProcXF86DRIGetDeviceInfo);
 static DISPATCH_PROC(ProcXF86DRIDispatch);
 static DISPATCH_PROC(ProcXF86DRIAuthConnection);
+static DISPATCH_PROC(ProcXF86DRIOpenFullScreen);
+static DISPATCH_PROC(ProcXF86DRICloseFullScreen);
 
 static DISPATCH_PROC(SProcXF86DRIQueryVersion);
 static DISPATCH_PROC(SProcXF86DRIDispatch);
@@ -449,6 +453,8 @@
     if (rep.numClipRects) 
        rep.length += sizeof(XF86DRIClipRectRec) * rep.numClipRects;
     
+    rep.length = ((rep.length + 3) & ~3) >> 2;
+
     WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
 
     if (rep.numClipRects) {
@@ -502,7 +508,7 @@
     if (rep.devPrivateSize) {
 	rep.length = (SIZEOF(xXF86DRIGetDeviceInfoReply) - 
 		      SIZEOF(xGenericReply) +
-		      ((rep.devPrivateSize + 3) & ~3));
+		      ((rep.devPrivateSize + 3) & ~3)) >> 2;
     }
 
     WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
@@ -513,6 +519,57 @@
 }
 
 static int
+ProcXF86DRIOpenFullScreen (
+    register ClientPtr client
+)
+{
+    REQUEST(xXF86DRIOpenFullScreenReq);
+    xXF86DRIOpenFullScreenReply rep;
+    DrawablePtr                 pDrawable;
+
+    REQUEST_SIZE_MATCH(xXF86DRIOpenFullScreenReq);
+    rep.type           = X_Reply;
+    rep.length         = 0;
+    rep.sequenceNumber = client->sequence;
+
+    if (!(pDrawable = SecurityLookupDrawable(stuff->drawable,
+					     client, 
+					     SecurityReadAccess)))
+	return BadValue;
+
+    rep.isFullScreen = DRIOpenFullScreen(screenInfo.screens[stuff->screen],
+					 pDrawable);
+    
+    WriteToClient(client, sizeof(xXF86DRIOpenFullScreenReply), (char *)&rep);
+    return client->noClientException;
+}
+
+static int
+ProcXF86DRICloseFullScreen (
+    register ClientPtr client
+)
+{
+    REQUEST(xXF86DRICloseFullScreenReq);
+    xXF86DRICloseFullScreenReply rep;
+    DrawablePtr                  pDrawable;
+
+    REQUEST_SIZE_MATCH(xXF86DRICloseFullScreenReq);
+    rep.type           = X_Reply;
+    rep.length         = 0;
+    rep.sequenceNumber = client->sequence;
+
+    if (!(pDrawable = SecurityLookupDrawable(stuff->drawable,
+					     client, 
+					     SecurityReadAccess)))
+	return BadValue;
+    
+    DRICloseFullScreen(screenInfo.screens[stuff->screen], pDrawable);
+    
+    WriteToClient(client, sizeof(xXF86DRICloseFullScreenReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+static int
 ProcXF86DRIDispatch (
     register ClientPtr	client
 )
@@ -552,6 +609,10 @@
 	return ProcXF86DRIGetDeviceInfo(client);
     case X_XF86DRIAuthConnection:
 	return ProcXF86DRIAuthConnection(client);
+    case X_XF86DRIOpenFullScreen:
+	return ProcXF86DRIOpenFullScreen(client);
+    case X_XF86DRICloseFullScreen:
+	return ProcXF86DRICloseFullScreen(client);
     default:
 	return BadRequest;
     }
Index: xc/programs/Xserver/GL/glx/Imakefile
diff -u xc/programs/Xserver/GL/glx/Imakefile:1.7 xc/programs/Xserver/GL/glx/Imakefile:1.8
--- xc/programs/Xserver/GL/glx/Imakefile:1.7	Tue Feb 22 23:46:53 2000
+++ xc/programs/Xserver/GL/glx/Imakefile	Thu Aug 24 18:20:09 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/GL/glx/Imakefile,v 1.7 2000/02/23 04:46:53 martin Exp $
+XCOMM $XFree86: xc/programs/Xserver/GL/glx/Imakefile,v 1.8 2000/08/24 22:20:09 tsi Exp $
 
 #define IHaveModules
 #include <Server.tmpl>
@@ -43,7 +43,7 @@
 NormalLibraryObjectRule()
 #endif
 SubdirLibraryRule($(OBJS))
-NormalLibraryTarget(glx,$(OBJS))
+LibraryModuleTarget(glx,$(OBJS))
 
 LintLibraryTarget(glx,$(SRCS))
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/GL/glx/glx-def.cpp
diff -u /dev/null xc/programs/Xserver/GL/glx/glx-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:27:30 2000
+++ xc/programs/Xserver/GL/glx/glx-def.cpp	Thu Aug 10 13:40:29 2000
@@ -0,0 +1,663 @@
+LIBRARY GLX
+VERSION LIBRARY_VERSION
+EXPORTS
+__glXFBInitDrawable
+__glXFreeBuffers
+__glXPixInitDrawable
+__glXResizeBuffers
+__glXClientInfo
+__glXCopyContext
+__glXCreateContext
+__glXCreateGLXPixmap
+__glXDestroyContext
+__glXDestroyGLXPixmap
+__glXGetVisualConfigs
+__glXIsDirect
+__glXLookupContextByTag
+__glXMakeCurrent
+__glXQueryContextInfoEXT
+__glXQueryExtensionsString
+__glXQueryServerString
+__glXQueryVersion
+__glXRender
+__glXRenderLarge
+__glXSwapBuffers
+__glXVendorPrivate
+__glXVendorPrivateWithReply
+__glXWaitGL
+__glXWaitX
+__glXSwapClientInfo
+__glXSwapCopyContext
+__glXSwapCreateContext
+__glXSwapCreateGLXPixmap
+__glXSwapDestroyContext
+__glXSwapDestroyGLXPixmap
+__glXSwapGetVisualConfigs
+__glXSwapIsDirect
+__glXSwapIsDirectReply
+__glXSwapMakeCurrent
+__glXSwapMakeCurrentReply
+__glXSwapQueryContextInfoEXT
+__glXSwapQueryContextInfoEXTReply
+__glXSwapQueryExtensionsString
+__glXSwapQueryServerString
+__glXSwapQueryVersion
+__glXSwapQueryVersionReply
+__glXSwapRender
+__glXSwapRenderLarge
+__glXSwapSwapBuffers
+__glXSwapUseXFont
+__glXSwapVendorPrivate
+__glXSwapVendorPrivateWithReply
+__glXSwapWaitGL
+__glXSwapWaitX
+glxSwapQueryExtensionsStringReply
+glxSwapQueryServerStringReply
+GlxExtensionInit
+GlxInitVisuals
+GlxSetVisualConfigs
+GlxWrapInitVisuals
+__glXClearErrorOccured
+__glXCoreType
+__glXErrorCallBack
+__glXErrorOccured
+__glXFlushContextCache
+__glXForceCurrent
+__glXFreeContext
+__glXNoSuchRenderOpcode
+__glXNoSuchSingleOpcode
+__glXResetLargeCommandStatus
+__glXFBGetGC
+__glXFBMemSwapBuffers
+__glXInitFB
+__glXImpCalloc
+__glXImpFatal
+__glXImpFclose
+__glXImpFopen
+__glXImpFprintf
+__glXImpFree
+__glXImpGetDrawablePrivate
+__glXImpGetenv
+__glXImpMalloc
+__glXImpRealloc
+__glXImpSprintf
+__glXImpWarning
+__glXInitMem
+__glXInitPix
+__glXScreenInit
+__glXAssociateContext
+__glXCacheDrawableSize
+__glXCalloc
+__glXCreateDrawablePrivate
+__glXDeassociateContext
+__glXDestroyDrawablePrivate
+__glXFindDrawablePrivate
+__glXFormatGLModes
+__glXFree
+__glXGetDrawablePrivate
+__glXGetDrawableSize
+__glXMalloc
+__glXNop
+__glXRealloc
+__glXRefDrawablePrivate
+__glXResizeDrawable
+__glXResizeDrawableBuffers
+__glXUnrefDrawablePrivate
+__glXDisp_CallLists
+__glXDisp_DrawArrays
+__glXDisp_Map1d
+__glXDisp_Map1f
+__glXDisp_Map2d
+__glXDisp_Map2f
+__glXDispSwap_CallLists
+__glXDispSwap_DrawArrays
+__glXDispSwap_Map1d
+__glXDispSwap_Map1f
+__glXDispSwap_Map2d
+__glXDispSwap_Map2f
+__glXDisp_Bitmap
+__glXDisp_DrawPixels
+__glXDisp_PolygonStipple
+__glXDisp_TexImage1D
+__glXDisp_TexImage2D
+__glXDisp_TexSubImage1D
+__glXDisp_TexSubImage2D
+__glXDispSwap_Bitmap
+__glXDispSwap_DrawPixels
+__glXDispSwap_PolygonStipple
+__glXDispSwap_TexImage1D
+__glXDispSwap_TexImage2D
+__glXDispSwap_TexSubImage1D
+__glXDispSwap_TexSubImage2D
+__glXBitmapReqSize
+__glXCallListsReqSize
+__glXDrawArraysSize
+__glXDrawPixelsReqSize
+__glXFogfvReqSize
+__glXFogivReqSize
+__glXLightModelfvReqSize
+__glXLightModelivReqSize
+__glXLightfvReqSize
+__glXLightivReqSize
+__glXMap1dReqSize
+__glXMap1fReqSize
+__glXMap2dReqSize
+__glXMap2fReqSize
+__glXMaterialfvReqSize
+__glXMaterialivReqSize
+__glXPixelMapfvReqSize
+__glXPixelMapuivReqSize
+__glXPixelMapusvReqSize
+__glXPrioritizeTexturesReqSize
+__glXTexEnvfvReqSize
+__glXTexEnvivReqSize
+__glXTexGendvReqSize
+__glXTexGenfvReqSize
+__glXTexGenivReqSize
+__glXTexImage1DReqSize
+__glXTexImage2DReqSize
+__glXTexParameterfvReqSize
+__glXTexParameterivReqSize
+__glXTexSubImage1DReqSize
+__glXTexSubImage2DReqSize
+__glXTypeSize
+__glXDisp_FeedbackBuffer
+__glXDisp_Finish
+__glXDisp_Flush
+__glXDisp_GetClipPlane
+__glXDisp_GetString
+__glXDisp_RenderMode
+__glXDisp_SelectBuffer
+__glXcombine_strings
+__glXDispSwap_FeedbackBuffer
+__glXDispSwap_Finish
+__glXDispSwap_Flush
+__glXDispSwap_GetClipPlane
+__glXDispSwap_GetString
+__glXDispSwap_RenderMode
+__glXDispSwap_SelectBuffer
+__glXDisp_GetPolygonStipple
+__glXDisp_GetTexImage
+__glXDisp_ReadPixels
+__glXDispSwap_GetPolygonStipple
+__glXDispSwap_GetTexImage
+__glXDispSwap_ReadPixels
+__glGetBooleanv_size
+__glGetDoublev_size
+__glGetFloatv_size
+__glGetIntegerv_size
+__glGetLightfv_size
+__glGetLightiv_size
+__glGetMap_size
+__glGetMapdv_size
+__glGetMapfv_size
+__glGetMapiv_size
+__glGetMaterialfv_size
+__glGetMaterialiv_size
+__glGetPixelMap_size
+__glGetPixelMapfv_size
+__glGetPixelMapuiv_size
+__glGetPixelMapusv_size
+__glGetTexEnvfv_size
+__glGetTexEnviv_size
+__glGetTexGendv_size
+__glGetTexGenfv_size
+__glGetTexGeniv_size
+__glGetTexImage_size
+__glGetTexLevelParameterfv_size
+__glGetTexLevelParameteriv_size
+__glGetTexParameterfv_size
+__glGetTexParameteriv_size
+__glGet_size
+__glReadPixels_size
+__glXUseXFont
+__glXDisp_Accum
+__glXDisp_AlphaFunc
+__glXDisp_Begin
+__glXDisp_BindTexture
+__glXDisp_BlendFunc
+__glXDisp_CallList
+__glXDisp_Clear
+__glXDisp_ClearAccum
+__glXDisp_ClearColor
+__glXDisp_ClearDepth
+__glXDisp_ClearIndex
+__glXDisp_ClearStencil
+__glXDisp_ClipPlane
+__glXDisp_Color3bv
+__glXDisp_Color3dv
+__glXDisp_Color3fv
+__glXDisp_Color3iv
+__glXDisp_Color3sv
+__glXDisp_Color3ubv
+__glXDisp_Color3uiv
+__glXDisp_Color3usv
+__glXDisp_Color4bv
+__glXDisp_Color4dv
+__glXDisp_Color4fv
+__glXDisp_Color4iv
+__glXDisp_Color4sv
+__glXDisp_Color4ubv
+__glXDisp_Color4uiv
+__glXDisp_Color4usv
+__glXDisp_ColorMask
+__glXDisp_ColorMaterial
+__glXDisp_CopyPixels
+__glXDisp_CopyTexImage1D
+__glXDisp_CopyTexImage2D
+__glXDisp_CopyTexSubImage1D
+__glXDisp_CopyTexSubImage2D
+__glXDisp_CullFace
+__glXDisp_DepthFunc
+__glXDisp_DepthMask
+__glXDisp_DepthRange
+__glXDisp_Disable
+__glXDisp_DrawBuffer
+__glXDisp_EdgeFlagv
+__glXDisp_Enable
+__glXDisp_End
+__glXDisp_EvalCoord1dv
+__glXDisp_EvalCoord1fv
+__glXDisp_EvalCoord2dv
+__glXDisp_EvalCoord2fv
+__glXDisp_EvalMesh1
+__glXDisp_EvalMesh2
+__glXDisp_EvalPoint1
+__glXDisp_EvalPoint2
+__glXDisp_Fogf
+__glXDisp_Fogfv
+__glXDisp_Fogi
+__glXDisp_Fogiv
+__glXDisp_FrontFace
+__glXDisp_Frustum
+__glXDisp_Hint
+__glXDisp_IndexMask
+__glXDisp_Indexdv
+__glXDisp_Indexfv
+__glXDisp_Indexiv
+__glXDisp_Indexsv
+__glXDisp_Indexubv
+__glXDisp_InitNames
+__glXDisp_LightModelf
+__glXDisp_LightModelfv
+__glXDisp_LightModeli
+__glXDisp_LightModeliv
+__glXDisp_Lightf
+__glXDisp_Lightfv
+__glXDisp_Lighti
+__glXDisp_Lightiv
+__glXDisp_LineStipple
+__glXDisp_LineWidth
+__glXDisp_ListBase
+__glXDisp_LoadIdentity
+__glXDisp_LoadMatrixd
+__glXDisp_LoadMatrixf
+__glXDisp_LoadName
+__glXDisp_LogicOp
+__glXDisp_MapGrid1d
+__glXDisp_MapGrid1f
+__glXDisp_MapGrid2d
+__glXDisp_MapGrid2f
+__glXDisp_Materialf
+__glXDisp_Materialfv
+__glXDisp_Materiali
+__glXDisp_Materialiv
+__glXDisp_MatrixMode
+__glXDisp_MultMatrixd
+__glXDisp_MultMatrixf
+__glXDisp_Normal3bv
+__glXDisp_Normal3dv
+__glXDisp_Normal3fv
+__glXDisp_Normal3iv
+__glXDisp_Normal3sv
+__glXDisp_Ortho
+__glXDisp_PassThrough
+__glXDisp_PixelMapfv
+__glXDisp_PixelMapuiv
+__glXDisp_PixelMapusv
+__glXDisp_PixelTransferf
+__glXDisp_PixelTransferi
+__glXDisp_PixelZoom
+__glXDisp_PointSize
+__glXDisp_PolygonMode
+__glXDisp_PolygonOffset
+__glXDisp_PopAttrib
+__glXDisp_PopMatrix
+__glXDisp_PopName
+__glXDisp_PrioritizeTextures
+__glXDisp_PushAttrib
+__glXDisp_PushMatrix
+__glXDisp_PushName
+__glXDisp_RasterPos2dv
+__glXDisp_RasterPos2fv
+__glXDisp_RasterPos2iv
+__glXDisp_RasterPos2sv
+__glXDisp_RasterPos3dv
+__glXDisp_RasterPos3fv
+__glXDisp_RasterPos3iv
+__glXDisp_RasterPos3sv
+__glXDisp_RasterPos4dv
+__glXDisp_RasterPos4fv
+__glXDisp_RasterPos4iv
+__glXDisp_RasterPos4sv
+__glXDisp_ReadBuffer
+__glXDisp_Rectdv
+__glXDisp_Rectfv
+__glXDisp_Rectiv
+__glXDisp_Rectsv
+__glXDisp_Rotated
+__glXDisp_Rotatef
+__glXDisp_Scaled
+__glXDisp_Scalef
+__glXDisp_Scissor
+__glXDisp_ShadeModel
+__glXDisp_StencilFunc
+__glXDisp_StencilMask
+__glXDisp_StencilOp
+__glXDisp_TexCoord1dv
+__glXDisp_TexCoord1fv
+__glXDisp_TexCoord1iv
+__glXDisp_TexCoord1sv
+__glXDisp_TexCoord2dv
+__glXDisp_TexCoord2fv
+__glXDisp_TexCoord2iv
+__glXDisp_TexCoord2sv
+__glXDisp_TexCoord3dv
+__glXDisp_TexCoord3fv
+__glXDisp_TexCoord3iv
+__glXDisp_TexCoord3sv
+__glXDisp_TexCoord4dv
+__glXDisp_TexCoord4fv
+__glXDisp_TexCoord4iv
+__glXDisp_TexCoord4sv
+__glXDisp_TexEnvf
+__glXDisp_TexEnvfv
+__glXDisp_TexEnvi
+__glXDisp_TexEnviv
+__glXDisp_TexGend
+__glXDisp_TexGendv
+__glXDisp_TexGenf
+__glXDisp_TexGenfv
+__glXDisp_TexGeni
+__glXDisp_TexGeniv
+__glXDisp_TexParameterf
+__glXDisp_TexParameterfv
+__glXDisp_TexParameteri
+__glXDisp_TexParameteriv
+__glXDisp_Translated
+__glXDisp_Translatef
+__glXDisp_Vertex2dv
+__glXDisp_Vertex2fv
+__glXDisp_Vertex2iv
+__glXDisp_Vertex2sv
+__glXDisp_Vertex3dv
+__glXDisp_Vertex3fv
+__glXDisp_Vertex3iv
+__glXDisp_Vertex3sv
+__glXDisp_Vertex4dv
+__glXDisp_Vertex4fv
+__glXDisp_Vertex4iv
+__glXDisp_Vertex4sv
+__glXDisp_Viewport
+__glXDispSwap_Accum
+__glXDispSwap_AlphaFunc
+__glXDispSwap_Begin
+__glXDispSwap_BindTexture
+__glXDispSwap_BlendFunc
+__glXDispSwap_CallList
+__glXDispSwap_Clear
+__glXDispSwap_ClearAccum
+__glXDispSwap_ClearColor
+__glXDispSwap_ClearDepth
+__glXDispSwap_ClearIndex
+__glXDispSwap_ClearStencil
+__glXDispSwap_ClipPlane
+__glXDispSwap_Color3bv
+__glXDispSwap_Color3dv
+__glXDispSwap_Color3fv
+__glXDispSwap_Color3iv
+__glXDispSwap_Color3sv
+__glXDispSwap_Color3ubv
+__glXDispSwap_Color3uiv
+__glXDispSwap_Color3usv
+__glXDispSwap_Color4bv
+__glXDispSwap_Color4dv
+__glXDispSwap_Color4fv
+__glXDispSwap_Color4iv
+__glXDispSwap_Color4sv
+__glXDispSwap_Color4ubv
+__glXDispSwap_Color4uiv
+__glXDispSwap_Color4usv
+__glXDispSwap_ColorMask
+__glXDispSwap_ColorMaterial
+__glXDispSwap_CopyPixels
+__glXDispSwap_CopyTexImage1D
+__glXDispSwap_CopyTexImage2D
+__glXDispSwap_CopyTexSubImage1D
+__glXDispSwap_CopyTexSubImage2D
+__glXDispSwap_CullFace
+__glXDispSwap_DepthFunc
+__glXDispSwap_DepthMask
+__glXDispSwap_DepthRange
+__glXDispSwap_Disable
+__glXDispSwap_DrawBuffer
+__glXDispSwap_EdgeFlagv
+__glXDispSwap_Enable
+__glXDispSwap_End
+__glXDispSwap_EvalCoord1dv
+__glXDispSwap_EvalCoord1fv
+__glXDispSwap_EvalCoord2dv
+__glXDispSwap_EvalCoord2fv
+__glXDispSwap_EvalMesh1
+__glXDispSwap_EvalMesh2
+__glXDispSwap_EvalPoint1
+__glXDispSwap_EvalPoint2
+__glXDispSwap_Fogf
+__glXDispSwap_Fogfv
+__glXDispSwap_Fogi
+__glXDispSwap_Fogiv
+__glXDispSwap_FrontFace
+__glXDispSwap_Frustum
+__glXDispSwap_Hint
+__glXDispSwap_IndexMask
+__glXDispSwap_Indexdv
+__glXDispSwap_Indexfv
+__glXDispSwap_Indexiv
+__glXDispSwap_Indexsv
+__glXDispSwap_Indexubv
+__glXDispSwap_InitNames
+__glXDispSwap_LightModelf
+__glXDispSwap_LightModelfv
+__glXDispSwap_LightModeli
+__glXDispSwap_LightModeliv
+__glXDispSwap_Lightf
+__glXDispSwap_Lightfv
+__glXDispSwap_Lighti
+__glXDispSwap_Lightiv
+__glXDispSwap_LineStipple
+__glXDispSwap_LineWidth
+__glXDispSwap_ListBase
+__glXDispSwap_LoadIdentity
+__glXDispSwap_LoadMatrixd
+__glXDispSwap_LoadMatrixf
+__glXDispSwap_LoadName
+__glXDispSwap_LogicOp
+__glXDispSwap_MapGrid1d
+__glXDispSwap_MapGrid1f
+__glXDispSwap_MapGrid2d
+__glXDispSwap_MapGrid2f
+__glXDispSwap_Materialf
+__glXDispSwap_Materialfv
+__glXDispSwap_Materiali
+__glXDispSwap_Materialiv
+__glXDispSwap_MatrixMode
+__glXDispSwap_MultMatrixd
+__glXDispSwap_MultMatrixf
+__glXDispSwap_Normal3bv
+__glXDispSwap_Normal3dv
+__glXDispSwap_Normal3fv
+__glXDispSwap_Normal3iv
+__glXDispSwap_Normal3sv
+__glXDispSwap_Ortho
+__glXDispSwap_PassThrough
+__glXDispSwap_PixelMapfv
+__glXDispSwap_PixelMapuiv
+__glXDispSwap_PixelMapusv
+__glXDispSwap_PixelTransferf
+__glXDispSwap_PixelTransferi
+__glXDispSwap_PixelZoom
+__glXDispSwap_PointSize
+__glXDispSwap_PolygonMode
+__glXDispSwap_PolygonOffset
+__glXDispSwap_PopAttrib
+__glXDispSwap_PopMatrix
+__glXDispSwap_PopName
+__glXDispSwap_PrioritizeTextures
+__glXDispSwap_PushAttrib
+__glXDispSwap_PushMatrix
+__glXDispSwap_PushName
+__glXDispSwap_RasterPos2dv
+__glXDispSwap_RasterPos2fv
+__glXDispSwap_RasterPos2iv
+__glXDispSwap_RasterPos2sv
+__glXDispSwap_RasterPos3dv
+__glXDispSwap_RasterPos3fv
+__glXDispSwap_RasterPos3iv
+__glXDispSwap_RasterPos3sv
+__glXDispSwap_RasterPos4dv
+__glXDispSwap_RasterPos4fv
+__glXDispSwap_RasterPos4iv
+__glXDispSwap_RasterPos4sv
+__glXDispSwap_ReadBuffer
+__glXDispSwap_Rectdv
+__glXDispSwap_Rectfv
+__glXDispSwap_Rectiv
+__glXDispSwap_Rectsv
+__glXDispSwap_Rotated
+__glXDispSwap_Rotatef
+__glXDispSwap_Scaled
+__glXDispSwap_Scalef
+__glXDispSwap_Scissor
+__glXDispSwap_ShadeModel
+__glXDispSwap_StencilFunc
+__glXDispSwap_StencilMask
+__glXDispSwap_StencilOp
+__glXDispSwap_TexCoord1dv
+__glXDispSwap_TexCoord1fv
+__glXDispSwap_TexCoord1iv
+__glXDispSwap_TexCoord1sv
+__glXDispSwap_TexCoord2dv
+__glXDispSwap_TexCoord2fv
+__glXDispSwap_TexCoord2iv
+__glXDispSwap_TexCoord2sv
+__glXDispSwap_TexCoord3dv
+__glXDispSwap_TexCoord3fv
+__glXDispSwap_TexCoord3iv
+__glXDispSwap_TexCoord3sv
+__glXDispSwap_TexCoord4dv
+__glXDispSwap_TexCoord4fv
+__glXDispSwap_TexCoord4iv
+__glXDispSwap_TexCoord4sv
+__glXDispSwap_TexEnvf
+__glXDispSwap_TexEnvfv
+__glXDispSwap_TexEnvi
+__glXDispSwap_TexEnviv
+__glXDispSwap_TexGend
+__glXDispSwap_TexGendv
+__glXDispSwap_TexGenf
+__glXDispSwap_TexGenfv
+__glXDispSwap_TexGeni
+__glXDispSwap_TexGeniv
+__glXDispSwap_TexParameterf
+__glXDispSwap_TexParameterfv
+__glXDispSwap_TexParameteri
+__glXDispSwap_TexParameteriv
+__glXDispSwap_Translated
+__glXDispSwap_Translatef
+__glXDispSwap_Vertex2dv
+__glXDispSwap_Vertex2fv
+__glXDispSwap_Vertex2iv
+__glXDispSwap_Vertex2sv
+__glXDispSwap_Vertex3dv
+__glXDispSwap_Vertex3fv
+__glXDispSwap_Vertex3iv
+__glXDispSwap_Vertex3sv
+__glXDispSwap_Vertex4dv
+__glXDispSwap_Vertex4fv
+__glXDispSwap_Vertex4iv
+__glXDispSwap_Vertex4sv
+__glXDispSwap_Viewport
+__glXDisp_AreTexturesResident
+__glXDisp_DeleteLists
+__glXDisp_DeleteTextures
+__glXDisp_EndList
+__glXDisp_GenLists
+__glXDisp_GenTextures
+__glXDisp_GetBooleanv
+__glXDisp_GetDoublev
+__glXDisp_GetError
+__glXDisp_GetFloatv
+__glXDisp_GetIntegerv
+__glXDisp_GetLightfv
+__glXDisp_GetLightiv
+__glXDisp_GetMapdv
+__glXDisp_GetMapfv
+__glXDisp_GetMapiv
+__glXDisp_GetMaterialfv
+__glXDisp_GetMaterialiv
+__glXDisp_GetPixelMapfv
+__glXDisp_GetPixelMapuiv
+__glXDisp_GetPixelMapusv
+__glXDisp_GetTexEnvfv
+__glXDisp_GetTexEnviv
+__glXDisp_GetTexGendv
+__glXDisp_GetTexGenfv
+__glXDisp_GetTexGeniv
+__glXDisp_GetTexLevelParameterfv
+__glXDisp_GetTexLevelParameteriv
+__glXDisp_GetTexParameterfv
+__glXDisp_GetTexParameteriv
+__glXDisp_IsEnabled
+__glXDisp_IsList
+__glXDisp_IsTexture
+__glXDisp_NewList
+__glXDisp_PixelStoref
+__glXDisp_PixelStorei
+__glXDispSwap_AreTexturesResident
+__glXDispSwap_DeleteLists
+__glXDispSwap_DeleteTextures
+__glXDispSwap_EndList
+__glXDispSwap_GenLists
+__glXDispSwap_GenTextures
+__glXDispSwap_GetBooleanv
+__glXDispSwap_GetDoublev
+__glXDispSwap_GetError
+__glXDispSwap_GetFloatv
+__glXDispSwap_GetIntegerv
+__glXDispSwap_GetLightfv
+__glXDispSwap_GetLightiv
+__glXDispSwap_GetMapdv
+__glXDispSwap_GetMapfv
+__glXDispSwap_GetMapiv
+__glXDispSwap_GetMaterialfv
+__glXDispSwap_GetMaterialiv
+__glXDispSwap_GetPixelMapfv
+__glXDispSwap_GetPixelMapuiv
+__glXDispSwap_GetPixelMapusv
+__glXDispSwap_GetTexEnvfv
+__glXDispSwap_GetTexEnviv
+__glXDispSwap_GetTexGendv
+__glXDispSwap_GetTexGenfv
+__glXDispSwap_GetTexGeniv
+__glXDispSwap_GetTexLevelParameterfv
+__glXDispSwap_GetTexLevelParameteriv
+__glXDispSwap_GetTexParameterfv
+__glXDispSwap_GetTexParameteriv
+__glXDispSwap_IsEnabled
+__glXDispSwap_IsList
+__glXDispSwap_IsTexture
+__glXDispSwap_NewList
+__glXDispSwap_PixelStoref
+__glXDispSwap_PixelStorei
+
+/* $XFree86: xc/programs/Xserver/GL/glx/glx-def.cpp,v 1.1 2000/08/10 17:40:29 dawes Exp $ */
Index: xc/programs/Xserver/GL/glx/glxext.c
diff -u xc/programs/Xserver/GL/glx/glxext.c:1.4 xc/programs/Xserver/GL/glx/glxext.c:1.5
--- xc/programs/Xserver/GL/glx/glxext.c:1.4	Mon Jun 14 03:31:26 1999
+++ xc/programs/Xserver/GL/glx/glxext.c	Tue Sep 26 11:57:02 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/GL/glx/glxext.c,v 1.4 1999/06/14 07:31:26 dawes Exp $
+/* $XFree86: xc/programs/Xserver/GL/glx/glxext.c,v 1.5 2000/09/26 15:57:02 tsi Exp $
 ** The contents of this file are subject to the GLX Public License Version 1.0
 ** (the "License"). You may not use this file except in compliance with the
 ** License. You may obtain a copy of the License at Silicon Graphics, Inc.,
@@ -402,7 +402,7 @@
 	** with the client so we will be notified when the client dies.
 	*/
 	XID xid = FakeClientID(client->index);
-	if (!AddResource( xid, __glXClientRes, (pointer)client->index))  {
+	if (!AddResource( xid, __glXClientRes, (pointer)(long)client->index)) {
 	    return BadAlloc;
 	}
 	ResetClientState(client->index);
@@ -457,7 +457,7 @@
 	** with the client so we will be notified when the client dies.
 	*/
 	XID xid = FakeClientID(client->index);
-	if (!AddResource( xid, __glXClientRes, (pointer)client->index))  {
+	if (!AddResource( xid, __glXClientRes, (pointer)(long)client->index)) {
 	    return BadAlloc;
 	}
 	ResetClientState(client->index);
Index: xc/programs/Xserver/GL/glx/glxpix.c
diff -u xc/programs/Xserver/GL/glx/glxpix.c:1.2 xc/programs/Xserver/GL/glx/glxpix.c:1.3
--- xc/programs/Xserver/GL/glx/glxpix.c:1.2	Mon Jun 14 03:31:31 1999
+++ xc/programs/Xserver/GL/glx/glxpix.c	Tue Sep 26 11:57:02 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/GL/glx/glxpix.c,v 1.2 1999/06/14 07:31:31 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/GL/glx/glxpix.c,v 1.3 2000/09/26 15:57:02 tsi Exp $ */
 /*
 ** The contents of this file are subject to the GLX Public License Version 1.0
 ** (the "License"). You may not use this file except in compliance with the
@@ -67,8 +67,8 @@
 {
     __GLPixBufferInfo *bufferInfo;
 
-    if (LookupIDByType((XID)buf->handle, __glXPixmapRes)) {
-	FreeResource((XID)buf->handle, FALSE);
+    if (LookupIDByType((XID)(long)buf->handle, __glXPixmapRes)) {
+	FreeResource((XID)(long)buf->handle, FALSE);
 	buf->handle = NULL;
     }
 
@@ -96,7 +96,7 @@
     buf->elementSize = ((bits-1) / 8) + 1;
     buf->elementSizeLog2 = __glFloorLog2(buf->elementSize);
 
-    buf->handle = (void *) glxpixmapId;
+    buf->handle = (void *)(long) glxpixmapId;
     pGlxPixmap->refcnt++;
 
     buf->resize = Resize;
Index: xc/programs/Xserver/GL/mesa/include/GL/Imakefile
diff -u xc/programs/Xserver/GL/mesa/include/GL/Imakefile:1.5 xc/programs/Xserver/GL/mesa/include/GL/Imakefile:1.6
--- xc/programs/Xserver/GL/mesa/include/GL/Imakefile:1.5	Fri Jun 30 14:27:01 2000
+++ xc/programs/Xserver/GL/mesa/include/GL/Imakefile	Tue Aug  1 16:28:39 2000
@@ -1,13 +1,13 @@
-XCOMM $XFree86: xc/programs/Xserver/GL/mesa/include/GL/Imakefile,v 1.5 2000/06/30 18:27:01 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/include/GL/Imakefile,v 1.6 2000/08/01 20:28:39 dawes Exp $
 
 #define IHaveModules
 #include <Server.tmpl>
 
       DEFINES = $(GLX_DEFINES)
 
-LinkSourceFile(gl.h, ../../../../../../extras/Mesa/include/GL)
-LinkSourceFile(glx.h, ../../../../../../../xc/include/GL)
-LinkSourceFile(glxtokens.h, ../../../../../../../xc/include/GL)
-LinkSourceFile(xmesa.h, ../../../../../../extras/Mesa/include/GL)
-LinkSourceFile(xmesa_x.h, ../../../../../../extras/Mesa/include/GL)
-LinkSourceFile(xmesa_xf86.h, ../../../../../../extras/Mesa/include/GL)
+LinkSourceFile(gl.h, $(MESASRCDIR)/include/GL)
+LinkSourceFile(glx.h, $(TOP)/include/GL)
+LinkSourceFile(glxtokens.h, $(TOP)/include/GL)
+LinkSourceFile(xmesa.h, $(MESASRCDIR)/include/GL)
+LinkSourceFile(xmesa_x.h, $(MESASRCDIR)/include/GL)
+LinkSourceFile(xmesa_xf86.h, $(MESASRCDIR)/include/GL)
Index: xc/programs/Xserver/GL/mesa/src/GLcore-def.cpp
diff -u /dev/null xc/programs/Xserver/GL/mesa/src/GLcore-def.cpp:1.1
--- /dev/null	Mon Dec 18 14:27:31 2000
+++ xc/programs/Xserver/GL/mesa/src/GLcore-def.cpp	Thu Aug 10 13:40:29 2000
@@ -0,0 +1,1483 @@
+LIBRARY GLcore
+VERSION LIBRARY_VERSION
+EXPORTS
+
+_mesa_set_aa_triangle_function
+_mesa_Accum
+_mesa_ClearAccum
+_mesa_alloc_accum_buffer
+_mesa_clear_accum_buffer
+_mesa_AlphaFunc
+_mesa_alpha_test
+_mesa_alloc_alpha_buffers
+_mesa_clear_alpha_buffers
+_mesa_read_alpha_pixels
+_mesa_read_alpha_span
+_mesa_write_alpha_pixels
+_mesa_write_alpha_span
+_mesa_write_mono_alpha_pixels
+_mesa_write_mono_alpha_span
+_mesa_PopAttrib
+_mesa_PopClientAttrib
+_mesa_PushAttrib
+_mesa_PushClientAttrib
+_mesa_Bitmap
+_mesa_BlendColor
+_mesa_BlendEquation
+_mesa_BlendFunc
+_mesa_BlendFuncSeparateEXT
+_mesa_blend_pixels
+_mesa_blend_span
+_mesa_Clear
+_mesa_ClearColor
+_mesa_ClearIndex
+_mesa_DrawBuffer
+_mesa_ReadBuffer
+_mesa_ResizeBuffersMESA
+_mesa_ClipPlane
+_mesa_GetClipPlane
+gl_init_clip
+gl_update_clipmask
+gl_update_userclip
+gl_user_cliptest
+gl_userclip_point
+gl_viewclip_point
+_mesa_ColorSubTable
+_mesa_ColorTable
+_mesa_ColorTableParameterfv
+_mesa_ColorTableParameteriv
+_mesa_CopyColorSubTable
+_mesa_CopyColorTable
+_mesa_GetColorTable
+_mesa_GetColorTableParameterfv
+_mesa_GetColorTableParameteriv
+_mesa_free_colortable_data
+_mesa_init_colortable
+gl_read_config_file
+gl_register_config_var
+_mesa_Finish
+_mesa_Flush
+_mesa_create_visual
+_mesa_destroy_visual
+_mesa_get_dispatch
+_mesa_initialize_context
+_mesa_initialize_framebuffer
+_mesa_initialize_visual
+_mesa_swapbuffers
+gl_compile_error
+gl_context_initialize
+gl_copy_context
+gl_create_context
+gl_create_framebuffer
+gl_create_visual
+gl_destroy_context
+gl_destroy_framebuffer
+gl_destroy_visual
+gl_error
+gl_free_context_data
+gl_get_current_context
+gl_make_current
+gl_make_current2
+gl_problem
+gl_warning
+_mesa_CopyPixels
+_mesa_LockArraysEXT
+_mesa_UnlockArraysEXT
+gl_alloc_cva_store
+gl_cva_compile_cassette
+gl_cva_force_precalc
+gl_cva_init
+gl_free_cva_store
+gl_merge_cva
+gl_prepare_arrays_cva
+gl_rescue_cva
+_mesa_ClearDepth
+_mesa_DepthFunc
+_mesa_DepthMask
+_mesa_alloc_depth_buffer
+_mesa_clear_depth_buffer
+_mesa_depth_test_pixels
+_mesa_depth_test_span
+_mesa_read_depth_span
+_mesa_read_depth_span_float
+_mesa_zbuffer_address
+glAccum
+glActiveTextureARB
+glAlphaFunc
+glAreTexturesResident
+glAreTexturesResidentEXT
+glArrayElement
+glArrayElementEXT
+glBegin
+glBindTexture
+glBindTextureEXT
+glBitmap
+glBlendColor
+glBlendColorEXT
+glBlendEquation
+glBlendEquationEXT
+glBlendFunc
+glBlendFuncSeparateEXT
+glBlendFuncSeparateINGR
+glCallList
+glCallLists
+glClear
+glClearAccum
+glClearColor
+glClearDepth
+glClearIndex
+glClearStencil
+glClientActiveTextureARB
+glClipPlane
+glColor3b
+glColor3bv
+glColor3d
+glColor3dv
+glColor3f
+glColor3fv
+glColor3i
+glColor3iv
+glColor3s
+glColor3sv
+glColor3ub
+glColor3ubv
+glColor3ui
+glColor3uiv
+glColor3us
+glColor3usv
+glColor4b
+glColor4bv
+glColor4d
+glColor4dv
+glColor4f
+glColor4fv
+glColor4i
+glColor4iv
+glColor4s
+glColor4sv
+glColor4ub
+glColor4ubv
+glColor4ui
+glColor4uiv
+glColor4us
+glColor4usv
+glColorMask
+glColorMaterial
+glColorPointer
+glColorPointerEXT
+glColorSubTable
+glColorSubTableEXT
+glColorTable
+glColorTableEXT
+glColorTableParameterfv
+glColorTableParameterfvSGI
+glColorTableParameteriv
+glColorTableParameterivSGI
+glColorTableSGI
+glCombinerInputNV
+glCombinerOutputNV
+glCombinerParameterfNV
+glCombinerParameterfvNV
+glCombinerParameteriNV
+glCombinerParameterivNV
+glCompressedTexImage1DARB
+glCompressedTexImage2DARB
+glCompressedTexImage3DARB
+glCompressedTexSubImage1DARB
+glCompressedTexSubImage2DARB
+glCompressedTexSubImage3DARB
+glConvolutionFilter1D
+glConvolutionFilter1DEXT
+glConvolutionFilter2D
+glConvolutionFilter2DEXT
+glConvolutionParameterf
+glConvolutionParameterfEXT
+glConvolutionParameterfv
+glConvolutionParameterfvEXT
+glConvolutionParameteri
+glConvolutionParameteriEXT
+glConvolutionParameteriv
+glConvolutionParameterivEXT
+glCopyColorSubTable
+glCopyColorSubTableEXT
+glCopyColorTable
+glCopyColorTableSGI
+glCopyConvolutionFilter1D
+glCopyConvolutionFilter1DEXT
+glCopyConvolutionFilter2D
+glCopyConvolutionFilter2DEXT
+glCopyPixels
+glCopyTexImage1D
+glCopyTexImage1DEXT
+glCopyTexImage2D
+glCopyTexImage2DEXT
+glCopyTexSubImage1D
+glCopyTexSubImage1DEXT
+glCopyTexSubImage2D
+glCopyTexSubImage2DEXT
+glCopyTexSubImage3D
+glCopyTexSubImage3DEXT
+glCullFace
+glCullParameterdvEXT
+glCullParameterfvEXT
+glDeleteLists
+glDeleteTextures
+glDeleteTexturesEXT
+glDepthFunc
+glDepthMask
+glDepthRange
+glDetailTexFuncSGIS
+glDisable
+glDisableClientState
+glDrawArrays
+glDrawArraysEXT
+glDrawBuffer
+glDrawElements
+glDrawPixels
+glDrawRangeElements
+glDrawRangeElementsEXT
+glEdgeFlag
+glEdgeFlagPointer
+glEdgeFlagPointerEXT
+glEdgeFlagv
+glEnable
+glEnableClientState
+glEnd
+glEndList
+glEvalCoord1d
+glEvalCoord1dv
+glEvalCoord1f
+glEvalCoord1fv
+glEvalCoord2d
+glEvalCoord2dv
+glEvalCoord2f
+glEvalCoord2fv
+glEvalMesh1
+glEvalMesh2
+glEvalPoint1
+glEvalPoint2
+glFeedbackBuffer
+glFinalCombinerInputNV
+glFinish
+glFlush
+glFlushRasterSGIX
+glFlushVertexArrayRangeNV
+glFogCoordPointerEXT
+glFogCoorddEXT
+glFogCoorddvEXT
+glFogCoordfEXT
+glFogCoordfvEXT
+glFogf
+glFogfv
+glFogi
+glFogiv
+glFragmentColorMaterialSGIX
+glFragmentLightModelfSGIX
+glFragmentLightModelfvSGIX
+glFragmentLightModeliSGIX
+glFragmentLightModelivSGIX
+glFragmentLightfSGIX
+glFragmentLightfvSGIX
+glFragmentLightiSGIX
+glFragmentLightivSGIX
+glFragmentMaterialfSGIX
+glFragmentMaterialfvSGIX
+glFragmentMaterialiSGIX
+glFragmentMaterialivSGIX
+glFrameZoomSGIX
+glFrontFace
+glFrustum
+glGenLists
+glGenTextures
+glGenTexturesEXT
+glGetBooleanv
+glGetClipPlane
+glGetColorTable
+glGetColorTableEXT
+glGetColorTableParameterfv
+glGetColorTableParameterfvEXT
+glGetColorTableParameterfvSGI
+glGetColorTableParameteriv
+glGetColorTableParameterivEXT
+glGetColorTableParameterivSGI
+glGetColorTableSGI
+glGetCombinerInputParameterfvNV
+glGetCombinerInputParameterivNV
+glGetCombinerOutputParameterfvNV
+glGetCombinerOutputParameterivNV
+glGetCompressedTexImageARB
+glGetConvolutionFilter
+glGetConvolutionFilterEXT
+glGetConvolutionParameterfv
+glGetConvolutionParameterfvEXT
+glGetConvolutionParameteriv
+glGetConvolutionParameterivEXT
+glGetDetailTexFuncSGIS
+glGetDoublev
+glGetError
+glGetFinalCombinerInputParameterfvNV
+glGetFinalCombinerInputParameterivNV
+glGetFloatv
+glGetFragmentLightfvSGIX
+glGetFragmentLightivSGIX
+glGetFragmentMaterialfvSGIX
+glGetFragmentMaterialivSGIX
+glGetHistogram
+glGetHistogramEXT
+glGetHistogramParameterfv
+glGetHistogramParameterfvEXT
+glGetHistogramParameteriv
+glGetHistogramParameterivEXT
+glGetInstrumentsSGIX
+glGetIntegerv
+glGetLightfv
+glGetLightiv
+glGetListParameterfvSGIX
+glGetListParameterivSGIX
+glGetMapdv
+glGetMapfv
+glGetMapiv
+glGetMaterialfv
+glGetMaterialiv
+glGetMinmax
+glGetMinmaxEXT
+glGetMinmaxParameterfv
+glGetMinmaxParameterfvEXT
+glGetMinmaxParameteriv
+glGetMinmaxParameterivEXT
+glGetPixelMapfv
+glGetPixelMapuiv
+glGetPixelMapusv
+glGetPixelTexGenParameterfvSGIS
+glGetPixelTexGenParameterivSGIS
+glGetPointerv
+glGetPointervEXT
+glGetPolygonStipple
+glGetSeparableFilter
+glGetSeparableFilterEXT
+glGetSharpenTexFuncSGIS
+glGetString
+glGetTexEnvfv
+glGetTexEnviv
+glGetTexFilterFuncSGIS
+glGetTexGendv
+glGetTexGenfv
+glGetTexGeniv
+glGetTexImage
+glGetTexLevelParameterfv
+glGetTexLevelParameteriv
+glGetTexParameterfv
+glGetTexParameteriv
+glHint
+glHintPGI
+glHistogram
+glHistogramEXT
+glIndexFuncEXT
+glIndexMask
+glIndexMaterialEXT
+glIndexPointer
+glIndexPointerEXT
+glIndexd
+glIndexdv
+glIndexf
+glIndexfv
+glIndexi
+glIndexiv
+glIndexs
+glIndexsv
+glIndexub
+glIndexubv
+glInitNames
+glInstrumentsBufferSGIX
+glInterleavedArrays
+glIsEnabled
+glIsList
+glIsTexture
+glIsTextureEXT
+glLightEnviSGIX
+glLightModelf
+glLightModelfv
+glLightModeli
+glLightModeliv
+glLightf
+glLightfv
+glLighti
+glLightiv
+glLineStipple
+glLineWidth
+glListBase
+glListParameterfSGIX
+glListParameterfvSGIX
+glListParameteriSGIX
+glListParameterivSGIX
+glLoadIdentity
+glLoadMatrixd
+glLoadMatrixf
+glLoadName
+glLoadTransposeMatrixdARB
+glLoadTransposeMatrixfARB
+glLockArraysEXT
+glLogicOp
+glMap1d
+glMap1f
+glMap2d
+glMap2f
+glMapGrid1d
+glMapGrid1f
+glMapGrid2d
+glMapGrid2f
+glMaterialf
+glMaterialfv
+glMateriali
+glMaterialiv
+glMatrixMode
+glMinmax
+glMinmaxEXT
+glMultMatrixd
+glMultMatrixf
+glMultTransposeMatrixdARB
+glMultTransposeMatrixfARB
+glMultiTexCoord1dARB
+glMultiTexCoord1dvARB
+glMultiTexCoord1fARB
+glMultiTexCoord1fvARB
+glMultiTexCoord1iARB
+glMultiTexCoord1ivARB
+glMultiTexCoord1sARB
+glMultiTexCoord1svARB
+glMultiTexCoord2dARB
+glMultiTexCoord2dvARB
+glMultiTexCoord2fARB
+glMultiTexCoord2fvARB
+glMultiTexCoord2iARB
+glMultiTexCoord2ivARB
+glMultiTexCoord2sARB
+glMultiTexCoord2svARB
+glMultiTexCoord3dARB
+glMultiTexCoord3dvARB
+glMultiTexCoord3fARB
+glMultiTexCoord3fvARB
+glMultiTexCoord3iARB
+glMultiTexCoord3ivARB
+glMultiTexCoord3sARB
+glMultiTexCoord3svARB
+glMultiTexCoord4dARB
+glMultiTexCoord4dvARB
+glMultiTexCoord4fARB
+glMultiTexCoord4fvARB
+glMultiTexCoord4iARB
+glMultiTexCoord4ivARB
+glMultiTexCoord4sARB
+glMultiTexCoord4svARB
+glNewList
+glNormal3b
+glNormal3bv
+glNormal3d
+glNormal3dv
+glNormal3f
+glNormal3fv
+glNormal3i
+glNormal3iv
+glNormal3s
+glNormal3sv
+glNormalPointer
+glNormalPointerEXT
+glOrtho
+glPassThrough
+glPixelMapfv
+glPixelMapuiv
+glPixelMapusv
+glPixelStoref
+glPixelStorei
+glPixelTexGenParameterfSGIS
+glPixelTexGenParameterfvSGIS
+glPixelTexGenParameteriSGIS
+glPixelTexGenParameterivSGIS
+glPixelTexGenSGIX
+glPixelTransferf
+glPixelTransferi
+glPixelZoom
+glPointParameterfEXT
+glPointParameterfSGIS
+glPointParameterfvEXT
+glPointParameterfvSGIS
+glPointSize
+glPollInstrumentsSGIX
+glPolygonMode
+glPolygonOffset
+glPolygonOffsetEXT
+glPolygonStipple
+glPopAttrib
+glPopClientAttrib
+glPopMatrix
+glPopName
+glPrioritizeTextures
+glPrioritizeTexturesEXT
+glPushAttrib
+glPushClientAttrib
+glPushMatrix
+glPushName
+glRasterPos2d
+glRasterPos2dv
+glRasterPos2f
+glRasterPos2fv
+glRasterPos2i
+glRasterPos2iv
+glRasterPos2s
+glRasterPos2sv
+glRasterPos3d
+glRasterPos3dv
+glRasterPos3f
+glRasterPos3fv
+glRasterPos3i
+glRasterPos3iv
+glRasterPos3s
+glRasterPos3sv
+glRasterPos4d
+glRasterPos4dv
+glRasterPos4f
+glRasterPos4fv
+glRasterPos4i
+glRasterPos4iv
+glRasterPos4s
+glRasterPos4sv
+glReadBuffer
+glReadInstrumentsSGIX
+glReadPixels
+glRectd
+glRectdv
+glRectf
+glRectfv
+glRecti
+glRectiv
+glRects
+glRectsv
+glReferencePlaneSGIX
+glRenderMode
+glResetHistogram
+glResetHistogramEXT
+glResetMinmax
+glResetMinmaxEXT
+glResizeBuffersMESA
+glRotated
+glRotatef
+glSampleCoverageARB
+glSampleMaskEXT
+glSampleMaskSGIS
+glSamplePassARB
+glSamplePatternEXT
+glSamplePatternSGIS
+glScaled
+glScalef
+glScissor
+glSelectBuffer
+glSeparableFilter2D
+glSeparableFilter2DEXT
+glShadeModel
+glSharpenTexFuncSGIS
+glSpriteParameterfSGIX
+glSpriteParameterfvSGIX
+glSpriteParameteriSGIX
+glSpriteParameterivSGIX
+glStartInstrumentsSGIX
+glStencilFunc
+glStencilMask
+glStencilOp
+glStopInstrumentsSGIX
+glTagSampleBufferSGIX
+glTbufferMask3DFX
+glTexCoord1d
+glTexCoord1dv
+glTexCoord1f
+glTexCoord1fv
+glTexCoord1i
+glTexCoord1iv
+glTexCoord1s
+glTexCoord1sv
+glTexCoord2d
+glTexCoord2dv
+glTexCoord2f
+glTexCoord2fv
+glTexCoord2i
+glTexCoord2iv
+glTexCoord2s
+glTexCoord2sv
+glTexCoord3d
+glTexCoord3dv
+glTexCoord3f
+glTexCoord3fv
+glTexCoord3i
+glTexCoord3iv
+glTexCoord3s
+glTexCoord3sv
+glTexCoord4d
+glTexCoord4dv
+glTexCoord4f
+glTexCoord4fv
+glTexCoord4i
+glTexCoord4iv
+glTexCoord4s
+glTexCoord4sv
+glTexCoordPointer
+glTexCoordPointerEXT
+glTexEnvf
+glTexEnvfv
+glTexEnvi
+glTexEnviv
+glTexFilterFuncSGIS
+glTexGend
+glTexGendv
+glTexGenf
+glTexGenfv
+glTexGeni
+glTexGeniv
+glTexImage1D
+glTexImage2D
+glTexImage3D
+glTexImage3DEXT
+glTexImage4DSGIS
+glTexParameterf
+glTexParameterfv
+glTexParameteri
+glTexParameteriv
+glTexSubImage1D
+glTexSubImage1DEXT
+glTexSubImage2D
+glTexSubImage2DEXT
+glTexSubImage3D
+glTexSubImage3DEXT
+glTexSubImage4DSGIS
+glTranslated
+glTranslatef
+glUnlockArraysEXT
+glVertex2d
+glVertex2dv
+glVertex2f
+glVertex2fv
+glVertex2i
+glVertex2iv
+glVertex2s
+glVertex2sv
+glVertex3d
+glVertex3dv
+glVertex3f
+glVertex3fv
+glVertex3i
+glVertex3iv
+glVertex3s
+glVertex3sv
+glVertex4d
+glVertex4dv
+glVertex4f
+glVertex4fv
+glVertex4i
+glVertex4iv
+glVertex4s
+glVertex4sv
+glVertexArrayRangeNV
+glVertexPointer
+glVertexPointerEXT
+glVertexWeightPointerEXT
+glVertexWeightfEXT
+glVertexWeightfvEXT
+glViewport
+glWindowPos2dMESA
+glWindowPos2dvMESA
+glWindowPos2fMESA
+glWindowPos2fvMESA
+glWindowPos2iMESA
+glWindowPos2ivMESA
+glWindowPos2sMESA
+glWindowPos2svMESA
+glWindowPos3dMESA
+glWindowPos3dvMESA
+glWindowPos3fMESA
+glWindowPos3fvMESA
+glWindowPos3iMESA
+glWindowPos3ivMESA
+glWindowPos3sMESA
+glWindowPos3svMESA
+glWindowPos4dMESA
+glWindowPos4dvMESA
+glWindowPos4fMESA
+glWindowPos4fvMESA
+glWindowPos4iMESA
+glWindowPos4ivMESA
+glWindowPos4sMESA
+glWindowPos4svMESA
+_mesa_CallList
+_mesa_CallLists
+_mesa_DeleteLists
+_mesa_EndList
+_mesa_GenLists
+_mesa_IsList
+_mesa_ListBase
+_mesa_NewList
+_mesa_init_dlist_table
+gl_compile_cassette
+gl_destroy_list
+gl_init_lists
+gl_save_error
+mesa_print_display_list
+_mesa_DrawPixels
+_mesa_clip_pixelrect
+_mesa_Disable
+_mesa_DisableClientState
+_mesa_Enable
+_mesa_EnableClientState
+_mesa_IsEnabled
+_mesa_set_enable
+gl_lookup_enum_by_name
+gl_lookup_enum_by_nr
+_mesa_EvalCoord1d
+_mesa_EvalCoord1dv
+_mesa_EvalCoord1f
+_mesa_EvalCoord1fv
+_mesa_EvalCoord2d
+_mesa_EvalCoord2dv
+_mesa_EvalCoord2f
+_mesa_EvalCoord2fv
+_mesa_EvalMesh1
+_mesa_EvalMesh2
+_mesa_EvalPoint1
+_mesa_EvalPoint2
+_mesa_GetMapdv
+_mesa_GetMapfv
+_mesa_GetMapiv
+_mesa_Map1d
+_mesa_Map1f
+_mesa_Map2d
+_mesa_Map2f
+_mesa_MapGrid1d
+_mesa_MapGrid1f
+_mesa_MapGrid2d
+_mesa_MapGrid2f
+_mesa_evaluator_components
+gl_copy_map_points1d
+gl_copy_map_points1f
+gl_copy_map_points2d
+gl_copy_map_points2f
+gl_eval_vb
+gl_init_eval
+gl_extension_is_enabled
+gl_extensions_add
+gl_extensions_ctr
+gl_extensions_disable
+gl_extensions_dtr
+gl_extensions_enable
+gl_extensions_get_string
+_mesa_FeedbackBuffer
+_mesa_InitNames
+_mesa_LoadName
+_mesa_PassThrough
+_mesa_PopName
+_mesa_PushName
+_mesa_RenderMode
+_mesa_SelectBuffer
+gl_feedback_line
+gl_feedback_points
+gl_feedback_triangle
+gl_feedback_vertex
+gl_select_line
+gl_select_points
+gl_select_triangle
+gl_update_hitflag
+_mesa_Fogf
+_mesa_Fogfv
+_mesa_Fogi
+_mesa_Fogiv
+_mesa_fog_ci_pixels
+_mesa_fog_rgba_pixels
+_mesa_fog_vertices
+_mesa_init_fog
+_mesa_GetBooleanv
+_mesa_GetDoublev
+_mesa_GetError
+_mesa_GetFloatv
+_mesa_GetIntegerv
+_mesa_GetPointerv
+_mesa_GetString
+_glapi_add_entrypoint
+_glapi_check_multithread
+_glapi_check_table
+_glapi_get_context
+_glapi_get_dispatch
+_glapi_get_dispatch_table_size
+_glapi_get_proc_address
+_glapi_get_proc_name
+_glapi_get_proc_offset
+_glapi_get_version
+_glapi_set_context
+_glapi_set_dispatch
+_glapi_noop_enable_warnings
+_glthread_GetID
+_glthread_GetTSD
+_glthread_InitTSD
+_glthread_SetTSD
+_mesa_DeleteHashTable
+_mesa_HashFindFreeKeyBlock
+_mesa_HashFirstEntry
+_mesa_HashInsert
+_mesa_HashLookup
+_mesa_HashPrint
+_mesa_HashRemove
+_mesa_NewHashTable
+_mesa_Hint
+_mesa_HintPGI
+_mesa_try_Hint
+_mesa_bytes_per_pixel
+_mesa_components_in_format
+_mesa_image_address
+_mesa_image_row_stride
+_mesa_is_legal_format_and_type
+_mesa_native_packing
+_mesa_pack_bitmap
+_mesa_pack_polygon_stipple
+_mesa_pack_rgba_span
+_mesa_sizeof_packed_type
+_mesa_sizeof_type
+_mesa_swap2
+_mesa_swap4
+_mesa_unpack_bitmap
+_mesa_unpack_depth_span
+_mesa_unpack_float_color_span
+_mesa_unpack_image
+_mesa_unpack_index_span
+_mesa_unpack_polygon_stipple
+_mesa_unpack_stencil_span
+_mesa_unpack_ubyte_color_span
+_mesa_ConvolutionFilter1D
+_mesa_ConvolutionFilter2D
+_mesa_ConvolutionParameterf
+_mesa_ConvolutionParameterfv
+_mesa_ConvolutionParameteri
+_mesa_ConvolutionParameteriv
+_mesa_CopyConvolutionFilter1D
+_mesa_CopyConvolutionFilter2D
+_mesa_GetConvolutionFilter
+_mesa_GetConvolutionParameterfv
+_mesa_GetConvolutionParameteriv
+_mesa_GetHistogram
+_mesa_GetHistogramParameterfv
+_mesa_GetHistogramParameteriv
+_mesa_GetMinmax
+_mesa_GetMinmaxParameterfv
+_mesa_GetMinmaxParameteriv
+_mesa_GetSeparableFilter
+_mesa_Histogram
+_mesa_Minmax
+_mesa_ResetHistogram
+_mesa_ResetMinmax
+_mesa_SeparableFilter2D
+_mesa_update_histogram
+_mesa_update_minmax
+_mesa_ColorMaterial
+_mesa_GetLightfv
+_mesa_GetLightiv
+_mesa_GetMaterialfv
+_mesa_GetMaterialiv
+_mesa_LightModelf
+_mesa_LightModelfv
+_mesa_LightModeli
+_mesa_LightModeliv
+_mesa_Lightf
+_mesa_Lightfv
+_mesa_Lighti
+_mesa_Lightiv
+_mesa_Materialf
+_mesa_Materialfv
+_mesa_Materiali
+_mesa_Materialiv
+_mesa_ShadeModel
+gl_compute_light_positions
+gl_compute_shine_table
+gl_compute_spot_exp_table
+gl_material_bitmask
+gl_update_color_material
+gl_update_lighting
+gl_update_material
+gl_update_normal_transform
+_mesa_LineStipple
+_mesa_LineWidth
+gl_set_line_function
+_mesa_LogicOp
+_mesa_logicop_ci_pixels
+_mesa_logicop_ci_span
+_mesa_logicop_rgba_pixels
+_mesa_logicop_rgba_span
+_mesa_ColorMask
+_mesa_IndexMask
+_mesa_mask_index_pixels
+_mesa_mask_index_span
+_mesa_mask_rgba_pixels
+_mesa_mask_rgba_span
+_mesa_DepthRange
+_mesa_Frustum
+_mesa_LoadIdentity
+_mesa_LoadMatrixd
+_mesa_LoadMatrixf
+_mesa_LoadTransposeMatrixdARB
+_mesa_LoadTransposeMatrixfARB
+_mesa_MatrixMode
+_mesa_MultMatrixd
+_mesa_MultMatrixf
+_mesa_MultTransposeMatrixdARB
+_mesa_MultTransposeMatrixfARB
+_mesa_Ortho
+_mesa_PopMatrix
+_mesa_PushMatrix
+_mesa_Rotated
+_mesa_Rotatef
+_mesa_Scaled
+_mesa_Scalef
+_mesa_Translated
+_mesa_Translatef
+_mesa_Viewport
+gl_Viewport
+gl_calculate_model_project_matrix
+gl_mat_mul_floats
+gl_mat_mul_mat
+gl_matrix_alloc_inv
+gl_matrix_analyze
+gl_matrix_copy
+gl_matrix_ctr
+gl_matrix_dtr
+gl_matrix_invert
+gl_matrix_mul
+gl_matrix_transposed
+gl_matrix_transposef
+gl_print_matrix
+gl_rotation_matrix
+_mesa_calloc
+_mesa_free
+_mesa_malloc
+_mesa_bitcount
+_mesa_init_math
+gl_sqrt
+gl_alloc_pb
+gl_flush_pb
+gl_build_immediate_pipeline
+gl_build_precalc_pipeline
+gl_pipeline_init
+gl_print_active_pipeline
+gl_print_pipe_ops
+gl_print_pipeline
+gl_print_tri_caps
+gl_print_vert_flags
+gl_reset_cva_vb
+gl_run_pipeline
+gl_update_pipelines
+_mesa_GetPixelMapfv
+_mesa_GetPixelMapuiv
+_mesa_GetPixelMapusv
+_mesa_PixelMapfv
+_mesa_PixelMapuiv
+_mesa_PixelMapusv
+_mesa_PixelStoref
+_mesa_PixelStorei
+_mesa_PixelTransferf
+_mesa_PixelTransferi
+_mesa_PixelZoom
+_mesa_lookup_rgba
+_mesa_map_ci
+_mesa_map_ci8_to_rgba
+_mesa_map_ci_to_rgba
+_mesa_map_ci_to_rgba_ubyte
+_mesa_map_rgba
+_mesa_map_stencil
+_mesa_scale_and_bias_rgba
+_mesa_shift_and_offset_ci
+_mesa_shift_and_offset_stencil
+_mesa_transform_rgba
+_mesa_GetPixelTexGenParameterfvSGIS
+_mesa_GetPixelTexGenParameterivSGIS
+_mesa_PixelTexGenParameterfSGIS
+_mesa_PixelTexGenParameterfvSGIS
+_mesa_PixelTexGenParameteriSGIS
+_mesa_PixelTexGenParameterivSGIS
+_mesa_PixelTexGenSGIX
+_mesa_pixeltexgen
+_mesa_PointParameterfEXT
+_mesa_PointParameterfvEXT
+_mesa_PointSize
+gl_set_point_function
+_mesa_CullFace
+_mesa_FrontFace
+_mesa_GetPolygonStipple
+_mesa_PolygonMode
+_mesa_PolygonOffset
+_mesa_PolygonOffsetEXT
+_mesa_PolygonStipple
+gl_set_quad_function
+_mesa_RasterPos2d
+_mesa_RasterPos2dv
+_mesa_RasterPos2f
+_mesa_RasterPos2fv
+_mesa_RasterPos2i
+_mesa_RasterPos2iv
+_mesa_RasterPos2s
+_mesa_RasterPos2sv
+_mesa_RasterPos3d
+_mesa_RasterPos3dv
+_mesa_RasterPos3f
+_mesa_RasterPos3fv
+_mesa_RasterPos3i
+_mesa_RasterPos3iv
+_mesa_RasterPos3s
+_mesa_RasterPos3sv
+_mesa_RasterPos4d
+_mesa_RasterPos4dv
+_mesa_RasterPos4f
+_mesa_RasterPos4fv
+_mesa_RasterPos4i
+_mesa_RasterPos4iv
+_mesa_RasterPos4s
+_mesa_RasterPos4sv
+_mesa_ReadPixels
+_mesa_Rectd
+_mesa_Rectdv
+_mesa_Rectf
+_mesa_Rectfv
+_mesa_Recti
+_mesa_Rectiv
+_mesa_Rects
+_mesa_Rectsv
+_mesa_Scissor
+gl_scissor_pixels
+gl_scissor_span
+gl_init_shade
+gl_shade_rastpos
+gl_update_lighting_function
+gl_read_index_span
+gl_read_rgba_span
+gl_write_index_span
+gl_write_monocolor_span
+gl_write_monoindex_span
+gl_write_multitexture_span
+gl_write_rgba_span
+gl_write_texture_span
+gl_clean_color
+gl_default_nr_stages
+gl_default_pipeline
+gl_import_client_data
+gl_init_vbxform
+gl_update_materials
+_mesa_init_exec_table
+_mesa_init_no_op_table
+gl_print_enable_flags
+gl_print_state
+gl_update_state
+_mesa_ClearStencil
+_mesa_StencilFunc
+_mesa_StencilMask
+_mesa_StencilOp
+_mesa_alloc_stencil_buffer
+_mesa_clear_stencil_buffer
+_mesa_read_stencil_span
+_mesa_stencil_and_ztest_pixels
+_mesa_stencil_and_ztest_span
+_mesa_write_stencil_span
+_mesa_CompressedTexImage1DARB
+_mesa_CompressedTexImage2DARB
+_mesa_CompressedTexImage3DARB
+_mesa_CompressedTexSubImage1DARB
+_mesa_CompressedTexSubImage2DARB
+_mesa_CompressedTexSubImage3DARB
+_mesa_CopyTexImage1D
+_mesa_CopyTexImage2D
+_mesa_CopyTexSubImage1D
+_mesa_CopyTexSubImage2D
+_mesa_CopyTexSubImage3D
+_mesa_GetCompressedTexImageARB
+_mesa_GetTexImage
+_mesa_TexImage1D
+_mesa_TexImage2D
+_mesa_TexImage3D
+_mesa_TexImage3DEXT
+_mesa_TexSubImage1D
+_mesa_TexSubImage2D
+_mesa_TexSubImage3D
+_mesa_alloc_texture_image
+_mesa_base_tex_format
+_mesa_compressed_image_size
+_mesa_free_texture_image
+_mesa_get_teximage_from_driver
+_mesa_select_tex_image
+_mesa_select_tex_object
+_mesa_AreTexturesResident
+_mesa_BindTexture
+_mesa_DeleteTextures
+_mesa_GenTextures
+_mesa_IsTexture
+_mesa_PrioritizeTextures
+_mesa_test_texobj_completeness
+gl_alloc_texture_object
+gl_free_texture_object
+_mesa_ActiveTextureARB
+_mesa_ClientActiveTextureARB
+_mesa_GetTexEnvfv
+_mesa_GetTexEnviv
+_mesa_GetTexGendv
+_mesa_GetTexGenfv
+_mesa_GetTexGeniv
+_mesa_GetTexLevelParameterfv
+_mesa_GetTexLevelParameteriv
+_mesa_GetTexParameterfv
+_mesa_GetTexParameteriv
+_mesa_TexEnvf
+_mesa_TexEnvfv
+_mesa_TexEnvi
+_mesa_TexEnviv
+_mesa_TexGend
+_mesa_TexGendv
+_mesa_TexGenf
+_mesa_TexGenfv
+_mesa_TexGeni
+_mesa_TexGeniv
+_mesa_TexParameterf
+_mesa_TexParameterfv
+_mesa_TexParameteri
+_mesa_TexParameteriv
+gl_put_texobj_on_dirty_list
+gl_remove_texobj_from_dirty_list
+gl_update_dirty_texobjs
+_mesa_set_texture_sampler
+gl_init_texture
+gl_texture_pixels
+gl_update_texture_unit
+gl_init_translate
+gl_cull_triangle
+gl_set_triangle_function
+_mesa_ArrayElement
+_mesa_ColorPointer
+_mesa_ColorPointerEXT
+_mesa_DrawArrays
+_mesa_DrawElements
+_mesa_DrawRangeElements
+_mesa_EdgeFlagPointer
+_mesa_EdgeFlagPointerEXT
+_mesa_IndexPointer
+_mesa_IndexPointerEXT
+_mesa_InterleavedArrays
+_mesa_NormalPointer
+_mesa_NormalPointerEXT
+_mesa_TexCoordPointer
+_mesa_TexCoordPointerEXT
+_mesa_VertexPointer
+_mesa_VertexPointerEXT
+gl_exec_array_elements
+gl_update_client_state
+gl_immediate_alloc
+gl_immediate_free
+gl_vb_create_for_cva
+gl_vb_create_for_immediate
+gl_vb_free
+gl_cull_vb
+gl_dont_cull_vb
+gl_fast_copy_vb
+gl_make_normal_cullmask
+gl_purge_vertices
+_mesa_Begin
+_mesa_Color3b
+_mesa_Color3bv
+_mesa_Color3d
+_mesa_Color3dv
+_mesa_Color3f
+_mesa_Color3fv
+_mesa_Color3i
+_mesa_Color3iv
+_mesa_Color3s
+_mesa_Color3sv
+_mesa_Color3ub
+_mesa_Color3ubv
+_mesa_Color3ui
+_mesa_Color3uiv
+_mesa_Color3us
+_mesa_Color3usv
+_mesa_Color4b
+_mesa_Color4bv
+_mesa_Color4d
+_mesa_Color4dv
+_mesa_Color4f
+_mesa_Color4fv
+_mesa_Color4i
+_mesa_Color4iv
+_mesa_Color4s
+_mesa_Color4sv
+_mesa_Color4ub
+_mesa_Color4ubv
+_mesa_Color4ui
+_mesa_Color4uiv
+_mesa_Color4us
+_mesa_Color4usv
+_mesa_EdgeFlag
+_mesa_EdgeFlagv
+_mesa_End
+_mesa_Indexd
+_mesa_Indexdv
+_mesa_Indexf
+_mesa_Indexfv
+_mesa_Indexi
+_mesa_Indexiv
+_mesa_Indexs
+_mesa_Indexsv
+_mesa_Indexub
+_mesa_Indexubv
+_mesa_MultiTexCoord1dARB
+_mesa_MultiTexCoord1dvARB
+_mesa_MultiTexCoord1fARB
+_mesa_MultiTexCoord1fvARB
+_mesa_MultiTexCoord1iARB
+_mesa_MultiTexCoord1ivARB
+_mesa_MultiTexCoord1sARB
+_mesa_MultiTexCoord1svARB
+_mesa_MultiTexCoord2dARB
+_mesa_MultiTexCoord2dvARB
+_mesa_MultiTexCoord2fARB
+_mesa_MultiTexCoord2fvARB
+_mesa_MultiTexCoord2iARB
+_mesa_MultiTexCoord2ivARB
+_mesa_MultiTexCoord2sARB
+_mesa_MultiTexCoord2svARB
+_mesa_MultiTexCoord3dARB
+_mesa_MultiTexCoord3dvARB
+_mesa_MultiTexCoord3fARB
+_mesa_MultiTexCoord3fvARB
+_mesa_MultiTexCoord3iARB
+_mesa_MultiTexCoord3ivARB
+_mesa_MultiTexCoord3sARB
+_mesa_MultiTexCoord3svARB
+_mesa_MultiTexCoord4dARB
+_mesa_MultiTexCoord4dvARB
+_mesa_MultiTexCoord4fARB
+_mesa_MultiTexCoord4fvARB
+_mesa_MultiTexCoord4iARB
+_mesa_MultiTexCoord4ivARB
+_mesa_MultiTexCoord4sARB
+_mesa_MultiTexCoord4svARB
+_mesa_Normal3b
+_mesa_Normal3bv
+_mesa_Normal3d
+_mesa_Normal3dv
+_mesa_Normal3f
+_mesa_Normal3fv
+_mesa_Normal3i
+_mesa_Normal3iv
+_mesa_Normal3s
+_mesa_Normal3sv
+_mesa_TexCoord1d
+_mesa_TexCoord1dv
+_mesa_TexCoord1f
+_mesa_TexCoord1fv
+_mesa_TexCoord1i
+_mesa_TexCoord1iv
+_mesa_TexCoord1s
+_mesa_TexCoord1sv
+_mesa_TexCoord2d
+_mesa_TexCoord2dv
+_mesa_TexCoord2f
+_mesa_TexCoord2fv
+_mesa_TexCoord2i
+_mesa_TexCoord2iv
+_mesa_TexCoord2s
+_mesa_TexCoord2sv
+_mesa_TexCoord3d
+_mesa_TexCoord3dv
+_mesa_TexCoord3f
+_mesa_TexCoord3fv
+_mesa_TexCoord3i
+_mesa_TexCoord3iv
+_mesa_TexCoord3s
+_mesa_TexCoord3sv
+_mesa_TexCoord4d
+_mesa_TexCoord4dv
+_mesa_TexCoord4f
+_mesa_TexCoord4fv
+_mesa_TexCoord4i
+_mesa_TexCoord4iv
+_mesa_TexCoord4s
+_mesa_TexCoord4sv
+_mesa_Vertex2d
+_mesa_Vertex2dv
+_mesa_Vertex2f
+_mesa_Vertex2fv
+_mesa_Vertex2i
+_mesa_Vertex2iv
+_mesa_Vertex2s
+_mesa_Vertex2sv
+_mesa_Vertex3d
+_mesa_Vertex3dv
+_mesa_Vertex3f
+_mesa_Vertex3fv
+_mesa_Vertex3i
+_mesa_Vertex3iv
+_mesa_Vertex3s
+_mesa_Vertex3sv
+_mesa_Vertex4d
+_mesa_Vertex4dv
+_mesa_Vertex4f
+_mesa_Vertex4fv
+_mesa_Vertex4i
+_mesa_Vertex4iv
+_mesa_Vertex4s
+_mesa_Vertex4sv
+gl_Begin
+gl_End
+gl_Vertex2f
+gl_render_elts
+gl_render_vb_indirect
+gl_init_vbrender
+gl_reduced_prim_change
+gl_render_clipped_line
+gl_render_clipped_triangle
+gl_render_vb
+gl_set_render_vb_function
+RESET_IMMEDIATE
+gl_compute_orflag
+gl_copy_prev_vertices
+gl_copy_to_current
+gl_execute_cassette
+gl_fixup_cassette
+gl_fixup_input
+gl_flush_vb
+gl_internal_flush
+gl_maybe_transform_vb
+gl_print_cassette
+gl_print_cassette_flags
+gl_reset_input
+gl_reset_vb
+gl_texcoord_size
+gl_vector1ub_alloc
+gl_vector1ub_free
+gl_vector1ub_init
+gl_vector1ui_alloc
+gl_vector1ui_free
+gl_vector1ui_init
+gl_vector3f_alloc
+gl_vector3f_free
+gl_vector3f_init
+gl_vector3f_print
+gl_vector4f_alloc
+gl_vector4f_clean_elem
+gl_vector4f_free
+gl_vector4f_init
+gl_vector4f_print
+gl_vector4ub_alloc
+gl_vector4ub_free
+gl_vector4ub_init
+gl_init_vertices
+_mesa_WindowPos2dMESA
+_mesa_WindowPos2dvMESA
+_mesa_WindowPos2fMESA
+_mesa_WindowPos2fvMESA
+_mesa_WindowPos2iMESA
+_mesa_WindowPos2ivMESA
+_mesa_WindowPos2sMESA
+_mesa_WindowPos2svMESA
+_mesa_WindowPos3dMESA
+_mesa_WindowPos3dvMESA
+_mesa_WindowPos3fMESA
+_mesa_WindowPos3fvMESA
+_mesa_WindowPos3iMESA
+_mesa_WindowPos3ivMESA
+_mesa_WindowPos3sMESA
+_mesa_WindowPos3svMESA
+_mesa_WindowPos4dMESA
+_mesa_WindowPos4dvMESA
+_mesa_WindowPos4fMESA
+_mesa_WindowPos4fvMESA
+_mesa_WindowPos4iMESA
+_mesa_WindowPos4ivMESA
+_mesa_WindowPos4sMESA
+_mesa_WindowPos4svMESA
+gl_init_transformation
+gl_project_points
+gl_transform_point_sz
+gl_transform_vector
+gl_write_zoomed_index_span
+gl_write_zoomed_rgb_span
+gl_write_zoomed_rgba_span
+gl_write_zoomed_stencil_span
+__glBitmap_size
+__glCallLists_size
+__glDrawPixels_size
+__glFogfv_size
+__glFogiv_size
+__glLightModelfv_size
+__glLightModeliv_size
+__glLightfv_size
+__glLightiv_size
+__glMaterialfv_size
+__glMaterialiv_size
+__glTexEnvfv_size
+__glTexEnviv_size
+__glTexGendv_size
+__glTexGenfv_size
+__glTexGeniv_size
+__glTexImage1D_size
+__glTexImage2D_size
+__glTexParameterfv_size
+__glTexParameteriv_size
+__MESA_beginDispatchOverride
+__MESA_copyContext
+__MESA_createBuffer
+__MESA_createContext
+__MESA_destroyBuffer
+__MESA_destroyContext
+__MESA_dispatchExec
+__MESA_endDispatchOverride
+__MESA_forceCurrent
+__MESA_initVisuals
+__MESA_loseCurrent
+__MESA_makeCurrent
+__MESA_notifyDestroy
+__MESA_notifyResize
+__MESA_notifySwapBuffers
+__MESA_resetExtension
+__MESA_resizeBuffers
+__MESA_screenProbe
+__MESA_setVisualConfigs
+__MESA_shareContext
+__MESA_swapBuffers
+__glEvalComputeK
+__glFloorLog2
+XMesaCreateImage
+XMesaDestroyImage
+XMesaGetPixel
+XMesaPutImageHelper
+XMesaCopySubBuffer
+XMesaCreateContext
+XMesaCreatePixmapBuffer
+XMesaCreateVisual
+XMesaCreateWindowBuffer
+XMesaCreateWindowBuffer2
+XMesaDestroyBuffer
+XMesaDestroyContext
+XMesaDestroyVisual
+XMesaDitherColor
+XMesaFindBuffer
+XMesaFlush
+XMesaForceCurrent
+XMesaGarbageCollect
+XMesaGetBackBuffer
+XMesaGetCurrentBuffer
+XMesaGetCurrentContext
+XMesaGetCurrentReadBuffer
+XMesaGetDepthBuffer
+XMesaGetString
+XMesaLoseCurrent
+XMesaMakeCurrent
+XMesaMakeCurrent2
+XMesaReset
+XMesaSetFXmode
+XMesaSetVisualDisplay
+XMesaSwapBuffers
+XMesaUnbindContext
+xmesa_alloc_back_buffer
+xmesa_color_to_pixel
+xmesa_update_state
+xmesa_get_line_func
+xmesa_get_points_func
+xmesa_get_triangle_func
+
+/* $XFree86: xc/programs/Xserver/GL/mesa/src/GLcore-def.cpp,v 1.1 2000/08/10 17:40:29 dawes Exp $ */
Index: xc/programs/Xserver/GL/mesa/src/Imakefile
diff -u xc/programs/Xserver/GL/mesa/src/Imakefile:1.14 xc/programs/Xserver/GL/mesa/src/Imakefile:1.16
--- xc/programs/Xserver/GL/mesa/src/Imakefile:1.14	Fri Jun 16 20:03:13 2000
+++ xc/programs/Xserver/GL/mesa/src/Imakefile	Sun Sep 24 09:51:22 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/Imakefile,v 1.14 2000/06/17 00:03:13 martin Exp $
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/Imakefile,v 1.16 2000/09/24 13:51:22 alanh Exp $
 
 #define IHaveModules
 #include <Server.tmpl>
@@ -7,187 +7,187 @@
 
       SUBDIRS = X
 
-LinkSourceFile(aatriangle.c,../../../../../extras/Mesa/src)
-LinkSourceFile(aatriangle.h,../../../../../extras/Mesa/src)
-LinkSourceFile(aatritemp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(accum.c,../../../../../extras/Mesa/src)
-LinkSourceFile(accum.h,../../../../../extras/Mesa/src)
-LinkSourceFile(all.h,../../../../../extras/Mesa/src)
-LinkSourceFile(alpha.c,../../../../../extras/Mesa/src)
-LinkSourceFile(alpha.h,../../../../../extras/Mesa/src)
-LinkSourceFile(alphabuf.c,../../../../../extras/Mesa/src)
-LinkSourceFile(alphabuf.h,../../../../../extras/Mesa/src)
-LinkSourceFile(attrib.c,../../../../../extras/Mesa/src)
-LinkSourceFile(attrib.h,../../../../../extras/Mesa/src)
-LinkSourceFile(bbox.c,../../../../../extras/Mesa/src)
-LinkSourceFile(bbox.h,../../../../../extras/Mesa/src)
-LinkSourceFile(bitmap.c,../../../../../extras/Mesa/src)
-LinkSourceFile(bitmap.h,../../../../../extras/Mesa/src)
-LinkSourceFile(blend.c,../../../../../extras/Mesa/src)
-LinkSourceFile(blend.h,../../../../../extras/Mesa/src)
-LinkSourceFile(buffers.c,../../../../../extras/Mesa/src)
-LinkSourceFile(buffers.h,../../../../../extras/Mesa/src)
-LinkSourceFile(clip.c,../../../../../extras/Mesa/src)
-LinkSourceFile(clip.h,../../../../../extras/Mesa/src)
-LinkSourceFile(clip_funcs.h,../../../../../extras/Mesa/src)
-LinkSourceFile(clip_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(colortab.c,../../../../../extras/Mesa/src)
-LinkSourceFile(colortab.h,../../../../../extras/Mesa/src)
-LinkSourceFile(config.c,../../../../../extras/Mesa/src)
-LinkSourceFile(config.h,../../../../../extras/Mesa/src)
-LinkSourceFile(context.c,../../../../../extras/Mesa/src)
-LinkSourceFile(context.h,../../../../../extras/Mesa/src)
-LinkSourceFile(copy_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(copypix.c,../../../../../extras/Mesa/src)
-LinkSourceFile(copypix.h,../../../../../extras/Mesa/src)
-LinkSourceFile(cull_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(cva.c,../../../../../extras/Mesa/src)
-LinkSourceFile(cva.h,../../../../../extras/Mesa/src)
-LinkSourceFile(dd.h,../../../../../extras/Mesa/src)
-LinkSourceFile(ddsample.c,../../../../../extras/Mesa/src)
-LinkSourceFile(debug_xform.c,../../../../../extras/Mesa/src)
-LinkSourceFile(debug_xform.h,../../../../../extras/Mesa/src)
-LinkSourceFile(depth.c,../../../../../extras/Mesa/src)
-LinkSourceFile(depth.h,../../../../../extras/Mesa/src)
-LinkSourceFile(dispatch.c,../../../../../extras/Mesa/src)
-LinkSourceFile(dlist.c,../../../../../extras/Mesa/src)
-LinkSourceFile(dlist.h,../../../../../extras/Mesa/src)
-LinkSourceFile(dotprod_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(drawpix.c,../../../../../extras/Mesa/src)
-LinkSourceFile(drawpix.h,../../../../../extras/Mesa/src)
-LinkSourceFile(enable.c,../../../../../extras/Mesa/src)
-LinkSourceFile(enable.h,../../../../../extras/Mesa/src)
-LinkSourceFile(enums.c,../../../../../extras/Mesa/src)
-LinkSourceFile(enums.h,../../../../../extras/Mesa/src)
-LinkSourceFile(eval.c,../../../../../extras/Mesa/src)
-LinkSourceFile(eval.h,../../../../../extras/Mesa/src)
-LinkSourceFile(extensions.c,../../../../../extras/Mesa/src)
-LinkSourceFile(extensions.h,../../../../../extras/Mesa/src)
-LinkSourceFile(feedback.c,../../../../../extras/Mesa/src)
-LinkSourceFile(feedback.h,../../../../../extras/Mesa/src)
-LinkSourceFile(fixed.h,../../../../../extras/Mesa/src)
-LinkSourceFile(fog.c,../../../../../extras/Mesa/src)
-LinkSourceFile(fog.h,../../../../../extras/Mesa/src)
-LinkSourceFile(fog_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(general_clip.h,../../../../../extras/Mesa/src)
-LinkSourceFile(get.c,../../../../../extras/Mesa/src)
-LinkSourceFile(get.h,../../../../../extras/Mesa/src)
-LinkSourceFile(glapi.h,../../../../../extras/Mesa/src)
-LinkSourceFile(glapi.c,../../../../../extras/Mesa/src)
-LinkSourceFile(glapioffsets.h,../../../../../extras/Mesa/src)
-LinkSourceFile(glapinoop.c,../../../../../extras/Mesa/src)
-LinkSourceFile(glapinoop.h,../../../../../extras/Mesa/src)
-LinkSourceFile(glapitable.h,../../../../../extras/Mesa/src)
-LinkSourceFile(glapitemp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(glheader.h,../../../../../extras/Mesa/src)
-LinkSourceFile(glthread.c,../../../../../extras/Mesa/src)
-LinkSourceFile(glthread.h,../../../../../extras/Mesa/src)
-LinkSourceFile(hash.c,../../../../../extras/Mesa/src)
-LinkSourceFile(hash.h,../../../../../extras/Mesa/src)
-LinkSourceFile(hint.c,../../../../../extras/Mesa/src)
-LinkSourceFile(hint.h,../../../../../extras/Mesa/src)
-LinkSourceFile(highpc.c,../../../../../extras/Mesa/src)
-LinkSourceFile(image.c,../../../../../extras/Mesa/src)
-LinkSourceFile(image.h,../../../../../extras/Mesa/src)
-LinkSourceFile(imaging.c,../../../../../extras/Mesa/src)
-LinkSourceFile(imaging.h,../../../../../extras/Mesa/src)
-LinkSourceFile(indirect_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(interp_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(light.c,../../../../../extras/Mesa/src)
-LinkSourceFile(light.h,../../../../../extras/Mesa/src)
-LinkSourceFile(lines.c,../../../../../extras/Mesa/src)
-LinkSourceFile(lines.h,../../../../../extras/Mesa/src)
-LinkSourceFile(linetemp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(lnaatemp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(logic.c,../../../../../extras/Mesa/src)
-LinkSourceFile(logic.h,../../../../../extras/Mesa/src)
-LinkSourceFile(lowpc.c,../../../../../extras/Mesa/src)
-LinkSourceFile(macros.h,../../../../../extras/Mesa/src)
-LinkSourceFile(masking.c,../../../../../extras/Mesa/src)
-LinkSourceFile(masking.h,../../../../../extras/Mesa/src)
-LinkSourceFile(matrix.c,../../../../../extras/Mesa/src)
-LinkSourceFile(matrix.h,../../../../../extras/Mesa/src)
-LinkSourceFile(mem.c,../../../../../extras/Mesa/src)
-LinkSourceFile(mem.h,../../../../../extras/Mesa/src)
-LinkSourceFile(mmath.c,../../../../../extras/Mesa/src)
-LinkSourceFile(mmath.h,../../../../../extras/Mesa/src)
-LinkSourceFile(norm_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(pb.c,../../../../../extras/Mesa/src)
-LinkSourceFile(pb.h,../../../../../extras/Mesa/src)
-LinkSourceFile(pipeline.c,../../../../../extras/Mesa/src)
-LinkSourceFile(pipeline.h,../../../../../extras/Mesa/src)
-LinkSourceFile(pixel.c,../../../../../extras/Mesa/src)
-LinkSourceFile(pixel.h,../../../../../extras/Mesa/src)
-LinkSourceFile(pixeltex.c,../../../../../extras/Mesa/src)
-LinkSourceFile(pixeltex.h,../../../../../extras/Mesa/src)
-LinkSourceFile(points.c,../../../../../extras/Mesa/src)
-LinkSourceFile(points.h,../../../../../extras/Mesa/src)
-LinkSourceFile(polygon.c,../../../../../extras/Mesa/src)
-LinkSourceFile(polygon.h,../../../../../extras/Mesa/src)
-LinkSourceFile(quads.c,../../../../../extras/Mesa/src)
-LinkSourceFile(quads.h,../../../../../extras/Mesa/src)
-LinkSourceFile(rastpos.c,../../../../../extras/Mesa/src)
-LinkSourceFile(rastpos.h,../../../../../extras/Mesa/src)
-LinkSourceFile(readpix.c,../../../../../extras/Mesa/src)
-LinkSourceFile(readpix.h,../../../../../extras/Mesa/src)
-LinkSourceFile(rect.c,../../../../../extras/Mesa/src)
-LinkSourceFile(rect.h,../../../../../extras/Mesa/src)
-LinkSourceFile(render_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(scissor.c,../../../../../extras/Mesa/src)
-LinkSourceFile(scissor.h,../../../../../extras/Mesa/src)
-LinkSourceFile(shade.c,../../../../../extras/Mesa/src)
-LinkSourceFile(shade.h,../../../../../extras/Mesa/src)
-LinkSourceFile(shade_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(simple_list.h,../../../../../extras/Mesa/src)
-LinkSourceFile(span.c,../../../../../extras/Mesa/src)
-LinkSourceFile(span.h,../../../../../extras/Mesa/src)
-LinkSourceFile(stages.c,../../../../../extras/Mesa/src)
-LinkSourceFile(stages.h,../../../../../extras/Mesa/src)
-LinkSourceFile(state.c,../../../../../extras/Mesa/src)
-LinkSourceFile(state.h,../../../../../extras/Mesa/src)
-LinkSourceFile(stencil.c,../../../../../extras/Mesa/src)
-LinkSourceFile(stencil.h,../../../../../extras/Mesa/src)
-LinkSourceFile(texgen_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(teximage.c,../../../../../extras/Mesa/src)
-LinkSourceFile(teximage.h,../../../../../extras/Mesa/src)
-LinkSourceFile(texobj.c,../../../../../extras/Mesa/src)
-LinkSourceFile(texobj.h,../../../../../extras/Mesa/src)
-LinkSourceFile(texstate.c,../../../../../extras/Mesa/src)
-LinkSourceFile(texstate.h,../../../../../extras/Mesa/src)
-LinkSourceFile(texture.c,../../../../../extras/Mesa/src)
-LinkSourceFile(texture.h,../../../../../extras/Mesa/src)
-LinkSourceFile(trans_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(translate.c,../../../../../extras/Mesa/src)
-LinkSourceFile(translate.h,../../../../../extras/Mesa/src)
-LinkSourceFile(triangle.c,../../../../../extras/Mesa/src)
-LinkSourceFile(triangle.h,../../../../../extras/Mesa/src)
-LinkSourceFile(tritemp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(types.h,../../../../../extras/Mesa/src)
-LinkSourceFile(varray.c,../../../../../extras/Mesa/src)
-LinkSourceFile(varray.h,../../../../../extras/Mesa/src)
-LinkSourceFile(vb.c,../../../../../extras/Mesa/src)
-LinkSourceFile(vb.h,../../../../../extras/Mesa/src)
-LinkSourceFile(vbcull.c,../../../../../extras/Mesa/src)
-LinkSourceFile(vbcull.h,../../../../../extras/Mesa/src)
-LinkSourceFile(vbfill.c,../../../../../extras/Mesa/src)
-LinkSourceFile(vbfill.h,../../../../../extras/Mesa/src)
-LinkSourceFile(vbindirect.c,../../../../../extras/Mesa/src)
-LinkSourceFile(vbindirect.h,../../../../../extras/Mesa/src)
-LinkSourceFile(vbrender.c,../../../../../extras/Mesa/src)
-LinkSourceFile(vbrender.h,../../../../../extras/Mesa/src)
-LinkSourceFile(vbxform.c,../../../../../extras/Mesa/src)
-LinkSourceFile(vbxform.h,../../../../../extras/Mesa/src)
-LinkSourceFile(vector.c,../../../../../extras/Mesa/src)
-LinkSourceFile(vector.h,../../../../../extras/Mesa/src)
-LinkSourceFile(vertices.c,../../../../../extras/Mesa/src)
-LinkSourceFile(vertices.h,../../../../../extras/Mesa/src)
-LinkSourceFile(winpos.c,../../../../../extras/Mesa/src)
-LinkSourceFile(winpos.h,../../../../../extras/Mesa/src)
-LinkSourceFile(xform.c,../../../../../extras/Mesa/src)
-LinkSourceFile(xform.h,../../../../../extras/Mesa/src)
-LinkSourceFile(xform_tmp.h,../../../../../extras/Mesa/src)
-LinkSourceFile(zoom.c,../../../../../extras/Mesa/src)
-LinkSourceFile(zoom.h,../../../../../extras/Mesa/src)
+LinkSourceFile(aatriangle.c,$(MESASRCDIR)/src)
+LinkSourceFile(aatriangle.h,$(MESASRCDIR)/src)
+LinkSourceFile(aatritemp.h,$(MESASRCDIR)/src)
+LinkSourceFile(accum.c,$(MESASRCDIR)/src)
+LinkSourceFile(accum.h,$(MESASRCDIR)/src)
+LinkSourceFile(all.h,$(MESASRCDIR)/src)
+LinkSourceFile(alpha.c,$(MESASRCDIR)/src)
+LinkSourceFile(alpha.h,$(MESASRCDIR)/src)
+LinkSourceFile(alphabuf.c,$(MESASRCDIR)/src)
+LinkSourceFile(alphabuf.h,$(MESASRCDIR)/src)
+LinkSourceFile(attrib.c,$(MESASRCDIR)/src)
+LinkSourceFile(attrib.h,$(MESASRCDIR)/src)
+LinkSourceFile(bbox.c,$(MESASRCDIR)/src)
+LinkSourceFile(bbox.h,$(MESASRCDIR)/src)
+LinkSourceFile(bitmap.c,$(MESASRCDIR)/src)
+LinkSourceFile(bitmap.h,$(MESASRCDIR)/src)
+LinkSourceFile(blend.c,$(MESASRCDIR)/src)
+LinkSourceFile(blend.h,$(MESASRCDIR)/src)
+LinkSourceFile(buffers.c,$(MESASRCDIR)/src)
+LinkSourceFile(buffers.h,$(MESASRCDIR)/src)
+LinkSourceFile(clip.c,$(MESASRCDIR)/src)
+LinkSourceFile(clip.h,$(MESASRCDIR)/src)
+LinkSourceFile(clip_funcs.h,$(MESASRCDIR)/src)
+LinkSourceFile(clip_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(colortab.c,$(MESASRCDIR)/src)
+LinkSourceFile(colortab.h,$(MESASRCDIR)/src)
+LinkSourceFile(config.c,$(MESASRCDIR)/src)
+LinkSourceFile(config.h,$(MESASRCDIR)/src)
+LinkSourceFile(context.c,$(MESASRCDIR)/src)
+LinkSourceFile(context.h,$(MESASRCDIR)/src)
+LinkSourceFile(copy_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(copypix.c,$(MESASRCDIR)/src)
+LinkSourceFile(copypix.h,$(MESASRCDIR)/src)
+LinkSourceFile(cull_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(cva.c,$(MESASRCDIR)/src)
+LinkSourceFile(cva.h,$(MESASRCDIR)/src)
+LinkSourceFile(dd.h,$(MESASRCDIR)/src)
+LinkSourceFile(ddsample.c,$(MESASRCDIR)/src)
+LinkSourceFile(debug_xform.c,$(MESASRCDIR)/src)
+LinkSourceFile(debug_xform.h,$(MESASRCDIR)/src)
+LinkSourceFile(depth.c,$(MESASRCDIR)/src)
+LinkSourceFile(depth.h,$(MESASRCDIR)/src)
+LinkSourceFile(dispatch.c,$(MESASRCDIR)/src)
+LinkSourceFile(dlist.c,$(MESASRCDIR)/src)
+LinkSourceFile(dlist.h,$(MESASRCDIR)/src)
+LinkSourceFile(dotprod_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(drawpix.c,$(MESASRCDIR)/src)
+LinkSourceFile(drawpix.h,$(MESASRCDIR)/src)
+LinkSourceFile(enable.c,$(MESASRCDIR)/src)
+LinkSourceFile(enable.h,$(MESASRCDIR)/src)
+LinkSourceFile(enums.c,$(MESASRCDIR)/src)
+LinkSourceFile(enums.h,$(MESASRCDIR)/src)
+LinkSourceFile(eval.c,$(MESASRCDIR)/src)
+LinkSourceFile(eval.h,$(MESASRCDIR)/src)
+LinkSourceFile(extensions.c,$(MESASRCDIR)/src)
+LinkSourceFile(extensions.h,$(MESASRCDIR)/src)
+LinkSourceFile(feedback.c,$(MESASRCDIR)/src)
+LinkSourceFile(feedback.h,$(MESASRCDIR)/src)
+LinkSourceFile(fixed.h,$(MESASRCDIR)/src)
+LinkSourceFile(fog.c,$(MESASRCDIR)/src)
+LinkSourceFile(fog.h,$(MESASRCDIR)/src)
+LinkSourceFile(fog_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(general_clip.h,$(MESASRCDIR)/src)
+LinkSourceFile(get.c,$(MESASRCDIR)/src)
+LinkSourceFile(get.h,$(MESASRCDIR)/src)
+LinkSourceFile(glapi.h,$(MESASRCDIR)/src)
+LinkSourceFile(glapi.c,$(MESASRCDIR)/src)
+LinkSourceFile(glapioffsets.h,$(MESASRCDIR)/src)
+LinkSourceFile(glapinoop.c,$(MESASRCDIR)/src)
+LinkSourceFile(glapinoop.h,$(MESASRCDIR)/src)
+LinkSourceFile(glapitable.h,$(MESASRCDIR)/src)
+LinkSourceFile(glapitemp.h,$(MESASRCDIR)/src)
+LinkSourceFile(glheader.h,$(MESASRCDIR)/src)
+LinkSourceFile(glthread.c,$(MESASRCDIR)/src)
+LinkSourceFile(glthread.h,$(MESASRCDIR)/src)
+LinkSourceFile(hash.c,$(MESASRCDIR)/src)
+LinkSourceFile(hash.h,$(MESASRCDIR)/src)
+LinkSourceFile(hint.c,$(MESASRCDIR)/src)
+LinkSourceFile(hint.h,$(MESASRCDIR)/src)
+LinkSourceFile(highpc.c,$(MESASRCDIR)/src)
+LinkSourceFile(image.c,$(MESASRCDIR)/src)
+LinkSourceFile(image.h,$(MESASRCDIR)/src)
+LinkSourceFile(imaging.c,$(MESASRCDIR)/src)
+LinkSourceFile(imaging.h,$(MESASRCDIR)/src)
+LinkSourceFile(indirect_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(interp_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(light.c,$(MESASRCDIR)/src)
+LinkSourceFile(light.h,$(MESASRCDIR)/src)
+LinkSourceFile(lines.c,$(MESASRCDIR)/src)
+LinkSourceFile(lines.h,$(MESASRCDIR)/src)
+LinkSourceFile(linetemp.h,$(MESASRCDIR)/src)
+LinkSourceFile(lnaatemp.h,$(MESASRCDIR)/src)
+LinkSourceFile(logic.c,$(MESASRCDIR)/src)
+LinkSourceFile(logic.h,$(MESASRCDIR)/src)
+LinkSourceFile(lowpc.c,$(MESASRCDIR)/src)
+LinkSourceFile(macros.h,$(MESASRCDIR)/src)
+LinkSourceFile(masking.c,$(MESASRCDIR)/src)
+LinkSourceFile(masking.h,$(MESASRCDIR)/src)
+LinkSourceFile(matrix.c,$(MESASRCDIR)/src)
+LinkSourceFile(matrix.h,$(MESASRCDIR)/src)
+LinkSourceFile(mem.c,$(MESASRCDIR)/src)
+LinkSourceFile(mem.h,$(MESASRCDIR)/src)
+LinkSourceFile(mmath.c,$(MESASRCDIR)/src)
+LinkSourceFile(mmath.h,$(MESASRCDIR)/src)
+LinkSourceFile(norm_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(pb.c,$(MESASRCDIR)/src)
+LinkSourceFile(pb.h,$(MESASRCDIR)/src)
+LinkSourceFile(pipeline.c,$(MESASRCDIR)/src)
+LinkSourceFile(pipeline.h,$(MESASRCDIR)/src)
+LinkSourceFile(pixel.c,$(MESASRCDIR)/src)
+LinkSourceFile(pixel.h,$(MESASRCDIR)/src)
+LinkSourceFile(pixeltex.c,$(MESASRCDIR)/src)
+LinkSourceFile(pixeltex.h,$(MESASRCDIR)/src)
+LinkSourceFile(points.c,$(MESASRCDIR)/src)
+LinkSourceFile(points.h,$(MESASRCDIR)/src)
+LinkSourceFile(polygon.c,$(MESASRCDIR)/src)
+LinkSourceFile(polygon.h,$(MESASRCDIR)/src)
+LinkSourceFile(quads.c,$(MESASRCDIR)/src)
+LinkSourceFile(quads.h,$(MESASRCDIR)/src)
+LinkSourceFile(rastpos.c,$(MESASRCDIR)/src)
+LinkSourceFile(rastpos.h,$(MESASRCDIR)/src)
+LinkSourceFile(readpix.c,$(MESASRCDIR)/src)
+LinkSourceFile(readpix.h,$(MESASRCDIR)/src)
+LinkSourceFile(rect.c,$(MESASRCDIR)/src)
+LinkSourceFile(rect.h,$(MESASRCDIR)/src)
+LinkSourceFile(render_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(scissor.c,$(MESASRCDIR)/src)
+LinkSourceFile(scissor.h,$(MESASRCDIR)/src)
+LinkSourceFile(shade.c,$(MESASRCDIR)/src)
+LinkSourceFile(shade.h,$(MESASRCDIR)/src)
+LinkSourceFile(shade_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(simple_list.h,$(MESASRCDIR)/src)
+LinkSourceFile(span.c,$(MESASRCDIR)/src)
+LinkSourceFile(span.h,$(MESASRCDIR)/src)
+LinkSourceFile(stages.c,$(MESASRCDIR)/src)
+LinkSourceFile(stages.h,$(MESASRCDIR)/src)
+LinkSourceFile(state.c,$(MESASRCDIR)/src)
+LinkSourceFile(state.h,$(MESASRCDIR)/src)
+LinkSourceFile(stencil.c,$(MESASRCDIR)/src)
+LinkSourceFile(stencil.h,$(MESASRCDIR)/src)
+LinkSourceFile(texgen_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(teximage.c,$(MESASRCDIR)/src)
+LinkSourceFile(teximage.h,$(MESASRCDIR)/src)
+LinkSourceFile(texobj.c,$(MESASRCDIR)/src)
+LinkSourceFile(texobj.h,$(MESASRCDIR)/src)
+LinkSourceFile(texstate.c,$(MESASRCDIR)/src)
+LinkSourceFile(texstate.h,$(MESASRCDIR)/src)
+LinkSourceFile(texture.c,$(MESASRCDIR)/src)
+LinkSourceFile(texture.h,$(MESASRCDIR)/src)
+LinkSourceFile(trans_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(translate.c,$(MESASRCDIR)/src)
+LinkSourceFile(translate.h,$(MESASRCDIR)/src)
+LinkSourceFile(triangle.c,$(MESASRCDIR)/src)
+LinkSourceFile(triangle.h,$(MESASRCDIR)/src)
+LinkSourceFile(tritemp.h,$(MESASRCDIR)/src)
+LinkSourceFile(types.h,$(MESASRCDIR)/src)
+LinkSourceFile(varray.c,$(MESASRCDIR)/src)
+LinkSourceFile(varray.h,$(MESASRCDIR)/src)
+LinkSourceFile(vb.c,$(MESASRCDIR)/src)
+LinkSourceFile(vb.h,$(MESASRCDIR)/src)
+LinkSourceFile(vbcull.c,$(MESASRCDIR)/src)
+LinkSourceFile(vbcull.h,$(MESASRCDIR)/src)
+LinkSourceFile(vbfill.c,$(MESASRCDIR)/src)
+LinkSourceFile(vbfill.h,$(MESASRCDIR)/src)
+LinkSourceFile(vbindirect.c,$(MESASRCDIR)/src)
+LinkSourceFile(vbindirect.h,$(MESASRCDIR)/src)
+LinkSourceFile(vbrender.c,$(MESASRCDIR)/src)
+LinkSourceFile(vbrender.h,$(MESASRCDIR)/src)
+LinkSourceFile(vbxform.c,$(MESASRCDIR)/src)
+LinkSourceFile(vbxform.h,$(MESASRCDIR)/src)
+LinkSourceFile(vector.c,$(MESASRCDIR)/src)
+LinkSourceFile(vector.h,$(MESASRCDIR)/src)
+LinkSourceFile(vertices.c,$(MESASRCDIR)/src)
+LinkSourceFile(vertices.h,$(MESASRCDIR)/src)
+LinkSourceFile(winpos.c,$(MESASRCDIR)/src)
+LinkSourceFile(winpos.h,$(MESASRCDIR)/src)
+LinkSourceFile(xform.c,$(MESASRCDIR)/src)
+LinkSourceFile(xform.h,$(MESASRCDIR)/src)
+LinkSourceFile(xform_tmp.h,$(MESASRCDIR)/src)
+LinkSourceFile(zoom.c,$(MESASRCDIR)/src)
+LinkSourceFile(zoom.h,$(MESASRCDIR)/src)
 
     CORE_SRCS = aatriangle.c \
 		accum.c \
@@ -355,6 +355,7 @@
 
      INCLUDES = -I. -I../include -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
                 -I../../include -I../../glx
+
       DEFINES = $(GLX_DEFINES) /*-DUSE_X86_ASM */
 
 #if DoLoadableServer
Index: xc/programs/Xserver/GL/mesa/src/X/Imakefile
diff -u xc/programs/Xserver/GL/mesa/src/X/Imakefile:1.7 xc/programs/Xserver/GL/mesa/src/X/Imakefile:1.8
--- xc/programs/Xserver/GL/mesa/src/X/Imakefile:1.7	Tue Feb 22 23:46:56 2000
+++ xc/programs/Xserver/GL/mesa/src/X/Imakefile	Tue Aug  1 16:28:40 2000
@@ -1,17 +1,17 @@
-XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/X/Imakefile,v 1.7 2000/02/23 04:46:56 martin Exp $
+XCOMM $XFree86: xc/programs/Xserver/GL/mesa/src/X/Imakefile,v 1.8 2000/08/01 20:28:40 dawes Exp $
 
 #define IHaveModules
 #include <Server.tmpl>
 
-LinkSourceFile(xmesa1.c,../../../../../../extras/Mesa/src/X)
-LinkSourceFile(xmesa2.c,../../../../../../extras/Mesa/src/X)
-LinkSourceFile(xmesa3.c,../../../../../../extras/Mesa/src/X)
-LinkSourceFile(xmesa4.c,../../../../../../extras/Mesa/src/X)
-LinkSourceFile(xmesaP.h,../../../../../../extras/Mesa/src/X)
-LinkSourceFile(glxheader.h,../../../../../../extras/Mesa/src/X)
+LinkSourceFile(xmesa1.c,$(MESASRCDIR)/src/X)
+LinkSourceFile(xmesa2.c,$(MESASRCDIR)/src/X)
+LinkSourceFile(xmesa3.c,$(MESASRCDIR)/src/X)
+LinkSourceFile(xmesa4.c,$(MESASRCDIR)/src/X)
+LinkSourceFile(xmesaP.h,$(MESASRCDIR)/src/X)
+LinkSourceFile(glxheader.h,$(MESASRCDIR)/src/X)
 
-LinkSourceFile(compsize.c,../../../../../../lib/GL/glx)
-LinkSourceFile(size.h,../../../../../../lib/GL/glx)
+LinkSourceFile(compsize.c,$(LIBSRC)/GL/glx)
+LinkSourceFile(size.h,$(LIBSRC)/GL/glx)
 
   DRIVER_SRCS = xmesa1.c xmesa2.c xmesa3.c xmesa4.c
   DRIVER_OBJS = xmesa1.o xmesa2.o xmesa3.o xmesa4.o
Index: xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.h
diff -u xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.h:1.4 xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.h:1.5
--- xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.h:1.4	Thu Mar  2 11:07:39 2000
+++ xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.h	Thu Aug 10 13:40:29 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.h,v 1.4 2000/03/02 16:07:39 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.h,v 1.5 2000/08/10 17:40:29 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -34,6 +34,11 @@
 
 #ifndef _XF86GLX_UTIL_H_
 #define _XF86GLX_UTIL_H_
+
+#ifdef __CYGWIN__
+#undef WIN32
+#undef _WIN32
+#endif
 
 #include <screenint.h>
 #include <pixmap.h>
Index: xc/programs/Xserver/PEX5/ddpex/mi/include/miStruct.h
diff -u xc/programs/Xserver/PEX5/ddpex/mi/include/miStruct.h:1.3 xc/programs/Xserver/PEX5/ddpex/mi/include/miStruct.h:1.4
--- xc/programs/Xserver/PEX5/ddpex/mi/include/miStruct.h:1.3	Sun Oct  4 05:34:07 1998
+++ xc/programs/Xserver/PEX5/ddpex/mi/include/miStruct.h	Thu Aug 31 15:03:55 2000
@@ -42,7 +42,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/include/miStruct.h,v 1.3 1998/10/04 09:34:07 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/include/miStruct.h,v 1.4 2000/08/31 19:03:55 tsi Exp $ */
 
 #ifndef MISTRUCT_H
 #define MISTRUCT_H
@@ -59,8 +59,9 @@
 	/* concatenate imp. dep. data definitions here */
 	/* sample server definitions are listed later in this file */
 	
-	/* do the following to pad to 64 bit alignment for alpha */
-#if defined(__alpha) || defined(__alpha__)
+	/* do the following to pad to 64 bit alignment for alpha and ia64 */
+#if defined(__alpha) || defined(__alpha__) || \
+    defined(ia64) || defined(__ia64__)
 	ddUSHORT		unused0;
 	ddUSHORT		unused1;
 #endif
Index: xc/programs/Xserver/PEX5/ddpex/mi/level1/Imakefile
diff -u xc/programs/Xserver/PEX5/ddpex/mi/level1/Imakefile:3.10 xc/programs/Xserver/PEX5/ddpex/mi/level1/Imakefile:3.11
--- xc/programs/Xserver/PEX5/ddpex/mi/level1/Imakefile:3.10	Sat Apr 17 05:08:15 1999
+++ xc/programs/Xserver/PEX5/ddpex/mi/level1/Imakefile	Thu Aug 24 18:20:09 2000
@@ -1,6 +1,6 @@
 XCOMM
 XCOMM $XConsortium: Imakefile /main/10 1996/09/28 16:54:08 rws $
-XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/level1/Imakefile,v 3.10 1999/04/17 09:08:15 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/level1/Imakefile,v 3.11 2000/08/24 22:20:09 tsi Exp $
 XCOMM
 XCOMM 
 XCOMM Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium
@@ -72,7 +72,7 @@
 
 SubdirLibraryRule($(OBJS))
 
-NormalLibraryTarget(ddpex1,$(OBJS))
+LibraryModuleTarget(ddpex1,$(OBJS))
 
 LintLibraryTarget(dp1, $(SRCS))
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/PEX5/ddpex/mi/level2/Imakefile
diff -u xc/programs/Xserver/PEX5/ddpex/mi/level2/Imakefile:3.9 xc/programs/Xserver/PEX5/ddpex/mi/level2/Imakefile:3.10
--- xc/programs/Xserver/PEX5/ddpex/mi/level2/Imakefile:3.9	Sat Apr 17 05:08:16 1999
+++ xc/programs/Xserver/PEX5/ddpex/mi/level2/Imakefile	Thu Aug 24 18:20:09 2000
@@ -1,6 +1,6 @@
 XCOMM
 XCOMM $XConsortium: Imakefile /main/8 1996/09/28 16:54:14 rws $
-XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/level2/Imakefile,v 3.9 1999/04/17 09:08:16 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/level2/Imakefile,v 3.10 2000/08/24 22:20:09 tsi Exp $
 XCOMM
 XCOMM 
 XCOMM Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium
@@ -108,7 +108,7 @@
 
 SubdirLibraryRule($(OBJS))
 
-NormalLibraryTarget(ddpex2,$(OBJS))
+LibraryModuleTarget(ddpex2,$(OBJS))
 
 LintLibraryTarget(dp2, $(SRCS))
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/PEX5/ddpex/mi/level3/Imakefile
diff -u xc/programs/Xserver/PEX5/ddpex/mi/level3/Imakefile:3.9 xc/programs/Xserver/PEX5/ddpex/mi/level3/Imakefile:3.10
--- xc/programs/Xserver/PEX5/ddpex/mi/level3/Imakefile:3.9	Sat Apr 17 05:08:16 1999
+++ xc/programs/Xserver/PEX5/ddpex/mi/level3/Imakefile	Thu Aug 24 18:20:09 2000
@@ -1,6 +1,6 @@
 XCOMM
 XCOMM $XConsortium: Imakefile /main/9 1996/09/28 16:54:20 rws $
-XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/level3/Imakefile,v 3.9 1999/04/17 09:08:16 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/level3/Imakefile,v 3.10 2000/08/24 22:20:09 tsi Exp $
 XCOMM
 XCOMM 
 XCOMM Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium
@@ -54,7 +54,7 @@
 
 SubdirLibraryRule($(OBJS))
 
-NormalLibraryTarget(ddpex3,$(OBJS))
+LibraryModuleTarget(ddpex3,$(OBJS))
 
 LintLibraryTarget(dp3, $(SRCS))
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/PEX5/ddpex/mi/level4/Imakefile
diff -u xc/programs/Xserver/PEX5/ddpex/mi/level4/Imakefile:3.11 xc/programs/Xserver/PEX5/ddpex/mi/level4/Imakefile:3.12
--- xc/programs/Xserver/PEX5/ddpex/mi/level4/Imakefile:3.11	Sun Jul  4 02:38:31 1999
+++ xc/programs/Xserver/PEX5/ddpex/mi/level4/Imakefile	Thu Aug 24 18:20:10 2000
@@ -1,6 +1,6 @@
 XCOMM
 XCOMM $XConsortium: Imakefile /main/11 1996/09/28 16:54:25 rws $
-XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/level4/Imakefile,v 3.11 1999/07/04 06:38:31 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/level4/Imakefile,v 3.12 2000/08/24 22:20:10 tsi Exp $
 XCOMM
 XCOMM 
 XCOMM Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium
@@ -72,7 +72,7 @@
 
 SubdirLibraryRule($(OBJS))
 
-NormalLibraryTarget(ddpex4,$(OBJS))
+LibraryModuleTarget(ddpex4,$(OBJS))
 
 LintLibraryTarget(dp4,$(SRCS))
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/PEX5/ddpex/mi/shared/Imakefile
diff -u xc/programs/Xserver/PEX5/ddpex/mi/shared/Imakefile:3.11 xc/programs/Xserver/PEX5/ddpex/mi/shared/Imakefile:3.12
--- xc/programs/Xserver/PEX5/ddpex/mi/shared/Imakefile:3.11	Sun Jul  4 02:38:31 1999
+++ xc/programs/Xserver/PEX5/ddpex/mi/shared/Imakefile	Thu Aug 24 18:20:10 2000
@@ -1,6 +1,6 @@
 XCOMM
 XCOMM $XConsortium: Imakefile /main/12 1996/09/28 16:54:42 rws $
-XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/shared/Imakefile,v 3.11 1999/07/04 06:38:31 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/PEX5/ddpex/mi/shared/Imakefile,v 3.12 2000/08/24 22:20:10 tsi Exp $
 XCOMM
 XCOMM 
 XCOMM Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium
@@ -88,7 +88,7 @@
 
 SubdirLibraryRule($(OBJS))
 
-NormalLibraryTarget(ddpexs,$(OBJS))
+LibraryModuleTarget(ddpexs,$(OBJS))
 
 LintLibraryTarget(dps, $(SRCS))
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/PEX5/dipex/dispatch/Imakefile
diff -u xc/programs/Xserver/PEX5/dipex/dispatch/Imakefile:3.11 xc/programs/Xserver/PEX5/dipex/dispatch/Imakefile:3.12
--- xc/programs/Xserver/PEX5/dipex/dispatch/Imakefile:3.11	Sat Apr 17 05:08:18 1999
+++ xc/programs/Xserver/PEX5/dipex/dispatch/Imakefile	Thu Aug 24 18:20:10 2000
@@ -1,6 +1,6 @@
 XCOMM
 XCOMM $XConsortium: Imakefile /main/8 1996/09/28 16:54:48 rws $
-XCOMM $XFree86: xc/programs/Xserver/PEX5/dipex/dispatch/Imakefile,v 3.11 1999/04/17 09:08:18 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/PEX5/dipex/dispatch/Imakefile,v 3.12 2000/08/24 22:20:10 tsi Exp $
 XCOMM
 XCOMM 
 XCOMM Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
@@ -59,7 +59,7 @@
 
 SubdirLibraryRule($(OBJS))
 
-NormalLibraryTarget(didipex,$(OBJS))
+LibraryModuleTarget(didipex,$(OBJS))
 
 LintLibraryTarget(dsp,$(SRCS))
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/PEX5/dipex/objects/Imakefile
diff -u xc/programs/Xserver/PEX5/dipex/objects/Imakefile:3.14 xc/programs/Xserver/PEX5/dipex/objects/Imakefile:3.15
--- xc/programs/Xserver/PEX5/dipex/objects/Imakefile:3.14	Sun Jul  4 02:38:32 1999
+++ xc/programs/Xserver/PEX5/dipex/objects/Imakefile	Thu Aug 24 18:20:10 2000
@@ -1,6 +1,6 @@
 XCOMM
 XCOMM $XConsortium: Imakefile /main/13 1996/09/28 16:54:53 rws $
-XCOMM $XFree86: xc/programs/Xserver/PEX5/dipex/objects/Imakefile,v 3.14 1999/07/04 06:38:32 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/PEX5/dipex/objects/Imakefile,v 3.15 2000/08/24 22:20:10 tsi Exp $
 XCOMM
 XCOMM 
 XCOMM Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium
@@ -59,7 +59,7 @@
 
 SubdirLibraryRule($(OBJS))
 
-NormalLibraryTarget(diobpex,$(OBJS))
+LibraryModuleTarget(diobpex,$(OBJS))
 
 LintLibraryTarget(obj,$(SRCS))
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/PEX5/dipex/swap/Imakefile
diff -u xc/programs/Xserver/PEX5/dipex/swap/Imakefile:3.9 xc/programs/Xserver/PEX5/dipex/swap/Imakefile:3.10
--- xc/programs/Xserver/PEX5/dipex/swap/Imakefile:3.9	Sat Apr 17 05:08:19 1999
+++ xc/programs/Xserver/PEX5/dipex/swap/Imakefile	Thu Aug 24 18:20:11 2000
@@ -1,6 +1,6 @@
 XCOMM
 XCOMM $XConsortium: Imakefile /main/13 1996/09/28 16:55:03 rws $
-XCOMM $XFree86: xc/programs/Xserver/PEX5/dipex/swap/Imakefile,v 3.9 1999/04/17 09:08:19 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/PEX5/dipex/swap/Imakefile,v 3.10 2000/08/24 22:20:11 tsi Exp $
 XCOMM
 XCOMM 
 XCOMM Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium
@@ -61,7 +61,7 @@
 
 SubdirLibraryRule($(OBJS))
 
-NormalLibraryTarget(diswapex,$(OBJS))
+LibraryModuleTarget(diswapex,$(OBJS))
 
 LintLibraryTarget(dsw,$(SRCS))
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/PEX5/ospex/Imakefile
diff -u xc/programs/Xserver/PEX5/ospex/Imakefile:3.13 xc/programs/Xserver/PEX5/ospex/Imakefile:3.14
--- xc/programs/Xserver/PEX5/ospex/Imakefile:3.13	Sun Jul  4 02:38:33 1999
+++ xc/programs/Xserver/PEX5/ospex/Imakefile	Thu Aug 24 18:20:11 2000
@@ -1,6 +1,6 @@
 XCOMM
 XCOMM $XConsortium: Imakefile /main/8 1996/09/28 16:55:19 rws $
-XCOMM $XFree86: xc/programs/Xserver/PEX5/ospex/Imakefile,v 3.13 1999/07/04 06:38:33 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/PEX5/ospex/Imakefile,v 3.14 2000/08/24 22:20:11 tsi Exp $
 XCOMM
 XCOMM 
 XCOMM Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium
@@ -70,7 +70,7 @@
 
 SubdirLibraryRule($(OBJS))
 
-NormalLibraryTarget(ospex,$(OBJS))
+LibraryModuleTarget(ospex,$(OBJS))
 
 SpecialCObjectRule(osPexFont,$(ICONFIGFILES),NullParameter)
 
Index: xc/programs/Xserver/PEX5/ospex/osPexFont.c
diff -u xc/programs/Xserver/PEX5/ospex/osPexFont.c:3.15 xc/programs/Xserver/PEX5/ospex/osPexFont.c:3.16
--- xc/programs/Xserver/PEX5/ospex/osPexFont.c:3.15	Sun Oct  4 05:35:23 1998
+++ xc/programs/Xserver/PEX5/ospex/osPexFont.c	Thu Aug 10 13:40:30 2000
@@ -42,7 +42,7 @@
 SOFTWARE.
 
 */
-/* $XFree86: xc/programs/Xserver/PEX5/ospex/osPexFont.c,v 3.15 1998/10/04 09:35:23 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/PEX5/ospex/osPexFont.c,v 3.16 2000/08/10 17:40:30 dawes Exp $ */
 
 #ifdef WIN32
 #define _WILLWINSOCK_
@@ -65,20 +65,12 @@
 
 #ifndef XFree86LOADER
 
-#ifndef X_NOT_POSIX
+#if !defined(X_NOT_POSIX) || defined(SYSV) || defined(__CYGWIN__) || defined(USG)
 #include <dirent.h>
 #else
-#ifdef SYSV
-#include <dirent.h>
-#else
-#ifdef USG
-#include <dirent.h>
-#else
 #include <sys/dir.h>
 #ifndef dirent
 #define dirent direct
-#endif
-#endif
 #endif
 #endif
 typedef struct dirent	 ENTRY;
Index: xc/programs/Xserver/XIE/dixie/Imakefile
diff -u xc/programs/Xserver/XIE/dixie/Imakefile:3.14 xc/programs/Xserver/XIE/dixie/Imakefile:3.15
--- xc/programs/Xserver/XIE/dixie/Imakefile:3.14	Thu Apr 29 05:13:37 1999
+++ xc/programs/Xserver/XIE/dixie/Imakefile	Thu Aug 24 18:20:11 2000
@@ -1,5 +1,5 @@
 XCOMM $XConsortium: Imakefile /main/6 1995/12/07 21:15:29 gildea $
-XCOMM $XFree86: xc/programs/Xserver/XIE/dixie/Imakefile,v 3.14 1999/04/29 09:13:37 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/XIE/dixie/Imakefile,v 3.15 2000/08/24 22:20:11 tsi Exp $
 XCOMM build dixie archive
 
 #define IHaveModules
@@ -20,7 +20,7 @@
 $(DONES): $(SUBDIRS)
 #endif
 
-NormalDepLibraryTarget(dixie,$(SUBDIRS) $(DONES),$(OBJS))
+DepLibraryModuleTarget(dixie,$(SUBDIRS) $(DONES),$(OBJS))
 
 ForceSubdirs($(SUBDIRS))
 
Index: xc/programs/Xserver/XIE/mixie/Imakefile
diff -u xc/programs/Xserver/XIE/mixie/Imakefile:3.15 xc/programs/Xserver/XIE/mixie/Imakefile:3.16
--- xc/programs/Xserver/XIE/mixie/Imakefile:3.15	Thu Apr 29 05:13:37 1999
+++ xc/programs/Xserver/XIE/mixie/Imakefile	Thu Aug 24 18:20:11 2000
@@ -1,5 +1,5 @@
 XCOMM $XConsortium: Imakefile /main/6 1995/12/07 21:15:34 gildea $
-XCOMM $XFree86: xc/programs/Xserver/XIE/mixie/Imakefile,v 3.15 1999/04/29 09:13:37 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/XIE/mixie/Imakefile,v 3.16 2000/08/24 22:20:11 tsi Exp $
 
 #define IHaveModules
 #include <Server.tmpl>
@@ -25,7 +25,7 @@
 $(DONES): $(SUBDIRS)
 #endif
 
-NormalDepLibraryTarget(mixie,$(SUBDIRS) $(DONES),$(OBJS))
+DepLibraryModuleTarget(mixie,$(SUBDIRS) $(DONES),$(OBJS))
 
 ForceSubdirs($(SUBDIRS))
 
Index: xc/programs/Xserver/XIE/mixie/jpeg/jconfig.h
diff -u xc/programs/Xserver/XIE/mixie/jpeg/jconfig.h:1.3 xc/programs/Xserver/XIE/mixie/jpeg/jconfig.h:1.5
--- xc/programs/Xserver/XIE/mixie/jpeg/jconfig.h:1.3	Sun Oct  4 05:36:20 1998
+++ xc/programs/Xserver/XIE/mixie/jpeg/jconfig.h	Tue Sep 19 08:46:09 2000
@@ -66,7 +66,7 @@
 	Gary Rogers, AGE Logic, Inc., January 1994
 
 ****************************************************************************/
-/* $XFree86: xc/programs/Xserver/XIE/mixie/jpeg/jconfig.h,v 1.3 1998/10/04 09:36:20 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/XIE/mixie/jpeg/jconfig.h,v 1.5 2000/09/19 12:46:09 eich Exp $ */
 
 /*
  * jconfig.h
@@ -467,7 +467,7 @@
 /* to have 64-bit longs, you might want to change this. */
 
 #ifndef XMD_H					/* X11/xmd.h correctly defines INT32 */
-#if defined(__alpha) || defined(__alpha__)
+#if defined(LONG64) || defined(WORD64)
 typedef int INT32;
 #else
 typedef long INT32;
Index: xc/programs/Xserver/XIE/mixie/process/mpctoi.c
diff -u xc/programs/Xserver/XIE/mixie/process/mpctoi.c:3.3 xc/programs/Xserver/XIE/mixie/process/mpctoi.c:3.4
--- xc/programs/Xserver/XIE/mixie/process/mpctoi.c:3.3	Mon Oct  5 09:22:43 1998
+++ xc/programs/Xserver/XIE/mixie/process/mpctoi.c	Thu Oct  5 17:59:29 2000
@@ -67,7 +67,7 @@
 	Robert NC Shelley -- AGE Logic, Inc. July, 1993
   
 *****************************************************************************/
-/* $XFree86: xc/programs/Xserver/XIE/mixie/process/mpctoi.c,v 3.3 1998/10/05 13:22:43 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/XIE/mixie/process/mpctoi.c,v 3.4 2000/10/05 21:59:29 tsi Exp $ */
 
 #define _XIEC_MPCTOI
 #define _XIEC_PCTOI
@@ -599,7 +599,7 @@
       Pixel p, *ppix = (Pixel*) ddx->tmpLst[0];
       
       for(i = 0; i < ddx->pixCnt; ++ppix)
-	if((long int)(p = *ppix) >= 0)
+	if((INT32)(p = *ppix) >= 0)
 	  lst->cellPtr[i++] = p;
 
     } /* else pixels are already in place */
@@ -904,7 +904,7 @@
   CARD32  w, val, mask = ddx->mask[0], trim = ddx->trim[0];		      \
   CARD16  r, g, b;							      \
   for(w = ddx->width; w--; *dst++ = px) {				      \
-    if((long int)(px = *(pp = &lst[(val = *src++ >> trim & mask)])) < 0) {    \
+    if((INT32)(px = *(pp = &lst[(val = *src++ >> trim & mask)])) < 0) {       \
       if(!ddx->cmapFull) {						      \
 	r = g = b = (unsigned short)((float)val * ddx->coef[0]);	      \
 	if(!(ddx->cmapFull = (*ddx->alloc)(ddx->cmap,&r,&g,&b,pp,	      \
@@ -946,7 +946,7 @@
     rv  = *srcR++ >> Rtrim & Rmask;					      \
     gv  = *srcG++ >> Gtrim & Gmask;					      \
     bv  = *srcB++ >> Btrim & Bmask;					      \
-    if((long int)(px = *(pp = &lst[rv | gv<<Gshft | bv<<Bshft])) < 0) {	      \
+    if((INT32)(px = *(pp = &lst[rv | gv<<Gshft | bv<<Bshft])) < 0) {	      \
       if(!ddx->cmapFull) {					      	      \
 	r = (unsigned short)((float)rv * ddx->coef[0]);			      \
 	g = (unsigned short)((float)gv * ddx->coef[1]);			      \
Index: xc/programs/Xserver/Xext/Imakefile
diff -u xc/programs/Xserver/Xext/Imakefile:3.33 xc/programs/Xserver/Xext/Imakefile:3.36
--- xc/programs/Xserver/Xext/Imakefile:3.33	Thu Jun 15 16:49:59 2000
+++ xc/programs/Xserver/Xext/Imakefile	Tue Aug 15 12:05:32 2000
@@ -1,5 +1,5 @@
 XCOMM $TOG: Imakefile /main/63 1997/11/24 16:48:40 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/Xext/Imakefile,v 3.33 2000/06/15 20:49:59 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/Xext/Imakefile,v 3.36 2000/08/15 16:05:32 dawes Exp $
 
 #include <Server.tmpl>
 
@@ -60,12 +60,6 @@
       XVOBJS = xvmain.o xvdisp.o
 #endif
 
-#if BuildXantiExt
-      XANTISRCS = anti.c 
-      XANTIOBJS = anti.o
-#endif
-
-
 #if BuildAppgroup
   APPGROUPSRCS = appgroup.c
   APPGROUPOBJS = appgroup.o
@@ -104,14 +98,14 @@
 	      bigreq.c sync.c $(SCRNSAVSRC) xcmisc.c $(VIDMODESRCS) \
 	      $(XF86MISCSRCS) $(XF86BIGFSRCS) $(XF86DGASRCS) $(SECURITYSRCS) \
 	      $(APPGROUPSRCS) xprint.c $(CUPSRCS) $(PNRXSRCS) $(DPMSSRCS) \
-	      $(EVISRCS) $(XVSRCS) $(XANTISRCS) $(FONTCACHESRCS)
+	      $(EVISRCS) $(XVSRCS) $(FONTCACHESRCS)
 
        OBJS = shape.o $(SHMOBJS) $(MULTIBUFOBJ) \
               mitmisc.o xtest.o xtest1di.o xtest1dd.o sleepuntil.o \
               bigreq.o sync.o $(SCRNSAVOBJ) xcmisc.o $(VIDMODEOBJS) \
 	      $(XF86MISCOBJS) $(XF86BIGFOBJS) $(XF86DGAOBJS) $(SECURITYOBJS) \
 	      $(APPGROUPOBJS) xprint.o $(CUPOBJS) $(PNRXOBJS) $(DPMSOBJS) \
-	      $(EVIOBJS) $(XVOBJS) $(XANTIOBJS) $(FONTCACHEOBJS)
+	      $(EVIOBJS) $(XVOBJS) $(FONTCACHEOBJS)
 
       SOBJS = $(SHMOBJS) $(APPGROUPOBJS) $(SECURITYOBJS) xprint.o \
 	      xtest.o xtest1di.o xtest1dd.o sleepuntil.o $(PNRXOBJS) \
@@ -126,13 +120,14 @@
  		$(FONTCACHEINCLUDES)
     LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
 
+     DEFINES = $(EXT_DEFINES)
+
 NormalLibraryObjectRule()
 
 /*
- * A hack to work around an optimisation problem with the compiler on
- * FreeBSD 4.0-current in late 1999/early 2000.
+ * A hack to work around an optimization problem with gcc 2.95.2
  */
-#if BuildXF86VidModeExt && defined(FreeBSDGccOptBug)
+#if BuildXF86VidModeExt && defined(GccOptBug295)
 SpecialCObjectRule(xf86vmode,NullParameter,-O0)
 #endif
 
Index: xc/programs/Xserver/Xext/anti.c
diff -u xc/programs/Xserver/Xext/anti.c:1.4 xc/programs/Xserver/Xext/anti.c:removed
--- xc/programs/Xserver/Xext/anti.c:1.4	Sun Jun  6 04:48:37 1999
+++ xc/programs/Xserver/Xext/anti.c	Mon Dec 18 14:27:51 2000
@@ -1,1403 +0,0 @@
-
-/*
-   Copyright (c) 1998 by The XFree86 Project Inc.
-
-   Written by Mark Vojkovich (mvojkovi@ucsd.edu)
-
-*/
-/*
-
-Parts of this file derived from code carrying the following Copyright:
- 
-Copyright (c) 1986  X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
-
-*/
-/* $XFree86: xc/programs/Xserver/Xext/anti.c,v 1.4 1999/06/06 08:48:37 dawes Exp $ */
-
-#include "X.h"
-#include "Xproto.h"
-#include "misc.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include "gcstruct.h"
-#include "dixstruct.h"
-#include "dixfontstr.h"
-#include "resource.h"
-#include "fontstruct.h"
-#include "extnsionst.h"
-#include "swapreq.h"
-#include "closestr.h"
-#include "XAntiproto.h"
-#include "anti.h"
-
-#ifdef EXTMODULE
-#include "xf86_ansic.h"
-#else
-#include <string.h>
-#endif
-
-static Bool XAntiCreateGC(GCPtr);
-
-static void XAntiValidateGC(GCPtr, unsigned long, DrawablePtr);
-static void XAntiChangeGC(GCPtr, unsigned long);
-static void XAntiCopyGC(GCPtr, unsigned long, GCPtr);
-static void XAntiDestroyGC(GCPtr);
-static void XAntiChangeClip(GCPtr, int, pointer, int);
-static void XAntiDestroyClip(GCPtr);
-static void XAntiCopyClip(GCPtr, GCPtr);
-
-
-GCFuncs XAntiGCFuncs = {
-    XAntiValidateGC, XAntiChangeGC, XAntiCopyGC, XAntiDestroyGC,
-    XAntiChangeClip, XAntiDestroyClip, XAntiCopyClip
-};
-
-
-int ProcXAntiDispatch (ClientPtr);
-int SProcXAntiDispatch (ClientPtr);
-
-static Bool DrawAntiPolyText(PTclosurePtr);
-static Bool DrawAntiImageText(ITclosurePtr);
-
-int XAntiScreenIndex = -1;
-int XAntiGCIndex = -1;
-int XAntiReqCode;
- 
-
-#define XANTI_GC_FUNC_PROLOGUE(pGC)\
-    AntiGCPtr pGCPriv = (AntiGCPtr) (pGC)->devPrivates[XAntiGCIndex].ptr;\
-    (pGC)->funcs = pGCPriv->wrapFuncs;
-
-#define XANTI_GC_FUNC_EPILOGUE(pGC)\
-    pGCPriv->wrapFuncs = (pGC)->funcs;\
-    (pGC)->funcs = &XAntiGCFuncs;
-
-static DISPATCH_PROC(ProcAntiQueryExtension);
-static DISPATCH_PROC(ProcAntiSetInterpolationPixels);
-static DISPATCH_PROC(ProcAntiInterpolateColors);
-static DISPATCH_PROC(ProcAntiPolyText);
-static DISPATCH_PROC(ProcAntiImageText8);
-static DISPATCH_PROC(ProcAntiImageText16);
-static DISPATCH_PROC(SProcAntiQueryExtension);
-static DISPATCH_PROC(SProcAntiSetInterpolationPixels);
-static DISPATCH_PROC(SProcAntiInterpolateColors);
-static DISPATCH_PROC(SProcAntiPolyText);
-static DISPATCH_PROC(SProcAntiImageText8);
-static DISPATCH_PROC(SProcAntiImageText16);
-
-
-static int
-AntiImageText(
-    ClientPtr client,
-    DrawablePtr pDraw,
-    GCPtr pGC,
-    int nChars,
-    unsigned char *data,
-    int xorg,
-    int yorg,
-    int reqType,
-    XID did
-);
-
-static int
-AntiPolyText(
-    ClientPtr client,
-    DrawablePtr pDraw,
-    GCPtr pGC,
-    unsigned char *pElt,
-    unsigned char *endReq,
-    int xorg,
-    int yorg,
-    int reqType,
-    XID did
-);
-
-
-
-
-int
-ProcXAntiDispatch (ClientPtr client)
-{
-    REQUEST(xReq);
-    switch (stuff->data)
-    {
-    case XAnti_QueryExtension:
-        return ProcAntiQueryExtension(client);
-    case XAnti_InterpolateColors:
-        return ProcAntiInterpolateColors(client);
-    case XAnti_SetInterpolationPixels:
-        return ProcAntiSetInterpolationPixels(client);
-    case XAnti_PolyText8:
-    case XAnti_PolyText16:
-        return ProcAntiPolyText(client);
-    case XAnti_ImageText8:
-        return ProcAntiImageText8(client);
-    case XAnti_ImageText16:
-        return ProcAntiImageText16(client);
-    default:
-        return BadRequest;
-    }
-}
-
-
-int
-SProcXAntiDispatch (ClientPtr client)
-{
-    REQUEST(xReq);
-    switch (stuff->data)
-    {
-    case XAnti_QueryExtension:
-        return SProcAntiQueryExtension(client);
-    case XAnti_InterpolateColors:
-        return SProcAntiInterpolateColors(client);
-    case XAnti_SetInterpolationPixels:
-        return SProcAntiSetInterpolationPixels(client);
-    case XAnti_PolyText8:
-    case XAnti_PolyText16:
-        return SProcAntiPolyText(client);
-    case XAnti_ImageText8:
-        return SProcAntiImageText8(client);
-    case XAnti_ImageText16:
-        return SProcAntiImageText16(client);
-    default:
-        return BadRequest;
-    }
-}
-
-static void
-XAntiResetProc (ExtensionEntry *extEntry)
-{
-    AntiScreenPtr pScreenPriv;
-    ScreenPtr pScreen;
-    int i;
- 
-    for (i = 0; i < screenInfo.numScreens; i++)
-    {
-        pScreen = screenInfo.screens[i];
-        pScreenPriv = 
-	   (AntiScreenPtr) pScreen->devPrivates[XAntiScreenIndex].ptr;
-
-	pScreen->CreateGC = pScreenPriv->CreateGC;
-
-	xfree((pointer) pScreenPriv);
-	pScreen->devPrivates[XAntiScreenIndex].ptr = (pointer)NULL;
-    }
-}
-
-
-static void 
-XAntiUndoDamage(
-    int i  /* screens which we already set up */
-){
-   AntiScreenPtr pScreenPriv;
-   ScreenPtr pScreen;
-   int j;
-   for(j = 0; j < i; i++) {
-	/* unwrap the screen */
-	pScreen = screenInfo.screens[j];
-        pScreenPriv = 
-		(AntiScreenPtr) pScreen->devPrivates[XAntiScreenIndex].ptr;
-   
-	pScreen->CreateGC = pScreenPriv->CreateGC;
-
-	/* free the private */
-	xfree((pointer) pScreenPriv);
-	pScreen->devPrivates[XAntiScreenIndex].ptr = (pointer)NULL;
-   }
-   ErrorF("Antialiased font extension initialization failed!\n");
-}
-
-
-static void
-XAntiCopyGCPrivate(GCPtr old, GCPtr new)
-{
-    AntiGCPtr gcPrivNew = XANTI_GET_GC_PRIVATE(new);
-    AntiGCPtr gcPrivOld = XANTI_GET_GC_PRIVATE(old);
-    if(gcPrivOld->NumPixels) {
-	int size = gcPrivOld->NumPixels * sizeof(unsigned long);
-	gcPrivNew->Pixels = xalloc(size);
-	if(gcPrivNew->Pixels) {
-	    gcPrivNew->NumPixels = gcPrivOld->NumPixels;
-	    memcpy(gcPrivNew->Pixels, gcPrivOld->Pixels, size);
-	}
-    }
-}
-
-void
-XAntiExtensionInit(void)
-{
-    ScreenPtr pScreen;
-    AntiScreenPtr pScreenPriv;
-    ExtensionEntry *extEntry;
-    int i;
-
-    if((XAntiScreenIndex = AllocateScreenPrivateIndex()) < 0) return;
-    if((XAntiGCIndex = AllocateGCPrivateIndex()) < 0) return;
-
-    for(i = 0; i < screenInfo.numScreens; i++) {
-	pScreen = screenInfo.screens[i];
-
-    	if (!AllocateGCPrivate(pScreen, XAntiGCIndex, sizeof(AntiGCRec))) {
-	   XAntiUndoDamage(i);
-	   return;
-	}
-
-    	if (!(pScreenPriv = (AntiScreenPtr)xalloc(sizeof(AntiScreenRec)))) {
-	   XAntiUndoDamage(i);
-	   return;
-	}
-
-	pScreen->devPrivates[XAntiScreenIndex].ptr = (pointer)pScreenPriv;
-
-	pScreenPriv->CreateGC = pScreen->CreateGC;
-	pScreen->CreateGC = XAntiCreateGC;
-
-        pScreenPriv->PolyTextFunc = DrawAntiPolyText;
-        pScreenPriv->ImageTextFunc = DrawAntiImageText;
-    }
-
-    extEntry = AddExtension(XAntiName, 0 /*events*/, 0 /*errors*/,
-			ProcXAntiDispatch, SProcXAntiDispatch,
-			XAntiResetProc, StandardMinorOpcode);
-
-    if(!extEntry)
-	XAntiUndoDamage(screenInfo.numScreens);
-    else 
-	XAntiReqCode = extEntry->base;
-}
-
-
-/* Screen functions */
-
-
-static Bool
-XAntiCreateGC(GCPtr pGC)
-{
-    ScreenPtr	pScreen = pGC->pScreen;
-    Bool	ret;
-    AntiGCPtr	pGCPriv = (AntiGCPtr)(pGC->devPrivates[XAntiGCIndex].ptr);
-    AntiScreenPtr pScreenPriv = 
-        (AntiScreenPtr) pScreen->devPrivates[XAntiScreenIndex].ptr;
-    
-    pScreen->CreateGC = pScreenPriv->CreateGC;
-
-    if((ret = (*pScreen->CreateGC)(pGC))) {
-	pGCPriv->NumPixels = 0;
-	pGCPriv->Pixels = NULL;
-	pGCPriv->wrapFuncs = pGC->funcs;
-	pGCPriv->clientData = FALSE;
-	pGC->funcs = &XAntiGCFuncs;
-    }
-
-    pScreen->CreateGC = XAntiCreateGC;
-  
-    return ret;
-}
-
-/* GC Funcs */
-
-static void
-XAntiValidateGC(
-   GCPtr         pGC,
-   unsigned long changes,
-   DrawablePtr   pDraw 
-){
-    XANTI_GC_FUNC_PROLOGUE (pGC);
-    (*pGC->funcs->ValidateGC) (pGC, changes, pDraw);
-    XANTI_GC_FUNC_EPILOGUE (pGC);
-}
-
-/* It's a shame that we have to wrap all the GCFuncs just to free
-   the extra colors.  Alternatively you could have a static array
-   in the GC private, but it would have to be large enough to 
-   accomodate any number of levels that would be used with it and
-   you'd have all the GCs unnecessarily large, particularly in the
-   case where someone wanted to be using 256 interpolation levels. */
-
-static void
-XAntiDestroyGC(GCPtr pGC)
-{
-    XANTI_GC_FUNC_PROLOGUE (pGC);
-
-    if(pGCPriv->Pixels)
-	xfree(pGCPriv->Pixels);
-
-    (*pGC->funcs->DestroyGC)(pGC);
-    XANTI_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-XAntiChangeGC (
-    GCPtr	    pGC,
-    unsigned long   mask
-){
-    XANTI_GC_FUNC_PROLOGUE (pGC);
-    (*pGC->funcs->ChangeGC) (pGC, mask);
-    XANTI_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-XAntiCopyGC (
-    GCPtr	    pGCSrc, 
-    unsigned long   mask,
-    GCPtr	    pGCDst
-){
-    XANTI_GC_FUNC_PROLOGUE (pGCDst);
-    (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
-    XANTI_GC_FUNC_EPILOGUE (pGCDst);
-}
-static void
-XAntiChangeClip (
-    GCPtr   pGC,
-    int		type,
-    pointer	pvalue,
-    int		nrects 
-){
-    XANTI_GC_FUNC_PROLOGUE (pGC);
-    (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
-    XANTI_GC_FUNC_EPILOGUE (pGC);
-}
-
-static void
-XAntiCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
-{
-    XANTI_GC_FUNC_PROLOGUE (pgcDst);
-    (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
-    XANTI_GC_FUNC_EPILOGUE (pgcDst);
-}
-
-static void
-XAntiDestroyClip(GCPtr pGC)
-{
-    XANTI_GC_FUNC_PROLOGUE (pGC);
-    (* pGC->funcs->DestroyClip)(pGC);
-    XANTI_GC_FUNC_EPILOGUE (pGC);
-}
-
-
-/********/
-
-
-
-
-static int
-ProcAntiQueryExtension(ClientPtr client)
-{
-    xAntiQueryExtensionReply rep;
-    REQUEST(xAntiQueryExtensionReq);
-    REQUEST_SIZE_MATCH(xAntiQueryExtensionReq);
-
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.version = XAntiVersion;
-    rep.revision = XAntiRevision;
-
-    if(client->swapped) {
-	register char n;
-
-	swaps(&rep.sequenceNumber, n);
-	swapl(&rep.length, n);
-	swaps(&rep.version, n);
-	swaps(&rep.revision, n);
-    }  
-	
-    WriteToClient(client, sz_xAntiQueryExtensionReply, (char*) &rep);
- 
-    return(client->noClientException);
-}
-
-
-static int
-ProcAntiPolyText(ClientPtr client)
-{
-    int	err;
-    REQUEST(xAntiPolyTextReq);
-    DrawablePtr pDraw;
-    GCPtr pGC;
-
-    REQUEST_AT_LEAST_SIZE(xAntiPolyTextReq);
-    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
-
-    err = AntiPolyText(client,
-		   pDraw,
-		   pGC,
-		   (unsigned char *)&stuff[1],
-		   ((unsigned char *) stuff) + (client->req_len << 2),
-		   stuff->x,
-		   stuff->y,
-		   stuff->reqType,
-		   stuff->drawable);
-
-    if (err == Success)
-	return(client->noClientException);
-    else
-	return err;
-}
-
-
-static int
-ProcAntiImageText8(ClientPtr client)
-{
-    int	err;
-    DrawablePtr pDraw;
-    GCPtr pGC;
-
-    REQUEST(xAntiImageTextReq);
-
-    REQUEST_FIXED_SIZE(xAntiImageTextReq, stuff->nChars);
-    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
-
-    err = AntiImageText(client,
-		    pDraw,
-		    pGC,
-		    stuff->nChars,
-		    (unsigned char *)&stuff[1],
-		    stuff->x,
-		    stuff->y,
-		    stuff->reqType,
-		    stuff->drawable);
-
-    if (err == Success)
-	return(client->noClientException);
-    else
-	return err;
-}
-
-static int
-ProcAntiImageText16(ClientPtr client)
-{
-    int	err;
-    DrawablePtr pDraw;
-    GCPtr pGC;
-
-    REQUEST(xAntiImageTextReq);
-
-    REQUEST_FIXED_SIZE(xAntiImageTextReq, stuff->nChars << 1);
-    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
-
-    err = AntiImageText(client,
-		    pDraw,
-		    pGC,
-		    stuff->nChars,
-		    (unsigned char *)&stuff[1],
-		    stuff->x,
-		    stuff->y,
-		    stuff->reqType,
-		    stuff->drawable);
-
-    if (err == Success)
-	return(client->noClientException);
-    else
-	return err;
-}
-
-
-static int
-ProcAntiSetInterpolationPixels(ClientPtr client)
-{
-    CARD32 *newPix;
-    AntiGCPtr gcPriv; 
-    GCPtr pGC;
-    int i;
-
-    REQUEST(xAntiSetInterpolationPixelsReq);
-
-    REQUEST_FIXED_SIZE(xAntiSetInterpolationPixelsReq, stuff->number << 2);
-
-    if((stuff->number + 1) & stuff->number)
-	return BadValue;
-
-    if((stuff->number < 0) || (stuff->number > 255))
-	return BadValue;
-
-    SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess);  
-    gcPriv = XANTI_GET_GC_PRIVATE(pGC);
-
-    if(stuff->number != gcPriv->NumPixels) {
-	unsigned long *pixels = NULL;
-
-	if(stuff->number) {
-	   pixels = (unsigned long*)xalloc(
-			stuff->number * sizeof(unsigned long));
-	   if(!pixels)
-		return BadAlloc;
-	}
-
-	if(gcPriv->Pixels) 
-	   xfree(gcPriv->Pixels);
-
-	gcPriv->Pixels = pixels;
-	gcPriv->NumPixels = stuff->number;
-    }
-
-    newPix = (CARD32*)&stuff[1];
-
-    for(i = 0; i < stuff->number; i++)
-	gcPriv->Pixels[i] = newPix[i];
-
-    gcPriv->clientData = TRUE;
-    return(client->noClientException);
-}
-
-
-static void 
-FindInterpolationColors(
-   ColormapPtr pmap,
-   int number,
-   xColorItem *colors,
-   unsigned long fg,
-   unsigned long bg
-){
-    double red, green, blue, dr, dg, db;
-    xColorItem color;
-    Pixel pix[2];
-    xrgb rgb[2];
-    int i;
-
-    pix[0] = fg;
-    pix[1] = bg;
-    QueryColors(pmap, 2, pix, rgb);
-
-    red   = (double)rgb[0].red;
-    green = (double)rgb[0].green;
-    blue  = (double)rgb[0].blue;
-
-    dr = ((double)rgb[1].red - red)/(double)(number + 1);
-    dg = ((double)rgb[1].green - green)/(double)(number + 1);
-    db = ((double)rgb[1].blue - blue)/(double)(number + 1);
-
-    for(i = 0; i < number; i++) {
-	red += dr;
-	green += dg;
-	blue += db;
-
-	colors[i].red   = color.red   = (unsigned short)(red + 0.5);
-	colors[i].green = color.green = (unsigned short)(green + 0.5);
-	colors[i].blue  = color.blue  = (unsigned short)(blue + 0.5);
-        colors[i].flags = color.flags = DoRed | DoGreen | DoBlue;
-	
-        FakeAllocColor(pmap, &color); /* just to get the pixel */
-
-	colors[i].pixel = color.pixel; 
-
-	FakeFreeColor(pmap, color.pixel);
-    }
-}
-
-static int
-ProcAntiInterpolateColors(ClientPtr client)
-{
-    xAntiInterpolateColorsReply rep;
-    xColorItem *colors;
-    ColormapPtr pmap;
-    GCPtr pGC;
-
-    REQUEST(xAntiInterpolateColorsReq);
-    REQUEST_SIZE_MATCH(xAntiInterpolateColorsReq);
-
-    if((stuff->number <= 0) || (stuff->number > 254)) return BadValue;
-
-    SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityReadAccess);  
-
-    pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->colormap,
-				 RT_COLORMAP, SecurityReadAccess);
-
-    if(!pmap) return BadColor;
-
-    colors = (xColorItem*)ALLOCATE_LOCAL(stuff->number * sizeof(xColorItem));
-
-    FindInterpolationColors(pmap, stuff->number, colors, 
-				pGC->fgPixel, pGC->bgPixel);
-
-    rep.type = X_Reply;
-    rep.length = (stuff->number * sizeof(xColorItem)) >> 2;
-    rep.sequenceNumber = client->sequence;
-
-
-    if(client->swapped) {
-	register char n;
-
-	swaps(&rep.sequenceNumber, n);
-	swapl(&rep.length, n);
-    }  
-	
-    WriteToClient(client, sz_xAntiInterpolateColorsReply, (char*) &rep);
-
-    if(client->swapped) {
-	register char n;
-	int i;
-
-	for(i = 0; i < stuff->number; i++) {
-	    swapl(&colors[i].pixel, n);
-	    swaps(&colors[i].red, n);
-	    swaps(&colors[i].green, n);
-	    swaps(&colors[i].blue, n);
-	}
-    }
-
-    WriteToClient(client, stuff->number*sizeof(xColorItem), (char*)colors);
-
-    DEALLOCATE_LOCAL(colors);
-
-    return(client->noClientException);
-}
-
-
-/*******  Image text  **********/
-
-
-#define TextEltHeader 2
-#define FontShiftSize 5
-static XID clearGC[] = { CT_NONE };
-#define clearGCmask (GCClipMask)
-
-
-static Bool
-DrawAntiImageText(ITclosurePtr c) {
-    unsigned long n;
-    CharInfoPtr charPtr[255];  /* encoding only has 1 byte for count */
-    FontEncoding fontEncoding = Linear8Bit;
-    AntiGCPtr gcPriv = XANTI_GET_GC_PRIVATE(c->pGC);
-    GetAntiGlyphsFuncPtr *getGlyphs = XANTI_GET_FONT_PRIVATE(c->pGC->font);
-
-    if(!getGlyphs) return FALSE;
-
-    if(!gcPriv->NumPixels) {
-	if(gcPriv->clientData) return FALSE;
-	
-	/* otherwise, we generate some reasonable colors if appropriate */
-	return FALSE;
-    }
-
-    if(c->itemSize == 2)
-      fontEncoding = (FONTLASTROW(c->pGC->font) == 0) ? Linear16Bit : TwoD16Bit;
-
-    if(Success != (*getGlyphs)(c->pGC->font, (unsigned long)(c->nChars), 
-		(unsigned char *)(c->data), fontEncoding, &n, charPtr, 
-		gcPriv->NumPixels + 1))
-	return FALSE;
-
-    if(n) {
-        int i, j;
-        XID oldFG = c->pGC->fgPixel;
-        int Pitch[255];
-        CharInfoRec *charData;
-
-        (*c->pGC->ops->ImageGlyphBlt)(c->pDraw, c->pGC, c->xorg, c->yorg, 
-                                n, charPtr, FONTGLYPHS(c->pGC->font));
-
-        if(!(charData = (CharInfoPtr)ALLOCATE_LOCAL(n * sizeof(CharInfoRec))))
-            return FALSE;
-
-        /* we need a modifiable copy of the CharInfoRecs */
-        for(i = 0; i < n; i++) {
-            memcpy(&charData[i], charPtr[i], sizeof(CharInfoRec)); 
-            Pitch[i] = GLYPHWIDTHBYTESPADDED(charPtr[i]) * 
-                                        GLYPHHEIGHTPIXELS(charPtr[i]);
-        }
-        
-        for(i = 0; i < gcPriv->NumPixels; i++) {
-            for(j = 0; j < n; j++) 
-                charData[j].bits += Pitch[j];
-            ChangeGC(c->pGC, GCForeground, (XID*)&(gcPriv->Pixels[i]));
-            ValidateGC(c->pDraw, c->pGC);
-	    (*c->pGC->ops->PolyGlyphBlt)(c->pDraw, c->pGC, c->xorg, c->yorg,
-	 			n, &charData, FONTGLYPHS(c->pGC->font));
-        }
-
-        ChangeGC(c->pGC, GCForeground, &oldFG);
-        ValidateGC(c->pDraw, c->pGC);
-        DEALLOCATE_LOCAL(charData);   
-    }
- 
-    return TRUE;
-}
-
-
-static int
-doAntiImageText(
-    ClientPtr   client,
-    ITclosurePtr c
-){
-    int err = Success, lgerr;	/* err is in X error, not font error, space */
-    FontPathElementPtr fpe;
-
-    if (client->clientGone) 
-    {
-	fpe = c->pGC->font->fpe;
-	(*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
-	err = Success;
-	goto bail;
-    }
-
-    /* Make sure our drawable hasn't disappeared while we slept. */
-    if (c->slept &&
-	c->pDraw &&
-	c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
-					RC_DRAWABLE, SecurityWriteAccess))
-    {
-	/* Our drawable has disappeared.  Treat like client died... ask
-	   the FPE code to clean up after client. */
-	fpe = c->pGC->font->fpe;
-	(*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
-	err = Success;
-	goto bail;
-    }
-
-    lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, c->itemSize, c->data);
-    if (lgerr == Suspended)
-    {
-        if (!c->slept) {
-	    GCPtr pGC, oldGC;
-	    unsigned char *data;
-	    ITclosurePtr new_closure;
-
-	    /* We're putting the client to sleep.  We need to
-	       save some state.  Similar problem to that handled
-	       in doAntiPolyText, but much simpler because the
-	       request structure is much simpler. */
-
-	    new_closure = (ITclosurePtr) xalloc(sizeof(ITclosureRec));
-	    if (!new_closure)
-	    {
-		err = BadAlloc;
-		goto bail;
-	    }
-	    *new_closure = *c;
-	    c = new_closure;
-
-	    data = (unsigned char *)xalloc(c->nChars * c->itemSize);
-	    if (!data)
-	    {
-		xfree(c);
-		err = BadAlloc;
-		goto bail;
-	    }
-	    memmove(data, c->data, c->nChars * c->itemSize);
-	    c->data = data;
-
-	    pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
-	    if (!pGC)
-	    {
-		xfree(c->data);
-		xfree(c);
-		err = BadAlloc;
-		goto bail;
-	    }
-	    if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
-			      GCForeground | GCBackground | GCFillStyle |
-			      GCTile | GCStipple | GCTileStipXOrigin |
-			      GCTileStipYOrigin | GCFont |
-			      GCSubwindowMode | GCClipXOrigin |
-			      GCClipYOrigin | GCClipMask)) != Success)
-	    {
-		FreeScratchGC(pGC);
-		xfree(c->data);
-		xfree(c);
-		err = BadAlloc;
-		goto bail;
-	    }
-
-	    oldGC = c->pGC;
-	    c->pGC = pGC;
-	    ValidateGC(c->pDraw, c->pGC);
-
-            /* We need to make sure that our scratch GC has 
-					the correct private data */
-	    XAntiCopyGCPrivate(oldGC, c->pGC);
-
-
-	    c->slept = TRUE;
-            ClientSleep(client, (ClientSleepProcPtr)doAntiImageText, 
-							(pointer) c);
-        }
-        return TRUE;
-    }
-    else if (lgerr != Successful)
-    {
-        err = FontToXError(lgerr);
-        goto bail;
-    }
-    if (c->pDraw) {
-	AntiScreenPtr pScreenPriv = XANTI_GET_SCREEN_PRIVATE(c->pDraw);
-
-	if(!(*pScreenPriv->ImageTextFunc)(c)) {
-	     (* c->imageText)(c->pDraw, c->pGC, c->xorg, c->yorg,
-	    			c->nChars, c->data);
-	}
-    }
-
-bail:
-
-    if (err != Success && c->client != serverClient) {
-	SendErrorToClient(c->client, c->reqType, 0, 0, err);
-    }
-    if (c->slept)
-    {
-	AntiGCPtr gcPriv = XANTI_GET_GC_PRIVATE(c->pGC);
-	ClientWakeup(c->client);
-	ChangeGC(c->pGC, clearGCmask, clearGC);
-
-	/* Unreference the font from the scratch GC */
-	CloseFont(c->pGC->font, (Font)0);
-	c->pGC->font = NullFont;
-
-        /* We need to make sure we free any private data */
-        if(gcPriv->Pixels) xfree(gcPriv->Pixels);
-
-	FreeScratchGC(c->pGC);
-	xfree(c->data);
-	xfree(c);
-    }
-    return TRUE;
-}
-
-
-static int
-AntiImageText(
-    ClientPtr client,
-    DrawablePtr pDraw,
-    GCPtr pGC,
-    int nChars,
-    unsigned char *data,
-    int xorg,
-    int yorg,
-    int reqType,
-    XID did
-){
-    ITclosureRec local_closure;
-
-    local_closure.client = client;
-    local_closure.pDraw = pDraw;
-    local_closure.pGC = pGC;
-    local_closure.nChars = nChars;
-    local_closure.data = data;
-    local_closure.xorg = xorg;
-    local_closure.yorg = yorg;
-    if ((local_closure.reqType = reqType) == XAnti_ImageText8) {
-	local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText8;
-	local_closure.itemSize = 1;
-    } else {
-	local_closure.imageText = (ImageTextPtr) pGC->ops->ImageText16;
-	local_closure.itemSize = 2;
-    }
-    local_closure.did = did;
-    local_closure.slept = FALSE;
-
-    (void) doAntiImageText(client, &local_closure);
-    return Success;
-}
-
-
-/********  Poly Text  **********/
-
-
-static Bool
-DrawAntiPolyText(PTclosurePtr c)
-{
-    unsigned long n;
-    int w = 0;
-    CharInfoPtr charPtr[255];
-    FontEncoding fontEncoding = Linear8Bit;
-    AntiGCPtr gcPriv = XANTI_GET_GC_PRIVATE(c->pGC);
-    GetAntiGlyphsFuncPtr *getGlyphs = XANTI_GET_FONT_PRIVATE(c->pGC->font);
-
-
-    if(!gcPriv->NumPixels || !getGlyphs) return FALSE;
-
-    if(c->itemSize == 2) {
-      fontEncoding = (FONTLASTROW(c->pGC->font) == 0) ? Linear16Bit : TwoD16Bit;
-    }
-    
-
-    if(Success != (*getGlyphs)(c->pGC->font, (unsigned long)(*c->pElt), 
-		(unsigned char *)(c->pElt + TextEltHeader),
-              	fontEncoding, &n, charPtr, gcPriv->NumPixels + 1))
-	return FALSE;
-
-    if(n) {
-	int i, j;
-	XID oldFG = c->pGC->fgPixel;
-	int Pitch[255];
-	CharInfoRec *charData;
-
-        (*c->pGC->ops->PolyGlyphBlt)(c->pDraw, c->pGC, c->xorg, c->yorg, 
-				n, charPtr, FONTGLYPHS(c->pGC->font));
-
-	if(!(charData = (CharInfoPtr)ALLOCATE_LOCAL(n * sizeof(CharInfoRec))))
-	    return FALSE;
-
-	/* we need a modifiable copy of the CharInfoRecs */
-	for(i = 0; i < n; i++) {
-	    memcpy(&charData[i], charPtr[i], sizeof(CharInfoRec)); 
-	    Pitch[i] = GLYPHWIDTHBYTESPADDED(charPtr[i]) * 
-					GLYPHHEIGHTPIXELS(charPtr[i]);
-	    w += charPtr[i]->metrics.characterWidth;
-	}
-	
-	for(i = 0; i < gcPriv->NumPixels; i++) {
-	    for(j = 0; j < n; j++) 
-		charData[j].bits += Pitch[j];
-	    ChangeGC(c->pGC, GCForeground, (XID*)&(gcPriv->Pixels[i]));
-	    ValidateGC(c->pDraw, c->pGC);
-	    (*c->pGC->ops->PolyGlyphBlt)(c->pDraw, c->pGC, c->xorg, c->yorg,
-	 			n, &charData, FONTGLYPHS(c->pGC->font));
-	}
-
-	ChangeGC(c->pGC, GCForeground, &oldFG);
-	ValidateGC(c->pDraw, c->pGC);
-	DEALLOCATE_LOCAL(charData);   
-    }
-
-    c->xorg += w;
-
-    return TRUE;
-}
-
-
-static int
-doAntiPolyText(
-    ClientPtr   client,
-    PTclosurePtr c
-){
-    register FontPtr pFont = c->pGC->font, oldpFont;
-    Font	fid, oldfid;
-    int err = Success, lgerr;	/* err is in X error, not font error, space */
-    enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state;
-    FontPathElementPtr fpe;
-    GCPtr origGC;
-
-    if (client->clientGone)
-    {
-	fpe = c->pGC->font->fpe;
-	(*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
-
-	if (c->slept)
-	{
-	    /* Client has died, but we cannot bail out right now.  We
-	       need to clean up after the work we did when going to
-	       sleep.  Setting the drawable pointer to 0 makes this
-	       happen without any attempts to render or perform other
-	       unnecessary activities.  */
-	    c->pDraw = (DrawablePtr)0;
-	}
-	else
-	{
-	    err = Success;
-	    goto bail;
-	}
-    }
-
-    /* Make sure our drawable hasn't disappeared while we slept. */
-    if (c->slept &&
-	c->pDraw &&
-	c->pDraw != (DrawablePtr)SecurityLookupIDByClass(client, c->did,
-					RC_DRAWABLE, SecurityWriteAccess))
-    {
-	/* Our drawable has disappeared.  Treat like client died... ask
-	   the FPE code to clean up after client and avoid further
-	   rendering while we clean up after ourself.  */
-	fpe = c->pGC->font->fpe;
-	(*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
-	c->pDraw = (DrawablePtr)0;
-    }
-    client_state = c->slept ? SLEEPING : NEVER_SLEPT;
-
-    while (c->endReq - c->pElt > TextEltHeader)
-    {
-	if (*c->pElt == FontChange)
-        {
-	    if (c->endReq - c->pElt < FontShiftSize)
-	    {
-		 err = BadLength;
-		 goto bail;
-	    }
-
-	    oldpFont = pFont;
-	    oldfid = fid;
-
-	    fid =  ((Font)*(c->pElt+4))		/* big-endian */
-		 | ((Font)*(c->pElt+3)) << 8
-		 | ((Font)*(c->pElt+2)) << 16
-		 | ((Font)*(c->pElt+1)) << 24;
-	    pFont = (FontPtr)SecurityLookupIDByType(client, fid, RT_FONT,
-						    SecurityReadAccess);
-	    if (!pFont)
-	    {
-		client->errorValue = fid;
-		err = BadFont;
-		/* restore pFont and fid for step 4 (described below) */
-		pFont = oldpFont;
-		fid = oldfid;
-
-		/* If we're in START_SLEEP mode, the following step
-		   shortens the request...  in the unlikely event that
-		   the fid somehow becomes valid before we come through
-		   again to actually execute the polytext, which would
-		   then mess up our refcounting scheme badly.  */
-		c->err = err;
-		c->endReq = c->pElt;
-
-		goto bail;
-	    }
-
-	    /* Step 3 (described below) on our new font */
-	    if (client_state == START_SLEEP)
-		pFont->refcnt++;
-	    else
-	    {
-		if (pFont != c->pGC->font && c->pDraw)
-		{
-		    ChangeGC( c->pGC, GCFont, &fid);
-		    ValidateGC(c->pDraw, c->pGC);
-		    if (c->reqType == XAnti_PolyText8)
-			c->polyText = (PolyTextPtr) c->pGC->ops->PolyText8;
-		    else
-			c->polyText = (PolyTextPtr) c->pGC->ops->PolyText16;
-		}
-
-		/* Undo the refcnt++ we performed when going to sleep */
-		if (client_state == SLEEPING)
-		    (void)CloseFont(c->pGC->font, (Font)0);
-	    }
-	    c->pElt += FontShiftSize;
-	}
-	else	/* print a string */
-	{
-	    unsigned char *pNextElt;
-	    pNextElt = c->pElt + TextEltHeader + (*c->pElt)*c->itemSize;
-	    if ( pNextElt > c->endReq)
-	    {
-		err = BadLength;
-		goto bail;
-	    }
-	    if (client_state == START_SLEEP)
-	    {
-		c->pElt = pNextElt;
-		continue;
-	    }
-	    if (c->pDraw)
-	    {
-		lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, c->itemSize,
-				   c->pElt + TextEltHeader);
-	    }
-	    else lgerr = Successful;
-
-	    if (lgerr == Suspended)
-	    {
-		if (!c->slept) {
-		    int len;
-		    GCPtr pGC;
-		    PTclosurePtr new_closure;
-
-    /*  We're putting the client to sleep.  We need to do a few things
-	to ensure successful and atomic-appearing execution of the
-	remainder of the request.  First, copy the remainder of the
-	request into a safe malloc'd area.  Second, create a scratch GC
-	to use for the remainder of the request.  Third, mark all fonts
-	referenced in the remainder of the request to prevent their
-	deallocation.  Fourth, make the original GC look like the
-	request has completed...  set its font to the final font value
-	from this request.  These GC manipulations are for the unlikely
-	(but possible) event that some other client is using the GC.
-	Steps 3 and 4 are performed by running this procedure through
-	the remainder of the request in a special no-render mode
-	indicated by client_state = START_SLEEP.  */
-
-		    /* Step 1 */
-		    /* Allocate a malloc'd closure structure to replace
-		       the local one we were passed */
-		    new_closure = (PTclosurePtr) xalloc(sizeof(PTclosureRec));
-		    if (!new_closure)
-		    {
-			err = BadAlloc;
-			goto bail;
-		    }
-		    *new_closure = *c;
-		    c = new_closure;
-
-		    len = c->endReq - c->pElt;
-		    c->data = (unsigned char *)xalloc(len);
-		    if (!c->data)
-		    {
-			xfree(c);
-			err = BadAlloc;
-			goto bail;
-		    }
-		    memmove(c->data, c->pElt, len);
-		    c->pElt = c->data;
-		    c->endReq = c->pElt + len;
-
-		    /* Step 2 */
-
-		    pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
-		    if (!pGC)
-		    {
-			xfree(c->data);
-			xfree(c);
-			err = BadAlloc;
-			goto bail;
-		    }
-		    if ((err = CopyGC(c->pGC, pGC, GCFunction |
-				      GCPlaneMask | GCForeground |
-				      GCBackground | GCFillStyle |
-				      GCTile | GCStipple |
-				      GCTileStipXOrigin |
-				      GCTileStipYOrigin | GCFont |
-				      GCSubwindowMode | GCClipXOrigin |
-				      GCClipYOrigin | GCClipMask)) !=
-				      Success)
-		    {
-			FreeScratchGC(pGC);
-			xfree(c->data);
-			xfree(c);
-			err = BadAlloc;
-			goto bail;
-		    }
-		    origGC = c->pGC;
-		    c->pGC = pGC;
-		    ValidateGC(c->pDraw, c->pGC);
-		    
-		    /* We need to make sure that our scratch GC has
-			the correct private data */
-		    XAntiCopyGCPrivate(origGC, c->pGC);
-
-		    c->slept = TRUE;
-		    ClientSleep(client,
-		    	     (ClientSleepProcPtr)doAntiPolyText,
-			     (pointer) c);
-
-		    /* Set up to perform steps 3 and 4 */
-		    client_state = START_SLEEP;
-		    continue;	/* on to steps 3 and 4 */
-		}
-		return TRUE;
-	    }
-	    else if (lgerr != Successful)
-	    {
-		err = FontToXError(lgerr);
-		goto bail;
-	    }
-	    if (c->pDraw) {
-		AntiScreenPtr pScreenPriv = XANTI_GET_SCREEN_PRIVATE(c->pDraw);
-		XID newVals[2];
-		XID oldVals[2];
-		int mask = 0;
-
-		if(c->pGC->alu != GXcopy) {
-		   newVals[0] = GXcopy;
-		   oldVals[0] = c->pGC->alu;
-		   mask |= GCFunction;
-		} 
-
-		if(c->pGC->fillStyle != FillSolid) {
-		   newVals[1] = FillSolid;
-		   oldVals[1] = c->pGC->fillStyle;
-		   mask |= GCFillStyle;
-		   if(!(mask & GCFunction)) {
-			newVals[0] = newVals[1];
-			oldVals[0] = oldVals[1];
-		   }
-		} 
-		
-		if(mask) {
-		    ChangeGC(c->pGC, mask, newVals);
-		    ValidateGC(c->pDraw, c->pGC);
-		}
-
-		c->xorg += *((INT8 *)(c->pElt + 1));	/* must be signed */
-		if(!(*pScreenPriv->PolyTextFunc)(c)) {
-		   c->xorg = (* c->polyText)(c->pDraw, c->pGC, 
-					c->xorg, c->yorg,
-		    			*c->pElt, c->pElt + TextEltHeader);
-		}
-
-		if(mask) {
-		    ChangeGC(c->pGC, mask, oldVals);
-		    ValidateGC(c->pDraw, c->pGC);
-		}
-
-	    }
-	    c->pElt = pNextElt;
-	}
-    }
-
-bail:
-
-    if (client_state == START_SLEEP)
-    {
-	/* Step 4 */
-	if (pFont != origGC->font)
-	{
-	    ChangeGC(origGC, GCFont, &fid);
-	    ValidateGC(c->pDraw, origGC);
-	}
-
-	/* restore pElt pointer for execution of remainder of the request */
-	c->pElt = c->data;
-	return TRUE;
-    }
-
-    if (c->err != Success) err = c->err;
-    if (err != Success && c->client != serverClient) {
-	SendErrorToClient(c->client, c->reqType, 0, 0, err);
-    }
-    if (c->slept)
-    {
-	AntiGCPtr gcPriv = XANTI_GET_GC_PRIVATE(c->pGC);
-	ClientWakeup(c->client);
-	ChangeGC(c->pGC, clearGCmask, clearGC);
-
-	/* Unreference the font from the scratch GC */
-	CloseFont(c->pGC->font, (Font)0);
-	c->pGC->font = NullFont;
-
-	/* We need to make sure we free any private data */
-	if(gcPriv->Pixels) xfree(gcPriv->Pixels);
-
-	FreeScratchGC(c->pGC);
-	xfree(c->data);
-	xfree(c);
-    }
-    return TRUE;
-}
-
-static int
-AntiPolyText(
-    ClientPtr client,
-    DrawablePtr pDraw,
-    GCPtr pGC,
-    unsigned char *pElt,
-    unsigned char *endReq,
-    int xorg,
-    int yorg,
-    int reqType,
-    XID did
-){
-    PTclosureRec local_closure;
-
-    local_closure.pElt = pElt;
-    local_closure.endReq = endReq;
-    local_closure.client = client;
-    local_closure.pDraw = pDraw;
-    local_closure.xorg = xorg;
-    local_closure.yorg = yorg;
-    if ((local_closure.reqType = reqType) == XAnti_PolyText8) {
-	local_closure.polyText = (PolyTextPtr) pGC->ops->PolyText8;
-	local_closure.itemSize = 1;
-    } else {
-	local_closure.polyText =  (PolyTextPtr) pGC->ops->PolyText16;
-	local_closure.itemSize = 2;
-    }
-    local_closure.pGC = pGC;
-    local_closure.did = did;
-    local_closure.err = Success;
-    local_closure.slept = FALSE;
-
-    (void) doAntiPolyText(client, &local_closure);
-    return Success;
-}
-
-
-#undef TextEltHeader
-#undef FontShiftSize
-
-
-/**** swaps ****/
-
-
-static int 
-SProcAntiQueryExtension(ClientPtr client)
-{
-  register char n;
-  REQUEST(xAntiQueryExtensionReq);
-  swaps(&stuff->length, n);
-  return ProcAntiQueryExtension(client);
-}
-
-static int 
-SProcAntiSetInterpolationPixels(ClientPtr client)
-{
-  register char n;
-  REQUEST(xAntiSetInterpolationPixelsReq);
-  swaps(&stuff->length, n);
-  swapl(&stuff->gc, n);
-  swapl(&stuff->number, n);
-  if(stuff->number)
-     SwapLongs((CARD32*)(stuff + 1), stuff->number);
-  return ProcAntiSetInterpolationPixels(client);
-}
-
-static int 
-SProcAntiInterpolateColors(ClientPtr client)
-{
-  register char n;
-  REQUEST(xAntiInterpolateColorsReq);
-  swaps(&stuff->length, n);
-  swapl(&stuff->gc, n);
-  swapl(&stuff->colormap, n);
-  swapl(&stuff->number, n);
-  return ProcAntiInterpolateColors(client);
-}
-
-static int 
-SProcAntiPolyText(ClientPtr client)
-{
-  register char n;
-  REQUEST(xAntiPolyTextReq);
-  swaps(&stuff->length, n);
-  swapl(&stuff->drawable, n);
-  swapl(&stuff->gc, n);
-  swaps(&stuff->x, n);
-  swaps(&stuff->y, n);
-  return ProcAntiPolyText(client);
-}
-
-static int 
-SProcAntiImageText8(ClientPtr client)
-{
-  register char n;
-  REQUEST(xAntiImageText8Req);
-  swaps(&stuff->length, n);
-  swapl(&stuff->drawable, n);
-  swapl(&stuff->gc, n);
-  swaps(&stuff->x, n);
-  swaps(&stuff->y, n);
-  return ProcAntiImageText8(client);
-}
-
-static int 
-SProcAntiImageText16(ClientPtr client)
-{
-  register char n;
-  REQUEST(xAntiImageText16Req);
-  swaps(&stuff->length, n);
-  swapl(&stuff->drawable, n);
-  swapl(&stuff->gc, n);
-  swaps(&stuff->x, n);
-  swaps(&stuff->y, n);
-  return ProcAntiImageText16(client);
-}
-
Index: xc/programs/Xserver/Xext/anti.h
diff -u xc/programs/Xserver/Xext/anti.h:1.2 xc/programs/Xserver/Xext/anti.h:removed
--- xc/programs/Xserver/Xext/anti.h:1.2	Sun Jun  6 04:48:37 1999
+++ xc/programs/Xserver/Xext/anti.h	Mon Dec 18 14:27:51 2000
@@ -1,42 +0,0 @@
-/* $XFree86: xc/programs/Xserver/Xext/anti.h,v 1.2 1999/06/06 08:48:37 dawes Exp $ */
-
-#ifndef _ANTI_H
-#define _ANTI_H
-
-typedef struct {
-    CreateGCProcPtr	CreateGC;
-    Bool 		(*PolyTextFunc)(PTclosurePtr);
-    Bool 		(*ImageTextFunc)(ITclosurePtr);
-} AntiScreenRec, *AntiScreenPtr;
-
-typedef struct {
-    int 		NumPixels;
-    unsigned long 	*Pixels;
-    GCFuncs		*wrapFuncs;
-    Bool		clientData;
-    unsigned long	fg;
-    unsigned long	bg;
-} AntiGCRec, *AntiGCPtr;
-
-extern int XAntiGCIndex;
-extern int XAntiScreenIndex;
-
-void XAntiExtensionInit(void);
-
-typedef int (*GetAntiGlyphsFuncPtr)(FontPtr, unsigned long, unsigned char*, 
-		FontEncoding, unsigned long*, CharInfoPtr*, int);
-
-#define XANTI_GET_GC_PRIVATE(gc) \
-	(AntiGCPtr)((gc)->devPrivates[XAntiGCIndex].ptr)
-#define XANTI_GET_SCREEN_PRIVATE(draw) \
-	(AntiScreenPtr)((draw)->pScreen->devPrivates[XAntiScreenIndex].ptr)
-#if 1
-#define XANTI_GET_FONT_PRIVATE(font) 0 /* for now */
-#else
-#define XANTI_GET_FONT_PRIVATE(font) \
-	(antiAliasingPrivateIndex == -1) ? 0 : \
-	(GetAntiGlyphsFuncPtr)(font->devPrivates[antiAliasingPrivateIndex])
-#endif
-
-#endif /* _ANTI_H */
-
Index: xc/programs/Xserver/Xext/appgroup.c
diff -u xc/programs/Xserver/Xext/appgroup.c:1.1.1.2 xc/programs/Xserver/Xext/appgroup.c:1.3
--- xc/programs/Xserver/Xext/appgroup.c:1.1.1.2	Sun Sep 27 04:33:50 1998
+++ xc/programs/Xserver/Xext/appgroup.c	Fri Aug 11 19:59:47 2000
@@ -1,3 +1,4 @@
+/* $XFree86: xc/programs/Xserver/Xext/appgroup.c,v 1.3 2000/08/11 23:59:47 dawes Exp $ */
 /*
 Copyright 1996, 1998  The Open Group
 
@@ -559,7 +560,7 @@
     if (stuff->window_type != XagWindowTypeX11)
 #endif
 	return BadMatch;
-#ifdef WIN32 /* and Mac, etc */
+#if defined(WIN32) || defined(__CYGWIN__) /* and Mac, etc */
     if (!LocalClient (client))
 	return BadAccess;
 #endif
Index: xc/programs/Xserver/Xext/dpms.c
diff -u xc/programs/Xserver/Xext/dpms.c:3.6 xc/programs/Xserver/Xext/dpms.c:3.7
--- xc/programs/Xserver/Xext/dpms.c:3.6	Sun Mar  7 06:40:25 1999
+++ xc/programs/Xserver/Xext/dpms.c	Fri Aug 11 17:12:43 2000
@@ -32,7 +32,7 @@
  * @(#)RCSfile: dpms.c,v Revision: 1.1.4.5  (DEC) Date: 1996/03/04 15:27:00
  */
 
-/* $XFree86: xc/programs/Xserver/Xext/dpms.c,v 3.6 1999/03/07 11:40:25 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/dpms.c,v 3.7 2000/08/11 21:12:43 dawes Exp $ */
 
 #include "X.h"
 #include "Xproto.h"
@@ -115,6 +115,7 @@
 {
     REQUEST(xDPMSCapableReq);
     xDPMSCapableReply rep;
+    register int n;
 
     REQUEST_SIZE_MATCH(xDPMSCapableReq);
 
@@ -123,6 +124,9 @@
     rep.sequenceNumber = client->sequence;
     rep.capable = DPMSCapableFlag;
 
+    if (client->swapped) {
+	swaps(&rep.sequenceNumber, n);
+    }
     WriteToClient(client, sizeof(xDPMSCapableReply), (char *)&rep);
     return(client->noClientException);
 }
Index: xc/programs/Xserver/Xext/panoramiX.c
diff -u xc/programs/Xserver/Xext/panoramiX.c:3.22 xc/programs/Xserver/Xext/panoramiX.c:3.23
--- xc/programs/Xserver/Xext/panoramiX.c:3.22	Thu May 25 17:12:30 2000
+++ xc/programs/Xserver/Xext/panoramiX.c	Tue Sep 26 11:57:02 2000
@@ -19,7 +19,7 @@
 *   or  in  FAR 52.227-19, as applicable.                       *
 *                                                               *
 *****************************************************************/
-/* $XFree86: xc/programs/Xserver/Xext/panoramiX.c,v 3.22 2000/05/25 21:12:30 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/panoramiX.c,v 3.23 2000/09/26 15:57:02 tsi Exp $ */
 
 #define NEED_REPLIES
 #include <stdio.h>
@@ -963,8 +963,8 @@
     	if (client->swapped) {
 	    swaps (&rep.sequenceNumber, n);
 	    swapl (&rep.length, n);
-	    swaps (rep.width, n);
-	    swaps (rep.height, n);
+	    swaps (&rep.width, n);
+	    swaps (&rep.height, n);
 	}	
 	WriteToClient (client, sizeof (xPanoramiXGetScreenSizeReply), (char *) &rep);
 	return client->noClientException;
Index: xc/programs/Xserver/Xext/security.c
diff -u xc/programs/Xserver/Xext/security.c:1.4 xc/programs/Xserver/Xext/security.c:1.5
--- xc/programs/Xserver/Xext/security.c:1.4	Sun Oct  4 05:36:47 1998
+++ xc/programs/Xserver/Xext/security.c	Thu Aug 10 13:40:30 2000
@@ -20,7 +20,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/programs/Xserver/Xext/security.c,v 1.4 1998/10/04 09:36:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/security.c,v 1.5 2000/08/10 17:40:30 dawes Exp $ */
 
 #include "dixstruct.h"
 #include "extnsionst.h"
@@ -47,7 +47,7 @@
 #ifndef DEFAULTPOLICYFILE
 # define DEFAULTPOLICYFILE NULL
 #endif
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 #include <X11/Xos.h>
 #undef index
 #endif
Index: xc/programs/Xserver/Xext/shape.c
diff -u xc/programs/Xserver/Xext/shape.c:3.11 xc/programs/Xserver/Xext/shape.c:3.12
--- xc/programs/Xserver/Xext/shape.c:3.11	Fri Mar  3 15:50:25 2000
+++ xc/programs/Xserver/Xext/shape.c	Tue Oct 24 18:45:03 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/Xext/shape.c,v 3.11 2000/03/03 20:50:25 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/shape.c,v 3.12 2000/10/24 22:45:03 dawes Exp $ */
 /************************************************************
 
 Copyright 1989, 1998  The Open Group
@@ -669,6 +669,7 @@
     xShapeQueryExtentsReply	rep;
     BoxRec		extents, *pExtents;
     register int	n;
+    RegionPtr		region;
 
     REQUEST_SIZE_MATCH (xShapeQueryExtentsReq);
     pWin = LookupWindow (stuff->window, client);
@@ -679,9 +680,9 @@
     rep.sequenceNumber = client->sequence;
     rep.boundingShaped = (wBoundingShape(pWin) != 0);
     rep.clipShaped = (wClipShape(pWin) != 0);
-    if (wBoundingShape(pWin)) {
+    if ((region = wBoundingShape(pWin))) {
      /* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
-	pExtents = REGION_EXTENTS(pWin->drawable.pScreen, wBoundingShape(pWin));
+	pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
 	extents = *pExtents;
     } else {
 	extents.x1 = -wBorderWidth (pWin);
@@ -693,9 +694,9 @@
     rep.yBoundingShape = extents.y1;
     rep.widthBoundingShape = extents.x2 - extents.x1;
     rep.heightBoundingShape = extents.y2 - extents.y1;
-    if (wClipShape(pWin)) {
+    if ((region = wClipShape(pWin))) {
      /* this is done in two steps because of a compiler bug on SunOS 4.1.3 */
-	pExtents = REGION_EXTENTS(pWin->drawable.pScreen, wClipShape(pWin));
+	pExtents = REGION_EXTENTS(pWin->drawable.pScreen, region);
 	extents = *pExtents;
     } else {
 	extents.x1 = 0;
Index: xc/programs/Xserver/Xext/shm.c
diff -u xc/programs/Xserver/Xext/shm.c:3.26 xc/programs/Xserver/Xext/shm.c:3.27
--- xc/programs/Xserver/Xext/shm.c:3.26	Thu Apr 27 12:26:44 2000
+++ xc/programs/Xserver/Xext/shm.c	Thu Aug 10 13:40:30 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/Xext/shm.c,v 3.26 2000/04/27 16:26:44 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/shm.c,v 3.27 2000/08/10 17:40:30 dawes Exp $ */
 /************************************************************
 
 Copyright 1989, 1998  The Open Group
@@ -27,7 +27,11 @@
 
 #include <sys/types.h>
 #ifndef Lynx
+#ifndef __CYGWIN__
 #include <sys/ipc.h>
+#else
+#include <sys/cygipc.h>
+#endif
 #include <sys/shm.h>
 #else
 #include <ipc.h>
Index: xc/programs/Xserver/Xext/xf86bigfont.c
diff -u xc/programs/Xserver/Xext/xf86bigfont.c:1.9 xc/programs/Xserver/Xext/xf86bigfont.c:1.10
--- xc/programs/Xserver/Xext/xf86bigfont.c:1.9	Thu Jun 22 12:59:25 2000
+++ xc/programs/Xserver/Xext/xf86bigfont.c	Thu Aug 10 13:40:30 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/Xext/xf86bigfont.c,v 1.9 2000/06/22 16:59:25 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/xf86bigfont.c,v 1.10 2000/08/10 17:40:30 dawes Exp $ */
 /*
  * BIGFONT extension for sharing font metrics between clients (if possible)
  * and for transmitting font metrics to clients in a compressed form.
@@ -46,7 +46,7 @@
 #ifdef SVR4
 #include <sys/sysmacros.h>
 #endif
-#ifdef ISC
+#if defined(ISC) || defined(__CYGWIN__)
 #include <sys/param.h>
 #include <sys/sysmacros.h>
 #endif
@@ -98,7 +98,7 @@
 
 static unsigned int pagesize;
 
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
 
 #include <sys/signal.h>
 
Index: xc/programs/Xserver/Xext/xvdisp.c
diff -u xc/programs/Xserver/Xext/xvdisp.c:1.15 xc/programs/Xserver/Xext/xvdisp.c:1.16
--- xc/programs/Xserver/Xext/xvdisp.c:1.15	Sat Jun 10 18:00:26 2000
+++ xc/programs/Xserver/Xext/xvdisp.c	Thu Aug 10 13:40:30 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/programs/Xserver/Xext/xvdisp.c,v 1.15 2000/06/10 22:00:26 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/xvdisp.c,v 1.16 2000/08/10 17:40:30 dawes Exp $ */
 
 /*
 ** File: 
@@ -61,8 +61,10 @@
 #include "Xv.h"
 #include "Xvproto.h"
 #include "xvdix.h"
+#ifdef MITSHM
 #define _XSHM_SERVER_
 #include "shmstr.h"
+#endif
 
 #ifdef EXTMODULE
 #include "xf86_ansic.h"
@@ -73,7 +75,9 @@
 #include "panoramiXsrv.h"
 
 XvAdaptorPtr XineramaAdaptors[MAXSCREENS];
+#ifdef MITSHM
 static int XineramaXvShmPutImage(ClientPtr);
+#endif
 static int XineramaXvPutImage(ClientPtr);
 static int XineramaXvSetPortAttribute(ClientPtr);
 static int XineramaXvStopVideo(ClientPtr);
@@ -98,7 +102,9 @@
 static int ProcXvQueryBestSize(ClientPtr);
 static int ProcXvQueryPortAttributes(ClientPtr);
 static int ProcXvPutImage(ClientPtr);
+#ifdef MITSHM
 static int ProcXvShmPutImage(ClientPtr);
+#endif
 static int ProcXvQueryImageAttributes(ClientPtr);
 static int ProcXvListImageFormats(ClientPtr);
 
@@ -119,7 +125,9 @@
 static int SProcXvQueryBestSize(ClientPtr);
 static int SProcXvQueryPortAttributes(ClientPtr);
 static int SProcXvPutImage(ClientPtr);
+#ifdef MITSHM
 static int SProcXvShmPutImage(ClientPtr);
+#endif
 static int SProcXvQueryImageAttributes(ClientPtr);
 static int SProcXvListImageFormats(ClientPtr);
 
@@ -250,6 +258,7 @@
 	else
 #endif
 	    return(ProcXvPutImage(client));
+#ifdef MITSHM
     case xv_ShmPutImage: 
 #ifdef PANORAMIX
         if(!noPanoramiXExtension)
@@ -257,6 +266,7 @@
 	else
 #endif
 	    return(ProcXvShmPutImage(client));
+#endif
     case xv_QueryImageAttributes: return(ProcXvQueryImageAttributes(client));
     case xv_ListImageFormats: return(ProcXvListImageFormats(client));
     default:
@@ -300,7 +310,9 @@
     case xv_QueryBestSize: return(SProcXvQueryBestSize(client));
     case xv_QueryPortAttributes: return(SProcXvQueryPortAttributes(client));
     case xv_PutImage: return(SProcXvPutImage(client));
+#ifdef MITSHM
     case xv_ShmPutImage: return(SProcXvShmPutImage(client));
+#endif
     case xv_QueryImageAttributes: return(SProcXvQueryImageAttributes(client));
     case xv_ListImageFormats: return(SProcXvListImageFormats(client));
     default:
@@ -1069,6 +1081,7 @@
 			    stuff->width, stuff->height);
 }
 
+#ifdef MITSHM
 /* redefined here since it's not in any header file */
 typedef struct _ShmDesc {
     struct _ShmDesc *next;
@@ -1170,6 +1183,7 @@
 
   return status;
 }
+#endif
 
 
 static int 
@@ -1446,6 +1460,7 @@
   return ProcXvPutImage(client);
 }
 
+#ifdef MITSHM
 static int
 SProcXvShmPutImage(ClientPtr client)
 {
@@ -1470,6 +1485,7 @@
   swaps(&stuff->height, n);
   return ProcXvShmPutImage(client);
 }
+#endif
 
 
 static int
@@ -1864,6 +1880,7 @@
 }
 
 
+#ifdef MITSHM
 static int 
 XineramaXvShmPutImage(ClientPtr client)
 {
@@ -1910,6 +1927,7 @@
     }
     return result;
 }
+#endif
 
 static int 
 XineramaXvPutImage(ClientPtr client)
Index: xc/programs/Xserver/Xext/xvmain.c
diff -u xc/programs/Xserver/Xext/xvmain.c:1.9 xc/programs/Xserver/Xext/xvmain.c:1.11
--- xc/programs/Xserver/Xext/xvmain.c:1.9	Thu Mar 30 13:20:36 2000
+++ xc/programs/Xserver/Xext/xvmain.c	Thu Sep  7 22:29:41 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/programs/Xserver/Xext/xvmain.c,v 1.9 2000/03/30 18:20:36 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/xvmain.c,v 1.11 2000/09/08 02:29:41 mvojkovi Exp $ */
 
 /*
 ** File: 
@@ -610,7 +610,7 @@
   DrawablePtr pOldDraw;
 
   if(!drw_w || !drw_h || !vid_w || !vid_h)
-	return BadValue;
+	return Success;
 
   /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
 
@@ -664,7 +664,7 @@
   int status;
 
   if(!drw_w || !drw_h || !vid_w || !vid_h)
-	return BadValue;
+	return Success; 
 
   /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
 
@@ -705,7 +705,7 @@
    CARD16 width, CARD16 height
 ){
   if(!drw_w || !drw_h || !src_w || !src_h)
-	return BadValue;
+	return Success;
 
   /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
 
@@ -744,7 +744,7 @@
   DrawablePtr pOldDraw;
 
   if(!drw_w || !drw_h || !vid_w || !vid_h)
-	return BadValue;
+	return Success; 
 
   /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
 
@@ -798,7 +798,7 @@
   int status;
 
   if(!drw_w || !drw_h || !vid_w || !vid_h)
-	return BadValue;
+	return Success;
 
   /* UPDATE TIME VARIABLES FOR USE IN EVENTS */
 
@@ -1125,9 +1125,12 @@
 
   while (nf--)
     {
-      if ((pf->depth == pDraw->depth) &&
-	  ((pDraw->type == DRAWABLE_PIXMAP) || 
-	   (wVisual(((WindowPtr)pDraw)) == pf->visual)))
+      if ((pf->depth == pDraw->depth) 
+#if 0
+         && ((pDraw->type == DRAWABLE_PIXMAP) || 
+	   (wVisual(((WindowPtr)pDraw)) == pf->visual))
+#endif
+	)
 	return Success;
       pf++;
     }
Index: xc/programs/Xserver/Xext/extmod/Imakefile
diff -u xc/programs/Xserver/Xext/extmod/Imakefile:1.17 xc/programs/Xserver/Xext/extmod/Imakefile:1.20
--- xc/programs/Xserver/Xext/extmod/Imakefile:1.17	Sun Feb 13 01:15:31 2000
+++ xc/programs/Xserver/Xext/extmod/Imakefile	Tue Aug 15 12:05:33 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/Xext/extmod/Imakefile,v 1.17 2000/02/13 06:15:31 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/Xext/extmod/Imakefile,v 1.20 2000/08/15 16:05:33 dawes Exp $
 XCOMM This directory is only entered if DoLoadableServer is set
 
 #define IHaveModules
@@ -58,12 +58,6 @@
 LinkSourceFile(xvmod.c,..)
 #endif
 
-#if BuildXantiExt
-       XANTISRCS = anti.c
-       XANTIOBJS = anti.o
-LinkSourceFile(anti.c,..)
-#endif
-
 #if BuildEVI
          EVISRCS = EVI.c sampleEVI.c
          EVIOBJS = EVI.o sampleEVI.o
@@ -85,15 +79,15 @@
 	      bigreq.c sync.c $(SCRNSAVSRC) xcmisc.c $(VIDMODESRCS) \
 	      $(XF86MISCSRCS) $(XF86DGASRCS) \
 	      $(CUPSRCS) $(DPMSSRCS) $(FONTCACHESRCS)  \
-	      $(EVISRCS) $(XVSRCS) $(XANTISRCS) $(MODINITSRCS)
+	      $(EVISRCS) $(XVSRCS) $(MODINITSRCS)
 
       MOBJS = $(MODINITOBJS) shape.o $(MULTIBUFOBJ) mitmisc.o \
 	      bigreq.o sync.o $(SCRNSAVOBJ) xcmisc.o \
 	      $(VIDMODEOBJS) $(XF86MISCOBJS) $(XF86DGAOBJS) \
               $(CUPOBJS) $(DPMSOBJS) $(FONTCACHEOBJS) \
-	      $(EVIOBJS) $(XVOBJS) $(XANTIOBJS)
+	      $(EVIOBJS) $(XVOBJS)
 
-    DEFINES = -DEXTMODULE
+    DEFINES = -DEXTMODULE $(EXT_DEFINES)
 
 XF86INCLUDES = -I$(XF86COMSRC)
     INCLUDES = -I.. -I../../include -I$(XINCLUDESRC) -I$(EXTINCSRC) \
@@ -109,10 +103,9 @@
 ModuleObjectRule()
 
 /*
- * A hack to work around an optimisation problem with the compiler on
- * FreeBSD 4.0-current in late 1999/early 2000.
+ * A hack to work around an optimization problem with gcc 2.95.2
  */
-#if BuildXF86VidModeExt && defined(FreeBSDGccOptBug)
+#if BuildXF86VidModeExt && defined(GccOptBug295)
 SpecialCObjectRule(xf86vmode,NullParameter,-O0)
 #endif
 
Index: xc/programs/Xserver/Xext/extmod/modinit.c
diff -u xc/programs/Xserver/Xext/extmod/modinit.c:1.13 xc/programs/Xserver/Xext/extmod/modinit.c:1.14
--- xc/programs/Xserver/Xext/extmod/modinit.c:1.13	Sun Feb 13 01:15:31 2000
+++ xc/programs/Xserver/Xext/extmod/modinit.c	Tue Aug  8 23:06:55 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/Xext/extmod/modinit.c,v 1.13 2000/02/13 06:15:31 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/Xext/extmod/modinit.c,v 1.14 2000/08/09 03:06:55 tsi Exp $ */
 
 /*
  *
@@ -114,11 +114,6 @@
 #include "fontcachstr.h"
 #endif
 
-#ifdef XANTI
-extern void XAntiExtensionInit(INITARGS);
-#include "XAntiproto.h"
-#endif
-
 #ifdef TOGCUP
 extern void XcupExtensionInit(INITARGS);
 #define _XCUP_SERVER_
@@ -281,15 +276,6 @@
 	XvName,
 	NULL,
 	XvRegister,
-	NULL
-    },
-#endif
-#ifdef XANTI
-    {
-	XAntiExtensionInit,
-	XAntiName,
-	NULL,
-	NULL,
 	NULL
     },
 #endif
Index: xc/programs/Xserver/Xprint/Init.c
diff -u xc/programs/Xserver/Xprint/Init.c:1.7 xc/programs/Xserver/Xprint/Init.c:1.8
--- xc/programs/Xserver/Xprint/Init.c:1.7	Sun Dec 12 21:12:46 1999
+++ xc/programs/Xserver/Xprint/Init.c	Tue Nov 14 13:20:33 2000
@@ -50,7 +50,7 @@
 **    *********************************************************
 ** 
 ********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/Init.c,v 1.7 1999/12/13 02:12:46 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/Xprint/Init.c,v 1.8 2000/11/14 18:20:33 dawes Exp $ */
 
 #include <unistd.h>
 #include <stdlib.h>
@@ -154,7 +154,7 @@
                             "      print substr($5, 1, x-1)"
                             "   }' | sort";
 #else
-#if defined(CSRG_BASED) || defined(linux) || defined(ISC)
+#if defined(CSRG_BASED) || defined(linux) || defined(ISC) || defined(__GNUC__)
 const char *LIST_QUEUES = "LANG=C lpc status | grep -v '^\t' | "
                             "sed -e /:/s/// | sort";
 #else
Index: xc/programs/Xserver/Xprint/Xresource.h
diff -u xc/programs/Xserver/Xprint/Xresource.h:1.3 xc/programs/Xserver/Xprint/Xresource.h:1.5
--- xc/programs/Xserver/Xprint/Xresource.h:1.3	Wed Dec 15 21:26:25 1999
+++ xc/programs/Xserver/Xprint/Xresource.h	Thu Sep 28 16:17:06 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/Xprint/Xresource.h,v 1.3 1999/12/16 02:26:25 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/Xprint/Xresource.h,v 1.5 2000/09/28 20:17:06 tsi Exp $ */
 
 /* $XConsortium: Xresource.h /main/1 1996/09/28 16:59:12 rws $ */
 /*
@@ -90,7 +90,7 @@
  *
  ****************************************************************/
 
-typedef int     XrmQuark, *XrmQuarkList;
+typedef int       XrmQuark, *XrmQuarkList;
 #define NULLQUARK ((XrmQuark) 0)
 
 typedef char *XrmString;
Index: xc/programs/Xserver/Xprint/attributes.c
diff -u xc/programs/Xserver/Xprint/attributes.c:1.9 xc/programs/Xserver/Xprint/attributes.c:1.11
--- xc/programs/Xserver/Xprint/attributes.c:1.9	Sun Dec 26 19:39:32 1999
+++ xc/programs/Xserver/Xprint/attributes.c	Wed Nov  1 21:51:14 2000
@@ -44,7 +44,7 @@
 **    *********************************************************
 ** 
 ********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/attributes.c,v 1.9 1999/12/27 00:39:32 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/Xprint/attributes.c,v 1.11 2000/11/02 02:51:14 dawes Exp $ */
 
 #include <Xproto.h>
 #include <string.h>
@@ -1206,7 +1206,7 @@
 #define toascii( c ) ((unsigned)(c) & 0x007f)
 #endif
 
-#if defined(CSRG_BASED) || defined(linux) || (defined(sun) && !defined(SVR4)) || (defined(SVR4) && !defined(sun) && !defined(USL)) || defined(__EMX__) || defined(ISC) || defined(Lynx) || defined(__QNX__)
+#if defined(CSRG_BASED) || defined(linux) || defined(__CYGWIN__) || (defined(sun) && !defined(SVR4)) || (defined(SVR4) && !defined(sun) && !defined(USL)) || defined(__EMX__) || defined(ISC) || defined(Lynx) || defined(__QNX__) || defined(__DARWIN__)
 #define iswspace(c) (isascii(c) && isspace(toascii(c)))
 #endif
 
Index: xc/programs/Xserver/Xprint/pcl/PclMisc.c
diff -u xc/programs/Xserver/Xprint/pcl/PclMisc.c:1.6 xc/programs/Xserver/Xprint/pcl/PclMisc.c:1.7
--- xc/programs/Xserver/Xprint/pcl/PclMisc.c:1.6	Sun Dec 12 21:12:56 1999
+++ xc/programs/Xserver/Xprint/pcl/PclMisc.c	Wed Aug 23 17:06:19 2000
@@ -44,7 +44,12 @@
 dealings in this Software without prior written authorization from said
 copyright holders.
 */
-/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclMisc.c,v 1.6 1999/12/13 02:12:56 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclMisc.c,v 1.7 2000/08/23 21:06:19 dawes Exp $ */
+
+#ifdef __CYGWIN__
+#include <signal.h>
+#include <stdlib.h>
+#endif
 
 #include "Xos.h"	/* for SIGCLD on pre-POSIX systems */
 #include "Pcl.h"
Index: xc/programs/Xserver/afb/afb.h
diff -u xc/programs/Xserver/afb/afb.h:3.5 xc/programs/Xserver/afb/afb.h:3.6
--- xc/programs/Xserver/afb/afb.h:3.5	Sun Jun 27 12:17:29 1999
+++ xc/programs/Xserver/afb/afb.h	Fri Jul 14 20:27:07 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/afb/afb.h,v 3.5 1999/06/27 16:17:29 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/afb/afb.h,v 3.6 2000/07/15 00:27:07 mvojkovi Exp $ */
 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
 /***********************************************************
 
@@ -63,7 +63,7 @@
 extern int afbScreenPrivateIndex;
 /* warning: PixelType definition duplicated in maskbits.h */
 #ifndef PixelType
-#define PixelType unsigned long
+#define PixelType CARD32 
 #endif /* PixelType */
 
 #define AFB_MAX_DEPTH 8
Index: xc/programs/Xserver/afb/afbfillsp.c
diff -u xc/programs/Xserver/afb/afbfillsp.c:3.1 xc/programs/Xserver/afb/afbfillsp.c:3.3
--- xc/programs/Xserver/afb/afbfillsp.c:3.1	Fri Mar 20 16:04:54 1998
+++ xc/programs/Xserver/afb/afbfillsp.c	Tue Nov 21 19:58:12 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/afb/afbfillsp.c,v 3.1 1998/03/20 21:04:54 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/afb/afbfillsp.c,v 3.3 2000/11/22 00:58:12 tsi Exp $ */
 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
 /***********************************************************
 
@@ -57,6 +57,7 @@
 #include "scrnintstr.h"
 #include "windowstr.h"
 #include "afb.h"
+
 #include "maskbits.h"
 
 #include "mergerop.h"
Index: xc/programs/Xserver/afb/afbtile.c
diff -u xc/programs/Xserver/afb/afbtile.c:3.0 xc/programs/Xserver/afb/afbtile.c:3.2
--- xc/programs/Xserver/afb/afbtile.c:3.0	Sat Aug 17 21:45:57 1996
+++ xc/programs/Xserver/afb/afbtile.c	Tue Nov 21 19:58:12 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/afb/afbtile.c,v 3.0 1996/08/18 01:45:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/afb/afbtile.c,v 3.2 2000/11/22 00:58:12 tsi Exp $ */
 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
 /***********************************************************
 
@@ -57,6 +57,7 @@
 #include "scrnintstr.h"
 
 #include "afb.h"
+
 #include "maskbits.h"
 
 #include "mergerop.h"
Index: xc/programs/Xserver/cfb/Imakefile
diff -u xc/programs/Xserver/cfb/Imakefile:3.24 xc/programs/Xserver/cfb/Imakefile:3.25
--- xc/programs/Xserver/cfb/Imakefile:3.24	Mon Sep 27 02:29:16 1999
+++ xc/programs/Xserver/cfb/Imakefile	Thu Nov 30 19:24:31 2000
@@ -1,5 +1,5 @@
 XCOMM $TOG: Imakefile /main/71 1997/11/17 10:00:11 msr $
-XCOMM $XFree86: xc/programs/Xserver/cfb/Imakefile,v 3.24 1999/09/27 06:29:16 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/cfb/Imakefile,v 3.25 2000/12/01 00:24:31 dawes Exp $
 
 #define IHaveModules
 #include <Server.tmpl>
@@ -234,10 +234,10 @@
 	$(RM) stipsparcte.s
 
 stipsparc.o: stipsparc.s
-	$(CPP) stipsparc.s | $(AS) -o $@ -
+	$(CPP) stipsparc.s AsmDefines | $(AS) -o $@ -
 
 stipsparcte.o: stipsparcte.s
-	$(CPP) -DTETEXT stipsparcte.s | $(AS) -o $@ -
+	$(CPP) -DTETEXT stipsparcte.s AsmDefines | $(AS) -o $@ -
 #endif
 #endif
 
@@ -250,10 +250,10 @@
 	$(RM) stipsprcte32.s
 
 stipsprc32.o: stipsprc32.s
-	$(CPP) stipsprc32.s | $(AS) -o $@ -
+	$(CPP) stipsprc32.s AsmDefines | $(AS) -o $@ -
 
 stipsprcte32.o: stipsprcte32.s
-	$(CPP) -DTETEXT stipsprcte32.s | $(AS) -o $@ -
+	$(CPP) -DTETEXT stipsprcte32.s AsmDefines | $(AS) -o $@ -
 #endif
 #endif
 
Index: xc/programs/Xserver/cfb/cfb.h
diff -u xc/programs/Xserver/cfb/cfb.h:3.23 xc/programs/Xserver/cfb/cfb.h:3.25
--- xc/programs/Xserver/cfb/cfb.h:3.23	Fri Feb 11 22:39:19 2000
+++ xc/programs/Xserver/cfb/cfb.h	Mon Oct 23 17:16:43 2000
@@ -27,7 +27,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
-/* $XFree86: xc/programs/Xserver/cfb/cfb.h,v 3.23 2000/02/12 03:39:19 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/cfb/cfb.h,v 3.25 2000/10/23 21:16:43 tsi Exp $ */
 
 #if !defined(__CFB_H__) || defined(CFB_PROTOTYPES_ONLY)
 
@@ -1292,34 +1292,8 @@
     ((pDrawable)->type == DRAWABLE_PIXMAP ? \
      TRUE : cfbWindowEnabled((WindowPtr) pDrawable))
 
-/* Macros which handle a coordinate in a single register */
+#include "micoord.h"
 
-/* Most compilers will convert divide by 65536 into a shift, if signed
- * shifts exist.  If your machine does arithmetic shifts and your compiler
- * can't get it right, add to this line.
- */
-
-/* mips compiler - what a joke - it CSEs the 65536 constant into a reg
- * forcing as to use div instead of shift.  Let's be explicit.
- */
-
-#if defined(mips) || defined(sparc) || defined(__alpha) || defined(__alpha__) || defined(__i386__) || defined(i386)
-#define GetHighWord(x) (((int) (x)) >> 16)
-#else
-#define GetHighWord(x) (((int) (x)) / 65536)
-#endif
-
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define intToCoord(i,x,y)   (((x) = GetHighWord(i)), ((y) = (int) ((short) (i))))
-#define coordToInt(x,y)	(((x) << 16) | ((y) & 0xffff))
-#define intToX(i)	(GetHighWord(i))
-#define intToY(i)	((int) ((short) i))
-#else
-#define intToCoord(i,x,y)   (((x) = (int) ((short) (i))), ((y) = GetHighWord(i)))
-#define coordToInt(x,y)	(((y) << 16) | ((x) & 0xffff))
-#define intToX(i)	((int) ((short) (i)))
-#define intToY(i)	(GetHighWord(i))
-#endif
 /*
  * if CFB is built as a module, it shouldn't call libc functions.
  */
Index: xc/programs/Xserver/cfb/cfb8line.c
diff -u xc/programs/Xserver/cfb/cfb8line.c:3.11 xc/programs/Xserver/cfb/cfb8line.c:3.13
--- xc/programs/Xserver/cfb/cfb8line.c:3.11	Fri Feb 11 22:39:20 2000
+++ xc/programs/Xserver/cfb/cfb8line.c	Tue Oct 24 14:07:46 2000
@@ -21,7 +21,7 @@
  *
  * Author:  Keith Packard, MIT X Consortium
  *
- * $XFree86: xc/programs/Xserver/cfb/cfb8line.c,v 3.11 2000/02/12 03:39:20 dawes Exp $
+ * $XFree86: xc/programs/Xserver/cfb/cfb8line.c,v 3.13 2000/10/24 18:07:46 dawes Exp $
  * Jeff Anton'x fixes: cfb8line.c   97/02/07
  */
 
@@ -63,7 +63,8 @@
 
 #ifdef POLYSEGMENT
 
-# ifdef sun
+# if (defined(sun) || defined(__bsdi__)) && \
+     (defined(sparc) || defined(__sparc__))
 #  define WIDTH_FAST  1152
 # endif
 
@@ -144,8 +145,8 @@
 
 #if RROP == GXcopy
 #define body_rop \
-	    addrp = (PixelType *)((CfbBits)addrb & ~0x03); \
-	    switch((CfbBits)addrb & 3){ \
+	    addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+	    switch((unsigned long)addrb & 3){ \
 	    case 0: \
 	      *addrp = (*addrp & 0xFF000000)|(piQxelXor[0] & 0xFFFFFF); \
 	      break; \
@@ -164,8 +165,8 @@
 #endif
 #if RROP == GXxor
 #define body_rop \
-	    addrp = (PixelType *)((CfbBits)addrb & ~0x03); \
-	    switch((CfbBits)addrb & 3){ \
+	    addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+	    switch((unsigned long)addrb & 3){ \
 	    case 0: \
 	      *addrp ^= piQxelXor[0] & 0xFFFFFF; \
 	      break; \
@@ -184,8 +185,8 @@
 #endif
 #if RROP == GXand
 #define body_rop \
-	    addrp = (PixelType *)((CfbBits)addrb & ~0x03); \
-	    switch((CfbBits)addrb & 3){ \
+	    addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+	    switch((unsigned long)addrb & 3){ \
 	    case 0: \
 	      *addrp &= piQxelAnd[0] | 0xFF000000; \
 	      break; \
@@ -204,8 +205,8 @@
 #endif
 #if RROP == GXor
 #define body_rop \
-	    addrp = (PixelType *)((CfbBits)addrb & ~0x03); \
-	    switch((CfbBits)addrb & 3){ \
+	    addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+	    switch((unsigned long)addrb & 3){ \
 	    case 0: \
 	      *addrp |= piQxelOr[0] & 0xFFFFFF; \
 	      break; \
@@ -224,8 +225,8 @@
 #endif
 #if RROP == GXset
 #define body_rop \
-	    addrp = (PixelType *)((CfbBits)addrb & ~0x03); \
-	    switch((CfbBits)addrb & 3){ \
+	    addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+	    switch((unsigned long)addrb & 3){ \
 	    case 0: \
 	      *addrp = (*addrp & (piQxelAnd[0]|0xFF000000)) \
 			^ (piQxelXor[0] & 0xFFFFFF); \
@@ -394,7 +395,7 @@
 	addrLineEnd = addr + WIDTH_MUL(_y1, nwidth);
 	xOffset = xBase + _x1;
 	addrb = (char *)addrLineEnd + xOffset * 3;
-	addrp = (PixelType *)((CfbBits)addrb & ~0x03);
+	addrp = (PixelType *)((unsigned long)addrb & ~0x03);
 #else
 	addrp = addr + WIDTH_MUL(_y1, nwidth) + _x1;
 #endif
@@ -420,7 +421,7 @@
 	addrLineEnd = addr + WIDTH_MUL(Y2, nwidth);
 	xOffset = xBase + X2;
 	addrb = (char *)addrLineEnd + xOffset * 3;
-	addrp = (PixelType *)((CfbBits)addrb & ~0x03);
+	addrp = (PixelType *)((unsigned long)addrb & ~0x03);
 #else
 	addrp = addr + WIDTH_MUL(Y2, nwidth) + X2;
 #endif
@@ -441,7 +442,7 @@
 	addrLineEnd = addr + WIDTH_MUL(y1_or_e1, nwidth);
 	xOffset = xBase + x1_or_len;
 	addrb = (char *)addrLineEnd + xOffset * 3;
-	addrp = (PixelType *)((CfbBits)addrb & ~0x03);
+	addrp = (PixelType *)((unsigned long)addrb & ~0x03);
 #else
 	addrp = addr + WIDTH_MUL(y1_or_e1, nwidth) + x1_or_len;
 #endif
@@ -641,7 +642,7 @@
 #endif
 #endif
 #if PSZ == 24
-	addrp = (PixelType *)((CfbBits)addrb & ~0x03);
+	addrp = (PixelType *)((unsigned long)addrb & ~0x03);
 #endif
 	}
 #undef body
Index: xc/programs/Xserver/cfb/cfbbitblt.c
diff -u xc/programs/Xserver/cfb/cfbbitblt.c:1.10 xc/programs/Xserver/cfb/cfbbitblt.c:1.11
--- xc/programs/Xserver/cfb/cfbbitblt.c:1.10	Fri Feb 11 22:39:21 2000
+++ xc/programs/Xserver/cfb/cfbbitblt.c	Tue Sep 26 11:57:03 2000
@@ -2,7 +2,7 @@
  * cfb copy area
  */
 
-/* $XFree86: xc/programs/Xserver/cfb/cfbbitblt.c,v 1.10 2000/02/12 03:39:21 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbbitblt.c,v 1.11 2000/09/26 15:57:03 tsi Exp $ */
 
 /*
 
@@ -858,7 +858,7 @@
 		     * I've thrown in some optimization to at least write
 		     * some aligned 32-bit words instead of 16-bit shorts.
 		     */
-		    if ((unsigned int)psrc & 2) {
+		    if ((unsigned long)psrc & 2) {
 		        /* Write unaligned 16-bit word at left edge. */
 		        if (tmp & 0x01)
 		            *pdst = fgpixel;
Index: xc/programs/Xserver/cfb/cfbbresd.c
diff -u xc/programs/Xserver/cfb/cfbbresd.c:3.3 xc/programs/Xserver/cfb/cfbbresd.c:3.4
--- xc/programs/Xserver/cfb/cfbbresd.c:3.3	Fri Feb 11 22:39:23 2000
+++ xc/programs/Xserver/cfb/cfbbresd.c	Tue Sep 26 11:57:03 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/cfb/cfbbresd.c,v 3.3 2000/02/12 03:39:23 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbbresd.c,v 3.4 2000/09/26 15:57:03 tsi Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -179,8 +179,8 @@
     {
 #if PSZ == 24
 #define body_copy(pix) { \
-	addrp = (PixelType *)((CfbBits)addrb & ~0x03); \
-	switch((CfbBits)addrb & 3){ \
+	addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+	switch((unsigned long)addrb & 3){ \
 	case 0: \
 	  *addrp = (*addrp & 0xFF000000)|((pix)[0] & 0xFFFFFF); \
 	  break; \
@@ -228,8 +228,8 @@
     else
     {
 #define body_set(and, xor) { \
-	addrp = (PixelType *)((CfbBits)addrb & ~0x03); \
-	switch((CfbBits)addrb & 3){ \
+	addrp = (PixelType *)((unsigned long)addrb & ~0x03); \
+	switch((unsigned long)addrb & 3){ \
 	case 0: \
 	  *addrp = (*addrp & ((and)[0]|0xFF000000)) ^ ((xor)[0] & 0xFFFFFF); \
 	  break; \
Index: xc/programs/Xserver/cfb/cfbmskbits.h
diff -u xc/programs/Xserver/cfb/cfbmskbits.h:3.8 xc/programs/Xserver/cfb/cfbmskbits.h:3.10
--- xc/programs/Xserver/cfb/cfbmskbits.h:3.8	Fri Feb 11 22:39:27 2000
+++ xc/programs/Xserver/cfb/cfbmskbits.h	Tue Oct 24 14:07:46 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/cfb/cfbmskbits.h,v 3.8 2000/02/12 03:39:27 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbmskbits.h,v 3.10 2000/10/24 18:07:46 dawes Exp $ */
 /************************************************************
 Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
 
@@ -34,7 +34,9 @@
 #include	"X.h"
 #include	"Xmd.h"
 #include	"servermd.h"
-#if defined(XFREE86) || ( defined(__OpenBSD__) && defined(__alpha__) )
+#if defined(XFREE86) || ( defined(__OpenBSD__) && defined(__alpha__) ) \
+	|| (defined(__bsdi__))
+#include	"xf86_ansic.h"
 #define NO_COMPILER_H_EXTRAS
 #include	"compiler.h"
 #endif
Index: xc/programs/Xserver/cfb/cfbrrop.h
diff -u xc/programs/Xserver/cfb/cfbrrop.h:3.5 xc/programs/Xserver/cfb/cfbrrop.h:3.6
--- xc/programs/Xserver/cfb/cfbrrop.h:3.5	Fri Feb 11 22:39:30 2000
+++ xc/programs/Xserver/cfb/cfbrrop.h	Tue Oct 24 14:07:46 2000
@@ -22,7 +22,7 @@
  * Author:  Keith Packard, MIT X Consortium
  */
 
-/* $XFree86: xc/programs/Xserver/cfb/cfbrrop.h,v 3.5 2000/02/12 03:39:30 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/cfb/cfbrrop.h,v 3.6 2000/10/24 18:07:46 dawes Exp $ */
 
 #ifndef GXcopy
 #include "X.h"
@@ -320,12 +320,13 @@
 	RROP_SOLID((CfbBits *) (pdst)); \
 	(pdst) += sizeof (CfbBits) / sizeof (*pdst); \
     }
+#endif
+
 #define RROP_SPAN_lu(pdst,nmiddle) \
     while (--(nmiddle) >= 0) { \
 	RROP_SOLID_lu((CfbBits *) (pdst)); \
 	(pdst) += sizeof (CfbBits) / sizeof (*pdst); \
     }
-#endif
 
 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
 #define RROP_NAME_CAT(prefix,suffix)	prefix##suffix
Index: xc/programs/Xserver/dix/dispatch.c
diff -u xc/programs/Xserver/dix/dispatch.c:3.19 xc/programs/Xserver/dix/dispatch.c:3.22
--- xc/programs/Xserver/dix/dispatch.c:3.19	Fri May  5 13:53:46 2000
+++ xc/programs/Xserver/dix/dispatch.c	Fri Sep 22 02:21:18 2000
@@ -64,7 +64,7 @@
 *                                                               *
 *****************************************************************/
 
-/* $XFree86: xc/programs/Xserver/dix/dispatch.c,v 3.19 2000/05/05 17:53:46 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/dispatch.c,v 3.22 2000/09/22 06:21:18 keithp Exp $ */
 
 #ifdef PANORAMIX_DEBUG
 #include <stdio.h>
@@ -106,7 +106,7 @@
 #endif
 
 #define mskcnt ((MAXCLIENTS + 31) / 32)
-#define BITMASK(i) (1 << ((i) & 31))
+#define BITMASK(i) (1U << ((i) & 31))
 #define MASKIDX(i) ((i) >> 5)
 #define MASKWORD(buf, i) buf[MASKIDX(i)]
 #define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
@@ -1992,6 +1992,49 @@
     return (client->noClientException);
 }
 
+#ifdef MATCH_CLIENT_ENDIAN
+
+int
+ServerOrder (void)
+{
+    int	    whichbyte = 1;
+
+    if (*((char *) &whichbyte))
+	return LSBFirst;
+    return MSBFirst;
+}
+
+#define ClientOrder(client) ((client)->swapped ? !ServerOrder() : ServerOrder())
+
+void
+ReformatImage (char *base, int nbytes, int bpp, int order)
+{
+    switch (bpp) {
+    case 1:	/* yuck */
+	if (BITMAP_BIT_ORDER != order)
+	    BitOrderInvert ((unsigned char *) base, nbytes);
+#if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8
+	ReformatImage (base, nbytes, BITMAP_SCANLINE_UNIT, order);
+#endif
+	break;
+    case 4:
+	break;  /* yuck */
+    case 8:
+	break;
+    case 16:
+	if (IMAGE_BYTE_ORDER != order)
+	    TwoByteSwap ((unsigned char *) base, nbytes);
+	break;
+    case 32:
+	if (IMAGE_BYTE_ORDER != order)
+	    FourByteSwap ((unsigned char *) base, nbytes);
+	break;
+    }
+}
+#else
+#define ReformatImage(b,n,bpp,o)
+#endif
+
 /* 64-bit server notes: the protocol restricts padding of images to
  * 8-, 16-, or 32-bits. We would like to have 64-bits for the server
  * to use internally. Removes need for internal alignment checking.
@@ -2050,6 +2093,10 @@
 	(sizeof(xPutImageReq) >> 2)) != client->req_len)
 	return BadLength;
 
+    ReformatImage (tmpImage, lengthProto * stuff->height, 
+		   stuff->format == ZPixmap ? BitsPerPixel (stuff->depth) : 1,
+		   ClientOrder(client));
+    
     (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY,
 		  stuff->width, stuff->height, 
 		  stuff->leftPad, stuff->format, tmpImage);
@@ -2162,12 +2209,12 @@
 	{
 	    /* we have to make sure intermediate buffers don't need padding */
 	    while ((linesPerBuf > 1) &&
-		   (length & ((1 << LOG2_BYTES_PER_SCANLINE_PAD)-1)))
+		   (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1)))
 	    {
 		linesPerBuf--;
 		length -= widthBytesLine;
 	    }
-	    while (length & ((1 << LOG2_BYTES_PER_SCANLINE_PAD)-1))
+	    while (length & ((1L << LOG2_BYTES_PER_SCANLINE_PAD)-1))
 	    {
 		linesPerBuf++;
 		length += widthBytesLine;
@@ -2218,10 +2265,16 @@
 	    /* Note that this is NOT a call to WriteSwappedDataToClient,
                as we do NOT byte swap */
 	    if (!im_return)
+	    {
+		ReformatImage (pBuf, (int)(nlines * widthBytesLine),
+			       BitsPerPixel (pDraw->depth),
+			       ClientOrder(client));
+
 /* Don't split me, gcc pukes when you do */
 		(void)WriteToClient(client,
 				    (int)(nlines * widthBytesLine),
 				    pBuf);
+	    }
 	    linesDone += nlines;
         }
     }
@@ -2255,11 +2308,17 @@
 		       as we do NOT byte swap */
 		    if (im_return) {
 			pBuf += nlines * widthBytesLine;
-		    } else
+		    } else {
+			ReformatImage (pBuf, 
+				       (int)(nlines * widthBytesLine), 
+				       1,
+				       ClientOrder (client));
+
 /* Don't split me, gcc pukes when you do */
 			(void)WriteToClient(client,
 					(int)(nlines * widthBytesLine),
 					pBuf);
+		    }
 		    linesDone += nlines;
 		}
             }
@@ -3879,6 +3938,10 @@
 #endif
     ((xConnSetup *)lConnectionInfo)->ridBase = client->clientAsMask;
     ((xConnSetup *)lConnectionInfo)->ridMask = RESOURCE_ID_MASK;
+#ifdef MATCH_CLIENT_ENDIAN
+    ((xConnSetup *)lConnectionInfo)->imageByteOrder = ClientOrder (client);
+    ((xConnSetup *)lConnectionInfo)->bitmapBitOrder = ClientOrder (client);
+#endif
     /* fill in the "currentInputMask" */
     root = (xWindowRoot *)(lConnectionInfo + connBlockScreenStart);
 #ifdef PANORAMIX
Index: xc/programs/Xserver/dix/events.c
diff -u xc/programs/Xserver/dix/events.c:3.34 xc/programs/Xserver/dix/events.c:3.35
--- xc/programs/Xserver/dix/events.c:3.34	Fri May  5 13:53:48 2000
+++ xc/programs/Xserver/dix/events.c	Sun Oct 22 17:12:09 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/dix/events.c,v 3.34 2000/05/05 17:53:48 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/events.c,v 3.35 2000/10/22 21:12:09 mvojkovi Exp $ */
 /************************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -292,7 +292,7 @@
 static void PostNewCursor(void);
 
 static Bool
-PanoramiXSetCursorPosition(
+XineramaSetCursorPosition(
     int x, 
     int y, 
     Bool generateEvent
@@ -335,7 +335,7 @@
 
 
 static void
-PanoramiXConstrainCursor(void)
+XineramaConstrainCursor(void)
 {
     ScreenPtr pScreen = sprite.screen;
     BoxRec newBox = sprite.physLimits;
@@ -351,7 +351,7 @@
 }
 
 static void
-PanoramiXCheckPhysLimits(
+XineramaCheckPhysLimits(
     CursorPtr cursor,
     Bool generateEvents
 ){
@@ -382,18 +382,18 @@
 
     if((new.x != sprite.hotPhys.x) || (new.y != sprite.hotPhys.y))
     {
-	PanoramiXSetCursorPosition (new.x, new.y, generateEvents);
+	XineramaSetCursorPosition (new.x, new.y, generateEvents);
 	if (!generateEvents)
 	    SyntheticMotion(new.x, new.y);
     }
 
     /* Tell DDX what the limits are */
-    PanoramiXConstrainCursor();
+    XineramaConstrainCursor();
 }
 
 
 static Bool
-PanoramiXSetWindowPntrs(WindowPtr pWin)
+XineramaSetWindowPntrs(WindowPtr pWin)
 {
     if(pWin == WindowTable[0]) {
 	    memcpy(sprite.windows, WindowTable, 
@@ -417,7 +417,7 @@
 }
 
 static void
-PanoramiXCheckVirtualMotion(
+XineramaCheckVirtualMotion(
    QdEventPtr qe,
    WindowPtr pWin
 ){
@@ -435,7 +435,7 @@
 	int x, y, off_x, off_y, i;
 	BoxRec lims;
 
-	if(!PanoramiXSetWindowPntrs(pWin))
+	if(!XineramaSetWindowPntrs(pWin))
 	    return;
 
 	i = PanoramiXNumScreens - 1;
@@ -484,7 +484,7 @@
 
 
 static Bool
-PanoramiXCheckMotion(xEvent *xE)
+XineramaCheckMotion(xEvent *xE)
 {
     WindowPtr prevSpriteWin = sprite.win;
 
@@ -516,7 +516,7 @@
 	if ((sprite.hotPhys.x != XE_KBPTR.rootX) ||
 	    (sprite.hotPhys.y != XE_KBPTR.rootY))
 	{
-	    PanoramiXSetCursorPosition(
+	    XineramaSetCursorPosition(
 			sprite.hotPhys.x, sprite.hotPhys.y, FALSE);
 	}
 	XE_KBPTR.rootX = sprite.hot.x;
@@ -540,19 +540,19 @@
 
 
 static void
-PanoramiXConfineCursorToWindow(WindowPtr pWin, Bool generateEvents)
+XineramaConfineCursorToWindow(WindowPtr pWin, Bool generateEvents)
 {
 
     if (syncEvents.playingEvents)
     {
-	PanoramiXCheckVirtualMotion((QdEventPtr)NULL, pWin);
+	XineramaCheckVirtualMotion((QdEventPtr)NULL, pWin);
 	SyntheticMotion(sprite.hot.x, sprite.hot.y);
     }
     else
     {
 	int x, y, off_x, off_y, i;
 
-	if(!PanoramiXSetWindowPntrs(pWin))
+	if(!XineramaSetWindowPntrs(pWin))
 	    return;
 
 	i = PanoramiXNumScreens - 1;
@@ -586,19 +586,19 @@
 	sprite.confined = FALSE;
 	sprite.confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin;
 
-	PanoramiXCheckPhysLimits(sprite.current, generateEvents);
+	XineramaCheckPhysLimits(sprite.current, generateEvents);
     }
 }
 
 
 static void
-PanoramiXChangeToCursor(CursorPtr cursor)
+XineramaChangeToCursor(CursorPtr cursor)
 {
     if (cursor != sprite.current)
     {
 	if ((sprite.current->bits->xhot != cursor->bits->xhot) ||
 		(sprite.current->bits->yhot != cursor->bits->yhot))
-	    PanoramiXCheckPhysLimits(cursor, FALSE);
+	    XineramaCheckPhysLimits(cursor, FALSE);
     	(*sprite.screen->DisplayCursor)(sprite.screen, cursor);
 	sprite.current = cursor;
     }
@@ -772,7 +772,7 @@
 {
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-	PanoramiXCheckVirtualMotion(qe, pWin);
+	XineramaCheckVirtualMotion(qe, pWin);
 	return;
     }
 #endif
@@ -826,7 +826,7 @@
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-	PanoramiXConfineCursorToWindow(pWin, generateEvents);
+	XineramaConfineCursorToWindow(pWin, generateEvents);
 	return;
     }	
 #endif
@@ -864,7 +864,7 @@
 {
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-	PanoramiXChangeToCursor(cursor);
+	XineramaChangeToCursor(cursor);
 	return;
     }
 #endif
@@ -1710,7 +1710,7 @@
 
 #ifdef PANORAMIX
 static int 
-PanoramiXTryClientEventsResult(
+XineramaTryClientEventsResult(
     ClientPtr client,
     GrabPtr grab,
     Mask mask, 
@@ -1743,7 +1743,7 @@
 	    return 0;
 #ifdef PANORAMIX
 	if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) 
-	    return PanoramiXTryClientEventsResult(
+	    return XineramaTryClientEventsResult(
 			wClient(pWin), NullGrab, pWin->eventMask, filter);
 #endif
 	return TryClientEvents(wClient(pWin), pEvents, count,
@@ -1757,7 +1757,7 @@
 		return 0;
 #ifdef PANORAMIX
 	    if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) 
-	      return PanoramiXTryClientEventsResult(
+	      return XineramaTryClientEventsResult(
 			rClient(other), NullGrab, other->mask, filter);
 #endif
 	    return TryClientEvents(rClient(other), pEvents, count,
@@ -1947,7 +1947,7 @@
 	return TRUE;
 
 #ifdef PANORAMIX
-    if(!noPanoramiXExtension && PanoramiXSetWindowPntrs(pWin)) {
+    if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) {
 	int i;
 
 	for(i = 1; i < PanoramiXNumScreens; i++) {
@@ -2022,7 +2022,7 @@
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension)
-	return PanoramiXCheckMotion(xE);
+	return XineramaCheckMotion(xE);
 #endif
 
     if (xE && !syncEvents.playingEvents)
@@ -2157,9 +2157,9 @@
 	    sprite.screen = newScreen;
 	    /* Make sure we tell the DDX to update its copy of the screen */
 	    if(sprite.confineWin)
-		PanoramiXConfineCursorToWindow(sprite.confineWin, TRUE);
+		XineramaConfineCursorToWindow(sprite.confineWin, TRUE);
 	    else
-		PanoramiXConfineCursorToWindow(WindowTable[0], TRUE);
+		XineramaConfineCursorToWindow(WindowTable[0], TRUE);
 	    /* if the pointer wasn't confined, the DDX won't get 
 	       told of the pointer warp so we reposition it here */
 	    if(!syncEvents.playingEvents)
@@ -2178,7 +2178,7 @@
 #ifdef PANORAMIX
 
 static Bool
-PanoramiXPointInWindowIsVisible(
+XineramaPointInWindowIsVisible(
     WindowPtr pWin,
     int x,
     int y
@@ -2193,7 +2193,7 @@
     if (POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
         return TRUE;
     
-    if(!PanoramiXSetWindowPntrs(pWin)) return FALSE;
+    if(!XineramaSetWindowPntrs(pWin)) return FALSE;
 
     xoff = x + panoramiXdataPtr[0].x;  
     yoff = y + panoramiXdataPtr[0].y;  
@@ -2213,7 +2213,7 @@
 }
 
 static int
-PanoramiXWarpPointer(ClientPtr client)
+XineramaWarpPointer(ClientPtr client)
 {
     WindowPtr	dest = NULL;
     int		x, y;
@@ -2251,7 +2251,7 @@
 	     winX + stuff->srcX + (int)stuff->srcWidth < x) ||
 	    (stuff->srcHeight != 0 &&
 	     winY + stuff->srcY + (int)stuff->srcHeight < y) ||
-	    !PanoramiXPointInWindowIsVisible(source, x, y))
+	    !XineramaPointInWindowIsVisible(source, x, y))
 	    return Success;
     }
     if (dest) {
@@ -2277,7 +2277,7 @@
     if (sprite.hotShape)
 	ConfineToShape(sprite.hotShape, &x, &y);
 
-    PanoramiXSetCursorPosition(x, y, TRUE);
+    XineramaSetCursorPosition(x, y, TRUE);
 
     return Success;
 }
@@ -2299,7 +2299,7 @@
 
 #ifdef PANORAMIX
     if(!noPanoramiXExtension)
-	return PanoramiXWarpPointer(client);
+	return XineramaWarpPointer(client);
 #endif
 
     if (stuff->dstWid != None)
@@ -2382,7 +2382,7 @@
 	return TRUE;
 
 #ifdef PANORAMIX
-     if(!noPanoramiXExtension && PanoramiXSetWindowPntrs(pWin)) {
+     if(!noPanoramiXExtension && XineramaSetWindowPntrs(pWin)) {
 	int i;
 
 	for(i = 1; i < PanoramiXNumScreens; i++) {
Index: xc/programs/Xserver/dix/main.c
diff -u xc/programs/Xserver/dix/main.c:3.29 xc/programs/Xserver/dix/main.c:3.31
--- xc/programs/Xserver/dix/main.c:3.29	Thu Jun 15 21:50:19 2000
+++ xc/programs/Xserver/dix/main.c	Thu Nov 30 18:30:02 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/dix/main.c,v 3.29 2000/06/16 01:50:19 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/main.c,v 3.31 2000/11/30 23:30:02 dawes Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -256,6 +256,7 @@
     char	*envp[];
 {
     int		i, j, k, error;
+    char	*xauthfile;
     HWEventQueueType	alwaysCheckForInput[2];
 
     /* Notice if we're restarted.  Probably this is because we jumped through
@@ -267,6 +268,8 @@
 
     CheckUserParameters(argc, argv, envp);
 
+    CheckUserAuthorization();
+
 #ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
     ExpandCommandLine(&argc, &argv);
 #endif
@@ -279,6 +282,10 @@
     argcGlobal = argc;
     argvGlobal = argv;
     display = "0";
+    /* prep X authority file from environment; this can be overriden by a
+     * command line option */
+    xauthfile = getenv("XAUTHORITY");
+    if (xauthfile) InitAuthorization (xauthfile);
     ProcessCommandLine(argc, argv);
 
     alwaysCheckForInput[0] = 0;
@@ -286,7 +293,7 @@
     while(1)
     {
 	serverGeneration++;
-        ScreenSaverTime = defaultScreenSaverTime;
+	ScreenSaverTime = defaultScreenSaverTime;
 	ScreenSaverInterval = defaultScreenSaverInterval;
 	ScreenSaverBlanking = defaultScreenSaverBlanking;
 	ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
Index: xc/programs/Xserver/dix/swaprep.c
diff -u xc/programs/Xserver/dix/swaprep.c:3.4 xc/programs/Xserver/dix/swaprep.c:3.5
--- xc/programs/Xserver/dix/swaprep.c:3.4	Tue Aug 31 04:39:03 1999
+++ xc/programs/Xserver/dix/swaprep.c	Thu Nov  2 19:06:35 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/dix/swaprep.c,v 3.4 1999/08/31 08:39:03 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/swaprep.c,v 3.5 2000/11/03 00:06:35 mvojkovi Exp $ */
 /************************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -1312,57 +1312,47 @@
 }
 
 void
-SwapConnSetupInfo(pInfo, pInfoTBase)
-    char 		*pInfo;
-    char 		*pInfoTBase;
+SwapConnSetupInfo(
+    char 	*pInfo,
+    char 	*pInfoT
+)
 {
     int		i, j, k;
-    ScreenPtr	pScreen;
-    DepthPtr	pDepth;
-    char	*pInfoT;
     xConnSetup	*pConnSetup = (xConnSetup *)pInfo;
-    int         numScreens;
+    xDepth	*depth;
+    xWindowRoot *root;
 
-    pInfoT = pInfoTBase;
     SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT);
     pInfo += sizeof(xConnSetup);
     pInfoT += sizeof(xConnSetup);
 
     /* Copy the vendor string */
     i = (pConnSetup->nbytesVendor + 3) & ~3;
-    memmove(pInfoT, pInfo, i);
+    memcpy(pInfoT, pInfo, i);
     pInfo += i;
     pInfoT += i;
 
     /* The Pixmap formats don't need to be swapped, just copied. */
-    i = sizeof(xPixmapFormat) * screenInfo.numPixmapFormats;
-    memmove(pInfoT, pInfo, i);
+    i = sizeof(xPixmapFormat) * pConnSetup->numFormats;
+    memcpy(pInfoT, pInfo, i);
     pInfo += i;
     pInfoT += i;
 
-#ifndef PANORAMIX
-    numScreens = screenInfo.numScreens;
-#else
-    if (noPanoramiXExtension)
-	numScreens = screenInfo.numScreens;
-    else
-	numScreens = pConnSetup->numRoots;
-#endif
-
-    for(i = 0; i < numScreens; i++)
+    for(i = 0; i < pConnSetup->numRoots; i++)
     {
-	pScreen = screenInfo.screens[i];
-	SwapWinRoot((xWindowRoot *)pInfo, (xWindowRoot *)pInfoT);
+	root = (xWindowRoot*)pInfo;
+	SwapWinRoot(root, (xWindowRoot *)pInfoT);
 	pInfo += sizeof(xWindowRoot);
 	pInfoT += sizeof(xWindowRoot);
-	pDepth = pScreen->allowedDepths;
-	for(j = 0; j < pScreen->numDepths; j++, pDepth++)
+
+	for(j = 0; j < root->nDepths; j++)
 	{
-            ((xDepth *)pInfoT)->depth = ((xDepth *)pInfo)->depth;
-	    cpswaps(((xDepth *)pInfo)->nVisuals, ((xDepth *)pInfoT)->nVisuals);
+	    depth = (xDepth*)pInfo;
+            ((xDepth *)pInfoT)->depth = depth->depth;
+	    cpswaps(depth->nVisuals, ((xDepth *)pInfoT)->nVisuals);
 	    pInfo += sizeof(xDepth);
 	    pInfoT += sizeof(xDepth);
-	    for(k = 0; k < pDepth->numVids; k++)
+	    for(k = 0; k < depth->nVisuals; k++)
 	    {
 		SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT);
 		pInfo += sizeof(xVisualType);
Index: xc/programs/Xserver/fb/Imakefile
diff -u xc/programs/Xserver/fb/Imakefile:1.8 xc/programs/Xserver/fb/Imakefile:1.12
--- xc/programs/Xserver/fb/Imakefile:1.8	Sat May  6 17:09:29 2000
+++ xc/programs/Xserver/fb/Imakefile	Mon Oct  2 01:25:46 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/fb/Imakefile,v 1.8 2000/05/06 21:09:29 keithp Exp $
+XCOMM $XFree86: xc/programs/Xserver/fb/Imakefile,v 1.12 2000/10/02 05:25:46 keithp Exp $
 XCOMM 
 XCOMM 
 XCOMM Id: Imakefile,v 1.1 1999/11/02 03:54:44 keithp Exp $
@@ -16,6 +16,10 @@
 XFMODOBJ = fbmodule.o
 #endif
 #endif
+#if BuildRender
+PICTSRCS = fbpict.c
+PICTOBJS = fbpict.o
+#endif
 
 SRCS =	$(XFMODSRC) \
 	fballpriv.c \
@@ -24,6 +28,7 @@
 	fbbltone.c \
 	fbbstore.c \
 	fbcmap.c \
+	fbcompose.c \
 	fbcopy.c \
 	fbfill.c \
 	fbfillrect.c \
@@ -45,7 +50,8 @@
 	fbtile.c \
 	fbutil.c \
 	fbwindow.c \
-	fb24_32.c
+	fb24_32.c \
+	$(PICTSRCS)
 
 OBJS =	$(XFMODOBJ) \
 	fbarc.o \
@@ -55,6 +61,7 @@
 	fbbltone.o \
 	fbbstore.o \
 	fbcmap.o \
+	fbcompose.o \
 	fbcopy.o \
 	fbfill.o \
 	fbfillrect.o \
@@ -76,15 +83,17 @@
 	fbtile.o \
 	fbutil.o \
 	fbwindow.o \
-	fb24_32.o
+	fb24_32.o \
+	$(PICTOBJS)
 	
    INCLUDES = -I. -I../mi -I../include -I$(XINCLUDESRC) \
-	      -I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES)
+	      -I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES) \
+	      -I../render -I$(EXTINCSRC)
    LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln \
 	     ../mi/llib-lmi.ln
 
-NormalLibraryObjectRule()
-NormalLibraryTarget(fb,$(OBJS))
+ModuleObjectRule()
+LibraryModuleTarget(fb,$(OBJS))
 LintLibraryTarget(fb,$(SRCS))
 
 NormalLintTarget($(SRCS))
Index: xc/programs/Xserver/fb/fb.h
diff -u xc/programs/Xserver/fb/fb.h:1.16 xc/programs/Xserver/fb/fb.h:1.22
--- xc/programs/Xserver/fb/fb.h:1.16	Sat May  6 17:09:30 2000
+++ xc/programs/Xserver/fb/fb.h	Thu Nov  2 11:33:26 2000
@@ -1,5 +1,5 @@
 /*
- * Id: fb.h,v 1.1 1999/11/02 03:54:45 keithp Exp $
+ * $XFree86: xc/programs/Xserver/fb/fb.h,v 1.22 2000/11/02 16:33:26 tsi Exp $
  *
  * Copyright © 1998 Keith Packard
  *
@@ -21,7 +21,6 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fb.h,v 1.16 2000/05/06 21:09:30 keithp Exp $ */
 
 #ifndef _FB_H_
 #define _FB_H_
@@ -39,6 +38,9 @@
 #include "mi.h"
 #include "migc.h"
 #include "mibstore.h"
+#ifdef RENDER
+#include "picturestr.h"
+#endif
 
 /*
  * This single define controls the basic size of data manipulated
@@ -70,14 +72,6 @@
 #endif
 
 /*
- * 24bpp code doesn't work on BE machines yet; I need something to
- * test on.
- */
-#if BITMAP_BIT_ORDER == MSBFirst
-#undef FB_24BIT
-#endif
-
-/*
  * Unless otherwise instructed, fb includes code to advertise 24bpp
  * windows with 32bpp image format for application compatibility
  */
@@ -105,7 +99,8 @@
 # ifdef WIN32
 typedef unsigned __int64    FbBits;
 # else
-#  ifdef __alpha__
+#  if defined(__alpha__) || defined(__alpha) || \
+      defined(ia64) || defined(__ia64__)
 typedef unsigned long	    FbBits;
 #  else
 typedef unsigned long long  FbBits;
@@ -157,20 +152,8 @@
 #define FbPatternOffsetBits	(sizeof (FbBits) - 1)
 #endif
 
-#define GetHighWord(x) (((int) (x)) >> 16)
+#include "micoord.h"
 
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define intToCoord(i,x,y)   (((x) = GetHighWord(i)), ((y) = (int) ((short) (i))))
-#define coordToInt(x,y)	(((x) << 16) | (y))
-#define intToX(i)	(GetHighWord(i))
-#define intToY(i)	((int) ((short) i))
-#else
-#define intToCoord(i,x,y)   (((x) = (int) ((short) (i))), ((y) = GetHighWord(i)))
-#define coordToInt(x,y)	(((y) << 16) | (x))
-#define intToX(i)	((int) ((short) (i)))
-#define intToY(i)	(GetHighWord(i))
-#endif
-
 #define FbStipLeft(x,n)	FbScrLeft(x,n)
 #define FbStipRight(x,n) FbScrRight(x,n)
 
@@ -500,10 +483,24 @@
 #if FB_UNIT == 64
 #define FbNext24Rot(r)        ((r) == 16 ? 0 : (r) + 8)
 #define FbPrev24Rot(r)        ((r) == 0 ? 16 : (r) - 8)
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define FbFirst24Rot(x)		(((x) + 8) % 24)
+#else
+#define FbFirst24Rot(x)		((x) % 24)
 #endif
+
+#endif
+
 #if FB_UNIT == 32
 #define FbNext24Rot(r)        ((r) == 0 ? 16 : (r) - 8)
 #define FbPrev24Rot(r)        ((r) == 16 ? 0 : (r) + 8)
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define FbFirst24Rot(x)		(((x) + 16) % 24)
+#else
+#define FbFirst24Rot(x)		((x) % 24)
+#endif
 #endif
 
 #define FbNext24RotStip(r)        ((r) == 0 ? 16 : (r) - 8)
@@ -737,8 +734,8 @@
 	     int	    signdx,
 	     int	    signdy,
 	     int	    axis,
-	     int	    x1,
-	     int	    y1,
+	     int	    x,
+	     int	    y,
 	     int	    e,
 	     int	    e1,
 	     int	    e3,
@@ -751,8 +748,8 @@
 	     int	    signdx,
 	     int	    signdy,
 	     int	    axis,
-	     int	    x1,
-	     int	    y1,
+	     int	    x,
+	     int	    y,
 	     int	    e,
 	     int	    e1,
 	     int	    e3,
@@ -809,8 +806,8 @@
 	      int	    signdx,
 	      int	    signdy,
 	      int	    axis,
-	      int	    x1,
-	      int	    y1,
+	      int	    x,
+	      int	    y,
 	      int	    e,
 	      int	    e1,
 	      int	    e3,
@@ -823,8 +820,8 @@
 	     int	    signdx,
 	     int	    signdy,
 	     int	    axis,
-	     int	    x1,
-	     int	    y1,
+	     int	    x,
+	     int	    y,
 	     int	    e,
 	     int	    e1,
 	     int	    e3,
@@ -882,8 +879,8 @@
 	      int	    signdx,
 	      int	    signdy,
 	      int	    axis,
-	      int	    x1,
-	      int	    y1,
+	      int	    x,
+	      int	    y,
 	      int	    e,
 	      int	    e1,
 	      int	    e3,
@@ -896,8 +893,8 @@
 	     int	    signdx,
 	     int	    signdy,
 	     int	    axis,
-	     int	    x1,
-	     int	    y1,
+	     int	    x,
+	     int	    y,
 	     int	    e,
 	     int	    e1,
 	     int	    e3,
@@ -955,8 +952,8 @@
 	      int	    signdx,
 	      int	    signdy,
 	      int	    axis,
-	      int	    x1,
-	      int	    y1,
+	      int	    x,
+	      int	    y,
 	      int	    e,
 	      int	    e1,
 	      int	    e3,
@@ -969,8 +966,8 @@
 	     int	    signdx,
 	     int	    signdy,
 	     int	    axis,
-	     int	    x1,
-	     int	    y1,
+	     int	    x,
+	     int	    y,
 	     int	    e,
 	     int	    e1,
 	     int	    e3,
@@ -1313,10 +1310,10 @@
 void
 fbSolidBoxClipped (DrawablePtr	pDrawable,
 		   RegionPtr	pClip,
-		   int		x1,
-		   int		y1,
-		   int		x2,
-		   int		y2,
+		   int		xa,
+		   int		ya,
+		   int		xb,
+		   int		yb,
 		   FbBits	and,
 		   FbBits	xor);
 
@@ -1490,6 +1487,29 @@
 #define fbPolyRectangle	miPolyRectangle
 
 /*
+ * fbpict.c
+ */
+
+#ifdef RENDER
+void
+fbComposite (CARD8      op,
+	     PicturePtr pSrc,
+	     PicturePtr pMask,
+	     PicturePtr pDst,
+	     INT16      xSrc,
+	     INT16      ySrc,
+	     INT16      xMask,
+	     INT16      yMask,
+	     INT16      xDst,
+	     INT16      yDst,
+	     CARD16     width,
+	     CARD16     height);
+
+Bool
+fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+#endif
+
+/*
  * fbpixmap.c
  */
 
@@ -1599,7 +1619,7 @@
  */
 
 Bool
-fbCloseScreen (int index, ScreenPtr pScreen);
+fbCloseScreen (int indx, ScreenPtr pScreen);
 
 Bool
 fbRealizeFont(ScreenPtr pScreen, FontPtr pFont);
@@ -1654,8 +1674,8 @@
 			int		signdx,
 			int		signdy,
 			int		axis,
-			int		x1,
-			int		y1,
+			int		x,
+			int		y,
 			int		e,
 			int		e1,
 			int		e3,
@@ -1686,8 +1706,8 @@
 	int		signdx,
 	int		signdy,
 	int		axis,
-	int		x1,
-	int		y1,
+	int		x,
+	int		y,
 	int		e,
 	int		e1,
 	int		e3,
@@ -1696,10 +1716,10 @@
 void
 fbSegment (DrawablePtr	pDrawable,
 	   GCPtr	pGC,
-	   int		x1,
-	   int		y1,
-	   int		x2,
-	   int		y2,
+	   int		xa,
+	   int		ya,
+	   int		xb,
+	   int		yb,
 	   Bool		drawLast,
 	   int		*dashOffset);
 
Index: xc/programs/Xserver/fb/fb24_32.c
diff -u xc/programs/Xserver/fb/fb24_32.c:1.3 xc/programs/Xserver/fb/fb24_32.c:1.4
--- xc/programs/Xserver/fb/fb24_32.c:1.3	Sat May  6 17:09:31 2000
+++ xc/programs/Xserver/fb/fb24_32.c	Wed Aug  9 13:50:51 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/Xserver/fb/fb24_32.c,v 1.3 2000/05/06 21:09:31 keithp Exp $
+ * $XFree86: xc/programs/Xserver/fb/fb24_32.c,v 1.4 2000/08/09 17:50:51 keithp Exp $
  *
  * Copyright © 2000 SuSE, Inc.
  *
@@ -555,7 +555,6 @@
 	    GXcopy,
 	    FB_ALLONES);
 
-    (*pScreen->DestroyPixmap) (pOldTile);
     return pNewTile;
 }
 
Index: xc/programs/Xserver/fb/fbblt.c
diff -u xc/programs/Xserver/fb/fbblt.c:1.6 xc/programs/Xserver/fb/fbblt.c:1.8
--- xc/programs/Xserver/fb/fbblt.c:1.6	Wed Feb 23 15:29:42 2000
+++ xc/programs/Xserver/fb/fbblt.c	Wed Sep 27 20:47:22 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbblt.c,v 1.6 2000/02/23 20:29:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbblt.c,v 1.8 2000/09/28 00:47:22 keithp Exp $ */
 
 #include "fb.h"
 
@@ -312,8 +312,8 @@
 
 #ifdef FB_24BIT
 
-#if 0
-#include <stdio.h>
+#undef DEBUG_BLT24
+#ifdef DEBUG_BLT24
 
 static unsigned long
 getPixel (char *src, int x)
@@ -340,8 +340,12 @@
 	 
 	     Bool	    reverse)
 {
-    char    *origDst;
-    int	    origX;
+#ifdef DEBUG_BLT24
+    char    *origDst = (char *) dst;
+    FbBits  *origLine = dst + ((dstX >> FB_SHIFT) - 1);
+    int	    origNlw = ((width + FB_MASK) >> FB_SHIFT) + 3;
+    int	    origX = dstX / 24;
+#endif
     
     int	    leftShift, rightShift;
     FbBits  startmask, endmask;
@@ -352,17 +356,21 @@
 
     int	    rot;
     FbDeclareMergeRop ();
-
-    origDst = (char *) dst;
-    origX = dstX / 24;
     
     FbInitializeMergeRop (alu, FB_ALLONES);
     FbMaskBits(dstX, width, startmask, n, endmask);
+#ifdef DEBUG_BLT24
+    ErrorF ("dstX %d width %d reverse %d\n", dstX, width, reverse);
+#endif
     if (reverse)
     {
 	src += ((srcX + width - 1) >> FB_SHIFT) + 1;
 	dst += ((dstX + width - 1) >> FB_SHIFT) + 1;
-	rot = ((dstX + width) & FB_MASK) % 24;
+	rot = FbFirst24Rot (((dstX + width - 8) & FB_MASK));
+	rot = FbPrev24Rot(rot);
+#ifdef DEBUG_BLT24
+	ErrorF ("dstX + width - 8: %d rot: %d\n", (dstX + width - 8) & FB_MASK, rot);
+#endif
 	srcX = (srcX + width - 1) & FB_MASK;
 	dstX = (dstX + width - 1) & FB_MASK;
     }
@@ -372,9 +380,15 @@
 	dst += dstX >> FB_SHIFT;
 	srcX &= FB_MASK;
 	dstX &= FB_MASK;
-	rot = dstX % 24;
+	rot = FbFirst24Rot (dstX);
+#ifdef DEBUG_BLT24
+	ErrorF ("dstX: %d rot: %d\n", dstX, rot);
+#endif
     }
     mask = FbRot24(pm,rot);
+#ifdef DEBUG_BLT24
+    ErrorF ("pm 0x%x mask 0x%x\n", pm, mask);
+#endif
     if (srcX == dstX)
     {
 	if (reverse)
@@ -508,7 +522,7 @@
 	    }
 	}
     }
-#if 0
+#ifdef DEBUG_BLT24
     {
 	int firstx, lastx, x;
 
@@ -517,9 +531,12 @@
 	    firstx--;
 	lastx = origX + width/24 + 1;
 	for (x = firstx; x <= lastx; x++)
-	    fprintf (stderr, "%06x ", getPixel (origDst, x));
+	    ErrorF ("%06x ", getPixel (origDst, x));
+	ErrorF ("\n");
+	while (origNlw--)
+	    ErrorF ("%08x ", *origLine++);
+	ErrorF ("\n");
     }
-    fprintf (stderr, "\n");
 #endif
 }
 
@@ -554,8 +571,8 @@
 	srcLine += srcStride;
 	dstLine += dstStride;
     }
-#if 0
-    fprintf (stderr, "\n");
+#ifdef DEBUG_BLT24
+    ErrorF ("\n");
 #endif
 }
 #endif /* FB_24BIT */
Index: xc/programs/Xserver/fb/fbbltone.c
diff -u xc/programs/Xserver/fb/fbbltone.c:1.9 xc/programs/Xserver/fb/fbbltone.c:1.10
--- xc/programs/Xserver/fb/fbbltone.c:1.9	Sat May  6 17:09:32 2000
+++ xc/programs/Xserver/fb/fbbltone.c	Fri Sep 22 01:58:01 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbbltone.c,v 1.9 2000/05/06 21:09:32 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbbltone.c,v 1.10 2000/09/22 05:58:01 keithp Exp $ */
 
 #include "fb.h"
 
@@ -419,15 +419,20 @@
  * is to avoid compile-time warnings about shift overflow
  */
 
+#if BITMAP_BIT_ORDER == MSBFirst
+#define Mask24Pos(x,r) ((x)*24-(r))
+#else
 #define Mask24Pos(x,r) ((x)*24-((r) ? 24 - (r) : 0))
+#endif
+
 #define Mask24Neg(x,r)	(Mask24Pos(x,r) < 0 ? -Mask24Pos(x,r) : 0)
 #define Mask24Check(x,r)    (Mask24Pos(x,r) < 0 ? 0 : \
 			     Mask24Pos(x,r) >= FB_UNIT ? 0 : Mask24Pos(x,r))
+
 #define Mask24(x,r) (Mask24Pos(x,r) < FB_UNIT ? \
 		     (Mask24Pos(x,r) < 0 ? \
-		      FbScrLeft (FbBitsMask(0,24),Mask24Neg(x,r)) : \
-		      FbScrRight (FbBitsMask(0,24),Mask24Check(x,r))) \
-		     : 0)
+		      0xffffff >> Mask24Neg (x,r) : \
+		      0xffffff << Mask24Check(x,r)) : 0)
 
 #define SelMask24(b,n,r)	((((b) >> n) & 1) * Mask24(n,r))
 
@@ -477,7 +482,11 @@
      SelMask24(b,1,r))
 
 #define FbStip24Len	    2
+#if BITMAP_BIT_ORDER == MSBFirst
+#define FbStip24New(rot)    (1 + (rot == 0))
+#else
 #define FbStip24New(rot)    (1 + (rot == 8))
+#endif
 
 const FbBits	fbStipple24Bits[3][1 << FbStip24Len] = {
     /* rotate 0 */
@@ -495,6 +504,15 @@
 };
 #endif
 
+#if BITMAP_BIT_ORDER == LSBFirst
+#define FbMergeStip24Bits(left, right, new) (((left) >> (new)) | \
+					     (right) << (FbStip24Len - (new)))
+#else
+#define FbMergeStip24Bits(left, right, new) (((left << new) & \
+					      ((1 << FbStip24Len) - 1)) | \
+					     right)
+#endif
+
 #define fbFirstStipBits(len,stip) {\
     int	__len = (len); \
     if (len <= remain) { \
@@ -514,15 +532,14 @@
     bits = FbStipLeft (*src++,offset); \
     remain = FB_STIP_UNIT - offset; \
     fbFirstStipBits(len,stip); \
-    stip = FbStipRight (stip, FbStip24Len - len); \
+    stip = FbMergeStip24Bits (0, stip, len); \
 }
     
 #define fbNextStipBits(rot,stip) {\
     int	    __new = FbStip24New(rot); \
     FbStip  __right; \
     fbFirstStipBits(__new, __right); \
-    stip = (FbStipLeft (stip, __new) | \
-	    FbStipRight (__right, FbStip24Len - __new)); \
+    stip = FbMergeStip24Bits (stip, __right, __new); \
     rot = FbNext24Rot (rot); \
 }
 
@@ -566,7 +583,7 @@
     dst += dstX >> FB_SHIFT;
     srcX &= FB_STIP_MASK;
     dstX &= FB_MASK;
-    rot0 = dstX % 24;
+    rot0 = FbFirst24Rot (dstX);
     
     FbMaskBits (dstX, width, leftMask, nlMiddle, rightMask);
     
@@ -765,7 +782,7 @@
     {
 	int w = 24;
 
-	rot0 = srcX % 24;
+	rot0 = FbFirst24Rot (srcX);
 	if (srcX + w > FB_UNIT)
 	    w = FB_UNIT - srcX;
 	srcMaskFirst = FbRot24(pm,rot0) & FbBitsMask(srcX,w);
Index: xc/programs/Xserver/fb/fbcmap.c
diff -u xc/programs/Xserver/fb/fbcmap.c:1.4 xc/programs/Xserver/fb/fbcmap.c:1.5
--- xc/programs/Xserver/fb/fbcmap.c:1.4	Mon Feb 14 14:20:28 2000
+++ xc/programs/Xserver/fb/fbcmap.c	Tue Sep 19 20:09:13 2000
@@ -1,5 +1,5 @@
 /* $XConsortium: fbcmap.c,v 4.19 94/04/17 20:28:46 dpw Exp $ */
-/* $XFree86: xc/programs/Xserver/fb/fbcmap.c,v 1.4 2000/02/14 19:20:28 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbcmap.c,v 1.5 2000/09/20 00:09:13 keithp Exp $ */
 /************************************************************
 Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
 
@@ -94,41 +94,18 @@
     int shift = 16 - pVisual->bitsPerRGBValue;
     unsigned lim = (1 << pVisual->bitsPerRGBValue) - 1;
 
-    if ((pVisual->class == PseudoColor) || (pVisual->class == DirectColor))
+    if ((pVisual->class | DynamicClass) == GrayScale)
     {
-	/* rescale to rgb bits */
-	*pred = ((*pred >> shift) * 65535) / lim;
-	*pgreen = ((*pgreen >> shift) * 65535) / lim;
-	*pblue = ((*pblue >> shift) * 65535) / lim;
-    }
-    else if (pVisual->class == GrayScale)
-    {
 	/* rescale to gray then rgb bits */
 	*pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100;
 	*pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim;
     }
-    else if (pVisual->class == StaticGray)
-    {
-	unsigned limg = pVisual->ColormapEntries - 1;
-	/* rescale to gray then [0..limg] then [0..65535] then rgb bits */
-	*pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100;
-	*pred = ((((*pred * (limg + 1))) >> 16) * 65535) / limg;
-	*pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim;
-    }
     else
     {
-	unsigned limr, limg, limb;
-
-	limr = pVisual->redMask >> pVisual->offsetRed;
-	limg = pVisual->greenMask >> pVisual->offsetGreen;
-	limb = pVisual->blueMask >> pVisual->offsetBlue;
-	/* rescale to [0..limN] then [0..65535] then rgb bits */
-	*pred = ((((((*pred * (limr + 1)) >> 16) *
-		    65535) / limr) >> shift) * 65535) / lim;
-	*pgreen = ((((((*pgreen * (limg + 1)) >> 16) *
-		      65535) / limg) >> shift) * 65535) / lim;
-	*pblue = ((((((*pblue * (limb + 1)) >> 16) *
-		     65535) / limb) >> shift) * 65535) / lim;
+	/* rescale to rgb bits */
+	*pred = ((*pred >> shift) * 65535) / lim;
+	*pgreen = ((*pgreen >> shift) * 65535) / lim;
+	*pblue = ((*pblue >> shift) * 65535) / lim;
     }
 }
 
@@ -163,24 +140,39 @@
     }
     else if (pVisual->class == StaticColor)
     {
-	unsigned limr, limg, limb;
-
-	limr = pVisual->redMask >> pVisual->offsetRed;
-	limg = pVisual->greenMask >> pVisual->offsetGreen;
-	limb = pVisual->blueMask >> pVisual->offsetBlue;
-	for(i = 0; i <= maxent; i++)
+	unsigned	n;
+	unsigned	r, g, b;
+	unsigned	red, green, blue;
+
+	for (n = 0; n*n*n < pVisual->ColormapEntries; n++)
+	    ;
+	n--;
+	i = 0;
+	for (r = 0; r < n; r++)
 	{
-	    /* rescale to [0..65535] then rgb bits */
-	    pmap->red[i].co.local.red =
-		((((((i & pVisual->redMask) >> pVisual->offsetRed)
-		    * 65535) / limr) >> shift) * 65535) / lim;
-	    pmap->red[i].co.local.green =
-		((((((i & pVisual->greenMask) >> pVisual->offsetGreen)
-		    * 65535) / limg) >> shift) * 65535) / lim;
-	    pmap->red[i].co.local.blue =
-		((((((i & pVisual->blueMask) >> pVisual->offsetBlue)
-		    * 65535) / limb) >> shift) * 65535) / lim;
+	    red = (((r * 65535 / (n - 1)) >> shift) * 65535) / lim;
+	    for (g = 0; g < n; g++)
+	    {
+		green = (((g * 65535 / (n - 1)) >> shift) * 65535) / lim;
+		for (b = 0; b < n; b++)
+		{
+		    blue = (((b * 65535 / (n - 1)) >> shift) * 65535) / lim;
+		    pmap->red[i].co.local.red = red;
+		    pmap->red[i].co.local.green = green;
+		    pmap->red[i].co.local.blue = blue;
+		    i++;
+		}
+	    }
 	}
+	n = pVisual->ColormapEntries - i;
+	for (r = 0; r < n; r++)
+	{
+	    red = (((r * 65535 / (n - 1)) >> shift) * 65535) / lim;
+	    pmap->red[i].co.local.red = red;
+	    pmap->red[i].co.local.green = red;
+	    pmap->red[i].co.local.blue = red;
+	    i++;
+	}
     }
     else if (pVisual->class == StaticGray)
     {
@@ -534,6 +526,7 @@
 	    case PseudoColor:
 	    case GrayScale:
 	    case StaticGray:
+	    case StaticColor:
 		visual->redMask = 0;
 		visual->greenMask =  0;
 		visual->blueMask =  0;
@@ -544,8 +537,6 @@
 	    case DirectColor:
 	    case TrueColor:
 		visual->ColormapEntries = _CE(d);
-		/* fall through */
-	    case StaticColor:
 		visual->redMask =  visuals->redMask;
 		visual->greenMask =  visuals->greenMask;
 		visual->blueMask =  visuals->blueMask;
Index: xc/programs/Xserver/fb/fbcompose.c
diff -u /dev/null xc/programs/Xserver/fb/fbcompose.c:1.5
--- /dev/null	Mon Dec 18 14:28:23 2000
+++ xc/programs/Xserver/fb/fbcompose.c	Mon Nov 20 02:13:07 2000
@@ -0,0 +1,1573 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fbcompose.c,v 1.5 2000/11/20 07:13:07 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "fb.h"
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+
+/*
+ * General purpose compositing code optimized for minimal memory
+ * references
+ *
+ * All work is done on canonical ARGB values, functions for fetching
+ * and storing these exist for each format.
+ */
+
+typedef struct _fbCompSrc {
+    CARD32	value;
+    CARD32	alpha;
+} FbCompSrc;
+
+/*
+ * Combine src and mask using IN
+ */
+
+CARD32
+fbCombineMaskU (FbCompositeOperand   *src,
+		FbCompositeOperand   *msk)
+{
+    CARD32  x;
+    CARD16  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    if (!msk)
+	return (*src->fetch) (src->line, src->offset);
+    
+    a = (*msk->fetch) (msk->line, msk->offset) >> 24;
+    if (!a)
+	return 0;
+    
+    x = (*src->fetch) (src->line, src->offset);
+    if (a == 0xff)
+	return x;
+    
+    m = FbInU(x,0,a,t);
+    n = FbInU(x,8,a,t);
+    o = FbInU(x,16,a,t);
+    p = FbInU(x,24,a,t);
+    return m|n|o|p;
+}
+
+FbCompSrc
+fbCombineMaskC (FbCompositeOperand   *src,
+		FbCompositeOperand   *msk)
+{
+    FbCompSrc	s;
+    CARD32	x;
+    CARD32	a;
+    CARD16	xa;
+    CARD16	t;
+    CARD32	m,n,o,p;
+
+    if (!msk)
+    {
+	x = (*src->fetch) (src->line, src->offset);
+	s.value = x;
+	x = x >> 24;
+	x |= x << 8;
+	x |= x << 16;
+	s.alpha = x;
+	return s;
+    }
+    
+    a = (*msk->fetcha) (msk->line, msk->offset);
+    if (!a)
+    {
+	s.value = 0;
+	s.alpha = 0;
+	return s;
+    }
+    
+    x = (*src->fetch) (src->line, src->offset);
+    if (a == 0xffffffff)
+    {
+	s.value = x;
+	x = x >> 24;
+	x |= x << 8;
+	x |= x << 16;
+	s.alpha = x;
+	return s;
+    }
+    
+    m = FbInC(x,0,a,t);
+    n = FbInC(x,8,a,t);
+    o = FbInC(x,16,a,t);
+    p = FbInC(x,24,a,t);
+    s.value = m|n|o|p;
+    xa = x >> 24;
+    m = FbInU(a,0,xa,t);
+    n = FbInU(a,8,xa,t);
+    o = FbInU(a,16,xa,t);
+    p = FbInU(a,24,xa,t);
+    s.alpha = m|n|o|p;
+    return s;
+}
+
+CARD32
+fbCombineMaskValueC (FbCompositeOperand   *src,
+		     FbCompositeOperand   *msk)
+{
+    CARD32	x;
+    CARD32	a;
+    CARD16	xa;
+    CARD16	t;
+    CARD32	m,n,o,p;
+
+    if (!msk)
+    {
+	return (*src->fetch) (src->line, src->offset);
+    }
+    
+    a = (*msk->fetcha) (msk->line, msk->offset);
+    if (!a)
+	return a;
+    
+    x = (*src->fetch) (src->line, src->offset);
+    if (a == 0xffffffff)
+	return x;
+    
+    m = FbInC(x,0,a,t);
+    n = FbInC(x,8,a,t);
+    o = FbInC(x,16,a,t);
+    p = FbInC(x,24,a,t);
+    return m|n|o|p;
+}
+
+/*
+ * Combine src and mask using IN, generating only the alpha component
+ */
+CARD32
+fbCombineMaskAlphaU (FbCompositeOperand   *src,
+		     FbCompositeOperand   *msk)
+{
+    CARD32  x;
+    CARD16  a;
+    CARD16  t;
+
+    if (!msk)
+	return (*src->fetch) (src->line, src->offset);
+    
+    a = (*msk->fetch) (msk->line, msk->offset) >> 24;
+    if (!a)
+	return 0;
+    
+    x = (*src->fetch) (src->line, src->offset);
+    if (a == 0xff)
+	return x;
+    
+    return FbInU(x,24,a,t);
+}
+
+CARD32
+fbCombineMaskAlphaC (FbCompositeOperand   *src,
+		     FbCompositeOperand   *msk)
+{
+    CARD32	x;
+    CARD32	a;
+    CARD16	xa;
+    CARD16	t;
+    CARD32	m,n,o,p;
+
+    if (!msk)
+	return (*src->fetch) (src->line, src->offset);
+    
+    a = (*msk->fetcha) (msk->line, msk->offset);
+    if (!a)
+	return 0;
+    
+    x = (*src->fetcha) (src->line, src->offset);
+    if (a == 0xffffffff)
+	return x;
+    
+    m = FbInC(x,0,a,t);
+    n = FbInC(x,8,a,t);
+    o = FbInC(x,16,a,t);
+    p = FbInC(x,24,a,t);
+    return m|n|o|p;
+}
+
+/*
+ * All of the composing functions
+ */
+void
+fbCombineClear (FbCompositeOperand   *src,
+		FbCompositeOperand   *msk,
+		FbCompositeOperand   *dst)
+{
+    (*dst->store) (dst->line, dst->offset, 0);
+}
+
+void
+fbCombineSrcU (FbCompositeOperand    *src,
+	       FbCompositeOperand    *msk,
+	       FbCompositeOperand    *dst)
+{
+    (*dst->store) (dst->line, dst->offset, fbCombineMaskU (src, msk));
+}
+
+void
+fbCombineSrcC (FbCompositeOperand    *src,
+	       FbCompositeOperand    *msk,
+	       FbCompositeOperand    *dst)
+{
+    (*dst->store) (dst->line, dst->offset, fbCombineMaskValueC (src, msk));
+}
+
+void
+fbCombineDst (FbCompositeOperand    *src,
+	      FbCompositeOperand    *msk,
+	      FbCompositeOperand    *dst)
+{
+    /* noop */
+}
+
+void
+fbCombineOverU (FbCompositeOperand   *src,
+		FbCompositeOperand   *msk,
+		FbCompositeOperand   *dst)
+{
+    CARD32  s, d;
+    CARD16  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    s = fbCombineMaskU (src, msk);
+    a = ~s >> 24;
+    if (a != 0xff)
+    {
+	if (a)
+	{
+	    d = (*dst->fetch) (dst->line, dst->offset);
+	    m = FbOverU(s,d,0,a,t);
+	    n = FbOverU(s,d,8,a,t);
+	    o = FbOverU(s,d,16,a,t);
+	    p = FbOverU(s,d,24,a,t);
+	    s = m|n|o|p;
+	}
+	(*dst->store) (dst->line, dst->offset, s);
+    }
+}
+
+void
+fbCombineOverC (FbCompositeOperand   *src,
+		FbCompositeOperand   *msk,
+		FbCompositeOperand   *dst)
+{
+    FbCompSrc	cs;
+    CARD32  s, d;
+    CARD32  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    cs = fbCombineMaskC (src, msk);
+    s = cs.value;
+    a = ~cs.alpha;
+    if (a != 0xffffffff)
+    {
+	if (a)
+	{
+	    d = (*dst->fetch) (dst->line, dst->offset);
+	    m = FbOverC(s,d,0,a,t);
+	    n = FbOverC(s,d,8,a,t);
+	    o = FbOverC(s,d,16,a,t);
+	    p = FbOverC(s,d,24,a,t);
+	    s = m|n|o|p;
+	}
+	(*dst->store) (dst->line, dst->offset, s);
+    }
+}
+
+void
+fbCombineOverReverseU (FbCompositeOperand    *src,
+		       FbCompositeOperand    *msk,
+		       FbCompositeOperand    *dst)
+{
+    CARD32  s, d;
+    CARD16  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    d = (*dst->fetch) (dst->line, dst->offset);
+    a = ~d >> 24;
+    if (a)
+    {
+	s = fbCombineMaskU (src, msk);
+	if (a != 0xff)
+	{
+	    m = FbOverU(d,s,0,a,t);
+	    n = FbOverU(d,s,8,a,t);
+	    o = FbOverU(d,s,16,a,t);
+	    p = FbOverU(d,s,24,a,t);
+	    s = m|n|o|p;
+	}
+	(*dst->store) (dst->line, dst->offset, s);
+    }
+}
+
+void
+fbCombineOverReverseC (FbCompositeOperand    *src,
+		       FbCompositeOperand    *msk,
+		       FbCompositeOperand    *dst)
+{
+    CARD32  s, d;
+    CARD32  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    d = (*dst->fetch) (dst->line, dst->offset);
+    a = ~d >> 24;
+    if (a)
+    {
+	s = fbCombineMaskValueC (src, msk);
+	if (a != 0xff)
+	{
+	    m = FbOverU(d,s,0,a,t);
+	    n = FbOverU(d,s,8,a,t);
+	    o = FbOverU(d,s,16,a,t);
+	    p = FbOverU(d,s,24,a,t);
+	    s = m|n|o|p;
+	}
+	(*dst->store) (dst->line, dst->offset, s);
+    }
+}
+
+void
+fbCombineInU (FbCompositeOperand	    *src,
+	      FbCompositeOperand	    *msk,
+	      FbCompositeOperand	    *dst)
+{
+    CARD32  s, d;
+    CARD16  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    d = (*dst->fetch) (dst->line, dst->offset);
+    a = d >> 24;
+    s = 0;
+    if (a)
+    {
+	s = fbCombineMaskU (src, msk);
+	if (a != 0xff)
+	{
+	    m = FbInU(s,0,a,t);
+	    n = FbInU(s,8,a,t);
+	    o = FbInU(s,16,a,t);
+	    p = FbInU(s,24,a,t);
+	    s = m|n|o|p;
+	}
+    }
+    (*dst->store) (dst->line, dst->offset, s);
+}
+
+void
+fbCombineInC (FbCompositeOperand	    *src,
+	      FbCompositeOperand	    *msk,
+	      FbCompositeOperand	    *dst)
+{
+    CARD32  s, d;
+    CARD16  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    d = (*dst->fetch) (dst->line, dst->offset);
+    a = d >> 24;
+    s = 0;
+    if (a)
+    {
+	s = fbCombineMaskValueC (src, msk);
+	if (a != 0xff)
+	{
+	    m = FbInU(s,0,a,t);
+	    n = FbInU(s,8,a,t);
+	    o = FbInU(s,16,a,t);
+	    p = FbInU(s,24,a,t);
+	    s = m|n|o|p;
+	}
+    }
+    (*dst->store) (dst->line, dst->offset, s);
+}
+
+void
+fbCombineInReverseU (FbCompositeOperand  *src,
+		     FbCompositeOperand  *msk,
+		     FbCompositeOperand  *dst)
+{
+    CARD32  s, d;
+    CARD16  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    s = fbCombineMaskAlphaU (src, msk);
+    a = s >> 24;
+    if (a != 0xff)
+    {
+	d = 0;
+	if (a)
+	{
+	    d = (*dst->fetch) (dst->line, dst->offset);
+	    m = FbInU(d,0,a,t);
+	    n = FbInU(d,8,a,t);
+	    o = FbInU(d,16,a,t);
+	    p = FbInU(d,24,a,t);
+	    d = m|n|o|p;
+	}
+	(*dst->store) (dst->line, dst->offset, d);
+    }
+}
+
+void
+fbCombineInReverseC (FbCompositeOperand  *src,
+		     FbCompositeOperand  *msk,
+		     FbCompositeOperand  *dst)
+{
+    CARD32  s, d;
+    CARD32  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    s = fbCombineMaskAlphaC (src, msk);
+    a = s;
+    if (a != 0xffffffff)
+    {
+	d = 0;
+	if (a)
+	{
+	    d = (*dst->fetch) (dst->line, dst->offset);
+	    m = FbInC(d,0,a,t);
+	    n = FbInC(d,8,a,t);
+	    o = FbInC(d,16,a,t);
+	    p = FbInC(d,24,a,t);
+	    d = m|n|o|p;
+	}
+	(*dst->store) (dst->line, dst->offset, d);
+    }
+}
+
+void
+fbCombineOutU (FbCompositeOperand    *src,
+	       FbCompositeOperand    *msk,
+	       FbCompositeOperand    *dst)
+{
+    CARD32  s, d;
+    CARD16  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    d = (*dst->fetch) (dst->line, dst->offset);
+    a = ~d >> 24;
+    s = 0;
+    if (a)
+    {
+	s = fbCombineMaskU (src, msk);
+	if (a != 0xff)
+	{
+	    m = FbInU(s,0,a,t);
+	    n = FbInU(s,8,a,t);
+	    o = FbInU(s,16,a,t);
+	    p = FbInU(s,24,a,t);
+	    s = m|n|o|p;
+	}
+    }
+    (*dst->store) (dst->line, dst->offset, s);
+}
+
+void
+fbCombineOutC (FbCompositeOperand    *src,
+	       FbCompositeOperand    *msk,
+	       FbCompositeOperand    *dst)
+{
+    CARD32  s, d;
+    CARD16  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    d = (*dst->fetch) (dst->line, dst->offset);
+    a = ~d >> 24;
+    s = 0;
+    if (a)
+    {
+	s = fbCombineMaskValueC (src, msk);
+	if (a != 0xff)
+	{
+	    m = FbInU(s,0,a,t);
+	    n = FbInU(s,8,a,t);
+	    o = FbInU(s,16,a,t);
+	    p = FbInU(s,24,a,t);
+	    s = m|n|o|p;
+	}
+    }
+    (*dst->store) (dst->line, dst->offset, s);
+}
+
+void
+fbCombineOutReverseU (FbCompositeOperand *src,
+		      FbCompositeOperand *msk,
+		      FbCompositeOperand *dst)
+{
+    CARD32  s, d;
+    CARD16  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    s = fbCombineMaskAlphaU (src, msk);
+    a = ~s >> 24;
+    if (a != 0xff)
+    {
+	d = 0;
+	if (a)
+	{
+	    d = (*dst->fetch) (dst->line, dst->offset);
+	    m = FbInU(d,0,a,t);
+	    n = FbInU(d,8,a,t);
+	    o = FbInU(d,16,a,t);
+	    p = FbInU(d,24,a,t);
+	    d = m|n|o|p;
+	}
+	(*dst->store) (dst->line, dst->offset, d);
+    }
+}
+
+void
+fbCombineOutReverseC (FbCompositeOperand *src,
+		      FbCompositeOperand *msk,
+		      FbCompositeOperand *dst)
+{
+    CARD32  s, d;
+    CARD32  a;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    s = fbCombineMaskAlphaC (src, msk);
+    a = ~s;
+    if (a != 0xffffffff)
+    {
+	d = 0;
+	if (a)
+	{
+	    d = (*dst->fetch) (dst->line, dst->offset);
+	    m = FbInC(d,0,a,t);
+	    n = FbInC(d,8,a,t);
+	    o = FbInC(d,16,a,t);
+	    p = FbInC(d,24,a,t);
+	    d = m|n|o|p;
+	}
+	(*dst->store) (dst->line, dst->offset, d);
+    }
+}
+
+void
+fbCombineAtopU (FbCompositeOperand   *src,
+		FbCompositeOperand   *msk,
+		FbCompositeOperand   *dst)
+{
+    CARD32  s, d;
+    CARD16  ad, as;
+    CARD16  t;
+    CARD32  m,n,o,p;
+    
+    s = fbCombineMaskU (src, msk);
+    d = (*dst->fetch) (dst->line, dst->offset);
+    ad = ~s >> 24;
+    as = d >> 24;
+    m = FbGen(s,d,0,as,ad,t);
+    n = FbGen(s,d,8,as,ad,t);
+    o = FbGen(s,d,16,as,ad,t);
+    p = FbGen(s,d,24,as,ad,t);
+    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+}
+
+void
+fbCombineAtopC (FbCompositeOperand   *src,
+		FbCompositeOperand   *msk,
+		FbCompositeOperand   *dst)
+{
+    FbCompSrc	cs;
+    CARD32  s, d;
+    CARD32  ad;
+    CARD16  as;
+    CARD16  t;
+    CARD32  m,n,o,p;
+    
+    cs = fbCombineMaskC (src, msk);
+    d = (*dst->fetch) (dst->line, dst->offset);
+    s = cs.value;
+    ad = cs.alpha;
+    as = d >> 24;
+    m = FbGen(s,d,0,as,FbGet8(ad,0),t);
+    n = FbGen(s,d,8,as,FbGet8(ad,8),t);
+    o = FbGen(s,d,16,as,FbGet8(ad,16),t);
+    p = FbGen(s,d,24,as,FbGet8(ad,24),t);
+    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+}
+
+void
+fbCombineAtopReverseU (FbCompositeOperand    *src,
+		       FbCompositeOperand    *msk,
+		       FbCompositeOperand    *dst)
+{
+    CARD32  s, d;
+    CARD16  ad, as;
+    CARD16  t;
+    CARD32  m,n,o,p;
+    
+    s = fbCombineMaskU (src, msk);
+    d = (*dst->fetch) (dst->line, dst->offset);
+    ad = s >> 24;
+    as = ~d >> 24;
+    m = FbGen(s,d,0,as,ad,t);
+    n = FbGen(s,d,8,as,ad,t);
+    o = FbGen(s,d,16,as,ad,t);
+    p = FbGen(s,d,24,as,ad,t);
+    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+}
+
+void
+fbCombineAtopReverseC (FbCompositeOperand    *src,
+		       FbCompositeOperand    *msk,
+		       FbCompositeOperand    *dst)
+{
+    FbCompSrc	cs;
+    CARD32  s, d, ad;
+    CARD16  as;
+    CARD16  t;
+    CARD32  m,n,o,p;
+    
+    cs = fbCombineMaskC (src, msk);
+    d = (*dst->fetch) (dst->line, dst->offset);
+    s = cs.value;
+    ad = cs.alpha;
+    as = ~d >> 24;
+    m = FbGen(s,d,0,as,FbGet8(ad,0),t);
+    n = FbGen(s,d,8,as,FbGet8(ad,8),t);
+    o = FbGen(s,d,16,as,FbGet8(ad,16),t);
+    p = FbGen(s,d,24,as,FbGet8(ad,24),t);
+    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+}
+
+void
+fbCombineXorU (FbCompositeOperand    *src,
+	       FbCompositeOperand    *msk,
+	       FbCompositeOperand    *dst)
+{
+    CARD32  s, d;
+    CARD16  ad, as;
+    CARD16  t;
+    CARD32  m,n,o,p;
+    
+    s = fbCombineMaskU (src, msk);
+    d = (*dst->fetch) (dst->line, dst->offset);
+    ad = ~s >> 24;
+    as = ~d >> 24;
+    m = FbGen(s,d,0,as,ad,t);
+    n = FbGen(s,d,8,as,ad,t);
+    o = FbGen(s,d,16,as,ad,t);
+    p = FbGen(s,d,24,as,ad,t);
+    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+}
+
+void
+fbCombineXorC (FbCompositeOperand    *src,
+	       FbCompositeOperand    *msk,
+	       FbCompositeOperand    *dst)
+{
+    FbCompSrc	cs;
+    CARD32  s, d, ad;
+    CARD16  as;
+    CARD16  t;
+    CARD32  m,n,o,p;
+    
+    cs = fbCombineMaskC (src, msk);
+    d = (*dst->fetch) (dst->line, dst->offset);
+    s = cs.value;
+    ad = ~cs.alpha;
+    as = ~d >> 24;
+    m = FbGen(s,d,0,as,ad,t);
+    n = FbGen(s,d,8,as,ad,t);
+    o = FbGen(s,d,16,as,ad,t);
+    p = FbGen(s,d,24,as,ad,t);
+    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+}
+
+void
+fbCombineAddU (FbCompositeOperand    *src,
+	       FbCompositeOperand    *msk,
+	       FbCompositeOperand    *dst)
+{
+    CARD32  s, d;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    s = fbCombineMaskU (src, msk);
+    if (s == ~0)
+	(*dst->store) (dst->line, dst->offset, s);
+    else
+    {
+	d = (*dst->fetch) (dst->line, dst->offset);
+	if (s && d != ~0)
+	{
+	    m = FbAdd(s,d,0,t);
+	    n = FbAdd(s,d,8,t);
+	    o = FbAdd(s,d,16,t);
+	    p = FbAdd(s,d,24,t);
+	    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+	}
+    }
+}
+
+void
+fbCombineAddC (FbCompositeOperand    *src,
+	       FbCompositeOperand    *msk,
+	       FbCompositeOperand    *dst)
+{
+    CARD32  s, d;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    s = fbCombineMaskValueC (src, msk);
+    if (s == ~0)
+	(*dst->store) (dst->line, dst->offset, s);
+    else
+    {
+	d = (*dst->fetch) (dst->line, dst->offset);
+	if (s && d != ~0)
+	{
+	    m = FbAdd(s,d,0,t);
+	    n = FbAdd(s,d,8,t);
+	    o = FbAdd(s,d,16,t);
+	    p = FbAdd(s,d,24,t);
+	    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+	}
+    }
+}
+
+void
+fbCombineSaturateU (FbCompositeOperand   *src,
+		    FbCompositeOperand   *msk,
+		    FbCompositeOperand   *dst)
+{
+    CARD32  s, d;
+    CARD16  sa, da;
+    CARD16  ad, as;
+    CARD16  t;
+    CARD32  m,n,o,p;
+    
+    s = fbCombineMaskU (src, msk);
+    d = (*dst->fetch) (dst->line, dst->offset);
+    sa = s >> 24;
+    da = ~d >> 24;
+    if (sa <= da)
+    {
+	m = FbAdd(s,d,0,t);
+	n = FbAdd(s,d,8,t);
+	o = FbAdd(s,d,16,t);
+	p = FbAdd(s,d,24,t);
+    }
+    else
+    {
+	as = (da << 8) / sa;
+	ad = 0xff;
+	m = FbGen(s,d,0,as,ad,t);
+	n = FbGen(s,d,8,as,ad,t);
+	o = FbGen(s,d,16,as,ad,t);
+	p = FbGen(s,d,24,as,ad,t);
+    }
+    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+}
+
+void
+fbCombineSaturateC (FbCompositeOperand   *src,
+		    FbCompositeOperand   *msk,
+		    FbCompositeOperand   *dst)
+{
+    FbCompSrc	cs;
+    CARD32  s, d;
+    CARD16  sa, sr, sg, sb, da;
+    CARD16  ad, as;
+    CARD16  t;
+    CARD32  m,n,o,p;
+    
+    cs = fbCombineMaskC (src, msk);
+    d = (*dst->fetch) (dst->line, dst->offset);
+    s = cs.value;
+    sa = (cs.alpha >> 24) & 0xff;
+    sr = (cs.alpha >> 16) & 0xff;
+    sg = (cs.alpha >>  8) & 0xff;
+    sb = (cs.alpha      ) & 0xff;
+    da = ~d >> 24;
+    
+    if (sb <= da)
+	m = FbAdd(s,d,0,t);
+    else
+	m = FbGen (s, d, 0, (da << 8) / sb, 0xff, t);
+    
+    if (sg <= da)
+	n = FbAdd(s,d,8,t);
+    else
+	n = FbGen (s, d, 8, (da << 8) / sg, 0xff, t);
+    
+    if (sr < da)
+	o = FbAdd(s,d,16,t);
+    else
+	o = FbGen (s, d, 16, (da << 8) / sr, 0xff, t);
+
+    if (sa <= da)
+	p = FbAdd(s,d,24,t);
+    else
+	p = FbGen (s, d, 24, (da << 8) / sa, 0xff, t);
+    
+    (*dst->store) (dst->line, dst->offset, m|n|o|p);
+}
+
+FbCombineFunc	fbCombineFuncU[] = {
+    fbCombineClear,
+    fbCombineSrcU,
+    fbCombineDst,
+    fbCombineOverU,
+    fbCombineOverReverseU,
+    fbCombineInU,
+    fbCombineInReverseU,
+    fbCombineOutU,
+    fbCombineOutReverseU,
+    fbCombineAtopU,
+    fbCombineAtopReverseU,
+    fbCombineXorU,
+    fbCombineAddU,
+    fbCombineSaturateU,
+};
+
+FbCombineFunc	fbCombineFuncC[] = {
+    fbCombineClear,
+    fbCombineSrcC,
+    fbCombineDst,
+    fbCombineOverC,
+    fbCombineOverReverseC,
+    fbCombineInC,
+    fbCombineInReverseC,
+    fbCombineOutC,
+    fbCombineOutReverseC,
+    fbCombineAtopC,
+    fbCombineAtopReverseC,
+    fbCombineXorC,
+    fbCombineAddC,
+    fbCombineSaturateC,
+};
+
+/*
+ * All of the fetch functions
+ */
+
+CARD32
+fbFetch_a8r8g8b8 (FbBits *line, CARD32 offset)
+{
+    return ((CARD32 *)line)[offset >> 5];
+}
+
+CARD32
+fbFetch_x8r8g8b8 (FbBits *line, CARD32 offset)
+{
+    return ((CARD32 *)line)[offset >> 5] | 0xff000000;
+}
+
+CARD32
+fbFetch_a8b8g8r8 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD32 *)line)[offset >> 5];
+
+    return ((pixel & 0xff000000) |
+	    ((pixel >> 16) & 0xff) |
+	    (pixel & 0x0000ff00) |
+	    ((pixel & 0xff) << 16));
+}
+
+CARD32
+fbFetch_x8b8g8r8 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD32 *)line)[offset >> 5];
+
+    return ((0xff000000) |
+	    ((pixel >> 16) & 0xff) |
+	    (pixel & 0x0000ff00) |
+	    ((pixel & 0xff) << 16));
+}
+
+CARD32
+fbFetch_r8g8b8 (FbBits *line, CARD32 offset)
+{
+    CARD8   *pixel = ((CARD8 *) line) + (offset >> 3);
+#if IMAGE_BYTE_ORDER == MSBFirst
+    return (0xff000000 |
+	    (pixel[0] << 16) |
+	    (pixel[1] << 8) |
+	    (pixel[2]));
+#else
+    return (0xff000000 |
+	    (pixel[2] << 16) |
+	    (pixel[1] << 8) |
+	    (pixel[0]));
+#endif
+}
+
+CARD32
+fbFetch_b8g8r8 (FbBits *line, CARD32 offset)
+{
+    CARD8   *pixel = ((CARD8 *) line) + (offset >> 3);
+#if IMAGE_BYTE_ORDER == MSBFirst
+    return (0xff000000 |
+	    (pixel[2] << 16) |
+	    (pixel[1] << 8) |
+	    (pixel[0]));
+#else
+    return (0xff000000 |
+	    (pixel[0] << 16) |
+	    (pixel[1] << 8) |
+	    (pixel[2]));
+#endif
+}
+
+CARD32
+fbFetch_r5g6b5 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD16 *) line)[offset >> 4];
+    CARD32  r,g,b;
+
+    r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8;
+    g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
+    b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
+    return (0xff000000 | r | g | b);
+}
+
+CARD32
+fbFetch_b5g6r5 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD16 *) line)[offset >> 4];
+    CARD32  r,g,b;
+
+    b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8;
+    g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5;
+    r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
+    return (0xff000000 | r | g | b);
+}
+
+CARD32
+fbFetch_a1r5g5b5 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD16 *) line)[offset >> 4];
+    CARD32  a,r,g,b;
+
+    a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24;
+    r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
+    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
+    b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
+    return (a | r | g | b);
+}
+
+CARD32
+fbFetch_x1r5g5b5 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD16 *) line)[offset >> 4];
+    CARD32  r,g,b;
+
+    r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9;
+    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
+    b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2;
+    return (0xff000000 | r | g | b);
+}
+
+CARD32
+fbFetch_a1b5g5r5 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD16 *) line)[offset >> 4];
+    CARD32  a,r,g,b;
+
+    a = (CARD32) ((CARD8) (0 - ((pixel & 0x8000) >> 15))) << 24;
+    b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
+    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
+    r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
+    return (a | r | g | b);
+}
+
+CARD32
+fbFetch_x1b5g5r5 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD16 *) line)[offset >> 4];
+    CARD32  r,g,b;
+
+    b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7;
+    g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6;
+    r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14;
+    return (0xff000000 | r | g | b);
+}
+
+CARD32
+fbFetch_a8 (FbBits *line, CARD32 offset)
+{
+    CARD32   pixel = ((CARD8 *) line)[offset>>3];
+    
+    return pixel << 24;
+}
+
+CARD32
+fbFetcha_a8 (FbBits *line, CARD32 offset)
+{
+    CARD32   pixel = ((CARD8 *) line)[offset>>3];
+    
+    pixel |= pixel << 8;
+    pixel |= pixel << 16;
+    return pixel;
+}
+
+CARD32
+fbFetch_r3g3b2 (FbBits *line, CARD32 offset)
+{
+    CARD32   pixel = ((CARD8 *) line)[offset>>3];
+    CARD32  r,g,b;
+    
+    r = ((pixel & 0xe0) | ((pixel & 0xe0) >> 3) | ((pixel & 0xc0) >> 6)) << 16;
+    g = ((pixel & 0x1c) | ((pixel & 0x18) >> 3) | ((pixel & 0x1c) << 3)) << 8;
+    b = (((pixel & 0x03)     ) | 
+	 ((pixel & 0x03) << 2) | 
+	 ((pixel & 0x03) << 4) |
+	 ((pixel & 0x03) << 6));
+    return (0xff000000 | r | g | b);
+}
+
+CARD32
+fbFetch_b2g3r3 (FbBits *line, CARD32 offset)
+{
+    CARD32   pixel = ((CARD8 *) line)[offset>>3];
+    CARD32  r,g,b;
+    
+    b = (((pixel & 0xc0)     ) | 
+	 ((pixel & 0xc0) >> 2) |
+	 ((pixel & 0xc0) >> 4) |
+	 ((pixel & 0xc0) >> 6));
+    g = ((pixel & 0x38) | ((pixel & 0x38) >> 3) | ((pixel & 0x30) << 2)) << 8;
+    r = (((pixel & 0x07)     ) | 
+	 ((pixel & 0x07) << 3) | 
+	 ((pixel & 0x06) << 6)) << 16;
+    return (0xff000000 | r | g | b);
+}
+
+CARD32
+fbFetch_a2r2g2b2 (FbBits *line, CARD32 offset)
+{
+    CARD32   pixel = ((CARD8 *) line)[offset>>3];
+    CARD32   a,r,g,b;
+
+    a = ((pixel & 0xc0) * 0x55) << 18;
+    r = ((pixel & 0x30) * 0x55) << 12;
+    g = ((pixel & 0x0c) * 0x55) << 6;
+    b = ((pixel & 0x03) * 0x55);
+    return a|r|g|b;
+}
+
+CARD32
+fbFetch_a2b2g2r2 (FbBits *line, CARD32 offset)
+{
+    CARD32   pixel = ((CARD8 *) line)[offset>>3];
+    CARD32   a,r,g,b;
+
+    a = ((pixel & 0xc0) * 0x55) << 18;
+    b = ((pixel & 0x30) * 0x55) >> 6;
+    g = ((pixel & 0x0c) * 0x55) << 6;
+    r = ((pixel & 0x03) * 0x55) << 16;
+    return a|r|g|b;
+}
+
+#define Fetch8(l,o)    (((CARD8 *) (l))[(o) >> 3])
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Fetch4(l,o)    ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4)
+#else
+#define Fetch4(l,o)    ((o) & 2 ? Fetch8(l,o) >> 4 : Fetch8(l,o) & 0xf)
+#endif
+
+CARD32
+fbFetch_a4 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = Fetch4(line, offset);
+    
+    pixel |= pixel << 4;
+    return pixel << 24;
+}
+
+CARD32
+fbFetcha_a4 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = Fetch4(line, offset);
+    
+    pixel |= pixel << 4;
+    pixel |= pixel << 8;
+    pixel |= pixel << 16;
+    return pixel;
+}
+
+CARD32
+fbFetch_r1g2b1 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = Fetch4(line, offset);
+    CARD32  r,g,b;
+
+    r = ((pixel & 0x8) * 0xff) << 13;
+    g = ((pixel & 0x6) * 0x55) << 7;
+    b = ((pixel & 0x1) * 0xff);
+    return 0xff000000|r|g|b;
+}
+
+CARD32
+fbFetch_b1g2r1 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = Fetch4(line, offset);
+    CARD32  r,g,b;
+
+    b = ((pixel & 0x8) * 0xff) >> 3;
+    g = ((pixel & 0x6) * 0x55) << 7;
+    r = ((pixel & 0x1) * 0xff) << 16;
+    return 0xff000000|r|g|b;
+}
+
+CARD32
+fbFetch_a1r1g1b1 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = Fetch4(line, offset);
+    CARD32  a,r,g,b;
+
+    a = ((pixel & 0x8) * 0xff) << 21;
+    r = ((pixel & 0x4) * 0xff) << 14;
+    g = ((pixel & 0x2) * 0xff) << 7;
+    b = ((pixel & 0x1) * 0xff);
+    return a|r|g|b;
+}
+
+CARD32
+fbFetch_a1b1g1r1 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = Fetch4(line, offset);
+    CARD32  a,r,g,b;
+
+    a = ((pixel & 0x8) * 0xff) << 21;
+    r = ((pixel & 0x4) * 0xff) >> 3;
+    g = ((pixel & 0x2) * 0xff) << 7;
+    b = ((pixel & 0x1) * 0xff) << 16;
+    return a|r|g|b;
+}
+
+CARD32
+fbFetcha_a1 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD32 *)line)[offset >> 5];
+    CARD32  a;
+#if BITMAP_BIT_ORDER == MSBFirst
+    a = pixel >> (0x1f - offset & 0x1f);
+#else
+    a = pixel >> (offset & 0x1f);
+#endif
+    a = a & 1;
+    a |= a << 1;
+    a |= a << 2;
+    a |= a << 4;
+    a |= a << 8;
+    a |= a << 16;
+    return a;
+}
+
+CARD32
+fbFetch_a1 (FbBits *line, CARD32 offset)
+{
+    CARD32  pixel = ((CARD32 *)line)[offset >> 5];
+    CARD32  a;
+#if BITMAP_BIT_ORDER == MSBFirst
+    a = pixel >> (0x1f - offset & 0x1f);
+#else
+    a = pixel >> (offset & 0x1f);
+#endif
+    a = a & 1;
+    a |= a << 1;
+    a |= a << 2;
+    a |= a << 4;
+    return a << 24;
+}
+
+/*
+ * All the store functions
+ */
+
+#define Splita(v)	CARD32	a = ((v) >> 24), r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
+#define Split(v)	CARD32	r = ((v) >> 16) & 0xff, g = ((v) >> 8) & 0xff, b = (v) & 0xff
+
+void
+fbStore_a8r8g8b8 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    ((CARD32 *)line)[offset >> 5] = value;
+}
+
+void
+fbStore_x8r8g8b8 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    ((CARD32 *)line)[offset >> 5] = value & 0xffffff;
+}
+
+void
+fbStore_a8b8g8r8 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    Splita(value);
+    ((CARD32 *)line)[offset >> 5] = a << 24 | b << 16 | g << 8 | r;
+}
+
+void
+fbStore_x8b8g8r8 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    Split(value);
+    ((CARD32 *)line)[offset >> 5] = b << 16 | g << 8 | r;
+}
+
+void
+fbStore_r8g8b8 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD8   *pixel = ((CARD8 *) line) + (offset >> 3);
+    Split(value);
+#if IMAGE_BYTE_ORDER == MSBFirst
+    pixel[0] = r;
+    pixel[1] = g;
+    pixel[2] = b;
+#else
+    pixel[0] = b;
+    pixel[1] = g;
+    pixel[2] = r;
+#endif
+}
+
+void
+fbStore_b8g8r8 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD8   *pixel = ((CARD8 *) line) + (offset >> 3);
+    Split(value);
+#if IMAGE_BYTE_ORDER == MSBFirst
+    pixel[0] = b;
+    pixel[1] = g;
+    pixel[2] = r;
+#else
+    pixel[0] = r;
+    pixel[1] = g;
+    pixel[2] = b;
+#endif
+}
+
+void
+fbStore_r5g6b5 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD16  *pixel = ((CARD16 *) line) + (offset >> 4);
+    Split(value);
+    *pixel = (((r << 8) & 0xf800) |
+	      ((g << 3) & 0x07e0) |
+	      ((b >> 3)         ));
+}
+
+void
+fbStore_b5g6r5 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD16  *pixel = ((CARD16 *) line) + (offset >> 4);
+    Split(value);
+    *pixel = (((b << 8) & 0xf800) |
+	      ((g << 3) & 0x07e0) |
+	      ((r >> 3)         ));
+}
+
+void
+fbStore_a1r5g5b5 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD16  *pixel = ((CARD16 *) line) + (offset >> 4);
+    Splita(value);
+    *pixel = (((a << 8) & 0x8000) |
+	      ((r << 7) & 0x7c00) |
+	      ((g << 2) & 0x03e0) |
+	      ((b >> 3)         ));
+}
+
+void
+fbStore_x1r5g5b5 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD16  *pixel = ((CARD16 *) line) + (offset >> 4);
+    Split(value);
+    *pixel = (((r << 7) & 0x7c00) |
+	      ((g << 2) & 0x03e0) |
+	      ((b >> 3)         ));
+}
+
+void
+fbStore_a1b5g5r5 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD16  *pixel = ((CARD16 *) line) + (offset >> 4);
+    Splita(value);
+    *pixel = (((a << 8) & 0x8000) |
+	      ((b << 7) & 0x7c00) |
+	      ((g << 2) & 0x03e0) |
+	      ((r >> 3)         ));
+}
+
+void
+fbStore_x1b5g5r5 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD16  *pixel = ((CARD16 *) line) + (offset >> 4);
+    Split(value);
+    *pixel = (((b << 7) & 0x7c00) |
+	      ((g << 2) & 0x03e0) |
+	      ((r >> 3)         ));
+}
+
+void
+fbStore_a8 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD8   *pixel = ((CARD8 *) line) + (offset >> 3);
+    *pixel = value >> 24;
+}
+
+void
+fbStore_r3g3b2 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD8   *pixel = ((CARD8 *) line) + (offset >> 3);
+    Split(value);
+    *pixel = (((r     ) & 0xe0) |
+	      ((g >> 3) & 0x1c) |
+	      ((b >> 6)       ));
+}
+
+void
+fbStore_b2g3r3 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD8   *pixel = ((CARD8 *) line) + (offset >> 3);
+    Split(value);
+    *pixel = (((b     ) & 0xe0) |
+	      ((g >> 3) & 0x1c) |
+	      ((r >> 6)       ));
+}
+
+void
+fbStore_a2r2g2b2 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD8   *pixel = ((CARD8 *) line) + (offset >> 3);
+    Splita(value);
+    *pixel = (((a     ) & 0xc0) |
+	      ((r >> 2) & 0x30) |
+	      ((g >> 4) & 0x0c) |
+	      ((b >> 6)       ));
+}
+
+#define Store8(l,o,v)  (((CARD8 *) l)[(o) >> 3] = (v))
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Store4(l,o,v)  Store8(l,o,((o) & 2 ? \
+				   Fetch8(l,o) & 0xf0 | (v) : \
+				   Fetch8(l,o) & 0x0f | ((v) << 4)))
+#else
+#define Store4(l,o,v)  Store8(l,o,((o) & 2 ? \
+				   Fetch8(l,o) & 0x0f | ((v) << 4) : \
+				   Fetch8(l,o) & 0xf0 | (v)))
+#endif
+
+void
+fbStore_a4 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    Store4(line,offset,value>>28);
+}
+
+void
+fbStore_r1g2b1 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD32  pixel;
+    
+    Split(value);
+    pixel = (((r >> 4) & 0x8) |
+	     ((g >> 5) & 0x6) |
+	     ((b >> 7)      ));
+    Store4(line,offset,pixel);
+}
+
+void
+fbStore_b1g2r1 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD32  pixel;
+    
+    Split(value);
+    pixel = (((b >> 4) & 0x8) |
+	     ((g >> 5) & 0x6) |
+	     ((r >> 7)      ));
+    Store4(line,offset,pixel);
+}
+
+void
+fbStore_a1r1g1b1 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD32  pixel;
+    Splita(value);
+    pixel = (((a >> 4) & 0x8) |
+	     ((r >> 5) & 0x4) |
+	     ((g >> 6) & 0x2) |
+	     ((b >> 7)      ));
+    Store4(line,offset,pixel);
+}
+
+void
+fbStore_a1b1g1r1 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD32  pixel;
+    Splita(value);
+    pixel = (((a >> 4) & 0x8) |
+	     ((b >> 5) & 0x4) |
+	     ((g >> 6) & 0x2) |
+	     ((r >> 7)      ));
+    Store4(line,offset,pixel);
+}
+
+void
+fbStore_a1 (FbBits *line, CARD32 offset, CARD32 value)
+{
+    CARD32  *pixel = ((CARD32 *) line) + (offset >> 5);
+    CARD32  mask = FbStipMask(offset & 0x1f, 1);
+
+    value = value & 0x80000000 ? mask : 0;
+    *pixel = *pixel & ~mask | value;
+}
+
+FbAccessMap fbAccessMap[] = {
+    /* 32bpp formats */
+    PICT_a8r8g8b8,	fbFetch_a8r8g8b8,	fbFetch_a8r8g8b8,	fbStore_a8r8g8b8,
+    PICT_x8r8g8b8,	fbFetch_x8r8g8b8,	fbFetch_x8r8g8b8,	fbStore_x8r8g8b8,
+    PICT_a8b8g8r8,	fbFetch_a8b8g8r8,	fbFetch_a8b8g8r8,	fbStore_a8b8g8r8,
+    PICT_x8b8g8r8,	fbFetch_x8b8g8r8,	fbFetch_x8b8g8r8,	fbStore_x8b8g8r8,
+
+    /* 24bpp formats */
+    PICT_r8g8b8,	fbFetch_r8g8b8,		fbFetch_r8g8b8,		fbStore_r8g8b8,
+    PICT_b8g8r8,	fbFetch_b8g8r8,		fbFetch_b8g8r8,		fbStore_b8g8r8,
+
+    /* 16bpp formats */
+    PICT_r5g6b5,	fbFetch_r5g6b5,		fbFetch_r5g6b5,		fbStore_r5g6b5,
+    PICT_b5g6r5,	fbFetch_b5g6r5,		fbFetch_b5g6r5,		fbStore_b5g6r5,
+
+    PICT_a1r5g5b5,	fbFetch_a1r5g5b5,	fbFetch_a1r5g5b5,	fbStore_a1r5g5b5,
+    PICT_x1r5g5b5,	fbFetch_x1r5g5b5,	fbFetch_x1r5g5b5,	fbStore_x1r5g5b5,
+    PICT_a1b5g5r5,	fbFetch_a1b5g5r5,	fbFetch_a1b5g5r5,	fbStore_a1b5g5r5,
+    PICT_x1b5g5r5,	fbFetch_x1b5g5r5,	fbFetch_x1b5g5r5,	fbStore_x1b5g5r5,
+
+    /* 8bpp formats */
+    PICT_a8,		fbFetch_a8,		fbFetcha_a8,		fbStore_a8,
+    PICT_r3g3b2,	fbFetch_r3g3b2,		fbFetch_r3g3b2,		fbStore_r3g3b2,
+    PICT_b2g3r3,	fbFetch_b2g3r3,		fbFetch_b2g3r3,		fbStore_b2g3r3,
+    PICT_a2r2g2b2,	fbFetch_a2r2g2b2,	fbFetch_a2r2g2b2,	fbStore_a2r2g2b2,
+
+    /* 4bpp formats */
+    PICT_a4,		fbFetch_a4,		fbFetcha_a4,		fbStore_a4,
+    PICT_r1g2b1,	fbFetch_r1g2b1,		fbFetch_r1g2b1,		fbStore_r1g2b1,
+    PICT_b1g2r1,	fbFetch_b1g2r1,		fbFetch_b1g2r1,		fbStore_b1g2r1,
+    PICT_a1r1g1b1,	fbFetch_a1r1g1b1,	fbFetch_a1r1g1b1,	fbStore_a1r1g1b1,
+    PICT_a1b1g1r1,	fbFetch_a1b1g1r1,	fbFetch_a1b1g1r1,	fbStore_a1b1g1r1,
+
+    /* 1bpp formats */
+    PICT_a1,		fbFetch_a1,		fbFetcha_a1,		fbStore_a1,
+};
+#define NumAccessMap (sizeof fbAccessMap / sizeof fbAccessMap[0])
+
+Bool
+fbBuildCompositeOperand (PicturePtr	    pPict,
+			 FbCompositeOperand *op,
+			 INT16		    x,
+			 INT16		    y)
+{
+    int	    i;
+    
+    for (i = 0; i < NumAccessMap; i++)
+	if (fbAccessMap[i].format == pPict->format)
+	{
+	    op->fetch = fbAccessMap[i].fetch;
+	    op->fetcha = fbAccessMap[i].fetcha;
+	    op->store = fbAccessMap[i].store;
+	    fbGetDrawable (pPict->pDrawable, op->line, op->stride, op->bpp);
+	    if (pPict->repeat && pPict->pDrawable->width == 1 && 
+		pPict->pDrawable->height == 1)
+	    {
+		op->bpp = 0;
+		op->stride = 0;
+	    }
+	    op->line = op->line + y * op->stride;
+	    op->offset = 0;
+	    return TRUE;
+	}
+    return FALSE;
+}
+
+void
+fbCompositeGeneral (CARD8	op,
+		    PicturePtr	pSrc,
+		    PicturePtr	pMask,
+		    PicturePtr	pDst,
+		    INT16	xSrc,
+		    INT16	ySrc,
+		    INT16	xMask,
+		    INT16	yMask,
+		    INT16	xDst,
+		    INT16	yDst,
+		    CARD16	width,
+		    CARD16	height)
+{
+    FbCompositeOperand	src,msk,dst,*pmsk;
+    FbCombineFunc	f;
+    int			w;
+
+    if (!fbBuildCompositeOperand (pSrc, &src, xSrc, ySrc))
+	return;
+    if (!fbBuildCompositeOperand (pDst, &dst, xDst, yDst))
+	return;
+    f = fbCombineFuncU[op];
+    if (pMask)
+    {
+	if (!fbBuildCompositeOperand (pMask, &msk, xMask, yMask))
+	    return;
+	pmsk = &msk;
+	if (pMask->componentAlpha)
+	    f = fbCombineFuncC[op];
+    }
+    else
+	pmsk = 0;
+    while (height--)
+    {
+	w = width;
+	src.offset = xSrc * src.bpp;
+	dst.offset = xDst * dst.bpp;
+	if (pmsk)
+	    msk.offset = xMask * msk.bpp;
+	while (w--)
+	{
+	    (*f) (&src, pmsk, &dst);
+	    src.offset += src.bpp;
+	    dst.offset += dst.bpp;
+	    if (pmsk)
+		msk.offset += msk.bpp;
+	}
+	src.line += src.stride;
+	dst.line += dst.stride;
+	if (pmsk)
+	    msk.line += msk.stride;
+    }
+
+}
Index: xc/programs/Xserver/fb/fbgc.c
diff -u xc/programs/Xserver/fb/fbgc.c:1.9 xc/programs/Xserver/fb/fbgc.c:1.11
--- xc/programs/Xserver/fb/fbgc.c:1.9	Sat May  6 17:09:32 2000
+++ xc/programs/Xserver/fb/fbgc.c	Thu Oct 19 14:08:22 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbgc.c,v 1.9 2000/05/06 21:09:32 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbgc.c,v 1.11 2000/10/19 18:08:22 keithp Exp $ */
 
 #include "fb.h"
 #ifdef IN_MODULE
@@ -214,6 +214,12 @@
 	changes |= GCStipple|GCForeground|GCBackground|GCPlaneMask;
 	pPriv->bpp = pDrawable->bitsPerPixel;
     }
+    if ((changes & GCTile) && fbGetRotatedPixmap(pGC))
+    {
+	(*pGC->pScreen->DestroyPixmap) (fbGetRotatedPixmap(pGC));
+	fbGetRotatedPixmap(pGC) = 0;
+    }
+	
     if (pGC->fillStyle == FillTiled)
     {
 	PixmapPtr	pOldTile, pNewTile;
@@ -221,9 +227,16 @@
 	pOldTile = pGC->tile.pixmap;
 	if (pOldTile->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
 	{
-	    pNewTile = fb24_32ReformatTile (pOldTile, pDrawable->bitsPerPixel);
+	    pNewTile = fbGetRotatedPixmap(pGC);
+	    if (!pNewTile || pNewTile ->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+	    {
+		if (pNewTile)
+		    (*pGC->pScreen->DestroyPixmap) (pNewTile);
+		pNewTile = fb24_32ReformatTile (pOldTile, pDrawable->bitsPerPixel);
+	    }
 	    if (pNewTile)
 	    {
+		fbGetRotatedPixmap(pGC) = pOldTile;
 		pGC->tile.pixmap = pNewTile;
 		changes |= GCTile;
 	    }
@@ -261,12 +274,15 @@
 	
 	mask = FbFullMask(pDrawable->bitsPerPixel);
 	depthMask = FbFullMask(pDrawable->depth);
-	if ((pGC->planemask & depthMask) == depthMask)
-	    pGC->planemask = mask;
+	
 	pPriv->fg = pGC->fgPixel & mask;
 	pPriv->bg = pGC->bgPixel & mask;
-	pPriv->pm = pGC->planemask & mask;
-    
+	
+	if ((pGC->planemask & depthMask) == depthMask)
+	    pPriv->pm = mask;
+	else
+	    pPriv->pm = pGC->planemask & mask;    
+	
 	s = pDrawable->bitsPerPixel;
 	while (s < FB_UNIT)
 	{
Index: xc/programs/Xserver/fb/fbglyph.c
diff -u xc/programs/Xserver/fb/fbglyph.c:1.7 xc/programs/Xserver/fb/fbglyph.c:1.9
--- xc/programs/Xserver/fb/fbglyph.c:1.7	Wed Feb 23 15:29:44 2000
+++ xc/programs/Xserver/fb/fbglyph.c	Tue Sep 26 20:14:08 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbglyph.c,v 1.7 2000/02/23 20:29:44 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbglyph.c,v 1.9 2000/09/27 00:14:08 keithp Exp $ */
 
 #include "fb.h"
 #include	"fontstruct.h"
@@ -51,10 +51,10 @@
 #define WRITE1(d,n,fg)	((d)[n] = (CARD8) fg)
 #define WRITE2(d,n,fg)	(*(CARD16 *) &(d[n]) = (CARD16) fg)
 #define WRITE4(d,n,fg)	(*(CARD32 *) &(d[n]) = (CARD32) fg)
-#if FB_UNIT == 6
+#if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst
 #define WRITE8(d)	(*(FbBits *) &(d[0]) = fg)
 #else
-#define WRITE8(d)	WRITE4(d,0,f0), WRITE4(d,4,f1)
+#define WRITE8(d)	WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB)
 #endif
 			 
 /*
@@ -64,9 +64,47 @@
  *
  *  a b c d  a b c d  a b c d	bytes
  *  A B C A  B C A B  C A B C	pixels
- *    f0       f1       f2
+ * 
+ *    f0        f1       f2
+ *  A B C A  B C A B  C A B C	pixels LSB
+ *  C A B C  A B C A  B C A B	pixels MSB
+ *
+ *		LSB	MSB
+ *  A		f0	f1
+ *  B		f1	f2
+ *  C		f2	f0
+ *  A B		f0	f2
+ *  B C		f1	f0
+ *  C A		f2	f1
+ *  A B C A	f0	f1
+ *  B C A B	f1    	f2
+ *  C A B C	f2	f0
  */
 
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define	_A	f1
+#define _B	f2
+#define _C	f0
+#define _AB	f2
+#define _BC	f0
+#define _CA	f1
+#define _ABCA	f1
+#define _BCAB	f2
+#define _CABC	f0
+#define CASE(a,b,c,d)	((a << 3) | (b << 2) | (c << 1) | d)
+#else
+#define	_A	f0
+#define _B	f1
+#define _C	f2
+#define _AB	f0
+#define _BC	f1
+#define _CA	f2
+#define _ABCA	f0
+#define _BCAB	f1
+#define _CABC	f2
+#define CASE(a,b,c,d)	(a | (b << 1) | (c << 2) | (d << 3))
+#endif
+
 void
 fbGlyph24 (FbBits   *dstBits,
 	   FbStride dstStride,
@@ -101,84 +139,84 @@
 	while (bits)
 	{
 	    switch (FbStipMoveLsb (FbLeftStipBits (bits, n), 4, n)) {
-	    case 0:
+	    case CASE(0,0,0,0):
 		break;
-	    case 1:
-		WRITE2(dst,0,f0);
-		WRITE1(dst,2,f2);
-		break;
-	    case 2:
-		WRITE1(dst,3,f0);
-		WRITE2(dst,4,f1);
-		break;
-	    case 3:
-		WRITE4(dst,0,f0);
-		WRITE2(dst,4,f1);
-		break;
-	    case 4:
-		WRITE2(dst,6,f0);
-		WRITE1(dst,8,f2);
-		break;
-	    case 5:
-		WRITE2(dst,0,f0);
-		WRITE1(dst,2,f2);
+	    case CASE(1,0,0,0):
+		WRITE2(dst,0,_AB);
+		WRITE1(dst,2,_C);
+		break;
+	    case CASE(0,1,0,0):
+		WRITE1(dst,3,_A);
+		WRITE2(dst,4,_BC);
+		break;
+	    case CASE(1,1,0,0):
+		WRITE4(dst,0,_ABCA);
+		WRITE2(dst,4,_BC);
+		break;
+	    case CASE(0,0,1,0):
+		WRITE2(dst,6,_AB);
+		WRITE1(dst,8,_C);
+		break;
+	    case CASE(1,0,1,0):
+		WRITE2(dst,0,_AB);
+		WRITE1(dst,2,_C);
 		
-		WRITE2(dst,6,f0);
-		WRITE1(dst,8,f2);
+		WRITE2(dst,6,_AB);
+		WRITE1(dst,8,_C);
 		break;
-	    case 6:
-		WRITE1(dst,3,f0);
-		WRITE4(dst,4,f1);
-		WRITE1(dst,8,f2);
+	    case CASE(0,1,1,0):
+		WRITE1(dst,3,_A);
+		WRITE4(dst,4,_BCAB);
+		WRITE1(dst,8,_C);
 		break;
-	    case 7:
+	    case CASE(1,1,1,0):
 		WRITE8(dst);
-		WRITE1(dst,8,f2);
+		WRITE1(dst,8,_C);
 		break;
-	    case 8:
-		WRITE1(dst,9,f0);
-		WRITE2(dst,10,f1);
-		break;
-	    case 9:
-		WRITE2(dst,0,f0);
-		WRITE1(dst,2,f2);
+	    case CASE(0,0,0,1):
+		WRITE1(dst,9,_A);
+		WRITE2(dst,10,_BC);
+		break;
+	    case CASE(1,0,0,1):
+		WRITE2(dst,0,_AB);
+		WRITE1(dst,2,_C);
 		
-		WRITE1(dst,9,f0);
-		WRITE2(dst,10,f1);
+		WRITE1(dst,9,_A);
+		WRITE2(dst,10,_BC);
 		break;
-	    case 10:
-		WRITE1(dst,3,f0);
-		WRITE2(dst,4,f1);
+	    case CASE(0,1,0,1):
+		WRITE1(dst,3,_A);
+		WRITE2(dst,4,_BC);
 		
-		WRITE1(dst,9,f0);
-		WRITE2(dst,10,f1);
+		WRITE1(dst,9,_A);
+		WRITE2(dst,10,_BC);
 		break;
-	    case 11:
-		WRITE4(dst,0,f0);
-		WRITE2(dst,4,f1);
+	    case CASE(1,1,0,1):
+		WRITE4(dst,0,_ABCA);
+		WRITE2(dst,4,_BC);
 		
-		WRITE1(dst,9,f0);
-		WRITE2(dst,10,f1);
+		WRITE1(dst,9,_A);
+		WRITE2(dst,10,_BC);
 		break;
-	    case 12:
-		WRITE2(dst,6,f0);
-		WRITE4(dst,8,f2);
-		break;
-	    case 13:
-		WRITE2(dst,0,f0);
-		WRITE1(dst,2,f2);
+	    case CASE(0,0,1,1):
+		WRITE2(dst,6,_AB);
+		WRITE4(dst,8,_CABC);
+		break;
+	    case CASE(1,0,1,1):
+		WRITE2(dst,0,_AB);
+		WRITE1(dst,2,_C);
 		
-		WRITE2(dst,6,f0);
-		WRITE4(dst,8,f2);
+		WRITE2(dst,6,_AB);
+		WRITE4(dst,8,_CABC);
 		break;
-	    case 14:
-		WRITE1(dst,3,f0);
-		WRITE4(dst,4,f1);
-		WRITE4(dst,8,f2);
+	    case CASE(0,1,1,1):
+		WRITE1(dst,3,_A);
+		WRITE4(dst,4,_BCAB);
+		WRITE4(dst,8,_CABC);
 		break;
-	    case 15:
+	    case CASE(1,1,1,1):
 		WRITE8(dst);
-		WRITE4(dst,8,f2);
+		WRITE4(dst,8,_CABC);
 		break;
 	    }
 	    bits = FbStipLeft (bits, n);
Index: xc/programs/Xserver/fb/fboverlay.c
diff -u xc/programs/Xserver/fb/fboverlay.c:1.2 xc/programs/Xserver/fb/fboverlay.c:1.4
--- xc/programs/Xserver/fb/fboverlay.c:1.2	Thu May 11 14:14:13 2000
+++ xc/programs/Xserver/fb/fboverlay.c	Tue Sep 26 11:57:03 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/Xserver/fb/fboverlay.c,v 1.2 2000/05/11 18:14:13 tsi Exp $
+ * $XFree86: xc/programs/Xserver/fb/fboverlay.c,v 1.4 2000/09/26 15:57:03 tsi Exp $
  *
  * Copyright © 2000 SuSE, Inc.
  *
@@ -38,15 +38,31 @@
 {
     FbOverlayScrPrivPtr	pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
     int			i;
+    PixmapPtr		pPixmap;
     
     if (pWin->drawable.class != InputOutput)
 	return TRUE;
     for (i = 0; i < pScrPriv->nlayers; i++)
-	 if (pWin->drawable.depth == pScrPriv->pLayer[i]->drawable.depth)
-	 {
-	    pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pScrPriv->pLayer[i];
+    {
+	pPixmap = pScrPriv->layer[i].u.run.pixmap;
+	if (pWin->drawable.depth == pPixmap->drawable.depth)
+	{
+	    pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pPixmap;
+	    /*
+	     * Make sure layer keys are written correctly by
+	     * having non-root layers set to full while the
+	     * root layer is set to empty.  This will cause
+	     * all of the layers to get painted when the root
+	     * is mapped
+	     */
+	    if (!pWin->parent)
+	    {
+		REGION_EMPTY (pWin->drawable.pScreen,
+			      &pScrPriv->layer[i].u.run.region);
+	    }
 	    return TRUE;
-	 }
+	}
+    }
     return FALSE;
 }
 
@@ -57,47 +73,206 @@
     int			i;
 
     for (i = 0; i < pScrPriv->nlayers; i++)
-	(*pScreen->DestroyPixmap)(pScrPriv->pLayer[i]);
+    {
+	(*pScreen->DestroyPixmap)(pScrPriv->layer[i].u.run.pixmap);
+	REGION_UNINIT (pScreen, &pScrPriv->layer[i].u.run.region);
+    }
     return TRUE;
 }
 
+/*
+ * Return layer containing this window
+ */
+int
+fbOverlayWindowLayer(WindowPtr pWin)
+{
+    FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
+    int                 i;
+
+    for (i = 0; i < pScrPriv->nlayers; i++)
+	if (pWin->devPrivates[fbWinPrivateIndex].ptr ==
+	    (pointer) pScrPriv->layer[i].u.run.pixmap)
+	    return i;
+    return 0;
+}
+
 Bool
 fbOverlayCreateScreenResources(ScreenPtr pScreen)
 {
     int			i;
-    FbOverlayScrInitPtr	pInit = (FbOverlayScrInitPtr) (pScreen)->devPrivates[fbOverlayScreenPrivateIndex].ptr;
-    FbOverlayScrPrivPtr	pScrPriv;
+    FbOverlayScrPrivPtr	pScrPriv = fbOverlayGetScrPriv(pScreen);
     PixmapPtr		pPixmap;
-    FbOverlayInitPtr	overlay;
+    pointer		pbits;
+    int			width;
+    int			depth;
+    BoxRec		box;
     
     if (!miCreateScreenResources(pScreen))
 	return FALSE;
-    
-    pScrPriv = xalloc (sizeof (FbOverlayScrPrivRec));
-    if (!pScrPriv)
-	return FALSE;
 
-    for (i = 0; i < pInit->nlayers; i++)
+    box.x1 = 0;
+    box.y1 = 0;
+    box.x2 = pScreen->width;
+    box.y2 = pScreen->height;
+    for (i = 0; i < pScrPriv->nlayers; i++)
     {
-	overlay = &pInit->init[i];
-	pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, overlay->depth);
+	pbits = pScrPriv->layer[i].u.init.pbits;
+	width = pScrPriv->layer[i].u.init.width;
+	depth = pScrPriv->layer[i].u.init.depth;
+	pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth);
 	if (!pPixmap)
 	    return FALSE;
 	if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
-					    pScreen->height, overlay->depth,
-					    BitsPerPixel(overlay->depth),
-					    PixmapBytePad(overlay->width, overlay->depth),
-					    overlay->pbits))
+					    pScreen->height, depth,
+					    BitsPerPixel(depth),
+					    PixmapBytePad(width, depth),
+					    pbits))
 	    return FALSE;
-	pScrPriv->pLayer[i] = pPixmap;
+	pScrPriv->layer[i].u.run.pixmap = pPixmap;
+	REGION_INIT(pScreen, &pScrPriv->layer[i].u.run.region, &box, 0);
     }
-    pScrPriv->nlayers = pInit->nlayers;
-    xfree (pInit);
-    (pScreen)->devPrivates[fbOverlayScreenPrivateIndex].ptr = (pointer) pScrPriv;
-    pScreen->devPrivate = pScrPriv->pLayer[0];
+    pScreen->devPrivate = pScrPriv->layer[0].u.run.pixmap;
     return TRUE;
 }
 
+void
+fbOverlayPaintKey (DrawablePtr	pDrawable,
+		   RegionPtr	pRegion,
+		   CARD32	pixel,
+		   int		layer)
+{
+    fbFillRegionSolid (pDrawable, pRegion, 0, 
+		       fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
+}
+
+/*
+ * Track visible region for each layer
+ */
+void
+fbOverlayUpdateLayerRegion (ScreenPtr	pScreen,
+			    int		layer,
+			    RegionPtr	prgn)
+{
+    FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+    int			i;
+    RegionRec		rgnNew;
+    
+    if (!prgn || !REGION_NOTEMPTY(pScreen, prgn))
+	return;
+    for (i = 0; i < pScrPriv->nlayers; i++)
+    {
+	if (i == layer)
+	{
+	    /* add new piece to this fb */
+	    REGION_UNION (pScreen,
+			  &pScrPriv->layer[i].u.run.region,
+			  &pScrPriv->layer[i].u.run.region,
+			  prgn);
+	}
+	else if (REGION_NOTEMPTY (pScreen, 
+				  &pScrPriv->layer[i].u.run.region))
+	{
+	    /* paint new piece with chroma key */
+	    REGION_INIT (pScreen, &rgnNew, NullBox, 0);
+	    REGION_INTERSECT (pScreen,
+			      &rgnNew, 
+			      prgn, 
+			      &pScrPriv->layer[i].u.run.region);
+	    (*pScrPriv->PaintKey) (&pScrPriv->layer[i].u.run.pixmap->drawable,
+				   &rgnNew,
+				   pScrPriv->layer[i].key,
+				   i);
+	    REGION_UNINIT(pScreen, &rgnNew);
+	    /* remove piece from other fbs */
+	    REGION_SUBTRACT (pScreen,
+			     &pScrPriv->layer[i].u.run.region,
+			     &pScrPriv->layer[i].u.run.region,
+			     prgn);
+	}
+    }
+}
+
+/*
+ * Copy only areas in each layer containing real bits
+ */
+void
+fbOverlayCopyWindow(WindowPtr	pWin,
+		    DDXPointRec	ptOldOrg,
+		    RegionPtr	prgnSrc)
+{
+    ScreenPtr		pScreen = pWin->drawable.pScreen;
+    FbOverlayScrPrivPtr	pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
+    RegionRec		rgnDst;
+    int			dx, dy;
+    WindowPtr		pwinRoot;
+    int			i;
+    RegionRec		layerRgn[FB_OVERLAY_MAX];
+    PixmapPtr		pPixmap;
+
+    pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+    dx = ptOldOrg.x - pWin->drawable.x;
+    dy = ptOldOrg.y - pWin->drawable.y;
+
+    /*
+     * Clip to existing bits
+     */
+    REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
+    REGION_INIT (pScreen, &rgnDst, NullBox, 0);
+    REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+    REGION_TRANSLATE(pScreen, &rgnDst, dx, dy);
+    /*
+     * Compute the portion of each fb affected by this copy
+     */
+    for (i = 0; i < pScrPriv->nlayers; i++)
+    {
+	REGION_INIT (pScreen, &layerRgn[i], NullBox, 0);
+	REGION_INTERSECT(pScreen, &layerRgn[i], &rgnDst,
+			 &pScrPriv->layer[i].u.run.region);
+	if (REGION_NOTEMPTY (pScreen, &layerRgn[i]))
+	{
+	    REGION_TRANSLATE(pScreen, &layerRgn[i], -dx, -dy);
+	    pPixmap = pScrPriv->layer[i].u.run.pixmap;
+	    fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
+			  0,
+			  &layerRgn[i], dx, dy, pScrPriv->CopyWindow, 0,
+			  (void *)(long) i);
+	}
+    }
+    /*
+     * Update regions
+     */
+    for (i = 0; i < pScrPriv->nlayers; i++)
+    {
+	if (REGION_NOTEMPTY (pScreen, &layerRgn[i]))
+	    fbOverlayUpdateLayerRegion (pScreen, i, &layerRgn[i]);
+
+	REGION_UNINIT(pScreen, &layerRgn[i]);
+    }
+    REGION_UNINIT(pScreen, &rgnDst);
+}   
+
+void
+fbOverlayWindowExposures (WindowPtr	pWin,
+			  RegionPtr	prgn,
+			  RegionPtr	other_exposed)
+{
+    fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
+				fbOverlayWindowLayer (pWin),
+				prgn);
+    miWindowExposures(pWin, prgn, other_exposed);
+}
+
+void
+fbOverlayPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+    if (what == PW_BORDER)
+	fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
+				    fbOverlayWindowLayer (pWin),
+				    pRegion);
+    fbPaintWindow (pWin, pRegion, what);
+}
+
 Bool
 fbOverlaySetupScreen(ScreenPtr	pScreen,
 		     pointer	pbits1,
@@ -141,19 +316,18 @@
     int		nvisuals;
     int		ndepths;
     VisualID	defaultVisual;
-    FbOverlayScrInitPtr	pInit;
-
+    FbOverlayScrPrivPtr	pScrPriv;
+    
     if (fbOverlayGeneration != serverGeneration)
     {
 	fbOverlayScreenPrivateIndex = AllocateScreenPrivateIndex ();
 	fbOverlayGeneration = serverGeneration;
     }
-    
-    pInit = xalloc (sizeof (FbOverlayScrInitRec));
-    if (!pInit)
+
+    pScrPriv = xalloc (sizeof (FbOverlayScrPrivRec));
+    if (!pScrPriv)
 	return FALSE;
     
-    
     if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &depth1,
 			&defaultVisual, ((unsigned long)1<<(bpp1-1)) |
 			((unsigned long)1<<(bpp2-1)), 8))
@@ -173,20 +347,25 @@
     pScreen->minInstalledCmaps = 1;
     pScreen->maxInstalledCmaps = 2;
     
-    pInit->nlayers = 2;
-    pInit->init[0].pbits = pbits1;
-    pInit->init[0].width = width1;
-    pInit->init[0].depth = depth1;
-    
-    pInit->init[1].pbits = pbits2;
-    pInit->init[1].width = width2;
-    pInit->init[1].depth = depth2;
-
-    pScreen->devPrivates[fbOverlayScreenPrivateIndex].ptr = (pointer) pInit;
+    pScrPriv->nlayers = 2;
+    pScrPriv->PaintKey = fbOverlayPaintKey;
+    pScrPriv->CopyWindow = fbCopyWindowProc;
+    pScrPriv->layer[0].u.init.pbits = pbits1;
+    pScrPriv->layer[0].u.init.width = width1;
+    pScrPriv->layer[0].u.init.depth = depth1;
+    
+    pScrPriv->layer[1].u.init.pbits = pbits2;
+    pScrPriv->layer[1].u.init.width = width2;
+    pScrPriv->layer[1].u.init.depth = depth2;
+    
+    pScreen->devPrivates[fbOverlayScreenPrivateIndex].ptr = (pointer) pScrPriv;
     
     /* overwrite miCloseScreen with our own */
     pScreen->CloseScreen = fbOverlayCloseScreen;
     pScreen->CreateScreenResources = fbOverlayCreateScreenResources;
     pScreen->CreateWindow = fbOverlayCreateWindow;
+    pScreen->WindowExposures = fbOverlayWindowExposures;
+    pScreen->CopyWindow = fbOverlayCopyWindow;
+    pScreen->PaintWindowBorder = fbOverlayPaintWindow;
     return TRUE;
 }
Index: xc/programs/Xserver/fb/fboverlay.h
diff -u xc/programs/Xserver/fb/fboverlay.h:1.2 xc/programs/Xserver/fb/fboverlay.h:1.3
--- xc/programs/Xserver/fb/fboverlay.h:1.2	Thu May 11 14:14:13 2000
+++ xc/programs/Xserver/fb/fboverlay.h	Wed Aug  9 13:50:52 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/Xserver/fb/fboverlay.h,v 1.2 2000/05/11 18:14:13 tsi Exp $
+ * $XFree86: xc/programs/Xserver/fb/fboverlay.h,v 1.3 2000/08/09 17:50:52 keithp Exp $
  *
  * Copyright © 2000 SuSE, Inc.
  *
@@ -29,35 +29,72 @@
 extern int	fbOverlayGeneration;
 extern int	fbOverlayScreenPrivateIndex;
 
-#define FB_OVERLAY_MAX	3
+#ifndef FB_OVERLAY_MAX
+#define FB_OVERLAY_MAX	2
+#endif
+
+typedef	void	(*fbOverlayPaintKeyProc) (DrawablePtr, RegionPtr, CARD32, int);
+
+typedef struct _fbOverlayLayer {
+    union {
+	struct {
+	    pointer	pbits;
+	    int		width;
+	    int		depth;
+	} init;
+	struct {
+	    PixmapPtr	pixmap;
+	    RegionRec	region;
+	} run;
+    } u;
+    CARD32	key;	    /* special pixel value */
+} FbOverlayLayer;
 
 typedef struct _fbOverlayScrPriv {
-    int		nlayers;
-    PixmapPtr	pLayer[FB_OVERLAY_MAX];
+    int			    nlayers;
+    fbOverlayPaintKeyProc   PaintKey;
+    fbCopyProc		    CopyWindow;
+    FbOverlayLayer	    layer[FB_OVERLAY_MAX];
 } FbOverlayScrPrivRec, *FbOverlayScrPrivPtr;
 
 #define fbOverlayGetScrPriv(s)	((FbOverlayScrPrivPtr) \
 				 (s)->devPrivates[fbOverlayScreenPrivateIndex].ptr)
 
-typedef struct _fbOverlayInit {
-    pointer		pbits;
-    int			width;
-    int			depth;
-} FbOverlayInitRec, *FbOverlayInitPtr;
-
-typedef struct _fbOverlayScrInit {
-    int			nlayers;
-    FbOverlayInitRec	init[FB_OVERLAY_MAX];
-} FbOverlayScrInitRec, *FbOverlayScrInitPtr;
-
 Bool
 fbOverlayCreateWindow(WindowPtr pWin);
 
 Bool
 fbOverlayCloseScreen (int iScreen, ScreenPtr pScreen);
 
+int
+fbOverlayWindowLayer(WindowPtr pWin);
+
 Bool
 fbOverlayCreateScreenResources(ScreenPtr pScreen);
+
+void
+fbOverlayPaintKey (DrawablePtr	pDrawable,
+		   RegionPtr	pRegion,
+		   CARD32	pixel,
+		   int		layer);
+void
+fbOverlayUpdateLayerRegion (ScreenPtr	pScreen,
+			    int		layer,
+			    RegionPtr	prgn);
+
+    
+void
+fbOverlayCopyWindow(WindowPtr	pWin,
+		    DDXPointRec	ptOldOrg,
+		    RegionPtr	prgnSrc);
+    
+void
+fbOverlayWindowExposures (WindowPtr	pWin,
+			  RegionPtr	prgn,
+			  RegionPtr	other_exposed);
+
+void
+fbOverlayPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
 
 
 Bool
Index: xc/programs/Xserver/fb/fbpict.c
diff -u /dev/null xc/programs/Xserver/fb/fbpict.c:1.5
--- /dev/null	Mon Dec 18 14:28:25 2000
+++ xc/programs/Xserver/fb/fbpict.c	Wed Nov 29 03:43:08 2000
@@ -0,0 +1,952 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fbpict.c,v 1.5 2000/11/29 08:43:08 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "fb.h"
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+
+#define cvt8888to0565(s)    ((((s) >> 3) & 0x001f) | \
+			     (((s) >> 5) & 0x07e0) | \
+			     (((s) >> 8) & 0xf800))
+#define cvt0565to8888(s)    (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
+			     ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
+			     ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Fetch24(a)  ((unsigned long) (a) & 1 ? \
+		     ((*(a) << 16) | *((CARD16 *) ((a)+1))) : \
+		     ((*((CARD16 *) (a)) << 8) | *((a)+2)))
+#define Store24(a,v) ((unsigned long) (a) & 1 ? \
+		      ((*(a) = (CARD8) ((v) >> 16)), \
+		       (*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \
+		      ((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \
+		       (*((a)+2) = (CARD8) (v))))
+#else
+#define Fetch24(a)  ((unsigned long) (a) & 1 ? \
+		     ((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \
+		     ((*((CARD16 *) (a))) | (*((a)+2) << 16)))
+#define Store24(a,v) ((unsigned long) (a) & 1 ? \
+		      ((*(a) = (CARD8) (v)), \
+		       (*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \
+		      ((*((CARD16 *) (a)) = (CARD16) (v)),\
+		       (*((a)+2) = (CARD8) ((v) >> 16))))
+#endif
+		      
+CARD32
+fbOver (CARD32 x, CARD32 y)
+{
+    CARD16  a = ~x >> 24;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    m = FbOverU(x,y,0,a,t);
+    n = FbOverU(x,y,8,a,t);
+    o = FbOverU(x,y,16,a,t);
+    p = FbOverU(x,y,24,a,t);
+    return m|n|o|p;
+}
+
+CARD32
+fbIn (CARD32 x, CARD8 y)
+{
+    CARD16  a = y;
+    CARD16  t;
+    CARD32  m,n,o,p;
+
+    m = FbInU(x,0,a,t);
+    n = FbInU(x,8,a,t);
+    o = FbInU(x,16,a,t);
+    p = FbInU(x,24,a,t);
+    return m|n|o|p;
+}
+
+/*
+ * Naming convention:
+ *
+ *  opSRCxMASKxDST
+ */
+
+void
+fbCompositeSolidMask_nx8x8888 (CARD8      op,
+			       PicturePtr pSrc,
+			       PicturePtr pMask,
+			       PicturePtr pDst,
+			       INT16      xSrc,
+			       INT16      ySrc,
+			       INT16      xMask,
+			       INT16      yMask,
+			       INT16      xDst,
+			       INT16      yDst,
+			       CARD16     width,
+			       CARD16     height)
+{
+    CARD32	src, srca;
+    CARD32	*dstLine, *dst, d, dstMask;
+    CARD8	*maskLine, *mask, m;
+    FbBits	*dstBits, *maskBits, *srcBits;
+    FbStride	dstStride, maskStride, srcStride;
+    int		dstBpp, maskBpp, srcBpp;
+    CARD16	w;
+
+    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp);
+    switch (srcBpp) {
+    case 32:
+	src = *(CARD32 *) srcBits;
+	break;
+    case 24:
+	src = Fetch24 ((CARD8 *) srcBits);
+	break;
+    case 16:
+	src = *(CARD16 *) srcBits;
+	src = cvt0565to8888(src);
+	break;
+    }
+    /* manage missing src alpha */
+    if (pSrc->pFormat->direct.alphaMask == 0)
+	src |= 0xff000000;
+    dstMask = FbFullMask (pDst->pDrawable->depth);
+    srca = src >> 24;
+    if (srca == 0)
+	return;
+    
+    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp);
+    dstLine = (CARD32 *) dstBits;
+    dstStride = dstStride * sizeof (FbBits) / sizeof (CARD32);
+    dstLine += dstStride * yDst + xDst;
+    
+    fbGetDrawable(pMask->pDrawable, maskBits, maskStride, maskBpp);
+    maskLine = (CARD8 *) maskBits;
+    maskStride = maskStride * sizeof (FbBits) / sizeof (CARD8);
+    maskLine += maskStride * yMask + xMask;
+    
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+
+	while (w--)
+	{
+	    m = *mask++;
+	    if (m == 0xff)
+	    {
+		if (srca == 0xff)
+		    *dst = src & dstMask;
+		else
+		    *dst = fbOver (src, *dst) & dstMask;
+	    }
+	    else if (m)
+	    {
+		d = fbIn (src, m);
+		*dst = fbOver (d, *dst) & dstMask;
+	    }
+	    dst++;
+	}
+    }
+}
+
+void
+fbCompositeSolidMask_nx8888x8888C (CARD8      op,
+				   PicturePtr pSrc,
+				   PicturePtr pMask,
+				   PicturePtr pDst,
+				   INT16      xSrc,
+				   INT16      ySrc,
+				   INT16      xMask,
+				   INT16      yMask,
+				   INT16      xDst,
+				   INT16      yDst,
+				   CARD16     width,
+				   CARD16     height)
+{
+    CARD32	src, srca;
+    CARD32	*dstLine, *dst, d, dstMask;
+    CARD32	*maskLine, *mask, ma;
+    FbBits	*dstBits, *maskBits, *srcBits;
+    FbStride	dstStride, maskStride, srcStride;
+    int		dstBpp, maskBpp, srcBpp;
+    CARD16	w;
+    CARD32	m, n, o, p;
+
+    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp);
+    switch (srcBpp) {
+    case 32:
+	src = *(CARD32 *) srcBits;
+	break;
+    case 24:
+	src = Fetch24 ((CARD8 *) srcBits);
+	break;
+    case 16:
+	src = *(CARD16 *) srcBits;
+	src = cvt0565to8888(src);
+	break;
+    }
+    /* manage missing src alpha */
+    if (pSrc->pFormat->direct.alphaMask == 0)
+	src |= 0xff000000;
+    dstMask = FbFullMask (pDst->pDrawable->depth);
+    srca = src >> 24;
+    if (srca == 0)
+	return;
+    
+    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp);
+    dstLine = (CARD32 *) dstBits;
+    dstStride = dstStride * sizeof (FbBits) / sizeof (CARD32);
+    dstLine += dstStride * yDst + xDst;
+    
+    fbGetDrawable(pMask->pDrawable, maskBits, maskStride, maskBpp);
+    maskLine = (CARD32 *) maskBits;
+    maskStride = maskStride * sizeof (FbBits) / sizeof (CARD32);
+    maskLine += maskStride * yMask + xMask;
+    
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+
+	while (w--)
+	{
+	    ma = *mask++;
+	    if (ma == 0xffffffff)
+	    {
+		if (srca == 0xff)
+		    *dst = src & dstMask;
+		else
+		    *dst = fbOver (src, *dst) & dstMask;
+	    }
+	    else if (ma)
+	    {
+		d = *dst;
+#define FbInOverC(src,srca,msk,dst,i,result) { \
+    CARD16  __a = FbGet8(msk,i); \
+    CARD32  __t, __ta; \
+    CARD32  __i; \
+    __t = FbIntMult (FbGet8(src,i), __a,__i); \
+    __ta = (CARD8) ~FbIntMult (srca, __a,__i); \
+    __t = __t + FbIntMult(FbGet8(dst,i),__ta,__i); \
+    __t = (CARD32) (CARD8) (__t | (-(__t >> 8))); \
+    result = __t << (i); \
+}
+		FbInOverC (src, srca, ma, d, 0, m);
+		FbInOverC (src, srca, ma, d, 8, n);
+		FbInOverC (src, srca, ma, d, 16, o);
+		FbInOverC (src, srca, ma, d, 24, p);
+		*dst = m|n|o|p;
+	    }
+	    dst++;
+	}
+    }
+}
+
+void
+fbCompositeSolidMask_nx8x0888 (CARD8      op,
+			       PicturePtr pSrc,
+			       PicturePtr pMask,
+			       PicturePtr pDst,
+			       INT16      xSrc,
+			       INT16      ySrc,
+			       INT16      xMask,
+			       INT16      yMask,
+			       INT16      xDst,
+			       INT16      yDst,
+			       CARD16     width,
+			       CARD16     height)
+{
+    CARD32	src, srca;
+    CARD8	*dstLine, *dst;
+    CARD32	d;
+    CARD8	*maskLine, *mask, m;
+    FbBits	*dstBits, *maskBits, *srcBits;
+    FbStride	dstStride, maskStride, srcStride;
+    int		dstBpp, maskBpp, srcBpp;
+    CARD16	w;
+
+    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp);
+    switch (srcBpp) {
+    case 32:
+	src = *(CARD32 *) srcBits;
+	break;
+    case 24:
+	src = Fetch24 ((CARD8 *) srcBits);
+	break;
+    case 16:
+	src = *(CARD16 *) srcBits;
+	src = cvt0565to8888(src);
+	break;
+    }
+    /* manage missing src alpha */
+    if (pSrc->pFormat->direct.alphaMask == 0)
+	src |= 0xff000000;
+    srca = src >> 24;
+    if (srca == 0)
+	return;
+    
+    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp);
+    dstLine = (CARD8 *) dstBits;
+    dstStride = dstStride * sizeof (FbBits) / sizeof (CARD8);
+    dstLine += dstStride * yDst + xDst * 3;
+    
+    fbGetDrawable(pMask->pDrawable, maskBits, maskStride, maskBpp);
+    maskLine = (CARD8 *) maskBits;
+    maskStride = maskStride * sizeof (FbBits) / sizeof (CARD8);
+    maskLine += maskStride * yMask + xMask;
+    
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+
+	while (w--)
+	{
+	    m = *mask++;
+	    if (m == 0xff)
+	    {
+		if (srca == 0xff)
+		    d = src;
+		else
+		{
+		    d = Fetch24(dst);
+		    d = fbOver (src, d);
+		}
+		Store24(dst,d);
+	    }
+	    else if (m)
+	    {
+		d = fbOver (fbIn(src,m), Fetch24(dst));
+		Store24(dst,d);
+	    }
+	    dst += 3;
+	}
+    }
+}
+
+void
+fbCompositeSolidMask_nx8x0565 (CARD8      op,
+				  PicturePtr pSrc,
+				  PicturePtr pMask,
+				  PicturePtr pDst,
+				  INT16      xSrc,
+				  INT16      ySrc,
+				  INT16      xMask,
+				  INT16      yMask,
+				  INT16      xDst,
+				  INT16      yDst,
+				  CARD16     width,
+				  CARD16     height)
+{
+    CARD32	src, srca;
+    CARD16	*dstLine, *dst;
+    CARD32	d;
+    CARD8	*maskLine, *mask, m;
+    FbBits	*dstBits, *maskBits, *srcBits;
+    FbStride	dstStride, maskStride, srcStride;
+    int		dstBpp, maskBpp, srcBpp;
+    CARD16	w;
+
+    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp);
+    switch (srcBpp) {
+    case 32:
+	src = *(CARD32 *) srcBits;
+	break;
+    case 24:
+	src = Fetch24 ((CARD8 *) srcBits);
+	break;
+    case 16:
+	src = *(CARD16 *) srcBits;
+	src = cvt0565to8888(src);
+	break;
+    }
+    /* manage missing src alpha */
+    if (pSrc->pFormat->direct.alphaMask == 0)
+	src |= 0xff000000;
+    srca = src >> 24;
+    if (srca == 0)
+	return;
+    
+    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp);
+    dstLine = (CARD16 *) dstBits;
+    dstStride = dstStride * sizeof (FbBits) / sizeof (CARD16);
+    dstLine += dstStride * yDst + xDst;
+    
+    fbGetDrawable(pMask->pDrawable, maskBits, maskStride, maskBpp);
+    maskLine = (CARD8 *) maskBits;
+    maskStride = maskStride * sizeof (FbBits) / sizeof (CARD8);
+    maskLine += maskStride * yMask + xMask;
+    
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	mask = maskLine;
+	maskLine += maskStride;
+	w = width;
+
+	while (w--)
+	{
+	    m = *mask++;
+	    if (m == 0xff)
+	    {
+		if (srca == 0xff)
+		    d = src;
+		else
+		{
+		    d = *dst;
+		    d = fbOver (src, cvt0565to8888(d));
+		}
+		*dst = cvt8888to0565(d);
+	    }
+	    else if (m)
+	    {
+		d = *dst;
+		d = fbOver (fbIn(src,m), cvt0565to8888(d));
+		*dst = cvt8888to0565(d);
+	    }
+	    dst++;
+	}
+    }
+}
+
+void
+fbCompositeSrc_8888x8888 (CARD8      op,
+			 PicturePtr pSrc,
+			 PicturePtr pMask,
+			 PicturePtr pDst,
+			 INT16      xSrc,
+			 INT16      ySrc,
+			 INT16      xMask,
+			 INT16      yMask,
+			 INT16      xDst,
+			 INT16      yDst,
+			 CARD16     width,
+			 CARD16     height)
+{
+    CARD32	*dstLine, *dst, dstMask;
+    CARD32	*srcLine, *src, s;
+    CARD8	a;
+    FbBits	*dstBits, *srcBits;
+    FbStride	dstStride, srcStride;
+    int		dstBpp, srcBpp;
+    CARD16	w;
+    
+    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp);
+    srcLine = (CARD32 *) srcBits;
+    srcStride = srcStride * sizeof (FbBits) / sizeof (CARD32);
+    srcLine += srcStride * ySrc + xSrc;
+
+    dstMask = FbFullMask (pDst->pDrawable->depth);
+    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp);
+    dstLine = (CARD32 *) dstBits;
+    dstStride = dstStride * sizeof (FbBits) / sizeof (CARD32);
+    dstLine += dstStride * yDst + xDst;
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	src = srcLine;
+	srcLine += srcStride;
+	w = width;
+
+	while (w--)
+	{
+	    s = *src++;
+	    a = s >> 24;
+	    if (a == 0xff)
+		*dst = s & dstMask;
+	    else if (a)
+		*dst = fbOver (s, *dst) & dstMask;
+	    dst++;
+	}
+    }
+}
+
+void
+fbCompositeSrc_8888x0888 (CARD8      op,
+			 PicturePtr pSrc,
+			 PicturePtr pMask,
+			 PicturePtr pDst,
+			 INT16      xSrc,
+			 INT16      ySrc,
+			 INT16      xMask,
+			 INT16      yMask,
+			 INT16      xDst,
+			 INT16      yDst,
+			 CARD16     width,
+			 CARD16     height)
+{
+    CARD8	*dstLine, *dst;
+    CARD32	d;
+    CARD32	*srcLine, *src, s;
+    CARD8	a;
+    FbBits	*dstBits, *srcBits;
+    FbStride	dstStride, srcStride;
+    int		dstBpp, srcBpp;
+    CARD16	w;
+    
+    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp);
+    srcLine = (CARD32 *) srcBits;
+    srcStride = srcStride * sizeof (FbBits) / sizeof (CARD32);
+    srcLine += srcStride * ySrc + xSrc;
+
+    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp);
+    dstLine = (CARD8 *) dstBits;
+    dstStride = dstStride * sizeof (FbBits) / sizeof (CARD8);
+    dstLine += dstStride * yDst + xDst * 3;
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	src = srcLine;
+	srcLine += srcStride;
+	w = width;
+
+	while (w--)
+	{
+	    s = *src++;
+	    a = s >> 24;
+	    if (a)
+	    {
+		if (a == 0xff)
+		    d = s;
+		else
+		    d = fbOver (s, Fetch24(dst));
+		Store24(dst,d);
+	    }
+	    dst += 3;
+	}
+    }
+}
+
+void
+fbCompositeSrc_8888x0565 (CARD8      op,
+			 PicturePtr pSrc,
+			 PicturePtr pMask,
+			 PicturePtr pDst,
+			 INT16      xSrc,
+			 INT16      ySrc,
+			 INT16      xMask,
+			 INT16      yMask,
+			 INT16      xDst,
+			 INT16      yDst,
+			 CARD16     width,
+			 CARD16     height)
+{
+    CARD16	*dstLine, *dst;
+    CARD32	d;
+    CARD32	*srcLine, *src, s;
+    CARD8	a;
+    FbBits	*dstBits, *srcBits;
+    FbStride	dstStride, srcStride;
+    int		dstBpp, srcBpp;
+    CARD16	w;
+    
+    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp);
+    srcLine = (CARD32 *) srcBits;
+    srcStride = srcStride * sizeof (FbBits) / sizeof (CARD32);
+    srcLine += srcStride * ySrc + xSrc;
+
+    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp);
+    dstLine = (CARD16 *) dstBits;
+    dstStride = dstStride * sizeof (FbBits) / sizeof (CARD16);
+    dstLine += dstStride * yDst + xDst;
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	src = srcLine;
+	srcLine += srcStride;
+	w = width;
+
+	while (w--)
+	{
+	    s = *src++;
+	    a = s >> 24;
+	    if (a)
+	    {
+		if (a == 0xff)
+		    d = s;
+		else
+		{
+		    d = *dst;
+		    d = fbOver (s, cvt0565to8888(d));
+		}
+		*dst = cvt8888to0565(d);
+	    }
+	    dst++;
+	}
+    }
+}
+
+void
+fbCompositeSrc_0565x0565 (CARD8      op,
+			  PicturePtr pSrc,
+			  PicturePtr pMask,
+			  PicturePtr pDst,
+			  INT16      xSrc,
+			  INT16      ySrc,
+			  INT16      xMask,
+			  INT16      yMask,
+			  INT16      xDst,
+			  INT16      yDst,
+			  CARD16     width,
+			  CARD16     height)
+{
+    CARD16	*dstLine, *dst;
+    CARD16	*srcLine, *src;
+    FbBits	*dstBits, *srcBits;
+    FbStride	dstStride, srcStride;
+    int		dstBpp, srcBpp;
+    CARD16	w;
+    
+    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp);
+    srcLine = (CARD16 *) srcBits;
+    srcStride = srcStride * sizeof (FbBits) / sizeof (CARD16);
+    srcLine += srcStride * ySrc + xSrc;
+
+    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp);
+    dstLine = (CARD16 *) dstBits;
+    dstStride = dstStride * sizeof (FbBits) / sizeof (CARD16);
+    dstLine += dstStride * yDst + xDst;
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	src = srcLine;
+	srcLine += srcStride;
+	w = width;
+
+	while (w--)
+	    *dst++ = *src++;
+    }
+}
+
+void
+fbCompositeSrcAdd_8000x8000 (CARD8	op,
+			     PicturePtr pSrc,
+			     PicturePtr pMask,
+			     PicturePtr pDst,
+			     INT16      xSrc,
+			     INT16      ySrc,
+			     INT16      xMask,
+			     INT16      yMask,
+			     INT16      xDst,
+			     INT16      yDst,
+			     CARD16     width,
+			     CARD16     height)
+{
+    CARD8	*dstLine, *dst;
+    CARD8	*srcLine, *src;
+    FbBits	*dstBits, *srcBits;
+    FbStride	dstStride, srcStride;
+    int		dstBpp, srcBpp;
+    CARD8	w;
+    CARD8	s, d;
+    CARD16	t;
+    
+    fbGetDrawable(pSrc->pDrawable, srcBits, srcStride, srcBpp);
+    srcLine = (CARD8 *) srcBits;
+    srcStride = srcStride * sizeof (FbBits) / sizeof (CARD8);
+    srcLine += srcStride * ySrc + xSrc;
+
+    fbGetDrawable(pDst->pDrawable, dstBits, dstStride, dstBpp);
+    dstLine = (CARD8 *) dstBits;
+    dstStride = dstStride * sizeof (FbBits) / sizeof (CARD8);
+    dstLine += dstStride * yDst + xDst;
+
+    while (height--)
+    {
+	dst = dstLine;
+	dstLine += dstStride;
+	src = srcLine;
+	srcLine += srcStride;
+	w = width;
+
+	while (w--)
+	{
+	    s = *src++;
+	    if (s != 0xff)
+	    {
+		d = *dst;
+		t = d + s;
+		s = t | (0 - (t >> 8));
+	    }
+	    *dst++ = s;
+	}
+    }
+}
+
+# define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
+
+void
+fbComposite (CARD8      op,
+	     PicturePtr pSrc,
+	     PicturePtr pMask,
+	     PicturePtr pDst,
+	     INT16      xSrc,
+	     INT16      ySrc,
+	     INT16      xMask,
+	     INT16      yMask,
+	     INT16      xDst,
+	     INT16      yDst,
+	     CARD16     width,
+	     CARD16     height)
+{
+    RegionRec	    region;
+    int		    n;
+    BoxPtr	    pbox;
+    CompositeFunc   func;
+    Bool	    srcRepeat = pSrc->repeat;
+    Bool	    maskRepeat = FALSE;
+    int		    x_msk, y_msk, x_src, y_src, x_dst, y_dst;
+    int		    w, h, w_this, h_this;
+    
+    xDst += pDst->pDrawable->x;
+    yDst += pDst->pDrawable->y;
+    xSrc += pSrc->pDrawable->x;
+    ySrc += pSrc->pDrawable->y;
+    if (pMask)
+    {
+	xMask += pMask->pDrawable->x;
+	yMask += pMask->pDrawable->y;
+	maskRepeat = pMask->repeat;
+    }
+    
+    if (!miComputeCompositeRegion (&region,
+				   pSrc,
+				   pMask,
+				   pDst,
+				   xSrc,
+				   ySrc,
+				   xMask,
+				   yMask,
+				   xDst,
+				   yDst,
+				   width,
+				   height))
+	return;
+				   
+    func = fbCompositeGeneral;
+    switch (op) {
+    case PictOpOver:
+	if (pMask)
+	{
+	    if (srcRepeat && 
+		pSrc->pDrawable->width == 1 &&
+		pSrc->pDrawable->height == 1)
+	    {
+		srcRepeat = FALSE;
+		if (PICT_FORMAT_COLOR(pSrc->format)) {
+		    switch (pMask->format) {
+		    case PICT_a8:
+			switch (pDst->format) {
+			case PICT_r5g6b5:
+			case PICT_b5g6r5:
+			    func = fbCompositeSolidMask_nx8x0565;
+			    break;
+			case PICT_r8g8b8:
+			case PICT_b8g8r8:
+			    func = fbCompositeSolidMask_nx8x0888;
+			    break;
+			case PICT_a8r8g8b8:
+			case PICT_x8r8g8b8:
+			case PICT_a8b8g8r8:
+			case PICT_x8b8g8r8:
+			    func = fbCompositeSolidMask_nx8x8888;
+			    break;
+			}
+			break;
+		    case PICT_a8r8g8b8:
+			if (pMask->componentAlpha) {
+			    switch (pDst->format) {
+			    case PICT_a8r8g8b8:
+			    case PICT_x8r8g8b8:
+				func = fbCompositeSolidMask_nx8888x8888C;
+				break;
+			    }
+			}
+			break;
+		    case PICT_a8b8g8r8:
+			if (pMask->componentAlpha) {
+			    switch (pDst->format) {
+			    case PICT_a8b8g8r8:
+			    case PICT_x8b8g8r8:
+				func = fbCompositeSolidMask_nx8888x8888C;
+				break;
+			    }
+			}
+			break;
+		    }
+		}
+	    }
+	}
+	else
+	{
+	    switch (pSrc->format) {
+	    case PICT_a8r8g8b8:
+	    case PICT_x8r8g8b8:
+		switch (pDst->format) {
+		case PICT_a8r8g8b8:
+		case PICT_x8r8g8b8:
+		    func = fbCompositeSrc_8888x8888;
+		    break;
+		case PICT_r8g8b8:
+		    func = fbCompositeSrc_8888x0888;
+		    break;
+		case PICT_r5g6b5:
+		    func = fbCompositeSrc_8888x0565;
+		    break;
+		}
+		break;
+	    case PICT_a8b8g8r8:
+	    case PICT_x8b8g8r8:
+		switch (pDst->format) {
+		case PICT_a8b8g8r8:
+		case PICT_x8b8g8r8:
+		    func = fbCompositeSrc_8888x8888;
+		    break;
+		case PICT_b8g8r8:
+		    func = fbCompositeSrc_8888x0888;
+		    break;
+		case PICT_b5g6r5:
+		    func = fbCompositeSrc_8888x0565;
+		    break;
+		}
+		break;
+	    case PICT_r5g6b5:
+		switch (pDst->format) {
+		case PICT_r5g6b5:
+		    func = fbCompositeSrc_0565x0565;
+		    break;
+		}
+		break;
+	    case PICT_b5g6r5:
+		switch (pDst->format) {
+		case PICT_b5g6r5:
+		    func = fbCompositeSrc_0565x0565;
+		    break;
+		}
+		break;
+	    }
+	}
+	break;
+    case PictOpAdd:
+	if (pMask == 0)
+	{
+	    switch (pSrc->format) {
+	    case PICT_a8:
+		switch (pDst->format) {
+		case PICT_a8:
+		    func = fbCompositeSrcAdd_8000x8000;
+		    break;
+		}
+	    }
+	}
+	break;
+    }
+    n = REGION_NUM_RECTS (&region);
+    pbox = REGION_RECTS (&region);
+    while (n--)
+    {
+	h = pbox->y2 - pbox->y1;
+	y_src = pbox->y1 - yDst + ySrc;
+	y_msk = pbox->y1 - yDst + yMask;
+	y_dst = pbox->y1;
+	while (h)
+	{
+	    h_this = h;
+	    w = pbox->x2 - pbox->x1;
+	    x_src = pbox->x1 - xDst + xSrc;
+	    x_msk = pbox->x1 - xDst + xMask;
+	    x_dst = pbox->x1;
+	    if (maskRepeat)
+	    {
+		y_msk = mod (y_msk, pMask->pDrawable->height);
+		if (h_this > pMask->pDrawable->height - y_msk)
+		    h_this = pMask->pDrawable->height - y_msk;
+	    }
+	    if (srcRepeat)
+	    {
+		y_src = mod (y_src, pSrc->pDrawable->height);
+		if (h_this > pSrc->pDrawable->height - y_src)
+		    h_this = pSrc->pDrawable->height - y_src;
+	    }
+	    while (w)
+	    {
+		w_this = w;
+		if (maskRepeat)
+		{
+		    x_msk = mod (x_msk, pMask->pDrawable->width);
+		    if (w_this > pMask->pDrawable->width - x_msk)
+			w_this = pMask->pDrawable->width - x_msk;
+		}
+		if (srcRepeat)
+		{
+		    x_src = mod (x_src, pSrc->pDrawable->width);
+		    if (w_this > pSrc->pDrawable->width - x_src)
+			w_this = pSrc->pDrawable->width - x_src;
+		}
+		(*func) (op, pSrc, pMask, pDst,
+			 x_src, y_src, x_msk, y_msk, x_dst, y_dst, 
+			 w_this, h_this);
+		w -= w_this;
+		x_src += w_this;
+		x_msk += w_this;
+		x_dst += w_this;
+	    }
+	    h -= h_this;
+	    y_src += h_this;
+	    y_msk += h_this;
+	    y_dst += h_this;
+	}
+	pbox++;
+    }
+    REGION_UNINIT (pDst->pDrawable->pScreen, &region);
+}
+
+Bool
+fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+    PictureScreenPtr    ps;
+
+    if (!miPictureInit (pScreen, formats, nformats))
+	return FALSE;
+    ps = GetPictureScreen(pScreen);
+    ps->Composite = fbComposite;
+    ps->Glyphs = miGlyphs;
+    ps->CompositeRects = miCompositeRects;
+    return TRUE;
+}
Index: xc/programs/Xserver/fb/fbpict.h
diff -u /dev/null xc/programs/Xserver/fb/fbpict.h:1.2
--- /dev/null	Mon Dec 18 14:28:25 2000
+++ xc/programs/Xserver/fb/fbpict.h	Mon Nov 20 02:13:07 2000
@@ -0,0 +1,467 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fbpict.h,v 1.2 2000/11/20 07:13:07 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _FBPICT_H_
+#define _FBPICT_H_
+
+#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
+
+#define FbGet8(v,i)   ((CARD16) (CARD8) ((v) >> i))
+
+/*
+ * There are two ways of handling alpha -- either as a single unified value or
+ * a separate value for each component, hence each macro must have two
+ * versions.  The unified alpha version has a 'U' at the end of the name,
+ * the component version has a 'C'.  Similarly, functions which deal with
+ * this difference will have two versions using the same convention.
+ */
+
+#define FbOverU(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i),\
+			   (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+#define FbOverC(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),FbGet8(a,i),(t)) + FbGet8(x,i),\
+			    (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+#define FbInU(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),(a),(t)) << (i))
+
+#define FbInC(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),FbGet8(a,i),(t)) << (i))
+
+#define FbGen(x,y,i,ax,ay,t) ((t) = (FbIntMult(FbGet8(y,i),ay,(t)) + \
+				     FbIntMult(FbGet8(x,i),ax,(t))),\
+			      (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+#define FbAdd(x,y,i,t)	((t) = FbGet8(x,i) + FbGet8(y,i), \
+			 (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+
+typedef void	(*CompositeFunc) (CARD8      op,
+				  PicturePtr pSrc,
+				  PicturePtr pMask,
+				  PicturePtr pDst,
+				  INT16      xSrc,
+				  INT16      ySrc,
+				  INT16      xMask,
+				  INT16      yMask,
+				  INT16      xDst,
+				  INT16      yDst,
+				  CARD16     width,
+				  CARD16     height);
+
+typedef CARD32 (*FbCompositeFetch)(FbBits *line, CARD32 offset);
+typedef void (*FbCompositeStore) (FbBits *line, CARD32 offset, CARD32 value);
+
+typedef struct _FbCompositeOperand {
+    FbBits		*line;
+    CARD32		offset;
+    FbStride		stride;
+    int			bpp;
+    FbCompositeFetch	fetch;
+    FbCompositeFetch	fetcha;
+    FbCompositeStore	store;
+} FbCompositeOperand;
+
+typedef void (*FbCombineFunc) (FbCompositeOperand	*src,
+			       FbCompositeOperand	*msk,
+			       FbCompositeOperand	*dst);
+
+/*
+ * indexed by op
+ */
+extern FbCombineFunc	fbCombineFunc[];
+
+typedef struct _FbAccessMap {
+    CARD32		format;
+    FbCompositeFetch	fetch;
+    FbCompositeFetch	fetcha;
+    FbCompositeStore	store;
+} FbAccessMap;
+
+/*
+ * search on format
+ */
+extern FbAccessMap  fbAccessMap[];
+
+/* fbcompose.c */
+
+/*
+ * All compositing operators *
+ */
+
+CARD32
+FbCombineMask (FbCompositeOperand   *src,
+	       FbCompositeOperand   *msk);
+
+void
+FbCombineClear (FbCompositeOperand   *src,
+		FbCompositeOperand   *msk,
+		FbCompositeOperand   *dst);
+
+void
+FbCombineSrc (FbCompositeOperand    *src,
+	      FbCompositeOperand    *msk,
+	      FbCompositeOperand    *dst);
+
+void
+FbCombineDst (FbCompositeOperand    *src,
+	      FbCompositeOperand    *msk,
+	      FbCompositeOperand    *dst);
+
+void
+FbCombineOver (FbCompositeOperand   *src,
+	       FbCompositeOperand   *msk,
+	       FbCompositeOperand   *dst);
+
+void
+FbCombineOverReverse (FbCompositeOperand    *src,
+		      FbCompositeOperand    *msk,
+		      FbCompositeOperand    *dst);
+
+void
+FbCombineIn (FbCompositeOperand	    *src,
+	     FbCompositeOperand	    *msk,
+	     FbCompositeOperand	    *dst);
+
+void
+FbCombineInReverse (FbCompositeOperand  *src,
+		    FbCompositeOperand  *msk,
+		    FbCompositeOperand  *dst);
+
+void
+FbCombineOut (FbCompositeOperand    *src,
+	      FbCompositeOperand    *msk,
+	      FbCompositeOperand    *dst);
+
+void
+FbCombineOutReverse (FbCompositeOperand *src,
+		     FbCompositeOperand *msk,
+		     FbCompositeOperand *dst);
+
+void
+FbCombineAtop (FbCompositeOperand   *src,
+	       FbCompositeOperand   *msk,
+	       FbCompositeOperand   *dst);
+
+void
+FbCombineAtopReverse (FbCompositeOperand    *src,
+		      FbCompositeOperand    *msk,
+		      FbCompositeOperand    *dst);
+
+void
+FbCombineXor (FbCompositeOperand    *src,
+	      FbCompositeOperand    *msk,
+	      FbCompositeOperand    *dst);
+
+void
+FbCombineAdd (FbCompositeOperand    *src,
+	      FbCompositeOperand    *msk,
+	      FbCompositeOperand    *dst);
+
+void
+FbCombineSaturate (FbCompositeOperand   *src,
+		   FbCompositeOperand   *msk,
+		   FbCompositeOperand   *dst);
+
+
+/*
+ * All fetch functions
+ */
+
+CARD32
+fbFetch_a8r8g8b8 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_x8r8g8b8 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a8b8g8r8 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_x8b8g8r8 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_r8g8b8 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_b8g8r8 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_r5g6b5 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_b5g6r5 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a1r5g5b5 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_x1r5g5b5 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a1b5g5r5 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_x1b5g5r5 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a8 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_r3g3b2 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_b2g3r3 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a2r2g2b2 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a2b2g2r2 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a4 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_r1g2b1 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_b1g2r1 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a1r1g1b1 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a1b1g1r1 (FbBits *line, CARD32 offset);
+
+CARD32
+fbFetch_a1 (FbBits *line, CARD32 offset);
+
+void
+fbStore_a8r8g8b8 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_x8r8g8b8 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_a8b8g8r8 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_x8b8g8r8 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_r8g8b8 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_b8g8r8 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_r5g6b5 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_b5g6r5 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_a1r5g5b5 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_x1r5g5b5 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_a1b5g5r5 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_x1b5g5r5 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_a8 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_r3g3b2 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_b2g3r3 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_a2r2g2b2 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_a4 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_r1g2b1 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_b1g2r1 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_a1r1g1b1 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_a1b1g1r1 (FbBits *line, CARD32 offset, CARD32 value);
+
+void
+fbStore_a1 (FbBits *line, CARD32 offset, CARD32 value);
+
+Bool
+fbBuildCompositeOperand (PicturePtr	    pPict,
+			 FbCompositeOperand *op,
+			 INT16		    x,
+			 INT16		    y);
+void
+fbCompositeGeneral (CARD8	op,
+		    PicturePtr	pSrc,
+		    PicturePtr	pMask,
+		    PicturePtr	pDst,
+		    INT16	xSrc,
+		    INT16	ySrc,
+		    INT16	xMask,
+		    INT16	yMask,
+		    INT16	xDst,
+		    INT16	yDst,
+		    CARD16	width,
+		    CARD16	height);
+
+
+/* fbpict.c */
+CARD32
+fbOver (CARD32 x, CARD32 y);
+
+CARD32
+fbIn (CARD32 x, CARD8 y);
+
+void
+fbCompositeSolidMask_nx8x8888 (CARD8      op,
+			       PicturePtr pSrc,
+			       PicturePtr pMask,
+			       PicturePtr pDst,
+			       INT16      xSrc,
+			       INT16      ySrc,
+			       INT16      xMask,
+			       INT16      yMask,
+			       INT16      xDst,
+			       INT16      yDst,
+			       CARD16     width,
+			       CARD16     height);
+
+void
+fbCompositeSolidMask_nx8x0888 (CARD8      op,
+			       PicturePtr pSrc,
+			       PicturePtr pMask,
+			       PicturePtr pDst,
+			       INT16      xSrc,
+			       INT16      ySrc,
+			       INT16      xMask,
+			       INT16      yMask,
+			       INT16      xDst,
+			       INT16      yDst,
+			       CARD16     width,
+			       CARD16     height);
+
+void
+fbCompositeSolidMask_nx8x0565 (CARD8      op,
+			       PicturePtr pSrc,
+			       PicturePtr pMask,
+			       PicturePtr pDst,
+			       INT16      xSrc,
+			       INT16      ySrc,
+			       INT16      xMask,
+			       INT16      yMask,
+			       INT16      xDst,
+			       INT16      yDst,
+			       CARD16     width,
+			       CARD16     height);
+
+void
+fbCompositeSrc_8888x8888 (CARD8      op,
+			  PicturePtr pSrc,
+			  PicturePtr pMask,
+			  PicturePtr pDst,
+			  INT16      xSrc,
+			  INT16      ySrc,
+			  INT16      xMask,
+			  INT16      yMask,
+			  INT16      xDst,
+			  INT16      yDst,
+			  CARD16     width,
+			  CARD16     height);
+
+void
+fbCompositeSrc_8888x0888 (CARD8      op,
+			 PicturePtr pSrc,
+			 PicturePtr pMask,
+			 PicturePtr pDst,
+			 INT16      xSrc,
+			 INT16      ySrc,
+			 INT16      xMask,
+			 INT16      yMask,
+			 INT16      xDst,
+			 INT16      yDst,
+			 CARD16     width,
+			 CARD16     height);
+
+void
+fbCompositeSrc_8888x0565 (CARD8      op,
+			  PicturePtr pSrc,
+			  PicturePtr pMask,
+			  PicturePtr pDst,
+			  INT16      xSrc,
+			  INT16      ySrc,
+			  INT16      xMask,
+			  INT16      yMask,
+			  INT16      xDst,
+			  INT16      yDst,
+			  CARD16     width,
+			  CARD16     height);
+
+void
+fbCompositeSrc_0565x0565 (CARD8      op,
+			  PicturePtr pSrc,
+			  PicturePtr pMask,
+			  PicturePtr pDst,
+			  INT16      xSrc,
+			  INT16      ySrc,
+			  INT16      xMask,
+			  INT16      yMask,
+			  INT16      xDst,
+			  INT16      yDst,
+			  CARD16     width,
+			  CARD16     height);
+
+void
+fbComposite (CARD8      op,
+	     PicturePtr pSrc,
+	     PicturePtr pMask,
+	     PicturePtr pDst,
+	     INT16      xSrc,
+	     INT16      ySrc,
+	     INT16      xMask,
+	     INT16      yMask,
+	     INT16      xDst,
+	     INT16      yDst,
+	     CARD16     width,
+	     CARD16     height);
+
+Bool
+fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+    
+#endif /* _FBPICT_H_ */
Index: xc/programs/Xserver/fb/fbpixmap.c
diff -u xc/programs/Xserver/fb/fbpixmap.c:1.7 xc/programs/Xserver/fb/fbpixmap.c:1.8
--- xc/programs/Xserver/fb/fbpixmap.c:1.7	Sat May  6 17:09:34 2000
+++ xc/programs/Xserver/fb/fbpixmap.c	Mon Sep 18 01:43:40 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbpixmap.c,v 1.7 2000/05/06 21:09:34 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbpixmap.c,v 1.8 2000/09/18 05:43:40 keithp Exp $ */
 
 #include "fb.h"
 #ifdef IN_MODULE
@@ -79,10 +79,9 @@
 fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth)
 {
     int	bpp;
-
     bpp = BitsPerPixel (depth);
 #ifdef FB_SCREEN_PRIVATE
-    if (bpp == 32)
+    if (bpp == 32 && depth <= 24)
 	bpp = fbGetScreenPrivate(pScreen)->pix32bpp;
 #endif
     return fbCreatePixmapBpp (pScreen, width, height, depth, bpp);
Index: xc/programs/Xserver/fb/fbpoint.c
diff -u xc/programs/Xserver/fb/fbpoint.c:1.6 xc/programs/Xserver/fb/fbpoint.c:1.7
--- xc/programs/Xserver/fb/fbpoint.c:1.6	Tue Feb 29 19:25:15 2000
+++ xc/programs/Xserver/fb/fbpoint.c	Fri Sep 22 01:58:01 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbpoint.c,v 1.6 2000/03/01 00:25:15 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbpoint.c,v 1.7 2000/09/22 05:58:01 keithp Exp $ */
 
 #include "fb.h"
 
@@ -77,7 +77,7 @@
 		int	n, rot;
 		FbStip	andT, xorT;
 		
-		rot = x % 24;
+		rot = FbFirst24Rot (x);
 		andT = FbRot24Stip(and,rot);
 		xorT = FbRot24Stip(xor,rot);
 		FbMaskStip (x, 24, leftMask, n, rightMask);
Index: xc/programs/Xserver/fb/fbscreen.c
diff -u xc/programs/Xserver/fb/fbscreen.c:1.9 xc/programs/Xserver/fb/fbscreen.c:1.12
--- xc/programs/Xserver/fb/fbscreen.c:1.9	Sat May  6 17:09:34 2000
+++ xc/programs/Xserver/fb/fbscreen.c	Mon Sep 18 01:43:40 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbscreen.c,v 1.9 2000/05/06 21:09:34 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbscreen.c,v 1.12 2000/09/18 05:43:40 keithp Exp $ */
 
 #include "fb.h"
 
@@ -36,6 +36,9 @@
     xfree (depths);
     xfree (pScreen->visuals);
     xfree (pScreen->devPrivate);
+#ifdef FB_SCREEN_PRIVATE
+    xfree (pScreen->devPrivates[fbScreenPrivateIndex].ptr);
+#endif
     return TRUE;
 }
 
@@ -192,6 +195,11 @@
 	fbGetScreenPrivate(pScreen)->win32bpp = bpp;
 	fbGetScreenPrivate(pScreen)->pix32bpp = bpp;
     }
+    else
+    {
+	fbGetScreenPrivate(pScreen)->win32bpp = 32;
+	fbGetScreenPrivate(pScreen)->pix32bpp = 32;
+    }
 #endif
     rootdepth = 0;
     if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
@@ -255,6 +263,7 @@
 };
 #endif
 
+#if 0
 void
 fbInitializeBackingStore (ScreenPtr pScreen)
 {
@@ -264,3 +273,4 @@
     miInitializeBackingStore (pScreen);
 #endif
 }
+#endif
Index: xc/programs/Xserver/fb/fbseg.c
diff -u xc/programs/Xserver/fb/fbseg.c:1.5 xc/programs/Xserver/fb/fbseg.c:1.6
--- xc/programs/Xserver/fb/fbseg.c:1.5	Wed Feb 23 15:29:46 2000
+++ xc/programs/Xserver/fb/fbseg.c	Fri Sep 22 01:58:01 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbseg.c,v 1.5 2000/02/23 20:29:46 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbseg.c,v 1.6 2000/09/22 05:58:01 keithp Exp $ */
 
 #include "fb.h"
 #include "miline.h"
@@ -387,7 +387,7 @@
     {
 	d = dst + (x1 >> FB_STIP_SHIFT);
 	x = x1 & FB_STIP_MASK;
-	rot = x % 24;
+	rot = FbFirst24Rot (x);
 	andT = FbRot24Stip(and,rot);
 	xorT = FbRot24Stip(xor,rot);
 	FbMaskStip (x, 24, leftMask, nl, rightMask);
@@ -491,7 +491,7 @@
 	    }
 	    d = dst + (x1 >> FB_STIP_SHIFT);
 	    x = x1 & FB_STIP_MASK;
-	    rot = x % 24;
+	    rot = FbFirst24Rot (x);
 	    andT = FbRot24Stip (andT, rot);
 	    xorT = FbRot24Stip (xorT, rot);
 	    FbMaskStip (x, 24, leftMask, nl, rightMask);
Index: xc/programs/Xserver/fb/fbsolid.c
diff -u xc/programs/Xserver/fb/fbsolid.c:1.6 xc/programs/Xserver/fb/fbsolid.c:1.7
--- xc/programs/Xserver/fb/fbsolid.c:1.6	Wed Feb 23 15:29:47 2000
+++ xc/programs/Xserver/fb/fbsolid.c	Fri Sep 22 01:58:01 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbsolid.c,v 1.6 2000/02/23 20:29:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbsolid.c,v 1.7 2000/09/22 05:58:01 keithp Exp $ */
 
 #define FbSelectPart(xor,o,t)    xor
 
@@ -106,7 +106,7 @@
      * Rotate pixel values this far across the word to align on
      * screen pixel boundaries
      */
-    rot = dstX % 24;
+    rot = FbFirst24Rot (dstX);
     FbMaskBits (dstX, width, startmask, nmiddle, endmask);
     if (startmask)
 	dstStride--;
Index: xc/programs/Xserver/fb/fbwindow.c
diff -u xc/programs/Xserver/fb/fbwindow.c:1.6 xc/programs/Xserver/fb/fbwindow.c:1.7
--- xc/programs/Xserver/fb/fbwindow.c:1.6	Sat May  6 17:09:34 2000
+++ xc/programs/Xserver/fb/fbwindow.c	Wed Aug  9 13:50:52 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/fb/fbwindow.c,v 1.6 2000/05/06 21:09:34 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbwindow.c,v 1.7 2000/08/09 17:50:52 keithp Exp $ */
 
 #include "fb.h"
 #ifdef IN_MODULE
@@ -157,7 +157,10 @@
 		pPixmap = fb24_32ReformatTile (pPixmap,
 					       pWin->drawable.bitsPerPixel);
 		if (pPixmap)
+		{
+		    (*pWin->drawable.pScreen->DestroyPixmap) (pWin->background.pixmap);
 		    pWin->background.pixmap = pPixmap;
+		}
 	    }
 #endif
 	    if (FbEvenTile (pPixmap->drawable.width *
@@ -177,7 +180,10 @@
 		pPixmap = fb24_32ReformatTile (pPixmap,
 					       pWin->drawable.bitsPerPixel);
 		if (pPixmap)
+		{
+		    (*pWin->drawable.pScreen->DestroyPixmap) (pWin->border.pixmap);
 		    pWin->border.pixmap = pPixmap;
+		}
 	    }
 #endif
 	    if (FbEvenTile (pPixmap->drawable.width *
Index: xc/programs/Xserver/hw/darwin/Imakefile
diff -u /dev/null xc/programs/Xserver/hw/darwin/Imakefile:1.4
--- /dev/null	Mon Dec 18 14:28:28 2000
+++ xc/programs/Xserver/hw/darwin/Imakefile	Mon Dec 11 15:29:38 2000
@@ -0,0 +1,36 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/Imakefile,v 1.4 2000/12/11 20:29:38 dawes Exp $
+
+#include <Server.tmpl>
+#define IHaveSubdirs
+
+SUBDIRS = utils
+
+SRCS =	darwin.c \
+        darwinCursor.c \
+        darwinKeyboard.c
+
+OBJS =	darwin.o \
+        darwinCursor.o \
+        darwinKeyboard.o
+
+INCLUDES = -I. -I$(SERVERSRC)/mi -I$(SERVERSRC)/mfb -I$(SERVERSRC)/cfb \
+           -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(SERVERSRC)/os \
+           -I$(INCLUDESRC) -I$(FONTINCSRC)
+
+#if defined(XFree86CustomVersion)
+CUSTOMVERSION = XFree86CustomVersion
+CUSTOMVERDEF =  -DXF86_CUSTOM_VERSION='$(CUSTOMVERSION)'
+#endif
+
+DEFINES = $(CUSTOMVERDEF)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(darwin,$(OBJS))
+
+CppManTarget(Xdarwin,)
+InstallManPage(Xdarwin,$(MANDIR))
+
+DependTarget()
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
Index: xc/programs/Xserver/hw/darwin/Xdarwin.cpp
diff -u /dev/null xc/programs/Xserver/hw/darwin/Xdarwin.cpp:1.1
--- /dev/null	Mon Dec 18 14:28:29 2000
+++ xc/programs/Xserver/hw/darwin/Xdarwin.cpp	Mon Dec 11 15:29:39 2000
@@ -0,0 +1,69 @@
+.\" $XFree86: xc/programs/Xserver/hw/darwin/Xdarwin.cpp,v 1.1 2000/12/11 20:29:39 dawes Exp $
+.\"
+.TH XDARWIN 1 "Release 4.0.2" "XFree86"
+.SH NAME
+Xdarwin \- X window system server for Darwin operating system
+.SH SYNOPSIS
+.B Xdarwin
+[ options ] ...
+.SH DESCRIPTION
+.I Xdarwin
+is the window server for Version 11 of the X window system on the Darwin
+operating system. It uses IOKit services to accesss the display framebuffer,
+mouse and keyboard and to provide a layer of hardware abstraction.
+.I Xdarwin
+will normally be started by the \fIxdm(1)\fP display manager or by a script
+that runs the program \fIxinit(1)\fP.
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXdarwin\fP accepts the following command line switches:
+.TP 8
+.B \-fakebuttons
+Emulates a 3 button mouse using the Command and Option keys. Clicking the
+first mouse button while holding down Command will act like clicking
+button 2. Holding down Option will simulate button 3.
+.TP 8
+.B \-nofakebuttons
+Do not emulate a 3 button mouse. This is the default.
+.TP 8
+.B "\-size \fIwidth\fP \fIheight\fP"
+Sets the screeen resolution for the X server to use.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Specifies the color bit depth to use. Currently only 8, 15, and 24 color bits
+per pixel are supported.
+.TP 8
+.B "\-refresh \fIrate\fP"
+Gives the refresh rate to use in Hz. For LCD displays this should be 0.
+.TP 8
+.B \-showconfig
+Print out the server version and patchlevel.
+.TP 8
+.B \-version
+Same as \fB\-showconfig\fP.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1)
+.SH BUGS
+.I Xdarwin
+and this man page still have many limitations. Some of the more obvious
+ones are:
+.br
+- Only one display is supported.
+.br
+- The display mode can not be changed once the X server has started.
+.br
+- A screen saver is not supported.
+.br
+- The X server does not wake from sleep correctly.
+.br
+- The key repeat rate can not be changed.
+.PP
+.SH AUTHORS
+Original Port to Mac OS X Server - John Carmack
+.br
+Port to Darwin 1.0 - Dave Zarzycki
+.br
+Improvements and bug fixes - Torrey T. Lyons
+
Index: xc/programs/Xserver/hw/darwin/darwin.c
diff -u /dev/null xc/programs/Xserver/hw/darwin/darwin.c:1.2
--- /dev/null	Mon Dec 18 14:28:29 2000
+++ xc/programs/Xserver/hw/darwin/darwin.c	Fri Dec  1 14:47:38 2000
@@ -0,0 +1,1109 @@
+/**************************************************************
+ *
+ * IOKit support for the Darwin X Server
+ *
+ * HISTORY:
+ * Original port to Mac OS X Server by John Carmack
+ * Port to Darwin 1.0 by Dave Zarzycki
+ * Significantly rewritten for XFree86 4.0.1 by Torrey Lyons
+ *
+ **************************************************************/
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwin.c,v 1.2 2000/12/01 19:47:38 dawes Exp $ */
+
+#define NDEBUG 1
+
+#include "X.h"
+#include "Xproto.h"
+#include "os.h"
+#include "servermd.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "mipointer.h"
+#include "micmap.h"
+#include "site.h"
+#include "xf86Version.h"
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#include <mach/mach_interface.h>
+
+#define NO_CFPLUGIN
+#include <IOKit/IOKitLib.h>
+#include <IOKit/hidsystem/IOHIDShared.h>
+#include <IOKit/graphics/IOGraphicsLib.h>
+#include <drivers/event_status_driver.h>
+
+// Define this to work around bugs in the display drivers for
+// older PowerBook G3's. If the X server starts without this
+// #define, you don't need it.
+#undef OLD_POWERBOOK_G3
+
+#include "darwin.h"
+
+DarwinFramebufferRec    dfb;
+unsigned char           darwinKeyCommandL = 0, darwinKeyOptionL = 0;
+
+/* Fake button press/release for scroll wheel move. */
+#define	SCROLLWHEELUPFAKE	4
+#define	SCROLLWHEELDOWNFAKE	5
+
+static	int             darwinEventFD;
+static	Bool            fake3Buttons = FALSE;
+static	DeviceIntPtr    darwinPointer;
+static	DeviceIntPtr    darwinKeyboard;
+static	UInt32          darwinDesiredWidth = 0, darwinDesiredHeight = 0;
+static	IOIndex         darwinDesiredDepth = -1;
+static	SInt32          darwinDesiredRefresh = -1;
+
+// Common pixmap formats
+static PixmapFormatRec formats[] = {
+        { 1,    1,      BITMAP_SCANLINE_PAD },
+        { 4,    8,      BITMAP_SCANLINE_PAD },
+        { 8,    8,      BITMAP_SCANLINE_PAD },
+        { 15,   16,     BITMAP_SCANLINE_PAD },
+        { 16,   16,     BITMAP_SCANLINE_PAD },
+        { 24,   32,     BITMAP_SCANLINE_PAD }
+};
+const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
+
+#ifndef OSNAME
+#define OSNAME " Darwin"
+#endif
+#ifndef OSVENDOR
+#define OSVENDOR ""
+#endif
+#ifndef PRE_RELEASE
+#define PRE_RELEASE (XF86_VERSION_BETA || XF86_VERSION_ALPHA)
+#endif
+
+static void
+DarwinPrintBanner()
+{
+#if PRE_RELEASE
+  ErrorF("\n"
+    "This is a pre-release version of XFree86, and is not supported in any\n"
+    "way.  Bugs may be reported to XFree86@XFree86.Org and patches submitted\n"
+    "to fixes@XFree86.Org.  Before reporting bugs in pre-release versions,\n"
+    "please check the latest version in the XFree86 CVS repository\n"
+    "(http://www.XFree86.Org/cvs)\n");
+#endif
+  ErrorF("\nXFree86 Version%s", XF86_VERSION);
+#ifdef XF86_CUSTOM_VERSION
+  ErrorF("(%s) ", XF86_CUSTOM_VERSION);
+#endif
+  ErrorF("/ X Window System\n");
+  ErrorF("(protocol Version %d, revision %d, vendor release %d)\n",
+         X_PROTOCOL, X_PROTOCOL_REVISION, VENDOR_RELEASE );
+  ErrorF("Release Date: %s\n", XF86_DATE);
+  ErrorF("\tIf the server is older than 6-12 months, or if your hardware is\n"
+	 "\tnewer than the above date, look for a newer version before\n"
+	 "\treporting problems.  (See http://www.XFree86.Org/FAQ)\n");
+  ErrorF("Operating System:%s%s\n", OSNAME, OSVENDOR);
+#if defined(BUILDERSTRING)
+  ErrorF("%s \n",BUILDERSTRING);
+#endif
+}
+
+static Bool DarwinSaveScreen(ScreenPtr pScreen, int on)
+{	// FIXME
+	if (on == SCREEN_SAVER_FORCER) {
+	} else if (on == SCREEN_SAVER_ON) {
+	} else {
+	}
+	return TRUE;
+}
+
+/*
+ * DarwinStoreColors
+ * This is a callback from X to change the hardware colormap
+ * when using PsuedoColor
+ */
+static void DarwinStoreColors(
+    ColormapPtr     pmap,
+    int             numEntries,
+    xColorItem      *pdefs)
+{
+    kern_return_t   kr;
+    int             i;
+    IOColorEntry    *newColors;
+
+    assert( newColors = (IOColorEntry *)
+                xalloc( numEntries*sizeof(IOColorEntry) ));
+
+    // Convert xColorItem values to IOColorEntry
+    // assume the colormap is PsuedoColor
+    // as we do not support DirectColor
+    for (i = 0; i < numEntries; i++) {
+        newColors[i].index = pdefs[i].pixel;
+        newColors[i].red =   pdefs[i].red;
+        newColors[i].green = pdefs[i].green;
+        newColors[i].blue =  pdefs[i].blue;
+    }
+
+    kr = IOFBSetCLUT( dfb.fbService, 0, numEntries,
+                      kSetCLUTByValue, newColors );
+    kern_assert( kr );
+
+    xfree( newColors );
+}
+
+/*
+ * DarwinAddScreen
+ * This is a callback from X during AddScreen() from InitOutput()
+ */
+static Bool DarwinAddScreen(
+    int         index,
+    ScreenPtr   pScreen,
+    int         argc,
+    char        **argv )
+{
+    int         bitsPerRGB, i;
+    VisualPtr   visual;
+
+    /* Communicate the information about our initialized screen back to X. */
+    bitsPerRGB = dfb.pixelInfo.bitsPerComponent;
+
+    // reset the visual list
+    miClearVisualTypes();
+
+    // setup a single visual appropriate for our pixel type
+    // Note: Darwin kIORGBDirectPixels = X window TrueColor, not DirectColor
+    if (dfb.pixelInfo.pixelType == kIORGBDirectPixels) {
+        if (!miSetVisualTypes( dfb.colorBitsPerPixel, TrueColorMask,
+                                bitsPerRGB, TrueColor )) {
+            return FALSE;
+        }
+    } else if (dfb.pixelInfo.pixelType == kIOCLUTPixels) {
+        if (!miSetVisualTypes( dfb.colorBitsPerPixel, PseudoColorMask,
+                                bitsPerRGB, PseudoColor )) {
+            return FALSE;
+        }
+    } else if (dfb.pixelInfo.pixelType == kIOFixedCLUTPixels) {
+        if (!miSetVisualTypes( dfb.colorBitsPerPixel, StaticColorMask,
+                                bitsPerRGB, StaticColor )) {
+            return FALSE;
+        }
+    } else {
+        return FALSE;
+    }
+
+    // machine independent screen init
+    // setup _Screen structure in pScreen
+    if ( dfb.bitsPerPixel == 32 ) {
+        if (!cfb32ScreenInit(pScreen,
+                dfb.framebuffer,
+                dfb.width, dfb.height,
+                    75, 75,		/* screen size in dpi, which we have no accurate knowledge of */
+                dfb.pitch / (dfb.bitsPerPixel/8))) {
+            return FALSE;
+        }
+    } else if ( dfb.bitsPerPixel == 16 ) {
+        if (!cfb16ScreenInit(pScreen,
+                dfb.framebuffer,
+                dfb.width, dfb.height,
+                    75, 75,		/* screen size in dpi, which we have no accurate knowledge of */
+                dfb.pitch / (dfb.bitsPerPixel/8))) {
+            return FALSE;
+        }
+    } else if ( dfb.bitsPerPixel == 8 ) {
+        if (!cfbScreenInit(pScreen,
+                dfb.framebuffer,
+                dfb.width, dfb.height,
+                    75, 75,		/* screen size in dpi, which we have no accurate knowledge of */
+                dfb.pitch / (dfb.bitsPerPixel/8))) {
+            return FALSE;
+        }
+    } else {
+        return FALSE;
+    }
+
+    // set the RGB order correctly for TrueColor, it is byte swapped by X
+    // FIXME: make work on x86 darwin if it ever gets buildable
+    if (dfb.bitsPerPixel > 8) {
+        for (i = 0, visual = pScreen->visuals;  // someday we may have more than 1
+            i < pScreen->numVisuals; i++, visual++) {
+            if (visual->class == TrueColor) {
+                visual->offsetRed = bitsPerRGB * 2;
+                visual->offsetGreen = bitsPerRGB;
+                visual->offsetBlue = 0;
+#if FALSE
+                visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed;
+                visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen;
+                visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue;
+#else
+                visual->redMask = dfb.pixelInfo.componentMasks[0];
+                visual->greenMask = dfb.pixelInfo.componentMasks[1];
+                visual->blueMask = dfb.pixelInfo.componentMasks[2];
+#endif
+            }
+        }
+    }
+
+#ifdef MITSHM
+    ShmRegisterFbFuncs(pScreen);
+#endif
+
+    // setup cursor support, use hardware if possible
+    if (!DarwinInitCursor(pScreen)) {
+        return FALSE;
+    }
+
+    // this must be initialized (why doesn't X have a default?)
+    pScreen->SaveScreen = DarwinSaveScreen;
+    
+    // initialize colormap handling as needed
+    if (dfb.pixelInfo.pixelType == kIOCLUTPixels) {
+        pScreen->StoreColors = DarwinStoreColors;
+    }
+
+    // create and install the default colormap and
+    // set pScreen->blackPixel / pScreen->white
+    if (!miCreateDefColormap( pScreen )) {
+        return FALSE;
+    }
+    
+    return TRUE;
+}
+
+/*
+ * DarwinShutdownScreen
+ */
+void DarwinShutdownScreen( void )
+{
+#if 0
+    // we must close the HID System first
+    // because it is a client of the framebuffer
+    NXCloseEventStatus( dfb.hidParam );
+    IOServiceClose( dfb.hidService );
+    IOServiceClose( dfb.fbService );
+#endif
+}
+
+/*
+ =============================================================================
+
+ mouse callbacks
+ 
+ =============================================================================
+*/
+
+/*
+ * Set mouse acceleration and thresholding
+ * FIXME: We currently ignore the threshold in ctrl->threshold.
+ */
+static void DarwinChangePointerControl(
+    DeviceIntPtr    device,
+    PtrCtrl         *ctrl )
+{
+    kern_return_t   kr;
+    double          acceleration;
+
+    acceleration = ctrl->num / ctrl->den;
+    kr = IOHIDSetMouseAcceleration( dfb.hidParam, acceleration );
+    if (kr != KERN_SUCCESS)
+        ErrorF( "Could not set mouse acceleration with kernel return = 0x%x.\n", kr );
+}
+
+
+/*
+ * Motion history between events is not required to be supported.
+ */
+static int DarwinGetMotionEvents( DeviceIntPtr pDevice, xTimecoord *buff,
+                           unsigned long start, unsigned long stop, ScreenPtr pScr)
+{
+	return 0;
+}
+
+
+/*
+ * DarwinMouseProc --
+ *      Handle the initialization, etc. of a mouse
+ */
+
+static int DarwinMouseProc( DeviceIntPtr pPointer, int what ) {
+
+  char map[6];
+
+  switch (what) {
+
+  case DEVICE_INIT:
+    pPointer->public.on = FALSE;
+
+    map[1] = 1;
+    map[2] = 2;
+    map[3] = 3;
+    map[4] = 4;
+    map[5] = 5;
+    InitPointerDeviceStruct( (DevicePtr)pPointer,
+                map,
+                5,                      // numbuttons (4 & 5 are scroll wheel)
+                DarwinGetMotionEvents,  // miPointerGetMotionEvents ??
+                DarwinChangePointerControl,
+                0 );
+    break;
+
+  case DEVICE_ON:
+    pPointer->public.on = TRUE;
+      AddEnabledDevice( darwinEventFD ); 
+    return Success;
+
+  case DEVICE_CLOSE:
+  case DEVICE_OFF:
+    pPointer->public.on = FALSE;
+      RemoveEnabledDevice( darwinEventFD ); 
+    return Success;
+  }
+
+  return Success;
+}
+
+/*
+ * DarwinKeybdProc
+ * callback from X
+ */
+static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
+{
+    switch ( onoff ) {
+        case DEVICE_INIT:
+            DarwinKeyboardInit( pDev );
+            break;
+        case DEVICE_ON:
+            pDev->public.on = TRUE;
+            AddEnabledDevice( darwinEventFD );
+            break;
+        case DEVICE_OFF:
+            pDev->public.on = FALSE;
+            RemoveEnabledDevice( darwinEventFD );
+            break;
+        case DEVICE_CLOSE:
+            break;
+    }
+
+    return Success;
+}
+
+/*
+===========================================================================
+
+ Functions needed to link against device independent X
+
+===========================================================================
+*/
+
+/*
+ * ProcessInputEvents
+ * Read events from the event queue
+ */
+void ProcessInputEvents(void)
+{
+    xEvent	xe;
+    NXEvent	ev;
+    int	r;
+    struct timeval tv;
+    struct timezone tz;
+
+    // try to read from our pipe
+    r = read( darwinEventFD, &ev, sizeof(ev));
+    if ((r == -1) && (errno != EAGAIN)) {
+        ErrorF("read(darwinEventFD) failed, errno=%d: %s\n", errno, strerror(errno));
+        return;
+    } else if ((r == -1) && (errno == EAGAIN)) {
+        return;
+    } else if ( r != sizeof( ev ) ) {
+        ErrorF( "Only read %i bytes from darwinPipe!", r );
+        return;
+    }
+
+    gettimeofday(&tv, &tz);
+
+    // translate it to an X event and post it
+    memset(&xe, 0, sizeof(xe));
+
+    xe.u.keyButtonPointer.rootX = ev.location.x;
+    xe.u.keyButtonPointer.rootY = ev.location.y;
+    //xe.u.keyButtonPointer.time = ev.time;
+    xe.u.keyButtonPointer.time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
+
+    /* A newer kernel generates multi-button events by NX_SYSDEFINED.
+       See iokit/Families/IOHIDSystem/IOHIDSystem.cpp version 1.1.1.7,
+       2000/08/10 00:23:37 or later. */
+
+    switch( ev.type ) {
+        case NX_MOUSEMOVED:
+            xe.u.u.type = MotionNotify;
+            (darwinPointer->public.processInputProc)( &xe, darwinPointer, 1 );
+            break;
+ 
+        case NX_LMOUSEDOWN:
+            // Mimic multi-button mouse with Command and Option
+            if (fake3Buttons && ev.flags & (NX_COMMANDMASK | NX_ALTERNATEMASK)) {
+                if (ev.flags & NX_COMMANDMASK) {
+                    // first fool X into forgetting about Command key
+                    xe.u.u.type = KeyRelease;
+                    xe.u.u.detail = darwinKeyCommandL;
+                    (darwinKeyboard->public.processInputProc)
+                            ( &xe, darwinKeyboard, 1 );
+                    // push button 2
+                    xe.u.u.type = ButtonPress;
+                    xe.u.u.detail = 2;			// de.key = button 2
+                    (darwinPointer->public.processInputProc)
+                            ( &xe, darwinPointer, 1 );
+                    // reset Command key down
+                    xe.u.u.type = KeyPress;
+                    xe.u.u.detail = darwinKeyCommandL;
+                    (darwinKeyboard->public.processInputProc)
+                            ( &xe, darwinKeyboard, 1 );
+                } else {
+                    // first fool X into forgetting about Option key
+                    xe.u.u.type = KeyRelease;
+                    xe.u.u.detail = darwinKeyOptionL;
+                    (darwinKeyboard->public.processInputProc)
+                            ( &xe, darwinKeyboard, 1 );
+                    // push button 3
+                    xe.u.u.type = ButtonPress;
+                    xe.u.u.detail = 3;			// de.key = button 3
+                    (darwinPointer->public.processInputProc)
+                            ( &xe, darwinPointer, 1 );
+                    // reset Option key down
+                    xe.u.u.type = KeyPress;
+                    xe.u.u.detail = darwinKeyOptionL;
+                    (darwinKeyboard->public.processInputProc)
+                            ( &xe, darwinKeyboard, 1 );
+                }
+            } else {
+                xe.u.u.detail = 1;			//de.key = button 1;
+                xe.u.u.type = ButtonPress;
+                (darwinPointer->public.processInputProc)
+                        ( &xe, darwinPointer, 1 );
+            }
+            break;
+
+        case NX_LMOUSEUP:
+            // Mimic multi-button mouse with Command and Option
+            if (fake3Buttons && ev.flags & (NX_COMMANDMASK | NX_ALTERNATEMASK)) {
+                if (ev.flags & NX_COMMANDMASK) {
+                    // first fool X into forgetting about Command key
+                    xe.u.u.type = KeyRelease;
+                    xe.u.u.detail = darwinKeyCommandL;
+                    (darwinKeyboard->public.processInputProc)
+                            ( &xe, darwinKeyboard, 1 );
+                    // push button 2
+                    xe.u.u.type = ButtonRelease;
+                    xe.u.u.detail = 2;			// de.key = button 2
+                    (darwinPointer->public.processInputProc)
+                            ( &xe, darwinPointer, 1 );
+                    // reset Command key down
+                    xe.u.u.type = KeyPress;
+                    xe.u.u.detail = darwinKeyCommandL;
+                    (darwinKeyboard->public.processInputProc)
+                            ( &xe, darwinKeyboard, 1 );
+                } else {
+                    // first fool X into forgetting about Option key
+                    xe.u.u.type = KeyRelease;
+                    xe.u.u.detail = darwinKeyOptionL;
+                    (darwinKeyboard->public.processInputProc)
+                            ( &xe, darwinKeyboard, 1 );
+                    // push button 3
+                    xe.u.u.type = ButtonRelease;
+                    xe.u.u.detail = 3;			// de.key = button 3
+                    (darwinPointer->public.processInputProc)
+                            ( &xe, darwinPointer, 1 );
+                    // reset Option key down
+                    xe.u.u.type = KeyPress;
+                    xe.u.u.detail = darwinKeyOptionL;
+                    (darwinKeyboard->public.processInputProc)
+                            ( &xe, darwinKeyboard, 1 );
+                }
+            } else {
+                xe.u.u.detail = 1;			//de.key = button 1;
+                xe.u.u.type = ButtonRelease;
+                (darwinPointer->public.processInputProc)
+                        ( &xe, darwinPointer, 1 );
+            }
+            break;
+
+// Button 2 isn't handled correctly by older kernels anyway. Just let
+// NX_SYSDEFINED events handle these.
+        case NX_RMOUSEDOWN:
+#if 0
+            xe.u.u.detail = 2; //de.key;
+            xe.u.u.type = ButtonPress;
+            (darwinPointer->public.processInputProc)( &xe, darwinPointer, 1 );
+#endif
+            break;
+
+        case NX_RMOUSEUP:
+#if 0
+            xe.u.u.detail = 2; //de.key;
+            xe.u.u.type = ButtonRelease;
+            (darwinPointer->public.processInputProc)( &xe, darwinPointer, 1 );
+#endif
+            break;
+
+        case NX_KEYDOWN:
+            xe.u.u.type = KeyPress;
+            xe.u.u.detail = ev.data.key.keyCode + MIN_KEYCODE;
+            (darwinKeyboard->public.processInputProc)( &xe, darwinKeyboard, 1 );
+            break;
+
+        case NX_KEYUP:
+            xe.u.u.type = KeyRelease;
+            xe.u.u.detail = ev.data.key.keyCode + MIN_KEYCODE;
+            (darwinKeyboard->public.processInputProc)(&xe, darwinKeyboard, 1);
+            break;
+
+        case NX_FLAGSCHANGED:
+        {
+            static int old_state = 0;
+            int new_on_flags = ~old_state & ev.flags;
+            int new_off_flags = old_state & ~ev.flags;
+            old_state = ev.flags;
+            xe.u.u.detail = ev.data.key.keyCode + MIN_KEYCODE;
+
+            // alphalock is toggled rather than held on,
+            // so we have to handle it differently
+            if (new_on_flags & NX_ALPHASHIFTMASK ||
+                new_off_flags & NX_ALPHASHIFTMASK) {
+                xe.u.u.type = KeyPress;
+                (darwinKeyboard->public.processInputProc)
+                        (&xe, darwinKeyboard, 1);
+                xe.u.u.type = KeyRelease;
+                (darwinKeyboard->public.processInputProc)
+                        (&xe, darwinKeyboard, 1);
+                break;
+            }
+
+            if (new_on_flags) {
+                xe.u.u.type = KeyPress;
+            } else if (new_off_flags) {
+                xe.u.u.type = KeyRelease;
+            } else {
+                break;
+            }
+            (darwinKeyboard->public.processInputProc)(&xe, darwinKeyboard, 1);
+            break;
+        }
+
+        case NX_SYSDEFINED:
+            if (ev.data.compound.subType == 7) {
+                long hwDelta = ev.data.compound.misc.L[0];
+                long hwButtons = ev.data.compound.misc.L[1];
+                int i;
+
+                for (i = 1; i < 4; i++) {
+                    if (hwDelta & (1 << i)) {
+                        xe.u.u.detail = i + 1;
+                        if (hwButtons & (1 << i)) {
+                            xe.u.u.type = ButtonPress;
+                        } else {
+                            xe.u.u.type = ButtonRelease;
+                        }
+                        (darwinPointer->public.processInputProc)
+                            ( &xe, darwinPointer, 1 );
+                    }
+                }
+            }
+            break;
+
+        case NX_SCROLLWHEELMOVED:
+        {
+            short count = ev.data.scrollWheel.deltaAxis1;
+
+            if (count > 0) {
+                xe.u.u.detail = SCROLLWHEELUPFAKE;
+            } else {
+                xe.u.u.detail = SCROLLWHEELDOWNFAKE;
+                count = -count;
+            }
+
+            for (; count; --count) {
+                xe.u.u.type = ButtonPress;
+                (darwinPointer->public.processInputProc)
+                    ( &xe, darwinPointer, 1 );
+                xe.u.u.type = ButtonRelease;
+                (darwinPointer->public.processInputProc)
+                    ( &xe, darwinPointer, 1 );
+            }
+            break;
+        }
+
+        default:
+            ErrorF("unknown event caught: %d\n", ev.type);
+            ErrorF("\tev.type = %d\n", ev.type);
+            ErrorF("\tev.location.x,y = %d,%d\n", ev.location.x, ev.location.y);
+            ErrorF("\tev.time = %ld\n", ev.time);
+            ErrorF("\tev.flags = 0x%x\n", ev.flags);
+            ErrorF("\tev.window = %d\n", ev.window);
+            ErrorF("\tev.data.key.origCharSet = %d\n", ev.data.key.origCharSet);
+            ErrorF("\tev.data.key.charSet = %d\n", ev.data.key.charSet);
+            ErrorF("\tev.data.key.charCode = %d\n", ev.data.key.charCode);
+            ErrorF("\tev.data.key.keyCode = %d\n", ev.data.key.keyCode);
+            ErrorF("\tev.data.key.origCharCode = %d\n", ev.data.key.origCharCode);
+            break;
+    }
+
+    // why isn't this handled automatically by X???
+    //miPointerAbsoluteCursor( ev.location.x, ev.location.y, ev.time );
+    miPointerAbsoluteCursor( ev.location.x, ev.location.y,
+                             tv.tv_sec * 1000 + tv.tv_usec / 1000 );
+    miPointerUpdate();
+
+}
+
+static void *DarwinHIDThread(void *arg);
+
+/*
+ * InitInput
+ * Register the keyboard and mouse devices
+ */
+void InitInput( int  argc, char **argv )
+{
+	if (serverGeneration == 1) {
+		int fd[2];
+
+		assert( pipe(fd) == 0 );
+		darwinEventFD = fd[0];
+		fcntl(darwinEventFD, F_SETFL, O_NONBLOCK);
+		pthread_create(&dfb.hidThread, NULL, DarwinHIDThread, (void *) fd[1]);
+    
+		darwinPointer = AddInputDevice(DarwinMouseProc, TRUE);
+		RegisterPointerDevice( darwinPointer );
+
+		darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE);
+		RegisterKeyboardDevice( darwinKeyboard );
+	}
+}
+
+EvGlobals *     evg;
+mach_port_t     masterPort;
+mach_port_t     notificationPort;
+IONotificationPortRef NotificationPortRef;
+
+static void ClearEvent(NXEvent * ep)
+{
+    static NXEvent nullEvent = {NX_NULLEVENT, {0, 0 }, 0, -1, 0 };
+
+    *ep = nullEvent;
+    ep->data.compound.subType = ep->data.compound.misc.L[0] =
+                                ep->data.compound.misc.L[1] = 0;
+}
+
+static void *DarwinHIDThread(void *arg)
+{
+    int darwinEventWriteFD = (int)arg;
+
+    for (;;) {
+        IOReturn kr;
+        NXEvent ev;
+        NXEQElement *oldHead;
+        struct {
+            mach_msg_header_t	header;
+            mach_msg_trailer_t	trailer;
+        } msg;
+
+        kr = mach_msg((mach_msg_header_t*) &msg, MACH_RCV_MSG, 0,
+                      sizeof(msg), notificationPort, 0, MACH_PORT_NULL);
+        assert(KERN_SUCCESS == kr);
+
+        while (evg->LLEHead != evg->LLETail) {
+            oldHead = (NXEQElement*)&evg->lleq[evg->LLEHead];
+            ev_lock(&oldHead->sema);
+            ev = oldHead->event;
+            ClearEvent(&oldHead->event);
+            evg->LLEHead = oldHead->next;
+            ev_unlock(&oldHead->sema);
+
+            write(darwinEventWriteFD, &ev, sizeof(ev));
+        }
+    }
+    return NULL;
+}
+
+void SetupFBandHID(void)
+{
+    kern_return_t           kr;
+    io_service_t            service;
+    io_iterator_t           iter;
+    io_name_t               name;
+    vm_address_t            shmem, vram;
+    vm_size_t               shmemSize;
+    int                     i;
+    UInt32                  numModes;
+    IODisplayModeInformation modeInfo;
+    IODisplayModeID         displayMode, *allModes;
+    IOIndex                 displayDepth;
+    IOFramebufferInformation fbInfo;
+    StdFBShmem_t            *cshmem;
+
+    dfb.fbService = 0;
+    dfb.hidService = 0;
+
+    // find and open the IOFrameBuffer service
+    kr = IOServiceGetMatchingServices( masterPort,
+                        IOServiceMatching( IOFRAMEBUFFER_CONFORMSTO ),
+                        &iter );
+    kern_assert( kr );
+
+    assert(service = IOIteratorNext(iter));
+
+    kr = IOServiceOpen( service, mach_task_self(),
+                        kIOFBServerConnectType, &dfb.fbService );
+    if (kr != KERN_SUCCESS)
+        FatalError("failed to connect as window server!\nMake sure you have quit the Mac OS X window server.\n");
+
+    IOObjectRelease( service );
+    IOObjectRelease( iter );
+
+    // create the slice of shared memory containing cursor state data
+    kr = IOFBCreateSharedCursor( dfb.fbService, kIOFBCurrentShmemVersion,
+                               	 32, 32 );
+    kern_assert( kr );
+
+    // SET THE SCREEN PARAMETERS
+    // get the current screen resolution, refresh rate and depth
+    kr = IOFBGetCurrentDisplayModeAndDepth( dfb.fbService, &displayMode,
+                                            &displayDepth );
+    kern_assert( kr );
+
+    // use the current screen resolution if the user
+    // only wants to change the refresh rate
+    if (darwinDesiredRefresh != -1 && darwinDesiredWidth == 0) {
+        kr = IOFBGetDisplayModeInformation( dfb.fbService, displayMode,
+                                            &modeInfo );
+        kern_assert( kr );
+        darwinDesiredWidth = modeInfo.nominalWidth;
+        darwinDesiredHeight = modeInfo.nominalHeight;
+    }
+
+    // use the current resolution and refresh rate
+    // if the user doesn't have a preference
+    if (darwinDesiredWidth == 0) {
+
+        // change the pixel depth if desired
+        if (darwinDesiredDepth != -1) {
+            kr = IOFBGetDisplayModeInformation( dfb.fbService, displayMode,
+                                                &modeInfo );
+            kern_assert( kr );
+            if (modeInfo.maxDepthIndex < darwinDesiredDepth)
+                FatalError("Current screen resolution does not support desired pixel depth!\n");
+
+            displayDepth = darwinDesiredDepth;
+            kr = IOFBSetDisplayModeAndDepth( dfb.fbService, displayMode,
+                                             displayDepth );
+            kern_assert( kr );
+        }
+ 
+    // look for display mode with correct resolution and refresh rate
+    } else {
+
+        // get an array of all supported display modes
+        kr = IOFBGetDisplayModeCount( dfb.fbService, &numModes );
+        kern_assert( kr );
+        assert(allModes = (IODisplayModeID *)
+                xalloc( numModes * sizeof(IODisplayModeID) ));
+        kr = IOFBGetDisplayModes( dfb.fbService, numModes, allModes );
+        kern_assert( kr );
+
+        for (i = 0; i < numModes; i++) {
+            kr = IOFBGetDisplayModeInformation( dfb.fbService, allModes[i],
+                                                &modeInfo );
+            kern_assert( kr );
+
+            if (modeInfo.flags & kDisplayModeValidFlag &&
+                modeInfo.nominalWidth == darwinDesiredWidth &&
+                modeInfo.nominalHeight == darwinDesiredHeight) {
+
+                if (darwinDesiredDepth == -1)
+                    darwinDesiredDepth = modeInfo.maxDepthIndex;
+                if (modeInfo.maxDepthIndex < darwinDesiredDepth)
+                    FatalError("Desired screen resolution does not support desired pixel depth!\n");
+                if ((darwinDesiredRefresh == -1 ||
+                    (darwinDesiredRefresh << 16) == modeInfo.refreshRate)) {
+                    displayMode = allModes[i];
+                    displayDepth = darwinDesiredDepth;
+                    kr = IOFBSetDisplayModeAndDepth( dfb.fbService, displayMode,
+                                                     displayDepth );
+                    kern_assert( kr );
+                    break;
+                }
+            }
+        }
+
+        xfree( allModes );
+        if (i >= numModes)
+            FatalError("Desired screen resolution or refresh rate is not supported!\n");
+    }
+
+    kr = IOFBGetPixelInformation( dfb.fbService, displayMode, displayDepth,
+                                  kIOFBSystemAperture, &dfb.pixelInfo );
+    kern_assert( kr );
+
+#ifdef OLD_POWERBOOK_G3
+    if (dfb.pixelInfo.pixelType == kIOCLUTPixels)
+        dfb.pixelInfo.pixelType = kIOFixedCLUTPixels;
+#endif
+
+    kr = IOFBGetFramebufferInformationForAperture( dfb.fbService, kIOFBSystemAperture,
+                                                   &fbInfo );
+    kern_assert( kr );
+
+    kr = IOConnectMapMemory( dfb.fbService, kIOFBCursorMemory,
+                             mach_task_self(), (vm_address_t *) &cshmem,
+                             &shmemSize, kIOMapAnywhere );
+    kern_assert( kr );
+    dfb.cursorShmem = cshmem;
+
+    kr = IOConnectMapMemory( dfb.fbService, kIOFBSystemAperture, mach_task_self(),
+                             &vram, &shmemSize, kIOMapAnywhere );
+    kern_assert( kr );
+
+    dfb.framebuffer = (void*)vram;
+    dfb.width = fbInfo.activeWidth;
+    dfb.height = fbInfo.activeHeight;
+    dfb.pitch = fbInfo.bytesPerRow;
+    dfb.bitsPerPixel = fbInfo.bitsPerPixel;
+    dfb.colorBitsPerPixel = dfb.pixelInfo.componentCount *
+                            dfb.pixelInfo.bitsPerComponent;
+
+    // find and open the HID System Service
+    kr = IOServiceGetMatchingServices( masterPort,
+                                       IOServiceMatching( kIOHIDSystemClass ),
+                                       &iter );
+    kern_assert( kr );
+
+    assert( service = IOIteratorNext( iter ) );
+
+    kr = IORegistryEntryGetName( service, name );
+    kern_assert( kr );
+
+    kr = IOServiceOpen( service, mach_task_self(), kIOHIDServerConnectType,
+                        &dfb.hidService );
+    kern_assert( kr );
+
+    IOObjectRelease( service );
+    IOObjectRelease( iter );
+
+    kr = IOHIDCreateSharedMemory( dfb.hidService, kIOHIDCurrentShmemVersion );
+    kern_assert( kr );
+
+    kr = IOHIDSetEventsEnable(dfb.hidService, TRUE);
+    kern_assert( kr );
+
+    // Inform the HID system that the framebuffer is also connected to it
+    kr = IOConnectAddClient( dfb.hidService, dfb.fbService );
+    kern_assert( kr );
+
+    kr = IOHIDSetCursorEnable(dfb.hidService, TRUE);
+    kern_assert( kr );
+
+    kr = IOConnectMapMemory( dfb.hidService, kIOHIDGlobalMemory, mach_task_self(),
+                             &shmem, &shmemSize, kIOMapAnywhere );
+    kern_assert( kr );
+
+    evg = (EvGlobals *)(shmem + ((EvOffsets *)shmem)->evGlobalsOffset);
+
+    assert(sizeof(EvGlobals) == evg->structSize);
+
+    NotificationPortRef = IONotificationPortCreate( masterPort );
+
+    notificationPort = IONotificationPortGetMachPort(NotificationPortRef);
+
+    kr = IOConnectSetNotificationPort( dfb.hidService, kIOHIDEventNotification,
+                                       notificationPort, 0 );
+    kern_assert( kr );
+
+    evg->movedMask |= NX_MOUSEMOVEDMASK;
+}
+
+
+/*
+ * InitOutput
+ *	Initialize screenInfo for all actually accessible framebuffers.
+ */
+void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv )
+{
+    int i;
+
+    pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+    pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+    pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+    pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+    // list how we want common pixmap formats to be padded
+    pScreenInfo->numPixmapFormats = NUMFORMATS;
+    for (i = 0; i < NUMFORMATS; i++)
+        pScreenInfo->formats[i] = formats[i];
+
+    AddScreen( DarwinAddScreen, argc, argv );
+}
+
+void OsVendorFatalError( void )
+{	ErrorF( "   OsVendorFatalError\n" );
+}
+
+/*
+ * OSVendorInit
+ *  One-time initialization of Darwin support.
+ *  Connect to framebuffer and HID system.
+ */
+void OsVendorInit(void)
+{
+    kern_return_t           kr;
+
+    kr = IOMasterPort(bootstrap_port, &masterPort);
+    kern_assert( kr );
+
+    DarwinPrintBanner();
+    SetupFBandHID();
+}
+
+/*
+ * ddxProcessArgument --
+ *	Process device-dependent command line args. Returns 0 if argument is
+ *      not device dependent, otherwise Count of number of elements of argv
+ *      that are part of a device dependent commandline option.
+ */
+int ddxProcessArgument( int argc, char *argv[], int i )
+{
+#if 0
+    if ( !strcmp( argv[i], "-screen" ) ) {
+    	if ( i == argc-1 ) {
+            FatalError( "-screen must be followed by a number" );
+        }
+    	darwinScreenNumber = atoi( argv[i+1] );
+        ErrorF( "Attempting to use screen number %i\n", darwinScreenNumber );
+		return 2;
+    }
+#endif
+
+    if ( !strcmp( argv[i], "-fakebuttons" ) ) {
+    	fake3Buttons = TRUE;
+        ErrorF( "Faking a three button mouse\n" );
+		return 1;
+    }
+
+    if ( !strcmp( argv[i], "-nofakebuttons" ) ) {
+    	fake3Buttons = FALSE;
+        ErrorF( "Not faking a three button mouse\n" );
+		return 1;
+    }
+
+    if ( !strcmp( argv[i], "-size" ) ) {
+    	if ( i >= argc-2 ) {
+            FatalError( "-size must be followed by two numbers" );
+        }
+#ifdef OLD_POWERBOOK_G3
+        ErrorF( "Ignoring unsupported -size option on old PowerBook G3\n");
+#else
+    	darwinDesiredWidth = atoi( argv[i+1] );
+        darwinDesiredHeight = atoi( argv[i+2] );
+        ErrorF( "Attempting to use width x height = %i x %i\n",
+                darwinDesiredWidth, darwinDesiredHeight );
+#endif
+        return 3;
+    }
+
+    if ( !strcmp( argv[i], "-depth" ) ) {
+        int     bitDepth;
+    	if ( i == argc-1 ) {
+            FatalError( "-depth must be followed by a number" );
+        }
+#ifdef OLD_POWERBOOK_G3
+        ErrorF( "Ignoring unsupported -depth option on old PowerBook G3\n");
+#else
+    	bitDepth = atoi( argv[i+1] );
+        if (bitDepth == 8)
+            darwinDesiredDepth = 0;
+        else if (bitDepth == 15)
+            darwinDesiredDepth = 1;
+        else if (bitDepth == 24)
+            darwinDesiredDepth = 2;
+        else
+            FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits" );
+        ErrorF( "Attempting to use pixel depth of %i\n", bitDepth );
+#endif
+        return 2;
+    }
+
+    if ( !strcmp( argv[i], "-refresh" ) ) {
+    	if ( i == argc-1 ) {
+            FatalError( "-refresh must be followed by a number" );
+        }
+#ifdef OLD_POWERBOOK_G3
+        ErrorF( "Ignoring unsupported -refresh option on old PowerBook G3\n");
+#else
+    	darwinDesiredRefresh = atoi( argv[i+1] );
+        ErrorF( "Attempting to use refresh rate of %i\n", darwinDesiredRefresh );
+#endif
+        return 2;
+    }
+
+    if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
+        DarwinPrintBanner();
+        exit(0);
+    }
+
+    return 0;
+}
+
+/*
+ * ddxUseMsg --
+ *	Print out correct use of device dependent commandline options.
+ *      Maybe the user now knows what really to do ...
+ */
+void ddxUseMsg( void )
+{
+    ErrorF("\n");
+    ErrorF("\n");
+    ErrorF("Device Dependent Usage:\n");
+    ErrorF("\n");
+#if 0
+    ErrorF("-screen <0,1,...> : use this mac screen num.\n" );
+#endif
+    ErrorF("-fakebuttons : fake a three button mouse with Command and Option keys.\n");
+    ErrorF("-nofakebuttons : don't fake a three button mouse.\n");
+    ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n");
+    ErrorF("-depth <8,15,24> : use this bit depth.\n");
+    ErrorF("-refresh <rate> : use a monitor refresh rate of <rate> Hz.\n");
+    ErrorF("-version : show the server version\n");
+    ErrorF("\n");
+}
+
+/*
+ * ddxGiveUp --
+ *      Device dependent cleanup. Called by dix before normal server death.
+ */
+void ddxGiveUp( void ) {
+    ErrorF( "   ddxGiveUp\n" ); 
+}
+
+/*
+ * AbortDDX --
+ *      DDX - specific abort routine.  Called by AbortServer(). The attempt is
+ *      made to restore all original setting of the displays. Also all devices
+ *      are closed.
+ */
+void AbortDDX( void ) {
+#if TRUE
+   ErrorF( "   AbortDDX\n" ); 
+    /*
+     * This is needed for a abnormal server exit, since the normal exit stuff
+     * MUST also be performed (i.e. the vt must be left in a defined state)
+     */
+    ddxGiveUp();
+#endif
+}
+
+Bool DPMSSupported(void)
+{	return 0;
+}
+
+void DPMSSet(void)
+{	return;
+}
Index: xc/programs/Xserver/hw/darwin/darwin.h
diff -u /dev/null xc/programs/Xserver/hw/darwin/darwin.h:1.1
--- /dev/null	Mon Dec 18 14:28:29 2000
+++ xc/programs/Xserver/hw/darwin/darwin.h	Tue Nov 14 20:36:13 2000
@@ -0,0 +1,38 @@
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwin.h,v 1.1 2000/11/15 01:36:13 dawes Exp $ */
+
+#ifndef _DARWIN_H
+#define _DARWIN_H
+
+#include <pthread.h>
+#include <IOKit/graphics/IOFramebufferShared.h>
+#include "inputstr.h"
+#include "screenint.h"
+#include "extensions/XKB.h"
+
+typedef struct {
+    pthread_t           hidThread;
+    io_connect_t        fbService;
+    io_connect_t        hidService;
+    io_connect_t        hidParam;
+    void                *framebuffer;
+    int                 width;
+    int                 height;
+    int                 pitch;
+    int                 bitsPerPixel;
+    int                 colorBitsPerPixel;
+    IOPixelInformation  pixelInfo;
+    StdFBShmem_t        *cursorShmem;
+} DarwinFramebufferRec;
+
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+Bool DarwinInitCursor(ScreenPtr	pScreen);
+
+#define assert(x) { if ((x) == 0) \
+    FatalError("assert failed on line %d of %s!\n", __LINE__, __FILE__); }
+#define kern_assert(x) { if ((x) != KERN_SUCCESS) \
+    FatalError("assert failed on line %d of %s with kernel return 0x%x!\n", \
+                __LINE__, __FILE__, x); }
+
+#define MIN_KEYCODE     XkbMinLegalKeyCode     // unfortunately, this isn't 0...
+
+#endif	/* _DARWIN_H */
Index: xc/programs/Xserver/hw/darwin/darwinCursor.c
diff -u /dev/null xc/programs/Xserver/hw/darwin/darwinCursor.c:1.2
--- /dev/null	Mon Dec 18 14:28:30 2000
+++ xc/programs/Xserver/hw/darwin/darwinCursor.c	Tue Nov 28 12:25:10 2000
@@ -0,0 +1,706 @@
+/**************************************************************
+ *
+ * Cursor support for Darwin X Server
+ *
+ * Three different cursor modes are possible:
+ *  X (0)         - tracking via Darwin kernel,
+ *                  display via X machine independent
+ *  Kernel (1)    - tracking and display via Darwin kernel
+ *                  (not currently supported)
+ *  Hardware (2)  - tracking and display via hardware
+ *
+ * The X software cursor uses the Darwin software cursor
+ * routines in IOFramebuffer.cpp to track the cursor, but
+ * displays the cursor image using the X machine
+ * independent display cursor routines in midispcur.c.
+ *
+ * The kernel cursor uses IOFramebuffer.cpp routines to
+ * track and display the cursor. This gives better
+ * performance as the display calls don't have to cross
+ * the kernel boundary. Unfortunately, this mode has
+ * synchronization issues with the user land X server
+ * and isn't currently used.
+ *
+ * Hardware cursor support lets the hardware handle these
+ * details.
+ *
+ * Kernel and hardware cursor mode only work for cursors
+ * up to a certain size, currently 16x16 pixels. If a
+ * bigger cursor is set, we fallback to X cursor mode.
+ *
+ * HISTORY:
+ * 1.0 by Torrey T. Lyons, October 30, 2000
+ *
+ **************************************************************/
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwinCursor.c,v 1.2 2000/11/28 17:25:10 dawes Exp $ */
+
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "micmap.h"
+#define NO_CFPLUGIN
+#include <IOKit/graphics/IOGraphicsLib.h>
+#include <IOKit/hidsystem/IOHIDLib.h>
+#include "darwin.h"
+#include "mipointrst.h"
+
+#define DUMP_DARWIN_CURSOR FALSE
+
+// The cursors format are documented in IOFramebufferShared.h.
+#define RGBto34WithGamma(red, green, blue)  \
+    (  0x000F                               \
+     | (((red) & 0xF) << 12)                \
+     | (((green) & 0xF) << 8)               \
+     | (((blue) & 0xF) << 4) )
+#define RGBto38WithGamma(red, green, blue)  \
+    (  0xFF << 24                           \
+     | (((red) & 0xFF) << 16)               \
+     | (((green) & 0xFF) << 8)              \
+     | (((blue) & 0xFF)) )
+#define HighBitOf32 0x80000000
+
+typedef struct {
+    Bool                    canHWCursor;
+    short                   cursorMode;
+    RecolorCursorProcPtr    RecolorCursor;
+    InstallColormapProcPtr  InstallColormap;
+    QueryBestSizeProcPtr    QueryBestSize;
+    miPointerSpriteFuncPtr  spriteFuncs;
+    ColormapPtr             pInstalledMap;
+} DarwinCursorScreenRec, *DarwinCursorScreenPtr;
+
+extern DarwinFramebufferRec dfb;
+static int darwinCursorScreenIndex = -1;
+static unsigned long darwinCursorGeneration = 0;
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+    Realizing the Darwin hardware cursor (ie. converting from the
+    X representation to the Darwin representation) is complicated
+    by the fact that we have three different potential cursor
+    formats to go to, one for each bit depth (8, 15, or 24).
+    The Darwin formats are documented in IOFramebufferShared.h.
+    X cursors are represented as two pieces, a source and a mask.
+    The mask is a bitmap indicating which parts of the cursor are 
+    transparent and which parts are drawn.  The source is a bitmap
+    indicating which parts of the non-transparent portion of the the
+    cursor should be painted in the foreground color and which should
+    be painted in the background color. The bitmaps are given in
+    32-bit format with least significant byte and bit first.
+    (This is opposite PowerPC Darwin.)
+*/
+
+typedef struct {
+    unsigned char image[CURSORWIDTH*CURSORHEIGHT];
+    unsigned char mask[CURSORWIDTH*CURSORHEIGHT];
+} cursorPrivRec, *cursorPrivPtr;
+
+/*
+ * DarwinRealizeCursor8
+ * Convert the X cursor representation to an 8-bit depth
+ * format for Darwin. This function assumes the maximum cursor
+ * width is a multiple of 8.
+ */
+static Bool
+DarwinRealizeCursor8(
+    ScreenPtr pScreen,
+    CursorPtr pCursor)
+{
+    cursorPrivPtr   newCursor;
+    unsigned char   *newSourceP, *newMaskP;
+    CARD32          *oldSourceP, *oldMaskP;
+    xColorItem      fgColor, bgColor;
+    int             index, x, y, rowPad;
+    int             cursorWidth, cursorHeight;
+    ColormapPtr     pmap;
+
+    // check cursor size just to be sure
+    cursorWidth = pCursor->bits->width;
+    cursorHeight = pCursor->bits->height;
+    if (cursorHeight > CURSORHEIGHT || cursorWidth > CURSORWIDTH)
+        return FALSE;
+
+    // get cursor colors in colormap
+    index = pScreen->myNum;
+    pmap = miInstalledMaps[index];
+    if (!pmap) return FALSE;
+
+    fgColor.red = pCursor->foreRed;
+    fgColor.green = pCursor->foreGreen;
+    fgColor.blue = pCursor->foreBlue;
+    FakeAllocColor(pmap, &fgColor);
+    bgColor.red = pCursor->backRed;
+    bgColor.green = pCursor->backGreen;
+    bgColor.blue = pCursor->backBlue;
+    FakeAllocColor(pmap, &bgColor);
+    FakeFreeColor(pmap, fgColor.pixel);
+    FakeFreeColor(pmap, bgColor.pixel);
+
+    // allocate memory for new cursor image
+    newCursor = xalloc( sizeof(cursorPrivRec) );
+    if (!newCursor)
+        return FALSE;
+    memset( newCursor->image, pScreen->blackPixel, CURSORWIDTH*CURSORHEIGHT );
+    memset( newCursor->mask, 0, CURSORWIDTH*CURSORHEIGHT );
+
+    // convert to 8-bit Darwin cursor format
+    oldSourceP = (CARD32 *) pCursor->bits->source;
+    oldMaskP = (CARD32 *) pCursor->bits->mask;
+    newSourceP = newCursor->image;
+    newMaskP = newCursor->mask;
+    rowPad = CURSORWIDTH - cursorWidth;
+
+    for (y = 0; y < cursorHeight; y++) {
+        for (x = 0; x < cursorWidth; x++) {
+            if (*oldSourceP & (HighBitOf32 >> x))
+                *newSourceP = fgColor.pixel;
+            else
+                *newSourceP = bgColor.pixel;
+            if (*oldMaskP & (HighBitOf32 >> x))
+                *newMaskP = 255;
+            else
+                *newSourceP = pScreen->blackPixel;
+            newSourceP++; newMaskP++;
+        }
+        oldSourceP++; oldMaskP++;
+        newSourceP += rowPad; newMaskP += rowPad;
+    }
+
+    // save the result
+    pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
+    return TRUE;
+}
+
+
+/*
+ * DarwinRealizeCursor15
+ * Convert the X cursor representation to an 15-bit depth
+ * format for Darwin.
+ */
+static Bool
+DarwinRealizeCursor15(
+    ScreenPtr       pScreen,
+    CursorPtr       pCursor)
+{
+    unsigned short  *newCursor;
+    unsigned short  fgPixel, bgPixel;
+    unsigned short  *newSourceP;
+    CARD32          *oldSourceP, *oldMaskP;
+    int             x, y, rowPad;
+    int             cursorWidth, cursorHeight;
+
+    // check cursor size just to be sure
+    cursorWidth = pCursor->bits->width;
+    cursorHeight = pCursor->bits->height;
+    if (cursorHeight > CURSORHEIGHT || cursorWidth > CURSORWIDTH)
+       return FALSE;
+
+    // allocate memory for new cursor image
+    newCursor = xalloc( CURSORWIDTH*CURSORHEIGHT*sizeof(short) );
+    if (!newCursor)
+        return FALSE;
+    memset( newCursor, 0, CURSORWIDTH*CURSORHEIGHT*sizeof(short) );
+
+    // calculate pixel values
+    fgPixel = RGBto34WithGamma( pCursor->foreRed, pCursor->foreGreen,
+                                pCursor->foreBlue );
+    bgPixel = RGBto34WithGamma( pCursor->backRed, pCursor->backGreen,
+                                pCursor->backBlue );
+
+    // convert to 15-bit Darwin cursor format
+    oldSourceP = (CARD32 *) pCursor->bits->source;
+    oldMaskP = (CARD32 *) pCursor->bits->mask;
+    newSourceP = newCursor;
+    rowPad = CURSORWIDTH - cursorWidth;
+
+    for (y = 0; y < cursorHeight; y++) {
+        for (x = 0; x < cursorWidth; x++) {
+            if (*oldMaskP & (HighBitOf32 >> x)) {
+                if (*oldSourceP & (HighBitOf32 >> x))
+                    *newSourceP = fgPixel;
+                else
+                    *newSourceP = bgPixel;
+            } else {
+                *newSourceP = 0;
+            }
+            newSourceP++;
+        }
+        oldSourceP++; oldMaskP++;
+        newSourceP += rowPad;
+    }
+
+#if DUMP_DARWIN_CURSOR
+    // Write out the cursor
+    ErrorF("Cursor: 0x%x\n", pCursor);
+    ErrorF("Width = %i, Height = %i, RowPad = %i\n", cursorWidth,
+            cursorHeight, rowPad);
+    for (y = 0; y < cursorHeight; y++) {
+        newSourceP = newCursor + y*CURSORWIDTH;
+        for (x = 0; x < cursorWidth; x++) {
+            if (*newSourceP == fgPixel)
+                ErrorF("x");
+            else if (*newSourceP == bgPixel)
+                ErrorF("o");
+            else
+                ErrorF(" ");
+            newSourceP++;
+        }
+        ErrorF("\n");
+    }
+#endif
+
+    // save the result
+    pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
+    return TRUE;
+}
+
+
+/*
+ * DarwinRealizeCursor24
+ * Convert the X cursor representation to an 24-bit depth
+ * format for Darwin. This function assumes the maximum cursor
+ * width is a multiple of 8.
+ */
+static Bool
+DarwinRealizeCursor24(
+    ScreenPtr       pScreen,
+    CursorPtr       pCursor)
+{
+    unsigned int    *newCursor;
+    unsigned int    fgPixel, bgPixel;
+    unsigned int    *newSourceP;
+    CARD32          *oldSourceP, *oldMaskP;
+    int             x, y, rowPad;
+    int             cursorWidth, cursorHeight;
+
+    // check cursor size just to be sure
+    cursorWidth = pCursor->bits->width;
+    cursorHeight = pCursor->bits->height;
+    if (cursorHeight > CURSORHEIGHT || cursorWidth > CURSORWIDTH)
+       return FALSE;
+
+    // allocate memory for new cursor image
+    newCursor = xalloc( CURSORWIDTH*CURSORHEIGHT*sizeof(int) );
+    if (!newCursor)
+        return FALSE;
+    memset( newCursor, 0, CURSORWIDTH*CURSORHEIGHT*sizeof(int) );
+
+    // calculate pixel values
+    fgPixel = RGBto38WithGamma( pCursor->foreRed, pCursor->foreGreen,
+                                pCursor->foreBlue );
+    bgPixel = RGBto38WithGamma( pCursor->backRed, pCursor->backGreen,
+                                pCursor->backBlue );
+
+    // convert to 24-bit Darwin cursor format
+    oldSourceP = (CARD32 *) pCursor->bits->source;
+    oldMaskP = (CARD32 *) pCursor->bits->mask;
+    newSourceP = newCursor;
+    rowPad = CURSORWIDTH - cursorWidth;
+
+    for (y = 0; y < cursorHeight; y++) {
+        for (x = 0; x < cursorWidth; x++) {
+            if (*oldMaskP & (HighBitOf32 >> x)) {
+                if (*oldSourceP & (HighBitOf32 >> x))
+                    *newSourceP = fgPixel;
+                else
+                    *newSourceP = bgPixel;
+            } else {
+                *newSourceP = 0;
+            }
+            newSourceP++;
+        }
+        oldSourceP++; oldMaskP++;
+        newSourceP += rowPad;
+    }
+
+#if DUMP_DARWIN_CURSOR
+    // Write out the cursor
+    ErrorF("Cursor: 0x%x\n", pCursor);
+    ErrorF("Width = %i, Height = %i, RowPad = %i\n", cursorWidth,
+            cursorHeight, rowPad);
+    for (y = 0; y < cursorHeight; y++) {
+        newSourceP = newCursor + y*CURSORWIDTH;
+        for (x = 0; x < cursorWidth; x++) {
+            if (*newSourceP == fgPixel)
+                ErrorF("x");
+            else if (*newSourceP == bgPixel)
+                ErrorF("o");
+            else
+                ErrorF(" ");
+            newSourceP++;
+        }
+        ErrorF("\n");
+    }
+#endif
+
+    // save the result
+    pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
+    return TRUE;
+}
+
+
+/*
+ * DarwinRealizeCursor
+ * 
+ */
+static Bool
+DarwinRealizeCursor(
+    ScreenPtr       pScreen,
+    CursorPtr       pCursor)
+{
+    Bool                        result;
+    DarwinCursorScreenPtr       ScreenPriv = (DarwinCursorScreenPtr)
+        pScreen->devPrivates[darwinCursorScreenIndex].ptr;
+
+    if ((pCursor->bits->height > CURSORHEIGHT) ||
+        (pCursor->bits->width > CURSORWIDTH) ||
+        // FIXME: this condition is not needed after kernel cursor works
+        !ScreenPriv->canHWCursor) {
+        result = (*ScreenPriv->spriteFuncs->RealizeCursor)(pScreen, pCursor);
+    } else if (dfb.bitsPerPixel == 8) {
+        result = DarwinRealizeCursor8(pScreen, pCursor);
+    } else if (dfb.bitsPerPixel == 16) {
+        result = DarwinRealizeCursor15(pScreen, pCursor);
+    } else {
+        result = DarwinRealizeCursor24(pScreen, pCursor);
+    }
+
+    return result;
+}
+
+
+/*
+ * DarwinUnrealizeCursor
+ * 
+ */
+static Bool
+DarwinUnrealizeCursor(
+    ScreenPtr pScreen,
+    CursorPtr pCursor)
+{
+    Bool                        result;
+    DarwinCursorScreenPtr       ScreenPriv = (DarwinCursorScreenPtr)
+        pScreen->devPrivates[darwinCursorScreenIndex].ptr;
+
+    if ((pCursor->bits->height > CURSORHEIGHT) ||
+        (pCursor->bits->width > CURSORWIDTH) ||
+        // FIXME: this condition is not needed after kernel cursor works
+        !ScreenPriv->canHWCursor) {
+        result = (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCursor);
+    } else {
+        xfree( pCursor->devPriv[pScreen->myNum] );
+        result = TRUE;
+    }
+
+    return result;
+}
+
+
+/*
+ * DarwinSetCursor
+ * Set the cursor sprite and position
+ * Use hardware cursor if possible
+ */
+static void
+DarwinSetCursor(
+    ScreenPtr       pScreen,
+    CursorPtr       pCursor,
+    int             x,
+    int             y)
+{
+    kern_return_t               kr;
+    StdFBShmem_t                *cshmem = dfb.cursorShmem;
+    DarwinCursorScreenPtr       ScreenPriv = (DarwinCursorScreenPtr)
+        pScreen->devPrivates[darwinCursorScreenIndex].ptr;
+
+    // are we supposed to remove the cursor?
+    if (!pCursor) {
+        if (ScreenPriv->cursorMode == 0)
+            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+        else {
+            if (!cshmem->cursorShow) {
+                cshmem->cursorShow++;
+                if (cshmem->hardwareCursorActive) {
+                    kr = IOFBSetCursorVisible(dfb.fbService, FALSE);
+                    kern_assert( kr );
+                }
+            }
+        }
+        return;
+    } 
+ 
+    // can we use the kernel or hardware cursor?
+    if ((pCursor->bits->height <= CURSORHEIGHT) &&
+        (pCursor->bits->width <= CURSORWIDTH) &&
+        // FIXME: condition not needed when kernel cursor works
+        ScreenPriv->canHWCursor) {
+
+        if (ScreenPriv->cursorMode == 0)    // remove the X cursor
+            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+        ScreenPriv->cursorMode = 1;         // kernel cursor
+
+        // change the cursor image in shared memory
+        if (dfb.bitsPerPixel == 8) {
+            cursorPrivPtr newCursor =
+                    (cursorPrivPtr) pCursor->devPriv[pScreen->myNum];
+            memcpy(cshmem->cursor.bw8.image[0], newCursor->image,
+                        CURSORWIDTH*CURSORHEIGHT);
+            memcpy(cshmem->cursor.bw8.mask[0], newCursor->mask,
+                        CURSORWIDTH*CURSORHEIGHT);
+        } else if (dfb.bitsPerPixel == 16) {
+            unsigned short *newCursor =
+                    (unsigned short *) pCursor->devPriv[pScreen->myNum];
+            memcpy(cshmem->cursor.rgb.image[0], newCursor,
+                        2*CURSORWIDTH*CURSORHEIGHT);
+        } else {
+            unsigned int *newCursor =
+                    (unsigned int *) pCursor->devPriv[pScreen->myNum];
+            memcpy(cshmem->cursor.rgb24.image[0], newCursor,
+                        4*CURSORWIDTH*CURSORHEIGHT);
+        }
+
+        // FIXME: We always use a full size cursor, even if the image
+        // is smaller because I couldn't get the padding to come out
+        // right otherwise.
+        cshmem->cursorSize[0].width = CURSORWIDTH;
+        cshmem->cursorSize[0].height = CURSORHEIGHT;
+        cshmem->hotSpot[0].x = pCursor->bits->xhot;
+        cshmem->hotSpot[0].y = pCursor->bits->yhot;
+
+        // try to use a hardware cursor
+        if (ScreenPriv->canHWCursor) {
+            kr = IOFBSetNewCursor(dfb.fbService, 0, 0, 0);
+            // FIXME: this is a fatal error without the kernel cursor
+            kern_assert( kr );
+#if 0
+            if (kr != KERN_SUCCESS) {
+                ErrorF("Could not set new cursor with kernel return 0x%x.\n", kr);
+                ScreenPriv->canHWCursor = FALSE;
+            }
+#endif
+        }
+
+        // make the new cursor visible
+        if (cshmem->cursorShow)
+            cshmem->cursorShow--;
+
+        if (!cshmem->cursorShow && ScreenPriv->canHWCursor) {
+            kr = IOFBSetCursorVisible(dfb.fbService, TRUE);
+            // FIXME: this is a fatal error without the kernel cursor
+            kern_assert( kr );
+#if 0
+            if (kr != KERN_SUCCESS) {
+                ErrorF("Couldn't set hardware cursor visible with kernel return 0x%x.\n", kr);
+                ScreenPriv->canHWCursor = FALSE;
+            } else
+#endif
+                ScreenPriv->cursorMode = 2;     // hardware cursor
+        }
+
+	return; 
+    }
+
+    // otherwise we use a software cursor
+    if (ScreenPriv->cursorMode) {
+	/* remove the kernel or hardware cursor */
+	DarwinSetCursor(pScreen, 0, x, y);
+    }
+
+    ScreenPriv->cursorMode = 0;
+    (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
+}
+
+
+/*
+ * DarwinMoveCursor
+ * Move the cursor. This is a noop for a kernel or hardware cursor.
+ */
+static void
+DarwinMoveCursor(
+    ScreenPtr   pScreen,
+    int         x,
+    int         y)
+{
+    DarwinCursorScreenPtr ScreenPriv = (DarwinCursorScreenPtr)
+        pScreen->devPrivates[darwinCursorScreenIndex].ptr;
+
+    // only the X cursor needs to be explicitly moved
+    if (!ScreenPriv->cursorMode)
+	(*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
+}
+
+static miPointerSpriteFuncRec darwinSpriteFuncsRec = {
+    DarwinRealizeCursor,
+    DarwinUnrealizeCursor,
+    DarwinSetCursor,
+    DarwinMoveCursor
+};
+
+
+/*
+===========================================================================
+
+ Pointer screen functions
+
+===========================================================================
+*/
+
+/*
+ * DarwinCursorOffScreen
+ */
+static Bool DarwinCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{	return FALSE;
+}
+
+
+/*
+ * DarwinCrossScreen
+ */
+static void DarwinCrossScreen(ScreenPtr pScreen, Bool entering)
+{	return;
+}
+
+
+/*
+ * DarwinWarpCursor
+ * Change the cursor position without generating an event or motion history
+ */
+static void
+DarwinWarpCursor(
+    ScreenPtr               pScreen,
+    int                     x,
+    int                     y)
+{
+    kern_return_t           kr;
+
+    kr = IOHIDSetMouseLocation( dfb.hidService, x, y );
+    if (kr != KERN_SUCCESS) {
+        ErrorF("Could not set cursor position with kernel return 0x%x.\n", kr);
+    }
+    miPointerWarpCursor(pScreen, x, y);
+}
+
+static miPointerScreenFuncRec darwinScreenFuncsRec = {
+  DarwinCursorOffScreen,
+  DarwinCrossScreen,
+  DarwinWarpCursor,
+};
+
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * DarwinCursorQueryBestSize
+ * Handle queries for best cursor size
+ */
+static void
+DarwinCursorQueryBestSize(
+   int              class, 
+   unsigned short   *width,
+   unsigned short   *height,
+   ScreenPtr        pScreen)
+{
+    DarwinCursorScreenPtr ScreenPriv = (DarwinCursorScreenPtr)
+        pScreen->devPrivates[darwinCursorScreenIndex].ptr;
+
+    if (class == CursorShape) {
+        *width = CURSORWIDTH;
+        *height = CURSORHEIGHT;
+    } else
+        (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+}
+
+
+/*
+ * DarwinInitCursor
+ * Initialize cursor support
+ */
+Bool 
+DarwinInitCursor(
+    ScreenPtr	pScreen)
+{
+    DarwinCursorScreenPtr   ScreenPriv;
+    miPointerScreenPtr	    PointPriv;
+    kern_return_t           kr;
+ 
+    // start with no cursor displayed
+    if (!dfb.cursorShmem->cursorShow++) {
+        if (dfb.cursorShmem->hardwareCursorActive) {
+            kr = IOFBSetCursorVisible(dfb.fbService, FALSE);
+            kern_assert( kr );
+        }
+    }
+
+    // initialize software cursor handling (always needed as backup)
+    if (!miDCInitialize(pScreen, &darwinScreenFuncsRec)) {
+        return FALSE;
+    }
+
+    // allocate private storage for this screen's hardware cursor info
+    if (darwinCursorGeneration != serverGeneration) {
+        if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
+            return FALSE;
+        darwinCursorGeneration = serverGeneration; 	
+    }
+
+    ScreenPriv = xcalloc( 1, sizeof(DarwinCursorScreenRec) );
+    if (!ScreenPriv) return FALSE;
+
+    pScreen->devPrivates[darwinCursorScreenIndex].ptr = (pointer) ScreenPriv;
+
+    // check if a hardware cursor is supported
+    if (!dfb.cursorShmem->hardwareCursorCapable) {
+        ScreenPriv->canHWCursor = FALSE;
+        ErrorF("Hardware cursor not supported.\n");
+    } else {
+        // we need to make sure that the hardware cursor really works
+        ScreenPriv->canHWCursor = TRUE;
+        kr = IOFBSetNewCursor(dfb.fbService, 0, 0, 0);
+        if (kr != KERN_SUCCESS) {
+            ErrorF("Could not set hardware cursor with kernel return 0x%x.\n", kr);
+            ScreenPriv->canHWCursor = FALSE;
+        }
+        kr = IOFBSetCursorVisible(dfb.fbService, TRUE);
+        if (kr != KERN_SUCCESS) {
+            ErrorF("Couldn't set hardware cursor visible with kernel return 0x%x.\n", kr);
+            ScreenPriv->canHWCursor = FALSE;
+        }
+        IOFBSetCursorVisible(dfb.fbService, FALSE);
+    }
+
+    ScreenPriv->cursorMode = 0;
+    ScreenPriv->pInstalledMap = NULL;
+
+    // override some screen procedures
+    ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
+    pScreen->QueryBestSize = DarwinCursorQueryBestSize;
+//    ScreenPriv->ConstrainCursor = pScreen->ConstrainCursor;
+//    pScreen->ConstrainCursor = DarwinConstrainCursor;
+
+    // initialize hardware cursor handling
+    PointPriv = (miPointerScreenPtr)
+                    pScreen->devPrivates[miPointerScreenIndex].ptr;
+
+    ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
+    PointPriv->spriteFuncs = &darwinSpriteFuncsRec; 
+
+    /* Other routines that might be overridden */
+/*
+    CursorLimitsProcPtr		CursorLimits;
+    RecolorCursorProcPtr	RecolorCursor;
+*/
+
+    return TRUE;
+}
Index: xc/programs/Xserver/hw/darwin/darwinKeyboard.c
diff -u /dev/null xc/programs/Xserver/hw/darwin/darwinKeyboard.c:1.1
--- /dev/null	Mon Dec 18 14:28:30 2000
+++ xc/programs/Xserver/hw/darwin/darwinKeyboard.c	Tue Nov 14 20:36:14 2000
@@ -0,0 +1,503 @@
+//=============================================================================
+//
+// Keyboard support for the Darwin X Server
+//
+// By Torrey T. Lyons
+//
+// The code to parse the Darwin keymap is derived from dumpkeymap.c
+// by Eric Sunshine, which includes the following license:
+//
+//-----------------------------------------------------------------------------
+//
+// Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+//   1. Redistributions of source code must retain the above copyright
+//      notice, this list of conditions and the following disclaimer.
+//   2. Redistributions in binary form must reproduce the above copyright
+//      notice, this list of conditions and the following disclaimer in the
+//      documentation and/or other materials provided with the distribution.
+//   3. The name of the author may not be used to endorse or promote products
+//      derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+// NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+/* $XFree86: xc/programs/Xserver/hw/darwin/darwinKeyboard.c,v 1.1 2000/11/15 01:36:14 dawes Exp $ */
+
+/*
+===========================================================================
+
+ An X keyCode must be in the range XkbMinLegalKeyCode (8) to
+ XkbMaxLegalKeyCode(255).
+
+ The keyCodes we get from the kernel range from 0 to 127, so we need to
+ offset the range before passing the keyCode to X.
+
+ An X KeySym is an extended ascii code that is device independent.
+
+ The modifier map is accessed by the keyCode, but the normal map is
+ accessed by keyCode - MIN_KEYCODE.  Sigh.
+ 
+===========================================================================
+*/
+
+// Define this to get a diagnostic output to stderr which is helpful
+// in determining how the X server is interpreting the Darwin keymap.
+#undef DUMP_DARWIN_KEYMAP
+
+#include <drivers/event_status_driver.h>
+#include <IOKit/hidsystem/ev_keymap.h>
+#include "darwin.h"
+extern DarwinFramebufferRec dfb;
+extern unsigned char darwinKeyCommandL, darwinKeyOptionL;
+
+#define XK_TECHNICAL		// needed to get XK_Escape
+#include "keysym.h"
+
+#define GLYPHS_PER_KEY  4
+#define NUM_KEYCODES    248		// NX_NUMKEYCODES might be better
+#define MAX_KEYCODE     NUM_KEYCODES + MIN_KEYCODE - 1
+
+#define AltMask	        Mod1Mask
+#define NumLockMask     Mod2Mask
+#define MetaMask        Mod3Mask
+#define ScrollLockMask  Mod4Mask
+
+static KeySym const ascii_to_x[256] = {
+	NoSymbol,	NoSymbol,	NoSymbol,	XK_KP_Enter,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	XK_Delete,	XK_Tab,		XK_Linefeed,	NoSymbol,
+	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
+	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
+	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
+	XK_comma,	XK_minus,	XK_period,	XK_slash,
+	XK_0,		XK_1,		XK_2,		XK_3,
+	XK_4,		XK_5,		XK_6,		XK_7,
+	XK_8,		XK_9,		XK_colon,	XK_semicolon,
+	XK_less,	XK_equal,	XK_greater,	XK_question,
+	XK_at,		XK_A,		XK_B,		XK_C,
+	XK_D,		XK_E,		XK_F,		XK_G,
+	XK_H,		XK_I,		XK_J,		XK_K,
+	XK_L,		XK_M,		XK_N,		XK_O,
+	XK_P,		XK_Q,		XK_R,		XK_S,
+	XK_T,		XK_U,		XK_V,		XK_W,
+	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
+	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
+	XK_grave,	XK_a,		XK_b,		XK_c,
+	XK_d,		XK_e,		XK_f,		XK_g,
+	XK_h,		XK_i,		XK_j,		XK_k,
+	XK_l,		XK_m,		XK_n,		XK_o,
+	XK_p,		XK_q,		XK_r,		XK_s,
+	XK_t,		XK_u,		XK_v,		XK_w,
+	XK_x,		XK_y,		XK_z,		XK_braceleft,
+	XK_bar,		XK_braceright,	XK_asciitilde,	XK_BackSpace,
+// 128
+	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
+	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
+	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
+	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
+	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
+	XK_odiaeresis,	XK_ograve,	XK_ntilde,	XK_ugrave,
+	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
+	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
+// 160
+	XK_aacute,	XK_degree,	XK_cent,	XK_sterling,
+	XK_ntilde,	XK_Ntilde,	XK_paragraph,	XK_Greek_BETA,
+	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
+	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+// 192
+	XK_questiondown,XK_exclamdown,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	XK_AE,		XK_ae,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+// 224
+	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
+	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
+	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
+	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
+	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
+	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
+	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
+	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
+  };
+
+#define MIN_SYMBOL		0xAC
+static KeySym const symbol_to_x[] = {
+    XK_Left,        XK_Up,          XK_Right,      XK_Down
+  };
+int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
+
+#define MIN_FUNCKEY		0x20
+static KeySym const funckey_to_x[] = {
+    XK_F1,          XK_F2,          XK_F3,          XK_F4,
+    XK_F5,          XK_F6,          XK_F7,          XK_F8,
+    XK_F9,          XK_F10,         XK_F11,         XK_F12,
+    XK_Insert,      XK_Delete,      XK_Home,        XK_End,
+    XK_Page_Up,     XK_Page_Down,   XK_F13,         XK_F14,
+    XK_F15
+  };
+int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
+
+typedef struct {
+    KeySym		normalSym;
+    KeySym		keypadSym;
+} darwinKeyPad_t;
+
+static darwinKeyPad_t const normal_to_keypad[] = {
+    { XK_0,         XK_KP_0 },
+    { XK_1,         XK_KP_1 },
+    { XK_2,         XK_KP_2 },
+    { XK_3,         XK_KP_3 },
+    { XK_4,         XK_KP_4 },
+    { XK_5,         XK_KP_5 },
+    { XK_6,         XK_KP_6 },
+    { XK_7,         XK_KP_7 },
+    { XK_8,         XK_KP_8 },
+    { XK_9,         XK_KP_9 },
+    { XK_equal,     XK_KP_Equal },
+    { XK_asterisk,  XK_KP_Multiply },
+    { XK_plus,      XK_KP_Add },
+    { XK_comma,     XK_KP_Separator },
+    { XK_minus,     XK_KP_Subtract },
+    { XK_period,    XK_KP_Decimal },
+    { XK_slash,     XK_KP_Divide }
+};
+int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
+
+static void DarwinBell( int loud, DeviceIntPtr pDevice, pointer ctrl, int fbclass) {
+    // FIXME
+}
+
+static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl ) {
+    // keyclick, bell volume / pitch, autorepead, LED's
+}
+
+static	CARD8 modMap[MAP_LENGTH];
+static	KeySym map[256 * GLYPHS_PER_KEY];
+
+//-----------------------------------------------------------------------------
+// Data Stream Object
+//	Can be configured to treat embedded "numbers" as being composed of
+//	either 1, 2, or 4 bytes, apiece.
+//-----------------------------------------------------------------------------
+typedef struct _DataStream
+{
+    unsigned char const *data;
+    unsigned char const *data_end;
+    short number_size;  // Size in bytes of a "number" in the stream.
+} DataStream;
+
+static DataStream* new_data_stream( unsigned char const* data, int size )
+{
+    DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
+    s->data = data;
+    s->data_end = data + size;
+    s->number_size = 1; // Default to byte-sized numbers.
+    return s;
+}
+
+static void destroy_data_stream( DataStream* s )
+{
+    xfree(s);
+}
+
+static unsigned char get_byte( DataStream* s )
+{
+    assert(s->data + 1 <= s->data_end);
+    return *s->data++;
+}
+
+static short get_word( DataStream* s )
+{
+    short hi, lo;
+    assert(s->data + 2 <= s->data_end);
+    hi = *s->data++;
+    lo = *s->data++;
+    return ((hi << 8) | lo);
+}
+
+static int get_dword( DataStream* s )
+{
+    int b1, b2, b3, b4;
+    assert(s->data + 4 <= s->data_end);
+    b4 = *s->data++;
+    b3 = *s->data++;
+    b2 = *s->data++;
+    b1 = *s->data++;
+    return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
+}
+
+static int get_number( DataStream* s )
+{
+    switch (s->number_size) {
+	case 4:  return get_dword(s);
+	case 2:  return get_word(s);
+	default: return get_byte(s);
+    }
+}
+
+//-----------------------------------------------------------------------------
+// Utility functions to help parse Darwin keymap
+//-----------------------------------------------------------------------------
+
+/*
+ * bits_set
+ * Calculate number of bits set in the modifier mask.
+ */
+static short bits_set( short mask )
+{
+    short n = 0;
+
+    for ( ; mask != 0; mask >>= 1)
+	if ((mask & 0x01) != 0)
+	    n++;
+    return n;
+}
+
+/*
+ * parse_next_char_code
+ * Read the next character code from the Darwin keymapping
+ * and write it to the X keymap.
+ */
+static void parse_next_char_code(
+    DataStream  *s,
+    KeySym      *k )
+{
+    const short charSet = get_number(s);
+    const short charCode = get_number(s);
+
+    if (charSet == 0) {                 // ascii character
+        if (charCode >= 0 && charCode < 256)
+            *k = ascii_to_x[charCode];
+    } else if (charSet == 0x01) {       // symbol character
+        if (charCode >= MIN_SYMBOL &&
+            charCode <= MIN_SYMBOL + NUM_SYMBOL)
+            *k = symbol_to_x[charCode - MIN_SYMBOL];
+    } else if (charSet == 0xFE) {       // function key
+        if (charCode >= MIN_FUNCKEY &&
+            charCode <= MIN_FUNCKEY + NUM_FUNCKEY)
+            *k = funckey_to_x[charCode - MIN_FUNCKEY];
+    }
+}
+
+/*
+ * DarwinKeyboardInit
+ *      Get the Darwin keyboard map and compute an equivalent
+ *      X keyboard map and modifier map. Set the new keyboard
+ *      device structure.
+ */
+void DarwinKeyboardInit(
+    DeviceIntPtr        pDev )
+{
+    KeySym              *k;
+    int                 i;
+    short		numMods, numKeys, numPadKeys = 0;
+    KeySymsRec          keySyms;
+    NXKeyMapping        keyMap;
+    DataStream		*keyMapStream;
+    unsigned char const *numPadStart = 0;
+
+    memset( modMap, NoSymbol, sizeof( modMap ) );
+    memset( map, 0, sizeof( map ) );
+
+    // Open a shared connection to the HID System.
+    // Note that the Event Status Driver is really just a wrapper
+    // for a kIOHIDParamConnectType connection.
+    assert( dfb.hidParam = NXOpenEventStatus() );
+
+    // get the Darwin keyboard map
+    keyMap.size = NXKeyMappingLength( dfb.hidParam );
+    keyMap.mapping = (char*) xalloc( keyMap.size );
+    assert( NXGetKeyMapping( dfb.hidParam, &keyMap ));
+    keyMapStream = new_data_stream( (unsigned char const*)keyMap.mapping,
+                                    keyMap.size );
+
+    // check the type of map
+    if (get_word(keyMapStream)) {
+        keyMapStream->number_size = 2;
+        ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n");
+    }
+
+    // Compute the modifier map and
+    // insert X modifier KeySyms into keyboard map.
+    numMods = get_number(keyMapStream);
+    while (numMods-- > 0) {
+        int	    	left = 1;                   // first keycode is left
+        short const     charCode = get_number(keyMapStream);
+        short           numKeyCodes = get_number(keyMapStream);
+        if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
+            numPadStart = keyMapStream->data;
+            numPadKeys = numKeyCodes;
+        }
+        while (numKeyCodes-- > 0) {
+            const short keyCode = get_number(keyMapStream);
+            if (charCode == NX_MODIFIERKEY_ALPHALOCK) {
+                modMap[keyCode + MIN_KEYCODE] = LockMask;
+                map[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock;
+            } else if (charCode == NX_MODIFIERKEY_SHIFT) {
+                modMap[keyCode + MIN_KEYCODE] = ShiftMask;
+                map[keyCode * GLYPHS_PER_KEY] =
+                        (left ? XK_Shift_L : XK_Shift_R);
+            } else if (charCode == NX_MODIFIERKEY_CONTROL) {
+                modMap[keyCode + MIN_KEYCODE] = ControlMask;
+                map[keyCode * GLYPHS_PER_KEY] =
+                        (left ? XK_Control_L : XK_Control_R);
+            } else if (charCode == NX_MODIFIERKEY_ALTERNATE) {
+                modMap[keyCode + MIN_KEYCODE] = AltMask;
+                if (left) {
+                    map[keyCode * GLYPHS_PER_KEY] = XK_Alt_L;
+                    darwinKeyOptionL = keyCode + MIN_KEYCODE;
+                } else
+                    map[keyCode * GLYPHS_PER_KEY] = XK_Alt_R;
+            } else if (charCode == NX_MODIFIERKEY_COMMAND) {
+                modMap[keyCode + MIN_KEYCODE] = MetaMask;
+                if (left) {
+                    map[keyCode * GLYPHS_PER_KEY] = XK_Meta_L;
+                    darwinKeyCommandL = keyCode + MIN_KEYCODE;
+                } else
+                    map[keyCode * GLYPHS_PER_KEY] = XK_Meta_R;
+            } else if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
+                continue;
+            } else if (charCode == NX_MODIFIERKEY_HELP) {
+                map[keyCode * GLYPHS_PER_KEY] = XK_Help;
+            } else {
+                break;
+            }
+            left = 0;
+        }
+    }
+
+    // Convert the Darwin keyboard map to an X keyboard map.
+    // A key can have shifted and unshifted character codes.
+    // Other modifiers are ignored although they are
+    // present in the Darwin keyboard map.
+    numKeys = get_number(keyMapStream);
+    for (i = 0, k = map; i < numKeys; i++, k += GLYPHS_PER_KEY) {
+        short const     charGenMask = get_number(keyMapStream);
+        if (charGenMask != 0xFF) {              // is key bound?
+            short       numKeyCodes = 1 << bits_set(charGenMask);
+
+            // If alphalock and shift modifiers produce different codes,
+            // we only need the shift case since X handles alphalock.
+            if (charGenMask & 0x01 && charGenMask & 0x02) {
+                // record unshifted case
+                parse_next_char_code( keyMapStream, k );
+                // skip alphalock case
+                get_number(keyMapStream); get_number(keyMapStream);
+                // record shifted case
+                parse_next_char_code( keyMapStream, k+1 );
+                if (k[1] == k[0]) k[1] = NoSymbol;
+                numKeyCodes -= 3;
+                // skip the rest
+                while (numKeyCodes-- > 0) {
+                    get_number(keyMapStream); get_number(keyMapStream);
+                }
+
+            // If alphalock and shift modifiers produce same code, use it.
+            } else if (charGenMask & 0x03) {
+                // record unshifted case
+                parse_next_char_code( keyMapStream, k );
+                // record shifted case
+                parse_next_char_code( keyMapStream, k+1 );
+                if (k[1] == k[0]) k[1] = NoSymbol;
+                numKeyCodes -= 2;
+                // skip the rest
+                while (numKeyCodes-- > 0) {
+                    get_number(keyMapStream); get_number(keyMapStream);
+                }
+
+            // If neither alphalock or shift produce characters,
+            // use only one character code for this key,
+            // but it can be a special character.
+            } else {
+                parse_next_char_code( keyMapStream, k );
+                numKeyCodes--;
+                while (numKeyCodes-- > 0) {     // skip the rest
+                    get_number(keyMapStream); get_number(keyMapStream);
+                
+                }
+            }
+        }
+    }
+
+    // Now we have to go back through the list of keycodes that are on the
+    // numeric keypad and update the X keymap.
+    keyMapStream->data = numPadStart;
+    while(numPadKeys-- > 0) {
+        const short keyCode = get_number(keyMapStream);
+        k = &map[keyCode * GLYPHS_PER_KEY];
+        for (i = 0; i < NUM_KEYPAD; i++) {
+            if (*k == normal_to_keypad[i].normalSym) {
+                k[0] = normal_to_keypad[i].keypadSym;
+                break;
+            }
+        }
+    }
+
+    // free Darwin keyboard map
+    destroy_data_stream( keyMapStream );
+    xfree( keyMap.mapping );
+
+#ifdef DUMP_DARWIN_KEYMAP
+    ErrorF("Darwin -> X converted keyboard map\n");
+    for (i = 0, k = map; i < NX_NUMKEYCODES; i++, k += GLYPHS_PER_KEY) {
+        int j;
+        ErrorF("0x%02x:", i);
+        for (j = 0; j < GLYPHS_PER_KEY; j++) {
+            if (k[j] == NoSymbol) {
+                ErrorF("\tNoSym");
+            } else {
+                ErrorF("\t0x%x", k[j]);
+            }
+        }
+        ErrorF("\n");
+    }
+#endif
+
+    keySyms.map        = map;
+    keySyms.mapWidth   = GLYPHS_PER_KEY;
+    keySyms.minKeyCode = MIN_KEYCODE;
+    keySyms.maxKeyCode = MAX_KEYCODE;
+
+    assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms, modMap,
+                                      DarwinBell,
+                                      DarwinChangeKeyboardControl ));
+}
+
+/*
+ * LegalModifier
+ * This allows the driver level to prevent some keys from being remapped
+ * as modifier keys.
+ * I have no idea why this is useful.
+ */
+Bool LegalModifier(unsigned int key, DevicePtr pDev)
+{
+    return 1;
+}
Index: xc/programs/Xserver/hw/darwin/utils/Imakefile
diff -u /dev/null xc/programs/Xserver/hw/darwin/utils/Imakefile:1.3
--- /dev/null	Mon Dec 18 14:28:30 2000
+++ xc/programs/Xserver/hw/darwin/utils/Imakefile	Fri Dec  1 14:47:38 2000
@@ -0,0 +1,10 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/darwin/utils/Imakefile,v 1.3 2000/12/01 19:47:38 dawes Exp $
+
+            SRCS = dumpkeymap.c
+            OBJS = dumpkeymap.o
+EXTRA_LOAD_FLAGS = -framework IOKit
+
+AllTarget(ProgramTargetName(dumpkeymap))
+
+SimpleProgramTarget(dumpkeymap)
+
Index: xc/programs/Xserver/hw/darwin/utils/README.txt
diff -u /dev/null xc/programs/Xserver/hw/darwin/utils/README.txt:1.2
--- /dev/null	Mon Dec 18 14:28:31 2000
+++ xc/programs/Xserver/hw/darwin/utils/README.txt	Tue Dec  5 16:18:34 2000
@@ -0,0 +1,111 @@
+dumpkeymap - Diagnostic dump and detailed description of .keymapping files
+Version 4
+
+Copyright (C)1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+Eric Sunshine, 1 December 2000
+
+OVERVIEW
+========
+This package contains the diagnostic utility dumpkeymap, as well as highly
+detailed documentation describing the internal layout of the Apple/NeXT
+.keymapping file.
+
+The dumpkeymap utility displays detailed information about each .keymapping
+file mentioned on the command-line.  On Apple and NeXT platforms, if no
+.keymapping files are mentioned on the command-line, then it will instead
+dissect the key mapping currently in use by the WindowServer and AppKit.
+
+Documentation includes a thorough and detailed description of the internal
+layout of the .keymapping file, as well as an explanation of how to interpret
+the output of dumpkeymap.
+
+The complete set of documentation is available for perusal via dumpkeymap's
+manual page (dumpkeymap.1), as well as via the command-line options described
+below.
+
+    --help
+	Usage summary.
+    --help-keymapping
+	Detailed discussion of the internal format of a .keymapping file.
+    --help-output
+	Explanation of dumpkeymap's output.
+    --help-files
+	List of key mapping-related files and directories.
+    --help-diagnostics
+	Explanation of diagnostic messages.
+
+Once the manual page is been installed, documentation can also be accessed
+with the Unix `man' command:
+
+    % man dumpkeymap
+
+
+COMPILATION
+===========
+MacOS/X, Darwin
+
+    cc -Wall -o dumpkeymap dumpkeymap.c -framework IOKit
+
+MacOS/X DP4 (Developer Preview 4)
+
+    cc -Wall -o dumpkeymap dumpkeymap.c -FKernel -framework IOKit
+
+MacOS/X Server, OpenStep, NextStep
+
+    cc -Wall -o dumpkeymap dumpkeymap.c
+
+By default, dumpkeymap is configured to interface with the HID driver (Apple)
+or event-status driver (NeXT), thus allowing it to dump the key mapping which
+is currently in use by the WindowServer and AppKit.  However, these facilities
+are specific to Apple/NeXT.  In order to build dumpkeymap for non-Apple/NeXT
+platforms, you must define the DUMPKEYMAP_FILE_ONLY flag when compiling the
+program.  This flag inhibits use of the HID and event-status drivers and
+configures dumpkeymap to work strictly with raw key mapping files.
+
+For example, to compile for Linux:
+
+    gcc -Wall -DDUMPKEYMAP_FILE_ONLY -o dumpkeymap dumpkeymap.c
+
+
+INSTALLATION
+============
+Install the dumpkeymap executable image in a location mentioned in the PATH
+environment variable.  Typicall locations for executable files are:
+
+    /usr/local/bin
+    $(HOME)/bin
+
+Install the manual page, dumpkeymap.1, in the `man1' subdirectory one of the
+standard manual page locations or in any other location mentioned by the
+MANPATH environment variable.
+
+Typical locations for manual pages on most Unix platforms are:
+
+    /usr/local/man/man1
+
+Typical locations for manual pages on MacOS/X, Darwin, and MacOS/X Server are:
+
+    /usr/local/man/man1
+    /Local/Documentation/ManPages/man1
+    /Network/Documentation/ManPages/man1
+
+Typical locations for manual pages on OpenStep and NextStep are:
+
+    /usr/local/man/man1
+    /LocalLibrary/Documentation/ManPages/man1
+    /LocalDeveloper/Documentation/ManPages/man1
+
+
+CONCLUSION
+==========
+This program and its accompanying documentation were written by Eric Sunshine
+and are copyright (C)1999,2000 by Eric Sunshine <sunshine@sunshineco.com>.
+
+The implementation of dumpkeymap is based upon information gathered on
+September 3, 1997 by Eric Sunshine <sunshine@sunshineco.com> and Paul S.
+McCarthy <zarnuk@zarnuk.com> during an effort to reverse engineer the format
+of the NeXT .keymapping file.
+
+
+
+$XFree86: xc/programs/Xserver/hw/darwin/utils/README.txt,v 1.2 2000/12/05 21:18:34 dawes Exp $
Index: xc/programs/Xserver/hw/darwin/utils/dumpkeymap.c
diff -u /dev/null xc/programs/Xserver/hw/darwin/utils/dumpkeymap.c:1.3
--- /dev/null	Mon Dec 18 14:28:31 2000
+++ xc/programs/Xserver/hw/darwin/utils/dumpkeymap.c	Tue Dec  5 16:18:34 2000
@@ -0,0 +1,1453 @@
+// $XFree86: xc/programs/Xserver/hw/darwin/utils/dumpkeymap.c,v 1.3 2000/12/05 21:18:34 dawes Exp $
+//=============================================================================
+//
+// Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+//   1. Redistributions of source code must retain the above copyright
+//      notice, this list of conditions and the following disclaimer.
+//   2. Redistributions in binary form must reproduce the above copyright
+//      notice, this list of conditions and the following disclaimer in the
+//      documentation and/or other materials provided with the distribution.
+//   3. The name of the author may not be used to endorse or promote products
+//      derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+// NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+//-----------------------------------------------------------------------------
+// dumpkeymap.c
+//
+//	Prints a textual representation of each Apple/NeXT .keymapping file
+//	mentioned on the command-line.  If no files are mentioned and if the
+//	local machine is an Apple or NeXT installation, then the key mapping
+//	currently in use by the WindowServer and the AppKit is printed
+//	instead.
+//
+//	Invoke dumpkeymap with one of the options listed below in order to
+//	view detailed documentation about .keymapping files and the use of
+//	this program.
+//
+//	--help: Usage summary.
+//	--help-keymapping: Detailed discussion of the internal format of a
+//	    .keymapping file.
+//	--help-output: Explanation of dumpkeymap's output.
+//	--help-files: List of key mapping-related files and directories.
+//	--help-diagnostics: Explanation of diagnostic messages.
+//
+// COMPILATION INSTRUCTIONS
+//
+//	MacOS/X, Darwin
+//	cc -Wall -o dumpkeymap dumpkeymap.c -framework IOKit
+//
+//	MacOS/X DP4 (Developer Preview 4)
+//	cc -Wall -o dumpkeymap dumpkeymap.c -FKernel -framework IOKit
+//
+//	MacOS/X Server, OpenStep, NextStep
+//	cc -Wall -o dumpkeymap dumpkeymap.c
+//
+//	By default, dumpkeymap is configured to interface with the HID driver
+//	(Apple) or event-status driver (NeXT), thus allowing it to dump the
+//	key mapping which is currently in use by the WindowServer and AppKit.
+//	However, these facilities are specific to Apple/NeXT.  In order to
+//	build dumpkeymap for non-Apple/NeXT platforms, you must define the
+//	DUMPKEYMAP_FILE_ONLY flag when compiling the program.  This flag
+//	inhibits use of the HID and event-status drivers and configures
+//	dumpkeymap to work strictly with raw key mapping files.
+//
+//	For example, to compile for Linux:
+//	gcc -Wall -DDUMPKEYMAP_FILE_ONLY -o dumpkeymap dumpkeymap.c
+//
+// CONCLUSION
+//
+//	This program and its accompanying documentation were written by Eric
+//	Sunshine and are copyright (C)1999,2000 by Eric Sunshine
+//	<sunshine@sunshineco.com>.
+//
+//	The implementation of dumpkeymap is based upon information gathered
+//	on September 3, 1997 by Eric Sunshine <sunshine@sunshineco.com> and
+//	Paul S. McCarthy <zarnuk@zarnuk.com> during an effort to reverse
+//	engineer the format of the NeXT .keymapping file.
+//
+// HISTORY
+//
+//	v4 2000/12/01 Eric Sunshine <sunshine@sunshineco.com>
+//	    Updated manual page to work with `rman', the `man' to `HTML'
+//		translator.  Unfortunately, however, rman is missing important
+//		roff features such as diversions, indentation, and tab stops,
+//		and is also hideously buggy, so getting the manual to work with
+//		rman required quite a few work-arounds.
+//	    The manual page has now been tested with nroff (plain text), troff
+//		(PostScript, etc.), groff (PostScript), and rman (HTML, etc.)
+//
+//	v3 2000/11/28 Eric Sunshine <sunshine@sunshineco.com>
+//	    Considerably expanded the documentation.
+//	    Augmented the existing description of .keymapping internals.
+//	    Added these new documentation topics:
+//		- Output: Very important section describing how to interpret
+//		  the output of dumpkeymap.
+//		- Files: Lists files and directories related to key mappings.
+//		- Diagnostics: Explains diagnostic messages issued by
+//		  dumpkeymap.
+//	    Created a manual page (dumpkeymap.1) which contains the complete
+//		set of documentation for key mapping files and dumpkeymap.
+//	    Added command-line options (--help, --help-keymapping,
+//		--help-output, --help-files, --help-diagnostics) which allow
+//		access to all key mapping documentation.  Previously the
+//		description of the internal layout of a .keymapping file was
+//		only available as source code comments.
+//	    Added --version option.
+//	    Ported to non-Apple/NeXT platforms.  Defining the pre-processor
+//		flag DUMPKEYMAP_FILE_ONLY at compilation time inhibits use of
+//		Apple/NeXT-specific API.
+//	    Added a README file.
+//
+//	v2 2000/11/13 Eric Sunshine <sunshine@sunshineco.com>
+//	    Converted from C++ to plain-C.
+//	    Now parses and takes into account the "number-size" flag stored
+//		with each key map.  This flag indicates the size, in bytes, of
+//		all remaining numeric values in the mapping.  Updated all code
+//		to respect this flag.  (Previously, the purpose of this field
+//		was unknown, and it was thus denoted as
+//		`KeyMapping::fill[2]'.)
+//	    Updated all documentation; especially the "KEY MAPPING
+//		DESCRIPTION" section.  Added discussion of the "number-size"
+//		flag and revamped all structure definitions to use the generic
+//		data type `number' instead of `uchar' or 'byte'.  Clarified
+//		several sections of the documentation and added missing
+//		discussions about type definitions and the relationship of
+//		`interface' and `handler_id' to .keymapping and .keyboard
+//		files.
+//	    Updated compilation instructions to include directions for all
+//		platforms on which this program might be built.
+//	    Now published under the formal BSD license rather than a
+//		home-grown license.
+//
+//	v1 1999/09/08 Eric Sunshine <sunshine@sunshineco.com>
+//	    Created.
+//-----------------------------------------------------------------------------
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#if !defined(DUMPKEYMAP_FILE_ONLY)
+#include <drivers/event_status_driver.h>
+#endif
+
+#define PROG_NAME "dumpkeymap"
+#define PROG_VERSION "4"
+#define AUTHOR_NAME "Eric Sunshine"
+#define AUTHOR_EMAIL "sunshine@sunshineco.com"
+#define AUTHOR_INFO AUTHOR_NAME " <" AUTHOR_EMAIL ">"
+#define COPYRIGHT "Copyright (C) 1999,2000 by " AUTHOR_INFO
+
+typedef unsigned char byte;
+typedef unsigned short word;
+typedef unsigned int natural;
+typedef unsigned long dword;
+typedef dword number;
+
+#define ASCII_SET 0x00
+#define BIND_FUNCTION 0xfe
+#define BIND_SPECIAL 0xff
+
+#define OPT_SWITCH(X) { char const* switched_str__=(X); if (0) {
+#define OPT_CASE(X,Y) } else if (strcmp(switched_str__,(#X)) == 0 || \
+    strcmp(switched_str__,(#Y)) == 0) {
+#define OPT_DEFAULT } else {
+#define OPT_SWITCH_END }}
+
+//-----------------------------------------------------------------------------
+// Translation Tables
+//-----------------------------------------------------------------------------
+static char const* const SPECIAL_CODE[] =
+    {
+    "sound-up",
+    "sound-down",
+    "brightness-up",
+    "brightness-down",
+    "alpha-lock",
+    "help",
+    "power",
+    "secondary-up-arrow",
+    "secondary-down-arrow"
+    };
+#define N_SPECIAL_CODE (sizeof(SPECIAL_CODE) / sizeof(SPECIAL_CODE[0]))
+
+static char const* const MODIFIER_CODE[] =
+    {
+    "alpha-lock",
+    "shift",
+    "control",
+    "alternate",
+    "command",
+    "keypad",
+    "help"
+    };
+#define N_MODIFIER_CODE (sizeof(MODIFIER_CODE) / sizeof(MODIFIER_CODE[0]))
+
+static char const* const MODIFIER_MASK[] =
+    {
+    "-----",	// R = carriage-return
+    "----L",	// A = alternate
+    "---S-",	// C = control
+    "---SL",	// S = shift
+    "--C--",	// L = alpha-lock
+    "--C-L",
+    "--CS-",
+    "--CSL",
+    "-A---",
+    "-A--L",
+    "-A-S-",
+    "-A-SL",
+    "-AC--",
+    "-AC-L",
+    "-ACS-",
+    "-ACSL",
+    "R----",
+    "R---L",
+    "R--S-",
+    "R--SL",
+    "R-C--",
+    "R-C-L",
+    "R-CS-",
+    "R-CSL",
+    "RA---",
+    "RA--L",
+    "RA-S-",
+    "RA-SL",
+    "RAC--",
+    "RAC-L",
+    "RACS-",
+    "RACSL",
+    };
+#define N_MODIFIER_MASK (sizeof(MODIFIER_MASK) / sizeof(MODIFIER_MASK[0]))
+
+#define FUNCTION_KEY_FIRST 0x20
+static char const* const FUNCTION_KEY[] =
+    {
+    "F1",			// 0x20
+    "F2",			// 0x21
+    "F3",			// 0x22
+    "F4",			// 0x23
+    "F5",			// 0x24
+    "F6",			// 0x25
+    "F7",			// 0x26
+    "F8",			// 0x27
+    "F9",			// 0x28
+    "F10",			// 0x29
+    "F11",			// 0x2a
+    "F12",			// 0x2b
+    "insert",			// 0x2c
+    "delete",			// 0x2d
+    "home",			// 0x2e
+    "end",			// 0x2f
+    "page up",			// 0x30
+    "page down",		// 0x31
+    "print screen",		// 0x32
+    "scroll lock",		// 0x33
+    "pause",			// 0x34
+    "sys-request",		// 0x35
+    "break",			// 0x36
+    "reset (HIL)",		// 0x37
+    "stop (HIL)",		// 0x38
+    "menu (HIL)",		// 0x39
+    "user (HIL)",		// 0x3a
+    "system (HIL)",		// 0x3b
+    "print (HIL)",		// 0x3c
+    "clear line (HIL)",		// 0x3d
+    "clear display (HIL)",	// 0x3e
+    "insert line (HIL)",	// 0x3f
+    "delete line (HIL)",	// 0x40
+    "insert char (HIL)",	// 0x41
+    "delete char (HIL)",	// 0x42
+    "prev (HIL)",		// 0x43
+    "next (HIL)",		// 0x44
+    "select (HIL)",		// 0x45
+    };
+#define N_FUNCTION_KEY (sizeof(FUNCTION_KEY) / sizeof(FUNCTION_KEY[0]))
+
+
+//-----------------------------------------------------------------------------
+// Data Stream Object
+//	Can be configured to treat embedded "numbers" as being composed of
+//	either 1, 2, or 4 bytes, apiece.
+//-----------------------------------------------------------------------------
+typedef struct _DataStream
+    {
+    byte const* data;
+    byte const* data_end;
+    natural number_size; // Size in bytes of a "number" in the stream.
+    } DataStream;
+
+static DataStream* new_data_stream( byte const* data, int size )
+    {
+    DataStream* s = (DataStream*)malloc( sizeof(DataStream) );
+    s->data = data;
+    s->data_end = data + size;
+    s->number_size = 1; // Default to byte-sized numbers.
+    return s;
+    }
+
+static void destroy_data_stream( DataStream* s )
+    {
+    free(s);
+    }
+
+static int end_of_stream( DataStream* s )
+    {
+    return (s->data >= s->data_end);
+    }
+
+static void expect_nbytes( DataStream* s, int nbytes )
+    {
+    if (s->data + nbytes > s->data_end)
+	{
+	fputs( "Insufficient data in keymapping data stream.\n", stderr );
+	exit(-1);
+	}
+    }
+
+static byte get_byte( DataStream* s )
+    {
+    expect_nbytes( s, 1 );
+    return *s->data++;
+    }
+
+static word get_word( DataStream* s )
+    {
+    word hi, lo;
+    expect_nbytes( s, 2 );
+    hi = *s->data++;
+    lo = *s->data++;
+    return ((hi << 8) | lo);
+    }
+
+static dword get_dword( DataStream* s )
+    {
+    dword b1, b2, b3, b4;
+    expect_nbytes( s, 4 );
+    b4 = *s->data++;
+    b3 = *s->data++;
+    b2 = *s->data++;
+    b1 = *s->data++;
+    return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
+    }
+
+static number get_number( DataStream* s )
+    {
+    switch (s->number_size)
+	{
+	case 4:  return get_dword(s);
+	case 2:  return get_word(s);
+	default: return get_byte(s);
+	}
+    }
+
+
+//-----------------------------------------------------------------------------
+// Translation Utility Functions
+//-----------------------------------------------------------------------------
+static char const* special_code_desc( number n )
+    {
+    if (n < N_SPECIAL_CODE)
+	return SPECIAL_CODE[n];
+    else
+	return "invalid";
+    }
+
+static char const* modifier_code_desc( number n )
+    {
+    if (n < N_MODIFIER_CODE)
+	return MODIFIER_CODE[n];
+    else
+	return "invalid";
+    }
+
+static char const* modifier_mask_desc( number n )
+    {
+    if (n < N_MODIFIER_MASK)
+	return MODIFIER_MASK[n];
+    else
+	return "?????";
+    }
+
+static char const* function_key_desc( number n )
+    {
+    if (n >= FUNCTION_KEY_FIRST && n < N_FUNCTION_KEY + FUNCTION_KEY_FIRST)
+	return FUNCTION_KEY[ n - FUNCTION_KEY_FIRST ];
+    else
+	return "unknown";
+    }
+
+static number bits_set( number mask )
+    {
+    number n = 0;
+    for ( ; mask != 0; mask >>= 1)
+	if ((mask & 0x01) != 0)
+	    n++;
+    return n;
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of Modifier records.
+//-----------------------------------------------------------------------------
+static void unparse_modifiers( DataStream* s )
+    {
+    number nmod = get_number(s); // Modifier count
+    printf( "MODIFIERS [%lu]\n", nmod );
+    while (nmod-- > 0)
+	{
+	number nscan;
+	number const code = get_number(s);
+	printf( "%s:", modifier_code_desc(code) );
+	nscan = get_number(s);
+	while (nscan-- > 0)
+	    printf( " 0x%02x", (natural)get_number(s) );
+	putchar( '\n' );
+	}
+    putchar( '\n' );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of Character records.
+//-----------------------------------------------------------------------------
+typedef void (*UnparseSpecialFunc)( number code );
+
+static void unparse_char_codes(
+    DataStream* s, number ncodes, UnparseSpecialFunc unparse_special )
+    {
+    if (ncodes != 0)
+	{
+	while (ncodes-- > 0)
+	    {
+	    number const char_set = get_number(s);
+	    number const code = get_number(s);
+	    putchar(' ');
+	    switch (char_set)
+		{
+		case ASCII_SET:
+		    {
+		    int const c = (int)code;
+		    if (isprint(c))
+			printf( "\"%c\"", c );
+		    else if (code < ' ')
+			printf( "\"^%c\"", c + '@' );
+		    else
+			printf( "%02x", c );
+		    break;
+		    }
+		case BIND_FUNCTION:
+		    printf( "[%s]", function_key_desc(code) );
+		    break;
+		case BIND_SPECIAL:
+		    unparse_special( code );
+		    break;
+		default:
+		    printf( "%02x/%02x", (natural)char_set, (natural)code );
+		    break;
+		}
+	    }
+	}
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of scan code bindings.
+//-----------------------------------------------------------------------------
+static void unparse_key_special( number code )
+    {
+    printf( "{seq#%lu}", code );
+    }
+
+static void unparse_characters( DataStream* s )
+    {
+    number const NOT_BOUND = 0xff;
+    number const nscans = get_number(s);
+    number scan;
+    printf( "CHARACTERS [%lu]\n", nscans );
+    for (scan = 0; scan < nscans; scan++)
+	{
+	number const mask = get_number(s);
+	printf( "scan 0x%02x: ", (natural)scan );
+	if (mask == NOT_BOUND)
+	    fputs( "not-bound\n", stdout );
+	else
+	    {
+	    number const bits = bits_set( mask );
+	    number const codes = 1 << bits;
+	    printf( "%s ", modifier_mask_desc(mask) );
+	    unparse_char_codes( s, codes, unparse_key_special );
+	    putchar( '\n' );
+	    }
+	}
+    putchar( '\n' );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of key sequences.
+//-----------------------------------------------------------------------------
+static void unparse_sequence_special( number code )
+    {
+    printf( "{%s}", (code == 0 ? "unmodify" : modifier_code_desc(code)) );
+    }
+
+static void unparse_sequences( DataStream* s )
+    {
+    number const nseqs = get_number(s);
+    number seq;
+    printf( "SEQUENCES [%lu]\n", nseqs );
+    for (seq = 0; seq < nseqs; seq++)
+	{
+	number const nchars = get_number(s);
+	printf( "sequence %lu:", seq );
+	unparse_char_codes( s, nchars, unparse_sequence_special );
+	putchar( '\n' );
+	}
+    putchar( '\n' );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a list of special keys.
+//-----------------------------------------------------------------------------
+static void unparse_specials( DataStream* s )
+    {
+    number nspecials = get_number(s);
+    printf( "SPECIALS [%lu]\n", nspecials );
+    while (nspecials-- > 0)
+	{
+	number const special = get_number(s);
+	number const scan = get_number(s);
+	printf( "%s: 0x%02x\n", special_code_desc(special), (natural)scan );
+	}
+    putchar( '\n' );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse the number-size flag.
+//-----------------------------------------------------------------------------
+static void unparse_numeric_size( DataStream* s )
+    {
+    word const numbers_are_shorts = get_word(s);
+    s->number_size = numbers_are_shorts ? 2 : 1;
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse an entire key map.
+//-----------------------------------------------------------------------------
+static void unparse_keymap_data( DataStream* s )
+    {
+    unparse_numeric_size(s);
+    unparse_modifiers(s);
+    unparse_characters(s);
+    unparse_sequences(s);
+    unparse_specials(s);
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse the active key map.
+//-----------------------------------------------------------------------------
+#if !defined(DUMPKEYMAP_FILE_ONLY)
+static int unparse_active_keymap( void )
+    {
+    int rc = 1;
+    NXEventHandle const h = NXOpenEventStatus();
+    if (h == 0)
+	fputs( "Unable to open event status driver.\n", stderr );
+    else
+	{
+	NXKeyMapping km;
+	km.size = NXKeyMappingLength(h);
+	if (km.size <= 0)
+	    fprintf( stderr, "Bad key mapping length (%d).\n", km.size );
+	else
+	    {
+	    km.mapping = (char*)malloc( km.size );
+	    if (NXGetKeyMapping( h, &km ) == 0)
+		fputs( "Unable to get current key mapping.\n", stderr );
+	    else
+		{
+		DataStream* stream =
+		    new_data_stream( (byte const*)km.mapping, km.size );
+		fputs( "=============\nACTIVE KEYMAP\n=============\n\n",
+		    stdout);
+		unparse_keymap_data( stream );
+		destroy_data_stream( stream );
+		rc = 0;
+		}
+	    free( km.mapping );
+	    }
+	NXCloseEventStatus(h);
+	}
+    return rc;
+    }
+#endif
+
+
+//-----------------------------------------------------------------------------
+// Unparse one key map from a keymapping file.
+//-----------------------------------------------------------------------------
+static void unparse_keymap( DataStream* s )
+    {
+    dword const interface = get_dword(s);
+    dword const handler_id = get_dword(s);
+    dword const map_size = get_dword(s);
+    printf( "interface: 0x%02lx\nhandler_id: 0x%02lx\nmap_size: %lu bytes\n\n",
+	interface, handler_id, map_size );
+    unparse_keymap_data(s);
+    }
+
+
+//-----------------------------------------------------------------------------
+// Check the magic number of a keymapping file.
+//-----------------------------------------------------------------------------
+static int check_magic_number( DataStream* s )
+    {
+    return (get_byte(s) == 'K' &&
+	    get_byte(s) == 'Y' &&
+	    get_byte(s) == 'M' &&
+	    get_byte(s) == '1');
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse all key maps within a keymapping file.
+//-----------------------------------------------------------------------------
+static int unparse_keymaps( DataStream* s )
+    {
+    int rc = 0;
+    if (check_magic_number(s))
+	{
+	int n = 1;
+	while (!end_of_stream(s))
+	    {
+	    printf( "---------\nKEYMAP #%d\n---------\n", n++ );
+	    unparse_keymap(s);
+	    }
+	}
+    else
+	{
+	fputs( "Bad magic number.\n", stderr );
+	rc = 1;
+	}
+    return rc;
+    }
+
+
+//-----------------------------------------------------------------------------
+// Unparse a keymapping file.
+//-----------------------------------------------------------------------------
+static int unparse_keymap_file( char const* const path )
+    {
+    int rc = 1;
+    FILE* file;
+    printf( "===========\nKEYMAP FILE\n===========\n%s\n\n", path );
+    file = fopen( path, "rb" );
+    if (file == 0)
+	perror( "Unable to open key mapping file" );
+    else
+	{
+	struct stat st;
+	if (fstat( fileno(file), &st ) != 0)
+	    perror( "Unable to determine key mapping file size" );
+	else
+	    {
+	    byte* buffer = (byte*)malloc( st.st_size );
+	    if (fread( buffer, st.st_size, 1, file ) != 1)
+		perror( "Unable to read key mapping file" );
+	    else
+		{
+		DataStream* stream = new_data_stream(buffer, (int)st.st_size);
+		fclose( file ); file = 0;
+		rc = unparse_keymaps( stream );
+		destroy_data_stream( stream );
+		}
+	    free( buffer );
+	    }
+	if (file != 0)
+	    fclose( file );
+	}
+    return rc;
+    }
+
+
+//-----------------------------------------------------------------------------
+// Handle the case when no documents are mentioned on the command-line.  For
+// Apple/NeXT platforms, dump the currently active key mapping; else display
+// an error message.
+//-----------------------------------------------------------------------------
+static int handle_empty_document_list( void )
+    {
+#if !defined(DUMPKEYMAP_FILE_ONLY)
+    return unparse_active_keymap();
+#else
+    fputs( "ERROR: Must specify at least one .keymapping file.\n\n", stderr );
+    return 1;
+#endif
+    }
+
+
+//-----------------------------------------------------------------------------
+// Print a detailed description of the internal layout of a key mapping.
+//-----------------------------------------------------------------------------
+static void print_internal_layout_info( FILE* f )
+    {
+    fputs(
+"What follows is a detailed descriptions of the internal layout of an\n"
+"Apple/NeXT .keymapping file.\n"
+"\n"
+"Types and Data\n"
+"--------------\n"
+"The following type definitions are employed throughout this discussion:\n"
+"\n"
+"    typedef unsigned char  byte;\n"
+"    typedef unsigned short word;\n"
+"    typedef unsigned long  dword;\n"
+"\n"
+"Additionally, the type definition `number' is used generically to indicate\n"
+"a numeric value.  The actual size of the `number' type may be one or two\n"
+"bytes depending upon how the data is stored in the key map.  Although most\n"
+"key maps use byte-sized numeric values, word-sized values are also allowed.\n"
+"\n"
+"Multi-byte values in a key mapping file are stored in big-endian byte\n"
+"order.\n"
+"\n"
+"Key Mapping File and Device Mapping\n"
+"-----------------------------------\n"
+"A key mapping file begins with a magic-number and continues with a variable\n"
+"number of device-specific key mappings.\n"
+"\n"
+"    struct KeyMappingFile {\n"
+"        char magic_number[4];    // `KYM1'\n"
+"        DeviceMapping maps[...]; // Variable number of maps\n"
+"    };\n"
+"\n"
+"    struct DeviceMapping {\n"
+"        dword interface;  // Interface type\n"
+"        dword handler_id; // Interface subtype\n"
+"        dword map_size;   // Byte count of `map' (below)\n"
+"        KeyMapping map;\n"
+"    };\n"
+"\n"
+"The value of `interface' represents a family of keyboard device types\n"
+"(such as Intel PC, ADB, NeXT, Sun Type5, etc.), and is generally\n"
+"specified as one of the constant values NX_EVS_DEVICE_INTERFACE_ADB,\n"
+"NX_EVS_DEVICE_INTERFACE_ACE, etc., which are are defined in IOHIDTypes.h on\n"
+"MacOS/X and Darwin, and in ev_types.h on MacOS/X Server, OpenStep, and\n"
+"NextStep.\n"
+"\n"
+"The value of `handler_id' represents a specific keyboard layout within the\n"
+"much broader `interface' family.  For instance, for a 101-key Intel PC\n"
+"keyboard (of type NX_EVS_DEVICE_INTERFACE_ACE) the `handler_id' is '0',\n"
+"whereas for a 102-key keyboard it is `1'.\n"
+"\n"
+"Together, `interface' and `handler_id' identify the exact keyboard hardware\n"
+"to which this mapping applies.  Programs which display a visual\n"
+"representation of a keyboard layout, match `interface' and `handler_id'\n"
+"from the .keymapping file against the `interface' and `handler_id' values\n"
+"found in each .keyboard file.\n"
+"\n"
+"Key Mapping\n"
+"-----------\n"
+"A key mapping completely defines the relationship of all scan codes with\n"
+"their associated functionality.  A KeyMapping structure is embedded within\n"
+"the DeviceMapping structure in a KeyMappingFile.  The key mapping currently\n"
+"in use by the WindowServer and AppKit is also represented by a KeyMapping\n"
+"structure, and can be referred to directly by calling NXGetKeyMapping() and\n"
+"accessing the `mapping' data member of the returned NXKeyMapping structure.\n"
+"\n"
+"    struct KeyMapping {\n"
+"        word number_size;                   // 0=1 byte, non-zero=2 bytes\n"
+"        number num_modifier_groups;         // Modifier groups\n"
+"        ModifierGroup modifier_groups[...];\n"
+"        number num_scan_codes;              // Scan groups\n"
+"        ScanGroup scan_table[...];\n"
+"        number num_sequence_lists;          // Sequence lists\n"
+"        Sequence sequence_lists[...];\n"
+"        number num_special_keys;            // Special keys\n"
+"        SpecialKey special_key[...];\n"
+"    };\n"
+"\n"
+"The `number_size' flag determines the size, in bytes, of all remaining\n"
+"numeric values (denoted by the type definition `number') within the key\n"
+"mapping.  If its value is zero, then numbers are represented by a single\n"
+"byte.  If it is non-zero, then numbers are represented by a word (two\n"
+"bytes).\n"
+"\n"
+"Modifier Group\n"
+"--------------\n"
+"A modifier group defines all scan codes which map to a particular type of\n"
+"modifier, such as `shift', `control', etc.\n"
+"\n"
+"    enum Modifier {\n"
+"        ALPHALOCK = 0,\n"
+"        SHIFT,\n"
+"        CONTROL,\n"
+"        ALTERNATE,\n"
+"        COMMAND,\n"
+"        KEYPAD,\n"
+"        HELP\n"
+"    };\n"
+"\n"
+"    struct ModifierGroup {\n"
+"        number modifier;        // A Modifier constant\n"
+"        number num_scan_codes;\n"
+"        number scan_codes[...]; // Variable number of scan codes\n"
+"    };\n"
+"\n"
+"The scan_codes[] array contains a list of all scan codes which map to the\n"
+"specified modifier.  The `shift', `command', and `alternate' modifiers are\n"
+"frequently mapped to two different scan codes, apiece, since these\n"
+"modifiers often appear on both the left and right sides of the keyboard.\n"
+"\n"
+"Scan Group\n"
+"----------\n"
+"There is one ScanGroup for each scan code generated by the given keyboard.\n"
+"This number is given by KeyMapping::num_scan_codes.  The first scan group\n"
+"represents hardware scan code 0, the second represents scan code 1, etc.\n"
+"\n"
+"    enum ModifierMask {\n"
+"        ALPHALOCK_MASK       = 1 << 0,\n"
+"        SHIFT_MASK           = 1 << 1,\n"
+"        CONTROL_MASK         = 1 << 2,\n"
+"        ALTERNATE_MASK       = 1 << 3,\n"
+"        CARRIAGE_RETURN_MASK = 1 << 4\n"
+"    };\n"
+"    #define NOT_BOUND 0xff\n"
+"\n"
+"    struct ScanGroup {\n"
+"        number mask;\n"
+"        Character characters[...];\n"
+"    };\n"
+"\n"
+"For each scan code, `mask' defines which modifier combinations generate\n"
+"characters.  If `mask' is NOT_BOUND (0xff) then then this scan code does\n"
+"not generate any characters ever, and its characters[] array is zero\n"
+"length.  Otherwise, the characters[] array contains one Character record\n"
+"for each modifier combination.\n"
+"\n"
+"The number of records in characters[] is determined by computing (1 <<\n"
+"bits_set_in_mask).  In other words, if mask is zero, then zero bits are\n"
+"set, so characters[] contains only one record.  If `mask' is (SHIFT_MASK |\n"
+"CONTROL_MASK), then two bits are set, so characters[] contains four\n"
+"records.\n"
+"\n"
+"The first record always represents the character which is generated by that\n"
+"key when no modifiers are active.  The remaining records represent\n"
+"characters generated by the various modifier combinations.  Using the\n"
+"example with the `shift' and `control' masks set, record two would\n"
+"represent the character with the `shift' modifier active; record three, the\n"
+"`control' modifier active; and record four, both the `shift' and `control'\n"
+"modifiers active.\n"
+"\n"
+"As a special case, ALPHALOCK_MASK implies SHIFT_MASK, though only\n"
+"ALPHALOCK_MASK appears in `mask'.  In this case the same character is\n"
+"generated for both the `shift' and `alpha-lock' modifiers, but only needs\n"
+"to appear once in the characters[] array.\n"
+"\n"
+"CARRIAGE_RETURN_MASK does not actually refer to a modifier key.  Instead,\n"
+"it is used to distinguish the scan code which is given the special\n"
+"pseudo-designation of `carriage return' key.  Typically, this mask appears\n"
+"solo in a ScanGroup record and only the two Character records for control-M\n"
+"and control-C follow.  This flag may be a throwback to an earlier time or\n"
+"may be specially interpreted by the low-level keyboard driver, but its\n"
+"purpose is otherwise enigmatic.\n"
+"Character\n"
+"---------\n"
+"Each Character record indicates the character generated when this key is\n"
+"pressed, as well as the character set which contains the character.  Well\n"
+"known character sets are `ASCII' and `Symbol'.  The character set can also\n"
+"be one of the meta values FUNCTION_KEY or KEY_SEQUENCE.  If it is\n"
+"FUNCTION_KEY then `char_code' represents a generally well-known function\n"
+"key such as those enumerated by FunctionKey.  If the character set is\n"
+"KEY_SEQUENCE then `char_code' represents a zero-base index into\n"
+"KeyMapping::sequence_lists[].\n"
+"\n"
+"    enum CharacterSet {\n"
+"        ASCII        = 0x00,\n"
+"        SYMBOL       = 0x01,\n"
+"        ...\n"
+"        FUNCTION_KEY = 0xfe,\n"
+"        KEY_SEQUENCE = 0xff\n"
+"    };\n"
+"\n"
+"    struct Character {\n"
+"        number set;       // CharacterSet of generated character\n"
+"        number char_code; // Actual character generated\n"
+"    };\n"
+"\n"
+"    enum FunctionKey {\n"
+"        F1 = 0x20, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,\n"
+"        INSERT, DELETE, HOME, END, PAGE_UP, PAGE_DOWN, PRINT_SCREEN,\n"
+"        SCROLL_LOCK, PAUSE, SYS_REQUEST, BREAK, RESET, STOP, MENU, USER,\n"
+"        SYSTEM, PRINT, CLEAR_LINE, CLEAR_DISPLAY, INSERT_LINE,\n"
+"        DELETE_LINE, INSERT_CHAR, DELETE_CHAR, PREV, NEXT, SELECT\n"
+"    };\n"
+"\n"
+"Sequence\n"
+"--------\n"
+"When Character::set contains the meta value KEY_SEQUENCE, the scan code is\n"
+"bound to a sequence of keys rather than a single character.  A sequence is\n"
+"a series of modifiers and characters which are automatically generated when\n"
+"the associated key is depressed.\n"
+"\n"
+"    #define MODIFIER_KEY 0xff\n"
+"\n"
+"    struct Sequence {\n"
+"        number num_chars;\n"
+"        Character characters[...];\n"
+"    };\n"
+"\n"
+"Each generated Character is represented as previously described, with the\n"
+"exception that MODIFIER_KEY may appear in place of KEY_SEQUENCE.  When the\n"
+"value of Character::set is MODIFIER_KEY then Character::char_code\n"
+"represents a modifier key rather than an actual character.  If the modifier\n"
+"represented by `char_code' is non-zero, then it indicates that the\n"
+"associated modifier key has been depressed.  In this case, the value is one\n"
+"of the constants enumerated by Modifier (SHIFT, CONTROL, ALTERNATE, etc.).\n"
+"If the value is zero then it means that the modifier keys have been\n"
+"released.\n"
+"\n"
+"Special Key\n"
+"-----------\n"
+"A special key is one which is scanned directly by the Mach kernel rather\n"
+"than by the WindowServer.  In general, events are not generated for special\n"
+"keys.\n"
+"\n"
+"    enum SpecialKeyType {\n"
+"        VOLUME_UP = 0,\n"
+"        VOLUME_DOWN,\n"
+"        BRIGHTNESS_UP,\n"
+"        BRIGHTNESS_DOWN,\n"
+"        ALPHA_LOCK,\n"
+"        HELP,\n"
+"        POWER,\n"
+"        SECONDARY_ARROW_UP,\n"
+"        SECONDARY_ARROW_DOWN\n"
+"    };\n"
+"\n"
+"    struct SpecialKey {\n"
+"        number type;      // A SpecialKeyType constant\n"
+"        number scan_code; // Actual scan code\n"
+"    };\n"
+"\n", f );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Print an explanation of the output generated by this program.
+//-----------------------------------------------------------------------------
+static void print_output_info( FILE* f )
+    {
+    fputs(
+"What follows is an explanation and description of the various pieces of\n"
+"information emitted by dumpkeymap.\n"
+"\n"
+"For a more thorough discussion of any particular piece of information\n"
+"described here, refer to the detailed description of the internal layout of\n"
+"a key mapping given by the --help-layout option.\n"
+"\n"
+"Conventions\n"
+"-----------\n"
+"Depending upon context, some numeric values are displayed in decimal\n"
+"notation, whereas others are displayed in hexadecimal notation.\n"
+"Hexadecimal numbers are denoted by a `0x' prefix (for instance, `0x7b'),\n"
+"except when explicitly noted otherwise.\n"
+"\n"
+"Key Mapping Source\n"
+"------------------\n"
+"The first piece of information presented about a particular key mapping is\n"
+"the source from which the data was gleaned.  For a .keymapping file, the\n"
+"title `KEYMAP FILE' is emitted along with the path and name of the file in\n"
+"question.  For the key mapping currently in use by the WindowServer and\n"
+"AppKit, the title `ACTIVE KEYMAP' is emitted instead.\n"
+"\n"
+"Device Information\n"
+"------------------\n"
+"Each .keymapping file may contain one or more raw key mappings.  For\n"
+"example, a file which maps keys to a Dvorak-style layout might contain raw\n"
+"mappings for Intel PC, ADB, NeXT, and Sun Type5 keyboards.\n"
+"\n"
+"For each raw mapping, the following information is emitted:\n"
+"\n"
+"    o The title `KEYMAP' along with the mapping's relative position in the\n"
+"      .keymapping file.\n"
+"    o The `interface' identifier.\n"
+"    o The `handler_id' sub-identifier.\n"
+"    o The size of the raw mapping resource counted in bytes.\n"
+"\n"
+"The `interface' and `handler_id' values, taken together, define a specific\n"
+"keyboard device.  A .keyboard file, which describes the visual layout of a\n"
+"keyboard, also contains `interface' and `handler_id' identifiers.  The\n"
+".keyboard file corresponding to a particular key mapping can be found by\n"
+"matching the `interface' and `handler_id' values from each resource.\n"
+"\n"
+"Modifiers\n"
+"---------\n"
+"Each mapping may contain zero or more modifier records which associate\n"
+"hardware scan codes with modifier descriptions such as `shift', `control',\n"
+"`alternate', etc.  The title `MODIFIERS' is printed along with the count of\n"
+"modifier records which follow.  For each modifier record, the modifier's\n"
+"name is printed along with a list of scan codes, in hexadecimal format,\n"
+"which generate that modifier value.  For example:\n"
+"\n"
+"    MODIFIERS [4]\n"
+"    alternate: 0x1d 0x60\n"
+"    control: 0x3a\n"
+"    keypad: 0x52 0x53 ... 0x63 0x62\n"
+"    shift: 0x2a 0x36\n"
+"\n"
+"Characters\n"
+"----------\n"
+"Each mapping may contain zero or more character records which associate\n"
+"hardware scan codes with the actual characters generated by those scan\n"
+"codes in the presence or absence of various modifier combinations.  The\n"
+"title `CHARACTERS' is printed along with the count of character records\n"
+"which follow.  Here is a highly abbreviated example:\n"
+"\n"
+"    CHARACTERS [9]\n"
+"    scan 0x00: -AC-L  \"a\" \"A\" \"^A\" \"^A\" ca c7 \"^A\" \"^A\"\n"
+"    scan 0x07: -AC-L  \"x\" \"X\" \"^X\" \"^X\" 01/b4 01/ce \"^X\" \"^X\"\n"
+"    scan 0x0a: ---S-  \"<\" \">\"\n"
+"    scan 0x13: -ACS-  \"2\" \"@\" \"^@\" \"^@\" b2 b3 \"^@\" \"^@\"\n"
+"    scan 0x24: R----  \"^M\" \"^C\"\n"
+"    scan 0x3e: -----  [F4]\n"
+"    scan 0x4a: -----  [page up]\n"
+"    scan 0x60: -----  {seq#3}\n"
+"    scan 0x68: not-bound\n"
+"\n"
+"For each record, the hexadecimal value of the hardware scan code is\n"
+"printed, followed by a list of modifier flag combinations and the actual\n"
+"characters generated by this scan code with and without modifiers applied.\n"
+"\n"
+"The modifier flags field is composed of a combination of single letter\n"
+"representations of the various modifier types.  The letters stand for:\n"
+"\n"
+"    L - alpha-lock\n"
+"    S - shift\n"
+"    C - control\n"
+"    A - alternate\n"
+"    R - carriage-return\n"
+"\n"
+"As a special case, the `alpha-lock' flag also implies the `shift' flag, so\n"
+"these two flags never appear together in the same record.\n"
+"\n"
+"The combination of modifier flags determines the meaning and number of\n"
+"fields which follow.  The first field after the modifier flags always\n"
+"represents the character that will be generated if no modifier keys are\n"
+"depressed.  The remaining fields represent characters generated by the\n"
+"various modifier combinations.  The order of the fields follows this\n"
+"general pattern:\n"
+"\n"
+"    o The character generated by this scan code when no modifiers are in\n"
+"      effect is listed first.\n"
+"\n"
+"    o If the `L' or `S' flag is active, then the shifted character\n"
+"      generated by this scan code is listed next.\n"
+"\n"
+"    o If the `C' flag is active, then the control-character generated by\n"
+"      this scan code is listed next.  Furthermore, if the `L' or `S' flag\n"
+"      is also active, then the shifted control-character is listed after\n"
+"      that.\n"
+"\n"
+"    o If the `A' flag is active, then the alternate-character generated by\n"
+"      this scan code is listed next.  Furthermore, if the `L' or `S' flag\n"
+"      is active, then the shifted alternate-character is listed after that.\n"
+"      If the `C' flag is also active, then the alternate-control-character\n"
+"      is listed next.  Finally, if the `C' and `L' or `C' and `S' flags are\n"
+"      also active, then the shifted alternate-control-character is listed.\n"
+"\n"
+"The `R' flag does not actually refer to a modifier key.  Instead, it is\n"
+"used to distinguish the scan code which is given the special\n"
+"pseudo-designation of `carriage return' key.  Typically, this mask appears\n"
+"solo and only the two fields for control-M and control-C follow.  This flag\n"
+"may be a throwback to an earlier time or may be specially interpreted by\n"
+"the low-level keyboard driver, but its purpose is otherwise enigmatic.\n"
+"\n"
+"Recalling the example from above, the following fields can be identified:\n"
+"\n"
+"    scan 0x00: -AC-L  \"a\" \"A\" \"^A\" \"^A\" ca c7 \"^A\" \"^A\"\n"
+"\n"
+"    o Lower-case `a' is generated when no modifiers are active.\n"
+"    o Upper-case `A' is generated when `shift' or `alpha-lock' are active.\n"
+"    o Control-A is generated when `control' is active.\n"
+"    o Control-A is generated when `control' and `shift' are active.\n"
+"    o The character represented by the hexadecimal code 0xca is generated\n"
+"      when `alternate' is active.\n"
+"    o The character represented by 0xc7 is generated when `alternate' and\n"
+"      `shift' (or `alpha-lock') are active.\n"
+"    o Control-A is generated when `alternate' and `control' are active.\n"
+"    o Control-A is generated when `alternate', `control' and `shift' (or\n"
+"      `alpha-lock') are active.\n"
+"\n"
+"The notation used to represent a particular generated character varies.\n"
+"\n"
+"    o Printable ASCII characters are quoted, as in \"x\" or \"X\".\n"
+"\n"
+"    o Control-characters are quoted and prefixed with `^', as in \"^X\".\n"
+"\n"
+"    o Characters with values greater than 127 (0x7f) are displayed as\n"
+"      hexadecimal values without the `0x' prefix.\n"
+"\n"
+"    o Characters in a non-ASCII character set (such as `Symbol') are\n"
+"      displayed as two hexadecimal numbers separated by a slash, as in\n"
+"      `01/4a'.  The first number is the character set's identification code\n"
+"      (such as `01' for the `Symbol' set), and the second number is the\n"
+"      value of the generated character.\n"
+"\n"
+"    o Non-printing special function characters are displayed with the\n"
+"      function's common name enclosed in brackets, as in `[page up]' or\n"
+"      `[F4]'.\n"
+"\n"
+"    o If the binding represents a key sequence rather than a single\n"
+"      character, then the sequence's identification number is enclosed in\n"
+"      braces, as in `{seq#3}'.\n"
+"\n"
+"Recalling a few examples from above, the following interpretations can be\n"
+"made:\n"
+"\n"
+"    scan 0x07: -AC-L  \"x\" \"X\" \"^X\" \"^X\" 01/b4 01/ce \"^X\" \"^X\"\n"
+"    scan 0x3e: -----  [F4]\n"
+"    scan 0x4a: -----  [page up]\n"
+"    scan 0x60: -----  {seq#3}\n"
+"\n"
+"    o \"x\" and \"X\" are printable ASCII characters.\n"
+"    o \"^X\" is a control-character.\n"
+"    o `01/b4' and `01/ce' represent the character codes 0xb4 and 0xce in\n"
+"      the `Symbol' character set.\n"
+"    o Scan code 0x3e generates function-key `F4', and scan code 0x4a\n"
+"      generates function-key `page up'.\n"
+"    o Scan code 0x60 is bound to key sequence #3.\n"
+"\n"
+"Finally, if a scan code is not bound to any characters, then it is\n"
+"annotated with the label `not-bound', as with example scan code 0x68 from\n"
+"above.\n"
+"\n"
+"Sequences\n"
+"---------\n"
+"A scan code (modified and unmodified) can be bound to a key sequence rather\n"
+"than generating a single character or acting as a modifier.  When it is\n"
+"bound to a key sequence, a series of character invocations and modifier\n"
+"actions are automatically generated rather than a single keystroke.\n"
+"\n"
+"Each mapping may contain zero or more key sequence records.  The title\n"
+"`SEQUENCES' is printed along with the count of sequence records which\n"
+"follow.  For example:\n"
+"\n"
+"    SEQUENCES [3]\n"
+"    sequence 0: \"f\" \"o\" \"o\"\n"
+"    sequence 1: {alternate} \"b\" \"a\" \"r\" {unmodify}\n"
+"    sequence 2: [home] \"b\" \"a\" \"z\"\n"
+"\n"
+"The notation used to represent the sequence of generated characters is\n"
+"identical to the notation already described in the `Characters' section\n"
+"above, with the exception that modifier actions may be interposed between\n"
+"generated characters.  Such modifier actions are represented by the\n"
+"modifier's name enclosed in braces.  The special name `{unmodify}'\n"
+"indicates the release of the modifier keys.\n"
+"\n"
+"Thus, the sequences in the above example can be interpreted as follows:\n"
+"\n"
+"    o Sequence #0 generates `foo'.\n"
+"    o Sequence #1 invokes the `alternate' modifier, generates `bar', and\n"
+"      then releases `alternate'.\n"
+"    o Sequence #2 invokes the `home' key and then generates `baz'.  In a\n"
+"      text editor, this would probably result in `baz' being prepended to\n"
+"      the line of text on which the cursor resides.\n"
+"\n"
+"Special Keys\n"
+"------------\n"
+"Certain keyboards feature keys which perform some type of special purpose\n"
+"function rather than generating a character or acting as a modifier.  For\n"
+"instance, Apple keyboards often contain a `power' key, and NeXT keyboards\n"
+"have historically featured screen brightness and volume control keys.\n"
+"\n"
+"Each mapping may contain zero or more special-key records which associate\n"
+"hardware scan codes with such special purpose functions.  The title\n"
+"`SPECIALS' is printed along with the count of records which follow.  For\n"
+"each record, the special function's name is printed along with a list of\n"
+"scan codes, in hexadecimal format, which are bound to that function.  For\n"
+"example:\n"
+"\n"
+"    SPECIALS [6]\n"
+"    alpha-lock: 0x39\n"
+"    brightness-down: 0x79\n"
+"    brightness-up: 0x74\n"
+"    power: 0x7f\n"
+"    sound-down: 0x77\n"
+"    sound-up: 0x73\n"
+"\n", f );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Print a summary of the various files and directories which are related to
+// key mappings.
+//-----------------------------------------------------------------------------
+static void print_files_info( FILE* f )
+    {
+    fputs(
+"This is a summary of the various files and directories which are related to\n"
+"key mappings.\n"
+"\n"
+"*.keymapping\n"
+"    A key mapping file which precisely defines the relationship of all\n"
+"    hardware-specific keyboard scan-codes with their associated\n"
+"    functionality.\n"
+"\n"
+"*.keyboard\n"
+"    A file describing the physical layout of keys on a particular type of\n"
+"    keyboard.  Each `key' token in this file defines the position and shape\n"
+"    of the key on the keyboard, as well as the associated scan code which\n"
+"    that key generates.  A .keymapping file, on the other hand, defines the\n"
+"    characters which are generated by a particular scan code depending upon\n"
+"    the state of the various modifier keys (such as shift, control, etc.).\n"
+"    The `interface' and `handler_id' values from a .keymapping file are\n"
+"    matched against those in each .keyboard file in order to associate a\n"
+"    particular .keyboard file with a key mapping.  Various GUI programs use\n"
+"    the .keyboard file to display a visual representation of a keyboard for\n"
+"    the user.  Since these files are just plain text, they can be easily\n"
+"    viewed and interpreted without the aid of a specialized program, thus\n"
+"    dumpkeymap leaves these files alone.\n"
+"\n"
+"/System/Library/Keyboards\n"
+"/Network/Library/Keyboards\n"
+"/Local/Library/Keyboards\n"
+"/Library/Keyboards\n"
+"    Repositories for .keymapping and .keyboard files for MacOS/X, Darwin,\n"
+"    and MacOS/X Server.\n"
+"\n"
+"/NextLibrary/Keyboards\n"
+"/LocalLibrary/Keyboards\n"
+"    Repositories for .keymapping and .keyboard files for OpenStep and\n"
+"    NextStep.\n"
+"\n"
+"$(HOME)/Library/Keyboards\n"
+"    Repository for personal .keymapping and .keyboard files.\n"
+"\n", f );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Print a list of the various diagnostic messages which may be emitted.
+//-----------------------------------------------------------------------------
+static void print_diagnostics_info( FILE* f )
+    {
+    fputs(
+"The following diagnostic messages may be issued to the standard error\n"
+"stream.\n"
+"\n"
+"Unrecognized option.\n"
+"    An unrecognized option was specified on the command-line.  Invoke\n"
+"    dumpkeymap with the --help option to view a list of valid options.\n"
+"\n"
+"Insufficient data in keymapping data stream.\n"
+"    The key mapping file or data stream is corrupt.  Either the file has\n"
+"    been incorrectly truncated or a field, such as those which indicates\n"
+"    the number of variable records which follow, contains a corrupt value.\n"
+"\n"
+"The following diagnostic messages have significance only when trying to\n"
+"print .keymapping files mentioned on the command-line.\n"
+"\n"
+"Bad magic number.\n"
+"    The mentioned file is not a .keymapping file.  The file's content does\n"
+"    not start with the string `KYM1'.\n"
+"\n"
+"Unable to open key mapping file.\n"
+"    The call to fopen() failed; probably because the specified path is\n"
+"    invalid or dumpkeymap does not have permission to read the file.\n"
+"\n"
+"Unable to determine key mapping file size.\n"
+"    The call to fstat() failed, thus memory can not be allocated for\n"
+"    loading the file.\n"
+"\n"
+"Unable to read key mapping file.\n"
+"    The call to fread() failed.\n"
+"\n"
+"The following diagnostic messages have significance only when trying to\n"
+"print the currently active key mapping when no .keymapping files have been\n"
+"mentioned on the command-line.\n"
+"\n"
+"Unable to open event status driver.\n"
+"    The call to NXOpenEventStatus() failed.\n"
+"\n"
+"Bad key mapping length.\n"
+"    The call to NXKeyMappingLength() returned a bogus value.\n"
+"\n"
+"Unable to get current key mapping.\n"
+"    The call to NXGetKeyMapping() failed.\n"
+"\n"
+"The following diagnostic messages have significance only when using\n"
+"dumpkeymap on a non-Apple/NeXT platform.\n"
+"\n"
+"Must specify at least one .keymapping file.\n"
+"    No .keymapping files were mentioned on the command-line.  On\n"
+"    non-Apple/NeXT platforms, there is no concept of a currently active\n"
+"    .keymapping file, so at least one file must be mentioned on the\n"
+"    command-line.\n"
+"\n", f );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Print warranty.
+//-----------------------------------------------------------------------------
+static void print_warranty( FILE* f )
+    {
+    fputs(
+"This software is provided by the author `AS IS' and any express or implied\n"
+"WARRANTIES, including, but not limited to, the implied warranties of\n"
+"MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE are DISCLAIMED.  In NO\n"
+"EVENT shall the author be LIABLE for any DIRECT, INDIRECT, INCIDENTAL,\n"
+"SPECIAL, EXEMPLARY, or CONSEQUENTIAL damages (including, but not limited\n"
+"to, procurement of substitute goods or services; loss of use, data, or\n"
+"profits; or business interruption) however caused and on any theory of\n"
+"liability, whether in contract, strict liability, or tort (including\n"
+"negligence or otherwise) arising in any way out of the use of this\n"
+"software, even if advised of the possibility of such damage.\n"
+"\n", f );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Print this program's version number.
+//-----------------------------------------------------------------------------
+static void print_version( FILE* f )
+    {
+    fputs( "Version " PROG_VERSION " (built " __DATE__ ")\n\n", f );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Print a usage summary.
+//-----------------------------------------------------------------------------
+static void print_usage( FILE* f )
+    {
+    fputs(
+"Usage: dumpkeymap [options] [-] [file ...]\n"
+"\n"
+"Prints a textual representation of each Apple/NeXT .keymapping file\n"
+"mentioned on the command-line.  If no files are mentioned and if the local\n"
+"machine is an Apple or NeXT installation, then the key mapping currently in\n"
+"use by the WindowServer and the AppKit is printed instead.\n"
+"\n"
+"Options:\n"
+"    -h --help\n"
+"        Display general program instructions and option summary.\n"
+"\n"
+"    -k --help-keymapping\n"
+"        Display a detailed description of the internal layout of a\n"
+"        .keymapping file.\n"
+"\n"
+"    -o --help-output\n"
+"        Display an explanation of the output generated by dumpkeymap when\n"
+"        dissecting a .keymapping file.\n"
+"\n"
+"    -f --help-files\n"
+"        Display a summary of the various files and directories which are\n"
+"        related to key mappings.\n"
+"\n"
+"    -d --help-diagnostics\n"
+"        Display a list of the various diagnostic messages which may be\n"
+"        emitted by dumpkeymap.\n"
+"\n"
+"    -v --version\n"
+"        Display the dumpkeymap version number and warranty information.\n"
+"\n"
+"    - --\n"
+"        Inhibit processing of options at this point in the argument list.\n"
+"        An occurrence of `-' or `--' in the argument list causes all\n"
+"        following arguments to be treated as file names even if an argument\n"
+"        begins with a `-' character.\n"
+"\n", f );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Print an informational banner.
+//-----------------------------------------------------------------------------
+static void print_banner( FILE* f )
+    {
+    fputs( "\n" PROG_NAME " v" PROG_VERSION " by " AUTHOR_INFO "\n"
+	COPYRIGHT "\n\n", f );
+    }
+
+
+//-----------------------------------------------------------------------------
+// Process command-line arguments.  Examine options first; collecting files
+// along the way.  If all is well, process collected file list.
+//-----------------------------------------------------------------------------
+int main( int const argc, char const* const argv[] )
+    {
+    int rc = 0, i, nfiles = 0, more_options = 1, process_files = 1;
+    int* files = (int*)calloc( argc - 1, sizeof(int) );
+    print_banner( stdout );
+
+    for (i = 1; i < argc; i++)
+	{
+	char const* const s = argv[i];
+	if (!more_options || *s != '-')
+	    files[ nfiles++ ] = i;
+	else
+	    {
+	    OPT_SWITCH(s)
+		OPT_CASE(-,--)
+		    more_options = 0;
+		OPT_CASE(-h,--help)
+		    print_usage( stdout );
+		    process_files = 0;
+		OPT_CASE(-k,--help-keymapping)
+		    print_internal_layout_info( stdout );
+		    process_files = 0;
+		OPT_CASE(-o,--help-output)
+		    print_output_info( stdout );
+		    process_files = 0;
+		OPT_CASE(-f,--help-files)
+		    print_files_info( stdout );
+		    process_files = 0;
+		OPT_CASE(-d,--help-diagnostics)
+		    print_diagnostics_info( stdout );
+		    process_files = 0;
+		OPT_CASE(-v,--version)
+		    print_version( stdout );
+		    print_warranty( stdout );
+		    process_files = 0;
+		OPT_DEFAULT
+		    fprintf( stderr, "ERROR: Unrecognized option: %s\n\n", s );
+		    process_files = 0;
+		    rc = 1;
+	    OPT_SWITCH_END
+	    }
+	}
+
+    if (process_files)
+	{
+	if (nfiles == 0)
+	    rc = handle_empty_document_list();
+	else
+	    for (i = 0; i < nfiles; i++)
+		rc |= unparse_keymap_file( argv[files[i]] );
+	}
+
+    free( files );
+    return rc;
+    }
Index: xc/programs/Xserver/hw/darwin/utils/dumpkeymap.man
diff -u /dev/null xc/programs/Xserver/hw/darwin/utils/dumpkeymap.man:1.2
--- /dev/null	Mon Dec 18 14:28:31 2000
+++ xc/programs/Xserver/hw/darwin/utils/dumpkeymap.man	Tue Dec  5 16:18:34 2000
@@ -0,0 +1,1004 @@
+.ig
+//=============================================================================
+//
+// Manual page for `dumpkeymap'.
+//
+// Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+//   1. Redistributions of source code must retain the above copyright
+//      notice, this list of conditions and the following disclaimer.
+//   2. Redistributions in binary form must reproduce the above copyright
+//      notice, this list of conditions and the following disclaimer in the
+//      documentation and/or other materials provided with the distribution.
+//   3. The name of the author may not be used to endorse or promote products
+//      derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+//
+// $XFree86: xc/programs/Xserver/hw/darwin/utils/dumpkeymap.man,v 1.2 2000/12/05 21:18:34 dawes Exp $
+//
+..
+.ig
+//-----------------------------------------------------------------------------
+// Local identification information.
+//-----------------------------------------------------------------------------
+..
+.nr VE 4 \" Version number
+.TH DUMPKEYMAP 1 "v\n(VE \-\- 1 December 2000" "Version \n(VE"
+.de UP
+1 December 2000
+..
+.ig
+//-----------------------------------------------------------------------------
+// Annotation Macros
+// -----------------
+//	Facilitate creation of annotated, non-filled blocks of text.  An
+//	annotated block is initiated with the `AS' macro.  Each annotated,
+//	non-filled line within the block must be introduced with the `AN' macro
+//	which takes three arguments.  The first argument is the detail text to
+//	be annotated.  The second is a string of spaces used to align the
+//	annotations by certain (broken) roff interpreters which fail to
+//	implement the proper set of roff commands (such as diversions,
+//	indentation, and tab stops).  It is assumed that the spaces will be
+//	used with fixed-point font.  The third argument is the annotation
+//	itself.  The block should be terminated with the `AE' macro.  For all
+//	roff interpreters which properly implement diversions, indentation, and
+//	tab stops, all anotations within the block are automatically aligned at
+//	the same horizontal position.  This position is guaranteed to be just
+//	to the right of the widest `AN' detail line.  For broken roff
+//	interpreters, such as `rman', the string of spaces from the second
+//	argument are used to align the annotations.  Finally, the `AZ' macro,
+//	which takes a single argument, can be used to to insert a non-annotated
+//	line into the block which does not play a part in the calculation of
+//	the horizontal annotation alignment.
+//
+// Implementation Notes
+// --------------------
+// *1*	These macros utilize a diversion (named `AD').  Since the prevailing
+//	indentation is stored along with the diverted text, we must muck with
+//	the indentation level in order to prevent the indentation from being
+//	applied to the text a second time when `AD' is finally emitted.
+//
+// *2*	Unfortunately, `.if' strips leading whitespace from following text, so
+//	`AN' uses \& to preserve the whitespace.
+//
+// *3*	This manual page has been tested for proper formatting with troff,
+//	groff, nroff and rman (the `man' to `HTML' converter).  Unfortunately,
+//	rman fails to implement many useful features such as diversions,
+//	indentation, and tab stops, and is also hideously buggy.  Furthermore
+//	it identifies itself as nroff and fails to provide any further
+//	identification, so there is no way to create macros which specifically
+//	work around its limitations.  Following is a list of several bugs in
+//	rman which the implementation of these macros must avoid:
+//	    o Fails with multi-line conditionals within macros.
+//	    o Fails on macro definition within multi-line conditionals.
+//	    o Fails when macro arguments are not delimited by exactly 1 space.
+//	    o String definition `.ds' ignores the value; uses empty "" instead.
+//	As a consequence of these problems, the following macros are written
+//	using a series of ugly single-line `.if' conditionals rather than the
+//	more natural multi-line `.if' and `.ie' conditionals.  Also, rman fails
+//	to understand the common idiom of `.\"' to introduce a comment, which
+//	is why all comments in this file are wrapped in ignore `.ig' blocks.
+//-----------------------------------------------------------------------------
+..
+.de AS
+.if t .nr AW 0
+.if t .nr AI \\n(.i
+.if t .in -\\n(AI
+.nf
+..
+.de AN
+.if t .if \w'\\$1'>\\n(AW .nr AW \w'\\$1'
+.if t .da AD
+.if t \\&\\$1\\t\\$3
+.if t .da
+.if n \\&\\$1 \\$2\\$3
+..
+.de AZ
+.if t .da AD
+\\$1
+.if t .da
+..
+.de AE
+.if t .in +\\n(AIu
+.if t .if \\n(AW .ta \\n(AWu+\w'\\(em'u
+.if t .AD
+.if t .DT
+.if t .rm AD
+.if t .rm AW
+.fi
+..
+.ig
+//-----------------------------------------------------------------------------
+// Bulleted list macros -- `BG' begins a bulleted list; `BU' delimits
+//	bulleted entries; `BE' ends a bulleted list.
+//-----------------------------------------------------------------------------
+..
+.de BG
+.PP
+.RS
+..
+.de BU
+.HP
+\\(bu\\ \\c
+..
+.de BE
+.RE
+.PP
+..
+.ig
+//-----------------------------------------------------------------------------
+// Indented paragraph with stylized hanging tag macro.  `TG' takes a single
+//	argument and treats it as the hanging tag of the indented paragraph.
+//	The tag is italicized in troff but not in nroff.
+//-----------------------------------------------------------------------------
+..
+.de TG
+.TP
+.ie t .I "\\$1"
+.el \\$1
+..
+.ig
+//-----------------------------------------------------------------------------
+// Manual page for `dumpkeymap'.
+//-----------------------------------------------------------------------------
+..
+.SH NAME
+dumpkeymap \- Dianostic dump of a .keymapping file
+.SH SYNOPSIS
+.B dumpkeymap
+.RI [ options "] [-] [" file "...]"
+.SH DESCRIPTION
+.I dumpkeymap
+prints a textual representation of each Apple/\c
+.SM NeXT
+.I .keymapping
+file mentioned on the command-line.  If no files are mentioned and if the
+local machine is an Apple or
+.SM NeXT
+installation, then the key mapping currently in use by the WindowServer and the
+AppKit is printed instead.
+.SH OPTIONS
+.TP
+.B "\-h \-\^\-help"
+Display general program instructions and option summary.
+.TP
+.B "\-k \-\^\-help\-keymapping"
+Display a detailed description of the internal layout of a
+.I .keymapping
+file.  This is the same information as that presented in the
+.I "Key Mapping Description"
+section of this document.
+.TP
+.B "\-o \-\^\-help\-output"
+Display an explanation of the output generated by
+.I dumpkeymap
+when dissecting a
+.I .keymapping
+file.  This is the same information as that presented in the
+.I "Output Description"
+section of this document.
+.TP
+.B "\-f \-\^\-help\-files"
+Display a summary of the various files and directories which are related to
+key mappings.  This is the same information as that presented in the
+.I "Files"
+section of this document.
+.TP
+.B "\-d \-\^\-help\-diagnostics"
+Display a list of the various diagnostic messages which may be emitted by
+.I dumpkeymap.
+This is the same information as that presented in the
+.I "Diagnostics"
+section of this document.
+.TP
+.B "\-v \-\^\-version"
+Display the
+.I dumpkeymap
+version number and warranty information.
+.TP
+.B "\- \-\^\-"
+Inhibit processing of options at this point in the argument list.  An
+occurrence of `\-' or `\-\^\-' in the argument list causes all following
+arguments to be treated as file names even if an argument begins with a `\-'
+character.
+.SH "KEY MAPPING DESCRIPTION"
+The following sections describe, in complete detail, the format of a raw key
+mapping resource, as well as the format of the
+.I .keymapping
+file which encapsulates one or more raw mappings.
+.SH "Types and Data"
+The following type definitions are employed throughout this discussion:
+.PP
+.RS
+.AS
+.AZ "typedef unsigned char byte;"
+.AZ "typedef unsigned short word;"
+.AZ "typedef unsigned long dword;"
+.AE
+.RE
+.PP
+Additionally, the type definition
+.RI ` number '
+is used generically to
+indicate a numeric value.  The actual size of the
+.RI ` number '
+type may be one or two bytes depending upon how the data is stored in the key
+map.  Although most key maps use byte-sized numeric values, word-sized values
+are also allowed.
+.PP
+Multi-byte values in a key mapping file are stored in big-endian byte order.
+.SH "Key Mapping File and Device Mapping"
+A key mapping file begins with a magic-number and continues with a
+variable number of device-specific key mappings.
+.PP
+.RS
+.AS
+.AZ "struct KeyMappingFile {"
+.AN "    char magic_number[4];" "   " "// `KYM1'"
+.AN "    DeviceMapping maps[...];" "" "// Variable number of maps"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "struct DeviceMapping {"
+.AN "    dword interface;" " " "// Interface type"
+.AN "    dword handler_id;" "" "// Interface subtype"
+.AN "    dword map_size;" "  " "// Byte count of `map' (below)"
+.AN "    KeyMapping map;"
+.AZ };
+.AE
+.RE
+.PP
+The value of `interface' represents a family of keyboard device types
+(such as Intel
+.SM "PC, ADB, NeXT,"
+Sun Type5, etc.), and is generally specified as one of the constant values
+.SM "NX_EVS_DEVICE_INTERFACE_ADB, NX_EVS_DEVICE_INTERFACE_ACE,"
+etc., which are are defined in IOHIDTypes.h on MacOS/X and Darwin, and in
+ev_types.h on MacOS/X Server, OpenStep, and NextStep.
+.PP
+The value of `handler_id' represents a specific keyboard layout within the
+much broader `interface' family.  For instance, for a 101-key Intel
+.SM PC
+keyboard (of type
+.SM NX_EVS_DEVICE_INTERFACE_ACE\c
+) the `handler_id' is '0', whereas for a 102-key keyboard it is `1'.
+.PP
+Together, `interface' and `handler_id' identify the exact keyboard hardware to
+which this mapping applies.  Programs which display a visual representation of
+a keyboard layout, match `interface' and `handler_id' from the
+.I .keymapping
+file against the `interface' and `handler_id' values found in each
+.I .keyboard
+file.
+.SH "Key Mapping"
+A key mapping completely defines the relationship of all scan codes with their
+associated functionality.  A
+.I KeyMapping
+structure is embedded within the
+.I DeviceMapping
+structure in a
+.IR KeyMappingFile .
+The key mapping currently in use by the WindowServer and AppKit is also
+represented by a
+.I KeyMapping
+structure, and can be referred to directly by calling NXGetKeyMapping() and
+accessing the `mapping' data member of the returned
+.I NXKeyMapping
+structure.
+.PP
+.RS
+.AS
+.AZ "struct KeyMapping {"
+.AN "    word number_size;" "          " "// 0=1 byte, non-zero=2 bytes"
+.AN "    number num_modifier_groups;" "" "// Modifier groups"
+.AZ "    ModifierGroup modifier_groups[...];"
+.AN "    number num_scan_codes;" "     " "// Scan groups"
+.AN "    ScanGroup scan_table[...];"
+.AN "    number num_sequence_lists;" " " "// Sequence lists"
+.AN "    Sequence sequence_lists[...];"
+.AN "    number num_special_keys;" "   " "// Special keys"
+.AN "    SpecialKey special_key[...];"
+.AZ };
+.AE
+.RE
+.PP
+The `number_size' flag determines the size, in bytes, of all remaining numeric
+values (denoted by the type definition
+.RI ` number ')
+within the
+key mapping.  If its value is zero, then numbers are represented by a single
+byte.  If it is non-zero, then numbers are represented by a word (two bytes).
+.SH "Modifier Group"
+A modifier group defines all scan codes which map to a particular type of
+modifier, such as
+.IR shift ,
+.IR control ,
+etc.
+.PP
+.RS
+.AS
+.AZ "enum Modifier {"
+.AZ "    ALPHALOCK = 0,"
+.AZ "    SHIFT,"
+.AZ "    CONTROL,"
+.AZ "    ALTERNATE,"
+.AZ "    COMMAND,"
+.AZ "    KEYPAD,"
+.AZ "    HELP"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "struct ModifierGroup {"
+.AN "    number modifier;" "       " "// A Modifier constant"
+.AN "    number num_scan_codes;"
+.AN "    number scan_codes[...];" "" "// Variable number of scan codes"
+.AZ };
+.AE
+.RE
+.PP
+The scan_codes[] array contains a list of all scan codes which map to the
+specified modifier.  The
+.IR shift ", " command ", and " alternate
+modifiers are frequently mapped to two different scan codes, apiece,
+since these modifiers often appear on both the left and right sides of
+the keyboard.
+.SH "Scan Group"
+There is one
+.I ScanGroup
+for each scan code generated by the given keyboard.  This number is given by
+KeyMapping::num_scan_codes.  The first scan group represents hardware scan
+code 0, the second represents scan code 1, etc.
+.PP
+.RS
+.AS
+.AZ "enum ModifierMask {"
+.AN "    ALPHALOCK_MASK" "      " "= 1 << 0,"
+.AN "    SHIFT_MASK" "          " "= 1 << 1,"
+.AN "    CONTROL_MASK" "        " "= 1 << 2,"
+.AN "    ALTERNATE_MASK" "      " "= 1 << 3,"
+.AN "    CARRIAGE_RETURN_MASK" "" "= 1 << 4"
+.AZ };
+.AZ "#define NOT_BOUND 0xff"
+.AE
+.PP
+.AS
+.AZ "struct ScanGroup {"
+.AN "    number mask;"
+.AN "    Character characters[...];"
+.AZ };
+.AE
+.RE
+.PP
+For each scan code, `mask' defines which modifier combinations generate
+characters.  If `mask' is
+.SM NOT_BOUND
+(0xff) then then this scan code does not generate any characters ever, and its
+characters[] array is zero length.  Otherwise, the characters[] array contains
+one
+.I Character
+record for each modifier combination.
+.PP
+The number of records in characters[] is determined by computing (1 <<
+bits_set_in_mask).  In other words, if mask is zero, then zero bits are set,
+so characters[] contains only one record.  If `mask' is
+.SM "(SHIFT_MASK | CONTROL_MASK),"
+then two bits are set, so characters[] contains four records.
+.PP
+The first record always represents the character which is generated by that
+key when no modifiers are active.  The remaining records represent characters
+generated by the various modifier combinations.  Using the example with the
+.I shift
+and
+.I control
+masks set, record two would represent the character with the
+.I shift
+modifier active; record three, the
+.I control
+modifier active; and record four, both the
+.I shift
+and
+.I control
+modifiers active.
+.PP
+As a special case,
+.SM ALPHALOCK_MASK
+implies
+.SM SHIFT_MASK,
+though only
+.SM ALPHALOCK_MASK
+appears in `mask'.  In this case the same character is generated for both the
+.I shift
+and
+.I alpha-lock
+modifiers, but only needs to appear once in the characters[] array.
+.PP
+.SM CARRIAGE_RETURN_MASK
+does not actually refer to a modifier key.  Instead, it is used to
+distinguish the scan code which is given the special pseudo-designation of
+.I "carriage return"
+key.  Typically, this mask appears solo in a
+.I ScanGroup
+record and only the two
+.I Character
+records for control-M and control-C follow.  This flag may be a throwback to
+an earlier time or may be specially interpreted by the low-level keyboard
+driver, but its purpose is otherwise enigmatic.
+.SH Character
+Each
+.I Character
+record indicates the character generated when this key is pressed, as well as
+the character set which contains the character.  Well known character sets are
+.SM `ASCII'
+and `Symbol'.  The character set can also be one of the meta values
+.SM FUNCTION_KEY
+or
+.SM KEY_SEQUENCE.
+If it is
+.SM FUNCTION_KEY
+then `char_code' represents a generally well-known function key such as those
+enumerated by
+.I FunctionKey.
+If the character set is
+.SM KEY_SEQUENCE
+then `char_code' represents is a zero-base index into
+KeyMapping::sequence_lists[].
+.PP
+.RS
+.AS
+.AZ "enum CharacterSet {"
+.AN "    ASCII" "       " "= 0x00,"
+.AN "    SYMBOL" "      " "= 0x01,"
+.AN "    ..."
+.AN "    FUNCTION_KEY" "" "= 0xfe,"
+.AN "    KEY_SEQUENCE" "" "= 0xff"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "struct Character {"
+.AN "    number set;" "      " "// CharacterSet of generated character"
+.AN "    number char_code;" "" "// Actual character generated"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "enum FunctionKey {"
+.AZ "    F1 = 0x20, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,"
+.AZ "    INSERT, DELETE, HOME, END, PAGE_UP, PAGE_DOWN, PRINT_SCREEN,"
+.AZ "    SCROLL_LOCK, PAUSE, SYS_REQUEST, BREAK, RESET, STOP, MENU,"
+.AZ "    USER, SYSTEM, PRINT, CLEAR_LINE, CLEAR_DISPLAY, INSERT_LINE,"
+.AZ "    DELETE_LINE, INSERT_CHAR, DELETE_CHAR, PREV, NEXT, SELECT"
+.AZ };
+.AE
+.RE
+.SH Sequence
+When Character::set contains the meta value
+.SM KEY_SEQUENCE,
+the scan code is bound to a sequence of keys rather than a single character.
+A sequence is a series of modifiers and characters which are automatically
+generated when the associated key is depressed.
+.PP
+.RS
+.AS
+.AZ "#define MODIFIER_KEY 0xff"
+.AE
+.PP
+.AS
+.AZ "struct Sequence {"
+.AN "    number num_chars;"
+.AN "    Character characters[...];"
+.AZ };
+.AE
+.RE
+.PP
+Each generated
+.I Character
+is represented as previously described, with the exception that
+.SM MODIFIER_KEY
+may appear in place of
+.SM KEY_SEQUENCE.
+When the value of Character::set is
+.SM MODIFIER_KEY
+then Character::char_code represents a modifier key rather than an actual
+character.  If the modifier represented by `char_code' is non-zero, then it
+indicates that the associated modifier key has been depressed.  In this case,
+the value is one of the constants enumerated by
+.I Modifier
+(\c
+.SM "SHIFT, CONTROL, ALTERNATE,"
+etc.).  If the value is zero then it means that the modifier keys have been
+released.
+.SH "Special Key"
+A special key is one which is scanned directly by the Mach kernel rather than
+by the WindowServer.  In general, events are not generated for special keys.
+.PP
+.RS
+.AS
+.AZ "enum SpecialKeyType {"
+.AZ "    VOLUME_UP = 0,"
+.AZ "    VOLUME_DOWN,"
+.AZ "    BRIGHTNESS_UP,"
+.AZ "    BRIGHTNESS_DOWN,"
+.AZ "    ALPHA_LOCK,"
+.AZ "    HELP,"
+.AZ "    POWER,"
+.AZ "    SECONDARY_ARROW_UP,"
+.AZ "    SECONDARY_ARROW_DOWN"
+.AZ };
+.AE
+.PP
+.AS
+.AZ "struct SpecialKey {"
+.AN "    number type;" "     " "// A SpecialKeyType constant"
+.AN "    number scan_code;" "" "// Actual scan code"
+.AZ };
+.AE
+.RE
+.SH OUTPUT
+What follows is an explanation and description of the various pieces of
+information emitted by
+.I dumpkeymap.
+.PP
+For a more thorough discussion of any particular piece of information described
+here, refer to the detailed description of the internal layout of a key mapping
+provided by the
+.I "Key Mapping Description"
+section above.
+.SH Conventions
+Depending upon context, some numeric values are displayed in decimal
+notation, whereas others are displayed in hexadecimal notation.
+Hexadecimal numbers are denoted by a `0x' prefix (for instance, `0x7b'),
+except when explicitly noted otherwise.
+.SH "Key Mapping Source"
+The first piece of information presented about a particular key mapping is the
+source from which the data was gleaned.  For a
+.I .keymapping
+file, the title
+.SM "`KEYMAP FILE'"
+is emitted along with the path and name of the file in question.  For the key
+mapping currently in use by the WindowServer and AppKit, the title
+.SM "`ACTIVE KEYMAP'"
+is emitted instead.
+.SH "Device Information"
+Each
+.I .keymapping
+file may contain one or more raw key mappings.  For example, a file which maps
+keys to a Dvorak-style layout might contain raw mappings for Intel
+.SM "PC, ADB, NeXT,"
+and Sun Type5 keyboards.
+.PP
+For each raw mapping, the following information is emitted:
+.BG
+.BU
+The title
+.SM `KEYMAP'
+along with the mapping's relative position in the
+.I .keymapping
+file.
+.BU
+The `interface' identifier.
+.BU
+The `handler_id' sub-identifier.
+.BU
+The size of the raw mapping resource counted in bytes.
+.BE
+The `interface' and `handler_id' values, taken together, define a specific
+keyboard device.  A
+.I .keyboard
+file, which describes the visual layout of a keyboard, also contains
+`interface' and `handler_id' identifiers.  The
+.I .keyboard
+file corresponding to a particular key mapping can be found by matching the
+`interface' and `handler_id' values from each resource.
+.SH Modifiers
+Each mapping may contain zero or more modifier records which associate hardware
+scan codes with modifier descriptions such as
+.I "shift, control, alternate,"
+etc.  The title
+.SM `MODIFIERS'
+is printed along with the count of modifier records which follow.  For each
+modifier record, the modifier's name is printed along with a list of scan
+codes, in hexadecimal format, which generate that modifier value.  For example:
+.PP
+.RS
+.nf
+MODIFIERS [4]
+alternate: 0x1d 0x60
+control: 0x3a
+keypad: 0x52 0x53 ... 0x63 0x62
+shift: 0x2a 0x36
+.fi
+.RE
+.SH Characters
+Each mapping may contain zero or more character records which associate
+hardware scan codes with the actual characters generated by those scan
+codes in the presence or absence of various modifier combinations.  The
+title
+.SM `CHARACTERS'
+is printed along with the count of character records which follow.  Here is a
+highly abbreviated example:
+.PP
+.RS
+.nf
+CHARACTERS [9]
+scan 0x00: -AC-L  "a" "A" "^A" "^A" ca c7 "^A" "^A"
+scan 0x07: -AC-L  "x" "X" "^X" "^X" 01/b4 01/ce "^X" "^X"
+scan 0x0a: ---S-  "<" ">"
+scan 0x13: -ACS-  "2" "@" "^@" "^@" b2 b3 "^@" "^@"
+scan 0x24: R----  "^M" "^C"
+scan 0x3e: -----  [F4]
+scan 0x4a: -----  [page up]
+scan 0x60: -----  {seq#3}
+scan 0x68: not-bound
+.fi
+.RE
+.PP
+For each record, the hexadecimal value of the hardware scan code is printed,
+followed by a list of modifier flag combinations and the actual characters
+generated by this scan code with and without modifiers applied.
+.PP
+The modifier flags field is composed of a combination of single letter
+representations of the various modifier types.  The letters stand for:
+.PP
+.RS
+.nf
+L \- alpha-lock
+S \- shift
+C \- control
+A \- alternate
+R \- carriage-return
+.fi
+.RE
+.PP
+As a special case, the
+.I alpha-lock
+flag also implies the
+.I shift
+flag, so these two flags never appear together in the same record.
+.PP
+The combination of modifier flags determines the meaning and number of fields
+which follow.  The first field after the modifier flags always represents the
+character that will be generated if no modifier keys are depressed.  The
+remaining fields represent characters generated by the various modifier
+combinations.  The order of the fields follows this general pattern:
+.BG
+.BU
+The character generated by this scan code when no modifiers are in effect is
+listed first.
+.BU
+If the `L' or `S' flag is active, then the shifted character generated by this
+scan code is listed next.
+.BU
+If the `C' flag is active, then the control-character generated by this scan
+code is listed next.  Furthermore, if the `L' or `S' flag is also active, then
+the shifted control-character is listed after that.
+.BU
+If the `A' flag is active, then the alternate-character generated by this scan
+code is listed next.  Furthermore, if the `L' or `S' flag is active, then the
+shifted alternate-character is listed after that.  If the `C' flag is also
+active, then the alternate-control-character is listed next.  Finally, if the
+`C' and `L' or `C' and `S' flags are also active, then the shifted
+alternate-control-character is listed.
+.BE
+The `R' flag does not actually refer to a modifier key.  Instead, it is used to
+distinguish the scan code which is given the special pseudo-designation of
+.I "carriage return"
+key.  Typically, this mask appears solo and only the two fields for control-M
+and control-C follow.  This flag may be a throwback to an earlier time or may
+be specially interpreted by the low-level keyboard driver, but its purpose is
+otherwise enigmatic.
+.PP
+Recalling the example from above, the following fields can be identified:
+.PP
+.RS
+.nf
+scan 0x00: -AC-L  "a" "A" "^A" "^A" ca c7 "^A" "^A"
+.fi
+.RE
+.BG
+.BU
+Lower-case `a' is generated when no modifiers are active.
+.BU
+Upper-case `A' is generated when
+.IR shift " or " alpha-lock
+are active.
+.BU
+Control-A is generated when
+.I control
+is active.
+.BU
+Control-A is generated when
+.IR control " and " shift
+are active.
+.BU
+The character represented by the hexadecimal code 0xca is generated when
+.I alternate
+is active.
+.BU
+The character represented by 0xc7 is generated when
+.IR alternate " and " shift " (or " alpha-lock ") are active."
+.BU
+Control-A is generated when
+.IR alternate " and " control
+are active.
+.BU
+Control-A is generated when
+.IR "alternate, control" " and " shift " (or " alpha-lock ") are active."
+.BE
+The notation used to represent a particular generated character varies.
+.BG
+.BU
+Printable
+.SM ASCII
+characters are quoted, as in "x" or "X".
+.BU
+Control-characters are quoted and prefixed with `^', as in "^X".
+.BU
+Characters with values greater than 127 (0x7f) are displayed as hexadecimal
+values without the `0x' prefix.
+.BU
+Characters in a non-\c
+.SM ASCII
+character set (such as `Symbol') are displayed as two hexadecimal numbers
+separated by a slash, as in `01/4a'.  The first number is the character set's
+identification code (such as `01' for the `Symbol' set), and the second number
+is the value of the generated character.
+.BU
+Non-printing special function characters are displayed with the function's
+common name enclosed in brackets, as in `[page up]' or `[F4]'.
+.BU
+If the binding represents a key sequence rather than a single character, then
+the sequence's identification number is enclosed in braces, as in `{seq#3}'.
+.BE
+Recalling a few examples from above, the following interpretations can be made:
+.PP
+.RS
+.nf
+scan 0x07: -AC-L  "x" "X" "^X" "^X" 01/b4 01/ce "^X" "^X"
+scan 0x3e: -----  [F4]
+scan 0x4a: -----  [page up]
+scan 0x60: -----  {seq#3}
+.fi
+.RE
+.BG
+.BU
+"x" and "X" are printable
+.SM ASCII
+characters.
+.BU
+"^X" is a control-character.
+.BU
+`01/b4' and `01/ce' represent the character codes 0xb4 and 0xce in the `Symbol'
+character set.
+.BU
+Scan code 0x3e generates function-key `F4', and scan code 0x4a generates
+function-key `page up'.
+.BU
+Scan code 0x60 is bound to key sequence #3.
+.BE
+Finally, if a scan code is not bound to any characters, then it is annotated
+with the label `not-bound', as with example scan code 0x68 from above.
+.SH Sequences
+A scan code (modified and unmodified) can be bound to a key sequence rather
+than generating a single character or acting as a modifier.  When it is bound
+to a key sequence, a series of character invocations and modifier actions are
+automatically generated rather than a single keystroke.
+.PP
+Each mapping may contain zero or more key sequence records.  The title
+.SM `SEQUENCES'
+is printed along with the count of sequence records which follow.  For example:
+.PP
+.RS
+.nf
+SEQUENCES [3]
+sequence 0: "f" "o" "o"
+sequence 1: {alternate} "b" "a" "r" {unmodify}
+sequence 2: [home] "b" "a" "z"
+.fi
+.RE
+.PP
+The notation used to represent the sequence of generated characters is
+identical to the notation already described in the
+.I Characters
+section above, with the exception that modifier actions may be interposed
+between generated characters.  Such modifier actions are represented by the
+modifier's name enclosed in braces.  The special name `{unmodify}' indicates
+the release of the modifier keys.
+.PP
+Thus, the sequences in the above example can be interpreted as follows:
+.BG
+.BU
+Sequence\ #0 generates `foo'.
+.BU
+Sequence\ #1 invokes the
+.I alternate
+modifier, generates `bar', and then releases
+.I alternate.
+.BU
+Sequence\ #2 invokes the
+.I home
+key and then generates `baz'.  In a text editor, this would probably result in
+`baz' being prepended to the line of text on which the cursor resides.
+.BE
+.SH Special Keys
+Certain keyboards feature keys which perform some type of special purpose
+function rather than generating a character or acting as a modifier.  For
+instance, Apple keyboards often contain a
+.I power
+key, and
+.SM NeXT
+keyboards have historically featured screen brightness and volume control keys.
+.PP
+Each mapping may contain zero or more special-key records which associate
+hardware scan codes with such special purpose functions.  The title
+.SM `SPECIALS'
+is printed along with the count of records which follow.  For each record, the
+special function's name is printed along with a list of scan codes, in
+hexadecimal format, which are bound to that function.  For example:
+.PP
+.RS
+.nf
+SPECIALS [6]
+alpha-lock: 0x39
+brightness-down: 0x79
+brightness-up: 0x74
+power: 0x7f
+sound-down: 0x77
+sound-up: 0x73
+.fi
+.RE
+.SH FILES
+.IP *.keymapping
+A key mapping file which precisely defines the relationship of all
+hardware-specific keyboard scan-codes with their associated functionality.
+.IP *.keyboard
+A file describing the physical layout of keys on a particular type of
+keyboard.  Each `key' token in this file defines the position and shape of the
+key on the keyboard, as well as the associated scan code which that key
+generates.  A
+.I .keymapping
+file, on the other hand, defines the characters which are generated by a
+particular scan code depending upon the state of the various modifier keys
+(such as
+.I shift,
+.I control,
+etc.).  The `interface' and `handler_id' values from a
+.I .keymapping
+file are matched against those in each
+.I .keyboard
+file in order to associate a particular
+.I .keyboard
+file with a key mapping.  Various
+.SM GUI
+programs use the
+.I .keyboard
+file to display a visual representation of a keyboard for the user.  Since
+these files are just plain text, they can be easily viewed and interpreted
+without the aid of a specialized program, thus
+.I dumpkeymap
+leaves these files alone.
+.PP
+/System/Library/Keyboards
+.br
+/Network/Library/Keyboards
+.br
+/Local/Library/Keyboards
+.br
+/Library/Keyboards
+.RS
+Repositories for
+.I .keymapping
+and
+.I .keyboard
+files for MacOS/X, Darwin, and MacOS/X Server.
+.RE
+.PP
+/NextLibrary/Keyboards
+.br
+/LocalLibrary/Keyboards
+.RS
+Repositories for
+.I .keymapping
+and
+.I .keyboard
+files for OpenStep and NextStep.
+.RE
+.IP $(HOME)/Library/Keyboards
+Repository for personal
+.I .keymapping
+and
+.I .keyboard
+files.
+.SH DIGANOSTICS
+The following diagnostic messages may be issued to the standard error stream.
+.TG "Unrecognized option."
+An unrecognized option was specified on the command-line.  Invoke
+.I dumpkeymap
+with the
+.B "\-\^\-help"
+option to view a list of valid options.
+.TG "Insufficient data in keymapping data stream."
+The key mapping file or data stream is corrupt.  Either the file has been
+incorrectly truncated or a field, such as those which indicates the number of
+variable records which follow, contains a corrupt value.
+.PP
+The following diagnostic messages have significance only when trying to print
+.I .keymapping
+files mentioned on the command-line.
+.TG "Bad magic number."
+The mentioned file is not a
+.I .keymapping
+file.  The file's content does not start with the string `KYM1'.
+.TG "Unable to open key mapping file."
+The call to fopen() failed; probably because the specified path is invalid or
+.I dumpkeymap
+does not have permission to read the file.
+.TG "Unable to determine key mapping file size."
+The call to fstat() failed, thus memory can not be allocated for loading the
+file.
+.TG "Unable to read key mapping file."
+The call to fread() failed.
+.PP
+The following diagnostic messages have significance only when trying to print
+the currently active key mapping when no
+.I .keymapping
+files have been mentioned on the command-line.
+.TG "Unable to open event status driver."
+The call to NXOpenEventStatus() failed.
+.TG "Bad key mapping length."
+The call to NXKeyMappingLength() returned a bogus value.
+.TG "Unable to get current key mapping."
+The call to NXGetKeyMapping() failed.
+.PP
+The following diagnostic messages have significance only when using
+.I dumpkeymap
+on a non-Apple/\c
+.SM NeXT
+platform.
+.TG "Must specify at least one .keymapping file."
+No
+.I .keymapping
+files were mentioned on the command-line.  On non-Apple/\c
+.SM NeXT
+platforms, there is no concept of a currently active
+.I .keymapping
+file, so at least one file must be mentioned on the command-line.
+.SH AUTHOR
+Eric Sunshine <sunshine@sunshineco.com> wrote
+.I dumpkeymap
+and this document, the
+.I "dumpkeymap user's manual."
+Both
+.I dumpkeymap
+and this document are copyright \(co1999,2000 by Eric Sunshine
+<sunshine@sunshineco.com>.  All rights reserved.
+.PP
+The implementation of
+.I dumpkeymap
+is based upon information gathered on September 3, 1997 by Eric Sunshine
+<sunshine@sunshineco.com> and Paul S. McCarthy <zarnuk@zarnuk.com> during an
+effort to reverse engineer the format of the
+.SM NeXT
+.I .keymapping
+file.
+.if n .PP
+.if n Version \n(VE \-\-
+.if n .UP
Index: xc/programs/Xserver/hw/kdrive/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/Imakefile:1.2 xc/programs/Xserver/hw/kdrive/Imakefile:1.5
--- xc/programs/Xserver/hw/kdrive/Imakefile:1.2	Wed Dec 29 22:03:05 1999
+++ xc/programs/Xserver/hw/kdrive/Imakefile	Thu Nov 30 19:01:30 2000
@@ -1,20 +1,25 @@
 XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/Imakefile,v 1.2 1999/12/30 03:03:05 robin Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/Imakefile,v 1.5 2000/12/01 00:01:30 keithp Exp $
+KDRIVE=.
+#include "Kdrive.tmpl"
+
+#if BuildRender
+RENDERSRCS=kpict.c
+RENDEROBJS=kpict.o
+#endif
 
 SRCS = kcmap.c kcolor.c kdrive.c kinfo.c kinput.c kmap.c knoop.c ktest.c \
-	vga.c kasync.c kmode.c kcurscol.c
+	vga.c kasync.c kmode.c kcurscol.c kshadow.c $(RENDERSRCS)
 
 OBJS = kcmap.o kcolor.o kdrive.o kinfo.o kinput.o kmap.o knoop.o ktest.o \
-	vga.o kasync.o kmode.o kcurscol.o
+	vga.o kasync.o kmode.o kcurscol.o kshadow.o $(RENDEROBJS)
 
-INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../fb -I../../mi -I../../include -I../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+INCLUDES = $(KDINCS)
 
 NormalLibraryObjectRule()
 NormalLibraryTarget(kdrive,$(OBJS))
 
 SpecialCObjectRule(kdrive,,$(EXT_DEFINES))
 
+InstallManPage(Xkdrive,$(MANDIR))
 DependTarget()
Index: xc/programs/Xserver/hw/kdrive/Kdrive.tmpl
diff -u /dev/null xc/programs/Xserver/hw/kdrive/Kdrive.tmpl:1.1
--- /dev/null	Mon Dec 18 14:28:43 2000
+++ xc/programs/Xserver/hw/kdrive/Kdrive.tmpl	Sun Sep  3 01:11:46 2000
@@ -0,0 +1,13 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/Kdrive.tmpl,v 1.1 2000/09/03 05:11:46 keithp Exp $
+
+#include <Server.tmpl>
+
+#if BuildRender
+RENDERINCS=-I$(KDRIVE)/../../render -I$(EXTINCSRC)
+#endif
+
+KDINCS = -I$(KDRIVE) -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
+	 -I$(KDRIVE)/../../fb -I$(KDRIVE)/../../mi \
+	 -I$(KDRIVE)/../../miext/shadow \
+	 -I$(KDRIVE)/../../include -I$(KDRIVE)/../../os \
+         -I$(EXTINCSRC) -I$(XINCLUDESRC) $(RENDERINCS)
Index: xc/programs/Xserver/hw/kdrive/Xkdrive.man
diff -u /dev/null xc/programs/Xserver/hw/kdrive/Xkdrive.man:1.2
--- /dev/null	Mon Dec 18 14:28:43 2000
+++ xc/programs/Xserver/hw/kdrive/Xkdrive.man	Mon Dec  4 16:01:00 2000
@@ -0,0 +1,77 @@
+.\" $XFree86: xc/programs/Xserver/hw/kdrive/Xkdrive.man,v 1.2 2000/12/04 21:01:00 dawes Exp $
+.\"
+.TH Xkdrive 1
+.SH NAME
+Xkdrive \- tiny X server
+.SH SYNOPSIS
+.B Xvesa
+.RI [ :display ]
+.RI [ option ...]
+
+.B Xfbdev
+.RI [ :display ]
+.RI [ option ...]
+
+.B Xigs
+.RI [ :display ]
+.RI [ option ...]
+
+.B Xtrident
+.RI [ :display ]
+.RI [ option ...]
+
+.B Xsis530
+.RI [ :display ]
+.RI [ option ...]
+
+.B Xtrio
+.RI [ :display ]
+.RI [ option ...]
+
+.B Xitsy
+.RI [ :display ]
+.RI [ option ...]
+.SH DESCRIPTION
+.B Xkdrive
+is a family of X servers designed to be particularly small.  This
+manual page describes the common functionality of the 
+.B Xkdrive
+servers; for information on a specific X server, please refer to the
+relevant manual page.
+.SH OPTIONS
+In addition to the standard options accepted by all X servers (see
+Xserver(1)), all the 
+.B Xkdrive
+servers accept the following options:
+.TP 8
+.B -screen \fIwidth\fBx\fIheight\fR[\fBx\fIdepth\fR]\fB
+use a screen of the specified size.
+.TP 8
+.B -zaphod
+disable switching screens by moving the pointer accross a screen boundary.
+.TP 8
+.B -3button
+disable emulation of a middle mouse button by chording.
+.TP 8
+.B -2button
+enable emulation of a middle mouse button by chording.
+.TP 8
+.B -dumb
+disable hardware acceleration.
+.TP 8
+.B -softCursor
+disable the hardware cursor.
+.TP 8
+.B -card \fIcard\fB
+not documented.
+.TP 8
+.B -videoTest
+not documented.
+.TP 8
+.B -standalone
+not documented.
+.SH SEE ALSO
+X(1), Xserver(1), xdm(1), xinit(1), Xvesa(1), Xfbdev(1).
+.SH AUTHORS
+The Xkdrive common core was written by Keith Packard, based on XFree86
+which, in turn, is based on the Sample Implementation of X.
Index: xc/programs/Xserver/hw/kdrive/kasync.c
diff -u xc/programs/Xserver/hw/kdrive/kasync.c:1.4 xc/programs/Xserver/hw/kdrive/kasync.c:1.7
--- xc/programs/Xserver/hw/kdrive/kasync.c:1.4	Wed Feb 23 15:29:52 2000
+++ xc/programs/Xserver/hw/kdrive/kasync.c	Fri Sep 22 02:25:29 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kasync.c,v 1.4 2000/02/23 20:29:52 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kasync.c,v 1.7 2000/09/22 06:25:29 keithp Exp $ */
 
 #include "kdrive.h"
 
@@ -141,7 +141,6 @@
     fbPolyFillRect (pDrawable, pGC, nrect, prect);
 }
 
-#if 0
 void
 KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC, 
 		    int narcs, xArc *pArcs)
@@ -149,7 +148,6 @@
     KdCheckSync(pDrawable->pScreen);
     fbPolyFillArc (pDrawable, pGC, narcs, pArcs);
 }
-#endif
 
 void
 KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
@@ -237,7 +235,26 @@
     fbCopyWindow (pWin, ptOldOrg, prgnSrc);
 }
 
+#if KD_MAX_FB > 1
+void
+KdCheckPaintKey(DrawablePtr  pDrawable,
+		RegionPtr    pRegion,
+		CARD32       pixel,
+		int          layer)
+{
+    KdCheckSync (pDrawable->pScreen);
+    fbOverlayPaintKey (pDrawable,  pRegion, pixel, layer);
+}
+
 void
+KdCheckOverlayCopyWindow  (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+    KdCheckSync (pWin->drawable.pScreen);
+    fbOverlayCopyWindow (pWin, ptOldOrg, prgnSrc);
+}
+#endif
+
+void
 KdScreenInitAsync (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
@@ -253,6 +270,9 @@
 #else
     pScreenPriv->BackingStoreFuncs.SaveAreas = KdCheckSaveAreas;
     pScreenPriv->BackingStoreFuncs.RestoreAreas = KdCheckRestoreAreas;
+#endif
+#ifdef RENDER
+    KdPictureInitAsync (pScreen);
 #endif
 }
 
Index: xc/programs/Xserver/hw/kdrive/kcmap.c
diff -u xc/programs/Xserver/hw/kdrive/kcmap.c:1.4 xc/programs/Xserver/hw/kdrive/kcmap.c:1.5
--- xc/programs/Xserver/hw/kdrive/kcmap.c:1.4	Wed May 24 19:57:56 2000
+++ xc/programs/Xserver/hw/kdrive/kcmap.c	Fri Sep 22 02:25:29 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kcmap.c,v 1.4 2000/05/24 23:57:56 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kcmap.c,v 1.5 2000/09/22 06:25:29 keithp Exp $ */
 
 #include "kdrive.h"
 
@@ -189,14 +189,15 @@
 
     KdSetColormap (pCmap->pScreen, fb);
     
-    /* Tell X clients of the new colorscreen-> */
+    /* Tell X clients of the new colormap */
     WalkTree(pCmap->pScreen, TellGainedMap, (pointer) &(pCmap->mid));
 }
 
 /*
  * KdUninstallColormap
  *
- * This function uninstalls a colormap by installing the default X colorscreen->
+ * This function uninstalls a colormap by either installing 
+ * the default X colormap or erasing the installed colormap pointer.
  * The default X colormap itself cannot be uninstalled.
  */
 void
@@ -204,18 +205,28 @@
 {
     KdScreenPriv(pCmap->pScreen);
     int		fb = KdColormapFb (pCmap);
+    Colormap	defMapID;
+    ColormapPtr defMap;
 
-    if (pCmap == pScreenPriv->pInstalledmap[0]) 
-    {
-	Colormap defMapID = pCmap->pScreen->defColormap;
+    /* ignore if not installed */
+    if (pCmap != pScreenPriv->pInstalledmap[fb])
+	return;
 
-	if ((Colormap) pCmap->mid != defMapID) 
-	{
-	    ColormapPtr defMap = (ColormapPtr) LookupIDByType(defMapID,
-							      RT_COLORMAP);
-	    if (defMap)
-		(*pCmap->pScreen->InstallColormap)(defMap);
-	}
+    /* ignore attempts to uninstall default colormap */
+    defMapID = pCmap->pScreen->defColormap;
+    if ((Colormap) pCmap->mid == defMapID)
+	return;
+
+    /* install default if on same fb */
+    defMap = (ColormapPtr) LookupIDByType(defMapID, RT_COLORMAP);
+    if (defMap && KdColormapFb (defMap) == fb)
+	(*pCmap->pScreen->InstallColormap)(defMap);
+    else
+    {
+	/* uninstall and clear colormap pointer */
+	WalkTree(pCmap->pScreen, TellLostMap,
+		 (pointer) &(pCmap->mid));
+	pScreenPriv->pInstalledmap[fb] = 0;
     }
 }
 
Index: xc/programs/Xserver/hw/kdrive/kcurscol.c
diff -u xc/programs/Xserver/hw/kdrive/kcurscol.c:1.4 xc/programs/Xserver/hw/kdrive/kcurscol.c:1.5
--- xc/programs/Xserver/hw/kdrive/kcurscol.c:1.4	Thu May 11 14:14:13 2000
+++ xc/programs/Xserver/hw/kdrive/kcurscol.c	Fri Sep 15 11:18:59 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/Xserver/hw/kdrive/kcurscol.c,v 1.4 2000/05/11 18:14:13 tsi Exp $
+ * $XFree86: xc/programs/Xserver/hw/kdrive/kcurscol.c,v 1.5 2000/09/15 15:18:59 keithp Exp $
  *
  * Copyright © 1999 Keith Packard
  *
@@ -25,7 +25,7 @@
 #include "kdrive.h"
 #include "cursorstr.h"
 
-static int
+int
 KdComputeCmapShift (unsigned long mask)
 {
     int	shift;
Index: xc/programs/Xserver/hw/kdrive/kdrive.c
diff -u xc/programs/Xserver/hw/kdrive/kdrive.c:1.5 xc/programs/Xserver/hw/kdrive/kdrive.c:1.11
--- xc/programs/Xserver/hw/kdrive/kdrive.c:1.5	Wed May 24 19:57:56 2000
+++ xc/programs/Xserver/hw/kdrive/kdrive.c	Fri Dec  8 17:59:37 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.5 2000/05/24 23:57:56 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.11 2000/12/08 22:59:37 keithp Exp $ */
 
 #include "kdrive.h"
 #ifdef PSEUDO8
@@ -224,14 +224,15 @@
     }
 }
 
-void
+Bool
 KdEnableScreen (ScreenPtr pScreen)
 {
     KdScreenPriv (pScreen);
 
     if (pScreenPriv->enabled)
-	return;
-    (*pScreenPriv->card->cfuncs->enable) (pScreen);
+	return TRUE;
+    if (!(*pScreenPriv->card->cfuncs->enable) (pScreen))
+	return FALSE;
     pScreenPriv->enabled = TRUE;
     pScreenPriv->card->selected = pScreenPriv->screen->mynum;
     if (!pScreenPriv->screen->softCursor)
@@ -300,69 +301,110 @@
     AbortDDX ();
 }
 
+Bool	kdDumbDriver;
+Bool	kdSoftCursor;
+
+char *
+KdParseFindNext (char *cur, char *delim, char *save, char *last)
+{
+    while (*cur && !strchr (delim, *cur))
+    {
+	*save++ = *cur++;
+    }
+    *save = 0;
+    *last = *cur;
+    if (*cur)
+	cur++;
+    return cur;
+}
+
 void
 KdParseScreen (KdScreenInfo *screen,
 	       char	    *arg)
 {
     char    *bpp;
+    char    delim;
+    char    save[1024];
     int	    fb;
+    int	    i;
+    int	    pixels, mm;
     
+    screen->dumb = kdDumbDriver;
+    screen->softCursor = kdSoftCursor;
+    kdDumbDriver = FALSE;
+    kdSoftCursor = FALSE;
     screen->width = 0;
     screen->height = 0;
+    screen->width_mm = 0;
+    screen->height_mm = 0;
     screen->rate = 0;
     for (fb = 0; fb < KD_MAX_FB; fb++)
 	screen->fb[fb].depth = 0;
     if (!arg)
 	return;
-    
-    screen->width = atoi(arg);
-    arg = strchr (arg, 'x');
-    if (!arg)
+    if (strlen (arg) > sizeof (save))
 	return;
-    arg++;
-
-    screen->height = atoi(arg);
-    arg = strchr (arg, 'x');
-    if (!arg)
-	return;
-    arg++;
-
+    
+    for (i = 0; i < 2; i++)
+    {
+	arg = KdParseFindNext (arg, "x/", save, &delim);
+	if (!save[0])
+	    return;
+	
+	pixels = atoi(save);
+	mm = 0;
+	
+	if (delim == '/')
+	{
+	    arg = KdParseFindNext (arg, "x", save, &delim);
+	    if (!save[0])
+		return;
+	    mm = atoi(save);
+	}
+	
+	if (i == 0)
+	{
+	    screen->width = pixels;
+	    screen->width_mm = mm;
+	}
+	else
+	{
+	    screen->height = pixels;
+	    screen->height_mm = mm;
+	}
+	if (delim != 'x')
+	    return;
+    }
+    
     fb = 0;
     while (fb < KD_MAX_FB)
     {
-	screen->fb[fb].depth = atoi(arg);
-    
-	bpp = strchr (arg, '/');
-	if (bpp)
+	arg = KdParseFindNext (arg, "x/,", save, &delim);
+	if (!save[0])
+	    break;
+	screen->fb[fb].depth = atoi(save);
+	if (delim == '/')
 	{
-	    bpp++;
-	    screen->fb[fb].bitsPerPixel = atoi(bpp);
-	    arg = bpp;
+	    arg = KdParseFindNext (arg, "x,", save, &delim);
+	    if (!save[0])
+		break;
+	    screen->fb[fb].bitsPerPixel = atoi (save);
 	}
 	else
 	    screen->fb[fb].bitsPerPixel = 0;
-	bpp = strchr (arg, ',');
-	if (!bpp)
+	if (delim != ',')
 	    break;
-	arg = bpp+1;
 	fb++;
     }
 
-    arg = strchr (arg, 'x');
-    if (!arg)
-	return;
-    arg++;
-
-    screen->rate = atoi(arg);
-    arg = strchr (arg, 'x');
-    if (!arg)
-	return;
-    arg++;
+    if (delim == 'x')
+    {
+	arg = KdParseFindNext (arg, "x", save, &delim);
+	if (save[0])
+	    screen->rate = atoi(save);
+    }
 }
 
-Bool	kdDumbDriver;
-Bool	kdSoftCursor;
-
 int
 KdProcessArgument (int argc, char **argv, int i)
 {
@@ -389,10 +431,6 @@
 	    }
 	    screen = KdScreenInfoAdd (card);
 	    KdParseScreen (screen, argv[i+1]);
-	    screen->dumb = kdDumbDriver;
-	    screen->softCursor = kdSoftCursor;
-	    kdDumbDriver = FALSE;
-	    kdSoftCursor = FALSE;
 	}
 	else
 	    UseMsg ();
@@ -464,9 +502,9 @@
 	kdGeneration         = serverGeneration;
     }
     pScreenPriv = (KdPrivScreenPtr) xalloc(sizeof (*pScreenPriv));
-    memset (pScreenPriv, '\0', sizeof (KdPrivScreenRec));
     if (!pScreenPriv)
 	return FALSE;
+    memset (pScreenPriv, '\0', sizeof (KdPrivScreenRec));
     KdSetScreenPriv (pScreen, pScreenPriv);
     return TRUE;
 }
@@ -493,11 +531,14 @@
      * Restore video hardware when last screen is closed
      */
     if (screen == card->screenList)
-	(*card->cfuncs->restore) (card);
-    
+    {
+	if (kdEnabled)
+	    (*card->cfuncs->restore) (card);
+    }
+	
     if (!pScreenPriv->screen->dumb)
 	(*card->cfuncs->finiAccel) (pScreen);
-    
+
     if (!pScreenPriv->screen->softCursor)
 	(*card->cfuncs->finiCursor) (pScreen);
 
@@ -611,7 +652,7 @@
     if (!fbSetupScreen (pScreen, 
 			screen->fb[0].frameBuffer, 
 			screen->width, screen->height, 
-			screen->dpix, screen->dpiy, 
+			75, 75, 
 			screen->fb[0].pixelStride,
 			screen->fb[0].bitsPerPixel))
     {
@@ -637,13 +678,14 @@
     pScreenPriv->BackingStoreFuncs.GetSpansPixmap = 0;
 #endif
 
+#if KD_MAX_FB > 1
     if (screen->fb[1].depth)
     {
 	if (!fbOverlayFinishScreenInit (pScreen, 
 					screen->fb[0].frameBuffer, 
 					screen->fb[1].frameBuffer, 
 					screen->width, screen->height, 
-					screen->dpix, screen->dpiy, 
+					75, 75,
 					screen->fb[0].pixelStride,
 					screen->fb[1].pixelStride,
 					screen->fb[0].bitsPerPixel,
@@ -655,11 +697,12 @@
 	}
     }
     else
+#endif
     {
 	if (!fbFinishScreenInit (pScreen, 
 				 screen->fb[0].frameBuffer, 
-				 screen->width, screen->height, 
-				 screen->dpix, screen->dpiy, 
+				 screen->width, screen->height,
+				 75, 75,
 				 screen->fb[0].pixelStride,
 				 screen->fb[0].bitsPerPixel))
 	{
@@ -668,12 +711,26 @@
     }
     
     /*
+     * Fix screen sizes; for some reason mi takes dpi instead of mm.
+     * Rounding errors are annoying
+     */
+    if (screen->width_mm)
+	pScreen->mmWidth = screen->width_mm;
+    if (screen->height_mm)
+	pScreen->mmHeight = screen->height_mm;
+    
+    /*
      * Plug in our own block/wakeup handlers.
      * miScreenInit installs NoopDDA in both places
      */
     pScreen->BlockHandler	= KdBlockHandler;
     pScreen->WakeupHandler	= KdWakeupHandler;
     
+#ifdef RENDER
+    if (!fbPictureInit (pScreen, 0, 0))
+	return FALSE;
+#endif
+    
     if (card->cfuncs->initScreen)
 	if (!(*card->cfuncs->initScreen) (pScreen))
 	    return FALSE;
@@ -686,12 +743,18 @@
     (void) p8Init (pScreen, PSEUDO8_USE_DEFAULT);
 #endif
     
+#if 0
+    fbInitValidateTree (pScreen);
+#endif
+    
+#if 0
     pScreen->backingStoreSupport = Always;
 #ifdef FB_OLD_SCREEN
     miInitializeBackingStore (pScreen, &pScreenPriv->BackingStoreFuncs);
 #else
     miInitializeBackingStore (pScreen);
 #endif
+#endif
     /* 
      * Wrap CloseScreen, the order now is:
      *	KdCloseScreen
@@ -710,6 +773,7 @@
 	miDCInitialize(pScreen, &kdPointerScreenFuncs);
     }
 
+    
     if (!fbCreateDefColormap (pScreen))
     {
 	return FALSE;
@@ -727,7 +791,8 @@
     if (screen->mynum == card->selected)
     {
 	(*card->cfuncs->preserve) (card);
-	(*card->cfuncs->enable) (pScreen);
+	if (!(*card->cfuncs->enable) (pScreen))
+	    return FALSE;
 	pScreenPriv->enabled = TRUE;
 	if (!screen->softCursor)
 	    (*card->cfuncs->enableCursor) (pScreen);
@@ -750,11 +815,6 @@
     
     (*card->cfuncs->scrinit) (screen);
     
-    if (!screen->dpix)
-	screen->dpix = 75;
-    
-    if (!screen->dpiy)
-	screen->dpiy = 75;
     if (!card->cfuncs->initAccel)
 	screen->dumb = TRUE;
     if (!card->cfuncs->initCursor)
Index: xc/programs/Xserver/hw/kdrive/kdrive.h
diff -u xc/programs/Xserver/hw/kdrive/kdrive.h:1.5 xc/programs/Xserver/hw/kdrive/kdrive.h:1.12
--- xc/programs/Xserver/hw/kdrive/kdrive.h:1.5	Sat May  6 18:17:40 2000
+++ xc/programs/Xserver/hw/kdrive/kdrive.h	Fri Dec  8 17:59:37 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.5 2000/05/06 22:17:40 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.12 2000/12/08 22:59:37 keithp Exp $ */
 
 #include <stdio.h>
 #include "X.h"
@@ -41,6 +41,7 @@
 #include "dix.h"
 #include "fb.h"
 #include "fboverlay.h"
+#include "shadow.h"
 
 extern WindowPtr    *WindowTable;
 
@@ -51,7 +52,7 @@
 #define KD_DPMS_MAX	    KD_DPMS_POWERDOWN
 
 #ifndef KD_MAX_FB
-#define KD_MAX_FB   2
+#define KD_MAX_FB   FB_OVERLAY_MAX
 #endif
 
 #ifndef KD_MAX_CARD_ADDRESS
@@ -103,7 +104,8 @@
     int		width;
     int		height;
     int		rate;
-    int         dpix, dpiy;
+    int		width_mm;
+    int		height_mm;
     Bool        dumb;
     Bool        softCursor;
     int		mynum;
@@ -115,7 +117,7 @@
     Bool	(*scrinit) (KdScreenInfo *);/* initialize screen information */
     Bool	(*initScreen) (ScreenPtr);  /* initialize ScreenRec */
     void	(*preserve) (KdCardInfo *); /* save graphics card state */
-    void        (*enable) (ScreenPtr);      /* set up for rendering */
+    Bool        (*enable) (ScreenPtr);      /* set up for rendering */
     Bool	(*dpms) (ScreenPtr, int);   /* set DPMS screen saver */
     void        (*disable) (ScreenPtr);     /* turn off rendering */
     void	(*restore) (KdCardInfo *);  /* restore graphics card state */
@@ -166,6 +168,14 @@
     void	    (*Fini) (int);
 } KdMouseFuncs;
 
+#ifdef TOUCHSCREEN
+typedef struct _KdTsFuncs {
+    int		    (*Init) (void);
+    void	    (*Read) (int);
+    void	    (*Fini) (int);
+} KdTsFuncs;
+#endif
+
 typedef struct _KdKeyboardFuncs {
     void	    (*Load) (void);
     int		    (*Init) (void);
@@ -210,6 +220,10 @@
 extern const KdMonitorTiming	kdMonitorTimings[];
 extern const int		kdNumMonitorTimings;
 
+typedef struct _KdMouseMatrix {
+    int	    matrix[2][3];
+} KdMouseMatrix;
+
 /*
  * This is the only completely portable way to
  * compute this info.
@@ -297,7 +311,9 @@
 KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
 		     int nrect, xRectangle *prect);
 
-#define KdCheckPolyFillArc	miPolyFillArc
+void
+KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC, 
+		    int narcs, xArc *pArcs);
 
 void
 KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
@@ -343,6 +359,21 @@
 		     WindowPtr	pWin);
 
 void
+KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
+
+void
+KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+void
+KdCheckPaintKey(DrawablePtr  pDrawable,
+		RegionPtr    pRegion,
+		CARD32       pixel,
+		int          layer);
+
+void
+KdCheckOverlayCopyWindow  (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+void
 KdScreenInitAsync (ScreenPtr pScreen);
 
 void
@@ -395,7 +426,7 @@
 void
 KdDisableScreens (void);
 
-void
+Bool
 KdEnableScreen (ScreenPtr pScreen);
 
 void
@@ -469,6 +500,11 @@
 void
 KdInitInput(KdMouseFuncs *, KdKeyboardFuncs *);
 
+#ifdef TOUCHSCREEN
+void
+KdInitTouchScreen(KdTsFuncs *pTsFuncs);
+#endif
+
 void
 KdEnqueueKeyboardEvent(unsigned char	scan_code,
 		       unsigned char	is_up);
@@ -491,6 +527,9 @@
 KdSetLed (int led, Bool on);
 
 void
+KdSetMouseMatrix (KdMouseMatrix *matrix);
+
+void
 KdBlockHandler (int		screen,
 		pointer		blockData,
 		pointer		timeout,
@@ -512,6 +551,10 @@
 ProcessInputEvents ();
 
 extern KdMouseFuncs	Ps2MouseFuncs;
+extern KdMouseFuncs	BusMouseFuncs;
+#ifdef TOUCHSCREEN
+extern KdTsFuncs	TsFuncs;
+#endif
 extern KdKeyboardFuncs	LinuxKeyboardFuncs;
 extern KdOsFuncs	LinuxFuncs;
 
@@ -520,12 +563,22 @@
 extern KdOsFuncs	VxWorksFuncs;
 
 /* kmap.c */
+
+#define KD_MAPPED_MODE_REGISTERS    0
+#define KD_MAPPED_MODE_FRAMEBUFFER  1
+
 void *
 KdMapDevice (CARD32 addr, CARD32 size);
 
 void
 KdUnmapDevice (void *addr, CARD32 size);
 
+void
+KdSetMappedMode (CARD32 addr, CARD32 size, int mode);
+
+void
+KdResetMappedMode (CARD32 addr, CARD32 size, int mode);
+
 /* kmode.c */
 const KdMonitorTiming *
 KdFindMode (KdScreenInfo    *screen,
@@ -537,6 +590,20 @@
 	    Bool	    (*usable) (KdScreenInfo *),
 	    Bool	    (*supported) (KdScreenInfo *,
 					  const KdMonitorTiming *));
+
+/* kpict.c */
+void
+KdPictureInitAsync (ScreenPtr pScreen);
+
+/* kshadow.c */
+Bool
+KdShadowScreenInit (KdScreenInfo *screen);
+
+Bool
+KdShadowInitScreen (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window);
+
+void
+KdShadowScreenFini (KdScreenInfo *screen);
 
 /* ktest.c */
 Bool
Index: xc/programs/Xserver/hw/kdrive/kinput.c
diff -u xc/programs/Xserver/hw/kdrive/kinput.c:1.4 xc/programs/Xserver/hw/kdrive/kinput.c:1.11
--- xc/programs/Xserver/hw/kdrive/kinput.c:1.4	Sat May  6 18:17:40 2000
+++ xc/programs/Xserver/hw/kdrive/kinput.c	Fri Dec  8 16:40:02 2000
@@ -21,12 +21,14 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.4 2000/05/06 22:17:40 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.11 2000/12/08 21:40:02 keithp Exp $ */
 
 #include "kdrive.h"
 #include "inputstr.h"
 
+#define XK_PUBLISHING
 #include <X11/keysym.h>
+#include <X11/XF86keysym.h>
 #include "kkeymap.h"
 #include <signal.h>
 #include <stdio.h>
@@ -42,6 +44,18 @@
 static int		kdBellPitch;
 static int		kdBellDuration;
 static int		kdLeds;
+static Bool		kdInputEnabled;
+static Bool		kdOffScreen;
+static unsigned long	kdOffScreenTime;
+static KdMouseMatrix	kdMouseMatrix = {
+    1, 0, 0,
+    0, 1, 0
+};
+
+#ifdef TOUCHSCREEN
+static KdTsFuncs	*kdTsFuncs;
+static int		kdTsFd = -1;
+#endif
 
 int		kdMinScanCode;
 int		kdMaxScanCode;
@@ -67,6 +81,10 @@
 void
 KdSigio (int sig)
 {
+#ifdef TOUCHSCREEN    
+    if (kdTsFd >= 0)
+ 	(*kdTsFuncs->Read) (kdTsFd);
+#endif
     if (kdMouseFd >= 0)
 	(*kdMouseFuncs->Read) (kdMouseFd);
     if (kdKeyboardFd >= 0)
@@ -168,19 +186,34 @@
 void
 KdDisableInput (void)
 {
+#ifdef TOUCHSCREEN
+    if (kdTsFd >= 0)
+    	KdRemoveFd (kdTsFd);
+#endif
     if (kdMouseFd >= 0)
 	KdRemoveFd (kdMouseFd);
     if (kdKeyboardFd >= 0)
 	KdRemoveFd (kdKeyboardFd);
+    kdInputEnabled = FALSE;
 }
 
 void
 KdEnableInput (void)
 {
+    xEvent	xE;
+    
+    kdInputEnabled = TRUE;
+#ifdef TOUCHSCREEN
+    if (kdTsFd >= 0)
+    	KdAddFd (kdTsFd);
+#endif
     if (kdMouseFd >= 0)
 	KdAddFd (kdMouseFd);
     if (kdKeyboardFd >= 0)
 	KdAddFd (kdKeyboardFd);
+    /* reset screen saver */
+    xE.u.keyButtonPointer.time = GetTimeInMillis ();
+    NoticeEventTime (&xE);
 }
 
 static int
@@ -210,9 +243,17 @@
 	if (kdMouseFuncs)
 	{
 	    kdMouseFd = (*kdMouseFuncs->Init) ();
-	    if (kdMouseFd >= 0)
+	    if (kdMouseFd >= 0 && kdInputEnabled)
 		KdAddFd (kdMouseFd);
 	}
+#ifdef TOUCHSCREEN
+	if (kdTsFuncs)
+	{
+	    kdTsFd = (*kdTsFuncs->Init) ();
+	    if (kdTsFd >= 0 && kdInputEnabled)
+		KdAddFd (kdTsFd);
+	}
+#endif
 	break;
     case DEVICE_OFF:
     case DEVICE_CLOSE:
@@ -222,10 +263,20 @@
 	    pKdPointer = 0;
 	    if (kdMouseFd >= 0)
 	    {
-		KdRemoveFd (kdMouseFd);
+		if (kdInputEnabled)
+		    KdRemoveFd (kdMouseFd);
 		(*kdMouseFuncs->Fini) (kdMouseFd);
 		kdMouseFd = -1;
 	    }
+#ifdef TOUCHSCREEN
+	    if (kdTsFd >= 0)
+	    {
+		if (kdInputEnabled)
+		    KdRemoveFd (kdTsFd);
+		(*kdTsFuncs->Fini) (kdTsFd);
+		kdTsFd = -1;
+	    }
+#endif
 	}
 	break;
     }
@@ -241,14 +292,16 @@
 static void
 KdBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something)
 {
-    (*kdKeyboardFuncs->Bell) (volume, kdBellPitch, kdBellDuration);
+    if (kdInputEnabled)
+	(*kdKeyboardFuncs->Bell) (volume, kdBellPitch, kdBellDuration);
 }
 
 
 static void
 KdSetLeds (void)
 {
-    (*kdKeyboardFuncs->Leds) (kdLeds);
+    if (kdInputEnabled)
+	(*kdKeyboardFuncs->Leds) (kdLeds);
 }
 
 void
@@ -259,6 +312,12 @@
     KdSetLeds ();
 }
 
+void
+KdSetMouseMatrix (KdMouseMatrix *matrix)
+{
+    kdMouseMatrix = *matrix;
+}
+
 static void
 KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
 {
@@ -297,7 +356,7 @@
 	if (kdKeyboardFuncs)
 	{
 	    kdKeyboardFd = (*kdKeyboardFuncs->Init) ();
-	    if (kdKeyboardFd >= 0)
+	    if (kdKeyboardFd >= 0 && kdInputEnabled)
 		KdAddFd (kdKeyboardFd);
 	}
 	break;
@@ -309,7 +368,8 @@
 	    pDev->on = FALSE;
 	    if (kdKeyboardFd >= 0)
 	    {
-		KdRemoveFd (kdKeyboardFd);
+		if (kdInputEnabled)
+		    KdRemoveFd (kdKeyboardFd);
 		(*kdKeyboardFuncs->Fini) (kdKeyboardFd);
 		kdKeyboardFd = -1;
 	    }
@@ -342,6 +402,35 @@
     }
 }
 
+const KdKeySymModsRec kdKeySymMods[] = {
+  XK_Control_L,	ControlMask,
+  XK_Control_R, ControlMask,
+  XK_Shift_L,	ShiftMask,
+  XK_Shift_R,	ShiftMask,
+  XK_Caps_Lock,	LockMask,
+  XK_Shift_Lock, LockMask,
+  XK_Alt_L,	Mod1Mask,
+  XK_Alt_R,	Mod1Mask,
+  XK_Meta_L,	Mod1Mask,
+  XK_Meta_R,	Mod1Mask,
+  XK_Num_Lock,	Mod2Mask,
+  XK_Super_L,	Mod3Mask,
+  XK_Super_R,	Mod3Mask,
+  XK_Hyper_L,	Mod3Mask,
+  XK_Hyper_R,	Mod3Mask,
+  XK_Mode_switch, Mod4Mask,
+#ifdef TOUCHSCREEN
+  /* iPAQ specific hacks */
+  XF86XK_Start, ControlMask,
+  XK_Menu, ShiftMask,
+  XF86XK_Calendar, LockMask,
+  XK_telephone, Mod1Mask,
+  XF86XK_AudioRecord, Mod2Mask,
+#endif
+};
+
+#define NUM_SYM_MODS (sizeof(kdKeySymMods) / sizeof(kdKeySymMods[0]))
+
 static void
 KdInitModMap (void)
 {
@@ -349,6 +438,7 @@
     int	    row;
     int	    width;
     KeySym  *syms;
+    int	    i;
 
     width = kdKeySyms.mapWidth;
     for (key_code = kdMinKeyCode; key_code <= kdMaxKeyCode; key_code++)
@@ -357,37 +447,10 @@
 	syms = kdKeymap + (key_code - kdMinKeyCode) * width;
 	for (row = 0; row < width; row++, syms++)
 	{
-	    switch (*syms) {
-	    case XK_Control_L:
-	    case XK_Control_R:
-		kdModMap[key_code] |= ControlMask;
-		break;
-	    case XK_Shift_L:
-	    case XK_Shift_R:
-		kdModMap[key_code] |= ShiftMask;
-		break;
-	    case XK_Caps_Lock:
-	    case XK_Shift_Lock:
-		kdModMap[key_code] |= LockMask;
-		break;
-	    case XK_Alt_L:
-	    case XK_Alt_R:
-	    case XK_Meta_L:
-	    case XK_Meta_R:
-		kdModMap[key_code] |= Mod1Mask;
-		break;
-	    case XK_Num_Lock:
-		kdModMap[key_code] |= Mod2Mask;
-		break;
-	    case XK_Super_L:
-	    case XK_Super_R:
-	    case XK_Hyper_L:
-	    case XK_Hyper_R:
-		kdModMap[key_code] |= Mod3Mask;
-		break;
-	    case XK_Mode_switch:
-		kdModMap[key_code] |= Mod4Mask;
-		break;
+	    for (i = 0; i < NUM_SYM_MODS; i++) 
+	    {
+		if (*syms == kdKeySymMods[i].modsym) 
+		    kdModMap[key_code] |= kdKeySymMods[i].modbit;
 	    }
 	}
     }
@@ -413,6 +476,7 @@
     kdLeds = 0;
     kdBellPitch = 1000;
     kdBellDuration = 200;
+    kdInputEnabled = TRUE;
     KdInitModMap ();
     KdInitAutoRepeats ();
     KdResetInputMachine ();
@@ -431,6 +495,14 @@
 #endif
 }
 
+#ifdef TOUCHSCREEN
+void
+KdInitTouchScreen(KdTsFuncs *pTsFuncs)
+{
+    kdTsFuncs = pTsFuncs;
+}
+#endif
+
 /*
  * Middle button emulation state machine
  *
@@ -710,7 +782,7 @@
 int		kdEmulationDx, kdEmulationDy;
 
 #define EMULATION_WINDOW    10
-#define EMULATION_TIMEOUT   30
+#define EMULATION_TIMEOUT   100
 
 #define EventX(e)   ((e)->u.keyButtonPointer.rootX)
 #define EventY(e)   ((e)->u.keyButtonPointer.rootY)
@@ -997,6 +1069,7 @@
     xEvent  xE;
     int	    key;
 
+    KdBlockSigio ();
     for (key = 0; key < KD_KEY_COUNT; key++)
 	if (IsKeyDown(key))
 	{
@@ -1005,6 +1078,7 @@
 	    xE.u.u.detail = key;
 	    KdHandleKeyboardEvent (&xE);
 	}
+    KdUnblockSigio ();
 }
 
 void
@@ -1081,12 +1155,19 @@
 	    {
 		return;
 	    }
+	    /*
+	     * X delivers press/release even for autorepeat
+	     */
+	    xE.u.u.type = KeyRelease;
+	    KdHandleKeyboardEvent (&xE);
+	    xE.u.u.type = KeyPress;
 	}
-	if (xE.u.u.type == KeyRelease && !IsKeyDown (key_code))
+	/*
+	 * Check released keys which are already up
+	 */
+	else if (!IsKeyDown (key_code) && xE.u.u.type == KeyRelease)
 	{
-	    xE.u.u.type = KeyPress;
-	    KdHandleKeyboardEvent (&xE);
-	    xE.u.u.type = KeyRelease;
+	    return;
 	}
 	KdCheckSpecialKeys (&xE);
 	KdHandleKeyboardEvent (&xE);
@@ -1125,11 +1206,13 @@
 }
 
 void
-KdEnqueueMouseEvent(unsigned long flags, int x, int y)
+KdEnqueueMouseEvent(unsigned long flags, int rx, int ry)
 {
     CARD32  ms;
     xEvent  xE;
     unsigned char	buttons;
+    int	    x, y;
+    int	    (*matrix)[3] = kdMouseMatrix.matrix;
 
     if (!pKdPointer)
 	return;
@@ -1138,12 +1221,18 @@
     
     if (flags & KD_MOUSE_DELTA)
     {
+	x = matrix[0][0] * rx + matrix[0][1] * ry;
+	y = matrix[1][0] * rx + matrix[1][1] * ry;
 	x = KdMouseAccelerate (pKdPointer, x);
 	y = KdMouseAccelerate (pKdPointer, y);
 	xE.u.keyButtonPointer.pad1 = 1;
     }
     else
+    {
+	x = matrix[0][0] * rx + matrix[0][1] * ry + matrix[0][2];
+	y = matrix[1][0] * rx + matrix[1][1] * ry + matrix[1][2];
 	xE.u.keyButtonPointer.pad1 = 0;
+    }
     xE.u.keyButtonPointer.time = ms;
     xE.u.keyButtonPointer.rootX = x;
     xE.u.keyButtonPointer.rootY = y;
@@ -1241,22 +1330,34 @@
 void
 KdWakeupHandler (int		screen, 
 		 pointer    	data,
-		 unsigned long	result,
+		 unsigned long	lresult,
 		 pointer	readmask)
 {
+    int	    result = (int) lresult;
     fd_set  *pReadmask = (fd_set *) readmask;
     
-    if (kdMouseFd >= 0 && FD_ISSET (kdMouseFd, pReadmask))
+    if (kdInputEnabled && result > 0)
     {
-	KdBlockSigio ();
-	(*kdMouseFuncs->Read) (kdMouseFd);
-	KdUnblockSigio ();
-    }
-    if (kdKeyboardFd >= 0 && FD_ISSET (kdKeyboardFd, pReadmask))
-    {
-	KdBlockSigio ();
-	(*kdKeyboardFuncs->Read) (kdKeyboardFd);
-	KdUnblockSigio ();
+	if (kdMouseFd >= 0 && FD_ISSET (kdMouseFd, pReadmask))
+	{
+	    KdBlockSigio ();
+	    (*kdMouseFuncs->Read) (kdMouseFd);
+	    KdUnblockSigio ();
+	}
+#ifdef TOUCHSCREEN
+	if (kdTsFd >= 0 && FD_ISSET (kdTsFd, pReadmask))
+	{
+	    KdBlockSigio ();
+	    (*kdTsFuncs->Read) (kdTsFd);
+	    KdUnblockSigio ();
+	}
+#endif
+	if (kdKeyboardFd >= 0 && FD_ISSET (kdKeyboardFd, pReadmask))
+	{
+	    KdBlockSigio ();
+	    (*kdKeyboardFuncs->Read) (kdKeyboardFd);
+	    KdUnblockSigio ();
+	}
     }
     if (kdTimeoutPending)
     {
@@ -1277,25 +1378,44 @@
 {
     ScreenPtr	pScreen  = *ppScreen;
     int		n;
+    CARD32	ms;
     
     if (kdDisableZaphod || screenInfo.numScreens <= 1)
 	return FALSE;
-    if (*x < 0)
+    if (*x < 0 || *y < 0)
     {
+        ms = GetTimeInMillis ();
+	if (kdOffScreen && (int) (ms - kdOffScreenTime) < 1000)
+	    return FALSE;
+	kdOffScreen = TRUE;
+	kdOffScreenTime = ms;
+	
 	n = pScreen->myNum - 1;
 	if (n < 0)
 	    n = screenInfo.numScreens - 1;
 	pScreen = screenInfo.screens[n];
-	*x += pScreen->width;
+	if (*x < 0)
+	    *x += pScreen->width;
+	if (*y < 0)
+	    *y += pScreen->height;
 	*ppScreen = pScreen;
 	return TRUE;
     }
-    else if (*x >= pScreen->width)
+    else if (*x >= pScreen->width || *y >= pScreen->height)
     {
+        ms = GetTimeInMillis ();
+	if (kdOffScreen && (int) (ms - kdOffScreenTime) < 1000)
+	    return FALSE;
+	kdOffScreen = TRUE;
+	kdOffScreenTime = ms;
+	
 	n = pScreen->myNum + 1;
 	if (n >= screenInfo.numScreens)
 	    n = 0;
-	*x -= pScreen->width;
+	if (*x >= pScreen->width)
+	    *x -= pScreen->width;
+	if (*y >= pScreen->height)
+	    *y -= pScreen->height;
 	pScreen = screenInfo.screens[n];
 	*ppScreen = pScreen;
 	return TRUE;
Index: xc/programs/Xserver/hw/kdrive/kkeymap.h
diff -u xc/programs/Xserver/hw/kdrive/kkeymap.h:1.2 xc/programs/Xserver/hw/kdrive/kkeymap.h:1.3
--- xc/programs/Xserver/hw/kdrive/kkeymap.h:1.2	Wed Feb 23 15:29:54 2000
+++ xc/programs/Xserver/hw/kdrive/kkeymap.h	Tue Sep 26 00:29:54 2000
@@ -21,14 +21,14 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kkeymap.h,v 1.2 2000/02/23 20:29:54 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kkeymap.h,v 1.3 2000/09/26 04:29:54 keithp Exp $ */
 /*
  *  All global variables and functions pertaining to keyboard key mapping
  *  live in this header file.
  */
 
-#ifndef _KDKEYMP_H
-#define _KDKEYMP_H
+#ifndef _KKEYMAP_H
+#define _KKEYMAP_H
 
 /* Offset of MIN_SCANCODE to 8 (X minimum scancode value) */
 #define KD_KEY_OFFSET	(8 - kdMinScanCode)
@@ -50,4 +50,9 @@
     
 extern KeySymsRec	kdKeySyms;
 
-#endif /* _WINKEYMP_H */
+typedef struct {
+    KeySym  modsym;
+    int	    modbit;
+} KdKeySymModsRec;
+
+#endif /* _KKEYMAP_H */
Index: xc/programs/Xserver/hw/kdrive/kmap.c
diff -u xc/programs/Xserver/hw/kdrive/kmap.c:1.3 xc/programs/Xserver/hw/kdrive/kmap.c:1.6
--- xc/programs/Xserver/hw/kdrive/kmap.c:1.3	Wed Feb 23 15:29:55 2000
+++ xc/programs/Xserver/hw/kdrive/kmap.c	Wed Dec 13 13:06:54 2000
@@ -21,14 +21,21 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kmap.c,v 1.3 2000/02/23 20:29:55 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kmap.c,v 1.6 2000/12/13 18:06:54 keithp Exp $ */
 
 #include "kdrive.h"
 
 #ifdef linux
+#ifdef __i386__
+#define HAS_MTRR
+#endif
+#endif
+
 #include <errno.h>
 #include <unistd.h>
 #include <sys/mman.h>
+#ifdef HAS_MTRR
+#include <asm/mtrr.h>
 #endif
 
 void *
@@ -90,3 +97,72 @@
 #endif
 }
 
+#ifdef HAS_MTRR
+static int  mtrr;
+#endif
+
+void
+KdSetMappedMode (CARD32 addr, CARD32 size, int mode)
+{
+#ifdef HAS_MTRR
+    struct mtrr_sentry  sentry;
+    unsigned long    	base, bound;
+    unsigned int	type;
+
+    if (addr < 0x100000)
+	return;
+    if (!mtrr)
+	mtrr = open ("/proc/mtrr", 2);
+    if (mtrr > 0)
+    {
+	base = addr & ~((1<22)-1);
+	bound = ((addr + size) + ((1<<22) - 1)) & ~((1<<22) - 1);
+	switch (mode) {
+	case KD_MAPPED_MODE_REGISTERS:
+	    type = MTRR_TYPE_UNCACHABLE;
+	    break;
+	case KD_MAPPED_MODE_FRAMEBUFFER:
+	    type = MTRR_TYPE_WRCOMB;
+	    break;
+	}
+	sentry.base = base;
+	sentry.size = bound - base;
+	sentry.type = type;
+	
+	ioctl (mtrr, MTRRIOC_ADD_ENTRY, &sentry);
+    }
+#endif
+}
+
+void
+KdResetMappedMode (CARD32 addr, CARD32 size, int mode)
+{
+#ifdef HAS_MTRR
+    struct mtrr_sentry  sentry;
+    unsigned long    	base, bound;
+    unsigned int	type;
+
+    if (addr < 0x100000)
+	return;
+    if (!mtrr)
+	mtrr = open ("/proc/mtrr", 2);
+    if (mtrr > 0)
+    {
+	base = addr & ~((1<22)-1);
+	bound = ((addr + size) + ((1<<22) - 1)) & ~((1<<22) - 1);
+	switch (mode) {
+	case KD_MAPPED_MODE_REGISTERS:
+	    type = MTRR_TYPE_UNCACHABLE;
+	    break;
+	case KD_MAPPED_MODE_FRAMEBUFFER:
+	    type = MTRR_TYPE_WRCOMB;
+	    break;
+	}
+	sentry.base = base;
+	sentry.size = bound - base;
+	sentry.type = type;
+	
+	ioctl (mtrr, MTRRIOC_DEL_ENTRY, &sentry);
+    }
+#endif
+}
Index: xc/programs/Xserver/hw/kdrive/kpict.c
diff -u /dev/null xc/programs/Xserver/hw/kdrive/kpict.c:1.3
--- /dev/null	Mon Dec 18 14:28:47 2000
+++ xc/programs/Xserver/hw/kdrive/kpict.c	Fri Sep 15 11:19:00 2000
@@ -0,0 +1,64 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/kpict.c,v 1.3 2000/09/15 15:19:00 keithp Exp $
+ *
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "kdrive.h"
+#include "picturestr.h"
+
+void
+KdCheckComposite (CARD8      op,
+		  PicturePtr pSrc,
+		  PicturePtr pMask,
+		  PicturePtr pDst,
+		  INT16      xSrc,
+		  INT16      ySrc,
+		  INT16      xMask,
+		  INT16      yMask,
+		  INT16      xDst,
+		  INT16      yDst,
+		  CARD16     width,
+		  CARD16     height)
+{
+    KdCheckSync (pDst->pDrawable->pScreen);
+    fbComposite (op,
+		 pSrc,
+		 pMask,
+		 pDst,
+		 xSrc,
+		 ySrc,
+		 xMask,
+		 yMask,
+		 xDst,
+		 yDst,
+		 width,
+		 height);
+}
+
+void
+KdPictureInitAsync (ScreenPtr pScreen)
+{
+    PictureScreenPtr    ps;
+
+    ps = GetPictureScreen(pScreen);
+    ps->Composite = KdCheckComposite;
+}
Index: xc/programs/Xserver/hw/kdrive/kshadow.c
diff -u /dev/null xc/programs/Xserver/hw/kdrive/kshadow.c:1.3
--- /dev/null	Mon Dec 18 14:28:48 2000
+++ xc/programs/Xserver/hw/kdrive/kshadow.c	Wed Sep 27 16:47:37 2000
@@ -0,0 +1,55 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/kshadow.c,v 1.3 2000/09/27 20:47:37 keithp Exp $
+ *
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "kdrive.h"
+
+Bool
+KdShadowScreenInit (KdScreenInfo *screen)
+{
+    void    *buf;
+
+    buf = shadowAlloc (screen->width, screen->height, screen->fb[0].bitsPerPixel);
+    if (!buf)
+	return FALSE;
+    screen->fb[0].frameBuffer = buf;
+    screen->fb[0].byteStride = BitmapBytePad (screen->width * screen->fb[0].bitsPerPixel);
+    screen->fb[0].pixelStride = screen->fb[0].byteStride * 8 / screen->fb[0].bitsPerPixel;
+    screen->dumb = TRUE;
+    return TRUE;
+}
+
+Bool
+KdShadowInitScreen (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window)
+{
+    KdScreenPriv(pScreen);
+
+    return shadowInit (pScreen, update, window);
+}
+
+void
+KdShadowScreenFini (KdScreenInfo *screen)
+{
+    if (screen->fb[0].frameBuffer)
+	xfree (screen->fb[0].frameBuffer);
+}
Index: xc/programs/Xserver/hw/kdrive/fbdev/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/fbdev/Imakefile:1.1 xc/programs/Xserver/hw/kdrive/fbdev/Imakefile:1.3
--- xc/programs/Xserver/hw/kdrive/fbdev/Imakefile:1.1	Fri Nov 19 08:53:52 1999
+++ xc/programs/Xserver/hw/kdrive/fbdev/Imakefile	Thu Nov 30 19:01:31 2000
@@ -1,15 +1,15 @@
 XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/Imakefile,v 1.1 1999/11/19 13:53:52 hohndel Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/Imakefile,v 1.3 2000/12/01 00:01:31 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
 
 SRCS = 	fbdev.c fbinit.c
 
 OBJS = 	fbdev.o fbinit.o
 
-INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../../fb -I../../../mi -I../../../include -I../../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+INCLUDES = $(KDINCS) -I.
 
 NormalLibraryObjectRule()
 NormalLibraryTarget(fbdev,$(OBJS))
+InstallManPage(Xfbdev,$(MANDIR))
 DependTarget()
Index: xc/programs/Xserver/hw/kdrive/fbdev/Xfbdev.man
diff -u /dev/null xc/programs/Xserver/hw/kdrive/fbdev/Xfbdev.man:1.2
--- /dev/null	Mon Dec 18 14:28:48 2000
+++ xc/programs/Xserver/hw/kdrive/fbdev/Xfbdev.man	Mon Dec  4 16:01:00 2000
@@ -0,0 +1,28 @@
+.\" $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/Xfbdev.man,v 1.2 2000/12/04 21:01:00 dawes Exp $
+.\"
+.TH Xfbdev 1
+.SH NAME
+Xvesa \- Linux framebuffer device tiny X server
+.SH SYNOPSIS
+.B Xfbdev
+.RI [ :display ] 
+.RI [ option ...]
+.SH DESCRIPTION
+.B Xfbdev
+is a generic X server for Linux.
+.B Xfbdev
+doesn't know about any particular hardware, and uses the framebuffer
+provided by the Linux framebuffer device.
+.SH OPTIONS
+.B Xfbdev
+accepts the common options of the Xkdrive family of servers.  Please
+see Xkdrive(1).
+.SH KEYBOARD
+To be written.
+.SH SEE ALSO
+X(1), Xserver(1), Xkdrive(1), xdm(1), xinit(1).
+.SH AUTHORS
+The
+.B Xfbdev
+server was written by Keith Packard.
+
Index: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c
diff -u xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c:1.4 xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c:1.10
--- xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c:1.4	Sat May  6 18:17:41 2000
+++ xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c	Tue Oct  3 13:22:14 2000
@@ -21,14 +21,18 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.4 2000/05/06 22:17:41 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.10 2000/10/03 17:22:14 keithp Exp $ */
 
 #include "fbdev.h"
 
+/* this code was used to debug MSB 24bpp code on a 16bpp frame buffer */
+#undef FAKE24_ON_16
+
 Bool
 fbdevInitialize (KdCardInfo *card, FbdevPriv *priv)
 {
-    int	    k;
+    int		    k;
+    unsigned long   off;
     if ((priv->fd = open("/dev/fb0", O_RDWR)) < 0) {
 	perror("Error opening /dev/fb0\n");
 	return FALSE;
@@ -44,18 +48,21 @@
 	return FALSE;
     }
 
-    priv->fb = (unsigned char *) mmap ((caddr_t) NULL,
-				       priv->fix.smem_len,
-				       PROT_READ|PROT_WRITE,
-				       MAP_SHARED,
-				       priv->fd, 0);
+    priv->fb_base = (unsigned char *) mmap ((caddr_t) NULL,
+					    priv->fix.smem_len,
+					    PROT_READ|PROT_WRITE,
+					    MAP_SHARED,
+					    priv->fd, 0);
     
-    if (priv->fb == (char *)-1) 
+    if (priv->fb_base == (char *)-1) 
     {
         perror("ERROR: mmap framebuffer fails!");
 	close (priv->fd);
 	return FALSE;
     }
+    off = (unsigned long) priv->fix.smem_start % (unsigned long) getpagesize();
+    priv->fb = priv->fb_base + off;
+    return TRUE;
 }
 
 Bool
@@ -80,19 +87,19 @@
 }
 
 Bool
-fbdevScreenInit (KdScreenInfo *screen)
+fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
 {
     FbdevPriv	*priv = screen->card->driver;
     Pixel	allbits;
     int		depth;
+    Bool	rotate;
+    Bool	shadow;
+#ifdef FAKE24_ON_16
+    Bool	fake24;
+#endif
 
-    screen->width = priv->var.xres;
-    screen->height = priv->var.yres;
-    screen->fb[0].depth = priv->var.bits_per_pixel;
-    screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel;
-    screen->fb[0].byteStride = priv->fix.line_length;
-    screen->fb[0].pixelStride = (priv->fix.line_length * 8 / 
-			   priv->var.bits_per_pixel);
+    depth = priv->var.bits_per_pixel;
+    
     switch (priv->fix.visual) {
     case FB_VISUAL_PSEUDOCOLOR:
 	screen->fb[0].visuals = ((1 << StaticGray) |
@@ -106,28 +113,219 @@
 	screen->fb[0].redMask   = 0x00;
 	break;
     case FB_VISUAL_TRUECOLOR:
+    case FB_VISUAL_DIRECTCOLOR:
 	screen->fb[0].visuals = (1 << TrueColor);
-	screen->fb[0].redMask = FbStipMask (priv->var.red.offset, priv->var.red.length);
-	screen->fb[0].greenMask = FbStipMask (priv->var.green.offset, priv->var.green.length);
-	screen->fb[0].blueMask = FbStipMask (priv->var.blue.offset, priv->var.blue.length);
+#define Mask(o,l)   (((1 << l) - 1) << o)
+	screen->fb[0].redMask = Mask (priv->var.red.offset, priv->var.red.length);
+	screen->fb[0].greenMask = Mask (priv->var.green.offset, priv->var.green.length);
+	screen->fb[0].blueMask = Mask (priv->var.blue.offset, priv->var.blue.length);
 	allbits = screen->fb[0].redMask | screen->fb[0].greenMask | screen->fb[0].blueMask;
 	depth = 32;
 	while (depth && !(allbits & (1 << (depth - 1))))
 	    depth--;
-	screen->fb[0].depth = depth;
 	break;
     default:
 	return FALSE;
 	break;
     }
     screen->rate = 72;
-    screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
+    scrpriv->rotate = ((priv->var.xres < priv->var.yres) != 
+		       (screen->width < screen->height));
+#ifdef FAKE24_ON_16
+    if (screen->fb[0].depth == 24 && screen->fb[0].bitsPerPixel == 24 &&
+	priv->var.bits_per_pixel == 16)
+    {
+	fake24 = TRUE;
+	scrpriv->shadow = TRUE;
+	scrpriv->rotate = FALSE;
+	screen->fb[0].redMask = 0xff0000;
+	screen->fb[0].greenMask = 0x00ff00;
+	screen->fb[0].blueMask = 0x0000ff;
+	screen->width = priv->var.xres;
+	screen->height = priv->var.yres;
+	screen->softCursor = TRUE;
+    }
+    else
+#endif
+    {
+	screen->fb[0].depth = depth;
+	screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel;
+	if (!scrpriv->rotate)
+	{
+	    screen->width = priv->var.xres;
+	    screen->height = priv->var.yres;
+	    screen->fb[0].byteStride = priv->fix.line_length;
+	    screen->fb[0].pixelStride = (priv->fix.line_length * 8 / 
+					 priv->var.bits_per_pixel);
+	    screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
+	    return TRUE;
+	}
+	else
+	{
+	    screen->width = priv->var.yres;
+	    screen->height = priv->var.xres;
+	    screen->softCursor = TRUE;
+	}
+    }
+    if (scrpriv->rotate)
+	scrpriv->shadow = TRUE;
+    if (scrpriv->shadow)
+	return KdShadowScreenInit (screen);
     return TRUE;
 }
 
 Bool
+fbdevScreenInit (KdScreenInfo *screen)
+{
+    FbdevScrPriv *scrpriv;
+
+    scrpriv = xalloc (sizeof (FbdevScrPriv));
+    if (!scrpriv)
+	return FALSE;
+    memset (scrpriv, '\0', sizeof (FbdevScrPriv));
+    if (!fbdevScreenInitialize (screen, scrpriv))
+    {
+	xfree (scrpriv);
+	return FALSE;
+    }
+    screen->driver = scrpriv;
+    return TRUE;
+}
+    
+void *
+fbdevWindowLinear (ScreenPtr	pScreen,
+		   CARD32	row,
+		   CARD32	offset,
+		   int		mode,
+		   CARD32	*size)
+{
+    KdScreenPriv(pScreen);
+    FbdevPriv	    *priv = pScreenPriv->card->driver;
+
+    if (!pScreenPriv->enabled)
+	return 0;
+    *size = priv->fix.line_length;
+    return (CARD8 *) priv->fb + row * priv->fix.line_length + offset;
+}
+
+#ifdef FAKE24_ON_16
+void
+fbdevUpdateFake24 (ScreenPtr pScreen,
+		   PixmapPtr pShadow,
+		   RegionPtr damage)
+{
+    shadowScrPriv(pScreen);
+    int		nbox = REGION_NUM_RECTS (damage);
+    BoxPtr	pbox = REGION_RECTS (damage);
+    FbBits	*shaBits;
+    CARD8	*shaBase, *shaLine, *sha;
+    CARD16	s;
+    FbStride	shaStride;
+    int		scrBase, scrLine, scr;
+    int		shaBpp;
+    int		x, y, w, h, width;
+    int         i;
+    CARD16	*winBase, *winLine, *win;
+    CARD32      winSize;
+
+    fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp);
+    shaStride = shaStride * sizeof (FbBits) / sizeof (CARD8);
+    shaBase = (CARD8 *) shaBits;
+    while (nbox--)
+    {
+	x = pbox->x1;
+	y = pbox->y1;
+	w = (pbox->x2 - pbox->x1);
+	h = pbox->y2 - pbox->y1;
+
+	shaLine = shaBase + y * shaStride + x * 3;
+				   
+	while (h--)
+	{
+	    winSize = 0;
+	    scrBase = 0;
+	    width = w;
+	    scr = x;
+	    sha = shaLine;
+	    while (width) {
+		/* how much remains in this window */
+		i = scrBase + winSize - scr;
+		if (i <= 0 || scr < scrBase)
+		{
+		    winBase = (CARD16 *) (*pScrPriv->window) (pScreen,
+							      y,
+							      scr * sizeof (CARD16),
+							      SHADOW_WINDOW_WRITE,
+							      &winSize);
+		    if(!winBase)
+			return;
+		    scrBase = scr;
+		    winSize /= sizeof (CARD16);
+		    i = winSize;
+		}
+		win = winBase + (scr - scrBase);
+		if (i > width)
+		    i = width;
+		width -= i;
+		scr += i;
+		while (i--)
+		{
+#if IMAGE_BYTE_ORDER == MSBFirst
+		    *win++ = ((sha[2] >> 3) | 
+			      ((sha[1] & 0xf8) << 2) |
+			      ((sha[0] & 0xf8) << 7));
+#else
+		    *win++ = ((sha[0] >> 3) | 
+			      ((sha[1] & 0xfc) << 3) |
+			      ((sha[2] & 0xf8) << 8));
+#endif
+		    sha += 3;
+		}
+	    }
+	    shaLine += shaStride;
+	    y++;
+	}
+	pbox++;
+    }
+}
+#endif /* FAKE24_ON_16 */
+
+Bool
 fbdevInitScreen (ScreenPtr pScreen)
 {
+    KdScreenPriv(pScreen);
+    FbdevPriv		*priv = pScreenPriv->card->driver;
+    FbdevScrPriv	*scrpriv = pScreenPriv->screen->driver;
+    ShadowUpdateProc	update;
+    ShadowWindowProc	window;
+
+    if (scrpriv->shadow)
+    {
+        window = fbdevWindowLinear;
+#ifdef FAKE24_ON_16
+	if (pScreenPriv->screen->fb[0].bitsPerPixel == 24 && priv->var.bits_per_pixel == 16)
+	{
+	    update = fbdevUpdateFake24;
+	}
+	else
+#endif /* FAKE24_ON_16 */
+	{
+	    update = shadowUpdatePacked;
+	    if (scrpriv->rotate)
+	    {
+		window = fbdevWindowLinear;
+		switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+		case 8:
+		    update = shadowUpdateRotate8; break;
+		case 16:
+		    update = shadowUpdateRotate16; break;
+		case 32:
+		    update = shadowUpdateRotate32; break;
+		}
+	    }
+	}
+	return KdShadowInitScreen (pScreen, update, window);
+    }
     return TRUE;
 }
 
@@ -136,19 +334,58 @@
 {
 }
 
-void
+Bool
 fbdevEnable (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
     FbdevPriv	*priv = pScreenPriv->card->driver;
-    int		k;
+    FbdevScrPriv	*scrpriv = pScreenPriv->screen->driver;
+    int			k;
+    KdMouseMatrix	m;
 
     priv->var.activate = FB_ACTIVATE_NOW|FB_CHANGE_CMAP_VBL;
     
     /* display it on the LCD */
     k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &priv->var);
     if (k < 0)
+    {
 	perror ("FBIOPUT_VSCREENINFO");
+	return FALSE;
+    }
+    if (scrpriv->rotate)
+    {
+	m.matrix[0][0] = 0; m.matrix[0][1] = 1; m.matrix[0][2] = 0;
+	m.matrix[1][0] = -1; m.matrix[1][1] = 0; m.matrix[1][2] = pScreen->height - 1;
+    }
+    else
+    {
+	m.matrix[0][0] = 1; m.matrix[0][1] = 0; m.matrix[0][2] = 0;
+	m.matrix[1][0] = 0; m.matrix[1][1] = 1; m.matrix[1][2] = 0;
+    }
+    if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR)
+    {
+	struct fb_cmap	cmap;
+	int		i;
+
+	for (i = 0; 
+	     i < (1 << priv->var.red.length) ||
+	     i < (1 << priv->var.green.length) ||
+	     i < (1 << priv->var.blue.length); i++)
+	{
+	    priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1);
+	    priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1);
+	    priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1);
+	}
+	cmap.start = 0;
+	cmap.len = i;
+	cmap.red = &priv->red[0];
+	cmap.green = &priv->green[0];
+	cmap.blue = &priv->blue[0];
+	cmap.transp = 0;
+	ioctl (priv->fd, FBIOPUTCMAP, &cmap);
+    }
+    KdSetMouseMatrix (&m);
+    return TRUE;
 }
 
 Bool
@@ -158,9 +395,13 @@
     FbdevPriv	*priv = pScreenPriv->card->driver;
 
 #ifdef FBIOPUT_POWERMODE
-    if (!ioctl (priv->fd, FBIOPUT_POWERMODE, &mode))
+    if (ioctl (priv->fd, FBIOPUT_POWERMODE, &mode) >= 0)
 	return TRUE;
 #endif
+#ifdef FBIOBLANK
+    if (ioctl (priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0)
+	return TRUE;
+#endif
     return FALSE;
 }
 
@@ -177,6 +418,10 @@
 void
 fbdevScreenFini (KdScreenInfo *screen)
 {
+    FbdevScrPriv	*scrpriv = screen->driver;
+    
+    if (scrpriv->shadow)
+	KdShadowScreenFini (screen);
 }
 
 void
@@ -185,7 +430,7 @@
     int	k;
     FbdevPriv	*priv = card->driver;
     
-    munmap (priv->fb, priv->fix.smem_len);
+    munmap (priv->fb_base, priv->fix.smem_len);
     close (priv->fd);
     xfree (priv);
 }
Index: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h
diff -u xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h:1.4 xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h:1.8
--- xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h:1.4	Sat May  6 18:17:42 2000
+++ xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h	Wed Sep 27 16:46:36 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h,v 1.4 2000/05/06 22:17:42 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h,v 1.8 2000/09/27 20:46:36 keithp Exp $ */
 
 #ifndef _FBDEV_H_
 #define _FBDEV_H_
@@ -39,8 +39,14 @@
     __u16			blue[256];
     int				fd;
     char			*fb;
+    char			*fb_base;
 } FbdevPriv;
     
+typedef struct _fbdevScrPriv {
+    Bool			rotate;
+    Bool			shadow;
+} FbdevScrPriv;
+
 Bool
 fbdevInitialize (KdCardInfo *card, FbdevPriv *priv);
 
@@ -51,12 +57,15 @@
 fbdevScreenInit (KdScreenInfo *screen);
 
 Bool
+fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv);
+    
+Bool
 fbdevInitScreen (ScreenPtr pScreen);
 
 void
 fbdevPreserve (KdCardInfo *card);
 
-void
+Bool
 fbdevEnable (ScreenPtr pScreen);
 
 Bool
Index: xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c
diff -u xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c:1.3 xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c:1.6
--- xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c:1.3	Wed Feb 23 15:29:58 2000
+++ xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c	Thu Sep 28 16:58:21 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c,v 1.3 2000/02/23 20:29:58 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c,v 1.6 2000/09/28 20:58:21 keithp Exp $ */
 
 #include <fbdev.h>
 
@@ -70,7 +70,14 @@
 void
 InitInput (int argc, char **argv)
 {
+#ifdef __powerpc__
+    KdInitInput (&BusMouseFuncs, &LinuxKeyboardFuncs);
+#else
     KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
+#endif
+#ifdef TOUCHSCREEN
+    KdInitTouchScreen (&TsFuncs);
+#endif
 }
 
 int
Index: xc/programs/Xserver/hw/kdrive/igs/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/igs/Imakefile:1.2 xc/programs/Xserver/hw/kdrive/igs/Imakefile:1.3
--- xc/programs/Xserver/hw/kdrive/igs/Imakefile:1.2	Wed May 24 19:52:47 2000
+++ xc/programs/Xserver/hw/kdrive/igs/Imakefile	Sun Sep  3 01:11:17 2000
@@ -1,13 +1,12 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/igs/Imakefile,v 1.2 2000/05/24 23:52:47 keithp Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/igs/Imakefile,v 1.3 2000/09/03 05:11:17 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
 
 SRCS = 	igs.c igscmap.c igscurs.c igsdraw.c igsreg.c igsstub.c
 
 OBJS = 	igs.o igscmap.o igscurs.o igsdraw.o igsreg.o igsstub.o
 
-INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../../fb -I../../../mi -I../../../include -I../../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+INCLUDES = -I. $(KDINCS)
 
 NormalLibraryObjectRule()
 NormalLibraryTarget(igs,$(OBJS))
Index: xc/programs/Xserver/hw/kdrive/igs/igs.c
diff -u xc/programs/Xserver/hw/kdrive/igs/igs.c:1.2 xc/programs/Xserver/hw/kdrive/igs/igs.c:1.3
--- xc/programs/Xserver/hw/kdrive/igs/igs.c:1.2	Wed May 24 19:52:47 2000
+++ xc/programs/Xserver/hw/kdrive/igs/igs.c	Sun Sep  3 01:11:17 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igs.c,v 1.2 2000/05/24 23:52:47 keithp Exp $
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igs.c,v 1.3 2000/09/03 05:11:17 keithp Exp $
  *
  * Copyright © 1999 SuSE, Inc.
  *
@@ -331,7 +331,7 @@
     *Pp = P;
 }
 
-void
+Bool
 igsEnable (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
@@ -562,6 +562,7 @@
 		    VgaFetch (&igsvga->card, reg));
     }
 #endif
+    return TRUE;
 }
 
 Bool
Index: xc/programs/Xserver/hw/kdrive/itsy/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/itsy/Imakefile:1.1 xc/programs/Xserver/hw/kdrive/itsy/Imakefile:1.2
--- xc/programs/Xserver/hw/kdrive/itsy/Imakefile:1.1	Fri Nov 19 08:53:53 1999
+++ xc/programs/Xserver/hw/kdrive/itsy/Imakefile	Sun Sep  3 01:11:18 2000
@@ -1,14 +1,13 @@
 XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/itsy/Imakefile,v 1.1 1999/11/19 13:53:53 hohndel Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/itsy/Imakefile,v 1.2 2000/09/03 05:11:18 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
 
 SRCS = 	itsy.c ts.c kbd.c
 
 OBJS = 	itsy.o ts.o kbd.o
 
-INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../../fb -I../../../mi -I../../../include -I../../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+INCLUDES = -I. $(KDINCS)
 
 NormalLibraryObjectRule()
 NormalLibraryTarget(itsy,$(OBJS))
Index: xc/programs/Xserver/hw/kdrive/linux/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/linux/Imakefile:1.1 xc/programs/Xserver/hw/kdrive/linux/Imakefile:1.4
--- xc/programs/Xserver/hw/kdrive/linux/Imakefile:1.1	Wed Dec 29 22:03:09 1999
+++ xc/programs/Xserver/hw/kdrive/linux/Imakefile	Tue Sep 26 00:27:49 2000
@@ -1,14 +1,18 @@
 XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/linux/Imakefile,v 1.1 1999/12/30 03:03:09 robin Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/linux/Imakefile,v 1.4 2000/09/26 04:27:49 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
 
-SRCS = keyboard.c linux.c ps2.c
+#if TouchScreen
+TSSRCS = ts.c
+TSOBJS = ts.o
+#endif
 
-OBJS = keyboard.o linux.o ps2.o
+SRCS = keyboard.c linux.c ps2.c bus.c $(TSSRCS)
 
-INCLUDES = -I. -I.. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../../fb -I../../../mi -I../../../include -I../../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+OBJS = keyboard.o linux.o ps2.o bus.o $(TSOBJS)
+
+INCLUDES = -I. $(KDINCS)
 
 NormalLibraryObjectRule()
 NormalLibraryTarget(linux,$(OBJS))
Index: xc/programs/Xserver/hw/kdrive/linux/bus.c
diff -u /dev/null xc/programs/Xserver/hw/kdrive/linux/bus.c:1.1
--- /dev/null	Mon Dec 18 14:28:52 2000
+++ xc/programs/Xserver/hw/kdrive/linux/bus.c	Fri Sep 22 02:25:09 2000
@@ -0,0 +1,92 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/linux/bus.c,v 1.1 2000/09/22 06:25:09 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+#include "Xpoll.h"
+
+/* /dev/adbmouse is a busmouse */
+
+void
+BusRead (int adbPort)
+{
+    unsigned char   buf[3];
+    unsigned char   *b;
+    int		    n;
+    int		    dx, dy;
+    unsigned long   flags;
+
+    n = read (adbPort, buf, 3);
+    if (n == 3)
+    {
+	flags = KD_MOUSE_DELTA;
+	dx = (char) buf[1];
+	dy = -(char) buf[2];
+	if ((buf[0] & 4) == 0)
+	    flags |= KD_BUTTON_1;
+	if ((buf[0] & 2) == 0)
+	    flags |= KD_BUTTON_2;
+	if ((buf[0] & 1) == 0)
+	    flags |= KD_BUTTON_3;
+        KdEnqueueMouseEvent (flags, dx, dy);
+    }
+}
+
+char	*BusNames[] = {
+    "/dev/adbmouse",
+    "/dev/mouse",
+};
+
+#define NUM_BUS_NAMES	(sizeof (BusNames) / sizeof (BusNames[0]))
+
+int
+BusInit (void)
+{
+    int	    i;
+    int	    busPort;
+
+    for (i = 0; i < NUM_BUS_NAMES; i++)
+    {
+	busPort = open (BusNames[i], 0);
+	if (busPort >= 0)
+	    return busPort;
+    }
+}
+
+void
+BusFini (int busPort)
+{
+    if (busPort >= 0)
+	close (busPort);
+}
+
+KdMouseFuncs BusMouseFuncs = {
+    BusInit,
+    BusRead,
+    BusFini
+};
Index: xc/programs/Xserver/hw/kdrive/linux/keyboard.c
diff -u xc/programs/Xserver/hw/kdrive/linux/keyboard.c:1.2 xc/programs/Xserver/hw/kdrive/linux/keyboard.c:1.5
--- xc/programs/Xserver/hw/kdrive/linux/keyboard.c:1.2	Wed Feb 23 15:30:00 2000
+++ xc/programs/Xserver/hw/kdrive/linux/keyboard.c	Fri Dec  8 18:04:57 2000
@@ -1,5 +1,5 @@
 /*
- * Id: keyboard.c,v 1.2 1999/11/08 06:22:01 keithp Exp $
+ * $XFree86: xc/programs/Xserver/hw/kdrive/linux/keyboard.c,v 1.5 2000/12/08 23:04:57 keithp Exp $
  *
  * Copyright © 1999 Keith Packard
  *
@@ -26,6 +26,7 @@
 #include "kkeymap.h"
 #include <linux/keyboard.h>
 #include <linux/kd.h>
+#define XK_PUBLISHING
 #include <X11/keysym.h>
 #include <termios.h>
 
@@ -63,7 +64,7 @@
 	XK_p,		XK_q,		XK_r,		XK_s,
 	XK_t,		XK_u,		XK_v,		XK_w,
 	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
+	XK_bar,		XK_braceright,	XK_asciitilde,	XK_BackSpace,
 	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
 	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
 	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
@@ -330,6 +331,20 @@
 		    k[j] = XK_Shift_Lock;
 		break;
 
+#ifdef KT_X
+	    case KT_X:
+		/* depends on new keyboard symbols in file linux/keyboard.h */
+		if(kbe.kb_value == K_XMENU) k[j] = XK_Menu;
+		if(kbe.kb_value == K_XTELEPHONE) k[j] = XK_telephone;
+		break;
+#endif
+#ifdef KT_XF
+	    case KT_XF:
+		/* special linux keysyms which map directly to XF86 keysyms */
+		k[j] = (kbe.kb_value & 0xFF) + 0x1008FF00;
+		break;
+#endif
+		
 	    default:
 		break;
 	    }
Index: xc/programs/Xserver/hw/kdrive/linux/linux.c
diff -u xc/programs/Xserver/hw/kdrive/linux/linux.c:1.2 xc/programs/Xserver/hw/kdrive/linux/linux.c:1.4
--- xc/programs/Xserver/hw/kdrive/linux/linux.c:1.2	Wed Feb 23 15:30:00 2000
+++ xc/programs/Xserver/hw/kdrive/linux/linux.c	Sun Aug 27 22:43:14 2000
@@ -1,5 +1,5 @@
 /*
- * Id: linux.c,v 1.2 1999/11/23 04:21:09 keithp Exp $
+ * $XFree86: xc/programs/Xserver/hw/kdrive/linux/linux.c,v 1.4 2000/08/28 02:43:14 tsi Exp $
  *
  * Copyright © 1999 Keith Packard
  *
@@ -85,8 +85,6 @@
     }
     close(fd);
 
-/*    ErrorF("(using VT number %d)\n\n", vtno); */
-
     sprintf(vtname,"/dev/tty%d",vtno); /* /dev/tty1-64 */
 
     if ((LinuxConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
@@ -184,11 +182,49 @@
 }
 
 void
-LinuxEnable (void)
+LinuxSetSwitchMode (int mode)
 {
     struct sigaction	act;
     struct vt_mode	VT;
     
+    if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0) 
+    {
+	FatalError ("LinuxInit: VT_GETMODE failed\n");
+    }
+
+    if (mode == VT_PROCESS)
+    {
+	act.sa_handler = LinuxVTRequest;
+	sigemptyset (&act.sa_mask);
+	act.sa_flags = 0;
+	act.sa_restorer = 0;
+	sigaction (SIGUSR1, &act, 0);
+    
+	VT.mode = mode;
+	VT.relsig = SIGUSR1;
+	VT.acqsig = SIGUSR1;
+    }
+    else
+    {
+	act.sa_handler = SIG_IGN;
+	sigemptyset (&act.sa_mask);
+	act.sa_flags = 0;
+	act.sa_restorer = 0;
+	sigaction (SIGUSR1, &act, 0);
+    
+	VT.mode = mode;
+	VT.relsig = 0;
+	VT.acqsig = 0;
+    }
+    if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0) 
+    {
+	FatalError("LinuxInit: VT_SETMODE failed\n");
+    }
+}
+
+void
+LinuxEnable (void)
+{
     if (enabled)
 	return;
     if (kdSwitchPending)
@@ -199,32 +235,16 @@
     /*
      * now get the VT
      */
+    LinuxSetSwitchMode (VT_AUTO);
     if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0)
     {
-	ErrorF("LinuxInit: VT_ACTIVATE failed\n");
+	FatalError("LinuxInit: VT_ACTIVATE failed\n");
     }
     if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0)
-    {
-	ErrorF("LinuxInit: VT_WAITACTIVE failed\n");
-    }
-    if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0) 
-    {
-	FatalError ("LinuxInit: VT_GETMODE failed\n");
-    }
-
-    act.sa_handler = LinuxVTRequest;
-    sigemptyset (&act.sa_mask);
-    act.sa_flags = 0;
-    act.sa_restorer = 0;
-    sigaction (SIGUSR1, &act, 0);
-
-    VT.mode = VT_PROCESS;
-    VT.relsig = SIGUSR1;
-    VT.acqsig = SIGUSR1;
-    if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0) 
     {
-	FatalError("LinuxInit: VT_SETMODE VT_PROCESS failed\n");
+	FatalError("LinuxInit: VT_WAITACTIVE failed\n");
     }
+    LinuxSetSwitchMode (VT_PROCESS);
     if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0)
     {
 	FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n");
Index: xc/programs/Xserver/hw/kdrive/linux/ts.c
diff -u /dev/null xc/programs/Xserver/hw/kdrive/linux/ts.c:1.2
--- /dev/null	Mon Dec 18 14:28:53 2000
+++ xc/programs/Xserver/hw/kdrive/linux/ts.c	Tue Sep 26 11:57:04 2000
@@ -0,0 +1,104 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/linux/ts.c,v 1.2 2000/09/26 15:57:04 tsi Exp $
+ *
+ * Derived from ps2.c by Jim Gettys
+ *
+ * Copyright © 1999 Keith Packard
+ * Copyright © 2000 Compaq Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard or Compaq not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard and Compaq makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD AND COMPAQ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, 
+ * IN NO EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+#include "Xpoll.h"
+#include <sys/ioctl.h>
+#include <linux/h3600_ts.h>	/* touch screen events */
+
+void
+TsRead (int tsPort)
+{
+    TS_EVENT	    event;
+    long	    buf[3];
+    int		    n;
+    long	    pressure;
+    long	    x, y;
+    unsigned long   flags;
+    unsigned long   buttons;
+
+    n = Ps2ReadBytes (tsPort, (char *) &event, 
+			 sizeof (event), sizeof (event));
+    if (n == sizeof (event))  
+    {
+	if (event.pressure) 
+	{
+	    flags = KD_BUTTON_1;
+	    x = event.x;
+	    y = event.y;
+	}
+	else {
+	    flags = KD_MOUSE_DELTA;
+	    x = 0;
+	    y = 0;
+	}
+	KdEnqueueMouseEvent (flags, x, y);
+    }
+}
+
+
+char	*TsNames[] = {
+  "/dev/ts",	
+  "/dev/h3600_ts" /* temporary name; note this code can try
+			   to open more than one device */
+};
+
+#define NUM_TS_NAMES	(sizeof (TsNames) / sizeof (TsNames[0]))
+
+int
+TsInit (void)
+{
+    int	    i;
+    int	    TsPort;
+
+    for (i = 0; i < NUM_TS_NAMES; i++)    
+    {
+	TsPort = open (TsNames[i], 0);
+	if (TsPort >= 0) 
+	    return TsPort;
+    }
+    perror("Touch screen not found.\n");
+    exit (1);
+}
+
+void
+TsFini (int tsPort)
+{
+    if (tsPort >= 0)
+	close (tsPort);
+}
+
+KdTsFuncs TsFuncs = {
+    TsInit,
+    TsRead,
+    TsFini
+};
Index: xc/programs/Xserver/hw/kdrive/savage/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/savage/Imakefile:1.1 xc/programs/Xserver/hw/kdrive/savage/Imakefile:1.2
--- xc/programs/Xserver/hw/kdrive/savage/Imakefile:1.1	Fri Nov 19 08:53:54 1999
+++ xc/programs/Xserver/hw/kdrive/savage/Imakefile	Sun Sep  3 01:11:18 2000
@@ -1,14 +1,13 @@
 XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/savage/Imakefile,v 1.1 1999/11/19 13:53:54 hohndel Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/savage/Imakefile,v 1.2 2000/09/03 05:11:18 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
 
 SRCS = 	s3.c s3clock.c s3cmap.c s3curs.c s3draw.c s3gc.c s3reg.c s3stub.c
 
 OBJS = 	s3.o s3clock.o s3cmap.o s3curs.o s3draw.o s3gc.o s3reg.o s3stub.o
 
-INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../../fb -I../../../mi -I../../../include -I../../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+INCLUDES = -I. $(KDINCS)
 
 NormalLibraryObjectRule()
 NormalLibraryTarget(savage,$(OBJS))
Index: xc/programs/Xserver/hw/kdrive/savage/s3.c
diff -u xc/programs/Xserver/hw/kdrive/savage/s3.c:1.4 xc/programs/Xserver/hw/kdrive/savage/s3.c:1.6
--- xc/programs/Xserver/hw/kdrive/savage/s3.c:1.4	Sat May  6 18:17:44 2000
+++ xc/programs/Xserver/hw/kdrive/savage/s3.c	Sun Sep  3 01:11:18 2000
@@ -22,7 +22,7 @@
  *
  * Author:  Keith Packard, SuSE, Inc.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.c,v 1.4 2000/05/06 22:17:44 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.c,v 1.6 2000/09/03 05:11:18 keithp Exp $ */
 
 #include "s3.h"
 
@@ -226,11 +226,12 @@
 	    screen->fb[fb].bitsPerPixel = 8;
 	}
     
-	byte_width = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
-	pixel_width = screen->width;
-	screen->fb[fb].pixelStride = pixel_width;
-	screen->fb[fb].byteStride = byte_width;
-	screen_size += byte_width * screen->height;
+        /*
+         * SGRAM requires stride % 64 == 0
+         */
+        screen->fb[fb].pixelStride = (screen->width + 63) & ~63;
+        screen->fb[fb].byteStride = screen->fb[fb].pixelStride * (screen->fb[fb].bitsPerPixel >> 3);
+        screen_size += screen->fb[fb].byteStride * screen->height;
     }
 
     return screen_size <= s3c->memory;
@@ -340,6 +341,12 @@
 	screen->fb[fb].frameBuffer = s3c->frameBuffer + screen_size;
 	screen_size += screen->fb[fb].byteStride * screen->height;
 	
+	REGION_INIT(pScreen, (&s3s->region[fb]), NullBox, 0);
+	if (screen->fb[fb].bitsPerPixel == 8)
+	    s3s->fb[ma].chroma_key = 0xff;
+	else
+	    s3s->fb[ma].chroma_key = 0;
+	
 	/*
 	 * Use remaining memory for off-screen storage, but only use
 	 * one piece (either right or bottom).
@@ -957,7 +964,7 @@
     }
 }
 
-void
+Bool
 s3Enable (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
@@ -1101,6 +1108,9 @@
     s3Set (s3vga, s3_sequential_addressing_mode, 1);
     s3Set (s3vga, s3_select_chain_4_mode, 1);
     s3Set (s3vga, s3_linear_addressing_control, 1);
+
+    s3Set (s3vga, s3_enable_gamma_correction, 0);
+
     s3Set (s3vga, s3_enable_8_bit_luts, 1);
     
     s3Set (s3vga, s3_dclk_invert, 0);
@@ -1150,7 +1160,6 @@
     s3Set (s3vga, s3_eclk_r, r);
 #endif
     
-    s3s->manage_border = FALSE;
     /*
      * Compute character lengths for horizontal timing values
      */
@@ -1189,10 +1198,6 @@
 		h_blank_start_adjust = -3;
 		h_blank_end_adjust = -4;
 		s3Set (s3vga, s3_border_select, 0);
-#if 0
-		s3s->manage_border = TRUE;
-		/*	    s3Set (s3vga, s3_border_color, pScreen->blackPixel); */
-#endif
 	    }
 	    break;
 	case 16:
@@ -1522,6 +1527,8 @@
     VgaFlush(&s3vga->card);
     VgaSetImm (&s3vga->card, s3_clock_load_imm, 1);
     VgaSetImm(&s3vga->card, s3_clock_load_imm, 0);
+
+
     if (s3s->use_streams)
     {
 	fb = s3s->fbmap[0];
@@ -1537,7 +1544,7 @@
 	    fb = s3s->fbmap[1];
 	    s3->blend_control = 5 << 24;
 	    if (s3s->fb[0].accel_bpp == 8)
-		s3->chroma_key_control = 0x330000ff;
+		s3->chroma_key_control = 0x33000000 | s3s->fb[0].chroma_key;
 	    else
 		s3->chroma_key_control = 0x13010101;
 	    s3->secondary_stream_control = control[1] | screen->width;
@@ -1660,6 +1667,7 @@
 	}
     }
 #endif
+    return TRUE;
 }
 
 void
@@ -1758,97 +1766,26 @@
     return TRUE;
 }
 
-void
-s3DumbPaintChromaKey (WindowPtr pWin, RegionPtr pRegion)
+Bool
+s3InitScreen(ScreenPtr pScreen)
 {
-    ScreenPtr	pScreen = pWin->drawable.pScreen;
     KdScreenPriv(pScreen);
     KdCardInfo	    *card = pScreenPriv->card;
     KdScreenInfo    *screen = pScreenPriv->screen;
     s3CardInfo (pScreenPriv);
     s3ScreenInfo (pScreenPriv);
-    
-    if (pWin->drawable.depth != s3s->primary_depth)
+    int		ma, fb;
+
+    if (screen->fb[1].depth)
     {
-	int	    nBox = REGION_NUM_RECTS(pRegion);
-	BoxPtr	    pBox = REGION_RECTS(pRegion);
-	PixmapPtr   pPixmap;
-	FbOverlayScrPrivPtr	pScrPriv = fbOverlayGetScrPriv(pScreen);
-	FbBits	    *dst;
-	FbStride    dstStride;
-	int	    dstBpp;
+	FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
 
-	if (pScrPriv->pLayer[0]->drawable.depth == pWin->drawable.depth)
-	    pPixmap = pScrPriv->pLayer[1];
-	else
-	    pPixmap = pScrPriv->pLayer[0];
-	fbGetDrawable (&pPixmap->drawable, dst, dstStride, dstBpp);
-	while (nBox--)
+	for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
 	{
-	    fbSolid (dst + pBox->y1 * dstStride,
-		     dstStride,
-		     pBox->x1 * dstBpp,
-		     dstBpp,
-		     (pBox->x2 - pBox->x1) * dstBpp,
-		     (pBox->y2 - pBox->y1),
-		     0x0, FB_ALLONES);
-	    pBox++;
+	    fb = s3s->fbmap[ma];
+	    pScrPriv->layer[fb].key = s3s->fb[ma].chroma_key;
 	}
     }
-}
-
-void
-s3DumbPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    s3DumbPaintChromaKey (pWin, pRegion);
-    fbPaintWindow (pWin, pRegion, what);
-}
-
-void
-s3DumbCopyWindow (WindowPtr pWin, 
-	     DDXPointRec    ptOldOrg, 
-	     RegionPtr	    prgnSrc)
-{
-    ScreenPtr		pScreen = pWin->drawable.pScreen;
-    RegionRec		rgnDst;
-    int			dx, dy;
-    PixmapPtr		pPixmap;
-    FbOverlayScrPrivPtr	pScrPriv = fbOverlayGetScrPriv(pScreen);
-    int			fb;
-
-    KdCheckSync (pScreen);
-    dx = ptOldOrg.x - pWin->drawable.x;
-    dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
-
-    REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
-    
-    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
-
-    for (fb = 0; fb < pScrPriv->nlayers; fb++)
-    {
-	pPixmap = pScrPriv->pLayer[fb];
-	fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
-		      0,
-		      &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
-    }
-    
-    REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
-    fbValidateDrawable (&pWin->drawable);
-}
-
-Bool
-s3InitScreen(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    KdCardInfo	    *card = pScreenPriv->card;
-    KdScreenInfo    *screen = pScreenPriv->screen;
-    s3CardInfo (pScreenPriv);
-    s3ScreenInfo (pScreenPriv);
-
-    pScreen->PaintWindowBackground = s3DumbPaintWindow;
-    pScreen->PaintWindowBorder = s3DumbPaintWindow;
-    pScreen->CopyWindow = s3DumbCopyWindow;
     return TRUE;
 }
 
Index: xc/programs/Xserver/hw/kdrive/savage/s3.h
diff -u xc/programs/Xserver/hw/kdrive/savage/s3.h:1.4 xc/programs/Xserver/hw/kdrive/savage/s3.h:1.6
--- xc/programs/Xserver/hw/kdrive/savage/s3.h:1.4	Sat May  6 18:17:45 2000
+++ xc/programs/Xserver/hw/kdrive/savage/s3.h	Sun Sep  3 01:11:19 2000
@@ -22,7 +22,7 @@
  *
  * Author:  Keith Packard, SuSE, Inc.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.h,v 1.4 2000/05/06 22:17:45 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.h,v 1.6 2000/09/03 05:11:19 keithp Exp $ */
 
 #ifndef _S3_H_
 #define _S3_H_
@@ -439,18 +439,19 @@
     CARD32	bitmap_offset;
     int		accel_stride;
     int		accel_bpp;
+    CARD32	chroma_key;
 } S3FBInfo;
     
 typedef struct _s3ScreenInfo {
     CARD8	*cursor_base;	    /* pointer to cursor area */
     S3Cursor	cursor;
-    Bool	manage_border;
     Bool	managing_border;
     Bool	use_streams;
     int		primary_depth;
     int		current_ma;
     CARD32	border_pixel;
     S3FBInfo	fb[KD_MAX_FB];
+    RegionRec	region[KD_MAX_FB];
     int		fbmap[KD_MAX_FB+1];   /* map from fb to stream */
 } S3ScreenInfo;
 
@@ -462,7 +463,7 @@
 
 Bool	s3CardInit (KdCardInfo *);
 Bool	s3ScreenInit (KdScreenInfo *);
-void	s3Enable (ScreenPtr pScreen);
+Bool	s3Enable (ScreenPtr pScreen);
 void	s3Disable (ScreenPtr pScreen);
 void	s3Fini (ScreenPtr pScreen);
 
Index: xc/programs/Xserver/hw/kdrive/savage/s3cmap.c
diff -u xc/programs/Xserver/hw/kdrive/savage/s3cmap.c:1.4 xc/programs/Xserver/hw/kdrive/savage/s3cmap.c:1.5
--- xc/programs/Xserver/hw/kdrive/savage/s3cmap.c:1.4	Sat May  6 18:17:45 2000
+++ xc/programs/Xserver/hw/kdrive/savage/s3cmap.c	Wed Aug  9 13:52:41 2000
@@ -22,7 +22,7 @@
  *
  * Author:  Keith Packard, SuSE, Inc.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3cmap.c,v 1.4 2000/05/06 22:17:45 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3cmap.c,v 1.5 2000/08/09 17:52:41 keithp Exp $ */
 
 #include "s3.h"
 
@@ -43,50 +43,80 @@
     }
 }
 
+#ifndef S3_TRIO
+#define Shift(v,d)  ((d) < 0 ? ((v) >> (-d)) : ((v) << (d)))
+
 void
+s3SetTrueChromaKey (ScreenPtr pScreen, int pfb, xColorItem *pdef)
+{
+    FbOverlayScrPrivPtr	pScrPriv = fbOverlayGetScrPriv(pScreen);
+    KdScreenPriv(pScreen);
+    s3ScreenInfo(pScreenPriv);
+    int		fb, ma;
+    CARD32	key;
+    int		r, g, b;
+
+    for (ma = 0; s3s->fbmap[ma] >= 0; ma++) 
+    {
+	fb = s3s->fbmap[ma];
+	if (fb != pfb && pScreenPriv->screen->fb[fb].redMask)
+	{
+	    r = KdComputeCmapShift (pScreenPriv->screen->fb[fb].redMask);
+	    g = KdComputeCmapShift (pScreenPriv->screen->fb[fb].greenMask);
+	    b = KdComputeCmapShift (pScreenPriv->screen->fb[fb].blueMask);
+	    key = ((Shift(pdef->red,r) & pScreenPriv->screen->fb[fb].redMask) |
+		   (Shift(pdef->green,g) & pScreenPriv->screen->fb[fb].greenMask) |
+		   (Shift(pdef->blue,b) & pScreenPriv->screen->fb[fb].blueMask));
+	    if (pScrPriv->layer[fb].key != key)
+	    {
+		pScrPriv->layer[fb].key = key;
+		(*pScrPriv->PaintKey) (&pScrPriv->layer[fb].u.run.pixmap->drawable,
+				       &pScrPriv->layer[pfb].u.run.region,
+				       pScrPriv->layer[fb].key, fb);
+	    }
+	}
+    }
+}
+#endif
+
+void
 s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
 {
     KdScreenPriv(pScreen);
     s3CardInfo(pScreenPriv);
     s3ScreenInfo(pScreenPriv);
-    S3Vga   *s3vga = &s3c->s3vga;
-    Bool    hit_border = FALSE;
-    Bool    check_border = FALSE;
+    S3Vga	*s3vga = &s3c->s3vga;
+    xColorItem	*chroma = 0;
+    CARD32	key;
 
 #if 0
     _s3WaitVRetrace (s3vga);
 #else
     S3Ptr   s3 = s3c->s3;
     _s3WaitVRetraceFast(s3);
+#endif
+#ifndef S3_TRIO
+    if (pScreenPriv->screen->fb[1].depth)
+    {
+	FbOverlayScrPrivPtr	pScrPriv = fbOverlayGetScrPriv(pScreen);
+	key = pScrPriv->layer[fb].key;
+    }
 #endif
-    if (pScreenPriv->enabled && s3s->manage_border && !s3s->managing_border)
-	check_border = TRUE;
+    else
+	key = ~0;
     while (ndef--)
     {
-	if (check_border && pdefs->pixel == s3s->border_pixel)
-	{
-	    if (pdefs->red || pdefs->green || pdefs->blue)
-		hit_border = TRUE;
-	}
+	if (pdefs->pixel == key)
+	    chroma = pdefs;
 	s3SetImm (s3vga, s3_dac_write_index, pdefs->pixel);
 	s3SetImm (s3vga, s3_dac_data, pdefs->red >> 8);
 	s3SetImm (s3vga, s3_dac_data, pdefs->green >> 8);
 	s3SetImm (s3vga, s3_dac_data, pdefs->blue >> 8);
 	pdefs++;
     }
-    if (hit_border)
-    {
-	xColorItem  black;
-
-	black.red = 0;
-	black.green = 0;
-	black.blue = 0;
-	s3s->managing_border = TRUE;
-	FakeAllocColor (pScreenPriv->pInstalledmap[fb],
-			&black);
-	s3s->border_pixel = black.pixel;
-	FakeFreeColor (pScreenPriv->pInstalledmap[fb], s3s->border_pixel);
-/*	s3SetImm (&s3c->s3vga, s3_border_color, (VGA8) s3s->border_pixel); */
-    }
+#ifndef S3_TRIO
+    if (chroma && !pScreenPriv->closed)
+	s3SetTrueChromaKey (pScreen, fb, chroma);
+#endif
 }
 
Index: xc/programs/Xserver/hw/kdrive/savage/s3draw.c
diff -u xc/programs/Xserver/hw/kdrive/savage/s3draw.c:1.4 xc/programs/Xserver/hw/kdrive/savage/s3draw.c:1.5
--- xc/programs/Xserver/hw/kdrive/savage/s3draw.c:1.4	Sat May  6 18:17:46 2000
+++ xc/programs/Xserver/hw/kdrive/savage/s3draw.c	Wed Aug  9 13:52:41 2000
@@ -22,7 +22,7 @@
  *
  * Author:  Keith Packard, SuSE, Inc.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.c,v 1.4 2000/05/06 22:17:46 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.c,v 1.5 2000/08/09 17:52:41 keithp Exp $ */
 
 #include	"s3.h"
 #include	"s3draw.h"
@@ -491,7 +491,6 @@
     BoxPtr	    pboxClippedBase;
     BoxPtr	    pextent;
     BoxRec	    stackRects[NUM_STACK_RECTS];
-    FbGCPrivPtr	    fbPriv = fbGetGCPrivate (pGC);
     int		    numRects;
     int		    n;
     int		    xorg, yorg;
@@ -712,7 +711,6 @@
     int		    nTmp;
     int		    *pwidthFree;/* copies of the pointers to free */
     DDXPointPtr	    pptFree;
-    FbGCPrivPtr	    fbPriv = fbGetGCPrivate(pGC);
     BoxPtr	    extents;
     S3PatternCache  *cache;
     RegionPtr	    pClip = fbGetCompositeClip (pGC);
@@ -994,17 +992,19 @@
 }
 
 void
-s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape, 
-		 int mode, int countInit, DDXPointPtr ptsIn)
+s3FillPoly (DrawablePtr pDrawable, GCPtr pGC, int shape, 
+	    int mode, int countInit, DDXPointPtr ptsIn)
 {
     SetupS3(pDrawable->pScreen);
-    FbGCPrivPtr	    fbPriv;
     int		    nwidth;
     int		    maxy;
+    int		    origin;
     int		    count;
     register int    vertex1, vertex2;
     int		    c;
+    RegionPtr	    pClip = fbGetCompositeClip(pGC);    
     BoxPtr	    extents;
+    int		    clip;
     int		    y, sy;
     int		    *vertex1p, *vertex2p;
     int		    *endp;
@@ -1018,17 +1018,21 @@
     int		    l, r;
     int		    nmiddle;
 
-    if (mode == CoordModePrevious)
+    if (mode == CoordModePrevious || REGION_NUM_RECTS(pClip) != 1)
     {
 	KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
 	return;
     }
     
     s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
-    fbPriv = fbGetGCPrivate(pGC);
     sy = pDrawable->y;
     sx = pDrawable->x;
-    extents = &fbGetCompositeClip(pGC)->extents;
+    origin = *((int *) &pDrawable->x);
+    origin -= (origin & 0x8000) << 1;
+    extents = &pClip->extents;
+    vertex1 = *((int *) &extents->x1) - origin;
+    vertex2 = *((int *) &extents->x2) - origin - 0x00010001;
+    clip = 0;
     
     y = 32767;
     maxy = 0;
@@ -1040,14 +1044,7 @@
     	while (count--)
     	{
 	    c = *vertex2p;
-	    /*
-	     * Check for negative or over S3 limits
-	     */
-	    if (c & 0xe000e000)
-	    {
-		KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
-		return;
-	    }
+	    clip |= (c - vertex1) | (vertex2 - c);
 	    c = intToY(c);
 	    DRAW_DEBUG ((DEBUG_POLYGON, "Y coordinate %d", c));
 	    if (c < y) 
@@ -1070,14 +1067,7 @@
     	while (count--)
     	{
 	    c = *vertex2p;
-	    /*
-	     * Check for negative or over S3 limits
-	     */
-	    if (c & 0xe000e000)
-	    {
-		KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
-		return;
-	    }
+	    clip |= (c - vertex1) | (vertex2 - c);
 	    c = intToY(c);
 	    DRAW_DEBUG ((DEBUG_POLYGON, "Y coordinate %d", c));
 	    if (c < y) 
@@ -1111,16 +1101,17 @@
 	if (x1 != dx2)
 	    yFlip++;
 	if (yFlip != 2) 
-	{
-	    KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
-	    return;
-	}
+	    clip = 0x8000;
     }
     if (y == maxy)
 	return;
 
+    if (clip & 0x80008000)
+    {
+	KdCheckFillPolygon (pDrawable, pGC, shape, mode, countInit, ptsIn);
+	return;
+    }
     _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask);
-    _s3SetClip(s3,extents);
     
     vertex2p = vertex1p;
     vertex2 = vertex1 = *vertex2p++;
@@ -1236,7 +1227,6 @@
 	if (y == maxy)
 	    break;
     }
-    _s3ResetClip (s3, pDrawable->pScreen);
     MarkSyncS3 (pDrawable->pScreen);
 }
 
@@ -2162,15 +2152,8 @@
     KdScreenPriv(pWin->drawable.pScreen);
     s3ScreenInfo(pScreenPriv);
     
-    if (!KdCreateWindow (pWin))
-	return FALSE;
     pWin->devPrivates[s3WindowPrivateIndex].ptr = 0;
-#ifndef S3_TRIO
-    if (pWin->drawable.depth != s3s->primary_depth)
-	return fbOverlayCreateWindow (pWin);
-    else
-#endif
-	return fbCreateWindow (pWin);
+    return KdCreateWindow (pWin);
 }
 
 Bool
@@ -2217,27 +2200,34 @@
     return ret;
 }
 
+
 #ifndef S3_TRIO
 void
-s3PaintChromaKey (WindowPtr pWin, RegionPtr pRegion)
+s3PaintKey (DrawablePtr	pDrawable,
+	    RegionPtr	pRegion,
+	    CARD32	pixel,
+	    int		fb)
 {
-    SetupS3 (pWin->drawable.pScreen);
+    SetupS3 (pDrawable->pScreen);
     s3ScreenInfo (pScreenPriv);
+    int	    nBox = REGION_NUM_RECTS(pRegion);
+    BoxPtr  pBox = REGION_RECTS(pRegion);
+    int	    ma;
+    
+    if (!nBox)
+	return;
     
-    if (pWin->drawable.depth != s3s->primary_depth)
+    for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
+	if (s3s->fbmap[ma] == fb)
+	    break;
+    s3SetGlobalBitmap (pDrawable->pScreen, ma);
+    _s3SetSolidFill (s3, pixel, GXcopy, 0xffffffff);
+    while (nBox--) 
     {
-	int	    nBox = REGION_NUM_RECTS(pRegion);
-	BoxPtr	    pBox = REGION_RECTS(pRegion);
-	
-	s3SetGlobalBitmap (pWin->drawable.pScreen, 0);
-	_s3SetSolidFill(s3,0xffffffff,GXcopy,0xffffffff);
-	while (nBox--) 
-	{
-	    _s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1);
-	    pBox++;
-	}
-	MarkSyncS3 (pWin->drawable.pScreen);
+	_s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1);
+	pBox++;
     }
+    MarkSyncS3 (pDrawable->pScreen);
 }
 #endif
 
@@ -2245,6 +2235,7 @@
 s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
 {
     SetupS3(pWin->drawable.pScreen);
+    s3ScreenInfo(pScreenPriv);
     s3PatternPtr    pPattern;
 
     DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d",
@@ -2254,9 +2245,6 @@
 		 REGION_NUM_RECTS(pRegion)));
     if (!REGION_NUM_RECTS(pRegion)) 
 	return;
-#ifndef S3_TRIO
-    s3PaintChromaKey (pWin, pRegion);
-#endif
     switch (what) {
     case PW_BACKGROUND:
 	switch (pWin->backgroundState) {
@@ -2289,6 +2277,12 @@
     	}
     	break;
     case PW_BORDER:
+#ifndef S3_TRIO
+	if (s3s->fbmap[1] >= 0)
+	    fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
+					fbOverlayWindowLayer (pWin),
+					pRegion);
+#endif
 	if (pWin->borderIsPixel)
 	{
 	    s3FillBoxSolid((DrawablePtr)pWin,
@@ -2303,19 +2297,6 @@
 }
 
 void
-s3RestoreAreas(PixmapPtr    pPixmap,
-	       RegionPtr    prgnRestore,
-	       int	    xorg,
-	       int	    yorg,
-	       WindowPtr    pWin)
-{
-#ifndef S3_TRIO
-    s3PaintChromaKey (pWin, prgnRestore);
-#endif
-    KdCheckRestoreAreas (pPixmap, prgnRestore, xorg, yorg, pWin);
-}
-    
-void
 s3CopyWindowProc (DrawablePtr pSrcDrawable,
 		  DrawablePtr pDstDrawable,
 		  GCPtr       pGC,
@@ -2330,86 +2311,94 @@
 {
     SetupS3(pDstDrawable->pScreen);
     s3ScreenInfo(pScreenPriv);
-    int	    srcX, srcY, dstX, dstY;
-    int	    x1, x2;
-    int	    w, h;
-    int	    flags;
-    int	    ma;
-    BoxPtr  pbox;
-    int     nbox;
+    KdScreenInfo    *screen = pScreenPriv->screen;
+    int		    srcX, srcY, dstX, dstY;
+    int		    x1, x2;
+    int		    w, h;
+    int		    flags;
+    int		    fb = (int) closure;
+    int		    ma;
+    BoxPtr	    pbox;
+    int		    nbox;
+    int		    bitsPerPixel;
     
-    if (pSrcDrawable->bitsPerPixel == 24)
-	dx *= 3;
 #ifdef S3_TRIO
     ma = 0;
 #else
     for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
+	if (s3s->fbmap[ma] == fb)
+	    break;
 #endif
+    bitsPerPixel = screen->fb[fb].bitsPerPixel;
+    if (bitsPerPixel == 24)
+	dx *= 3;
+    nbox = nboxOrig;
+    pbox = pboxOrig;
+    s3SetGlobalBitmap (pDstDrawable->pScreen, ma);
+    _s3SetBlt(s3,GXcopy,~0);
+    while (nbox--)
     {
-	nbox = nboxOrig;
-	pbox = pboxOrig;
-	s3SetGlobalBitmap (pDstDrawable->pScreen, ma);
-	_s3SetBlt(s3,GXcopy,~0);
-	while (nbox--)
-	{
-	    x1 = pbox->x1;
-	    x2 = pbox->x2;
-	    if (pSrcDrawable->bitsPerPixel == 24)
-	    {
-		x1 *= 3;
-		x2 *= 3;
-	    }
-	    
-	    w = x2 - x1;
-	    h = pbox->y2 - pbox->y1;
-	    flags = 0;
-	    if (reverse)
-	    {
-		dstX = x2 - 1;
-	    }
-	    else
-	    {
-		dstX = x1;
-		flags |= INC_X;
-	    }
-	    srcX = dstX + dx;
-	    
-	    if (upsidedown)
-	    {
-		dstY = pbox->y2 - 1;
-	    }
-	    else
-	    {
-		dstY = pbox->y1;
-		flags |= INC_Y;
-	    }
-	    srcY = dstY + dy;
-	    
-	    _s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags);
-	    pbox++;
+	x1 = pbox->x1;
+	x2 = pbox->x2;
+	if (bitsPerPixel == 24)
+	{
+	    x1 *= 3;
+	    x2 *= 3;
+	}
+	
+	w = x2 - x1;
+	h = pbox->y2 - pbox->y1;
+	flags = 0;
+	if (reverse)
+	{
+	    dstX = x2 - 1;
+	}
+	else
+	{
+	    dstX = x1;
+	    flags |= INC_X;
+	}
+	srcX = dstX + dx;
+	
+	if (upsidedown)
+	{
+	    dstY = pbox->y2 - 1;
+	}
+	else
+	{
+	    dstY = pbox->y1;
+	    flags |= INC_Y;
 	}
-	MarkSyncS3 (pDstDrawable->pScreen);
+	srcY = dstY + dy;
+	
+	_s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags);
+	pbox++;
     }
+    MarkSyncS3 (pDstDrawable->pScreen);
 }
 
 void 
 s3CopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 {
-    ScreenPtr	pScreen = pWin->drawable.pScreen;
-    KdScreenPriv(pScreen);
-    RegionRec	rgnDst;
-    int		dx, dy;
-    WindowPtr	pwinRoot;
+    ScreenPtr	    pScreen = pWin->drawable.pScreen;
+    KdScreenPriv (pScreen);
+    s3ScreenInfo (pScreenPriv);
+    KdScreenInfo    *screen = pScreenPriv->screen;
+    RegionRec	    rgnDst;
+    int		    dx, dy;
+    WindowPtr	    pwinRoot;
 
     pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
 
     dx = ptOldOrg.x - pWin->drawable.x;
     dy = ptOldOrg.y - pWin->drawable.y;
+
     REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
 
     REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
-    
-    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst,
+		     &pWin->borderClip, prgnSrc);
 
     fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
 		  0,
@@ -2451,7 +2440,6 @@
     int		    nTmp;
     int		    *pwidthFree;/* copies of the pointers to free */
     DDXPointPtr	    pptFree;
-    FbGCPrivPtr	    fbPriv = fbGetGCPrivate(pGC);
     BoxPtr	    extents;
     RegionPtr	    pClip = fbGetCompositeClip (pGC);
 
@@ -2625,7 +2613,6 @@
     BoxPtr	    pboxClippedBase;
     BoxPtr	    pextent;
     BoxRec	    stackRects[NUM_STACK_RECTS];
-    FbGCPrivPtr	    fbPriv = fbGetGCPrivate (pGC);
     int		    numRects;
     int		    n;
     int		    xorg, yorg;
@@ -3096,13 +3083,18 @@
 	pScreen->DestroyWindow = s3DestroyWindow;
 	pScreen->PaintWindowBackground = s3PaintWindow;
 	pScreen->PaintWindowBorder = s3PaintWindow;
-	pScreen->CopyWindow = s3CopyWindow;
-	pScreen->BackingStoreFuncs.RestoreAreas = s3RestoreAreas;
-#if 0	
-	pScreen->PaintWindowBackground = s3DumbPaintWindow;
-	pScreen->PaintWindowBorder = s3DumbPaintWindow;
-	pScreen->CopyWindow = s3DumbCopyWindow;
+#ifndef S3_TRIO
+	if (pScreenPriv->screen->fb[1].depth)
+	{
+	    FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+
+	    pScrPriv->PaintKey = s3PaintKey;
+	    pScrPriv->CopyWindow = s3CopyWindowProc;
+	    pScreen->CopyWindow = fbOverlayCopyWindow;
+	}
+	else
 #endif
+	    pScreen->CopyWindow = s3CopyWindow;
 	
 	/*
 	 * Initialize patterns
Index: xc/programs/Xserver/hw/kdrive/savage/s3draw.h
diff -u xc/programs/Xserver/hw/kdrive/savage/s3draw.h:1.4 xc/programs/Xserver/hw/kdrive/savage/s3draw.h:1.5
--- xc/programs/Xserver/hw/kdrive/savage/s3draw.h:1.4	Sat May  6 18:17:47 2000
+++ xc/programs/Xserver/hw/kdrive/savage/s3draw.h	Wed Aug  9 13:52:42 2000
@@ -22,7 +22,7 @@
  *
  * Author:  Keith Packard, SuSE, Inc.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.h,v 1.4 2000/05/06 22:17:47 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.h,v 1.5 2000/08/09 17:52:42 keithp Exp $ */
 
 #ifndef _S3DRAW_H_
 #define _S3DRAW_H_
@@ -413,8 +413,8 @@
 s3PolyFillArcSolid (DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs);
 
 void
-s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape, 
-		 int mode, int count, DDXPointPtr ptsIn);
+s3FillPoly (DrawablePtr pDrawable, GCPtr pGC, int shape, 
+	    int mode, int count, DDXPointPtr ptsIn);
 
 void
 s3PolyGlyphBlt (DrawablePtr pDrawable, 
Index: xc/programs/Xserver/hw/kdrive/savage/s3gc.c
diff -u xc/programs/Xserver/hw/kdrive/savage/s3gc.c:1.4 xc/programs/Xserver/hw/kdrive/savage/s3gc.c:1.5
--- xc/programs/Xserver/hw/kdrive/savage/s3gc.c:1.4	Wed Feb 23 15:30:04 2000
+++ xc/programs/Xserver/hw/kdrive/savage/s3gc.c	Wed Aug  9 13:52:42 2000
@@ -22,7 +22,7 @@
  *
  * Author:  Keith Packard, SuSE, Inc.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3gc.c,v 1.4 2000/02/23 20:30:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3gc.c,v 1.5 2000/08/09 17:52:42 keithp Exp $ */
 
 #include	"s3.h"
 #include	"s3draw.h"
@@ -47,63 +47,7 @@
  *  font	<= 32 pixels wide
  */
 
-/* TE font, >= 4 pixels wide, one clip rectangle */
-static const GCOps	s3TEOps1Rect = {
-    s3FillSpans,
-    KdCheckSetSpans,
-    KdCheckPutImage,
-    s3CopyArea,
-    s3CopyPlane,
-    KdCheckPolyPoint,
-    s3Polylines,
-    s3PolySegment,
-    KdCheckPolyRectangle,
-    KdCheckPolyArc,
-    s3FillPoly1Rect,
-    s3PolyFillRect,
-    s3PolyFillArcSolid,
-    miPolyText8,
-    miPolyText16,
-    miImageText8,
-    miImageText16,
-    s3ImageTEGlyphBlt,
-    s3PolyTEGlyphBlt,
-    s3PushPixels,
-#ifdef NEED_LINEHELPER
-    ,NULL
-#endif
-};
-
-extern GCOps	    fbGCOps;
-
-/* Non TE font, one clip rectangle */
-static const GCOps	s3NonTEOps1Rect = {
-    s3FillSpans,
-    KdCheckSetSpans,
-    KdCheckPutImage,
-    s3CopyArea,
-    s3CopyPlane,
-    KdCheckPolyPoint,
-    s3Polylines,
-    s3PolySegment,
-    KdCheckPolyRectangle,
-    KdCheckPolyArc,
-    s3FillPoly1Rect,
-    s3PolyFillRect,
-    s3PolyFillArcSolid,
-    miPolyText8,
-    miPolyText16,
-    miImageText8,
-    miImageText16,
-    s3ImageGlyphBlt,
-    s3PolyGlyphBlt,
-    s3PushPixels
-#ifdef NEED_LINEHELPER
-    ,NULL
-#endif
-};
-
-/* TE font, != 1 clip rect (including 0) */
+/* TE font */
 static const GCOps	s3TEOps = {
     s3FillSpans,
     KdCheckSetSpans,
@@ -115,7 +59,7 @@
     s3PolySegment,
     KdCheckPolyRectangle,
     KdCheckPolyArc,
-    KdCheckFillPolygon,
+    s3FillPoly,
     s3PolyFillRect,
     s3PolyFillArcSolid,
     miPolyText8,
@@ -130,7 +74,7 @@
 #endif
 };
 
-/* Non TE font, != 1 clip rect (including 0) */
+/* Non TE font */
 static const GCOps	s3NonTEOps = {
     s3FillSpans,
     KdCheckSetSpans,
@@ -142,7 +86,7 @@
     s3PolySegment,
     KdCheckPolyRectangle,
     KdCheckPolyArc,
-    KdCheckFillPolygon,
+    s3FillPoly,
     s3PolyFillRect,
     s3PolyFillArcSolid,
     miPolyText8,
@@ -182,19 +126,9 @@
     if (pGC->font)
     {
 	if (TERMINALFONT(pGC->font))
-	{
-	    if (fbPriv->oneRect)
-		return (GCOps *) &s3TEOps1Rect;
-	    else
-		return (GCOps *) &s3TEOps;
-	}
+	    return (GCOps *) &s3TEOps;
 	else
-	{
-	    if (fbPriv->oneRect)
-		return (GCOps *) &s3NonTEOps1Rect;
-	    else
-		return (GCOps *) &s3NonTEOps;
-	}
+	    return (GCOps *) &s3NonTEOps;
     }
     return 0;
 }
@@ -203,19 +137,18 @@
 s3ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
 {
     int		new_type;	/* drawable type has changed */
-    int		new_onerect;	/* onerect value has changed */
     int		new_origin;
     
     /* flags for changing the proc vector */
     FbGCPrivPtr fbPriv;
     s3PrivGCPtr	s3Priv;
     int		oneRect;
+    GCOps	*newops;
     
     fbPriv = fbGetGCPrivate(pGC);
     s3Priv = s3GetGCPrivate(pGC);
 
     new_type = FALSE;
-    new_onerect = FALSE;
     new_origin = FALSE;
 
     /*
@@ -236,13 +169,9 @@
     /*
      * Call down to FB to set clip list and rrop values
      */
-    oneRect = fbPriv->oneRect;
     
     fbValidateGC (pGC, changes, pDrawable);
     
-    if (oneRect != fbPriv->oneRect)
-	new_onerect = TRUE;
-    
     /*
      * Check accelerated pattern if necessary
      */
@@ -256,19 +185,12 @@
      * Try to match common vector
      */
     
-    if (new_type || new_onerect ||
-	(changes & (GCLineWidth|GCLineStyle|GCFillStyle|
-		    GCFont|GCForeground|GCFunction|GCPlaneMask)))
+    if (newops = s3MatchCommon (pDrawable, pGC, fbPriv))
     {
-	GCOps	*newops;
-
-	if (newops = s3MatchCommon (pDrawable, pGC, fbPriv))
- 	{
-	    if (pGC->ops->devPrivate.val)
-		miDestroyGCOps (pGC->ops);
-	    pGC->ops = newops;
-	    return;
-	}
+	if (pGC->ops->devPrivate.val)
+	    miDestroyGCOps (pGC->ops);
+	pGC->ops = newops;
+	return;
     }
     
     /*
@@ -335,14 +257,13 @@
     /*
      * Polygons
      */
-    if (new_type || new_onerect || (changes & (GCFillStyle)))
+    if (new_type || (changes & (GCFillStyle)))
     {
 	pGC->ops->FillPolygon = KdCheckFillPolygon;
 	if (s3Priv->type == DRAWABLE_WINDOW &&
-	    fbPriv->oneRect && 
 	    pGC->fillStyle == FillSolid)
 	{
-	    pGC->ops->FillPolygon = s3FillPoly1Rect;
+	    pGC->ops->FillPolygon = s3FillPoly;
 	}
     }
 	
Index: xc/programs/Xserver/hw/kdrive/sis530/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/sis530/Imakefile:1.1 xc/programs/Xserver/hw/kdrive/sis530/Imakefile:1.2
--- xc/programs/Xserver/hw/kdrive/sis530/Imakefile:1.1	Fri Nov 19 08:53:58 1999
+++ xc/programs/Xserver/hw/kdrive/sis530/Imakefile	Sun Sep  3 01:11:19 2000
@@ -1,14 +1,13 @@
 XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/sis530/Imakefile,v 1.1 1999/11/19 13:53:58 hohndel Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/sis530/Imakefile,v 1.2 2000/09/03 05:11:19 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
 
 SRCS = 	sis.c sisclock.c siscmap.c siscurs.c sisdraw.c sisio.c sisstub.c
 
 OBJS = 	sis.o sisclock.o siscmap.o siscurs.o sisdraw.o sisio.o sisstub.o
 
-INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../../fb -I../../../mi -I../../../include -I../../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+INCLUDES = -I. $(KDINCS)
 
 NormalLibraryObjectRule()
 NormalLibraryTarget(sis530,$(OBJS))
Index: xc/programs/Xserver/hw/kdrive/sis530/sis.c
diff -u xc/programs/Xserver/hw/kdrive/sis530/sis.c:1.4 xc/programs/Xserver/hw/kdrive/sis530/sis.c:1.6
--- xc/programs/Xserver/hw/kdrive/sis530/sis.c:1.4	Sat May  6 18:17:49 2000
+++ xc/programs/Xserver/hw/kdrive/sis530/sis.c	Sun Sep  3 01:11:19 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sis.c,v 1.4 2000/05/06 22:17:49 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sis.c,v 1.6 2000/09/03 05:11:19 keithp Exp $ */
 
 #include "sis.h"
 
@@ -29,130 +29,10 @@
 
 #define MMIO_SIZE	(64 * 1024)
 
-#define SIS_TIMING_BAIL	2
-
-SisTiming    sisTimings[] = {
-	     /* FP	BP	BLANK   */
-    { 640, 480, 85,
-		56,	80,	192,    /* horizontal	43.265 KHz */
-		1,	25,	29,	/* vertical	85.000 Hz  */
-					/* pixel	35.996 MHz */
-    },
-    
-    { 640, 480, 75,
-		16,	120,	200,    /* horizontal	37.500 KHz */
-		1,	16,	20,	/* vertical	75.000 Hz  */
-					/* pixel	31.500 MHz */
-    },
-    
-    { 640, 480, 60,
-		16,	48,	160,    /* horizontal	31.321 KHz */
-		10,	33,	45,	/* vertical	59.568 Hz  */
-					/* pixel	25.057 MHz */
-    },
-    
-    { 800, 600, 85,
-		32,	152,	248,    /* horizontal	53.673 KHz */
-		1,	27,	31,	/* vertical	85.060 Hz  */
-					/* pixel	56.249 MHz */
-    },
-    { 800, 600, 75,
-		16,	160,	256,    /* horizontal	46.891 KHz */
-		1,	21,	25,	/* vertical	75.025 Hz  */
-					/* pixel	49.516 MHz */
-    },
-    { 800, 600, 72,
-		56,	64,	240,    /* horizontal	48.186 KHz */
-		37,	23,	66,	/* vertical	72.351 Hz  */
-					/* pixel	50.113 MHz */
-    },
-    
-    { 1024, 768, 85,
-		48,	208,	352,    /* horizontal	68.676 KHz */
-		1,	36,	40,	/* vertical	84.996 Hz  */
-					/* pixel	94.499 MHz */
-    },
-    { 1024, 768, 75,
-		16,	176,	288,    /* horizontal	60.022 KHz */
-		1,	28,	32,	/* vertical	75.028 Hz  */
-					/* pixel	78.749 MHz */
-    },
-    { 1024, 768, 70,
-		24,	144,	304,    /* horizontal	56.604 KHz */
-		3,	29,	38,	/* vertical	70.227 Hz  */
-					/* pixel	75.170 MHz */
-    },
-    { 1024, 768, 66,
-		24,	144,	304,	/* horizontal	53.234 KHz */
-		3,	29,	38,	/* vertical	66.047 Hz  */
-					/* pixel	70.695 MHz */
-    },
-    
-    { 1152, 900, 85,
-		48,	208,	384,	/* horizontal	 79.900 KHz */
-		1,	32,	38,	/* vertical	 85.181 Hz  */
-					/* pixel	122.726 MHz */
-    },
-    { 1152, 900, 75,
-		32,	208,	384,	/* horizontal	 70.495 Khz */
-		1,	32,	38,	/* vertical	 75.154  Hz */
-					/* pixel	108.280 MHz */
-    },
-    { 1152, 900, 70,
-		32,	208,	384,    /* horizontal	 65.251 KHz */
-		2,	32,	38,	/* vertical	 69.564 Hz  */
-					/* pixel	100.226 MHz */
-    },
-    { 1152, 900, 66,
-		32,	208,	384,    /* horizontal	61.817 KHz */
-		1,	32,	38,	/* vertical	65.903 Hz  */
-					/* pixel	94.951 MHz */
-    },
-    { 1280, 1024, 85,
-		16,	248,	416,	/* horizontal	 90.561 KHz */
-		1,	40,	45,	/* vertical	 84.717 Hz  */
-					/* pixel	153.593 MHz */
-    },
-    { 1280, 1024, 75,
-		16,	248,	408,    /* horizontal	 80.255 KHz */
-		1,	38,	42,	/* vertical	 75.285 Hz  */
-					/* pixel	134.828 MHz */
-    },
-    { 1280, 1024, 70,
-		32,	248,	400,    /* horizontal	 74.573 KHz */
-		0,	36,	39,	/* vertical	 70.153 Hz  */
-					/* pixel        125.283 MHz */
-    },
-    { 1280, 1024, 66,
-		32,	248,	400,    /* horizontal	 70.007 KHz */
-		0,	36,	39,	/* vertical	 65.858 Hz  */
-					/* pixel        117.612 MHz */
-    },
-    
-    { 1600, 1200, 85,
-		64,	304,	560,    /* horizontal	106.059 KHz */
-		1,	46,	50,	/* vertical	 84.847 Hz  */
-					/* pixel	229.088 MHz */
-    },
-    { 1600, 1200, 75,
-		64,	304,	560,    /* horizontal	 93.748 KHz */
-		1,	46,	50,	/* vertical	 74.999 Hz  */
-					/* pixel	202.497 MHz */
-    },
-    { 1600, 1200, 70,
-		56,	304,	588,	/* horizontal	 87.524 KHz */
-		1,	46,	50,	/* vertical	 70.019 Hz  */
-					/* pixel	191.503 MHz */
-    },
-    { 1600, 1200, 65,
-		56,	308,	524,    /* horizontal	 80.050 KHz */
-		1,	38,	42,	/* vertical	 64.453 Hz  */
-					/* pixel	170.026 MHz */
-    },
+int sisMemoryTable[8] = {
+    1, 2, 4, 0, 0, 2, 4, 8
 };
 
-#define NUM_SIS_TIMINGS	(sizeof (sisTimings) / sizeof (sisTimings[0]))
-
 Bool
 sisCardInit (KdCardInfo *card)
 {
@@ -161,19 +41,33 @@
     int		    size;
     CARD8	    *registers;
     CARD8	    *temp_buffer;
+    CARD8	    save_sr5;
 
     sisc = (SisCardInfo *) xalloc (sizeof (SisCardInfo));
     if (!sisc)
 	goto bail0;
-    
-    temp_buffer = KdMapDevice (card->attr.address[0], MAX_FB_SIZE);
-    if (!temp_buffer)
-	goto bail1;
     
-    sisc->memory = KdFrameBufferSize (temp_buffer, MAX_FB_SIZE);
+    sisc->io_base = card->attr.io;
+    /*
+     * enable access to SiS ports (no MMIO available) 
+     */
+    iopl(3);
+    save_sr5 = GetSrtc(sisc,0x5);
+    if (save_sr5 != 0x21)
+	save_sr5 = 0x86;
+    PutSrtc(sisc,0x5,0x86);
+#if 0
+    {
+	int	i;
 
-    KdUnmapDevice (temp_buffer, MAX_FB_SIZE);
+	for (i = 0; i <= 0x3f; i++)
+	    fprintf (stderr, "SR%02x = %02x\n", i, GetSrtc(sisc,i));
+    }
+#endif
+    sisc->memory = sisMemoryTable[GetSrtc(sisc,0xc)&0x7] * 1024 * 1024;
 
+    PutSrtc(sisc,0x5,save_sr5);
+    
     if (!sisc->memory)
     {
 	ErrorF ("Can't detect SiS530 frame buffer\n");
@@ -196,12 +90,7 @@
      */
     sisc->sis = (SisPtr) (sisc->registers + SIS_MMIO_OFFSET);
     sisc->cpu_bitblt = (VOL32 *) sisc->registers;
-    sisc->io_base = card->attr.io;
 
-    /*
-     * enable access to SiS ports (no MMIO available) 
-     */
-    ioperm (sisc->io_base, 0x80, 1);
     card->driver = sisc;
     
     return TRUE;
@@ -212,22 +101,60 @@
 bail0:
     return FALSE;
 }
-    
-SisTiming *
-sisGetTiming (int width, int height, int rate)
+
+Bool
+sisModeSupported (KdScreenInfo *screen, const KdMonitorTiming *t)
 {
-    int		i;
-    SisTiming	*t;
+    if (t->horizontal != 1600 &&
+	t->horizontal != 1280 &&
+	t->horizontal != 1152 &&
+	t->horizontal != 1024 &&
+	t->horizontal != 800 &&
+	t->horizontal != 640)
+	return FALSE;
+    return TRUE;
+}
+
+Bool
+sisModeUsable (KdScreenInfo *screen)
+{
+    KdCardInfo	    *card = screen->card;
+    SisCardInfo	    *sisc = (SisCardInfo *) card->driver;
+    SisScreenInfo   *siss;
+    int		    i;
+    KdMonitorTiming *t;
+    CARD32	    memory;
+    int		    byte_width, pixel_width, screen_size;
     
-    for (i = 0; i < NUM_SIS_TIMINGS; i++)
+    if (screen->fb[0].depth >= 24)
     {
-	t = &sisTimings[i];
-	if (t->horizontal >= width &&
-	    t->vertical >= height &&
-	    (!rate || t->rate <= rate))
-	    return t;
+	screen->fb[0].depth = 24;
+	screen->fb[0].bitsPerPixel = 24;
+	screen->dumb = TRUE;
+    }
+    else if (screen->fb[0].depth >= 16)
+    {
+	screen->fb[0].depth = 16;
+	screen->fb[0].bitsPerPixel = 16;
+    }
+    else if (screen->fb[0].depth >= 15)
+    {
+	screen->fb[0].depth = 15;
+	screen->fb[0].bitsPerPixel = 16;
     }
-    return &sisTimings[SIS_TIMING_BAIL];
+    else
+    {
+	screen->fb[0].depth = 8;
+	screen->fb[0].bitsPerPixel = 8;
+    }
+    byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3);
+    pixel_width = screen->width;
+    screen->fb[0].pixelStride = pixel_width;
+    screen->fb[0].byteStride = byte_width;
+
+    screen_size = byte_width * screen->height;
+
+    return screen_size <= sisc->memory;
 }
 
 Bool
@@ -237,7 +164,7 @@
     SisCardInfo	    *sisc = (SisCardInfo *) card->driver;
     SisScreenInfo   *siss;
     int		    i;
-    SisTiming	    *t;
+    const KdMonitorTiming *t;
     CARD32	    memory;
     int		    byte_width, pixel_width, screen_size;
 
@@ -256,117 +183,18 @@
     if (!screen->fb[0].depth)
 	screen->fb[0].depth = 8;
     
-    for (;;)
-    {
-	if (screen->fb[0].depth >= 24)
-	{
-	    screen->fb[0].depth = 24;
-	    screen->fb[0].bitsPerPixel = 24;
-	}
-	else if (screen->fb[0].depth >= 16)
-	{
-	    screen->fb[0].depth = 16;
-	    screen->fb[0].bitsPerPixel = 16;
-	}
-	else if (screen->fb[0].depth >= 15)
-	{
-	    screen->fb[0].depth = 15;
-	    screen->fb[0].bitsPerPixel = 16;
-	}
-	else
-	{
-	    screen->fb[0].depth = 8;
-	    screen->fb[0].bitsPerPixel = 8;
-	}
-
-	/* Normalize width to supported values */
-	
-	if (screen->width >= 1600)
-	    screen->width = 1600;
-	else if (screen->width >= 1280)
-	    screen->width = 1280;
-	else if (screen->width >= 1152)
-	    screen->width = 1152;
-	else if (screen->width >= 1024)
-	    screen->width = 1024;
-	else if (screen->width >= 800)
-	    screen->width = 800;
-	else
-	    screen->width = 640;
-	
-	byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3);
-	pixel_width = screen->width;
-	screen->fb[0].pixelStride = pixel_width;
-	screen->fb[0].byteStride = byte_width;
-
-	screen_size = byte_width * screen->height;
-	
-	if (screen_size <= sisc->memory)
-	    break;
-
-	/*
-	 * Fix requested depth and geometry until it works
-	 */
-	if (screen->fb[0].depth > 16)
-	    screen->fb[0].depth = 16;
-	else if (screen->fb[0].depth > 8)
-	    screen->fb[0].depth = 8;
-	else if (screen->width > 1152)
-	{
-	    screen->width = 1152;
-	    screen->height = 900;
-	}
-	else if (screen->width > 1024)
-	{
-	    screen->width = 1024;
-	    screen->height = 768;
-	}
-	else if (screen->width > 800)
-	{
-	    screen->width = 800;
-	    screen->height = 600;
-	}
-	else if (screen->width > 640)
-	{
-	    screen->width = 640;
-	    screen->height = 480;
-	}
-	else
-	{
-	    xfree (siss);
-	    return FALSE;
-	}
-    }
+    t = KdFindMode (screen, sisModeSupported);
     
-    t = sisGetTiming (screen->width, screen->height, screen->rate);
     screen->rate = t->rate;
     screen->width = t->horizontal;
     screen->height = t->vertical;
     
-    /*
-     * Take requested geometry and adjust to fit possible geometries
-     */
-    switch (screen->fb[0].depth) {
-    case 4:
-	screen->fb[0].bitsPerPixel = 4;
-	break;
-    case 8:
-	screen->fb[0].bitsPerPixel = 8;
-	break;
-    case 15:
-    case 16:
-	screen->fb[0].bitsPerPixel = 16;
-	break;
-    case 24:
-    case 32:
-	screen->fb[0].bitsPerPixel = 24;
-	screen->dumb = TRUE;
-	break;
+    if (!KdTuneMode (screen, sisModeUsable, sisModeSupported))
+    {
+	xfree (sisc);
+	return FALSE;
     }
 
-    screen->fb[0].byteStride = screen->width * (screen->fb[0].bitsPerPixel >> 3);
-    screen->fb[0].pixelStride = screen->width;
-
     memory = sisc->memory - screen_size;
     
     screen->fb[0].frameBuffer = sisc->frameBuffer;
@@ -451,10 +279,12 @@
     crtc->crtc_overflow			= GetCrtc (sisc, 0x07);
     crtc->preset_row_scan		= GetCrtc (sisc, 0x08);
     crtc->_max_scan_line		= GetCrtc (sisc, 0x09);
-    
+    crtc->cursor_start			= GetCrtc (sisc, 0x0a);
+    crtc->cursor_end			= GetCrtc (sisc, 0x0a);
     crtc->start_address_8_15		= GetCrtc (sisc, 0x0c);
     crtc->start_address_0_7		= GetCrtc (sisc, 0x0d);
-
+    crtc->text_cursor_15_8		= GetCrtc (sisc, 0x0e);
+    crtc->text_cursor_7_0		= GetCrtc (sisc, 0x0f);
     crtc->v_retrace_start_0_7		= GetCrtc (sisc, 0x10);
     crtc->_v_retrace_end		= GetCrtc (sisc, 0x11);
     crtc->v_display_end_0_7		= GetCrtc (sisc, 0x12);
@@ -472,8 +302,12 @@
     crtc->horizontal_pixel_pan		= GetArtc (sisc, 0x13);
 
     crtc->mode_register			= GetGrtc (sisc, 0x5);
+    crtc->misc_register			= GetGrtc (sisc, 0x6);
+    crtc->color_dont_care		= GetGrtc (sisc, 0x7);
     
     crtc->clock_mode			= GetSrtc (sisc, 0x1);
+    crtc->color_plane_w_enable		= GetSrtc (sisc, 0x2);
+    crtc->memory_mode			= GetSrtc (sisc, 0x4);
     
     crtc->graphics_mode			= GetSrtc (sisc, 0x6);
     crtc->misc_control_0    		= GetSrtc (sisc, 0x7);
@@ -530,7 +364,6 @@
 static void
 _sisSetCrtc (SisCardInfo *sisc, SisCrtc *crtc)
 {
-    _sisOutb(crtc->misc_output, sisc->io_base+0x4c);
     _sisSetBlank (sisc, TRUE);
     PutCrtc (sisc, 0x00, crtc->h_total_0_7);
     PutCrtc (sisc, 0x01, crtc->h_display_end_0_7);
@@ -542,10 +375,12 @@
     PutCrtc (sisc, 0x07, crtc->crtc_overflow);
     PutCrtc (sisc, 0x08, crtc->preset_row_scan);
     PutCrtc (sisc, 0x09, crtc->_max_scan_line);
-    
+    PutCrtc (sisc, 0x0a, crtc->cursor_start);
+    PutCrtc (sisc, 0x0b, crtc->cursor_end);
     PutCrtc (sisc, 0x0c, crtc->start_address_8_15);
     PutCrtc (sisc, 0x0d, crtc->start_address_0_7);
-
+    PutCrtc (sisc, 0x0e, crtc->text_cursor_15_8);
+    PutCrtc (sisc, 0x0f, crtc->text_cursor_7_0);
     PutCrtc (sisc, 0x10, crtc->v_retrace_start_0_7);
     PutCrtc (sisc, 0x11, crtc->_v_retrace_end);
     PutCrtc (sisc, 0x12, crtc->v_display_end_0_7);
@@ -562,8 +397,12 @@
     PutArtc (sisc, 0x13, crtc->horizontal_pixel_pan);
 
     PutGrtc (sisc, 0x5, crtc->mode_register);
+    PutGrtc (sisc, 0x6, crtc->misc_register);
+    PutGrtc (sisc, 0x7, crtc->color_dont_care);
     
     PutSrtc (sisc, 0x1, crtc->clock_mode | 0x20);
+    PutSrtc (sisc, 0x2, crtc->color_plane_w_enable);
+    PutSrtc (sisc, 0x4, crtc->memory_mode);
     
     PutSrtc (sisc, 0x6, crtc->graphics_mode);
     PutSrtc (sisc, 0x7, crtc->misc_control_0);
@@ -603,6 +442,24 @@
     PutSrtc (sisc, 0x3E, crtc->misc_control_11);
     PutSrtc (sisc, 0x3F, crtc->misc_control_12);
     
+#if 0
+    PutCrtc (sisc, 0x5b, 0x27);
+    PutCrtc (sisc, 0x5c, 0xe1);
+    PutCrtc (sisc, 0x5d, 0x00);
+
+    PutSrtc (sisc, 0x5a, 0xe6);
+    PutSrtc (sisc, 0x5d, 0xa1);
+    PutSrtc (sisc, 0x9a, 0xe6);
+    PutSrtc (sisc, 0x9d, 0xa1);
+    PutSrtc (sisc, 0xda, 0xe6);
+    PutSrtc (sisc, 0xdd, 0x6c);
+#endif
+    
+    _sisOutb(crtc->misc_output, sisc->io_base+0x42);
+    
+    outw (0x3c4, 0x0100);
+    outw (0x3c4, 0x0300);
+    
     _sisSetBlank (sisc, FALSE);
 }
 
@@ -623,7 +480,30 @@
     _sisOutb (value, base+1);
 }
 
+CARD8
+_sisReadArtc (CARD32 base, CARD8 index)
+{
+    CARD8   ret;
+    
+    _sisInb (base+0x1a);
+    _sisOutb (index,base);
+    ret = _sisInb (base+1);
+    _sisInb (base+0x1a);
+    _sisOutb (0x20,base);
+    return ret;
+}
+
 void
+_sisWriteArtc (CARD32 base, CARD8 index, CARD8 value)
+{
+    _sisInb (base+0x1a);
+    _sisOutb (index|0x20,base);
+    _sisOutb (value,base);
+    _sisInb (base+0x1a);
+    _sisOutb (0x20,base);
+}
+
+void
 sisPreserve (KdCardInfo *card)
 {
     SisCardInfo	*sisc = card->driver;
@@ -638,14 +518,19 @@
 	sisc->save.sr5 = 0x86;
     /* unlock extension registers */
     PutSrtc(sisc,0x5,0x86);
+    /* unlock CRTC registers */
+    PutCrtc(sisc,0x11,GetCrtc(sisc,0x11)&~0x80);
+    /* enable vga */
+    _sisOutb(0x1,sisc->io_base+0x43);
     
     /* enable MMIO access to registers */
     sisc->save.srb = GetSrtc(sisc,0xb);
     PutSrtc(sisc, 0xb, sisc->save.srb | 0x60);
     _sisGetCrtc (sisc, &sisc->save.crtc);
+    memcpy (sisc->save.text_save, sisc->frameBuffer, SIS_TEXT_SAVE);
 }
 
-void
+Bool
 sisEnable (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
@@ -653,7 +538,7 @@
     KdCardInfo	    *card = pScreenPriv->card;
     SisCardInfo	    *sisc = card->driver;
     SisScreenInfo   *siss = screen->driver;
-    SisTiming	    *t;
+    const KdMonitorTiming *t;
     SisCrtc	    crtc;
     unsigned long   pixel;
     
@@ -686,28 +571,64 @@
 
     crtc = sisc->save.crtc;
     
-    t = sisGetTiming (screen->width, screen->height, screen->rate);
+    t = KdFindMode (screen, sisModeSupported);
     
+    /* CR9 */
+    crtc.max_scan_line = 0;
+    
+    /* CRA */
+    crtc.cursor_start = 0;
+
+    /* CRB */
+    crtc.cursor_end = 0;
+    
+    /* CRE */
+    crtc.text_cursor_15_8 = 0;
+
+    /* CRF */
+    crtc.text_cursor_7_0 = 0;
+    
     /* CR11 */
     crtc.disable_v_retrace_int = 1;
     
+    /* CR14 */
+    crtc.underline_location = 0;
+    crtc.count_by_four = 0;
+    crtc.doubleword_mode = 1;
+    
     /* 3CC/3C2 */
     crtc.io_address_select = 1;
     crtc.display_ram_enable = 1;
     crtc.clock_select = 3;
     
+    /* SR1 */
+    crtc.clock_mode = 0;
+    crtc.dot_clock_8_9 = 1;
+
+    /* SR2 */
+    crtc.color_plane_w_enable = 0xf;
+
+    /* SR4 */
+    crtc.memory_mode = 0;
+    crtc.chain_4_enable = 1;
+    crtc.odd_even_disable = 1;
+    crtc.extended_memory_sz = 1;
+
     /* SR6 */
-    crtc.graphics_mode = 0;
     crtc.graphics_mode_linear = 1;
     crtc.enhanced_graphics_mode = 1;
     
+    /* SR9 */
+    crtc.crt_cpu_threshold_control_1 = 0;
+
     /* SRB */
+#if 0
     crtc.cpu_bitblt_enable = 1;
+#endif
     crtc.memory_mapped_mode = 3;
     
     /* SRC */
     crtc.graphics_mode_32bit_enable = 1;
-    crtc.text_mode_16bit_enable = 0;
     crtc.read_ahead_enable = 1;
     
     /* SR11 */
@@ -717,6 +638,24 @@
     crtc.vga_standby = 0;
     crtc.vga_suspend = 0;
     
+    crtc.cursor_0_red = 0x3f;
+    crtc.cursor_0_green = 0x3f;
+    crtc.cursor_0_blue = 0x3f;
+
+    /* SR20 */
+    crtc.linear_base_19_26 = (card->attr.address[0] & 0x07f80000) >> 19;
+
+    /* SR21 */
+    crtc.linear_base_27_31 = (card->attr.address[0] & 0xf8000000) >> 27;
+    crtc.linear_aperture   = SIS_LINEAR_APERTURE_4M;
+     
+    /* SR27 */
+    crtc.logical_screen_width = 3;
+    crtc.graphics_prog_enable = 1;
+    
+    /* SR38 */
+    crtc.extended_clock_select = 0;
+    
     /* AR10 */
     crtc.mode_control = 0;
     crtc.graphics_mode_enable = 1;
@@ -726,14 +665,17 @@
     crtc.enable_color_plane = 0xf;
     /* AR13 */
     crtc.horizontal_pixel_pan = 0;
-    
-    /* SR27 */
-    crtc.logical_screen_width = 3;
-    crtc.graphics_prog_enable = 1;
     
-    /* SR38 */
-    crtc.extended_clock_select = 0;
-    
+    /* GR5 */
+    crtc.mode_register = 0;
+
+    /* GR6 */
+    crtc.graphics_enable = 1;
+    crtc.chain_odd_even = 0;
+    crtc.memory_address_select = 1;
+
+    /* GR7 */
+    crtc.color_dont_care = 0xf;
     if (siss->cursor_base)
     {
 	crtc_set_cursor_start_addr (&crtc, siss->cursor_off);
@@ -861,7 +803,31 @@
     crtc_set_v_blank_start (&crtc, v_blank_start);
     crtc.v_blank_end_0_7 = v_blank_end;
     
+#if 0
+    crtc.h_blank_start_0_7 = 0x6a;
+    crtc._h_blank_end = 0x9a;
+    crtc.h_sync_start_0_7 = 0x6b;
+    crtc._h_sync_end = 0x9a;
+    
+    crtc.v_retrace_start_0_7 = 0x7d;
+    crtc._v_retrace_end = 0x23;
+    crtc.v_blank_start_0_7 = 0x7d;
+    crtc.v_blank_end_0_7 = 0x84;
+
+    crtc.crt_cpu_threshold_control_0 = 0xdf;	/* SR8 */
+    crtc.crt_cpu_threshold_control_1 = 0x00;	/* SR9 */
+    crtc.extended_clock_generator = 0x40;	/* SR13 */
+
+    crtc.cursor_h_start_0_7 = 0x83;
+    crtc.cursor_v_start_0_7 = 0x6c;
+
+    crtc.internal_vclk_0 = 0x68;
+    crtc.internal_vclk_1 = 0xc4;
+    crtc.misc_control_7 = 0x70;
+#endif
+    
     _sisSetCrtc (sisc, &crtc);
+    return TRUE;
 }
 
 Bool
@@ -905,6 +871,7 @@
 {
     SisCardInfo	*sisc = (SisCardInfo *) card->driver;
     
+    memcpy (sisc->frameBuffer, sisc->save.text_save, SIS_TEXT_SAVE);
     _sisSetCrtc (sisc, &sisc->save.crtc);
     PutSrtc (sisc, 0xb, sisc->save.srb);
     PutSrtc (sisc, 0x5, sisc->save.sr5);
@@ -926,7 +893,6 @@
     
     KdUnmapDevice (sisc->frameBuffer, sisc->memory);
     KdUnmapDevice (sisc->registers, sizeof (SisRec));
-    ioperm (sisc->io_base, 0x80, 0);
 }
 
 KdCardFuncs	sisFuncs = {
Index: xc/programs/Xserver/hw/kdrive/sis530/sis.h
diff -u xc/programs/Xserver/hw/kdrive/sis530/sis.h:1.4 xc/programs/Xserver/hw/kdrive/sis530/sis.h:1.6
--- xc/programs/Xserver/hw/kdrive/sis530/sis.h:1.4	Sat May  6 18:17:49 2000
+++ xc/programs/Xserver/hw/kdrive/sis530/sis.h	Sun Sep  3 01:11:19 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sis.h,v 1.4 2000/05/06 22:17:49 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sis.h,v 1.6 2000/09/03 05:11:19 keithp Exp $ */
 
 #ifndef _SIS_H_
 #define _SIS_H_
@@ -194,6 +194,25 @@
 					/* 8254 */
 } SisTrapezoid;
 
+typedef struct _sisAccel {
+    VOL8	pad[0x80];		/* 8200 */
+    VOL32	src_addr;	    	/* 8280 */
+    VOL32	dst_addr;		/* 8284 */
+    VOL32	pitch;			/* 8288 */
+    VOL32	dimension;		/* 828c */
+    VOL32	fg;			/* 8290 */
+    VOL32	bg;			/* 8294 */
+    
+
+    VOL32	clip_ul;		/* 82a0 */
+    VOL32	clip_br;		/* 82a4 */
+
+    VOL16	cmd;			/* 82aa */
+
+    VOL8	pattern[256];		/* 82ac */
+    
+} SisAccel;
+
 typedef struct _sis530 {
     union {
 	SisGeneral	general;
@@ -201,6 +220,7 @@
 	SisTransparent	transparent;
 	SisMultiple	multiple;
 	SisTrapezoid	trapezoid;
+	SisAccel	accel;
     } u;
 } SisRec, *SisPtr;
 
@@ -307,26 +327,29 @@
 
     union {
 	struct {
-	    CARD8   _max_scan_line	    : 5;
+	    CARD8   ___max_scan_line	    : 5;
 	    CARD8   _v_blank_start_9	    : 1;
 	    CARD8   _line_compare_9	    : 1;
-	    CARD8   _double_scan		    : 1;
+	    CARD8   _double_scan	    : 1;
 	} _max_scan_line_s;
 	CARD8   __max_scan_line;		    /* CR9 */
     } _max_scan_line_u;
 
-#define max_scan_line	_max_scan_line_u._max_scan_line_s._max_scan_line
+#define max_scan_line	_max_scan_line_u._max_scan_line_s.___max_scan_line
 #define v_blank_start_9	_max_scan_line_u._max_scan_line_s._v_blank_start_9
 #define line_compare_9	_max_scan_line_u._max_scan_line_s._line_compare_9
 #define double_scan	_max_scan_line_u._max_scan_line_s._double_scan
 #define _max_scan_line	_max_scan_line_u.__max_scan_line
     
-    CARD8   cursor_start;
-    CARD8   cursor_end;
+    CARD8   cursor_start;			    /* CRA */
+    CARD8   cursor_end;				    /* CRB */
 
     CARD8   start_address_8_15;			    /* CRC */
     CARD8   start_address_0_7;			    /* CRD */
 
+    CARD8   text_cursor_15_8;			    /* CRE */
+    CARD8   text_cursor_7_0;			    /* CRF */
+
     CARD8   cursor_loc_high;
     CARD8   cursor_loc_low;
 
@@ -355,7 +378,7 @@
     
     union {
 	struct {
-	    CARD8   _underline_location	    : 5;
+	    CARD8   ___underline_location   : 5;
 	    CARD8   _count_by_four	    : 1;
 	    CARD8   _doubleword_mode	    : 1;
 	    CARD8			    : 1;
@@ -363,7 +386,7 @@
 	CARD8   __underline_location;		    /* CR14 */
     } _underline_location_u;
 
-#define underline_location  _underline_location_u._underline_location_s._underline_location
+#define underline_location  _underline_location_u._underline_location_s.___underline_location
 #define count_by_four	    _underline_location_u._underline_location_s._count_by_four
 #define doubleword_mode	    _underline_location_u._underline_location_s._doubleword_mode
 #define _underline_location _underline_location_u.__underline_location
@@ -433,6 +456,24 @@
     
 #define mode_register	    _mode_register_u._mode_register
 #define color_mode_256	    _mode_register_u._mode_register_s._color_mode_256
+#define odd_even_addressing _mode_register_u._mode_register_s._odd_even_addressing
+
+    union {
+	struct {
+	    CARD8   _graphics_enable	    : 1;
+	    CARD8   _chain_odd_even	    : 1;
+	    CARD8   _memory_address_select  : 2;
+	    CARD8			    : 4;
+	} _misc_register_s;
+	CARD8   _misc_register;
+    } _misc_register_u;				    /* GR6 */
+
+#define misc_register	    _misc_register_u._misc_register
+#define graphics_enable	    _misc_register_u._misc_register_s._graphics_enable
+#define chain_odd_even	    _misc_register_u._misc_register_s._chain_odd_even
+#define memory_address_select _misc_register_u._misc_register_s._memory_address_select
+    
+    CARD8	color_dont_care;		    /* GR7 */
     
     union {
 	struct {
@@ -454,8 +495,26 @@
 #define shifter_load_32	    _clock_mode_u._clock_mode_s._shifter_load_32
 #define display_off	    _clock_mode_u._clock_mode_s._display_off
 
+    CARD8   color_plane_w_enable;		    /* SR2 */
+    
     union {
 	struct {
+	    CARD8			    : 1;
+	    CARD8   _extended_memory_size   : 1;
+	    CARD8   _odd_even_disable	    : 1;
+	    CARD8   _chain_4_enable	    : 1;
+	    CARD8			    : 4;
+	} _memory_mode_s;
+	CARD8	_memory_mode;
+    } _memory_mode_u;				    /* SR4 */
+
+#define memory_mode	    _memory_mode_u._memory_mode
+#define extended_memory_sz  _memory_mode_u._memory_mode_s._extended_memory_size
+#define	odd_even_disable    _memory_mode_u._memory_mode_s._odd_even_disable
+#define chain_4_enable	    _memory_mode_u._memory_mode_s._chain_4_enable
+    
+    union {
+	struct {
 	    CARD8   _enhanced_text_mode	    : 1;
 	    CARD8   _enhanced_graphics_mode : 1;
 	    CARD8   _graphics_mode_32k	    : 1;
@@ -700,6 +759,7 @@
     
 #define linear_base_1	    _linear_base_1_u._linear_base_1
 #define linear_base_27_31   _linear_base_1_u._linear_base_1_s._linear_base_27_31
+#define linear_aperture	    _linear_base_1_u._linear_base_1_s._linear_aperture
 
     union {
 	struct {
@@ -1027,8 +1087,8 @@
 #define GetSrtc(sisc,i)	    _sisReadIndexRegister ((sisc)->io_base+0x44,i)
 #define PutSrtc(sisc,i,v)   _sisWriteIndexRegister ((sisc)->io_base+0x44,i,v)
 
-#define GetArtc(sisc,i)	    _sisReadIndexRegister ((sisc)->io_base+0x40,i)
-#define PutArtc(sisc,i,v)   _sisWriteIndexRegister ((sisc)->io_base+0x40,i,v)
+#define GetArtc(sisc,i)	    _sisReadArtc ((sisc)->io_base+0x40,i)
+#define PutArtc(sisc,i,v)   _sisWriteArtc ((sisc)->io_base+0x40,i,v)
 
 #define GetGrtc(sisc,i)	    _sisReadIndexRegister ((sisc)->io_base+0x4e,i)
 #define PutGrtc(sisc,i,v)   _sisWriteIndexRegister ((sisc)->io_base+0x4e,i,v)
@@ -1053,10 +1113,13 @@
     int		vblank;	    /* blanking */
 } SisTiming;
 
+#define SIS_TEXT_SAVE	(64*1024)
+
 typedef struct _sisSave {
     CARD8	srb;
     CARD8	sr5;
     SisCrtc	crtc;
+    CARD8	text_save[SIS_TEXT_SAVE];
 } SisSave;
 
 typedef struct _sisCardInfo {
@@ -1086,7 +1149,7 @@
 
 Bool	sisCardInit (KdCardInfo *);
 Bool	sisScreenInit (KdScreenInfo *);
-void	sisEnable (ScreenPtr pScreen);
+Bool	sisEnable (ScreenPtr pScreen);
 void	sisDisable (ScreenPtr pScreen);
 void	sisFini (ScreenPtr pScreen);
 
@@ -1109,6 +1172,8 @@
 
 CARD8	_sisReadIndexRegister (CARD32 base, CARD8 index);
 void	_sisWriteIndexRegister (CARD32 base, CARD8 index, CARD8 value);
+CARD8	_sisReadArtc (CARD32 base, CARD8 index);
+void	_sisWriteArtc (CARD32 base, CARD8 index, CARD8 value);
 
 extern KdCardFuncs  sisFuncs;
 
Index: xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c
diff -u xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c:1.4 xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c:1.5
--- xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c:1.4	Sat May  6 18:17:50 2000
+++ xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c	Wed Aug  9 13:52:44 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c,v 1.4 2000/05/06 22:17:50 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c,v 1.5 2000/08/09 17:52:44 keithp Exp $ */
 
 #include "sis.h"
 #include "sisdraw.h"
@@ -1635,11 +1635,15 @@
     CARD32  cmd;
     CARD32  base;
     CARD16  stride;
+    CARD16  op;
     
     base = pScreenPriv->screen->fb[0].frameBuffer - sisc->frameBuffer;
     stride = pScreenPriv->screen->fb[0].byteStride;
+#if 0    
     sis->u.general.dst_base = base;
     sis->u.general.dst_pitch = stride;
+    sis->u.general.src_pitch = stride;
+    sis->u.general._pad0 = stride;
     sis->u.general.dst_height = pScreenPriv->screen->height;
     _sisClip (sis, 0, 0, 
 	      pScreenPriv->screen->width, pScreenPriv->screen->height);
@@ -1647,6 +1651,53 @@
     _sisRect (sis, 0, 0, 
 	      pScreenPriv->screen->width, pScreenPriv->screen->height,
 	      cmd);
+#endif
+    base = (CARD32) (pScreenPriv->screen->fb[0].frameBuffer);
+    fprintf (stderr, "src 0x%x\n", sis->u.accel.src_addr);
+    sis->u.accel.src_addr = (base & 0x3fffff);
+    fprintf (stderr, "src 0x%x\n", sis->u.accel.src_addr);
+    sis->u.accel.dst_addr = (base & 0x3fffff);
+    sis->u.accel.pitch = (stride << 16) | stride;
+    sis->u.accel.dimension = ((pScreenPriv->screen->height-1) << 16 | 
+			      (pScreenPriv->screen->width - 1));
+    sis->u.accel.fg = (sisBltRop[GXcopy] << 24) | 0xf800;
+    sis->u.accel.bg = (sisBltRop[GXcopy] << 24) | 0x00;
+    
+#define sisLEFT2RIGHT           0x10
+#define sisRIGHT2LEFT           0x00
+#define sisTOP2BOTTOM           0x20
+#define sisBOTTOM2TOP           0x00
+
+#define sisSRCSYSTEM            0x03
+#define sisSRCVIDEO		0x02
+#define sisSRCFG		0x01
+#define sisSRCBG		0x00
+
+#define sisCMDBLT		0x0000
+#define sisCMDBLTMSK		0x0100
+#define sisCMDCOLEXP		0x0200
+#define sisCMDLINE		0x0300
+
+#define sisCMDENHCOLEXP		0x2000
+
+#define sisXINCREASE		0x10
+#define sisYINCREASE		0x20
+#define sisCLIPENABL		0x40
+#define sisCLIPINTRN		0x80 
+#define sisCLIPEXTRN		0x00
+
+
+#define sisPATREG		0x08
+#define sisPATFG		0x04
+#define sisPATBG		0x00
+
+#define sisLASTPIX		0x0800
+#define sisXMAJOR		0x0400
+
+    op = sisCMDBLT | sisLEFT2RIGHT | sisTOP2BOTTOM | sisSRCFG | sisPATFG;
+    
+    sis->u.accel.cmd = op;
+    
     KdMarkSync (pScreen);
 }
 
Index: xc/programs/Xserver/hw/kdrive/sis530/sisstub.c
diff -u xc/programs/Xserver/hw/kdrive/sis530/sisstub.c:1.3 xc/programs/Xserver/hw/kdrive/sis530/sisstub.c:1.4
--- xc/programs/Xserver/hw/kdrive/sis530/sisstub.c:1.3	Wed Feb 23 15:30:09 2000
+++ xc/programs/Xserver/hw/kdrive/sis530/sisstub.c	Wed Aug  9 13:52:44 2000
@@ -22,16 +22,23 @@
  *
  * Author:  Keith Packard, SuSE, Inc.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sisstub.c,v 1.3 2000/02/23 20:30:09 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sisstub.c,v 1.4 2000/08/09 17:52:44 keithp Exp $ */
 
 #include "sis.h"
 
+static const int   sisCards[] = { 0x6306, 0x0200 };
+
+#define numSisCards (sizeof (sisCards) / sizeof (sisCards[0]))
+
 void
 InitCard (char *name)
 {
     KdCardAttr	attr;
-    if (LinuxFindPci (0x1039, 0x6306, 0, &attr))
-	KdCardInfoAdd (&sisFuncs, &attr, 0);
+    int		i;
+
+    for (i = 0; i < numSisCards; i++)
+	if (LinuxFindPci (0x1039, sisCards[i], 0, &attr))
+	    KdCardInfoAdd (&sisFuncs, &attr, (void *) sisCards[i]);
 }
 
 void
Index: xc/programs/Xserver/hw/kdrive/trident/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/trident/Imakefile:1.1 xc/programs/Xserver/hw/kdrive/trident/Imakefile:1.6
--- xc/programs/Xserver/hw/kdrive/trident/Imakefile:1.1	Fri Nov 19 08:54:00 1999
+++ xc/programs/Xserver/hw/kdrive/trident/Imakefile	Thu Oct 19 20:19:51 2000
@@ -1,14 +1,15 @@
 XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/trident/Imakefile,v 1.1 1999/11/19 13:54:00 hohndel Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/trident/Imakefile,v 1.6 2000/10/20 00:19:51 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
 
 SRCS = 	trident.c tridentdraw.c tridentcurs.c tridentstub.c
 
 OBJS = 	trident.o tridentdraw.o tridentcurs.o tridentstub.o
 
-INCLUDES = -I.. -I../fbdev -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../../fb -I../../../mi -I../../../include -I../../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+DEFINES = -DVESA /* -DUSE_PCI*/
+
+INCLUDES = -I. $(KDINCS) -I$(KDRIVE)/fbdev -I$(KDRIVE)/vesa
 
 NormalLibraryObjectRule()
 NormalLibraryTarget(trident,$(OBJS))
Index: xc/programs/Xserver/hw/kdrive/trident/trident.c
diff -u xc/programs/Xserver/hw/kdrive/trident/trident.c:1.5 xc/programs/Xserver/hw/kdrive/trident/trident.c:1.15
--- xc/programs/Xserver/hw/kdrive/trident/trident.c:1.5	Sat May  6 18:17:51 2000
+++ xc/programs/Xserver/hw/kdrive/trident/trident.c	Wed Nov 29 03:42:25 2000
@@ -1,5 +1,5 @@
 /*
- * Id: trident.c,v 1.2 1999/11/02 08:17:24 keithp Exp $
+ * $Id: trident.c,v 1.11 2000/09/24 13:52:40 alanh Exp $
  *
  * Copyright © 1999 Keith Packard
  *
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/trident.c,v 1.5 2000/05/06 22:17:51 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/trident.c,v 1.15 2000/11/29 08:42:25 keithp Exp $ */
 
 #include "trident.h"
 #define extern
@@ -30,27 +30,66 @@
 
 #undef TRI_DEBUG
 
+int	trident_clk = 0;
+int	trident_mclk = 0;
+
+#define CLOCK 14318	/* KHz */
+#define CLK_N(a,b)	(a & 0xff)
+#define CLK_M(a,b)	((b) & 0x3f)
+#define CLK_K(a,b)	(((b) >> 6) & 3)
+#define CLK_FREQ(a,b)	(((CLK_N(a,b) + 8) * CLOCK) / ((CLK_M(a,b)+2) << CLK_K(a,b)))
+
 Bool
 tridentCardInit (KdCardInfo *card)
 {
-    int		k;
-    char	*pixels;
+    int			k;
+    char		*pixels;
     TridentCardInfo	*tridentc;
+    CARD8		r39;
 
     tridentc = (TridentCardInfo *) xalloc (sizeof (TridentCardInfo));
     if (!tridentc)
 	return FALSE;
     
+    iopl (3);
+    tridentc->cop_base = (CARD8 *) KdMapDevice (TRIDENT_COP_BASE(card),
+						TRIDENT_COP_SIZE(card));
+    
+    if (tridentc->cop_base)
+    {
+	KdSetMappedMode (TRIDENT_COP_BASE(card),
+			 TRIDENT_COP_SIZE(card),
+			 KD_MAPPED_MODE_REGISTERS);
+    }
+    tridentc->cop = (Cop *) (tridentc->cop_base + TRIDENT_COP_OFF(card));
+    tridentc->mmio = FALSE;
+    r39 = tridentReadIndex (tridentc, 0x3d4, 0x39);
+    if (r39 & 1)
+    {
+	tridentc->mmio = TRUE;
+	r39 = tridentReadIndex (tridentc, 0x3d4, 0x39);
+	if ((r39 & 1) == 0)
+	{
+	    ErrorF ("Trident: inconsisent IO mapping values\n");
+	    return FALSE;
+	}
+    }
+    
+#ifdef VESA
+    if (!vesaInitialize (card, &tridentc->vesa))
+#else
     if (!fbdevInitialize (card, &tridentc->fb))
+#endif
     {
 	xfree (tridentc);
 	return FALSE;
     }
     
-    iopl (3);
-    tridentc->cop_base = (CARD8 *) KdMapDevice (TRIDENT_COP_BASE,
-					      TRIDENT_COP_SIZE);
-    tridentc->cop = (Cop *) (tridentc->cop_base + TRIDENT_COP_OFF);
+#ifdef USE_PCI
+    tridentc->window = (CARD32 *) (tridentc->cop_base + 0x10000);
+#else
+    tridentc->window = 0;
+#endif
     card->driver = tridentc;
     
     return TRUE;
@@ -67,21 +106,45 @@
     if (!tridents)
 	return FALSE;
     memset (tridents, '\0', sizeof (TridentScreenInfo));
-    if (!fbdevScreenInit (screen))
+#ifdef VESA
+    if (!vesaScreenInitialize (screen, &tridents->vesa))
+#else
+    if (!fbdevScreenInitialize (screen, &tridents->fbdev))
+#endif
     {
 	xfree (tridents);
 	return FALSE;
     }
     if (!tridentc->cop)
 	screen->dumb = TRUE;
-    screen_size = screen->fb[0].byteStride * screen->height;
+#ifdef VESA
+    if (tridents->vesa.mapping != VESA_LINEAR)
+	screen->dumb = TRUE;
+    tridents->screen = tridents->vesa.fb;
+    memory = tridents->vesa.fb_size;
+#else
+    tridents->screen = tridentc->fb.fb;
     memory = (2048 + 512) * 1024;
-    if (memory >= screen_size + 2048)
+#endif
+    screen_size = screen->fb[0].byteStride * screen->height;
+    if (tridents->screen && memory >= screen_size + 2048)
     {
-	tridents->cursor_base = tridentc->fb.fb + memory - 2048;
+	memory -= 2048;
+	tridents->cursor_base = tridents->screen + memory - 2048;
     }
     else
 	tridents->cursor_base = 0;
+    memory -= screen_size;
+    if (memory > screen->fb[0].byteStride)
+    {
+	tridents->off_screen = tridents->screen + screen_size;
+	tridents->off_screen_size = memory;
+    }
+    else
+    {
+	tridents->off_screen = 0;
+	tridents->off_screen_size = 0;
+    }
     screen->driver = tridents;
     return TRUE;
 }
@@ -89,7 +152,11 @@
 Bool
 tridentInitScreen (ScreenPtr pScreen)
 {
+#ifdef VESA
+    return vesaInitScreen (pScreen);
+#else
     return fbdevInitScreen (pScreen);
+#endif
 }
 
 CARD8
@@ -97,25 +164,71 @@
 {
     CARD8   value;
     
-    outb (index, port);
-    value = inb (port+1);
+    if (tridentc->mmio)
+    {
+	tridentc->cop_base[port] = index;
+	value = tridentc->cop_base[port+1];
+    }
+    else
+    {
+	outb (index, port);
+	value = inb (port+1);
+    }
     return value;
 }
 
 void
 tridentWriteIndex (TridentCardInfo *tridentc, CARD16 port, CARD8 index, CARD8 value)
 {
-    outb (index, port);
-    outb (value, port+1);
+    if (tridentc->mmio)
+    {
+	tridentc->cop_base[port] = index;
+	tridentc->cop_base[port+1] = value;
+    }
+    else
+    {
+	outb (index, port);
+	outb (value, port+1);
+    }
 }
 
+CARD8
+tridentReadReg (TridentCardInfo *tridentc, CARD16 port)
+{
+    CARD8   value;
+    
+    if (tridentc->mmio)
+    {
+	value = tridentc->cop_base[port];
+    }
+    else
+    {
+	value = inb (port);
+    }
+    return value;
+}
+
 void
+tridentWriteReg (TridentCardInfo *tridentc, CARD16 port, CARD8 value)
+{
+    if (tridentc->mmio)
+    {
+	tridentc->cop_base[port] = value;
+    }
+    else
+    {
+	outb (value, port);
+    }
+}
+
+
+void
 tridentPause ()
 {
     struct timeval  tv;
 
     tv.tv_sec = 0;
-    tv.tv_usec = 200 * 1000;
+    tv.tv_usec = 50 * 1000;
     select (1, 0, 0, 0, &tv);
 }
 
@@ -124,12 +237,27 @@
 {
     TridentCardInfo	*tridentc = card->driver;
 
+#ifdef VESA
+    vesaPreserve(card);
+#else
     fbdevPreserve (card);
+#endif
+    tridentPause ();
     tridentc->save.reg_3c4_0e = tridentReadIndex (tridentc, 0x3c4, 0x0e);
     tridentc->save.reg_3d4_36 = tridentReadIndex (tridentc, 0x3d4, 0x36);
     tridentc->save.reg_3d4_39 = tridentReadIndex (tridentc, 0x3d4, 0x39);
     tridentc->save.reg_3d4_62 = tridentReadIndex (tridentc, 0x3d4, 0x62);
     tridentc->save.reg_3ce_21 = tridentReadIndex (tridentc, 0x3ce, 0x21);
+    tridentc->save.reg_3c2 = tridentReadReg (tridentc, 0x3cc);
+    tridentc->save.reg_3c4_16 = tridentReadIndex (tridentc, 0x3c4, 0x16);
+    tridentc->save.reg_3c4_17 = tridentReadIndex (tridentc, 0x3c4, 0x17);
+    tridentc->save.reg_3c4_18 = tridentReadIndex (tridentc, 0x3c4, 0x18);
+    tridentc->save.reg_3c4_19 = tridentReadIndex (tridentc, 0x3c4, 0x19);
+    ErrorF ("clk low 0x%x high 0x%x freq %d\n",
+	    tridentc->save.reg_3c4_18,
+	    tridentc->save.reg_3c4_19,
+	    CLK_FREQ(tridentc->save.reg_3c4_18,
+		     tridentc->save.reg_3c4_19));
 #ifdef TRI_DEBUG
     fprintf (stderr, "3c4 0e: %02x\n", tridentc->save.reg_3c4_0e);
     fprintf (stderr, "3d4 36: %02x\n", tridentc->save.reg_3d4_36);
@@ -142,6 +270,98 @@
 }
 
 void
+tridentSetCLK(int clock, CARD8 *a, CARD8 *b)
+{
+    int powerup[4] = { 1,2,4,8 };
+    int clock_diff = 750;
+    int freq, ffreq;
+    int m, n, k;
+    int p, q, r, s; 
+    int startn, endn;
+    int endm, endk;
+
+    p = q = r = s = 0;
+
+    startn = 64;
+    endn = 255;
+    endm = 63;
+    endk = 3;
+
+    freq = clock;
+
+    for (k=0;k<=endk;k++)
+	for (n=startn;n<=endn;n++)
+	    for (m=1;m<=endm;m++)
+	    {
+		ffreq = ( ( ((n + 8) * CLOCK) / ((m + 2) * powerup[k]) ));
+		if ((ffreq > freq - clock_diff) && (ffreq < freq + clock_diff)) 
+		{
+		    clock_diff = (freq > ffreq) ? freq - ffreq : ffreq - freq;
+		    p = n; q = m; r = k; s = ffreq;
+		}
+	    }
+
+    ErrorF ("ffreq %d clock %d\n", s, clock);
+    if (s == 0)
+    {
+	FatalError("Unable to set programmable clock.\n"
+		   "Frequency %d is not a valid clock.\n"
+		   "Please modify XF86Config for a new clock.\n",	
+		   freq);
+    }
+
+    /* N is all 8bits */
+    *a = p;
+    /* M is first 6bits, with K last 2bits */
+    *b = (q & 0x3F) | (r << 6);
+}
+
+void
+tridentSetMCLK(int clock, CARD8 *a, CARD8 *b)
+{
+    int powerup[4] = { 1,2,4,8 };
+    int clock_diff = 750;
+    int freq, ffreq;
+    int m,n,k;
+    int p, q, r, s; 
+    int startn, endn;
+    int endm, endk;
+
+    p = q = r = s = 0;
+
+    startn = 64;
+    endn = 255;
+    endm = 63;
+    endk = 3;
+
+    freq = clock;
+
+    for (k=0;k<=endk;k++)
+	for (n=startn;n<=endn;n++)
+	    for (m=1;m<=endm;m++) {
+		ffreq = ((((n+8)*CLOCK)/((m+2)*powerup[k])));
+		if ((ffreq > freq - clock_diff) && (ffreq < freq + clock_diff)) 
+		{
+		    clock_diff = (freq > ffreq) ? freq - ffreq : ffreq - freq;
+		    p = n; q = m; r = k; s = ffreq;
+		}
+	    }
+
+    if (s == 0)
+    {
+	FatalError("Unable to set memory clock.\n"
+		   "Frequency %d is not a valid clock.\n"
+		   "Please modify XF86Config for a new clock.\n",	
+		   freq);
+    }
+
+    /* N is all 8bits */
+    *a = p;
+    /* M is first 6bits, with K last 2bits */
+    *b = (q & 0x3F) | (r << 6);
+}
+
+void
 tridentSetMMIO (TridentCardInfo *tridentc)
 {
     int	tries;
@@ -169,10 +389,62 @@
 	}
 	/* enable screen */
 	tridentWriteIndex (tridentc, 0x3ce, 0x21, 0x80);
+#ifdef USE_PCI
+	/* enable burst r/w, enable memory mapped ports */
+	tridentWriteIndex (tridentc, 0x3d4, 0x39, 7);
+	tridentc->mmio = TRUE;
+	/* reset GE, enable GE, set GE to pci 1 */
+	tridentWriteIndex (tridentc, 0x3d4, 0x36, 0x90);
+#else
 	/* enable burst r/w, disable memory mapped ports */
 	tridentWriteIndex (tridentc, 0x3d4, 0x39, 0x6);
 	/* reset GE, enable GE, set GE to 0xbff00 */
 	tridentWriteIndex (tridentc, 0x3d4, 0x36, 0x92);
+#endif
+	/* set clock */
+	if (trident_clk)
+	{
+	    CARD8   a, b;
+
+	    a = tridentReadIndex (tridentc, 0x3c4, 0x18);
+	    b = tridentReadIndex (tridentc, 0x3c4, 0x19);
+	    ErrorF ("old clock 0x%x 0x%x %d\n", 
+		    a, b, CLK_FREQ(a,b));
+	    tridentSetCLK (trident_clk, &a, &b);
+	    ErrorF ("clk %d-> 0x%x 0x%x %d\n", trident_clk, a, b,
+		    CLK_FREQ(a,b));
+#if 1
+	    tridentWriteIndex (tridentc, 0x3c4, 0x18, a);
+	    tridentWriteIndex (tridentc, 0x3c4, 0x19, b);
+#endif
+	}
+	if (trident_mclk)
+	{
+	    CARD8   a, b;
+
+	    tridentSetMCLK (trident_mclk, &a, &b);
+	    ErrorF ("mclk %d -> 0x%x 0x%x\n", trident_mclk, a, b);
+#if 0
+	    tridentWriteIndex (tridentc, 0x3c4, 0x16, a);
+	    tridentWriteIndex (tridentc, 0x3c4, 0x17, b);
+#endif
+	}
+	if (trident_clk || trident_mclk)
+	{
+	    CARD8   mode;
+
+	    mode = tridentReadReg (tridentc, 0x3cc);
+	    ErrorF ("old mode 0x%x\n", mode);
+	    mode = (mode & 0xf3) | 0x08;
+	    ErrorF ("new mode 0x%x\n", mode);
+#if 1
+	    tridentWriteReg (tridentc, 0x3c2, mode);
+#endif
+	}
+#ifdef TRI_DEBUG
+	fprintf (stderr, "0x36: 0x%02x\n",
+		 tridentReadIndex (tridentc, 0x3d4, 0x36));
+#endif
 	if (tridentc->cop->status != 0xffffffff)
 	    break;
     }
@@ -189,28 +461,50 @@
 #ifdef TRI_DEBUG
     fprintf (stderr, "Reset MMIO\n");
 #endif
+    tridentPause ();
+#if 0
+    tridentWriteIndex (tridentc, 0x3c4, 0x16, tridentc->save.reg_3c4_16);
+    tridentWriteIndex (tridentc, 0x3c4, 0x17, tridentc->save.reg_3c4_17);
+#endif
+    tridentWriteIndex (tridentc, 0x3c4, 0x18, tridentc->save.reg_3c4_18);
+    tridentWriteIndex (tridentc, 0x3c4, 0x19, tridentc->save.reg_3c4_19);
+    tridentWriteReg (tridentc, 0x3c2, tridentc->save.reg_3c2);
+    tridentPause ();
     tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentc->save.reg_3ce_21);
+    tridentPause ();
     tridentWriteIndex (tridentc, 0x3d4, 0x62, tridentc->save.reg_3d4_62);
     tridentWriteIndex (tridentc, 0x3d4, 0x39, tridentc->save.reg_3d4_39);
+    tridentc->mmio = FALSE;
     tridentWriteIndex (tridentc, 0x3d4, 0x36, tridentc->save.reg_3d4_36);
     tridentWriteIndex (tridentc, 0x3c4, 0x0e, tridentc->save.reg_3c4_0e);
     tridentPause ();
 }
 
-void
+Bool
 tridentEnable (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
     TridentCardInfo	*tridentc = pScreenPriv->card->driver;
 
-    fbdevEnable (pScreen);
+#ifdef VESA
+    if (!vesaEnable (pScreen))
+	return FALSE;
+#else
+    if (!fbdevEnable (pScreen))
+	return FALSE;
+#endif
     tridentSetMMIO (tridentc);
+    return TRUE;
 }
 
 void
 tridentDisable (ScreenPtr pScreen)
 {
+#ifdef VESA
+    vesaDisable (pScreen);
+#else
     fbdevDisable (pScreen);
+#endif
 }
 
 const CARD8	tridentDPMSModes[4] = {
@@ -229,6 +523,7 @@
     TridentCardInfo	*tridentc = pScreenPriv->card->driver;
 
     tridentWriteIndex (tridentc, 0x3ce, 0x21, tridentDPMSModes[mode]);
+    tridentPause ();
     return TRUE;
 }
 
@@ -238,7 +533,11 @@
     TridentCardInfo	*tridentc = card->driver;
 
     tridentResetMMIO (tridentc);
+#ifdef VESA
+    vesaRestore (card);
+#else
     fbdevRestore (card);
+#endif
 }
 
 void
@@ -246,6 +545,9 @@
 {
     TridentScreenInfo	*tridents = (TridentScreenInfo *) screen->driver;
 
+#ifdef VESA
+    vesaScreenFini (screen);
+#endif
     xfree (tridents);
     screen->driver = 0;
 }
@@ -256,8 +558,17 @@
     TridentCardInfo	*tridentc = card->driver;
 
     if (tridentc->cop_base)
-	KdUnmapDevice ((void *) tridentc->cop_base, TRIDENT_COP_SIZE);
+    {
+	KdUnmapDevice ((void *) tridentc->cop_base, TRIDENT_COP_SIZE(card));
+	KdResetMappedMode (TRIDENT_COP_BASE(card),
+			   TRIDENT_COP_SIZE(card),
+			   KD_MAPPED_MODE_REGISTERS);
+    }
+#ifdef VESA
+    vesaCardFini (card);
+#else
     fbdevCardFini (card);
+#endif
 }
 
 KdCardFuncs	tridentFuncs = {
@@ -284,6 +595,11 @@
     tridentDrawDisable,     /* disableAccel */
     tridentDrawFini,        /* finiAccel */
     
+#ifdef VESA
+    vesaGetColors,    	    /* getColors */
+    vesaPutColors,	    /* putColors */
+#else
     fbdevGetColors,    	    /* getColors */
     fbdevPutColors,	    /* putColors */
+#endif
 };
Index: xc/programs/Xserver/hw/kdrive/trident/trident.h
diff -u xc/programs/Xserver/hw/kdrive/trident/trident.h:1.3 xc/programs/Xserver/hw/kdrive/trident/trident.h:1.9
--- xc/programs/Xserver/hw/kdrive/trident/trident.h:1.3	Wed Feb 23 15:30:10 2000
+++ xc/programs/Xserver/hw/kdrive/trident/trident.h	Wed Nov 29 03:42:25 2000
@@ -21,19 +21,30 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/trident.h,v 1.3 2000/02/23 20:30:10 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/trident.h,v 1.9 2000/11/29 08:42:25 keithp Exp $ */
 
 #ifndef _TRIDENT_H_
 #define _TRIDENT_H_
+#ifdef VESA
+#include <vesa.h>
+#else
 #include <fbdev.h>
+#endif
 
 /*
  * offset from ioport beginning 
  */
-#define TRIDENT_COP_BASE	0xbf000
-#define TRIDENT_COP_OFF		0x00f00
-#define TRIDENT_COP_SIZE	(0x2000)
 
+#ifdef USE_PCI
+#define TRIDENT_COP_BASE(c)	(c->attr.address[1])
+#define TRIDENT_COP_OFF(c)	0x2100
+#define TRIDENT_COP_SIZE(c)	0x20000
+#else
+#define TRIDENT_COP_BASE(c)	0xbf000
+#define TRIDENT_COP_OFF(c)    	0x00f00
+#define TRIDENT_COP_SIZE(c)	(0x2000)
+#endif
+
 typedef volatile CARD8	VOL8;
 typedef volatile CARD16	VOL16;
 typedef volatile CARD32	VOL32;
@@ -68,6 +79,31 @@
 #define COP_DEPTH_DITHER_DISABLE    0x00000008
     
 
+#define COP_ALPHA_SRC_BLEND_0	    0x00000000
+#define COP_ALPHA_SRC_BLEND_1	    0x00000001
+#define COP_ALPHA_SRC_BLEND_SRC_C   0x00000002
+#define COP_ALPHA_SRC_BLEND_1_SRC_C 0x00000003
+#define COP_ALPHA_SRC_BLEND_SRC_A   0x00000004
+#define COP_ALPHA_SRC_BLEND_1_SRC_A 0x00000005
+#define COP_ALPHA_SRC_BLEND_DST_A   0x00000006
+#define COP_ALPHA_SRC_BLEND_1_DST_A 0x00000007
+#define COP_ALPHA_SRC_BLEND_DST_C   0x00000008
+#define COP_ALPHA_SRC_BLEND_1_DST_C 0x00000009
+#define COP_ALPHA_SRC_BLEND_SAT     0x0000000A
+#define COP_ALPHA_SRC_BLEND_BG      0x0000000B
+
+#define COP_ALPHA_DST_BLEND_0	    0x00000000
+#define COP_ALPHA_DST_BLEND_1	    0x00000010
+#define COP_ALPHA_DST_BLEND_SRC_C   0x00000020
+#define COP_ALPHA_DST_BLEND_1_SRC_C 0x00000030
+#define COP_ALPHA_DST_BLEND_SRC_A   0x00000040
+#define COP_ALPHA_DST_BLEND_1_SRC_A 0x00000050
+#define COP_ALPHA_DST_BLEND_DST_A   0x00000060
+#define COP_ALPHA_DST_BLEND_1_DST_A 0x00000070
+#define COP_ALPHA_DST_BLEND_DST_C   0x00000080
+#define COP_ALPHA_DST_BLEND_1_DST_C 0x00000090
+#define COP_ALPHA_DST_BLEND_OTHER   0x000000A0
+
 #define COP_ALPHA_RESULT_ALPHA	    0x00100000
 #define COP_ALPHA_DEST_ALPHA	    0x00200000
 #define COP_ALPHA_SOURCE_ALPHA	    0x00400000
@@ -143,14 +179,25 @@
     CARD8   reg_3d4_39;
     CARD8   reg_3d4_62;	/* GE setup */
     CARD8   reg_3ce_21;	/* DPMS */
+    CARD8   reg_3c2;	/* clock config */
+    CARD8   reg_3c4_16;	/* MCLKLow */
+    CARD8   reg_3c4_17;	/* MCLKHigh */
+    CARD8   reg_3c4_18;	/* ClockLow */
+    CARD8   reg_3c4_19; /* ClockHigh */
 } TridentSave;
 
 typedef struct _tridentCardInfo {
+#ifdef VESA
+    VesaCardPrivRec	vesa;
+#else
     FbdevPriv		fb;
+#endif
     CARD8		*cop_base;
     Cop			*cop;
+    CARD32		*window;
     CARD32		cop_depth;
     CARD32		cop_stride;
+    Bool		mmio;
     TridentSave		save;
 } TridentCardInfo;
     
@@ -169,7 +216,15 @@
 #define TRIDENT_CURSOR_HEIGHT	64
 
 typedef struct _tridentScreenInfo {
+#ifdef VESA
+    VesaScreenPrivRec	vesa;
+#else
+    FbdevScrPriv    fbdev;
+#endif
     CARD8	    *cursor_base;
+    CARD8	    *screen;
+    CARD8	    *off_screen;
+    int		    off_screen_size;
     TridentCursor   cursor;
 } TridentScreenInfo;
 
Index: xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c
diff -u xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c:1.4 xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c:1.6
--- xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c:1.4	Sat May  6 18:17:51 2000
+++ xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c	Sun Sep  3 01:11:20 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c,v 1.4 2000/05/06 22:17:51 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c,v 1.6 2000/09/03 05:11:20 keithp Exp $ */
 
 #include "trident.h"
 #include "cursorstr.h"
@@ -221,7 +221,7 @@
     }
     
     /* Set address for cursor bits */
-    offset = tridents->cursor_base - (CARD8 *) tridentc->fb.fb;
+    offset = tridents->cursor_base - (CARD8 *) tridents->screen;
     offset >>= 10;
     tridentWriteIndex (tridentc, 0x3d4, 0x44, (CARD8) (offset & 0xff));
     tridentWriteIndex (tridentc, 0x3d4, 0x45, (CARD8) (offset >> 8));
Index: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c
diff -u xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c:1.4 xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c:1.7
--- xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c:1.4	Sat May  6 18:17:51 2000
+++ xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c	Wed Nov 29 03:42:25 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c,v 1.4 2000/05/06 22:17:51 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c,v 1.7 2000/11/29 08:42:25 keithp Exp $ */
 
 #include "trident.h"
 #include "tridentdraw.h"
@@ -37,6 +37,7 @@
 #include	"fb.h"
 #include	"migc.h"
 #include	"miline.h"
+#include	"picturestr.h"
 
 CARD8 tridentRop[16] = {
     /* GXclear      */      0x00,         /* 0 */
@@ -151,6 +152,7 @@
 	    cop->dst_end_xy   = TRI_XY (pbox->x2 - 1,
 					pbox->y2 - 1);
 	}
+	_tridentWaitDone(cop);
 	cop->command = cmd;
 	pbox++;
     }
@@ -636,7 +638,7 @@
     KdCheckPolyArc,
     miFillPolygon,
     tridentPolyFillRect,
-    KdCheckPolyFillArc,
+    miPolyFillArc,
     miPolyText8,
     miPolyText16,
     miImageText8,
@@ -685,6 +687,234 @@
 }
 
 void
+tridentComposite (CARD8      op,
+		  PicturePtr pSrc,
+		  PicturePtr pMask,
+		  PicturePtr pDst,
+		  INT16      xSrc,
+		  INT16      ySrc,
+		  INT16      xMask,
+		  INT16      yMask,
+		  INT16      xDst,
+		  INT16      yDst,
+		  CARD16     width,
+		  CARD16     height)
+{
+    SetupTrident (pDst->pDrawable->pScreen);
+    tridentScreenInfo(pScreenPriv);
+    RegionRec	region;
+    int		n;
+    BoxPtr	pbox;
+    CARD32	rgb;
+    CARD8	*msk, *mskLine;
+    FbBits	*mskBits;
+    FbStride	mskStride;
+    int		mskBpp;
+    CARD32	*src, *srcLine;
+    CARD32	*off, *offLine;
+    FbBits	*srcBits;
+    FbStride	srcStride;
+    FbStride	offStride;
+    int		srcBpp;
+    int		x_msk, y_msk, x_src, y_src, x_dst, y_dst;
+    int		x2;
+    int		w, h, w_this, h_this, w_remain;
+    CARD32	*off_screen;
+    int		off_size = tridents->off_screen_size >> 2;
+    int		off_width, off_height;
+    int		stride = pScreenPriv->screen->fb[0].pixelStride;
+    int		mskExtra;
+    CARD32	off_screen_offset = tridents->off_screen - tridents->screen;
+    int		mode;
+    
+#define MODE_NONE   0
+#define MODE_IMAGE  1
+#define MODE_MASK   2
+    
+    rgb = *((CARD32 *) ((PixmapPtr) (pSrc->pDrawable))->devPrivate.ptr);
+    if (pMask && 
+	!pMask->repeat &&
+	pMask->format == PICT_a8 &&
+        op == PictOpOver &&
+	pSrc->repeat &&
+	pSrc->pDrawable->width == 1 &&
+	pSrc->pDrawable->height == 1 &&
+	PICT_FORMAT_BPP(pSrc->format) == 32 &&
+	(PICT_FORMAT_A(pSrc->format) == 0 ||
+	 (rgb & 0xff000000) == 0xff000000) &&
+	pDst->pDrawable->bitsPerPixel == 32 &&
+	pDst->pDrawable->type == DRAWABLE_WINDOW)
+    {
+	mode = MODE_MASK;
+    }
+    else if (!pMask &&
+	     op == PictOpOver &&
+	     !pSrc->repeat &&
+	     PICT_FORMAT_A(pSrc->format) == 8 &&
+	     PICT_FORMAT_BPP(pSrc->format) == 32 &&
+	     pDst->pDrawable->bitsPerPixel == 32 &&
+	     pDst->pDrawable->type == DRAWABLE_WINDOW)
+    {
+	mode = MODE_IMAGE;
+    }
+    else
+	mode = MODE_NONE;
+    
+    if (mode != MODE_NONE)
+    {
+	xDst += pDst->pDrawable->x;
+	yDst += pDst->pDrawable->y;
+	xSrc += pSrc->pDrawable->x;
+	ySrc += pSrc->pDrawable->y;
+	
+	fbGetDrawable (pSrc->pDrawable, srcBits, srcStride, srcBpp);
+	
+	if (pMask)
+	{
+	    xMask += pMask->pDrawable->x;
+	    yMask += pMask->pDrawable->y;
+	    fbGetDrawable (pMask->pDrawable, mskBits, mskStride, mskBpp);
+	    mskStride = mskStride * sizeof (FbBits) / sizeof (CARD8);
+	}
+	
+	if (!miComputeCompositeRegion (&region,
+				       pSrc,
+				       pMask,
+				       pDst,
+				       xSrc,
+				       ySrc,
+				       xMask,
+				       yMask,
+				       xDst,
+				       yDst,
+				       width,
+				       height))
+	    return;
+	
+	_tridentInit(cop,tridentc);
+	
+	cop->multi = COP_MULTI_PATTERN;
+	cop->src_offset = off_screen_offset;
+	
+	if (mode == MODE_IMAGE)
+	{
+	    cop->multi = (COP_MULTI_ALPHA |
+			  COP_ALPHA_BLEND_ENABLE |
+			  COP_ALPHA_WRITE_ENABLE |
+			  0x7 << 16 |
+			  COP_ALPHA_DST_BLEND_1_SRC_A |
+			  COP_ALPHA_SRC_BLEND_1);
+	}
+	else
+	{
+	    rgb &= 0xffffff;
+	    cop->multi = (COP_MULTI_ALPHA |
+			  COP_ALPHA_BLEND_ENABLE |
+			  COP_ALPHA_WRITE_ENABLE |
+			  0x7 << 16 |
+			  COP_ALPHA_DST_BLEND_1_SRC_A |
+			  COP_ALPHA_SRC_BLEND_SRC_A);
+	}
+	
+	n = REGION_NUM_RECTS (&region);
+	pbox = REGION_RECTS (&region);
+	
+	while (n--)
+	{
+	    h = pbox->y2 - pbox->y1;
+	    w = pbox->x2 - pbox->x1;
+	    
+	    offStride = (w + 7) & ~7;
+	    off_height = off_size / offStride;
+	    if (off_height > h)
+		off_height = h;
+	    
+	    cop->multi = COP_MULTI_STRIDE | (stride << 16) | offStride;
+	    
+	    y_dst = pbox->y1;
+	    y_src = y_dst - yDst + ySrc;
+	    y_msk = y_dst - yDst + yMask;
+	    
+	    x_dst = pbox->x1;
+	    x_src = x_dst - xDst + xSrc;
+	    x_msk = x_dst - xDst + xMask;
+	
+	    if (mode == MODE_IMAGE)
+		srcLine = (CARD32 *) srcBits + y_src * srcStride + x_src;
+	    else
+		mskLine = (CARD8 *) mskBits + y_msk * mskStride + x_msk;
+
+	    while (h)
+	    {
+		h_this = h;
+		if (h_this > off_height)
+		    h_this = off_height;
+		h -= h_this;
+		
+		offLine = (CARD32 *) tridents->off_screen;
+		
+		_tridentWaitDone(cop);
+		
+		cop->dst_start_xy = TRI_XY(x_dst, y_dst);
+		cop->dst_end_xy = TRI_XY(x_dst + w - 1, y_dst + h_this - 1);
+		cop->src_start_xy = TRI_XY(0,0);
+		cop->src_end_xy = TRI_XY(w - 1, h_this - 1);
+					 
+		if (mode == MODE_IMAGE)
+		{
+		    while (h_this--)
+		    {
+			w_remain = w;
+			src = srcLine;
+			srcLine += srcStride;
+			off = offLine;
+			offLine += offStride;
+			while (w_remain--)
+			    *off++ = *src++;
+		    }
+		}
+		else
+		{
+		    while (h_this--)
+		    {
+			w_remain = w;
+			msk = mskLine;
+			mskLine += mskStride;
+			off = offLine;
+			offLine += offStride;
+			while (w_remain--)
+			    *off++ = rgb | (*msk++ << 24);
+		    }
+		}
+		
+		cop->command = (COP_OP_BLT |
+				COP_SCL_OPAQUE |
+				COP_OP_FB);
+	    }
+	    pbox++;
+	}
+	cop->src_offset = 0;
+	
+	KdMarkSync (pDst->pDrawable->pScreen);
+    }
+    else
+    {
+	KdCheckComposite (op,
+			  pSrc,
+			  pMask,
+			  pDst,
+			  xSrc,
+			  ySrc,
+			  xMask,
+			  yMask,
+			  xDst,
+			  yDst,
+			  width,
+			  height);
+    }
+}
+
+void
 tridentCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 {
     ScreenPtr	pScreen = pWin->drawable.pScreen;
@@ -786,6 +1016,10 @@
 Bool
 tridentDrawInit (ScreenPtr pScreen)
 {
+    SetupTrident(pScreen);
+    tridentScreenInfo(pScreenPriv);
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+    
     /*
      * Hook up asynchronous drawing
      */
@@ -797,6 +1031,9 @@
     pScreen->CopyWindow = tridentCopyWindow;
     pScreen->PaintWindowBackground = tridentPaintWindow;
     pScreen->PaintWindowBorder = tridentPaintWindow;
+
+    if (ps && tridents->off_screen)
+	ps->Composite = tridentComposite;
     
     return TRUE;
 }
@@ -811,6 +1048,7 @@
     CARD32  format;
     CARD32  alpha;
     int	    tries;
+    int	    nwrite;
     
     stride = pScreenPriv->screen->fb[0].pixelStride;
     switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
Index: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h
diff -u xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h:1.3 xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h:1.4
--- xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h:1.3	Wed Feb 23 15:30:11 2000
+++ xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h	Wed Oct 11 02:04:40 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h,v 1.3 2000/02/23 20:30:11 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.h,v 1.4 2000/10/11 06:04:40 keithp Exp $ */
 
 #ifndef _TRIDENTDRAW_H_
 #define _TRIDENTDRAW_H_
@@ -49,15 +49,21 @@
 #define _tridentRect(cop,x1,y1,x2,y2,cmd) { \
     (cop)->dst_start_xy = TRI_XY (x1,y1); \
     (cop)->dst_end_xy = TRI_XY(x2,y2); \
+    _tridentWaitDone(cop); \
     (cop)->command = (cmd); \
 }
 
 #define COP_STATUS_BUSY	(COP_STATUS_BE_BUSY | \
 			 COP_STATUS_DPE_BUSY | \
-			 COP_STATUS_MI_BUSY | \
-			 COP_STATUS_FIFO_BUSY)
+			 COP_STATUS_MI_BUSY)
 
-#define _tridentWaitDone(cop)   while ((cop)->status & COP_STATUS_BUSY)
+#define _tridentWaitDone(cop)   { \
+    int __q__ = 500000; \
+    while (__q__-- && (cop)->status & COP_STATUS_BUSY) \
+	; \
+    if (!__q__) \
+	(cop)->status = 0;  \
+}
 
 #define _tridentWaitIdleEmpty(cop)	_tridentWaitDone(cop)
 
Index: xc/programs/Xserver/hw/kdrive/trident/tridentstub.c
diff -u xc/programs/Xserver/hw/kdrive/trident/tridentstub.c:1.3 xc/programs/Xserver/hw/kdrive/trident/tridentstub.c:1.5
--- xc/programs/Xserver/hw/kdrive/trident/tridentstub.c:1.3	Wed Feb 23 15:30:11 2000
+++ xc/programs/Xserver/hw/kdrive/trident/tridentstub.c	Wed Nov 29 03:42:25 2000
@@ -22,10 +22,12 @@
  *
  * Author:  Keith Packard, SuSE, Inc.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentstub.c,v 1.3 2000/02/23 20:30:11 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentstub.c,v 1.5 2000/11/29 08:42:25 keithp Exp $ */
 
 #include "trident.h"
 
+extern int  trident_clk, trident_mclk;
+
 void
 InitCard (char *name)
 {
@@ -50,5 +52,28 @@
 int
 ddxProcessArgument (int argc, char **argv, int i)
 {
-    return KdProcessArgument (argc, argv, i);
+    int	ret;
+    
+    if (!strcmp (argv[i], "-clk")) 
+    {
+	if (i+1 < argc)
+	    trident_clk = atoi (argv[i+1]);
+	else
+	    UseMsg ();
+	return 2;
+    }
+    if (!strcmp (argv[i], "-mclk")) 
+    {
+	if (i+1 < argc)
+	    trident_mclk = atoi (argv[i+1]);
+	else
+	    UseMsg ();
+	return 2;
+    }
+	
+#ifdef VESA
+    if (!(ret = vesaProcessArgument (argc, argv, i)))
+#endif
+	ret = KdProcessArgument(argc, argv, i);
+    return ret;
 }
Index: xc/programs/Xserver/hw/kdrive/trio/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/trio/Imakefile:1.1 xc/programs/Xserver/hw/kdrive/trio/Imakefile:1.2
--- xc/programs/Xserver/hw/kdrive/trio/Imakefile:1.1	Fri Nov 19 08:54:02 1999
+++ xc/programs/Xserver/hw/kdrive/trio/Imakefile	Sun Sep  3 01:11:20 2000
@@ -1,14 +1,13 @@
 XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/trio/Imakefile,v 1.1 1999/11/19 13:54:02 hohndel Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/trio/Imakefile,v 1.2 2000/09/03 05:11:20 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
 
 SRCS = 	s3.c s3clock.c s3cmap.c s3curs.c s3draw.c s3gc.c s3stub.c
 
 OBJS = 	s3.o s3clock.o s3cmap.o s3curs.o s3draw.o s3gc.o s3stub.o
 
-INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../../fb -I../../../mi -I../../../include -I../../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+INCLUDES = -I. $(KDINCS)
 
 DEFINES = -DS3_TRIO
 
Index: xc/programs/Xserver/hw/kdrive/trio/s3.c
diff -u xc/programs/Xserver/hw/kdrive/trio/s3.c:1.4 xc/programs/Xserver/hw/kdrive/trio/s3.c:1.6
--- xc/programs/Xserver/hw/kdrive/trio/s3.c:1.4	Sat May  6 18:17:52 2000
+++ xc/programs/Xserver/hw/kdrive/trio/s3.c	Sun Sep  3 01:11:20 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.c,v 1.4 2000/05/06 22:17:52 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.c,v 1.6 2000/09/03 05:11:20 keithp Exp $ */
 
 #include "s3.h"
 
@@ -429,11 +429,13 @@
     if (t->horizontal != 1600 &&
 	t->horizontal != 1280 &&
 	t->horizontal != 1152 &&
+	t->horizontal != 1024 &&
 	t->horizontal != 800 &&
 	t->horizontal != 640)
 	return FALSE;
     if (t->clock > S3_MAX_CLOCK * 2)
 	return FALSE;
+    return TRUE;
 }
 
 Bool
@@ -634,7 +636,7 @@
  * Enable the card for rendering.  Manipulate the initial settings
  * of the card here.
  */
-void
+Bool
 s3Enable (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
@@ -902,6 +904,7 @@
     LockS3 (s3c);
     _s3SetDepth (s3c->s3, crtc);
     UnlockS3 (s3c);
+    return TRUE;
 }
 
 void
Index: xc/programs/Xserver/hw/kdrive/trio/s3.h
diff -u xc/programs/Xserver/hw/kdrive/trio/s3.h:1.4 xc/programs/Xserver/hw/kdrive/trio/s3.h:1.5
--- xc/programs/Xserver/hw/kdrive/trio/s3.h:1.4	Sat May  6 18:17:53 2000
+++ xc/programs/Xserver/hw/kdrive/trio/s3.h	Sun Sep  3 01:11:20 2000
@@ -21,7 +21,7 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.h,v 1.4 2000/05/06 22:17:53 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.h,v 1.5 2000/09/03 05:11:20 keithp Exp $ */
 
 #ifndef _S3_H_
 #define _S3_H_
@@ -1126,7 +1126,7 @@
 
 Bool	s3CardInit (KdCardInfo *);
 Bool	s3ScreenInit (KdScreenInfo *);
-void	s3Enable (ScreenPtr pScreen);
+Bool	s3Enable (ScreenPtr pScreen);
 void	s3Disable (ScreenPtr pScreen);
 void	s3Fini (ScreenPtr pScreen);
 
Index: xc/programs/Xserver/hw/kdrive/ts300/Imakefile
diff -u xc/programs/Xserver/hw/kdrive/ts300/Imakefile:1.1 xc/programs/Xserver/hw/kdrive/ts300/Imakefile:1.2
--- xc/programs/Xserver/hw/kdrive/ts300/Imakefile:1.1	Fri Nov 19 08:54:06 1999
+++ xc/programs/Xserver/hw/kdrive/ts300/Imakefile	Sun Sep  3 01:11:21 2000
@@ -1,14 +1,13 @@
 XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
-XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/ts300/Imakefile,v 1.1 1999/11/19 13:54:06 hohndel Exp $
-#include <Server.tmpl>
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/ts300/Imakefile,v 1.2 2000/09/03 05:11:21 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
 
 SRCS = 	ts300.c
 
 OBJS = 	ts300.o
 
-INCLUDES = -I../trio -I../sis530 -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../../fb -I../../../mi -I../../../include -I../../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+INCLUDES = -I. $(KDINCS) -I../trio -I../sis530
 
 NormalLibraryObjectRule()
 NormalLibraryTarget(ts300,$(OBJS))
Index: xc/programs/Xserver/hw/kdrive/vesa/Imakefile
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/Imakefile:1.3
--- /dev/null	Mon Dec 18 14:29:01 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/Imakefile	Thu Oct 19 20:19:50 2000
@@ -0,0 +1,14 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/vesa/Imakefile,v 1.3 2000/10/20 00:19:50 keithp Exp $
+KDRIVE=..
+#include "../Kdrive.tmpl"
+
+SRCS = 	vesa.c vesainit.c vbe.c vga.c vm86.c
+
+OBJS = 	vesa.o vesainit.o vbe.o vga.o vm86.o
+
+INCLUDES = -I. $(KDINCS)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(vesa,$(OBJS))
+InstallManPage(Xvesa,$(MANDIR))
+DependTarget()
Index: xc/programs/Xserver/hw/kdrive/vesa/Xvesa.man
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/Xvesa.man:1.4
--- /dev/null	Mon Dec 18 14:29:02 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/Xvesa.man	Thu Nov 30 19:01:32 2000
@@ -0,0 +1,86 @@
+.\" $XFree86: xc/programs/Xserver/hw/kdrive/vesa/Xvesa.man,v 1.4 2000/12/01 00:01:32 keithp Exp $
+.TH Xvesa 1
+.SH NAME
+Xvesa \- VESA Bios Extensions tiny X server
+.SH SYNOPSIS
+.B Xvesa
+.RI [ :display ] 
+.RI [ option ...]
+.SH DESCRIPTION
+.B Xvesa
+is a generic X server for Linux on the x86 platform.  
+.B Xvesa
+doesn't know about any particular hardware, and sets the video mode by
+running the video BIOS in VM86 mode.
+.B Xvesa
+can use both standard VGA BIOS modes and any modes advertised by a
+VESA BIOS if available.
+.B Xvesa
+runs untrusted code with full privileges, and is therefore a fairly
+insecure X server.
+.B Run at your own risk.
+.SH OPTIONS
+In addition to the normal KDrive server's options (see Xkdrive(1)),
+.B Xvesa
+accepts the following command line switches:
+.TP 8
+.B -mode \fIn\fB
+specifies the VESA video mode to use.  If mode
+.I n
+is not supported by your BIOS and hardware,
+.B Xvesa
+will fail, hang your system, or cause your monitor to explode; you are
+on your own.  This option overrides any
+.B -screen
+options.
+.TP 8
+.B -listmodes
+list all supported video modes.  If
+.B -force
+was specified before
+.BR -listmodes ,
+lists all the modes that your BIOS claims to support, even those that
+the
+.B Xvesa
+server won't be able to use.
+.TP 8
+.B -force
+disable some sanity checks and use the specified mode even if the
+BIOS claims not to support it.
+.TP 8
+.B -shadow
+use a shadow framebuffer even if it is not strictly necessary.  This
+may dramatically improve performance on some hardware.
+.TP 8
+.B -nolinear
+don't use a linear framebuffer even if one is available.  You don't
+want to use this option.
+.TP 8
+.B -swaprgb
+pass RGB values in the order that works on broken BIOSes.  Use this if
+the colours are wrong in PseudoColor and 16 colour modes.
+.TP 8
+.B -verbose
+emit diagnostic messages during BIOS initialization and teardown.
+.SH KEYBOARD
+To be written.
+.SH BUGS
+.B Xvesa
+opens all IO ports and runs your VESA BIOS, which may be assumed to be
+buggy.  Allowing your users to run
+.B Xvesa
+is probably a security hole.
+
+.B Xvesa
+records the current BIOS mode when it starts and restores that mode on
+termination; if the video card has been reprogrammed by another application,
+the display will almost certainly be trashed.  The alternative of saving and
+restoring the complete video card state has proven unreliable on most video
+cards.
+.SH SEE ALSO
+X(1), Xserver(1), Xkdrive(1), xdm(1), xinit(1).
+.SH AUTHORS
+The VESA driver was written by Juliusz Chroboczek who didn't realise
+what he was doing until it was too late.  Keith Packard then added
+support for standard VGA BIOS modes and is especially proud of 320x200
+16 colour mode.
Index: xc/programs/Xserver/hw/kdrive/vesa/vbe.c
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/vbe.c:1.8
--- /dev/null	Mon Dec 18 14:29:02 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/vbe.c	Wed Nov 29 03:42:25 2000
@@ -0,0 +1,628 @@
+/* 
+Copyright (c) 2000 by Juliusz Chroboczek
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions: 
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software. 
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.c,v 1.8 2000/11/29 08:42:25 keithp Exp $ */
+
+#include "vesa.h"
+
+int
+VbeGetVib (Vm86InfoPtr vi, VbeInfoBlock *vib)
+{
+    int		    code;
+    int		    mark;
+    int		    vib_base;
+    VbeInfoBlock    *vib_low;
+    
+    mark = Vm86MarkMemory (vi);
+    vib_base = Vm86AllocateMemory (vi, sizeof (VbeInfoBlock));
+    vib_low = (VbeInfoBlock*)&(LM(vi, vib_base));
+    vi->vms.regs.eax = 0x4F00;
+    vi->vms.regs.es = POINTER_SEGMENT(vib_base);
+    vi->vms.regs.edi = POINTER_OFFSET(vib_base);
+    memcpy(vib_low->VbeSignature, "VBE2", 4);
+    code = VbeDoInterrupt10(vi);
+    if(code >= 0)
+    {
+	if(memcmp(vib_low->VbeSignature, "VESA", 4) == 0) 
+	    *vib = *vib_low;
+	else
+	    code = -1;
+    }
+    Vm86ReleaseMemory (vi, mark);
+    return code;
+}
+
+int
+VbeGetVmib (Vm86InfoPtr vi, int mode, VbeModeInfoBlock *vmib)
+{
+    int			code;
+    int			mark;
+    int			vib_base;
+    int			vmib_base;
+    VbeModeInfoBlock	*vmib_low;
+    
+    mark = Vm86MarkMemory (vi);
+    
+    vmib_base = Vm86AllocateMemory (vi, sizeof (VbeModeInfoBlock));
+    vmib_low = (VbeModeInfoBlock*)&(LM(vi, vmib_base));
+    
+    vi->vms.regs.eax = 0x4F01;
+    vi->vms.regs.ecx = mode&0xFFFF;
+    vi->vms.regs.es = POINTER_SEGMENT(vmib_base);
+    vi->vms.regs.edi = POINTER_OFFSET(vmib_base);
+    code = VbeDoInterrupt10(vi);
+    
+    if(code >= 0)
+	*vmib = *vmib_low;
+    Vm86ReleaseMemory (vi, mark);
+    return code;
+}
+
+void
+VbeReportInfo (Vm86InfoPtr vi)
+{
+    VbeInfoBlock    vib;
+    int		    code;
+
+    code = VbeGetVib (vi, &vib);
+    if (code >= 0)
+	VbeReportVib(vi, &vib);
+}
+
+int
+VbeGetNmode (Vm86InfoPtr vi)
+{
+    VbeInfoBlock    vib;
+    int		    code;
+    int		    ret = 0;
+    unsigned int    p;
+    int		    n;
+    int		    mode;
+
+    code = VbeGetVib (vi, &vib);
+    if (code >= 0)
+    {
+	p = MAKE_POINTER_1(vib.VideoModePtr);
+	for (n = 0; ; n++)
+	{
+	    mode = Vm86MemoryW(vi, p);
+	    if (mode == 0xffff)
+	        break;
+	    p += 2;
+	}
+	code = n;
+    }
+    return code;
+}
+
+int
+VbeGetModes (Vm86InfoPtr vi, VesaModePtr modes, int nmode)
+{
+    VbeInfoBlock	vib;
+    int			code;
+    int			ret = 0;
+    unsigned int	p;
+    int			n;
+    int			mode;
+    VbeModeInfoBlock	vmib;
+
+    code = VbeGetVib (vi, &vib);
+    if (code < 0)
+	return code;
+
+    memset (modes, '\0', nmode * sizeof (VesaModeRec));
+    
+    p = MAKE_POINTER_1(vib.VideoModePtr);
+    for (n = 0; n < nmode; n++)
+    {
+	mode = Vm86MemoryW(vi, p);
+	if (mode == 0xffff)
+	    break;
+	modes[n].mode = mode;
+	modes[n].vbe = 1;
+	p += 2;
+    }
+    
+    nmode = n;
+    
+    for (n = 0; n < nmode; n++)
+    {
+	code = VbeGetVmib (vi, modes[n].mode, &vmib);
+	if (code >= 0)
+	{
+	    modes[n].ModeAttributes = vmib.ModeAttributes;
+	    modes[n].NumberOfPlanes = vmib.NumberOfPlanes;
+	    modes[n].BitsPerPixel = vmib.BitsPerPixel;
+	    modes[n].MemoryModel = vmib.MemoryModel;
+	    modes[n].RedMaskSize = vmib.RedMaskSize;
+	    modes[n].RedFieldPosition = vmib.RedFieldPosition;
+	    modes[n].GreenMaskSize = vmib.GreenMaskSize;
+	    modes[n].GreenFieldPosition = vmib.GreenFieldPosition;
+	    modes[n].BlueMaskSize = vmib.BlueMaskSize;
+	    modes[n].BlueFieldPosition = vmib.BlueFieldPosition;
+	    modes[n].RsvdMaskSize = vmib.RsvdMaskSize;
+	    modes[n].RsvdFieldPosition = vmib.RsvdFieldPosition;
+	    modes[n].DirectColorModeInfo = vmib.DirectColorModeInfo;
+	    modes[n].XResolution = vmib.XResolution;
+	    modes[n].YResolution = vmib.YResolution;
+	    modes[n].BytesPerScanLine = vmib.BytesPerScanLine;
+	}
+    }
+    
+    return nmode;
+}
+
+VbeInfoPtr
+VbeInit (Vm86InfoPtr vi)
+{
+    VbeInfoPtr	    vbe;
+    int		    code;
+    VbeInfoBlock    vib;
+
+    code = VbeGetVib (vi, &vib);
+    if (code < 0)
+	return 0;
+    
+    vbe = xalloc (sizeof (VbeInfoRec));
+    if (!vbe)
+	return 0;
+    vbe->palette_format = 6;
+    vbe->palette_wait = TRUE;
+    return vbe;
+}
+
+void
+VbeCleanup (Vm86InfoPtr vi, VbeInfoPtr vbe)
+{
+    xfree (vbe);
+}
+
+int
+VbeSetMode (Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int linear)
+{
+    int			code;
+    VbeInfoBlock	vib;
+    int			palette_wait = 0, palette_hi = 0;
+
+    code = VbeGetVib (vi, &vib);
+    if (code < 0)
+	return -1;
+    
+    code = VbeGetVmib (vi, mode, &vbe->vmib);
+    if (code < 0)
+	return -1;
+    
+    mode = (mode & 0xffff) | 0x8000;
+    if (linear)
+	mode |= 0x4000;
+    
+    vi->vms.regs.eax = 0x4F02;
+    vi->vms.regs.ebx = mode;
+    code = VbeDoInterrupt10(vi);
+    if(code < 0)
+        return -1;
+    
+    vbe->windowA_offset = vbe->windowB_offset = -1;
+    vbe->last_window = 1;
+    
+    if(vib.Capabilities[0] & 1)
+        palette_hi = 1;
+    if(vib.Capabilities[0] & 4)
+        palette_wait = 1;
+    
+    if(palette_hi || palette_wait)
+        VbeSetPaletteOptions(vi, vbe, palette_hi?8:6, palette_wait);
+
+    return 0;
+}
+
+int 
+VbeGetMode(Vm86InfoPtr vi, int *mode)
+{
+    int code;
+    
+    vi->vms.regs.eax = 0x4F03;
+    code = VbeDoInterrupt10(vi);
+    if(code < 0)
+        return - 1;
+    *mode = vi->vms.regs.ebx & 0xFFFF;
+    return 0;
+}
+
+void *
+VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size)
+{
+    U8			*fb;
+    VbeInfoBlock	vib;
+    VbeModeInfoBlock	vmib;
+    int			size;
+    int			pagesize = getpagesize();
+    int			before, after;
+    int			devmem;
+
+    if (VbeGetVib (vi, &vib) < 0)
+	return 0;
+    
+    if (VbeGetVmib (vi, mode, &vmib) < 0)
+	return 0;
+    
+    size = 1024 * 64L * vib.TotalMemory;
+    
+    *ret_size = size;
+
+    before = vmib.PhysBasePtr % pagesize;
+    after = pagesize - ((vmib.PhysBasePtr + size) % pagesize);
+    if(after == pagesize)
+        after = 0;
+
+    fb = KdMapDevice (vmib.PhysBasePtr - before, before + size + after);
+    
+    if(fb == 0)
+    {
+        ErrorF("Failed to map framebuffer\n");
+        return NULL;
+    }
+
+    KdSetMappedMode (vmib.PhysBasePtr - before, before + size + after,
+		     KD_MAPPED_MODE_FRAMEBUFFER);
+
+    return fb + before;
+}
+
+void
+VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb)
+{
+    VbeInfoBlock	vib;
+    VbeModeInfoBlock	vmib;
+    int			size;
+    int			pagesize = getpagesize();
+    int			before, after;
+
+    if (VbeGetVib (vi, &vib) < 0)
+	return;
+    
+    if (VbeGetVmib (vi, mode, &vmib) < 0)
+	return;
+    
+    size = 1024 * 64L * vib.TotalMemory;
+
+    before = vmib.PhysBasePtr % pagesize;
+    after = pagesize - ((vmib.PhysBasePtr + size) % pagesize);
+    if(after == pagesize)
+        after = 0;
+
+    fb = (void *) ((char *) fb - before);
+    
+    KdUnmapDevice (fb, before + size + after);
+    KdResetMappedMode (vmib.PhysBasePtr - before, before + size + after,
+		     KD_MAPPED_MODE_FRAMEBUFFER);
+}
+
+int 
+VbeSetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries)
+{
+    U8	    *palette_scratch;
+    int	    mark;
+    int	    palette_base;
+    int	    i, j, code;
+
+    if(number == 0)
+        return 0;
+
+    if(first < 0 || number < 0 || first + number > 256) {
+        ErrorF("Cannot set %d, %d palette entries\n", first, number);
+        return -1;
+    }
+    if(vbe->palette_format < 6 || vbe->palette_format > 8) {
+        ErrorF("Impossible palette format %d\n", vbe->palette_format);
+        return -1;
+    }
+
+    mark = Vm86MarkMemory (vi);
+    palette_base = Vm86AllocateMemory (vi, 4 * 256);
+
+    palette_scratch = &LM(vi, palette_base);
+
+    for(i=0; i<number*4; i++)
+	palette_scratch[i] = entries[i] >> (8 - vbe->palette_format);
+
+    vi->vms.regs.eax = 0x4F09;
+    if(vbe->palette_wait)
+	vi->vms.regs.ebx = 0x80;
+    else
+	vi->vms.regs.ebx = 0x00;
+    vi->vms.regs.ecx = number;
+    vi->vms.regs.edx = first;
+    vi->vms.regs.es = POINTER_SEGMENT(palette_base);
+    vi->vms.regs.edi = POINTER_OFFSET(palette_base);
+    code = VbeDoInterrupt10(vi);
+    Vm86ReleaseMemory (vi, mark);
+    
+    if(code < 0)
+	return -1;
+    return 0;
+}
+        
+int 
+VbeGetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries)
+{
+    U8	    *palette_scratch;
+    int	    mark;
+    int	    palette_base;
+    int	    i, j, code;
+
+    if(number == 0)
+        return 0;
+
+    if(first < 0 || number < 0 || first + number > 256) {
+        ErrorF("Cannot get %d, %d palette entries\n", first, number);
+        return -1;
+    }
+    if(vbe->palette_format < 6 || vbe->palette_format > 8) {
+        ErrorF("Impossible palette format %d\n", vbe->palette_format);
+        return -1;
+    }
+
+    mark = Vm86MarkMemory (vi);
+    palette_base = Vm86AllocateMemory (vi, 4 * 256);
+    
+    palette_scratch = &LM(vi, palette_base);
+
+    vi->vms.regs.eax = 0x4F09;
+    vi->vms.regs.ebx = 0x01;
+    vi->vms.regs.ecx = number;
+    vi->vms.regs.edx = first;
+    vi->vms.regs.es = POINTER_SEGMENT(palette_base);
+    vi->vms.regs.edi = POINTER_OFFSET(palette_base);
+    code = VbeDoInterrupt10(vi);
+    if(code >= 0)
+    {
+	for(i=0; i<number*4; i++)
+	    entries[i] = palette_scratch[i] << (8-vbe->palette_format);
+    }
+    Vm86ReleaseMemory (vi, mark);
+
+    return 0;
+}   
+        
+int 
+VbeSetPaletteOptions(Vm86InfoPtr vi, VbeInfoPtr vbe, U8 bits, int wait)
+{
+    int code;
+    
+    if(bits < 6 || bits > 8) {
+        ErrorF("Impossible palette format %d\n", bits);
+        return -1;
+    }
+    if(bits != vbe->palette_format) 
+    {
+        vbe->palette_format = 0;
+        vi->vms.regs.eax = 0x4F08;
+        vi->vms.regs.ebx = bits << 8;
+        code = VbeDoInterrupt10(vi);
+        if(code < 0)
+            return -1;
+        vbe->palette_format = bits;
+    }
+    vbe->palette_wait = wait;
+    return 0;
+}
+
+static int
+VbeReallySetWindow(Vm86InfoPtr vi, U8 window, U16 winnum)
+{
+    int code;
+    vi->vms.regs.eax = 0x4F05;
+    vi->vms.regs.ebx = window;
+    vi->vms.regs.edx = winnum;
+    code = VbeDoInterrupt10(vi);
+    if(code < 0)
+        return -1;
+    return 0;
+}
+
+void *
+VbeSetWindow(Vm86InfoPtr vi, VbeInfoPtr vbe, int offset, int purpose, int *size_return)
+{
+    int window_size = vbe->vmib.WinSize * 1024;
+    int code;
+    int winnum;
+
+    if(vbe->windowA_offset >= 0)
+	if(vbe->windowA_offset <= offset && vbe->windowA_offset + window_size > offset)
+	    if(vbe->vmib.WinAAttributes & purpose)
+		goto windowA;
+
+    if(vbe->windowB_offset >= 0)
+	if(vbe->windowB_offset <= offset && vbe->windowB_offset + window_size > offset)
+	    if(vbe->vmib.WinBAttributes & purpose)
+		goto windowB;
+
+    if(!(vbe->vmib.WinBAttributes & purpose) || 
+       !(vbe->vmib.WinBAttributes & VBE_WINDOW_RELOCATE))
+	goto set_windowA;
+
+    if(!(vbe->vmib.WinAAttributes & purpose) || 
+       !(vbe->vmib.WinAAttributes & VBE_WINDOW_RELOCATE))
+	goto set_windowB;
+
+    if(vbe->last_window)
+	goto set_windowA;
+    else
+	goto set_windowB;
+
+set_windowA:
+    winnum = offset / (vbe->vmib.WinGranularity * 1024);
+    code = VbeReallySetWindow(vi, 0, winnum);
+    if(code < 0) {
+	ErrorF("Couldn't set window A to %d*%d\n", 
+	       (int)winnum, (int)vbe->vmib.WinGranularity);
+	return NULL;
+    }
+    vbe->windowA_offset = winnum * vbe->vmib.WinGranularity * 1024;
+windowA:
+    vbe->last_window = 0;
+    *size_return = vbe->vmib.WinSize * 1024 - (offset - vbe->windowA_offset);
+    return ((U8*)&(LM(vi, MAKE_POINTER(vbe->vmib.WinASegment, 0)))) + offset - vbe->windowA_offset;
+
+set_windowB:
+    winnum = offset / (vbe->vmib.WinGranularity * 1024);
+    code = VbeReallySetWindow(vi, 1, winnum);
+    if(code < 0) {
+	ErrorF("Couldn't set window B to %d*%d\n", 
+	       (int)winnum, (int)vbe->vmib.WinGranularity);
+	return NULL;
+    }
+    vbe->windowB_offset = winnum * vbe->vmib.WinGranularity * 1024;
+windowB:
+    vbe->last_window = 1;
+    *size_return = vbe->vmib.WinSize * 1024 - (offset - vbe->windowB_offset);
+    return ((U8*)&(LM(vi, MAKE_POINTER(vbe->vmib.WinBSegment, 0)))) + offset - vbe->windowB_offset;
+}
+
+int 
+VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib)
+{
+    U32 i, p;
+    unsigned char c;
+    int error;
+    ErrorF("VBE version %c.%c (", 
+           ((vib->VbeVersion >> 8) & 0xFF) + '0',
+           (vib->VbeVersion & 0xFF)+'0');
+    p = vib->OemStringPtr;
+    for(i = 0; 1; i++) {
+        c = Vm86Memory(vi, MAKE_POINTER_1(p+i));
+        if(!c) break;
+	if (c >= ' ')
+	    ErrorF("%c", c);
+        if (i > 32000) {
+            error = 1;
+            break;
+        }
+    }
+    ErrorF(")\n");
+    ErrorF("DAC is %s, controller is %sVGA compatible%s\n",
+           (vib->Capabilities[0]&1)?"fixed":"switchable",
+           (vib->Capabilities[0]&2)?"not ":"",
+           (vib->Capabilities[0]&3)?", RAMDAC causes snow":"");
+    ErrorF("Total memory: %lu kilobytes\n", 64L*vib->TotalMemory);
+    if(error)
+        return -1;
+    return 0;
+}
+
+int 
+VbeReportModeInfo(Vm86InfoPtr vi, U16 mode, VbeModeInfoBlock *vmib)
+{
+    int supported = (vmib->ModeAttributes&0x1)?1:0;
+    int colour = (vmib->ModeAttributes&0x8)?1:0;
+    int graphics = (vmib->ModeAttributes&0x10)?1:0;
+    int vga_compatible = !((vmib->ModeAttributes&0x20)?1:0);
+    int linear_fb = (vmib->ModeAttributes&0x80)?1:0;
+
+    ErrorF("0x%04X: %dx%dx%d%s",
+           (unsigned)mode, 
+           (int)vmib->XResolution, (int)vmib->YResolution,
+           (int)vmib->BitsPerPixel,
+           colour?"":" (monochrome)");
+    switch(vmib->MemoryModel) {
+    case 0:
+        ErrorF(" text mode (%dx%d)",
+               (int)vmib->XCharSize, (int)vmib->YCharSize);
+        break;
+    case 1:
+        ErrorF(" CGA graphics");
+        break;
+    case 2:
+        ErrorF(" Hercules graphics");
+        break;
+    case 3:
+        ErrorF(" Planar (%d planes)", vmib->NumberOfPlanes);
+        break;
+    case 4:
+        ErrorF(" PseudoColor");
+        break;
+    case 5:
+        ErrorF(" Non-chain 4, 256 colour");
+        break;
+    case 6:
+        if(vmib->DirectColorModeInfo & 1)
+            ErrorF(" DirectColor");
+        else
+            ErrorF(" TrueColor");
+        ErrorF(" [%d:%d:%d:%d]",
+               vmib->RedMaskSize, vmib->GreenMaskSize, vmib->BlueMaskSize,
+               vmib->RsvdMaskSize);
+        if(vmib->DirectColorModeInfo & 2)
+            ErrorF(" (reserved bits are reserved)");
+        break;
+    case 7: ErrorF("YUV");
+        break;
+    default:
+        ErrorF("unknown MemoryModel 0x%X ", vmib->MemoryModel);
+    }
+    if(!supported)
+        ErrorF(" (unsupported)");
+    else if(!linear_fb)
+        ErrorF(" (no linear framebuffer)");
+    ErrorF("\n");
+    return 0;
+}       
+
+int
+VbeDoInterrupt10(Vm86InfoPtr vi)
+{
+    int code;
+    int oldax;
+
+    oldax = vi->vms.regs.eax & 0xFFFF;
+
+    code = Vm86DoInterrupt(vi, 0x10);
+    if(code < 0)
+	return -1;
+
+    if((vi->vms.regs.eax & 0xFFFF) != 0x4F && (oldax & 0xFF00) == 0x4F00) {
+	ErrorF("Int 10h (0x%04X) failed: 0x%04X",
+	       oldax, vi->vms.regs.eax & 0xFFFF);
+	if((oldax & 0xFF00) == 0x4F00) {
+	    switch((vi->vms.regs.eax & 0xFF00)>>8) {
+	    case 0: 
+		ErrorF(" (success)\n"); 
+		return 0;
+	    case 1: 
+		ErrorF(" (function call failed)\n"); 
+		break;
+	    case 2: 
+		ErrorF(" (function not supported on this hardware)\n"); 
+		break;
+	    case 3: 
+		ErrorF(" (function call invalid in this video mode)\n"); 
+		break;
+	    default: 
+		ErrorF(" (unknown error)\n"); 
+		break;
+	    }	    return -1;
+	} else {
+	    ErrorF("\n");
+	}
+    }
+    return code;
+}
Index: xc/programs/Xserver/hw/kdrive/vesa/vbe.h
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/vbe.h:1.5
--- /dev/null	Mon Dec 18 14:29:02 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/vbe.h	Thu Oct 19 20:19:50 2000
@@ -0,0 +1,163 @@
+/* 
+Copyright (c) 2000 by Juliusz Chroboczek
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions: 
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software. 
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.h,v 1.5 2000/10/20 00:19:50 keithp Exp $ */
+
+#ifndef _VBE_H
+#define _VBE_H
+
+#define VBE_WINDOW_RELOCATE 1
+#define VBE_WINDOW_READ 2
+#define VBE_WINDOW_WRITE 4
+
+typedef struct _VbeInfoBlock {
+    U8 VbeSignature[4];         /* VBE Signature */
+    U16 VbeVersion;             /* VBE Version */
+    U32 OemStringPtr;           /* Pointer to OEM String */
+    U8 Capabilities[4];         /* Capabilities of graphics controller */
+    U32 VideoModePtr;           /* Pointer to VideoModeList */
+    U16 TotalMemory;            /* Number of 64kb memory blocks */
+/* Added for VBE 2.0 */
+    U16 OemSoftwareRev;         /* VBE implementation Software revision */
+    U32 OemVendorNamePtr;       /* Pointer to Vendor Name String */
+    U32 OemProductNamePtr;	/* Pointer to Product Name String */
+    U32 OemProductRevPtr;       /* Pointer to Product Revision String */
+    U8 Reserved[222];           /* Reserved for VBE implementation */
+    U8 OemData[256];            /* Data Area for OEM Strings*/
+} __attribute__((packed)) VbeInfoBlock;
+
+typedef struct _VbeModeInfoBlock {
+/* Mandatory information for all VBE revisions */
+    U16 ModeAttributes;         /* mode attributes */
+    U8 WinAAttributes;          /* window A attributes */
+    U8 WinBAttributes;          /* window B attributes */
+    U16 WinGranularity;         /* window granularity */
+    U16 WinSize;                /* window size */
+    U16 WinASegment;            /* window A start segment */
+    U16 WinBSegment;            /* window B start segment */
+    U32 WinFuncPtr;             /* pointer to window function */
+    U16 BytesPerScanLine;       /* bytes per scan line */
+/* Mandatory information for VBE 1.2 and above */
+    U16 XResolution;            /* horizontal resolution */
+    U16 YResolution;            /* vertical resolution */
+    U8 XCharSize;               /* character cell width in pixels */
+    U8 YCharSize;               /* character cell height in pixels */
+    U8 NumberOfPlanes;          /* number of memory planes */
+    U8 BitsPerPixel;            /* bits per pixel */
+    U8 NumberOfBanks;           /* number of banks */
+    U8 MemoryModel;             /* memory model type */
+    U8 BankSize;                /* bank size in KB */
+    U8 NumberOfImagePages;      /* number of images */
+    U8 Reserved;                /* reserved for page function */
+/* Direct Color fields (required for direct/6 and YUV/7 memory models) */
+    U8 RedMaskSize;             /* size of direct color red mask in bits */
+    U8 RedFieldPosition;        /* bit position of lsb of red mask */
+    U8 GreenMaskSize;           /* size of direct color green mask in bits */
+    U8 GreenFieldPosition;      /* bit position of lsb of green mask */
+    U8 BlueMaskSize;            /* size of direct color blue mask in bits */
+    U8 BlueFieldPosition;       /* bit position of lsb of blue mask */
+    U8 RsvdMaskSize;            /* size of direct color reserved mask bits*/
+    U8 RsvdFieldPosition;       /* bit position of lsb of reserved mask */
+    U8 DirectColorModeInfo;     /* direct color mode attributes */
+/* Mandatory information for VBE 2.0 and above */
+    U32 PhysBasePtr;            /* physical address for flat memory fb */
+    U32 OffScreenMemOffset;     /* pointer to start of off screen memory */
+    U16 OffScreenMemSize;       /* amount of off screen memory in 1k units */
+    U8 Reserved2[206];          /* remainder of ModeInfoBlock */
+} __attribute__((packed)) VbeModeInfoBlock;
+
+typedef struct _VbeInfoRec {
+    U8			palette_format;
+    int			palette_wait;
+    int			windowA_offset;
+    int			windowB_offset;
+    int			window_size;
+    int			last_window;
+    VbeModeInfoBlock	vmib;
+} VbeInfoRec, *VbeInfoPtr;
+
+typedef struct _SupVbeInfoBlock {
+    U8 SupVbeSignature[7];      /* Supplemental VBE Signature */
+    U16 SupVbeVersion;          /* Supplemental VBE Version*/
+    U8 SupVbeSubFunc[8];	/* Bitfield of supported subfunctions */
+    U16 OemSoftwareRev;         /* OEM Software revision */
+    U32 OemVendorNamePtr;       /* Pointer to Vendor Name String */
+    U32 OemProductNamePtr;	/* Pointer to Product Name String */
+    U32 OemProductRevPtr;       /* Pointer to Product Revision String */
+    U32 OemStringPtr;           /* Pointer to OEM String */
+    U8 Reserved[221];           /* Reserved */
+} __attribute__((packed)) SupVbeInfoBlock;
+
+int
+VbeGetVib (Vm86InfoPtr vi, VbeInfoBlock *vib);
+
+int
+VbeGetVmib (Vm86InfoPtr vi, int mode, VbeModeInfoBlock *vmib);
+
+void
+VbeReportInfo (Vm86InfoPtr vi);
+
+int
+VbeGetNmode (Vm86InfoPtr vi);
+
+int
+VbeGetModes (Vm86InfoPtr vi, VesaModePtr modes, int nmode);
+
+int
+VbeGetModeInfo(Vm86InfoPtr vi, int m, VesaModePtr mode);
+
+VbeInfoPtr
+VbeInit (Vm86InfoPtr vi);
+
+int
+VbeSetMode (Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int linear);
+
+int 
+VbeGetMode(Vm86InfoPtr vi, int *mode);
+
+void *
+VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *size);
+
+void
+VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb);
+
+int 
+VbeSetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries);
+        
+int 
+VbeGetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries);
+        
+int 
+VbeSetPaletteOptions(Vm86InfoPtr vi, VbeInfoPtr vbe, U8 bits, int wait);
+
+void *
+VbeSetWindow(Vm86InfoPtr vi, VbeInfoPtr vbe, int offset, int purpose, int *size_return);
+
+int 
+VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib);
+
+int 
+VbeReportModeInfo(Vm86InfoPtr vi, U16 mode, VbeModeInfoBlock *vmib);
+
+int
+VbeDoInterrupt10(Vm86InfoPtr vi);
+    
+#endif
Index: xc/programs/Xserver/hw/kdrive/vesa/vesa.c
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/vesa.c:1.9
--- /dev/null	Mon Dec 18 14:29:03 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/vesa.c	Wed Nov 29 03:42:25 2000
@@ -0,0 +1,1218 @@
+/* 
+Copyright (c) 2000 by Juliusz Chroboczek
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions: 
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software. 
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.9 2000/11/29 08:42:25 keithp Exp $ */
+
+#include "vesa.h"
+
+int vesa_video_mode = 0;
+Bool vesa_force_mode = FALSE;
+Bool vesa_swap_rgb = FALSE;
+Bool vesa_shadow = FALSE;
+Bool vesa_linear_fb = TRUE;
+Bool vesa_restore = FALSE;
+Bool vesa_rotate = FALSE;
+Bool vesa_verbose = FALSE;
+
+#define VesaPriv(scr)	((VesaScreenPrivPtr) (scr)->driver)
+
+#define ScreenRotated(scr)  (VesaPriv(scr)->rotate)
+#define vesaWidth(scr,vmib) (ScreenRotated(scr) ? vmib->YResolution : vmib->XResolution)
+#define vesaHeight(scr,vmib) (ScreenRotated(scr) ? vmib->XResolution : vmib->YResolution)
+
+static Bool
+vesaModeSupportable (VesaModePtr mode, Bool complain)
+{
+    if((mode->ModeAttributes & 0x10) == 0) {
+	if(complain)
+	    ErrorF("Text mode specified.\n");
+	return FALSE;
+    }
+    if(mode->MemoryModel != 0x06 && mode->MemoryModel != 0x04 && mode->MemoryModel != 0x03) {
+	if(complain)
+	    ErrorF("Unsupported memory model 0x%X\n", mode->MemoryModel);
+	return FALSE;
+    }
+    if((mode->ModeAttributes & 0x80) == 0) {
+	if ((mode->ModeAttributes & 0x40) != 0) {
+	    if(complain)
+		ErrorF("Neither linear nor windowed framebuffer available in this mode\n");
+	    return FALSE;
+	}
+    }
+    if(!(mode->ModeAttributes & 1)) {
+	if(complain)
+	    ErrorF("Mode not supported on this hardware\n");
+	return FALSE;
+    }
+    return TRUE;
+}
+
+static Bool
+vesaModeSupported (VesaCardPrivPtr priv, VesaModePtr mode, Bool complain)
+{
+    if (!priv->vbeInfo && mode->vbe) {
+	if (complain)
+	    ErrorF("VBE bios mode not usable.\n");
+	return FALSE;
+    }
+    return vesaModeSupportable (mode, complain);
+}
+
+void
+vesaReportMode (VesaModePtr mode)
+{
+    int supported = (mode->ModeAttributes&MODE_SUPPORTED)?1:0;
+    int colour = (mode->ModeAttributes&MODE_COLOUR)?1:0;
+    int graphics = (mode->ModeAttributes&MODE_GRAPHICS)?1:0;
+    int vga_compatible = !((mode->ModeAttributes&MODE_VGA)?1:0);
+    int linear_fb = (mode->ModeAttributes&MODE_LINEAR)?1:0;
+
+    ErrorF("0x%04X: %dx%dx%d%s",
+           (unsigned)mode->mode, 
+           (int)mode->XResolution, (int)mode->YResolution,
+	   vesaDepth (mode),
+           colour?"":" (monochrome)");
+    switch(mode->MemoryModel) {
+    case MEMORY_TEXT:
+        ErrorF(" text mode");
+        break;
+    case MEMORY_CGA:
+        ErrorF(" CGA graphics");
+        break;
+    case MEMORY_HERCULES:
+        ErrorF(" Hercules graphics");
+        break;
+    case MEMORY_PLANAR:
+        ErrorF(" Planar (%d planes)", mode->NumberOfPlanes);
+        break;
+    case MEMORY_PSEUDO:
+        ErrorF(" PseudoColor");
+        break;
+    case MEMORY_NONCHAIN:
+        ErrorF(" Non-chain 4, 256 colour");
+        break;
+    case MEMORY_DIRECT:
+        if(mode->DirectColorModeInfo & MODE_DIRECT)
+            ErrorF(" DirectColor");
+        else
+            ErrorF(" TrueColor");
+        ErrorF(" [%d:%d:%d:%d]",
+               mode->RedMaskSize, mode->GreenMaskSize, mode->BlueMaskSize,
+               mode->RsvdMaskSize);
+        if(mode->DirectColorModeInfo & 2)
+            ErrorF(" (reserved bits are reserved)");
+        break;
+    case MEMORY_YUV:
+	ErrorF("YUV");
+        break;
+    default:
+        ErrorF("unknown MemoryModel 0x%X ", mode->MemoryModel);
+    }
+    if(!supported)
+        ErrorF(" (unsupported)");
+    else if(!linear_fb)
+        ErrorF(" (no linear framebuffer)");
+    ErrorF("\n");
+}
+
+VesaModePtr
+vesaGetModes (Vm86InfoPtr vi, int *ret_nmode)
+{
+    VesaModePtr		modes;
+    int			nmode, nmodeVbe, nmodeVga;
+    int			code;
+    
+    code = VgaGetNmode (vi);
+    if (code <= 0)
+	nmodeVga = 0;
+    else
+	nmodeVga = code;
+    
+    code = VbeGetNmode (vi);
+    if (code <= 0)
+	nmodeVbe = 0;
+    else
+	nmodeVbe = code;
+
+    nmode = nmodeVga + nmodeVbe;
+    if (nmode <= 0)
+	return 0;
+    
+    modes = xalloc (nmode * sizeof (VesaModeRec));
+    
+    memset (modes, '\0', nmode * sizeof (VesaModeRec));
+    
+    if (nmodeVga)
+    {
+	code = VgaGetModes (vi, modes, nmodeVga);
+	if (code <= 0)
+	    nmodeVga = 0;
+	else
+	    nmodeVga = code;
+    }
+
+    if (nmodeVbe)
+    {
+	code = VbeGetModes (vi, modes + nmodeVga, nmodeVbe);
+	if (code <= 0)
+	    nmodeVbe = 0;
+	else
+	    nmodeVbe = code;
+    }
+    
+    nmode = nmodeVga + nmodeVbe;
+
+    if (nmode == 0)
+    {
+	xfree (modes);
+	modes = 0;
+	return 0;
+    }
+    *ret_nmode = nmode;
+    return modes;
+}
+
+Bool
+vesaInitialize (KdCardInfo *card, VesaCardPrivPtr priv)
+{
+    int code;
+
+    priv->vi = Vm86Setup();
+    if(!priv->vi)
+	goto fail;
+
+    priv->modes = vesaGetModes (priv->vi, &priv->nmode);
+	
+    if (!priv->modes)
+	goto fail;
+
+    priv->vbeInfo = VbeInit (priv->vi);
+    
+    card->driver = priv;
+
+    return TRUE;
+
+fail:
+    if(priv->vi)
+	Vm86Cleanup(priv->vi);
+    return FALSE;
+}
+
+void
+vesaListModes (void)
+{
+    Vm86InfoPtr	vi;
+    VesaModePtr	modes;
+    int		nmode;
+    int		n;
+
+    vi = Vm86Setup ();
+    if (!vi)
+    {
+	ErrorF ("Can't setup vm86\n");
+    }
+    else
+    {
+	modes = vesaGetModes (vi, &nmode);
+	if (!modes)
+	{
+	    ErrorF ("No modes available\n");
+	}
+	else
+	{
+	    VbeReportInfo (vi);
+	    for (n = 0; n < nmode; n++)
+	    {
+		if (vesa_force_mode || vesaModeSupportable (modes+n, 0))
+		    vesaReportMode (modes+n);
+	    }
+	    xfree (modes);
+	}
+	Vm86Cleanup (vi);
+    }
+}
+
+Bool
+vesaCardInit(KdCardInfo *card)
+{
+    VesaCardPrivPtr priv;
+
+    priv = xalloc(sizeof(VesaCardPrivRec));
+    if(!priv)
+        return FALSE;
+
+    if (!vesaInitialize (card, priv))
+    {
+        xfree(priv);
+	return FALSE;
+    }
+    
+    return TRUE;
+}
+
+int
+vesaDepth (VesaModePtr mode)
+{
+    if (mode->MemoryModel == MEMORY_DIRECT)
+	return (mode->RedMaskSize +
+		mode->GreenMaskSize +
+		mode->BlueMaskSize);
+    else
+	return mode->BitsPerPixel;
+}
+
+Bool
+vesaModeGood (KdScreenInfo  *screen,
+	      VesaModePtr   a)
+{
+    if (vesaWidth(screen,a) <= screen->width &&
+	vesaHeight(screen,a) <= screen->height &&
+	vesaDepth (a) >= screen->fb[0].depth)
+    {
+	return TRUE;
+    }
+}
+
+#define vabs(a)	((a) >= 0 ? (a) : -(a))
+
+int
+vesaSizeError (KdScreenInfo *screen,
+	       VesaModePtr  a)
+{
+    int     xdist, ydist;
+    xdist = vabs (screen->width - vesaWidth(screen,a));
+    ydist = vabs (screen->height - vesaHeight(screen,a));
+    return xdist * xdist + ydist * ydist;
+}
+
+Bool
+vesaModeBetter (KdScreenInfo	*screen,
+		VesaModePtr	a,
+		VesaModePtr	b)
+{
+    int	    aerr, berr;
+
+    if (vesaModeGood (screen, a))
+    {
+	if (!vesaModeGood (screen, b))
+	    return TRUE;
+    }
+    else
+    {
+	if (vesaModeGood (screen, b))
+	    return FALSE;
+    }
+    aerr = vesaSizeError (screen, a);
+    berr = vesaSizeError (screen, b);
+    if (aerr < berr)
+	return TRUE;
+    if (berr < aerr)
+	return FALSE;
+    if (vabs (screen->fb[0].depth - vesaDepth (a)) < 
+	vabs (screen->fb[0].depth - vesaDepth (b)))
+	return TRUE;
+    return FALSE;
+}
+
+VesaModePtr
+vesaSelectMode (KdScreenInfo *screen)
+{
+    VesaCardPrivPtr priv = screen->card->driver;
+    int		    i, best;
+    
+    if (vesa_video_mode)
+    {
+	for (best = 0; best < priv->nmode; best++)
+	    if (priv->modes[best].mode == vesa_video_mode &&
+		(vesaModeSupported (priv, &priv->modes[best], FALSE) ||
+		 vesa_force_mode))
+		return &priv->modes[best];
+    }
+    for (best = 0; best < priv->nmode; best++)
+    {
+	if (vesaModeSupported (priv, &priv->modes[best], FALSE))
+	    break;
+    }
+    if (best == priv->nmode)
+	return 0;
+    for (i = best + 1; i < priv->nmode; i++)
+	if (vesaModeSupported (priv, &priv->modes[i], FALSE) &&
+	    vesaModeBetter (screen, &priv->modes[i], 
+			    &priv->modes[best]))
+	    best = i;
+    return &priv->modes[best];
+}   
+    
+Bool
+vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr)
+{
+    VesaCardPrivPtr	priv = screen->card->driver;
+    VesaModePtr		mode;
+    Pixel		allbits;
+    int			depth;
+    int			bpp, fbbpp;
+
+    screen->driver = pscr;
+    pscr->rotate = FALSE;
+    if (screen->width < screen->height)
+	pscr->rotate = TRUE;
+    
+    if (!screen->width || !screen->height)
+    {
+	screen->width = 640;
+	screen->height = 480;
+    }
+    if (!screen->fb[0].depth)
+	screen->fb[0].depth = 4;
+    
+    if (vesa_verbose)
+	ErrorF ("Mode requested %dx%dx%d\n",
+		screen->width, screen->height, screen->fb[0].depth);
+    
+    pscr->mode = vesaSelectMode (screen);
+    
+    if (!pscr->mode)
+    {
+	if (vesa_verbose)
+	    ErrorF ("No selectable mode\n");
+	return FALSE;
+    }
+
+    if (vesa_verbose)
+    {
+	ErrorF ("\t");
+	vesaReportMode (pscr->mode);
+    }
+    
+    pscr->shadow = vesa_shadow;
+    pscr->origDepth = screen->fb[0].depth;
+    if (vesa_linear_fb)
+	pscr->mapping = VESA_LINEAR;
+    else
+	pscr->mapping = VESA_WINDOWED;
+    
+    mode = pscr->mode;
+
+    depth = vesaDepth (mode);
+    bpp = mode->BitsPerPixel;
+    
+    if (bpp > 24)
+	bpp = 32;
+    else if (bpp > 16)
+	bpp = 24;
+    else if (bpp > 8)
+	bpp = 16;
+    else if (bpp > 4)
+	bpp = 8;
+    else if (bpp > 1)
+	bpp = 4;
+    else
+	bpp = 1;
+    fbbpp = bpp;
+    
+    switch (mode->MemoryModel) {
+    case MEMORY_DIRECT:
+        /* TrueColor or DirectColor */
+        screen->fb[0].visuals = (1 << TrueColor);
+        screen->fb[0].redMask = 
+            FbStipMask(mode->RedFieldPosition, mode->RedMaskSize);
+        screen->fb[0].greenMask = 
+            FbStipMask(mode->GreenFieldPosition, mode->GreenMaskSize);
+        screen->fb[0].blueMask = 
+            FbStipMask(mode->BlueFieldPosition, mode->BlueMaskSize);
+        allbits = 
+            screen->fb[0].redMask | 
+            screen->fb[0].greenMask | 
+            screen->fb[0].blueMask;
+        depth = 32;
+        while (depth && !(allbits & (1 << (depth - 1))))
+            depth--;
+	if (vesa_verbose)
+	    ErrorF ("\tTrue Color bpp %d depth %d red 0x%x green 0x%x blue 0x%x\n",
+		    bpp, depth, 
+		    screen->fb[0].redMask,
+		    screen->fb[0].greenMask,
+		    screen->fb[0].blueMask);
+	break;
+    case MEMORY_PSEUDO:
+        /* PseudoColor */
+	screen->fb[0].visuals = ((1 << StaticGray) |
+                                 (1 << GrayScale) |
+                                 (1 << StaticColor) |
+                                 (1 << PseudoColor) |
+                                 (1 << TrueColor) |
+                                 (1 << DirectColor));
+	screen->fb[0].blueMask  = 0x00;
+	screen->fb[0].greenMask = 0x00;
+	screen->fb[0].redMask   = 0x00;
+	if (vesa_verbose)
+	    ErrorF ("\tPseudo Color bpp %d depth %d\n",
+		    bpp, depth);
+	break;
+    case MEMORY_PLANAR:
+	/* 4 plane planar */
+	if (mode->ModeAttributes & MODE_COLOUR)
+	    screen->fb[0].visuals = (1 << StaticColor);
+	else
+	    screen->fb[0].visuals = (1 << StaticGray);
+	screen->fb[0].blueMask  = 0x00;
+	screen->fb[0].greenMask = 0x00;
+	screen->fb[0].redMask   = 0x00;
+	if (bpp == 4)
+	{
+	    bpp = screen->fb[0].bitsPerPixel;
+	    if (bpp != 8)
+		bpp = 4;
+	    depth = bpp;
+	}
+	if (bpp == 1)
+	{
+	    pscr->mapping = VESA_MONO;
+	    if (vesa_verbose)
+		ErrorF ("\tMonochrome\n");
+	}
+	else
+	{
+	    pscr->mapping = VESA_PLANAR;
+	    if (vesa_verbose)
+		ErrorF ("\tStatic color bpp %d depth %d\n",
+			bpp, depth);
+	}
+	pscr->rotate = FALSE;
+	break;
+    default:
+        ErrorF("Unsupported VESA MemoryModel 0x%02X\n",
+               mode->MemoryModel);
+        return FALSE;
+    }
+
+    screen->width = vesaWidth(screen, mode);
+    screen->height = vesaHeight(screen, mode);
+    screen->fb[0].depth = depth;
+    screen->fb[0].bitsPerPixel = bpp;
+    screen->fb[0].byteStride = mode->BytesPerScanLine;
+    screen->fb[0].pixelStride = ((mode->BytesPerScanLine * 8) / fbbpp);
+
+    if (pscr->mapping == VESA_LINEAR && !(mode->ModeAttributes & MODE_LINEAR))
+	pscr->mapping = VESA_WINDOWED;
+    
+    if (pscr->rotate)
+	pscr->shadow = TRUE;
+    
+    switch (pscr->mapping) {
+    case VESA_MONO:
+	pscr->shadow = TRUE;
+	/* fall through */
+    case VESA_LINEAR:
+	if (mode->vbe)
+	    pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo, 
+					 pscr->mode->mode,
+					 &pscr->fb_size);
+	else
+	    pscr->fb = VgaMapFramebuffer (priv->vi, 
+					  pscr->mode->mode,
+					  &pscr->fb_size);
+	break;
+    case VESA_WINDOWED:
+	pscr->fb = NULL;
+	pscr->shadow = TRUE;
+	break;
+    case VESA_PLANAR:
+	pscr->fb = NULL;
+	pscr->shadow = TRUE;
+	break;
+    }
+
+    screen->rate = 72;
+    screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb);
+
+    if (pscr->rotate)
+	screen->softCursor = TRUE;
+    
+    if (pscr->shadow)
+	return KdShadowScreenInit (screen);
+    
+    if (vesa_verbose)
+	ErrorF ("Mode selected %dx%dx%d\n",
+		screen->width, screen->height, screen->fb[0].depth);
+    
+    return TRUE;
+}
+
+Bool
+vesaScreenInit(KdScreenInfo *screen)
+{
+    VesaScreenPrivPtr	pscr;
+    
+    pscr = xcalloc (1, sizeof (VesaScreenPrivRec));
+    if (!pscr)
+	return FALSE;
+    if (!vesaScreenInitialize (screen, pscr))
+	return FALSE;
+    return TRUE;
+}
+
+void *
+vesaSetWindowPlanar(ScreenPtr pScreen,
+		  CARD32    row,
+		  CARD32    offset,
+		  int	    mode,
+		  CARD32    *size)
+{
+    KdScreenPriv(pScreen);
+    VesaCardPrivPtr	priv = pScreenPriv->card->driver;
+    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
+    static int		plane;
+    int			winSize;
+    void		*base;
+
+    plane = offset & 3;
+    VgaSetWritePlaneMask (priv->vi, (1 << plane));
+    offset = offset >> 2;
+    if (pscr->mode->vbe)
+    {
+	base = VbeSetWindow (priv->vi,
+			     priv->vbeInfo,
+			     pscr->mode->BytesPerScanLine * row + offset,
+			     mode,
+			     &winSize);
+    }
+    else
+    {
+	base = VgaSetWindow (priv->vi,
+			     pscr->mode->mode,
+			     pscr->mode->BytesPerScanLine * row + offset,
+			     mode,
+			     &winSize);
+    }
+    *size = (CARD32) winSize;
+    return base;
+}
+
+void *
+vesaSetWindowLinear (ScreenPtr	pScreen,
+		     CARD32	row,
+		     CARD32	offset,
+		     int	mode,
+		     CARD32	*size)
+{
+    KdScreenPriv(pScreen);
+    VesaCardPrivPtr	priv = pScreenPriv->card->driver;
+    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
+
+    *size = pscr->mode->BytesPerScanLine;
+    return (CARD8 *) pscr->fb + row * pscr->mode->BytesPerScanLine + offset;
+}
+
+void *
+vesaSetWindowWindowed (ScreenPtr    pScreen,
+		       CARD32	    row,
+		       CARD32	    offset,
+		       int	    mode,
+		       CARD32	    *size)
+{
+    KdScreenPriv(pScreen);
+    VesaCardPrivPtr	priv = pScreenPriv->card->driver;
+    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
+    int			winSize;
+    void		*base;
+
+    if (pscr->mode->vbe)
+    {
+	base = VbeSetWindow (priv->vi,
+			     priv->vbeInfo,
+			     pscr->mode->BytesPerScanLine * row + offset,
+			     mode,
+			     &winSize);
+    }
+    else
+    {
+	base = VgaSetWindow (priv->vi,
+			     pscr->mode->mode,
+			     pscr->mode->BytesPerScanLine * row + offset,
+			     mode,
+			     &winSize);
+    }
+    *size = (CARD32) winSize;
+    return base;
+}
+
+void *
+vesaWindowPlanar (ScreenPtr pScreen,
+		  CARD32    row,
+		  CARD32    offset,
+		  int	    mode,
+		  CARD32    *size)
+{
+    KdScreenPriv(pScreen);
+
+    if (!pScreenPriv->enabled)
+	return 0;
+    return vesaSetWindowPlanar (pScreen, row, offset, mode, size);
+}
+
+void *
+vesaWindowLinear (ScreenPtr pScreen,
+		  CARD32    row,
+		  CARD32    offset,
+		  int	    mode,
+		  CARD32    *size)
+{
+    KdScreenPriv(pScreen);
+
+    if (!pScreenPriv->enabled)
+	return 0;
+    return vesaSetWindowLinear (pScreen, row, offset, mode, size);
+}
+
+void *
+vesaWindowWindowed (ScreenPtr	pScreen,
+		    CARD32	row,
+		    CARD32	offset,
+		    int		mode,
+		    CARD32	*size)
+{
+    KdScreenPriv(pScreen);
+
+    if (!pScreenPriv->enabled)
+	return 0;
+    return vesaSetWindowWindowed (pScreen, row, offset, mode, size);
+}
+
+#define vesaInvertBits32(v) { \
+    v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
+    v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
+    v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
+}
+
+void *
+vesaWindowCga (ScreenPtr    pScreen,
+	       CARD32	    row,
+	       CARD32	    offset,
+	       int	    mode,
+	       CARD32	    *size)
+{
+    KdScreenPriv(pScreen);
+    VesaCardPrivPtr	priv = pScreenPriv->card->driver;
+    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
+    int			line;
+    
+    if (!pScreenPriv->enabled)
+	return 0;
+    *size = pscr->mode->BytesPerScanLine;
+    line = ((row & 1) << 13) + (row >> 1) * pscr->mode->BytesPerScanLine;
+    return (CARD8 *) pscr->fb + line + offset;
+}
+
+void
+vesaUpdateMono (ScreenPtr pScreen,
+		PixmapPtr pShadow,
+		RegionPtr damage)
+{
+    shadowScrPriv(pScreen);
+    int		nbox = REGION_NUM_RECTS (damage);
+    BoxPtr	pbox = REGION_RECTS (damage);
+    FbBits	*shaBase, *shaLine, *sha;
+    FbBits	s;
+    FbStride	shaStride;
+    int		scrBase, scrLine, scr;
+    int		shaBpp;
+    int		x, y, w, h, width;
+    int         i;
+    FbBits	*winBase, *winLine, *win;
+    CARD32      winSize;
+    FbBits	bits;
+    int		plane;
+
+    fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp);
+    while (nbox--)
+    {
+	x = pbox->x1 * shaBpp;
+	y = pbox->y1;
+	w = (pbox->x2 - pbox->x1) * shaBpp;
+	h = pbox->y2 - pbox->y1;
+
+	scrLine = (x >> FB_SHIFT);
+	shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+				   
+	x &= FB_MASK;
+	w = (w + x + FB_MASK) >> FB_SHIFT;
+	
+	while (h--)
+	{
+	    winSize = 0;
+	    scrBase = 0;
+	    width = w;
+	    scr = scrLine;
+	    sha = shaLine;
+	    while (width) {
+		/* how much remains in this window */
+		i = scrBase + winSize - scr;
+		if (i <= 0 || scr < scrBase)
+		{
+		    winBase = (FbBits *) (*pScrPriv->window) (pScreen,
+							      y,
+							      scr * sizeof (FbBits),
+							      SHADOW_WINDOW_WRITE,
+							      &winSize);
+		    if(!winBase)
+			return;
+		    scrBase = scr;
+		    winSize /= sizeof (FbBits);
+		    i = winSize;
+		}
+		win = winBase + (scr - scrBase);
+		if (i > width)
+		    i = width;
+		width -= i;
+		scr += i;
+		while (i--)
+		{
+		    bits = *sha++;
+		    vesaInvertBits32(bits);
+		    *win++ = bits;
+		}
+	    }
+	    shaLine += shaStride;
+	    y++;
+	}
+	pbox++;
+    }
+}
+
+static const CARD16	vga16Colors[16][3] = {
+    { 0,   0,   0,   },       /*  0 */
+    { 0,   0,   0xAA,},       /*  1 */
+    { 0,   0xAA,0,   },       /*  2 */
+    { 0,   0xAA,0xAA,},       /*  3 */
+    { 0xAA,0,   0,   },       /*  4 */
+    { 0xAA,0,   0xAA,},       /*  5 */
+    { 0xAA,0x55,0,   },       /*  6 */
+    { 0xAA,0xAA,0xAA,},       /*  7 */
+    { 0x55,0x55,0x55,},       /*  8 */
+    { 0x55,0x55,0xFF,},       /*  9 */
+    { 0x55,0xFF,0x55,},       /* 10 */
+    { 0x55,0xFF,0xFF,},       /* 11 */
+    { 0xFF,0x55,0x55,},       /* 12 */
+    { 0xFF,0x55,0xFF,},       /* 13 */
+    { 0xFF,0xFF,0x55,},       /* 14 */
+    { 0xFF,0xFF,0xFF,},       /* 15 */
+};
+
+Bool
+vesaCreateColormap16 (ColormapPtr pmap)
+{
+    int	    i, j;
+
+    for (i = 0; i < pmap->pVisual->ColormapEntries; i++)
+    {
+	j = i & 0xf;
+	pmap->red[i].co.local.red = (vga16Colors[j][0]<<8)|vga16Colors[j][0];
+	pmap->red[i].co.local.green = (vga16Colors[j][1]<<8)|vga16Colors[j][1];
+	pmap->red[i].co.local.blue = (vga16Colors[j][2]<<8)|vga16Colors[j][2];
+    }
+    return TRUE;
+}
+
+
+Bool
+vesaInitScreen(ScreenPtr pScreen)
+{
+    KdScreenPriv(pScreen);
+    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
+    ShadowUpdateProc	update;
+    ShadowWindowProc	window;
+    
+    if (pscr->shadow)
+    {
+	switch (pscr->mapping) {
+	case VESA_LINEAR:
+	    update = shadowUpdatePacked;
+	    window = vesaWindowLinear;
+	    break;
+	case VESA_WINDOWED:
+	    update = shadowUpdatePacked;
+	    window = vesaWindowWindowed;
+	    break;
+	case VESA_PLANAR:
+	    pScreen->CreateColormap = vesaCreateColormap16;
+	    if (pScreenPriv->screen->fb[0].bitsPerPixel == 8)
+		update = shadowUpdatePlanar4x8;
+	    else
+		update = shadowUpdatePlanar4;
+	    window = vesaWindowPlanar;
+	    pscr->rotate = FALSE;
+	    break;
+	case VESA_MONO:
+	    update = vesaUpdateMono;
+	    if (pscr->mode->mode < 8)
+		window = vesaWindowCga;
+	    else
+		window = vesaWindowLinear;
+	    pscr->rotate = FALSE;
+	    break;
+	}
+	if (pscr->rotate)
+	{
+	    switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+	    case 8:
+		update = shadowUpdateRotate8; break;
+	    case 16:
+		update = shadowUpdateRotate16; break;
+	    case 32:
+		update = shadowUpdateRotate32; break;
+	    }
+	}
+	
+        return KdShadowInitScreen (pScreen, update, window);
+    }
+    
+    return TRUE;
+}
+
+Bool
+vesaEnable(ScreenPtr pScreen)
+{
+    KdScreenPriv(pScreen);
+    VesaCardPrivPtr	priv = pScreenPriv->card->driver;
+    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
+    int			code;
+    int			i;
+    CARD32		size;
+    char		*p;
+    KdMouseMatrix	m;
+
+    if (pscr->mode->vbe)
+    {
+	if (vesa_verbose)
+	    ErrorF ("Enable VBE mode 0x%x\n", pscr->mode->mode);
+	code = VbeSetMode(priv->vi, priv->vbeInfo, pscr->mode->mode,
+			  pscr->mapping == VESA_LINEAR);
+    }
+    else
+    {
+	if (vesa_verbose)
+	    ErrorF ("Enable BIOS mode 0x%x\n", pscr->mode->mode);
+	code = VgaSetMode (priv->vi, pscr->mode->mode);
+    }
+    
+    if(code < 0)
+	return FALSE;
+    
+    switch (pscr->mapping) {
+    case VESA_MONO:
+	VgaSetWritePlaneMask (priv->vi, 0x1);
+    case VESA_LINEAR:
+	memcpy (priv->text, pscr->fb, VESA_TEXT_SAVE);
+	break;
+    case VESA_WINDOWED:
+	for (i = 0; i < VESA_TEXT_SAVE;) 
+	{
+	    p = vesaSetWindowWindowed (pScreen, 0, i, VBE_WINDOW_READ, &size);
+            if(!p) {
+                ErrorF("Couldn't set window for saving VGA font\n");
+                break;
+            }
+            if(i + size > VESA_TEXT_SAVE)
+                size = VESA_TEXT_SAVE - i;
+            memcpy(((char*)priv->text) + i, p, size);
+            i += size;
+        }
+	break;
+    case VESA_PLANAR:
+	for (i = 0; i < 4; i++)
+	{
+	    p = vesaSetWindowPlanar (pScreen, 0, i, VBE_WINDOW_READ, &size);
+	    memcpy (((char *)priv->text) + i * (VESA_TEXT_SAVE/4), p,
+		    (VESA_TEXT_SAVE/4));
+	}
+	break;
+    }
+    if (pscr->rotate)
+    {
+	m.matrix[0][0] = 0; m.matrix[0][1] = 1; m.matrix[0][2] = 0;
+	m.matrix[1][0] = -1; m.matrix[1][1] = 0; m.matrix[1][2] = pScreen->height - 1;
+    }
+    else
+    {
+	m.matrix[0][0] = 1; m.matrix[0][1] = 0; m.matrix[0][2] = 0;
+	m.matrix[1][0] = 0; m.matrix[1][1] = 1; m.matrix[1][2] = 0;
+    }
+    KdSetMouseMatrix (&m);
+    return TRUE;
+}
+
+void
+vesaDisable(ScreenPtr pScreen)
+{
+    KdScreenPriv(pScreen);
+    VesaCardPrivPtr	priv = pScreenPriv->card->driver;
+    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
+    int			i=0;
+    CARD32		size;
+    char		*p;
+
+    switch (pscr->mapping) {
+    case VESA_LINEAR:
+    case VESA_MONO:
+        memcpy(pscr->fb, priv->text, VESA_TEXT_SAVE);
+	break;
+    case VESA_WINDOWED:
+        while(i < VESA_TEXT_SAVE) {
+	    p = vesaSetWindowWindowed (pScreen, 0, i, VBE_WINDOW_WRITE, &size);
+            if(!p) {
+                ErrorF("Couldn't set window for restoring VGA font\n");
+                break;
+            }
+            if(i + size > VESA_TEXT_SAVE)
+                size = VESA_TEXT_SAVE - i;
+            memcpy(p, ((char*)priv->text) + i, size);
+            i += size;
+        }
+	break;
+    case VESA_PLANAR:
+	for (i = 0; i < 4; i++)
+	{
+	    p = vesaSetWindowPlanar (pScreen, 0, i, VBE_WINDOW_WRITE, &size);
+	    memcpy (p,
+		    ((char *)priv->text) + i * (VESA_TEXT_SAVE/4),
+		    (VESA_TEXT_SAVE/4));
+	}
+	break;
+    }
+}
+
+void
+vesaPreserve(KdCardInfo *card)
+{
+    VesaCardPrivPtr priv = card->driver;
+    int code;
+
+    /* The framebuffer might not be valid at this point, so we cannot
+       save the VGA fonts now; we do it in vesaEnable. */
+
+    if (VbeGetMode (priv->vi, &priv->old_vbe_mode) < 0)
+	priv->old_vbe_mode = -1;
+
+    if (VgaGetMode (priv->vi, &priv->old_vga_mode) < 0)
+	priv->old_vga_mode = -1;
+    
+    if (vesa_verbose)
+	ErrorF ("Previous modes: VBE 0x%x BIOS 0x%x\n",
+		priv->old_vbe_mode, priv->old_vga_mode);
+}
+
+void
+vesaRestore(KdCardInfo *card)
+{
+    VesaCardPrivPtr priv = card->driver;
+    int		    n;
+
+    for (n = 0; n < priv->nmode; n++)
+	if (priv->modes[n].vbe && priv->modes[n].mode == (priv->old_vbe_mode&0x3fff))
+	    break;
+
+    if (n < priv->nmode)
+    {
+	if (vesa_verbose)
+	    ErrorF ("Restore VBE mode 0x%x\n", priv->old_vbe_mode);
+	VbeSetMode (priv->vi, priv->vbeInfo, priv->old_vbe_mode, 0);
+    }
+    else
+    {
+	if (vesa_verbose)
+	    ErrorF ("Restore BIOS mode 0x%x\n", priv->old_vga_mode);
+	VgaSetMode (priv->vi, priv->old_vga_mode);
+    }
+}
+
+void
+vesaCardFini(KdCardInfo *card)
+{
+    VesaCardPrivPtr priv = card->driver;
+    
+    if (priv->vbeInfo)
+	VbeCleanup (priv->vi, priv->vbeInfo);
+    Vm86Cleanup(priv->vi);
+}
+
+void 
+vesaScreenFini(KdScreenInfo *screen)
+{
+    VesaScreenPrivPtr	pscr = screen->driver;
+    VesaCardPrivPtr	priv = screen->card->driver;
+    
+    if (pscr->fb)
+    {
+	if (pscr->mode->vbe)
+	    VbeUnmapFramebuffer(priv->vi, priv->vbeInfo, pscr->mode->mode, pscr->fb);
+	else
+	    VgaUnmapFramebuffer (priv->vi);
+    }
+    
+    if (pscr->shadow)
+	KdShadowScreenFini (screen);
+    screen->fb[0].depth = pscr->origDepth;
+}
+
+int 
+vesaSetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries)
+{
+    if (priv->vga_palette)
+	return VgaSetPalette (priv->vi, first, number, entries);
+    else
+	return VbeSetPalette (priv->vi, priv->vbeInfo, first, number, entries);
+}
+    
+
+int 
+vesaGetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries)
+{
+    int	code;
+    
+    if (priv->vga_palette)
+	code = VgaGetPalette (priv->vi, first, number, entries);
+    else
+    {
+	code = VbeGetPalette (priv->vi, priv->vbeInfo, first, number, entries);
+	if (code < 0)
+	{
+	    priv->vga_palette = 1;
+	    code = VgaGetPalette (priv->vi, first, number, entries);
+	}
+    }
+    return code;
+}
+    
+void
+vesaPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+    KdScreenPriv(pScreen);
+    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
+    VesaCardPrivPtr	priv = pScreenPriv->card->driver;
+    int	    p;
+    CARD8 scratch[4];
+    int	red, green, blue;
+
+    if (vesa_swap_rgb)
+    {
+	red = 2;
+	green = 1;
+	blue = 0;
+    }
+    else
+    {
+	red = 0;
+	green = 1;
+	blue = 2;
+    }
+
+    while (n--)
+    {
+        scratch[red] = pdefs->red >> 8;
+	scratch[green] = pdefs->green >> 8;
+	scratch[blue] = pdefs->blue >> 8;
+	scratch[3] = 0;
+	p = pdefs->pixel;
+	pdefs++;
+	if (pscr->mapping == VESA_PLANAR)
+	{
+	    /*
+	     * VGA modes are strange; this code covers all
+	     * possible modes by duplicating the color information
+	     * however the attribute registers might be set
+	     */
+	    if (p < 16)
+	    {
+		vesaSetPalette (priv, p, 1, scratch);
+		if (p >= 8)
+		    vesaSetPalette (priv, p+0x30, 1, scratch);
+		else if (p == 6)
+		    vesaSetPalette (priv, 0x14, 1, scratch);
+	    }
+	}
+	else
+	    vesaSetPalette(priv, p, 1, scratch);
+    }
+}
+
+void
+vesaGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+    KdScreenPriv(pScreen);
+    VesaCardPrivPtr priv = pScreenPriv->card->driver;
+    int first, i, j, k;
+    CARD8 scratch[4];
+    int	red, green, blue;
+
+    if (vesa_swap_rgb)
+    {
+	red = 2;
+	green = 1;
+	blue = 0;
+    }
+    else
+    {
+	red = 0;
+	green = 1;
+	blue = 2;
+    }
+    
+    for(i = 0; i<n; i++) {
+        vesaGetPalette(priv, pdefs[i].pixel, 1, scratch);
+        pdefs[i].red = scratch[red]<<8;
+        pdefs[i].green = scratch[green]<<8;
+        pdefs[i].blue = scratch[blue]<<8;
+    }
+}
+
+int
+vesaProcessArgument (int argc, char **argv, int i)
+{
+    if(!strcmp(argv[i], "-mode")) {
+        if(i+1 < argc) {
+            vesa_video_mode = strtol(argv[i+1], NULL, 0);
+        } else
+            UseMsg();
+        return 2;
+    } else if(!strcmp(argv[i], "-force")) {
+        vesa_force_mode = TRUE;
+        return 1;
+    } else if(!strcmp(argv[i], "-listmodes")) {
+        vesaListModes();
+        exit(0);
+    } else if(!strcmp(argv[i], "-swaprgb")) {
+	vesa_swap_rgb = TRUE;
+	return 1;
+    } else if(!strcmp(argv[i], "-shadow")) {
+	vesa_shadow = TRUE;
+	return 1;
+    } else if(!strcmp(argv[i], "-nolinear")) {
+        vesa_linear_fb = FALSE;
+        return 1;
+    } else if(!strcmp(argv[i], "-verbose")) {
+	vesa_verbose = TRUE;
+	return 1;
+    }
+    
+    return 0;
+}
Index: xc/programs/Xserver/hw/kdrive/vesa/vesa.h
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/vesa.h:1.7
--- /dev/null	Mon Dec 18 14:29:03 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/vesa.h	Thu Oct 19 20:19:50 2000
@@ -0,0 +1,151 @@
+/* 
+Copyright (c) 2000 by Juliusz Chroboczek
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions: 
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software. 
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.7 2000/10/20 00:19:50 keithp Exp $ */
+
+#ifndef _VESA_H_
+#define _VESA_H_
+
+#include "kdrive.h"
+#include "vm86.h"
+
+#define VESA_TEXT_SAVE	(64*1024)
+
+#define MODE_SUPPORTED	0x01
+#define MODE_COLOUR	0x08
+#define MODE_GRAPHICS	0x10
+#define MODE_VGA	0x20
+#define MODE_LINEAR	0x80
+
+#define MODE_DIRECT	0x1
+
+#define MEMORY_TEXT	0
+#define MEMORY_CGA	1
+#define MEMORY_HERCULES	2
+#define MEMORY_PLANAR	3
+#define MEMORY_PSEUDO	4
+#define MEMORY_NONCHAIN	5
+#define MEMORY_DIRECT	6
+#define MEMORY_YUV	7
+
+typedef struct _VesaMode {
+    int		mode;			/* mode number */
+    int		vbe;			/* a VBE mode */
+    int		ModeAttributes;		/* mode attributes */
+    int		NumberOfPlanes;		/* number of memory planes */
+    int		BitsPerPixel;		/* bits per pixel */
+    int		MemoryModel;		/* memory model type */
+    int		RedMaskSize;            /* size of direct color red mask in bits */
+    int		RedFieldPosition;       /* bit position of lsb of red mask */
+    int		GreenMaskSize;          /* size of direct color green mask in bits */
+    int		GreenFieldPosition;     /* bit position of lsb of green mask */
+    int		BlueMaskSize;           /* size of direct color blue mask in bits */
+    int		BlueFieldPosition;      /* bit position of lsb of blue mask */
+    int		RsvdMaskSize;           /* size of direct color reserved mask bits*/
+    int		RsvdFieldPosition;      /* bit position of lsb of reserved mask */
+    int		DirectColorModeInfo;    /* direct color mode attributes */
+    int		XResolution;            /* horizontal resolution */
+    int		YResolution;            /* vertical resolution */
+    int		BytesPerScanLine;       /* bytes per scan line */
+} VesaModeRec, *VesaModePtr;
+
+#include "vbe.h"
+#include "vga.h"
+
+typedef struct _VesaCardPriv {
+    int		vbe;
+    Vm86InfoPtr	vi;
+    VesaModePtr modes;
+    int		nmode;
+    int		vga_palette;
+    int		old_vbe_mode;
+    int		old_vga_mode;
+    VbeInfoPtr	vbeInfo;
+    char	text[VESA_TEXT_SAVE];
+} VesaCardPrivRec, *VesaCardPrivPtr;
+
+#define VESA_LINEAR	0
+#define VESA_WINDOWED	1
+#define VESA_PLANAR	2
+#define VESA_MONO	3
+
+typedef struct _VesaScreenPriv {
+    VesaModePtr mode;
+    Bool	shadow;
+    Bool	rotate;
+    int		mapping;
+    int		origDepth;
+    void	*fb;
+    int		fb_size;
+} VesaScreenPrivRec, *VesaScreenPrivPtr;
+
+extern int vesa_video_mode;
+extern Bool vesa_force_mode;
+
+void
+vesaListModes(void);
+
+Bool
+vesaInitialize(KdCardInfo *card, VesaCardPrivPtr priv);
+
+Bool
+vesaCardInit(KdCardInfo *card);
+
+Bool
+vesaInitialize (KdCardInfo *card, VesaCardPrivPtr priv);
+
+Bool
+vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr);
+
+Bool
+vesaScreenInit(KdScreenInfo *screen);    
+
+Bool
+vesaInitScreen(ScreenPtr pScreen);
+
+Bool
+vesaEnable(ScreenPtr pScreen);
+
+void
+vesaDisable(ScreenPtr pScreen);
+
+void
+vesaPreserve(KdCardInfo *card);
+
+void
+vesaRestore(KdCardInfo *card);
+
+void
+vesaCardFini(KdCardInfo *card);
+
+void
+vesaScreenFini(KdScreenInfo *screen);
+
+void
+vesaPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+void
+vesaGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+int
+vesaProcessArgument (int argc, char **argv, int i);
+
+#endif _VESA_H_
Index: xc/programs/Xserver/hw/kdrive/vesa/vesainit.c
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/vesainit.c:1.5
--- /dev/null	Mon Dec 18 14:29:03 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/vesainit.c	Fri Dec  8 16:40:29 2000
@@ -0,0 +1,81 @@
+/* 
+Copyright (c) 2000 by Juliusz Chroboczek
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions: 
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software. 
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesainit.c,v 1.5 2000/12/08 21:40:29 keithp Exp $ */
+
+#include "vesa.h"
+
+const KdCardFuncs vesaFuncs = {
+    vesaCardInit,               /* cardinit */
+    vesaScreenInit,             /* scrinit */
+    vesaInitScreen,             /* initScreen */
+    vesaPreserve,               /* preserve */
+    vesaEnable,                 /* enable */
+    0,                          /* dpms */
+    vesaDisable,                /* disable */
+    vesaRestore,                /* restore */
+    vesaScreenFini,             /* scrfini */
+    vesaCardFini,               /* cardfini */
+    
+    0,                          /* initCursor */
+    0,                          /* enableCursor */
+    0,                          /* disableCursor */
+    0,                          /* finiCursor */
+    0,                          /* recolorCursor */
+    
+    0,                          /* initAccel */
+    0,                          /* enableAccel */
+    0,                          /* syncAccel */
+    0,                          /* disableAccel */
+    0,                          /* finiAccel */
+    
+    vesaGetColors,              /* getColors */
+    vesaPutColors,              /* putColors */
+};
+
+void
+InitCard(char *name)
+{
+    KdCardAttr attr;
+    KdCardInfoAdd((KdCardFuncs *) &vesaFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+    KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+    KdInitInput(&Ps2MouseFuncs, &LinuxKeyboardFuncs);
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+    int	ret;
+    
+    if (!(ret = vesaProcessArgument (argc, argv, i)))
+	ret = KdProcessArgument(argc, argv, i);
+    return ret;
+}
Index: xc/programs/Xserver/hw/kdrive/vesa/vga.c
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/vga.c:1.1
--- /dev/null	Mon Dec 18 14:29:03 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/vga.c	Thu Oct 19 20:19:51 2000
@@ -0,0 +1,240 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vga.c,v 1.1 2000/10/20 00:19:51 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "vesa.h"
+
+static const VesaModeRec vgaModes[] = {
+    {
+	6,  0,
+	MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_LINEAR,
+	1, 1, MEMORY_PLANAR, 
+	0, 0, 0, 0, 0, 0, 0, 0, 0,
+	640, 200, 80,
+    },
+    {
+	0xd, 0,
+	MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR,
+	4, 4, MEMORY_PLANAR, 
+	0, 0, 0, 0, 0, 0, 0, 0, 0,
+	320, 200, 40,
+    },
+    {
+	0xe, 0,
+	MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR,
+	4, 4, MEMORY_PLANAR, 
+	0, 0, 0, 0, 0, 0, 0, 0, 0,
+	640, 200, 80,
+    },
+    {
+	0x10, 0,
+	MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR,
+	4, 4, MEMORY_PLANAR, 
+	0, 0, 0, 0, 0, 0, 0, 0, 0,
+	640, 350, 80,
+    },
+    {
+	0x11, 0,
+	MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_LINEAR,
+	1, 1, MEMORY_PLANAR, 
+	0, 0, 0, 0, 0, 0, 0, 0, 0,
+	640, 480, 80,
+    },
+    {
+	0x12, 0,
+	MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR,
+	4, 4, MEMORY_PLANAR, 
+	0, 0, 0, 0, 0, 0, 0, 0, 0,
+	640, 480, 80,
+    },
+    {
+	0x13, 0,
+	MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR | MODE_LINEAR,
+	8, 8, MEMORY_PSEUDO,
+	0, 0, 0, 0, 0, 0, 0, 0, 0,
+	320, 200, 320,
+    },
+};
+
+#define NUM_VGA_MODE	(sizeof vgaModes / sizeof vgaModes[0])
+
+int
+VgaGetNmode (Vm86InfoPtr vi)
+{
+    return NUM_VGA_MODE;
+}
+
+int
+VgaGetModes (Vm86InfoPtr vi, VesaModePtr mode, int nmode)
+{
+    if (nmode > NUM_VGA_MODE)
+	nmode = NUM_VGA_MODE;
+    memcpy (mode, vgaModes, nmode * sizeof (VesaModeRec));
+    return nmode;
+}
+
+int
+VgaSetMode(Vm86InfoPtr vi, int mode)
+{
+    int code;
+    
+    vi->vms.regs.eax = mode & 0x7f;
+    code = Vm86DoInterrupt (vi, 0x10);
+    if(code < 0)
+        return -1;
+    return 0;
+}
+
+int
+VgaGetMode (Vm86InfoPtr vi, int *mode)
+{
+    *mode = Vm86Memory (vi, 0x449);
+    return 0;
+}
+
+int
+VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask)
+{
+    asm volatile ("outb %b0,%w1" : : "a" (2), "d" (0x3c4));
+    asm volatile ("outb %b0,%w1" : : "a" (mask), "d" (0x3c5));
+}
+
+int
+VgaSetReadPlaneMap(Vm86InfoPtr vi, int map)
+{
+    asm volatile ("outb %b0,%w1" : : "a" (4), "d" (0x3ce));
+    asm volatile ("outb %b0,%w1" : : "a" (map), "d" (0x3cf));
+}
+
+int 
+VgaSetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries)
+{
+    U8	    *palette_scratch;
+    int	    mark;
+    int	    palette_base;
+    int	    i, j, code;
+
+    if(number == 0)
+        return 0;
+
+    if(first < 0 || number < 0 || first + number > 256) {
+        ErrorF("Cannot set %d, %d palette entries\n", first, number);
+        return -1;
+    }
+
+    mark = Vm86MarkMemory (vi);
+    palette_base = Vm86AllocateMemory (vi, 3 * 256);
+    
+    palette_scratch = &LM(vi, palette_base);
+
+    vi->vms.regs.eax = 0x1012;
+    vi->vms.regs.ebx = first;
+    vi->vms.regs.ecx = number;
+    vi->vms.regs.es = POINTER_SEGMENT(palette_base);
+    vi->vms.regs.edx = POINTER_OFFSET(palette_base);
+    j = 0;
+    i = 0;
+    while (number--)
+    {
+	palette_scratch[j++] = entries[i++] >> 2;
+	palette_scratch[j++] = entries[i++] >> 2;
+	palette_scratch[j++] = entries[i++] >> 2;
+	i++;
+    }
+    code = Vm86DoInterrupt(vi, 0x10);
+    Vm86ReleaseMemory (vi, mark);
+    
+    if(code < 0)
+	return -1;
+    return 0;
+}
+        
+int 
+VgaGetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries)
+{
+    U8	    *palette_scratch;
+    int	    mark;
+    int	    palette_base;
+    int	    i, j, code;
+
+    if(number == 0)
+        return 0;
+
+    if(first < 0 || number < 0 || first + number > 256) {
+        ErrorF("Cannot get %d, %d palette entries\n", first, number);
+        return -1;
+    }
+
+    mark = Vm86MarkMemory (vi);
+    palette_base = Vm86AllocateMemory (vi, 3 * 256);
+    
+    palette_scratch = &LM(vi, palette_base);
+
+    vi->vms.regs.eax = 0x1017;
+    vi->vms.regs.ebx = first;
+    vi->vms.regs.ecx = number;
+    vi->vms.regs.es = POINTER_SEGMENT(palette_base);
+    vi->vms.regs.edx = POINTER_OFFSET(palette_base);
+    
+    code = VbeDoInterrupt10(vi);
+    if(code < 0)
+	return -1;
+    
+    j = 0;
+    i = 0;
+    while (number--)
+    {
+	entries[i++] = palette_scratch[j++] << 2;
+	entries[i++] = palette_scratch[j++] << 2;
+	entries[i++] = palette_scratch[j++] << 2;
+	entries[i++] = 0;
+    }
+    
+    Vm86ReleaseMemory (vi, mark);
+
+    return 0;
+}   
+        
+#define VGA_FB(vm)  ((vm) < 8 ? 0xb8000 : 0xa0000)
+
+void *
+VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size)
+{
+    *size = 0x10000 - bytes;
+    return &LM(vi,VGA_FB(vmode) + bytes);
+}
+
+void *
+VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size)
+{
+    if (VGA_FB(vmode) == 0xa0000)
+	*size = 0x10000;
+    else
+	*size = 0x4000;
+    return &LM(vi,VGA_FB(vmode));
+}
+
+void
+VgaUnmapFramebuffer (Vm86InfoPtr vi)
+{
+}
Index: xc/programs/Xserver/hw/kdrive/vesa/vga.h
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/vga.h:1.1
--- /dev/null	Mon Dec 18 14:29:04 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/vga.h	Thu Oct 19 20:19:51 2000
@@ -0,0 +1,61 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vga.h,v 1.1 2000/10/20 00:19:51 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _VGA_H_
+#define _VGA_H_
+
+int
+VgaGetNmode (Vm86InfoPtr vi);
+
+int
+VgaGetModes (Vm86InfoPtr vi, VesaModePtr mode, int nmode);
+
+int
+VgaSetMode(Vm86InfoPtr vi, int mode);
+
+int
+VgaGetMode (Vm86InfoPtr vi, int *mode);
+
+int
+VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask);
+
+int
+VgaSetReadPlaneMap(Vm86InfoPtr vi, int map);
+
+int 
+VgaSetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries);
+        
+int 
+VgaGetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries);
+        
+void *
+VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size);
+    
+void *
+VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size);
+
+void
+VgaUnmapFramebuffer (Vm86InfoPtr vi);
+
+#endif /* _VGA_H_ */
Index: xc/programs/Xserver/hw/kdrive/vesa/vm86.c
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/vm86.c:1.1
--- /dev/null	Mon Dec 18 14:29:04 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/vm86.c	Thu Oct 19 20:19:51 2000
@@ -0,0 +1,697 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vm86.c,v 1.1 2000/10/20 00:19:51 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* 
+Copyright (c) 2000 by Juliusz Chroboczek
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions: 
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software. 
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#include "vm86.h"
+
+#define PUSHW(vi, i) \
+{ vi->vms.regs.esp -= 2;\
+  LMW(vi,MAKE_POINTER(vi->vms.regs.ss, vi->vms.regs.esp)) = i;}
+
+static int vm86old(struct vm86_struct *vms);
+static int vm86_loop(Vm86InfoPtr vi);
+
+static const U8 rev_ints[32] =
+{ 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0x80,
+};
+
+static const U8 retcode_data[2] =
+{ 0xCD, 0xFF };
+
+Vm86InfoPtr
+Vm86Setup(void)
+{
+    int devmem = -1, devzero = -1;
+    void *magicMem, *loMem, *hiMem;
+    U32 stack_base, ret_code;
+    Vm86InfoPtr vi = NULL;
+
+    devmem = open("/dev/mem", O_RDWR);
+    if(devmem < 0) {
+	perror("open /dev/mem");
+	goto fail;
+    }
+
+    devzero = open("/dev/zero", O_RDWR);
+    if(devmem < 0) {
+	perror("open /dev/zero");
+	goto fail;
+    }
+
+
+    magicMem = mmap((void*)MAGICMEM_BASE, MAGICMEM_SIZE,
+		    PROT_READ | PROT_WRITE | PROT_EXEC,
+		    MAP_PRIVATE | MAP_FIXED, devmem, MAGICMEM_BASE);
+    
+    if(magicMem == MAP_FAILED) {
+	ErrorF("Couldn't map magic memory\n");
+	goto fail;
+    }
+
+    loMem = mmap((void*)LOMEM_BASE, LOMEM_SIZE,
+		 PROT_READ | PROT_WRITE | PROT_EXEC,
+		 MAP_PRIVATE | MAP_FIXED, devzero, LOMEM_BASE);
+    if(loMem == MAP_FAILED) {
+	ErrorF("Couldn't map low memory\n");
+	munmap(magicMem, MAGICMEM_SIZE);
+	goto fail;
+    }
+
+    hiMem = mmap((void*)HIMEM_BASE, HIMEM_SIZE,
+		 PROT_READ | PROT_WRITE | PROT_EXEC,
+		 MAP_SHARED | MAP_FIXED,
+		 devmem, HIMEM_BASE);
+    if(hiMem == MAP_FAILED) {
+	ErrorF("Couldn't map high memory\n");
+	munmap(magicMem, MAGICMEM_SIZE);
+	munmap(loMem, LOMEM_SIZE);
+	goto fail;
+    }
+
+    vi = xalloc(sizeof(Vm86InfoRec));
+    if (!vi)
+	goto unmapfail;
+
+    vi->magicMem = magicMem;
+    vi->loMem = loMem;
+    vi->hiMem = hiMem;
+    vi->brk = LOMEM_BASE;
+
+    stack_base = Vm86AllocateMemory(vi, STACK_SIZE);
+    if(stack_base == ALLOC_FAIL)
+	goto unmapfail;
+    ret_code = Vm86AllocateMemory(vi, sizeof(retcode_data));
+    if(ret_code == ALLOC_FAIL)
+	goto unmapfail;
+
+    vi->stack_base = stack_base;
+    vi->ret_code = ret_code;
+
+    memset(&vi->vms, 0, sizeof(struct vm86_struct));
+    vi->vms.flags = 0;
+    vi->vms.screen_bitmap = 0;
+    vi->vms.cpu_type = CPU_586;
+    memcpy(&vi->vms.int_revectored, rev_ints, sizeof(rev_ints));
+
+    iopl(3);
+    
+    if(devmem >= 0)
+	close(devmem);
+    if(devzero >= 0)
+	close(devzero);
+
+    return vi;
+
+unmapfail:
+    munmap(magicMem, MAGICMEM_SIZE);
+    munmap(loMem, LOMEM_SIZE);
+    munmap(hiMem, HIMEM_SIZE);
+fail:
+    if(devmem >= 0)
+	close(devmem);
+    if(devzero >= 0)
+	close(devzero);
+    if(vi)
+	xfree(vi);
+    return NULL;
+}
+
+void
+Vm86Cleanup(Vm86InfoPtr vi)
+{
+    munmap(vi->magicMem, MAGICMEM_SIZE);
+    munmap(vi->loMem, LOMEM_SIZE);
+    munmap(vi->hiMem, HIMEM_SIZE);
+    xfree(vi);
+}
+
+int
+Vm86DoInterrupt(Vm86InfoPtr vi, int num)
+{
+    U16 seg, off;
+    int code;
+
+    if(num < 0 || num>256) {
+	ErrorF("Interrupt %d doesn't exist\n");
+	return -1;
+    }
+    seg = MMW(vi,num * 4 + 2);
+    off = MMW(vi,num * 4);
+    if(MAKE_POINTER(seg, off) < ROM_BASE ||
+       MAKE_POINTER(seg, off) >= ROM_BASE + ROM_SIZE) {
+	ErrorF("Interrupt pointer doesn't point at ROM\n");
+	return -1;
+    }
+    memcpy(&(LM(vi,vi->ret_code)), retcode_data, sizeof(retcode_data));
+    vi->vms.regs.eflags = IF_MASK | IOPL_MASK;
+    vi->vms.regs.ss = POINTER_SEGMENT(vi->stack_base);
+    vi->vms.regs.esp = STACK_SIZE;
+    PUSHW(vi, IF_MASK | IOPL_MASK);
+    PUSHW(vi, POINTER_SEGMENT(vi->ret_code));
+    PUSHW(vi, POINTER_OFFSET(vi->ret_code));
+    vi->vms.regs.cs = seg;
+    vi->vms.regs.eip = off;
+    OsBlockSignals ();
+    code = vm86_loop(vi);
+    OsReleaseSignals ();
+    if(code < 0) {
+	perror("vm86 failed");
+	return -1;
+    } else if(code != 0) {
+	ErrorF("vm86 returned 0x%04X\n", code);
+	return -1;
+    } else
+	return 0;
+}
+
+#define DEBUG_VBE 0
+#if DEBUG_VBE
+#define DBG(x) ErrorF x; usleep(10*1000)
+#else
+#define DBG(x)
+#endif
+
+static inline U8 
+vm86_inb(U16 port)
+{
+    U8 value;
+    
+    if (port != 0x3da)
+    {
+	DBG(("inb  0x%04x", port));
+    }
+    asm volatile ("inb %w1,%b0" : "=a" (value) : "d" (port));
+    if (port != 0x3da)
+    {
+	DBG((" = 0x%02x\n", value));
+    }
+    return value;
+}
+
+static inline U16
+vm86_inw(U16 port)
+{
+    U16 value;
+    DBG(("inw  0x%04x", port));
+    asm volatile ("inw %w1,%w0" : "=a" (value) : "d" (port));
+    DBG((" = 0x%04x\n", value));
+    return value;
+}
+
+static inline U32
+vm86_inl(U16 port)
+{
+    U32 value;
+    DBG(("inl  0x%04x", port));
+    asm volatile ("inl %w1,%0" : "=a" (value) : "d" (port));
+    DBG((" = 0x%08x\n", value));
+    return value;
+}
+
+static inline void
+vm86_outb(U16 port, U8 value)
+{
+#if 0
+    static U8 CR;
+
+    if (port == 0x3d4)
+	CR = value;
+    if (port == 0x3d5 && CR == 0xa4)
+    {
+	DBG(("outb 0x%04x = 0x%02x (skipped)\n", port, value));
+	return;
+    }
+#endif
+    DBG(("outb 0x%04x = 0x%02x\n", port, value));
+    asm volatile ("outb %b0,%w1" : : "a" (value), "d" (port));
+}
+
+static inline void
+vm86_outw(U16 port, U16 value)
+{
+    DBG(("outw 0x%04x = 0x%04x\n", port, value));
+    asm volatile ("outw %w0,%w1" : : "a" (value), "d" (port));
+}
+
+static inline void
+vm86_outl(U16 port, U32 value)
+{
+    DBG(("outl 0x%04x = 0x%08x\n", port, value));
+    asm volatile ("outl %0,%w1" : : "a" (value), "d" (port));
+}
+
+#define SEG_CS 1
+#define SEG_DS 2
+#define SEG_ES 3
+#define SEG_SS 4
+#define SEG_GS 5
+#define SEG_FS 6
+#define REP 1
+#define REPNZ 2
+#define SET_8(_x, _y) (_x) = (_x & ~0xFF) | (_y & 0xFF);
+#define SET_16(_x, _y) (_x) = (_x & ~0xFFFF) | (_y & 0xFFFF);
+#define INC_IP(_i) SET_16(regs->eip, (regs->eip + _i))
+#define AGAIN INC_IP(1); goto again;
+
+static int
+vm86_emulate(Vm86InfoPtr vi)
+{
+    struct vm86_regs *regs = &vi->vms.regs;
+    U8 opcode;
+    int size;
+    int pref_seg = 0, pref_rep = 0, pref_66 = 0, pref_67 = 0;
+    U32 count;
+    int code;
+
+  again:
+    if(!Vm86IsMemory(vi, MAKE_POINTER(regs->cs, regs->eip))) {
+        ErrorF("Trying to execute unmapped memory\n");
+        return -1;
+    }
+    opcode = Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip));
+    switch(opcode) {
+    case 0x2E: pref_seg = SEG_CS; AGAIN;
+    case 0x3E: pref_seg = SEG_DS; AGAIN;
+    case 0x26: pref_seg = SEG_ES; AGAIN;
+    case 0x36: pref_seg = SEG_SS; AGAIN;
+    case 0x65: pref_seg = SEG_GS; AGAIN;
+    case 0x64: pref_seg = SEG_FS; AGAIN;
+    case 0x66: pref_66 = 1; AGAIN;
+    case 0x67: pref_67 = 1; AGAIN;
+    case 0xF2: pref_rep = REPNZ; AGAIN;
+    case 0xF3: pref_rep = REP; AGAIN;
+
+    case 0xEC:                  /* IN AL, DX */
+        SET_8(regs->eax, vm86_inb(regs->edx & 0xFFFF));
+        INC_IP(1);
+        break;
+    case 0xED:                  /* IN AX, DX */
+        if(pref_66)
+            regs->eax = vm86_inl(regs->edx & 0xFFFF);
+        else
+            SET_16(regs->eax, vm86_inw(regs->edx & 0xFFFF));
+	INC_IP(1);
+        break;
+    case 0xE4:                  /* IN AL, imm8 */
+        SET_8(regs->eax, 
+              vm86_inb(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1))));
+        INC_IP(2);
+        break;
+    case 0xE5:                  /* IN AX, imm8 */
+        if(pref_66)
+            regs->eax =
+                vm86_inl(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)));
+        else
+            SET_16(regs->eax, 
+                   vm86_inw(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1))));
+        INC_IP(2);
+        break;
+    case 0x6C:                  /* INSB */
+    case 0x6D:                  /* INSW */
+        if(opcode == 0x6C) {
+            Vm86WriteMemory(vi, MAKE_POINTER(regs->es, regs->edi),
+                vm86_inb(regs->edx & 0xFFFF));
+            size = 1;
+        } else if(pref_66) {
+            Vm86WriteMemoryL(vi, MAKE_POINTER(regs->es, regs->edi),
+                vm86_inl(regs->edx & 0xFFFF));
+            size = 4;
+        } else {
+            Vm86WriteMemoryW(vi, MAKE_POINTER(regs->es, regs->edi),
+                vm86_inw(regs->edx & 0xFFFF));
+            size = 2;
+        }
+        if(regs->eflags & (1<<10))
+            regs->edi -= size;
+        else
+            regs->edi += size;
+        if(pref_rep) {
+            if(pref_66) {
+                regs->ecx--;
+                if(regs->ecx != 0) {
+                    goto again;
+                } else {
+                    SET_16(regs->ecx, regs->ecx - 1);
+                    if(regs->ecx & 0xFFFF != 0)
+                        goto again;
+                }
+            }
+        }
+        INC_IP(1);
+        break;
+
+    case 0xEE:                  /* OUT DX, AL */
+        vm86_outb(regs->edx & 0xFFFF, regs->eax & 0xFF);
+        INC_IP(1);
+        break;
+    case 0xEF:                  /* OUT DX, AX */
+        if(pref_66)
+            vm86_outl(regs->edx & 0xFFFF, regs->eax);
+        else
+            vm86_outw(regs->edx & 0xFFFF, regs->eax & 0xFFFF);
+        INC_IP(1);
+        break;
+    case 0xE6:                  /* OUT imm8, AL */
+        vm86_outb(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)),
+             regs->eax & 0xFF);
+        INC_IP(2);
+        break;
+    case 0xE7:                  /* OUT imm8, AX */
+        if(pref_66)
+            vm86_outl(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)),
+                  regs->eax);
+        else
+            vm86_outw(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)),
+                 regs->eax & 0xFFFF);
+        INC_IP(2);
+        break;
+    case 0x6E:                  /* OUTSB */
+    case 0x6F:                  /* OUTSW */
+        if(opcode == 0x6E) {
+            vm86_outb(regs->edx & 0xFFFF, 
+                 Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi)));
+            size = 1;
+        } else if(pref_66) {
+            vm86_outl(regs->edx & 0xFFFF, 
+                 Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi)));
+            size = 4;
+        } else {
+            vm86_outw(regs->edx & 0xFFFF, 
+                 Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi)));
+            size = 2;
+        }
+        if(regs->eflags & (1<<10))
+            regs->edi -= size;
+        else
+            regs->edi += size;
+        if(pref_rep) {
+            if(pref_66) {
+                regs->ecx--;
+                if(regs->ecx != 0) {
+                    goto again;
+                } else {
+                    SET_16(regs->ecx, regs->ecx - 1);
+                    if(regs->ecx & 0xFFFF != 0)
+                        goto again;
+                }
+            }
+        }
+        INC_IP(1);
+        break;
+
+    case 0x0F:
+        ErrorF("Hit 0F trap in VM86 code\n");
+        return -1;
+    case 0xF0:
+        ErrorF("Hit lock prefix in VM86 code\n");
+        return -1;
+    case 0xF4:
+        ErrorF("Hit HLT in VM86 code\n");
+        return -1;
+
+    default:
+        ErrorF("Unhandled GP fault in VM86 code (opcode = 0x%02X)\n",
+               opcode);
+        return -1;
+    }
+    return 0;
+}
+#undef SEG_CS
+#undef SEG_DS
+#undef SEG_ES
+#undef SEG_SS
+#undef SEG_GS
+#undef SEG_FS
+#undef REP
+#undef REPNZ
+#undef SET_8
+#undef SET_16
+#undef INC_IP
+#undef AGAIN
+
+static int
+vm86_loop(Vm86InfoPtr vi)
+{
+    int code;
+    
+    while(1) {
+        code = vm86old(&vi->vms);
+        switch(VM86_TYPE(code)) {
+        case VM86_SIGNAL:
+            continue;
+        case VM86_UNKNOWN:
+            code = vm86_emulate(vi);
+            if(code < 0) {
+                Vm86Debug(vi);
+                return -1;
+            }
+            break;
+        case VM86_INTx:
+            if(VM86_ARG(code) == 0xFF)
+                return 0;
+            else {
+                PUSHW(vi, vi->vms.regs.eflags)
+                PUSHW(vi, vi->vms.regs.cs);
+                PUSHW(vi, vi->vms.regs.eip);
+                vi->vms.regs.cs = MMW(vi,VM86_ARG(code) * 4 + 2);
+                vi->vms.regs.eip = MMW(vi,VM86_ARG(code) * 4);
+            }
+            break;
+        case VM86_STI:
+            ErrorF("VM86 code enabled interrupts\n");
+            Vm86Debug(vi);
+            return -1;
+        default:
+            ErrorF("Unexpected result code 0x%X from vm86\n", code);
+            Vm86Debug(vi);
+            return -1;
+        }
+    }
+}
+
+int 
+Vm86IsMemory(Vm86InfoPtr vi, U32 i) 
+{
+    if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+        return 1;
+    else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+        return 1;
+    else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+        return 1;
+    else
+        return 0;
+}
+
+U8 
+Vm86Memory(Vm86InfoPtr vi, U32 i)
+{
+    if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+        return MM(vi, i);
+    else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+        return LM(vi, i);
+    else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+        return HM(vi, i);
+    else {
+        ErrorF("Reading unmapped memory at 0x%08X\n", i);
+    }
+}
+
+U16
+Vm86MemoryW(Vm86InfoPtr vi, U32 i)
+{
+    if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+        return MMW(vi, i);
+    else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+        return LMW(vi, i);
+    else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+        return HMW(vi, i);
+    else {
+        ErrorF("Reading unmapped memory at 0x%08X\n", i);
+        return 0;
+    }
+}
+
+U32
+Vm86MemoryL(Vm86InfoPtr vi, U32 i)
+{
+    if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+        return MML(vi, i);
+    else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+        return LML(vi, i);
+    else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+        return HML(vi, i);
+    else {
+        ErrorF("Reading unmapped memory at 0x%08X\n", i);
+        return 0;
+    }
+}
+
+void
+Vm86WriteMemory(Vm86InfoPtr vi, U32 i, U8 val)
+{
+    if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+        MM(vi, i) = val;
+    else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+        LM(vi, i) = val;
+    else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+        HM(vi, i) = val;
+    else {
+        ErrorF("Writing unmapped memory at 0x%08X\n", i);
+    }
+}
+
+void
+Vm86WriteMemoryW(Vm86InfoPtr vi, U32 i, U16 val)
+{
+    if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+        MMW(vi, i) = val;
+    else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+        LMW(vi, i) = val;
+    else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+        HMW(vi, i) = val;
+    else {
+        ErrorF("Writing unmapped memory at 0x%08X\n", i);
+    }
+}
+
+void
+Vm86WriteMemoryL(Vm86InfoPtr vi, U32 i, U32 val)
+{
+    if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+        MML(vi, i) = val;
+    else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+        LML(vi, i) = val;
+    else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+        HML(vi, i) = val;
+    else {
+        ErrorF("Writing unmapped memory at 0x%08X\n", i);
+    }
+}
+
+int
+Vm86AllocateMemory(Vm86InfoPtr vi, int n)
+{
+    int ret;
+    if(n<0) {
+        ErrorF("Asked to allocate negative amount of memory\n");
+        return vi->brk;
+    }
+      
+    n = (n + 15) & ~15;
+    if(vi->brk + n > LOMEM_BASE + LOMEM_SIZE) {
+        ErrorF("Out of low memory\n");
+        exit(2);
+    }
+    ret = vi->brk;
+    vi->brk += n;
+    return ret;
+}
+
+int
+Vm86MarkMemory (Vm86InfoPtr vi)
+{
+    return vi->brk;
+}
+
+void
+Vm86ReleaseMemory (Vm86InfoPtr vi, int mark)
+{
+    vi->brk = mark;
+}
+
+static int
+vm86old(struct vm86_struct *vm)
+{
+    int res;
+    
+    asm volatile (
+	"pushl %%ebx\n\t"
+	"movl %2, %%ebx\n\t"
+	"movl %1,%%eax\n\t"
+	"int $0x80\n\t"
+	"popl %%ebx"
+	: "=a" (res)  : "n" (113), "r" (vm));
+    if(res < 0) {
+	errno = -res;
+	res = -1;
+    } else 
+	errno = 0;
+    return res;
+}
+
+void
+Vm86Debug(Vm86InfoPtr vi)
+{
+    struct vm86_regs *regs = &vi->vms.regs;
+    int i;
+
+    ErrorF("eax=0x%08lX ebx=0x%08lX ecx=0x%08lX edx=0x%08lX\n",
+           regs->eax, regs->ebx, regs->ecx, regs->edx);
+    ErrorF("esi=0x%08lX edi=0x%08lX ebp=0x%08lX\n",
+           regs->esi, regs->edi, regs->ebp);
+    ErrorF("eip=0x%08lX esp=0x%08lX eflags=0x%08lX\n",
+           regs->eip, regs->esp, regs->eflags);
+    ErrorF("cs=0x%04lX      ds=0x%04lX      es=0x%04lX      fs=0x%04lX      gs=0x%04lX\n",
+           regs->cs, regs->ds, regs->es, regs->fs, regs->gs);
+    for(i=-7; i<8; i++) {
+        ErrorF(" %s%02X",
+               i==0?"->":"",
+               Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip + i)));
+    }
+    ErrorF("\n");
+}
+
+#ifdef NOT_IN_X_SERVER
+static void 
+ErrorF(char *f, ...)
+{
+    va_list args;
+    va_start(args, f);
+    vfprintf(stderr, f, args);
+    va_end(args);
+}
+#endif
Index: xc/programs/Xserver/hw/kdrive/vesa/vm86.h
diff -u /dev/null xc/programs/Xserver/hw/kdrive/vesa/vm86.h:1.1
--- /dev/null	Mon Dec 18 14:29:04 2000
+++ xc/programs/Xserver/hw/kdrive/vesa/vm86.h	Thu Oct 19 20:19:51 2000
@@ -0,0 +1,165 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vm86.h,v 1.1 2000/10/20 00:19:51 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/* 
+Copyright (c) 2000 by Juliusz Chroboczek
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions: 
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software. 
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef _VM86_H_
+#define _VM86_H_
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/vm86.h>
+#include <sys/io.h>
+
+#ifdef NOT_IN_X_SERVER
+#include <stdio.h>
+#include <stdarg.h>
+#include <malloc.h>
+static void ErrorF(char*, ...);
+#define xalloc(a) malloc(a)
+#define xcalloc(a,b) calloc(a,b)
+#define xfree(a) free(a)
+#else
+#include "X.h"
+#include "Xproto.h"
+#include "Xos.h"
+#include "os.h"
+#endif
+
+typedef unsigned char	U8;
+typedef unsigned short	U16;
+typedef unsigned int	U32;
+
+/* The whole addressable memory */
+#define SYSMEM_BASE 0x00000
+#define SYSMEM_SIZE 0x100000
+
+/* Interrupt vectors and BIOS data area */
+/* This is allocated privately from /dev/mem */
+#define MAGICMEM_BASE 0x00000
+#define MAGICMEM_SIZE 0x01000
+
+/* The low memory, allocated privately from /dev/zero */
+/* 64KB should be enough for anyone, as they used to say */
+#define LOMEM_BASE 0x10000
+#define LOMEM_SIZE 0x10000
+
+/* The video memory and BIOS ROM, allocated shared from /dev/mem */
+#define HIMEM_BASE 0xA0000
+#define HIMEM_SIZE (SYSMEM_BASE + SYSMEM_SIZE - HIMEM_BASE)
+
+/* The BIOS ROM */
+#define ROM_BASE 0xC0000
+#define ROM_SIZE 0x30000
+
+#define STACK_SIZE 0x1000
+
+#define POINTER_SEGMENT(ptr) (((unsigned int)ptr)>>4)
+#define POINTER_OFFSET(ptr) (((unsigned int)ptr)&0x000F)
+#define MAKE_POINTER(seg, off) (((((unsigned int)(seg))<<4) + (unsigned int)(off)))
+#define MAKE_POINTER_1(lw) MAKE_POINTER(((lw)&0xFFFF0000)/0x10000, (lw)&0xFFFF)
+#define ALLOC_FAIL ((U32)-1)
+
+typedef struct _Vm86InfoRec {
+    void		*magicMem, *loMem, *hiMem;
+    U32			brk;
+    struct vm86_struct	vms;
+    U32			ret_code, stack_base;
+} Vm86InfoRec, *Vm86InfoPtr;
+
+#define LM(vi,i) (((char*)vi->loMem)[i-LOMEM_BASE])
+#define LMW(vi,i) (*(U16*)(&LM(vi,i)))
+#define LML(vi,i) (*(U32*)(&LM(vi,i)))
+#define MM(vi,i) (((char*)vi->magicMem)[i-MAGICMEM_BASE])
+#define MMW(vi,i) (*(U16*)(&MM(vi,i)))
+#define MML(vi,i) (*(U32*)(&MM(vi,i)))
+#define HM(vi,i) (((char*)vi->hiMem)[i-HIMEM_BASE])
+#define HMW(vi,i) (*(U16*)(&MM(vi,i)))
+#define HML(vi,i) (*(U32*)(&MM(vi,i)))
+
+Vm86InfoPtr
+Vm86Setup(void);
+    
+void
+Vm86Cleanup(Vm86InfoPtr vi);
+
+int
+Vm86DoInterrupt(Vm86InfoPtr vi, int num);
+
+int
+Vm86IsMemory(Vm86InfoPtr vi, U32 i);
+
+U8
+Vm86Memory(Vm86InfoPtr, U32);
+
+U16
+Vm86MemoryW(Vm86InfoPtr, U32);
+
+U32
+Vm86MemoryL(Vm86InfoPtr, U32);
+
+void
+Vm86WriteMemory(Vm86InfoPtr, U32, U8);
+
+void
+Vm86WriteMemoryW(Vm86InfoPtr, U32, U16);
+
+void
+Vm86WriteMemoryL(Vm86InfoPtr, U32, U32);
+
+int
+Vm86AllocateMemory(Vm86InfoPtr, int);
+
+int
+Vm86MarkMemory (Vm86InfoPtr vi);
+
+void
+Vm86ReleaseMemory (Vm86InfoPtr vi, int mark);
+
+void
+Vm86Debug(Vm86InfoPtr vi);
+
+#endif /* _VM86_H_ */
Index: xc/programs/Xserver/hw/sun/sun.h
diff -u xc/programs/Xserver/hw/sun/sun.h:3.9 xc/programs/Xserver/hw/sun/sun.h:3.10
--- xc/programs/Xserver/hw/sun/sun.h:3.9	Wed May 17 15:52:21 2000
+++ xc/programs/Xserver/hw/sun/sun.h	Tue Oct 24 14:07:47 2000
@@ -13,7 +13,7 @@
  * express or implied warranty.
  */
 
-/* $XFree86: xc/programs/Xserver/hw/sun/sun.h,v 3.9 2000/05/17 19:52:21 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sun.h,v 3.10 2000/10/24 18:07:47 dawes Exp $ */
 
 #ifndef _SUN_H_ 
 #define _SUN_H_
@@ -102,7 +102,7 @@
 extern int setrlimit();
 extern int getpagesize();
 # else
-#  ifdef CSRG_BASED
+#  if defined(CSRG_BASED) && !defined(__bsdi__)
 #   include <machine/fbio.h>
 #   include <machine/kbd.h>
 #   include <machine/kbio.h>
Index: xc/programs/Xserver/hw/sun/sunCfb.c
diff -u xc/programs/Xserver/hw/sun/sunCfb.c:3.10 xc/programs/Xserver/hw/sun/sunCfb.c:3.11
--- xc/programs/Xserver/hw/sun/sunCfb.c:3.10	Sun Oct  4 05:38:34 1998
+++ xc/programs/Xserver/hw/sun/sunCfb.c	Tue Oct 24 14:07:47 2000
@@ -50,7 +50,7 @@
 
 ********************************************************/
 
-/* $XFree86: xc/programs/Xserver/hw/sun/sunCfb.c,v 3.10 1998/10/04 09:38:34 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunCfb.c,v 3.11 2000/10/24 18:07:47 dawes Exp $ */
 
 /*
  * Copyright 1987 by the Regents of the University of California
@@ -300,7 +300,7 @@
 	cfbCreateDefColormap, sunSaveScreen, 0);
 }
 
-#if !defined(i386) && !defined(__bsdi__) /* { */
+#if !defined(i386) /* { */
 
 #ifdef SVR4 /* { */
 #include <sys/cg2reg.h>
@@ -309,13 +309,16 @@
 #include <pixrect/cg2reg.h>
 #else
 #if defined(__sparc__) || defined(__sparc) /* { */
+#if !defined(__bsdi__)
 #include <machine/cgtworeg.h>
+#endif
 #else
 #include <machine/cg2reg.h>
 #endif /* } */
 #endif /* } */
 #endif /* } */
 
+#ifndef __bsdi__ /* { */
 typedef struct {
     struct cg2memfb	mem;
     struct cg2fb 	regs;
@@ -418,6 +421,8 @@
 #endif /* ifndef LOWMEMFTPT */
     return ret;
 }
+
+#endif /* } */
 
 #define	CG4_HEIGHT	900
 #define	CG4_WIDTH	1152
Index: xc/programs/Xserver/hw/vfb/Imakefile
diff -u xc/programs/Xserver/hw/vfb/Imakefile:3.21 xc/programs/Xserver/hw/vfb/Imakefile:3.24
--- xc/programs/Xserver/hw/vfb/Imakefile:3.21	Tue Jan  4 21:03:10 2000
+++ xc/programs/Xserver/hw/vfb/Imakefile	Mon Dec 11 15:29:43 2000
@@ -1,5 +1,5 @@
 XCOMM $TOG: Imakefile /main/13 1998/03/24 13:27:03 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/vfb/Imakefile,v 3.21 2000/01/05 02:03:10 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/vfb/Imakefile,v 3.24 2000/12/11 20:29:43 dawes Exp $
 #include <Server.tmpl>
 
 #if HasShm
@@ -16,13 +16,18 @@
 OBJS1 = os2_stubs.o
 #endif
 
-SRCSA =	InitInput.c InitOutput.c stubs.c $(SRCS1) miinitext.c
+#ifdef cygwinArchitecture
+SRCS2 = ntux_xf.c
+OBJS2 = ntux_xf.o
+#endif
+
+SRCSA =	InitInput.c InitOutput.c stubs.c $(SRCS1) miinitext.c $(SRCS2)
 
-OBJSA =	InitInput.o InitOutput.o stubs.o $(OBJS1) miinitext.o
+OBJSA =	InitInput.o InitOutput.o stubs.o $(OBJS1) miinitext.o $(OBJS2)
 
 INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-	   -I../../cfb -I../../mfb -I../../mi -I../../include -I../../os  \
-           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+	   -I../../fb -I../../mfb -I../../mi -I../../include -I../../os  \
+           -I$(EXTINCSRC) -I$(XINCLUDESRC)  -I$(SERVERSRC)/render
 
 DEFINES = ServerOSDefines $(SHMDEF) $(MMAPDEF) -UXFree86LOADER -UXF86DRI
 
@@ -54,5 +59,6 @@
 SpecialCObjectRule(dpmsstubs,$(ICONFIGFILES),$(EXT_DEFINES))
 #endif
 
+CppManTarget(Xvfb,)
 InstallManPage(Xvfb,$(MANDIR))
 DependTarget()
Index: xc/programs/Xserver/hw/vfb/InitInput.c
diff -u xc/programs/Xserver/hw/vfb/InitInput.c:3.4 xc/programs/Xserver/hw/vfb/InitInput.c:3.5
--- xc/programs/Xserver/hw/vfb/InitInput.c:3.4	Sun Oct  4 05:38:50 1998
+++ xc/programs/Xserver/hw/vfb/InitInput.c	Thu Aug 10 13:40:31 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/Xserver/hw/vfb/InitInput.c,v 3.4 1998/10/04 09:38:50 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/vfb/InitInput.c,v 3.5 2000/08/10 17:40:31 dawes Exp $ */
 
 #include "X11/X.h"
 #define NEED_EVENTS
@@ -44,6 +44,30 @@
 int xf86bpp = 8;
 #endif
 
+#ifdef __CYGWIN__
+extern void init_mouse( );
+extern void init_keyboard( );
+extern void term_mouse( );
+extern void term_keyboard( );
+extern void get_WinMappings( char *pKeySyms, unsigned char *p_modMap );
+
+
+CARD32 lastEventTime = 0;
+
+int TimeSinceLastInputEvent()
+{
+    if (lastEventTime == 0)
+        lastEventTime = GetTimeInMillis();
+    return GetTimeInMillis() - lastEventTime;
+}
+
+void SetTimeSinceLastInputEvent()
+{
+  lastEventTime = GetTimeInMillis();
+}
+#endif
+
+ 
 Bool
 LegalModifier(key, pDev)
     unsigned int key;
@@ -259,6 +283,74 @@
     return TRUE;
 #undef INDEX
 }
+
+#ifdef __CYGWIN__
+static int
+winKeybdProc(pDevice, onoff)
+    DeviceIntPtr pDevice;
+    int onoff;
+{
+    KeySymsRec		keySyms;
+    CARD8 		modMap[MAP_LENGTH];
+    int i;
+    DevicePtr pDev = (DevicePtr)pDevice;
+
+    switch (onoff)
+    {
+    case DEVICE_INIT: 
+	get_WinMappings(&keySyms, modMap);
+	InitKeyboardDeviceStruct(pDev, &keySyms, modMap,
+			(BellProcPtr)NoopDDA, (KbdCtrlProcPtr)NoopDDA);
+	init_keyboard();
+	break;
+    case DEVICE_ON: 
+	pDev->on = TRUE;
+	break;
+    case DEVICE_OFF: 
+	pDev->on = FALSE;
+	break;
+    case DEVICE_CLOSE:
+	term_keyboard();
+	break;
+    }
+    return Success;
+}
+
+static int
+winMouseProc(pDevice, onoff)
+    DeviceIntPtr pDevice;
+    int onoff;
+{
+    BYTE map[4];
+    DevicePtr pDev = (DevicePtr)pDevice;
+
+    switch (onoff)
+    {
+    case DEVICE_INIT:
+	    map[1] = 1;
+	    map[2] = 2;
+	    map[3] = 3;
+	    InitPointerDeviceStruct(pDev, map, 3, miPointerGetMotionEvents,
+		(PtrCtrlProcPtr)NoopDDA, miPointerGetMotionBufferSize());
+		init_mouse();
+	    break;
+
+    case DEVICE_ON:
+	pDev->on = TRUE;
+        break;
+
+    case DEVICE_OFF:
+	pDev->on = FALSE;
+	break;
+
+    case DEVICE_CLOSE:
+	term_mouse();
+ 	break;
+    }
+    return Success;
+}
+#endif /* __CYGWIN__ */
+
 
 static int
 vfbKeybdProc(pDevice, onoff)
Index: xc/programs/Xserver/hw/vfb/InitOutput.c
diff -u xc/programs/Xserver/hw/vfb/InitOutput.c:3.11 xc/programs/Xserver/hw/vfb/InitOutput.c:3.14
--- xc/programs/Xserver/hw/vfb/InitOutput.c:3.11	Fri May 14 10:11:09 1999
+++ xc/programs/Xserver/hw/vfb/InitOutput.c	Thu Nov 16 14:44:52 2000
@@ -22,9 +22,9 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/Xserver/hw/vfb/InitOutput.c,v 3.11 1999/05/14 14:11:09 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/vfb/InitOutput.c,v 3.14 2000/11/16 19:44:52 eich Exp $ */
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__)
 #include <X11/Xwinsock.h>
 #endif
 #include <stdio.h>
@@ -35,7 +35,7 @@
 #include "scrnintstr.h"
 #include "servermd.h"
 #define PSZ 8
-#include "cfb.h"
+#include "fb.h"
 #include "mibstore.h"
 #include "colormapst.h"
 #include "gcstruct.h"
@@ -55,12 +55,29 @@
 #endif
 #include <X11/XWDFile.h>
 #ifdef HAS_SHM
+#ifndef __CYGWIN__
 #include <sys/ipc.h>
+#else
+#include <sys/cygipc.h>
+#endif
 #include <sys/shm.h>
 #endif /* HAS_SHM */
 #include "dix.h"
 #include "miline.h"
 
+#ifdef __CYGWIN__
+/*
+ * NT UX defines/includes
+ */
+#include <sys/mman.h>
+
+#define HAS_MMAP 1
+
+extern char *get_surf( unsigned long size );
+extern char *get_framebuf( unsigned long size );
+extern int     enable_ntux_xf( );
+#endif /* __CYGWIN__ */
+
 extern char *display;
 
 #define VFB_DEFAULT_WIDTH  1280
@@ -107,6 +124,10 @@
 static char needswap = 0;
 static int lastScreen = -1;
 
+#ifdef __CYGWIN__
+static int b_video_memory = 0;
+#endif
+
 #define swapcopy16(_dst, _src) \
     if (needswap) { CARD16 _s = _src; cpswaps(_s, _dst); } \
     else _dst = _src;
@@ -193,6 +214,9 @@
     case NORMAL_MEMORY_FB:
 	for (i = 0; i < vfbNumScreens; i++)
 	{
+#ifdef __CYGWIN__
+          if (!b_video_memory)
+#endif
 	    Xfree(vfbScreens[i].pXWDHeader);
 	}
 	break;
@@ -391,9 +415,9 @@
     switch (vfbBitsPerPixel(pGC->depth))
     {
     case 1:  return mfbCreateGC (pGC);
-    case 8:  return cfbCreateGC (pGC);
-    case 16: return cfb16CreateGC (pGC);
-    case 32: return cfb32CreateGC (pGC);
+    case 8:  
+    case 16: 
+    case 32: return fbCreateGC (pGC);
     default: return FALSE;
     }
 }
@@ -412,13 +436,9 @@
 	mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 	break;
     case 8:
-	cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
-	break;
     case 16:
-	cfb16GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
-	break;
     case 32:
-	cfb32GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+	fbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 	break;
     }
     return;
@@ -438,13 +458,9 @@
 	mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
 	break;
     case 8:
-	cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
-	break;
     case 16:
-	cfb16GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
-	break;
     case 32:
-	cfb32GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+	fbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
 	break;
     }
 }
@@ -651,7 +667,7 @@
 				    PROT_READ|PROT_WRITE,
 				    MAP_FILE|MAP_SHARED,
 				    pvfb->mmap_fd, 0);
-    if (-1 == (int)pvfb->pXWDHeader)
+    if (-1 == (long)pvfb->pXWDHeader)
     {
 	perror("mmap");
 	ErrorF("mmap %s failed, errno %d", pvfb->mmap_file, errno);
@@ -686,7 +702,7 @@
     /* try to attach it */
 
     pvfb->pXWDHeader = (XWDFileHeader *)shmat(pvfb->shmid, 0, 0);
-    if (-1 == (int)pvfb->pXWDHeader)
+    if (-1 == (long)pvfb->pXWDHeader)
     {
 	perror("shmat");
 	ErrorF("shmat failed, errno %d", errno);
@@ -752,7 +768,17 @@
     {
 	pvfb->pXWDCmap = (XWDColor *)((char *)pvfb->pXWDHeader
 				+ SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN);
+#ifndef __CYGWIN__
 	pvfb->pfbMemory = (char *)(pvfb->pXWDCmap + pvfb->ncolors);
+#else
+	pvfb->pfbMemory =
+		(char *)get_framebuf((unsigned long)
+			pvfb->paddedWidth * pvfb->height);
+	if (pvfb->pfbMemory)
+	    b_video_memory = 1;
+	else
+	    pvfb->pfbMemory = (char *)(pvfb->pXWDCmap + pvfb->ncolors);
+#endif
 	return pvfb->pfbMemory;
     }
     else
@@ -869,6 +895,8 @@
     pbits = vfbAllocateFramebufferMemory(pvfb);
     if (!pbits) return FALSE;
 
+    /*    miSetPixmapDepths ();*/
+
     switch (pvfb->bitsPerPixel)
     {
     case 1:
@@ -876,16 +904,14 @@
 			    dpix, dpiy, pvfb->paddedWidth * 8);
 	break;
     case 8:
-	ret = cfbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
-			    dpix, dpiy, pvfb->paddedWidth);
-	break;
     case 16:
-	ret = cfb16ScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
-			      dpix, dpiy, pvfb->paddedWidth);
-	break;
     case 32:
-	ret = cfb32ScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
-			      dpix, dpiy, pvfb->paddedWidth);
+	ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+			      dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel);
+#ifdef RENDER
+	if (ret) 
+	    fbPictureInit (pScreen, 0, 0);
+#endif
 	break;
     default:
 	return FALSE;
@@ -923,7 +949,7 @@
     }
     else
     {
-	ret = cfbCreateDefColormap(pScreen);
+	ret = fbCreateDefColormap(pScreen);
     }
 
     miSetZeroLineBias(pScreen, pvfb->lineBias);
@@ -942,6 +968,11 @@
     int i;
     int NumFormats = 0;
     FILE *pf = stderr;
+
+
+#ifdef __CYGWIN__
+    enable_ntux_xf();
+#endif
 
     /* initialize pixmap formats */
 
Index: xc/programs/Xserver/hw/vfb/Xvfb.cpp
diff -u /dev/null xc/programs/Xserver/hw/vfb/Xvfb.cpp:1.2
--- /dev/null	Mon Dec 18 14:29:10 2000
+++ xc/programs/Xserver/hw/vfb/Xvfb.cpp	Tue Dec 12 13:06:51 2000
@@ -0,0 +1,127 @@
+.\" $TOG: Xvfb.man /main/12 1998/02/10 13:24:06 kaleb $
+.\" Copyright 1993, 1998  The Open Group
+.\" 
+.\" All Rights Reserved.
+.\" 
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\" 
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\" 
+.\" Except as contained in this notice, the name of The Open Group shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from The Open Group.
+.\"
+.\" $XFree86: xc/programs/Xserver/hw/vfb/Xvfb.cpp,v 1.2 2000/12/12 18:06:51 dawes Exp $
+.\"
+.TH XVFB 1 "Release 6.4" "X Version 11"
+.SH NAME
+Xvfb \- virtual framebuffer X server for X Version 11
+.SH SYNOPSIS
+.B Xvfb
+[ option ] ...
+.SH DESCRIPTION
+.I Xvfb
+is an X server that can run on machines with no display hardware
+and no physical input devices.  It emulates a dumb framebuffer using
+virtual memory.
+.PP
+The primary use of this server was intended to be server testing.  The
+mfb or cfb code for any depth can be exercised with this server
+without the need for real hardware that supports the desired depths.
+The X community has found many other novel uses for \fIXvfb\fP,
+including testing clients against unusual depths and screen
+configurations, doing batch processing with \fIXvfb\fP as a background
+rendering engine, load testing, as an aid to porting the X server to a
+new platform, and providing an unobtrusive way to run applications
+that don't really need an X server but insist on having one anyway.
+.SH BUILDING
+To build \fIXvfb\fP, put the following in your host.def and remake.
+.PP
+#define BuildServer YES /* if you aren't already building other servers */
+.br
+#define XVirtualFramebufferServer YES
+
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXvfb\fP accepts the following command line switches:
+.TP 4
+.B "\-screen \fIscreennum\fP \fIWxHxD\fP"
+This option creates screen \fIscreennum\fP and sets its width, height,
+and depth to W, H, and D respectively.  By default, only screen 0 exists
+and has the dimensions 1280x1024x8.
+.TP 4
+.B "\-pixdepths \fIlist-of-depths\fP"
+This option specifies a list of pixmap depths that the server should
+support in addition to the depths implied by the supported screens.
+\fIlist-of-depths\fP is a space-separated list of integers that can
+have values from 1 to 32.
+.TP 4
+.B "\-fbdir \fIframebuffer-directory\fP"
+This option specifies the directory in which the memory mapped files
+containing the framebuffer memory should be created.
+See FILES. 
+This option only exists on machines that have the mmap and msync system
+calls.
+.TP 4
+.B "\-shmem"
+This option specifies that the framebuffer should be put in shared memory.
+The shared memory ID for each screen will be printed by the server.
+The shared memory is in xwd format.
+This option only exists on machines that support the System V shared memory
+interface.
+.PP
+If neither \fB\-shmem\fP nor \fB\-fbdir\fP is specified,
+the framebuffer memory will be allocated with malloc().
+.TP 4
+.B "\-linebias \fIn\fP"
+This option specifies how to adjust the pixelization of thin lines.
+The value \fIn\fP is a bitmask of octants in which to prefer an axial
+step when the Bresenham error term is exactly zero.  See the file
+Xserver/mi/miline.h for more information.  This option is probably only useful
+to server developers to experiment with the range of line pixelization
+possible with the cfb and mfb code.
+.TP 4
+.B "\-blackpixel \fIpixel-value\fP, \-whitepixel \fIpixel-value\fP"
+These options specify the black and white pixel values the server should use.
+.SH FILES
+The following files are created if the \-fbdir option is given.
+.TP 4
+\fIframebuffer-directory\fP/Xvfb_screen<n>
+Memory mapped file containing screen n's framebuffer memory, one file
+per screen.  The file is in xwd format.  Thus, taking a full-screen
+snapshot can be done with a file copy command, and the resulting
+snapshot will even contain the cursor image.
+.SH EXAMPLES
+.TP 8
+Xvfb :1 -screen 0 1600x1200x32
+The server will listen for connections as server number 1, and screen 0
+will be depth 32 1600x1200.
+.TP 8
+Xvfb :1 -screen 1 1600x1200x16
+The server will listen for connections as server number 1, will have the
+default screen configuration (one screen, 1280x1024x8), and screen 1
+will be depth 16 1600x1200.
+.TP 8
+Xvfb -pixdepths 3 27 -fbdir /usr/tmp
+The server will listen for connections as server number 0, will have the
+default screen configuration (one screen, 1280x1024x8),
+will also support pixmap
+depths of 3 and 27, 
+and will use memory mapped files in /usr/tmp for the framebuffer.
+.TP 8
+xwud -in /usr/tmp/Xvfb_screen0
+Displays screen 0 of the server started by the preceding example.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), Xserver(1), xwd(1), xwud(1), XWDFile.h
+.SH AUTHORS
+David P. Wiggins, The Open Group, Inc.
Index: xc/programs/Xserver/hw/vfb/Xvfb.man
diff -u xc/programs/Xserver/hw/vfb/Xvfb.man:1.4 xc/programs/Xserver/hw/vfb/Xvfb.man:removed
--- xc/programs/Xserver/hw/vfb/Xvfb.man:1.4	Sun Oct  4 05:38:51 1998
+++ xc/programs/Xserver/hw/vfb/Xvfb.man	Mon Dec 18 14:29:10 2000
@@ -1,124 +0,0 @@
-.\" $TOG: Xvfb.man /main/12 1998/02/10 13:24:06 kaleb $
-.\" Copyright 1993, 1998  The Open Group
-.\" 
-.\" All Rights Reserved.
-.\" 
-.\" The above copyright notice and this permission notice shall be included
-.\" in all copies or substantial portions of the Software.
-.\" 
-.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-.\" OTHER DEALINGS IN THE SOFTWARE.
-.\" 
-.\" Except as contained in this notice, the name of The Open Group shall
-.\" not be used in advertising or otherwise to promote the sale, use or
-.\" other dealings in this Software without prior written authorization
-.\" from The Open Group.
-.TH XVFB 1 "Release 6.4" "X Version 11"
-.SH NAME
-Xvfb \- virtual framebuffer X server for X Version 11
-.SH SYNOPSIS
-.B Xvfb
-[ option ] ...
-.SH DESCRIPTION
-.I Xvfb
-is an X server that can run on machines with no display hardware
-and no physical input devices.  It emulates a dumb framebuffer using
-virtual memory.
-.PP
-The primary use of this server was intended to be server testing.  The
-mfb or cfb code for any depth can be exercised with this server
-without the need for real hardware that supports the desired depths.
-The X community has found many other novel uses for \fIXvfb\fP,
-including testing clients against unusual depths and screen
-configurations, doing batch processing with \fIXvfb\fP as a background
-rendering engine, load testing, as an aid to porting the X server to a
-new platform, and providing an unobtrusive way to run applications
-that don't really need an X server but insist on having one anyway.
-.SH BUILDING
-To build \fIXvfb\fP, put the following in your host.def and remake.
-.PP
-#define BuildServer YES /* if you aren't already building other servers */
-.br
-#define XVirtualFramebufferServer YES
-
-.SH OPTIONS
-.PP
-In addition to the normal server options described in the \fIXserver(1)\fP
-manual page, \fIXvfb\fP accepts the following command line switches:
-.TP 4
-.B "\-screen \fIscreennum\fP \fIWxHxD\fP"
-This option creates screen \fIscreennum\fP and sets its width, height,
-and depth to W, H, and D respectively.  By default, only screen 0 exists
-and has the dimensions 1280x1024x8.
-.TP 4
-.B "\-pixdepths \fIlist-of-depths\fP"
-This option specifies a list of pixmap depths that the server should
-support in addition to the depths implied by the supported screens.
-\fIlist-of-depths\fP is a space-separated list of integers that can
-have values from 1 to 32.
-.TP 4
-.B "\-fbdir \fIframebuffer-directory\fP"
-This option specifies the directory in which the memory mapped files
-containing the framebuffer memory should be created.
-See FILES. 
-This option only exists on machines that have the mmap and msync system
-calls.
-.TP 4
-.B "\-shmem"
-This option specifies that the framebuffer should be put in shared memory.
-The shared memory ID for each screen will be printed by the server.
-The shared memory is in xwd format.
-This option only exists on machines that support the System V shared memory
-interface.
-.PP
-If neither \fB\-shmem\fP nor \fB\-fbdir\fP is specified,
-the framebuffer memory will be allocated with malloc().
-.TP 4
-.B "\-linebias \fIn\fP"
-This option specifies how to adjust the pixelization of thin lines.
-The value \fIn\fP is a bitmask of octants in which to prefer an axial
-step when the Bresenham error term is exactly zero.  See the file
-Xserver/mi/miline.h for more information.  This option is probably only useful
-to server developers to experiment with the range of line pixelization
-possible with the cfb and mfb code.
-.TP 4
-.B "\-blackpixel \fIpixel-value\fP, \-whitepixel \fIpixel-value\fP"
-These options specify the black and white pixel values the server should use.
-.SH FILES
-The following files are created if the \-fbdir option is given.
-.TP 4
-\fIframebuffer-directory\fP/Xvfb_screen<n>
-Memory mapped file containing screen n's framebuffer memory, one file
-per screen.  The file is in xwd format.  Thus, taking a full-screen
-snapshot can be done with a file copy command, and the resulting
-snapshot will even contain the cursor image.
-.SH EXAMPLES
-.TP 8
-Xvfb :1 -screen 0 1600x1200x32
-The server will listen for connections as server number 1, and screen 0
-will be depth 32 1600x1200.
-.TP 8
-Xvfb :1 -screen 1 1600x1200x16
-The server will listen for connections as server number 1, will have the
-default screen configuration (one screen, 1280x1024x8), and screen 1
-will be depth 16 1600x1200.
-.TP 8
-Xvfb -pixdepths 3 27 -fbdir /usr/tmp
-The server will listen for connections as server number 0, will have the
-default screen configuration (one screen, 1280x1024x8),
-will also support pixmap
-depths of 3 and 27, 
-and will use memory mapped files in /usr/tmp for the framebuffer.
-.TP 8
-xwud -in /usr/tmp/Xvfb_screen0
-Displays screen 0 of the server started by the preceding example.
-.SH "SEE ALSO"
-.PP
-X(1), Xserver(1), xwd(1), xwud(1), XWDFile.h
-.SH AUTHORS
-David P. Wiggins, The Open Group, Inc.
Index: xc/programs/Xserver/hw/vfb/ntux_xf.c
diff -u /dev/null xc/programs/Xserver/hw/vfb/ntux_xf.c:3.1
--- /dev/null	Mon Dec 18 14:29:10 2000
+++ xc/programs/Xserver/hw/vfb/ntux_xf.c	Thu Aug 10 13:40:31 2000
@@ -0,0 +1,133 @@
+/*
+* Copyright 2000 (C) Peter Busch
+* All rights reserved.
+NO WARRANTY; NO LIABILITY FOR DAMAGES:  THE MATERIALS ARE PROVIDED "AS IS" 
+WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES
+OF SATISFACTORY QUALITY, MERCHANTABILITY, NONINFRINGEMENT OF THIRD-PARTY
+INTELLECTUAL PROPERTY, OR FITNESS FOR ANY PARTICULAR PURPOSE.
+IN NO EVENT  SHALL Peter Busch BE LIABLE FOR ANY DAMAGES WHATSOEVER
+(INCLUDING, WITHOUT  LIMITATION, DIRECT OR INDIRECT DAMAGES, DAMAGES FOR
+LOSS OF PROFITS, BUSINESS  INTERRUPTION, LOSS OF INFORMATION) ARISING OUT
+OF THE USE OF OR INABILITY TO  USE THE MATERIALS, EVEN IF
+Peter Busch HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH  DAMAGES.
+Without limiting the generality of the foregoing, no warranty is made
+that the enclosed software will generate computer programs with the
+characteristics or specifications desired by you or that the demo
+software will be error-free.
+THESE DISCLAIMERS OF WARRANTY CONSTITUTE AN ESSENTIAL PART OF THIS
+AGREEMENT. 
+*/
+/* $XFree86: xc/programs/Xserver/hw/vfb/ntux_xf.c,v 3.1 2000/08/10 17:40:31 dawes Exp $ */
+
+/*
+* ntux_xf.c
+* support code for the output enabled X vfb server
+* contains the interface between the vfb source files and the ntux_ddx library
+* Copyright (C) Peter Busch
+* All rights reserved.
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+* This code is BETA and will be part of the CYGWIN/XFREE Project.
+* It may not be used for purposes other than to contribute to the 
+* CYGWIN/XFree project without prior written notice from the
+* author.
+* Any commercial use of this code will be permitted
+* provided you contact Peter Busch at pbusch@dfki.de
+*/
+
+
+
+#include <windows.h>
+#include <stdio.h>
+#include "keysym.h"
+
+
+typedef char *	(* _get_surface)( unsigned long size );
+typedef int		(* _init_input)( void );
+typedef void	(* _init_mouse)( );
+typedef void	(* _init_keyboard)( );
+typedef void	(* _term_mouse)( );
+typedef void	(* _term_keyboard)( );
+typedef void	(* _get_WinMap)( char *pKeySyms, unsigned char *p_modMap );
+
+
+HINSTANCE h_ntux_ddx = NULL;
+
+_get_surface	ntux_surface = NULL;
+_init_input		init_input = NULL;
+_init_mouse		ntux_init_mouse = NULL;
+_init_keyboard	ntux_init_keyboard = NULL;
+_term_mouse		ntux_term_mouse = NULL;
+_term_keyboard	ntux_term_keyboard = NULL;
+_get_WinMap		ntux_getWinMap = NULL;
+
+int	enable_ntux_xf( )
+{
+	h_ntux_ddx = LoadLibrary( "ntux_ddx.dll" );
+	if( h_ntux_ddx == NULL )
+		return 0;
+
+	ntux_surface = (_get_surface)GetProcAddress( h_ntux_ddx, "get_surface" );
+	init_input = (_init_input)GetProcAddress( h_ntux_ddx, "init_input" );
+	ntux_init_mouse = (_init_mouse)GetProcAddress( h_ntux_ddx, "init_mouse" );
+	ntux_init_keyboard = (_init_keyboard)GetProcAddress( h_ntux_ddx, "init_keyboard" );
+	ntux_term_mouse = (_term_mouse)GetProcAddress( h_ntux_ddx, "term_mouse" );
+	ntux_term_keyboard = (_term_keyboard)GetProcAddress( h_ntux_ddx, "term_keyboard" );
+	ntux_getWinMap = (_get_WinMap)GetProcAddress( h_ntux_ddx, "get_WinMap" );
+
+	OutputDebugString( "\nntux_ddx successfully loaded\n\n" );
+	return 1;
+}
+
+
+char *get_framebuf( unsigned long size )
+{
+	char	msg[256];
+	if( ntux_surface != NULL )
+	{
+		fprintf( stderr, "get_framebuf : calling %08x with size = %08x\n",
+					ntux_surface, size
+					);
+		return ntux_surface( size );
+	}
+	return NULL;
+}
+
+
+void init_mouse( )
+{
+	if( ntux_init_mouse != NULL )
+		return ntux_init_mouse();
+	return ;
+}
+
+void init_keyboard( )
+{
+	if( ntux_init_keyboard != NULL )
+		return ntux_init_keyboard();
+	return ;
+}
+
+void term_mouse( )
+{
+	if( ntux_term_mouse != NULL )
+		return ntux_term_mouse();
+	return ;
+}
+
+void term_keyboard( )
+{
+	if( ntux_term_keyboard != NULL )
+		return ntux_term_keyboard();
+	return ;
+}
+
+void get_WinMappings( char *pKeySyms, unsigned char *p_modMap )
+{
+	if( ntux_getWinMap != NULL )
+		return ntux_getWinMap( pKeySyms, p_modMap );
+	return ;
+}
+
+
+
Index: xc/programs/Xserver/hw/xnest/Display.h
diff -u xc/programs/Xserver/hw/xnest/Display.h:1.4 xc/programs/Xserver/hw/xnest/Display.h:1.5
--- xc/programs/Xserver/hw/xnest/Display.h:1.4	Fri Jun 16 20:27:33 2000
+++ xc/programs/Xserver/hw/xnest/Display.h	Tue Aug  1 16:05:43 2000
@@ -12,7 +12,7 @@
 is" without express or implied warranty.
 
 */
-/* $XFree86: xc/programs/Xserver/hw/xnest/Display.h,v 1.4 2000/06/17 00:27:33 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xnest/Display.h,v 1.5 2000/08/01 20:05:43 dawes Exp $ */
 
 #ifndef XNESTCOMMON_H
 #define XNESTCOMMON_H
@@ -20,7 +20,7 @@
 #define UNDEFINED -1
 
 #define MAXDEPTH 32
-#define MAXVISUALSPERDEPTH 64
+#define MAXVISUALSPERDEPTH 256
 
 extern Display *xnestDisplay;
 extern XVisualInfo *xnestVisuals;       
Index: xc/programs/Xserver/hw/xnest/Init.c
diff -u xc/programs/Xserver/hw/xnest/Init.c:3.18 xc/programs/Xserver/hw/xnest/Init.c:3.19
--- xc/programs/Xserver/hw/xnest/Init.c:3.18	Fri May 14 10:11:22 1999
+++ xc/programs/Xserver/hw/xnest/Init.c	Mon Nov 27 12:45:56 2000
@@ -12,7 +12,7 @@
 is" without express or implied warranty.
 
 */
-/* $XFree86: xc/programs/Xserver/hw/xnest/Init.c,v 3.18 1999/05/14 14:11:22 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xnest/Init.c,v 3.19 2000/11/27 17:45:56 dawes Exp $ */
 
 #include "X.h"
 #include "Xproto.h"
@@ -73,6 +73,7 @@
 	screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad = 
 	  xnestPixmapFormats[i].scanline_pad;
 	screenInfo->numPixmapFormats++;
+	break;
       }
   
   xnestWindowPrivateIndex = AllocateWindowPrivateIndex();
Index: xc/programs/Xserver/hw/xwin/Imakefile
diff -u /dev/null xc/programs/Xserver/hw/xwin/Imakefile:1.3
--- /dev/null	Mon Dec 18 14:33:00 2000
+++ xc/programs/Xserver/hw/xwin/Imakefile	Tue Nov 28 11:10:40 2000
@@ -0,0 +1,62 @@
+XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
+XCOMM $XFree86: xc/programs/Xserver/hw/xwin/Imakefile,v 1.3 2000/11/28 16:10:40 dawes Exp $
+#include <Server.tmpl>
+
+#if HasShm
+SHMDEF = -DHAS_SHM
+#endif
+
+XCOMM add more architectures here as we discover them
+#if defined(HPArchitecture) || (defined(SparcArchitecture) && !defined(LynxOSArchitecture)) || SystemV4 || defined(OSF1Architecture) || defined(cygwinArchitecture) || defined(i386BsdArchitecture)
+MMAPDEF = -DHAS_MMAP
+#endif
+
+#ifdef OS2Architecture
+SRCS1 = os2_stubs.c
+OBJS1 = os2_stubs.o
+#endif
+
+
+
+SRCSA =	InitInput.c InitOutput.c stubs.c miinitext.c directx.c
+
+OBJSA =	InitInput.o InitOutput.o stubs.o miinitext.o directx.o
+
+INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) -I$(SERVERSRC)/render \
+	   -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+	   -I$(SERVERSRC)/include -I$(SERVERSRC)/os  \
+           -I$(EXTINCSRC) -I$(XINCLUDESRC)
+
+DEFINES = ServerOSDefines $(SHMDEF) $(MMAPDEF) -UXFree86LOADER -UXF86DRI
+
+#if BuildDPMS
+SRCSC =	dpmsstubs.c
+OBJSC =	dpmsstubs.o
+#endif
+
+SRCS =	$(SRCSA) $(SRCSB) $(SRCSC)
+OBJS =	$(OBJSA) $(OBJSB) $(OBJSC)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(Xwin,$(OBJS))
+
+#ifdef OS2Architecture
+LinkSourceFile(os2_stubs.c,../xfree86/os-support/os2)
+SpecialCObjectRule(os2_stubs,$(ICONFIGFILES),-DOS2NULLSELECT)
+#endif
+
+LinkSourceFile(stubs.c,../../Xi)
+SpecialCObjectRule(InitInput,$(ICONFIGFILES),$(EXT_DEFINES))
+
+LinkSourceFile(miinitext.c,../../mi)
+SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(EXT_DEFINES) $(PAN_DEFINES) -DNO_HW_ONLY_EXTS -DNO_MODULE_EXTS $(EXT_MODULE_DEFINES) -UXFree86LOADER)
+
+#if BuildDPMS
+LinkSourceFile(dpmsstubs.c,$(SERVERSRC)/Xext)
+SpecialCObjectRule(dpmsstubs,$(ICONFIGFILES),$(EXT_DEFINES))
+#endif
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(Xwin,$(OBJS))
+
+DependTarget()
Index: xc/programs/Xserver/hw/xwin/InitInput.c
diff -u /dev/null xc/programs/Xserver/hw/xwin/InitInput.c:1.1
--- /dev/null	Mon Dec 18 14:33:00 2000
+++ xc/programs/Xserver/hw/xwin/InitInput.c	Thu Aug 10 13:40:37 2000
@@ -0,0 +1,283 @@
+/* $TOG: InitInput.c /main/12 1998/02/10 13:23:52 kaleb $ */
+/*
+
+Copyright 1993, 1998  The Open Group
+
+All Rights Reserved.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xwin/InitInput.c,v 1.1 2000/08/10 17:40:37 dawes Exp $ */
+
+
+
+#include "X11/X.h"
+#define NEED_EVENTS
+#include "X11/Xproto.h"
+#include "scrnintstr.h"
+#include "inputstr.h"
+#include "X11/Xos.h"
+#include "mibstore.h"
+#include "mipointer.h"
+#include "winkeynames.h"
+#include "winkeymap.h"
+#include "keysym.h"
+
+
+
+
+CARD32 lastEventTime = 0;
+
+int TimeSinceLastInputEvent()
+{
+    if (lastEventTime == 0)
+        lastEventTime = GetTimeInMillis();
+    return GetTimeInMillis() - lastEventTime;
+}
+
+void SetTimeSinceLastInputEvent()
+{
+  lastEventTime = GetTimeInMillis();
+}
+
+Bool
+LegalModifier(key, pDev)
+    unsigned int key;
+    DevicePtr	pDev;
+{
+    return TRUE;
+}
+
+void
+ProcessInputEvents()
+{
+    mieqProcessInputEvents();
+	miPointerUpdate();
+}
+
+#define WIN_MIN_KEY 8
+#define WIN_MAX_KEY 255
+
+void
+GetWinMappings (pKeySyms, pModMap)
+     KeySymsPtr pKeySyms;
+     CARD8      *pModMap;
+{
+	KeySym        *k;
+	char          type;
+	int           i, j;
+	KeySym        *pMap;
+
+	pMap = map;
+
+	for (i = 0; i < MAP_LENGTH; i++)
+		pModMap[i] = NoSymbol;  /* make sure it is restored */
+
+	for (k = pMap, i = MIN_KEYCODE; i < (NUM_KEYCODES + MIN_KEYCODE); i++, k += 4)
+		switch(*k) {
+			case XK_Shift_L:
+			case XK_Shift_R:
+			pModMap[i] = ShiftMask;
+			break;
+
+			case XK_Control_L:
+			case XK_Control_R:
+			pModMap[i] = ControlMask;
+			break;
+
+			case XK_Caps_Lock:
+			pModMap[i] = LockMask;
+			break;
+
+			case XK_Alt_L:
+			case XK_Alt_R:
+			pModMap[i] = AltMask;
+			break;
+
+			case XK_Num_Lock:
+			pModMap[i] = NumLockMask;
+			break;
+
+			case XK_Scroll_Lock:
+			pModMap[i] = ScrollLockMask;
+			break;
+
+			/* kana support */
+			case XK_Kana_Lock:
+			case XK_Kana_Shift:
+			pModMap[i] = KanaMask;
+			break;
+
+			/* alternate toggle for multinational support */
+			case XK_Mode_switch:
+			pModMap[i] = AltLangMask;
+			break;
+
+		}
+	pKeySyms->map        = pMap;
+	pKeySyms->mapWidth   = GLYPHS_PER_KEY;
+	pKeySyms->minKeyCode = MIN_KEYCODE;
+	pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
+}
+
+static int
+winKeybdProc(pDevice, onoff)
+    DeviceIntPtr pDevice;
+    int onoff;
+{
+    KeySymsRec		keySyms;
+    CARD8 		modMap[MAP_LENGTH];
+    int i;
+    DevicePtr pDev = (DevicePtr)pDevice;
+
+    switch (onoff)
+    {
+    case DEVICE_INIT: 
+	GetWinMappings(&keySyms, modMap);
+	InitKeyboardDeviceStruct(pDev, &keySyms, modMap,
+			(BellProcPtr)NoopDDA, (KbdCtrlProcPtr)NoopDDA);
+	DIInitKeyboard () ;
+	break;
+    case DEVICE_ON: 
+	pDev->on = TRUE;
+	break;
+    case DEVICE_OFF: 
+	pDev->on = FALSE;
+	break;
+    case DEVICE_CLOSE:
+	DITermKeyboard () ;
+	break;
+    }
+    return Success;
+}
+
+static int
+winMouseProc(pDevice, onoff)
+    DeviceIntPtr pDevice;
+    int onoff;
+{
+    BYTE map[4];
+    DevicePtr pDev = (DevicePtr)pDevice;
+
+    switch (onoff)
+    {
+    case DEVICE_INIT:
+	    map[1] = 1;
+	    map[2] = 2;
+	    map[3] = 3;
+	    InitPointerDeviceStruct(pDev, map, 3, miPointerGetMotionEvents,
+		(PtrCtrlProcPtr)NoopDDA, miPointerGetMotionBufferSize());
+		DIInitMouse () ;
+	    break;
+
+    case DEVICE_ON:
+	pDev->on = TRUE;
+        break;
+
+    case DEVICE_OFF:
+	pDev->on = FALSE;
+	break;
+
+    case DEVICE_CLOSE:
+	DITermMouse () ;
+ 	break;
+    }
+    return Success;
+}
+
+void
+InitInput(argc, argv)
+    int argc;
+    char *argv[];
+{
+    DevicePtr p, k;
+    p = AddInputDevice(winMouseProc, TRUE);
+    k = AddInputDevice(winKeybdProc, TRUE);
+    RegisterPointerDevice(p);
+    RegisterKeyboardDevice(k);
+    miRegisterPointerDevice(screenInfo.screens[0], p);
+    (void)mieqInit (k, p);
+}
+
+GenerateInputEvent (type, ix, iy, button)
+{
+	xEvent		x ;
+
+	/* Event types defined in directx.c */
+	switch (type)
+	{
+    case 0: /* Mouse motion */
+	  miPointerDeltaCursor (ix,iy,lastEventTime = GetTimeInMillis ());
+      break;
+
+    case 1: /* Mouse button pressed */
+      x.u.u.type = ButtonPress;
+      x.u.u.detail = Button1 + button ;
+      x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+      mieqEnqueue(&x);
+      break;
+      
+    case 2: /* Mouse button released */
+      x.u.u.type = ButtonRelease;
+      x.u.u.detail = button + 1 ;
+      x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+      mieqEnqueue(&x);
+      break;
+
+	case 3: /* Keyboard keypress */
+      x.u.u.type = KeyPress;
+      x.u.u.detail = button + MIN_KEYCODE ;
+      x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+      mieqEnqueue(&x);
+      break;
+      
+	case 4: /* Keyboard keyrelease */
+      x.u.u.type = KeyRelease;
+      x.u.u.detail = button + MIN_KEYCODE ;
+      x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
+      mieqEnqueue(&x);
+	  break ;
+	}
+}
+
+#ifdef XTESTEXT1
+void
+XTestGenerateEvent(dev_type, keycode, keystate, mousex, mousey)
+	int	dev_type;
+	int	keycode;
+	int	keystate;
+	int	mousex;
+	int	mousey;
+{
+}
+
+void
+XTestGetPointerPos(fmousex, fmousey)
+	short *fmousex, *fmousey;
+{
+}
+
+void
+XTestJumpPointer(jx, jy, dev_type)
+	int	jx;
+	int	jy;
+	int	dev_type;
+{
+}
+#endif
+
Index: xc/programs/Xserver/hw/xwin/InitOutput.c
diff -u /dev/null xc/programs/Xserver/hw/xwin/InitOutput.c:1.2
--- /dev/null	Mon Dec 18 14:33:00 2000
+++ xc/programs/Xserver/hw/xwin/InitOutput.c	Tue Nov 28 11:10:40 2000
@@ -0,0 +1,780 @@
+/* $TOG: InitOutput.c /main/20 1998/02/10 13:23:56 kaleb $ */
+/*
+
+Copyright 1993, 1998  The Open Group
+
+All Rights Reserved.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/programs/Xserver/hw/xwin/InitOutput.c,v 1.2 2000/11/28 16:10:40 dawes Exp $ */
+
+#if defined(WIN32) && !defined(__CYGWIN__)
+#include <X11/Xwinsock.h>
+#endif
+#include <stdio.h>
+#include "X11/X.h"
+#define NEED_EVENTS
+#include "X11/Xproto.h"
+#include "X11/Xos.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define PSZ 8
+#include "cfb.h"
+#include "mibstore.h"
+#include "colormapst.h"
+#include "gcstruct.h"
+#include "input.h"
+#include "mipointer.h"
+#include "picturestr.h"
+#include <sys/types.h>
+#ifdef HAS_MMAP
+#include <sys/mman.h>
+#ifndef MAP_FILE
+#define MAP_FILE 0
+#endif
+#endif /* HAS_MMAP */
+#include <sys/stat.h>
+#include <errno.h>
+#ifndef WIN32
+#include <sys/param.h>
+#endif
+#include <X11/XWDFile.h>
+#if defined(HAS_SHM) && !defined(__CYGWIN__)
+#include <sys/cygipc.h>
+#include <sys/shm.h>
+#endif /* HAS_SHM */
+#include "dix.h"
+#include "miline.h"
+
+extern char     *display;
+extern          void winfbBlockHandler ();
+extern          int winfbWakeupHandler ();
+
+#define WIN_DEFAULT_WIDTH  1280
+#define WIN_DEFAULT_HEIGHT 1024
+#define WIN_DEFAULT_DEPTH  16
+#define WIN_DEFAULT_WHITEPIXEL 255
+#define WIN_DEFAULT_BLACKPIXEL 0
+#define WIN_DEFAULT_LINEBIAS 0
+#define XWD_WINDOW_NAME_LEN 60
+
+typedef struct
+{
+  int scrnum;
+  int width;
+  int paddedWidth;
+  int height;
+  int depth;
+  int bitsPerPixel;
+  char *pfbMemory;
+  XWDColor *pXWDCmap;
+  XWDFileHeader *pXWDHeader;
+  Pixel blackPixel;
+  Pixel whitePixel;
+  ScreenPtr pScreen ;
+  unsigned int lineBias;
+
+} winScreenInfo, *winScreenInfoPtr;
+
+typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType;
+
+static int              winNumScreens;
+static winScreenInfo    winScreens[MAXSCREENS];
+static Bool             winPixmapDepths[33];
+static char             *pfbdir = NULL;
+static fbMemType        fbmemtype = NORMAL_MEMORY_FB;
+static char             needswap = 0;
+static int              lastScreen = -1;
+static ColormapPtr      InstalledMaps[MAXSCREENS];
+
+#define swapcopy16(_dst, _src) \
+    if (needswap) { CARD16 _s = _src; cpswaps(_s, _dst); } \
+    else _dst = _src;
+
+#define swapcopy32(_dst, _src) \
+    if (needswap) { CARD32 _s = _src; cpswapl(_s, _dst); } \
+    else _dst = _src;
+
+static void
+winInitializePixmapDepths()
+{
+  int i;
+  winPixmapDepths[1] = TRUE; /* always need bitmaps */
+  for (i = 2; i <= 32; i++)
+    winPixmapDepths[i] = FALSE;
+}
+
+static Bool
+winCreateDefColormap (ScreenPtr pScreen)
+{
+  int                   i;
+  Pixel                 wp, bp;
+  VisualPtr             pVisual;
+  ColormapPtr           cmap;
+  unsigned short        zero = 0, ones = 0xFFFF;
+
+  /*
+   * these are the MS-Windows desktop colors, adjusted for X's 16-bit
+   * color specifications.
+   */
+  static xColorItem citems[] = {
+    {   0,      0,      0,      0, 0, 0 },
+    {   1, 0x8000,      0,      0, 0, 0 },
+    {   2,      0, 0x8000,      0, 0, 0 },
+    {   3, 0x8000, 0x8000,      0, 0, 0 },
+    {   4,      0,      0, 0x8000, 0, 0 },
+    {   5, 0x8000,      0, 0x8000, 0, 0 },
+    {   6,      0, 0x8000, 0x8000, 0, 0 },
+    {   7, 0xc000, 0xc000, 0xc000, 0, 0 },
+    {   8, 0xc000, 0xdc00, 0xc000, 0, 0 },
+    {   9, 0xa600, 0xca00, 0xf000, 0, 0 },
+    { 246, 0xff00, 0xfb00, 0xf000, 0, 0 },
+    { 247, 0xa000, 0xa000, 0xa400, 0, 0 },
+    { 248, 0x8000, 0x8000, 0x8000, 0, 0 },
+    { 249, 0xff00,      0,      0, 0, 0 },
+    { 250,      0, 0xff00,      0, 0, 0 },
+    { 251, 0xff00, 0xff00,      0, 0, 0 },
+    { 252,      0,      0, 0xff00, 0, 0 },
+    { 253, 0xff00,      0, 0xff00, 0, 0 },
+    { 254,      0, 0xff00, 0xff00, 0, 0 },
+    { 255, 0xff00, 0xff00, 0xff00, 0, 0 }
+  };
+#define NUM_DESKTOP_COLORS sizeof citems / sizeof citems[0]
+
+  for (pVisual = pScreen->visuals;
+       pVisual->vid != pScreen->rootVisual;
+       pVisual++);
+
+  if (CreateColormap (pScreen->defColormap, pScreen, pVisual, &cmap,
+                      (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
+                      0)
+      != Success)
+    return FALSE;
+  if (pVisual->class == PseudoColor)
+    {
+      for (i = 0; i < NUM_DESKTOP_COLORS; i++)
+        {
+          if (AllocColor (cmap,
+                          &citems[i].red,
+                          &citems[i].green,
+                          &citems[i].blue,
+                          &citems[i].pixel,
+                          0) != Success)
+            return FALSE;
+        }
+      pScreen->whitePixel = 255;
+      pScreen->blackPixel = 0;
+    }
+  else
+    {
+      if ((AllocColor (cmap, &ones, &ones, &ones, &wp, 0)
+           != Success)
+          || (AllocColor (cmap, &zero, &zero, &zero, &bp, 0)
+              != Success))
+        return FALSE;
+      pScreen->whitePixel = wp;
+      pScreen->blackPixel = bp;
+    }
+  (*pScreen->InstallColormap)(cmap);
+  return TRUE;
+}
+
+static void
+winInitializeDefaultScreens()
+{
+  int                   i;
+
+  for (i = 0; i < MAXSCREENS; i++)
+    {
+      winScreens[i].scrnum = i;
+      winScreens[i].width  = WIN_DEFAULT_WIDTH;
+      winScreens[i].height = WIN_DEFAULT_HEIGHT;
+      winScreens[i].depth  = WIN_DEFAULT_DEPTH;
+      winScreens[i].blackPixel = WIN_DEFAULT_BLACKPIXEL;
+      winScreens[i].whitePixel = WIN_DEFAULT_WHITEPIXEL;
+      winScreens[i].lineBias = WIN_DEFAULT_LINEBIAS;
+      winScreens[i].pfbMemory = NULL;
+    }
+  winNumScreens = 1;
+}
+
+static int
+winBitsPerPixel (int depth)
+{
+  if (depth == 1) return 1;
+  else if (depth <= 8) return 8;
+  else if (depth <= 16) return 16;
+  else if (depth <= 24) return 24;
+  else return 32;
+}
+
+void
+ddxGiveUp()
+{
+  return;
+}
+
+void
+AbortDDX()
+{
+  ddxGiveUp();
+}
+
+void
+OsVendorInit()
+{
+}
+
+void
+ddxUseMsg()
+{
+  ErrorF("-screen scrn WxHxD     set screen's width, height, bit depth\n");
+  ErrorF("-pixdepths list-of-int support given pixmap depths\n");
+  ErrorF("-linebias n            adjust thin line pixelization\n");
+  ErrorF("-blackpixel n          pixel value for black\n");
+  ErrorF("-whitepixel n          pixel value for white\n");
+}
+
+int
+ddxProcessArgument (int argc, char *argv[], int i)
+{
+  static Bool firstTime = TRUE;
+
+  if (firstTime)
+    {
+      winInitializeDefaultScreens();
+      winInitializePixmapDepths();
+      firstTime = FALSE;
+    }
+
+  if (strcmp (argv[i], "-screen") == 0) /* -screen n WxHxD */
+    {
+      int screenNum;
+      if (i + 2 >= argc) UseMsg();
+      screenNum = atoi(argv[i+1]);
+      if (screenNum < 0 || screenNum >= MAXSCREENS)
+        {
+          ErrorF("Invalid screen number %d\n", screenNum);
+          UseMsg();
+        }
+      if (3 != sscanf(argv[i+2], "%dx%dx%d",
+                      &winScreens[screenNum].width,
+                      &winScreens[screenNum].height,
+                      &winScreens[screenNum].depth))
+        {
+          ErrorF("Invalid screen configuration %s\n", argv[i+2]);
+          UseMsg();
+        }
+
+      if (screenNum >= winNumScreens)
+        winNumScreens = screenNum + 1;
+      lastScreen = screenNum;
+      return 3;
+    }
+
+  if (strcmp (argv[i], "-pixdepths") == 0)      /* -pixdepths list-of-depth */
+    {
+      int depth, ret = 1;
+
+      if (++i >= argc) UseMsg();
+      while ((i < argc) && (depth = atoi(argv[i++])) != 0)
+        {
+          if (depth < 0 || depth > 32)
+            {
+              ErrorF("Invalid pixmap depth %d\n", depth);
+              UseMsg();
+            }
+          winPixmapDepths[depth] = TRUE;
+          ret++;
+        }
+      return ret;
+    }
+
+  if (strcmp (argv[i], "-blackpixel") == 0)     /* -blackpixel n */
+    {
+      Pixel pix;
+      if (++i >= argc) UseMsg();
+      pix = atoi(argv[i]);
+      if (-1 == lastScreen)
+        {
+          int i;
+          for (i = 0; i < MAXSCREENS; i++)
+            {
+              winScreens[i].blackPixel = pix;
+            }
+        }
+      else
+        {
+          winScreens[lastScreen].blackPixel = pix;
+        }
+      return 2;
+    }
+
+  if (strcmp (argv[i], "-whitepixel") == 0)     /* -whitepixel n */
+    {
+      Pixel pix;
+      if (++i >= argc) UseMsg();
+      pix = atoi(argv[i]);
+      if (-1 == lastScreen)
+        {
+          int i;
+          for (i = 0; i < MAXSCREENS; i++)
+            {
+              winScreens[i].whitePixel = pix;
+            }
+        }
+      else
+        {
+          winScreens[lastScreen].whitePixel = pix;
+        }
+      return 2;
+    }
+
+  if (strcmp (argv[i], "-linebias") == 0)       /* -linebias n */
+    {
+      unsigned int linebias;
+      if (++i >= argc) UseMsg();
+      linebias = atoi(argv[i]);
+      if (-1 == lastScreen)
+        {
+          int i;
+          for (i = 0; i < MAXSCREENS; i++)
+            {
+              winScreens[i].lineBias = linebias;
+            }
+        }
+      else
+        {
+          winScreens[lastScreen].lineBias = linebias;
+        }
+      return 2;
+    }
+
+  if (strcmp (argv[i], "-probe") == 0)  /* -linebias n */
+    {
+      ListModes ();
+      return 1;
+    }
+
+  return 0;
+}
+
+#ifdef DDXTIME /* from ServerOSDefines */
+CARD32
+GetTimeInMillis()
+{
+  struct timeval  tp;
+
+  X_GETTIMEOFDAY(&tp);
+  return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+#endif
+
+static Bool
+winMultiDepthCreateGC (GCPtr pGC)
+{
+  switch (winBitsPerPixel(pGC->depth))
+    {
+    case 1:  return mfbCreateGC (pGC);
+    case 8:  return cfbCreateGC (pGC);
+    case 16: return cfb16CreateGC (pGC);
+    case 24: return cfb24CreateGC (pGC);
+    case 32: return cfb32CreateGC (pGC);
+    default: return FALSE;
+    }
+}
+
+static void
+winMultiDepthGetSpans (DrawablePtr pDrawable, int wMax,
+                       register DDXPointPtr ppt,
+                       int *pwidth, int nspans, char *pdstStart)
+{
+  switch (pDrawable->bitsPerPixel)
+    {
+    case 1:
+      mfbGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+      break;
+    case 8:
+      cfbGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+      break;
+    case 16:
+      cfb16GetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+      break;
+    case 24:
+      cfb24GetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+      break;
+    case 32:
+      cfb32GetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+      break;
+    }
+  return;
+}
+
+static void
+winMultiDepthGetImage (DrawablePtr pDrawable, int sx, int sy,
+                       int w, int h, unsigned int format,
+                       unsigned long planeMask,
+                       char *pdstLine)
+{
+  switch (pDrawable->bitsPerPixel)
+    {
+    case 1:
+      mfbGetImage (pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+      break;
+    case 8:
+      cfbGetImage (pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+      break;
+    case 16:
+      cfb16GetImage (pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+      break;
+    case 24:
+      cfb24GetImage (pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+      break;
+    case 32:
+      cfb32GetImage (pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+      break;
+    }
+}
+
+static int
+winListInstalledColormaps (ScreenPtr pScreen, Colormap *pmaps)
+{
+    /* By the time we are processing requests, we can guarantee that there
+     * is always a colormap installed */
+    *pmaps = InstalledMaps[pScreen->myNum]->mid;
+    return (1);
+}
+
+static void
+winInstallColormap (ColormapPtr pmap)
+{
+  int                   index = pmap->pScreen->myNum;
+  ColormapPtr           oldpmap = InstalledMaps[index];
+  int                   entries;
+  VisualPtr             pVisual;
+  Pixel                 *ppix;
+  xrgb                  *prgb;
+  xColorItem            *defs;
+  int                   i;
+
+  if (pmap != oldpmap)
+    {
+      if(oldpmap != (ColormapPtr)None)
+        {
+          WalkTree (pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
+        }
+
+      /* Install pmap */
+      InstalledMaps[index] = pmap;
+      WalkTree (pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
+
+      entries = pmap->pVisual->ColormapEntries;
+      pVisual = pmap->pVisual;
+
+      ppix = (Pixel *)ALLOCATE_LOCAL(entries * sizeof(Pixel));
+      prgb = (xrgb *)ALLOCATE_LOCAL(entries * sizeof(xrgb));
+      defs = (xColorItem *)ALLOCATE_LOCAL(entries * sizeof(xColorItem));
+
+      for (i = 0; i < entries; i++)
+        {
+          ppix[i] = i;
+        }
+
+      /* XXX truecolor */
+      QueryColors(pmap, entries, ppix, prgb);
+
+      /* convert xrgbs to xColorItems */
+      for (i = 0; i < entries; i++)
+        {
+          defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */
+          defs[i].red = prgb[i].red;
+          defs[i].green = prgb[i].green;
+          defs[i].blue = prgb[i].blue;
+          defs[i].flags =  DoRed|DoGreen|DoBlue;
+        }
+      (*pmap->pScreen->StoreColors)(pmap, entries, defs);
+
+      DEALLOCATE_LOCAL(ppix);
+      DEALLOCATE_LOCAL(prgb);
+      DEALLOCATE_LOCAL(defs);
+    }
+}
+
+static void
+winUninstallColormap (ColormapPtr pmap)
+{
+  ColormapPtr           curpmap = InstalledMaps[pmap->pScreen->myNum];
+
+  if (pmap == curpmap)
+    {
+      if (pmap->mid != pmap->pScreen->defColormap)
+        {
+          curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
+                                                 RT_COLORMAP);
+          (*pmap->pScreen->InstallColormap)(curpmap);
+        }
+    }
+}
+
+static void
+winStoreColors (ColormapPtr pmap, int ndef, xColorItem *pdefs)
+{
+  int                   i;
+
+  if (pmap != InstalledMaps[pmap->pScreen->myNum]) return;
+
+  if ((pmap->pVisual->class | DynamicClass) == DirectColor)
+    return;
+
+  // TrueColor or Pseudo Color
+  if (pmap->pVisual->class == PseudoColor)
+    {
+      for (i = 0; i < ndef; i++, pdefs++)
+        {
+          DXStoreColors (pdefs->pixel,
+                         pdefs->red,
+                         pdefs->green,
+                         pdefs->blue);
+        }
+    }
+}
+
+static Bool
+winSaveScreen (ScreenPtr pScreen, int on)
+{
+    return TRUE;
+}
+
+static char *
+winAllocateFramebufferMemory (winScreenInfoPtr pwin)
+{
+  pwin->pfbMemory = winDXAllocateFramebufferMemory (&pwin->width,
+                                                    &pwin->height,
+                                                    &pwin->depth,
+                                                    &pwin->paddedWidth);
+  return pwin->pfbMemory;
+}
+
+static Bool
+winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y)
+{
+  return FALSE;
+}
+
+static void
+winCrossScreen (ScreenPtr pScreen, Bool entering)
+{
+}
+
+static miPointerScreenFuncRec winPointerCursorFuncs =
+{
+  winCursorOffScreen,
+  winCrossScreen,
+  miPointerWarpCursor
+};
+
+Bool miCreateScreenResources (ScreenPtr pScreen) ;
+
+static Bool
+winScreenInit (int index, ScreenPtr pScreen, int argc, char *argv[])
+{
+  winScreenInfoPtr      pwin = &winScreens[index];
+  PictFormatPtr         formats = NULL;
+  int                   nformats = 0;
+  int                   dpix = 100, dpiy = 100;
+  int                   ret = FALSE;
+  char                  *pbits;
+  BOOL                  fResult = FALSE;
+  unsigned long         stack_ptr;
+
+  /* Initial display parameters */
+  pwin->paddedWidth = PixmapBytePad(pwin->width, pwin->depth);
+  pwin->bitsPerPixel = winBitsPerPixel(pwin->depth);
+
+  pbits = winAllocateFramebufferMemory (pwin);
+
+  if (!pbits) return FALSE;
+
+  fprintf (stderr, "Obtained Width: %d, Height: %d, Depth: %d\n",
+           pwin->width, pwin->height, pwin->bitsPerPixel);
+
+  switch (pwin->bitsPerPixel)
+    {
+    case 1:
+      ret = mfbScreenInit (pScreen, pbits, pwin->width, pwin->height,
+                           dpix, dpiy, pwin->paddedWidth * 8);
+      break;
+    case 8:
+      fprintf( stderr, "Calling cfbScreenInit (%08x, %08x, %d, %d, %d, %d, %d)\n",
+               pScreen, pbits, pwin->width, pwin->height,
+               dpix, dpiy, pwin->paddedWidth);
+
+      ret = cfbScreenInit (pScreen, pbits, pwin->width, pwin->height,
+                           dpix, dpiy, pwin->paddedWidth);
+      break;
+    case 16:
+      fprintf( stderr, "Calling cfb16ScreenInit (%08x, %08x, %d, %d, %d, %d, %d)\n",
+               pScreen, pbits, pwin->width, pwin->height,
+               dpix, dpiy, pwin->paddedWidth);
+      ret = cfb16ScreenInit (pScreen, pbits, pwin->width, pwin->height,
+                             dpix, dpiy, pwin->paddedWidth);
+      break;
+    case 24:
+      fprintf( stderr, "Calling cfb24ScreenInit (%08x, %08x, %d, %d, %d, %d, %d)\n",
+               pScreen, pbits, pwin->width, pwin->height,
+               dpix, dpiy, pwin->paddedWidth);
+      ret = cfb24ScreenInit (pScreen, pbits, pwin->width, pwin->height,
+                             dpix, dpiy, pwin->paddedWidth);
+      break;
+    case 32:
+      fprintf( stderr, "Calling cfb32ScreenInit (%08x, %08x, %d, %d, %d, %d, %d)\n",
+               pScreen, pbits, pwin->width, pwin->height,
+               dpix, dpiy, pwin->paddedWidth);
+
+      ret = cfb32ScreenInit (pScreen, pbits, pwin->width, pwin->height,
+                             dpix, dpiy, pwin->paddedWidth);
+      break;
+    default:
+      return FALSE;
+    }
+
+  if (!ret) return FALSE;
+
+  pScreen->CreateGC = winMultiDepthCreateGC;
+  pScreen->GetImage = winMultiDepthGetImage;
+  pScreen->GetSpans = winMultiDepthGetSpans;
+
+  pScreen->InstallColormap = winInstallColormap;
+  pScreen->UninstallColormap = winUninstallColormap;
+  pScreen->ListInstalledColormaps = winListInstalledColormaps;
+
+  pScreen->SaveScreen = winSaveScreen;
+  pScreen->StoreColors = winStoreColors;
+
+  miPictureInit(pScreen, formats, nformats);
+  miDCInitialize (pScreen, &winPointerCursorFuncs);
+
+  pScreen->blackPixel = pwin->blackPixel;
+  pScreen->whitePixel = pwin->whitePixel;
+
+  if (pwin->bitsPerPixel == 1)
+    {
+      ret = mfbCreateDefColormap (pScreen);
+    }
+  else
+    {
+      ret = winCreateDefColormap (pScreen);
+    }
+
+  miSetZeroLineBias (pScreen, pwin->lineBias);
+
+  if (ret)
+    {
+      RegisterBlockAndWakeupHandlers (winfbBlockHandler,
+				      winfbWakeupHandler,
+				      NULL);
+    }
+  pwin->pScreen = pScreen ;
+  ErrorF ("Successful addition of Screen %p %p\n",
+	  pScreen->devPrivate,
+	  pScreen);
+  return ret;
+
+}
+
+void
+InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
+{
+  int		i;
+  int		iNumFormats = 0;
+  int		*piDepth = 0, *piWidth = 0, *piHeight = 0;
+  FILE		*pf = stderr;
+
+  /* Initialize pixmap formats */
+
+  /* cfbLoad() ;*/
+
+  /* Adjust bit depth for all screens */
+  for (i = 0; i < winNumScreens; i++)
+    {
+      piWidth = &winScreens[i].width;
+      piHeight = &winScreens[i].height;
+      piDepth = &winScreens[i].depth;
+
+      fprintf (stderr, "Desired Width: %d, Height: %d, Depth: %d\n",
+	       *piWidth, *piHeight, *piDepth);
+
+      /* Adjust bit depth and display size for hardware requirements */
+      AdjustVideoMode (piWidth, piHeight, piDepth, TRUE);
+
+      fprintf (stderr, "Adjusted Width: %d, Height: %d, Depth: %d\n",
+	       *piWidth, *piHeight, *piDepth);
+    }
+
+  /* must have a pixmap depth to match every screen depth */
+  for (i = 0; i < winNumScreens; i++)
+    {
+      winPixmapDepths[winScreens[i].depth] = TRUE;
+    }
+
+  for (i = 1; i <= 32; i++)
+    {
+      if (winPixmapDepths[i])
+	{
+	  if (iNumFormats >= MAXFORMATS)
+	    FatalError ("MAXFORMATS is too small for this server\n");
+	  screenInfo->formats[iNumFormats].depth = i;
+	  screenInfo->formats[iNumFormats].bitsPerPixel = winBitsPerPixel(i);
+	  screenInfo->formats[iNumFormats].scanlinePad = BITMAP_SCANLINE_PAD;
+	  iNumFormats++;
+	}
+    }
+
+  screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+  screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+  screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+  screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+  screenInfo->numPixmapFormats = iNumFormats;
+
+  /* initialize screens */
+  for (i = 0; i < winNumScreens; i++)
+    {
+      if (-1 == AddScreen (winScreenInit, argc, argv))
+	{
+	  FatalError ("Couldn't add screen %d", i);
+	}
+    }
+}
+
+void
+SwitchFramebuffer (pointer pbits)
+{
+  PixmapPtr		pmap;
+  ScreenPtr		s = winScreens[0].pScreen;
+
+  pmap = ((PixmapPtr) (s)->devPrivate);
+  /*
+    if (winScreens[0].depth == 8)
+    pmap = ((PixmapPtr) (s)->devPrivate);
+    else
+    pmap = ((PixmapPtr) (s)->devPrivates[0].ptr);
+  */
+  /*ErrorF ("Switch: %p, %p\n", winScreens[0].pScreen, pmap);*/
+  pmap->devPrivate.ptr = pbits;
+}
Index: xc/programs/Xserver/hw/xwin/ddraw.h
diff -u /dev/null xc/programs/Xserver/hw/xwin/ddraw.h:1.1
--- /dev/null	Mon Dec 18 14:33:01 2000
+++ xc/programs/Xserver/hw/xwin/ddraw.h	Thu Aug 10 13:40:37 2000
@@ -0,0 +1,1514 @@
+/* $XFree86: xc/programs/Xserver/hw/xwin/ddraw.h,v 1.1 2000/08/10 17:40:37 dawes Exp $ */
+
+#ifndef __WINE_DDRAW_H
+#define __WINE_DDRAW_H
+
+#include <X11/Xlib.h>
+#ifdef HAVE_LIBXXSHM
+#include <X11/extensions/XShm.h>
+#endif /* defined(HAVE_LIBXXSHM) */
+
+#include "winnt.h" /* LARGE_INTEGER ... */
+#include "wingdi.h" /* PALETTE stuff ... */
+#include "wine/obj_base.h"
+
+#ifndef	DIRECTDRAW_VERSION
+#define	DIRECTDRAW_VERSION	0x0500
+#endif /* DIRECTDRAW_VERSION */
+
+/*****************************************************************************
+ * Predeclare the interfaces
+ */
+DEFINE_GUID( CLSID_DirectDraw,		0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 );
+DEFINE_GUID( CLSID_DirectDrawClipper,	0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 );
+DEFINE_GUID( IID_IDirectDraw,		0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
+DEFINE_GUID( IID_IDirectDraw2,		0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 );
+DEFINE_GUID( IID_IDirectDraw4,          0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 );
+DEFINE_GUID( IID_IDirectDrawSurface,	0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
+DEFINE_GUID( IID_IDirectDrawSurface2,	0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 );
+DEFINE_GUID( IID_IDirectDrawSurface3,	0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB );
+DEFINE_GUID( IID_IDirectDrawSurface4,   0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B );
+DEFINE_GUID( IID_IDirectDrawPalette,	0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
+DEFINE_GUID( IID_IDirectDrawClipper,	0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 );
+DEFINE_GUID( IID_IDirectDrawColorControl,0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 );
+
+typedef struct IDirectDraw IDirectDraw,*LPDIRECTDRAW;
+typedef struct IDirectDraw2 IDirectDraw2,*LPDIRECTDRAW2;
+typedef struct IDirectDraw4 IDirectDraw4,*LPDIRECTDRAW4;
+typedef struct IDirectDrawClipper IDirectDrawClipper,*LPDIRECTDRAWCLIPPER;
+typedef struct IDirectDrawPalette IDirectDrawPalette,*LPDIRECTDRAWPALETTE;
+typedef struct IDirectDrawSurface IDirectDrawSurface,*LPDIRECTDRAWSURFACE;
+typedef struct IDirectDrawSurface2 IDirectDrawSurface2,*LPDIRECTDRAWSURFACE2;
+typedef struct IDirectDrawSurface3 IDirectDrawSurface3,*LPDIRECTDRAWSURFACE3;
+typedef struct IDirectDrawSurface4 IDirectDrawSurface4,*LPDIRECTDRAWSURFACE4;
+typedef struct IDirectDrawColorControl IDirectDrawColorControl,*LPDIRECTDRAWCOLORCONTROL;
+
+
+#define DDENUMRET_CANCEL	0
+#define DDENUMRET_OK		1
+
+#define DD_OK			0
+
+
+#define _FACDD		0x876
+#define MAKE_DDHRESULT( code )  MAKE_HRESULT( 1, _FACDD, code )
+
+#define DDERR_ALREADYINITIALIZED		MAKE_DDHRESULT( 5 )
+#define DDERR_CANNOTATTACHSURFACE		MAKE_DDHRESULT( 10 )
+#define DDERR_CANNOTDETACHSURFACE		MAKE_DDHRESULT( 20 )
+#define DDERR_CURRENTLYNOTAVAIL			MAKE_DDHRESULT( 40 )
+#define DDERR_EXCEPTION				MAKE_DDHRESULT( 55 )
+#define DDERR_GENERIC				E_FAIL
+#define DDERR_HEIGHTALIGN			MAKE_DDHRESULT( 90 )
+#define DDERR_INCOMPATIBLEPRIMARY		MAKE_DDHRESULT( 95 )
+#define DDERR_INVALIDCAPS			MAKE_DDHRESULT( 100 )
+#define DDERR_INVALIDCLIPLIST			MAKE_DDHRESULT( 110 )
+#define DDERR_INVALIDMODE			MAKE_DDHRESULT( 120 )
+#define DDERR_INVALIDOBJECT			MAKE_DDHRESULT( 130 )
+#define DDERR_INVALIDPARAMS			E_INVALIDARG
+#define DDERR_INVALIDPIXELFORMAT		MAKE_DDHRESULT( 145 )
+#define DDERR_INVALIDRECT			MAKE_DDHRESULT( 150 )
+#define DDERR_LOCKEDSURFACES			MAKE_DDHRESULT( 160 )
+#define DDERR_NO3D				MAKE_DDHRESULT( 170 )
+#define DDERR_NOALPHAHW				MAKE_DDHRESULT( 180 )
+#define DDERR_NOCLIPLIST			MAKE_DDHRESULT( 205 )
+#define DDERR_NOCOLORCONVHW			MAKE_DDHRESULT( 210 )
+#define DDERR_NOCOOPERATIVELEVELSET		MAKE_DDHRESULT( 212 )
+#define DDERR_NOCOLORKEY			MAKE_DDHRESULT( 215 )
+#define DDERR_NOCOLORKEYHW			MAKE_DDHRESULT( 220 )
+#define DDERR_NODIRECTDRAWSUPPORT		MAKE_DDHRESULT( 222 )
+#define DDERR_NOEXCLUSIVEMODE			MAKE_DDHRESULT( 225 )
+#define DDERR_NOFLIPHW				MAKE_DDHRESULT( 230 )
+#define DDERR_NOGDI				MAKE_DDHRESULT( 240 )
+#define DDERR_NOMIRRORHW			MAKE_DDHRESULT( 250 )
+#define DDERR_NOTFOUND				MAKE_DDHRESULT( 255 )
+#define DDERR_NOOVERLAYHW			MAKE_DDHRESULT( 260 )
+#define DDERR_NORASTEROPHW			MAKE_DDHRESULT( 280 )
+#define DDERR_NOROTATIONHW			MAKE_DDHRESULT( 290 )
+#define DDERR_NOSTRETCHHW			MAKE_DDHRESULT( 310 )
+#define DDERR_NOT4BITCOLOR			MAKE_DDHRESULT( 316 )
+#define DDERR_NOT4BITCOLORINDEX			MAKE_DDHRESULT( 317 )
+#define DDERR_NOT8BITCOLOR			MAKE_DDHRESULT( 320 )
+#define DDERR_NOTEXTUREHW			MAKE_DDHRESULT( 330 )
+#define DDERR_NOVSYNCHW				MAKE_DDHRESULT( 335 )
+#define DDERR_NOZBUFFERHW			MAKE_DDHRESULT( 340 )
+#define DDERR_NOZOVERLAYHW			MAKE_DDHRESULT( 350 )
+#define DDERR_OUTOFCAPS				MAKE_DDHRESULT( 360 )
+#define DDERR_OUTOFMEMORY			E_OUTOFMEMORY
+#define DDERR_OUTOFVIDEOMEMORY			MAKE_DDHRESULT( 380 )
+#define DDERR_OVERLAYCANTCLIP			MAKE_DDHRESULT( 382 )
+#define DDERR_OVERLAYCOLORKEYONLYONEACTIVE	MAKE_DDHRESULT( 384 )
+#define DDERR_PALETTEBUSY			MAKE_DDHRESULT( 387 )
+#define DDERR_COLORKEYNOTSET			MAKE_DDHRESULT( 400 )
+#define DDERR_SURFACEALREADYATTACHED		MAKE_DDHRESULT( 410 )
+#define DDERR_SURFACEALREADYDEPENDENT		MAKE_DDHRESULT( 420 )
+#define DDERR_SURFACEBUSY			MAKE_DDHRESULT( 430 )
+#define DDERR_CANTLOCKSURFACE			MAKE_DDHRESULT( 435 )
+#define DDERR_SURFACEISOBSCURED			MAKE_DDHRESULT( 440 )
+#define DDERR_SURFACELOST			MAKE_DDHRESULT( 450 )
+#define DDERR_SURFACENOTATTACHED		MAKE_DDHRESULT( 460 )
+#define DDERR_TOOBIGHEIGHT			MAKE_DDHRESULT( 470 )
+#define DDERR_TOOBIGSIZE			MAKE_DDHRESULT( 480 )
+#define DDERR_TOOBIGWIDTH			MAKE_DDHRESULT( 490 )
+#define DDERR_UNSUPPORTED			E_NOTIMPL
+#define DDERR_UNSUPPORTEDFORMAT			MAKE_DDHRESULT( 510 )
+#define DDERR_UNSUPPORTEDMASK			MAKE_DDHRESULT( 520 )
+#define DDERR_VERTICALBLANKINPROGRESS		MAKE_DDHRESULT( 537 )
+#define DDERR_WASSTILLDRAWING			MAKE_DDHRESULT( 540 )
+#define DDERR_XALIGN				MAKE_DDHRESULT( 560 )
+#define DDERR_INVALIDDIRECTDRAWGUID		MAKE_DDHRESULT( 561 )
+#define DDERR_DIRECTDRAWALREADYCREATED		MAKE_DDHRESULT( 562 )
+#define DDERR_NODIRECTDRAWHW			MAKE_DDHRESULT( 563 )
+#define DDERR_PRIMARYSURFACEALREADYEXISTS	MAKE_DDHRESULT( 564 )
+#define DDERR_NOEMULATION			MAKE_DDHRESULT( 565 )
+#define DDERR_REGIONTOOSMALL			MAKE_DDHRESULT( 566 )
+#define DDERR_CLIPPERISUSINGHWND		MAKE_DDHRESULT( 567 )
+#define DDERR_NOCLIPPERATTACHED			MAKE_DDHRESULT( 568 )
+#define DDERR_NOHWND				MAKE_DDHRESULT( 569 )
+#define DDERR_HWNDSUBCLASSED			MAKE_DDHRESULT( 570 )
+#define DDERR_HWNDALREADYSET			MAKE_DDHRESULT( 571 )
+#define DDERR_NOPALETTEATTACHED			MAKE_DDHRESULT( 572 )
+#define DDERR_NOPALETTEHW			MAKE_DDHRESULT( 573 )
+#define DDERR_BLTFASTCANTCLIP			MAKE_DDHRESULT( 574 )
+#define DDERR_NOBLTHW				MAKE_DDHRESULT( 575 )
+#define DDERR_NODDROPSHW			MAKE_DDHRESULT( 576 )
+#define DDERR_OVERLAYNOTVISIBLE			MAKE_DDHRESULT( 577 )
+#define DDERR_NOOVERLAYDEST			MAKE_DDHRESULT( 578 )
+#define DDERR_INVALIDPOSITION			MAKE_DDHRESULT( 579 )
+#define DDERR_NOTAOVERLAYSURFACE		MAKE_DDHRESULT( 580 )
+#define DDERR_EXCLUSIVEMODEALREADYSET		MAKE_DDHRESULT( 581 )
+#define DDERR_NOTFLIPPABLE			MAKE_DDHRESULT( 582 )
+#define DDERR_CANTDUPLICATE			MAKE_DDHRESULT( 583 )
+#define DDERR_NOTLOCKED				MAKE_DDHRESULT( 584 )
+#define DDERR_CANTCREATEDC			MAKE_DDHRESULT( 585 )
+#define DDERR_NODC				MAKE_DDHRESULT( 586 )
+#define DDERR_WRONGMODE				MAKE_DDHRESULT( 587 )
+#define DDERR_IMPLICITLYCREATED			MAKE_DDHRESULT( 588 )
+#define DDERR_NOTPALETTIZED			MAKE_DDHRESULT( 589 )
+#define DDERR_UNSUPPORTEDMODE			MAKE_DDHRESULT( 590 )
+#define DDERR_NOMIPMAPHW			MAKE_DDHRESULT( 591 )
+#define DDERR_INVALIDSURFACETYPE		MAKE_DDHRESULT( 592 )
+#define DDERR_NOOPTIMIZEHW			MAKE_DDHRESULT( 600 )
+#define DDERR_NOTLOADED				MAKE_DDHRESULT( 601 )
+#define DDERR_NOFOCUSWINDOW			MAKE_DDHRESULT( 602 )
+#define DDERR_DCALREADYCREATED			MAKE_DDHRESULT( 620 )
+#define DDERR_NONONLOCALVIDMEM			MAKE_DDHRESULT( 630 )
+#define DDERR_CANTPAGELOCK			MAKE_DDHRESULT( 640 )
+#define DDERR_CANTPAGEUNLOCK			MAKE_DDHRESULT( 660 )
+#define DDERR_NOTPAGELOCKED			MAKE_DDHRESULT( 680 )
+#define DDERR_MOREDATA				MAKE_DDHRESULT( 690 )
+#define DDERR_VIDEONOTACTIVE			MAKE_DDHRESULT( 695 )
+#define DDERR_DEVICEDOESNTOWNSURFACE		MAKE_DDHRESULT( 699 )
+#define DDERR_NOTINITIALIZED			CO_E_NOTINITIALIZED
+
+/* dwFlags for Blt* */
+#define DDBLT_ALPHADEST				0x00000001
+#define DDBLT_ALPHADESTCONSTOVERRIDE		0x00000002
+#define DDBLT_ALPHADESTNEG			0x00000004
+#define DDBLT_ALPHADESTSURFACEOVERRIDE		0x00000008
+#define DDBLT_ALPHAEDGEBLEND			0x00000010
+#define DDBLT_ALPHASRC				0x00000020
+#define DDBLT_ALPHASRCCONSTOVERRIDE		0x00000040
+#define DDBLT_ALPHASRCNEG			0x00000080
+#define DDBLT_ALPHASRCSURFACEOVERRIDE		0x00000100
+#define DDBLT_ASYNC				0x00000200
+#define DDBLT_COLORFILL				0x00000400
+#define DDBLT_DDFX				0x00000800
+#define DDBLT_DDROPS				0x00001000
+#define DDBLT_KEYDEST				0x00002000
+#define DDBLT_KEYDESTOVERRIDE			0x00004000
+#define DDBLT_KEYSRC				0x00008000
+#define DDBLT_KEYSRCOVERRIDE			0x00010000
+#define DDBLT_ROP				0x00020000
+#define DDBLT_ROTATIONANGLE			0x00040000
+#define DDBLT_ZBUFFER				0x00080000
+#define DDBLT_ZBUFFERDESTCONSTOVERRIDE		0x00100000
+#define DDBLT_ZBUFFERDESTOVERRIDE		0x00200000
+#define DDBLT_ZBUFFERSRCCONSTOVERRIDE		0x00400000
+#define DDBLT_ZBUFFERSRCOVERRIDE		0x00800000
+#define DDBLT_WAIT				0x01000000
+#define DDBLT_DEPTHFILL				0x02000000
+
+/* dwTrans for BltFast */
+#define DDBLTFAST_NOCOLORKEY			0x00000000
+#define DDBLTFAST_SRCCOLORKEY			0x00000001
+#define DDBLTFAST_DESTCOLORKEY			0x00000002
+#define DDBLTFAST_WAIT				0x00000010
+
+/* dwFlags for Flip */
+#define DDFLIP_WAIT	0x00000001
+#define DDFLIP_EVEN	0x00000002 /* only valid for overlay */
+#define DDFLIP_ODD	0x00000004 /* only valid for overlay */
+
+/* dwFlags for GetBltStatus */
+#define DDGBS_CANBLT				0x00000001
+#define DDGBS_ISBLTDONE				0x00000002
+
+/* DDSCAPS.dwCaps */
+/* reserved1, was 3d capable */
+#define DDSCAPS_RESERVED1		0x00000001
+/* surface contains alpha information */
+#define DDSCAPS_ALPHA			0x00000002
+/* this surface is a backbuffer */
+#define DDSCAPS_BACKBUFFER		0x00000004
+/* complex surface structure */
+#define DDSCAPS_COMPLEX			0x00000008
+/* part of surface flipping structure */
+#define DDSCAPS_FLIP			0x00000010
+/* this surface is the frontbuffer surface */
+#define DDSCAPS_FRONTBUFFER		0x00000020
+/* this is a plain offscreen surface */
+#define DDSCAPS_OFFSCREENPLAIN		0x00000040
+/* overlay */
+#define DDSCAPS_OVERLAY			0x00000080
+/* palette objects can be created and attached to us */
+#define DDSCAPS_PALETTE			0x00000100
+/* primary surface (the one the user looks at currently)(right eye)*/
+#define DDSCAPS_PRIMARYSURFACE		0x00000200
+/* primary surface for left eye */
+#define DDSCAPS_PRIMARYSURFACELEFT	0x00000400
+/* surface exists in systemmemory */
+#define DDSCAPS_SYSTEMMEMORY		0x00000800
+/* surface can be used as a texture */
+#define DDSCAPS_TEXTURE		        0x00001000
+/* surface may be destination for 3d rendering */
+#define DDSCAPS_3DDEVICE		0x00002000
+/* surface exists in videomemory */
+#define DDSCAPS_VIDEOMEMORY		0x00004000
+/* surface changes immediately visible */
+#define DDSCAPS_VISIBLE			0x00008000
+/* write only surface */
+#define DDSCAPS_WRITEONLY		0x00010000
+/* zbuffer surface */
+#define DDSCAPS_ZBUFFER			0x00020000
+/* has its own DC */
+#define DDSCAPS_OWNDC			0x00040000
+/* surface should be able to receive live video */
+#define DDSCAPS_LIVEVIDEO		0x00080000
+/* should be able to have a hw codec decompress stuff into it */
+#define DDSCAPS_HWCODEC			0x00100000
+/* mode X (320x200 or 320x240) surface */
+#define DDSCAPS_MODEX			0x00200000
+/* one mipmap surface (1 level) */
+#define DDSCAPS_MIPMAP			0x00400000
+#define DDSCAPS_RESERVED2		0x00800000
+/* memory allocation delayed until Load() */
+#define DDSCAPS_ALLOCONLOAD		0x04000000
+/* Indicates that the surface will recieve data from a video port */
+#define DDSCAPS_VIDEOPORT		0x08000000
+/* surface is in local videomemory */
+#define DDSCAPS_LOCALVIDMEM		0x10000000
+/* surface is in nonlocal videomemory */
+#define DDSCAPS_NONLOCALVIDMEM		0x20000000
+/* surface is a standard VGA mode surface (NOT ModeX) */
+#define DDSCAPS_STANDARDVGAMODE		0x40000000
+/* optimized? surface */
+#define DDSCAPS_OPTIMIZED		0x80000000
+
+typedef struct _DDSCAPS {
+	DWORD	dwCaps;	/* capabilities of surface wanted */
+} DDSCAPS,*LPDDSCAPS;
+
+#define	DD_ROP_SPACE	(256/32)	/* space required to store ROP array */
+
+typedef struct _DDCAPS_DX3
+{
+    DWORD	dwSize;                 /* size of the DDDRIVERCAPS structure */
+    DWORD	dwCaps;                 /* driver specific capabilities */
+    DWORD	dwCaps2;                /* more driver specific capabilites */
+    DWORD	dwCKeyCaps;             /* color key capabilities of the surface */
+    DWORD	dwFXCaps;               /* driver specific stretching and effects capabilites */
+    DWORD	dwFXAlphaCaps;          /* alpha driver specific capabilities */
+    DWORD	dwPalCaps;              /* palette capabilities */
+    DWORD	dwSVCaps;               /* stereo vision capabilities */
+    DWORD	dwAlphaBltConstBitDepths;       /* DDBD_2,4,8 */
+    DWORD	dwAlphaBltPixelBitDepths;       /* DDBD_1,2,4,8 */
+    DWORD	dwAlphaBltSurfaceBitDepths;     /* DDBD_1,2,4,8 */
+    DWORD	dwAlphaOverlayConstBitDepths;   /* DDBD_2,4,8 */
+    DWORD	dwAlphaOverlayPixelBitDepths;   /* DDBD_1,2,4,8 */
+    DWORD	dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */
+    DWORD	dwZBufferBitDepths;             /* DDBD_8,16,24,32 */
+    DWORD	dwVidMemTotal;          /* total amount of video memory */
+    DWORD	dwVidMemFree;           /* amount of free video memory */
+    DWORD	dwMaxVisibleOverlays;   /* maximum number of visible overlays */
+    DWORD	dwCurrVisibleOverlays;  /* current number of visible overlays */
+    DWORD	dwNumFourCCCodes;       /* number of four cc codes */
+    DWORD	dwAlignBoundarySrc;     /* source rectangle alignment */
+    DWORD	dwAlignSizeSrc;         /* source rectangle byte size */
+    DWORD	dwAlignBoundaryDest;    /* dest rectangle alignment */
+    DWORD	dwAlignSizeDest;        /* dest rectangle byte size */
+    DWORD	dwAlignStrideAlign;     /* stride alignment */
+    DWORD	dwRops[DD_ROP_SPACE];   /* ROPS supported */
+    DDSCAPS	ddsCaps;                /* DDSCAPS structure has all the general capabilities */
+    DWORD	dwMinOverlayStretch;    /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+    DWORD	dwMaxOverlayStretch;    /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+    DWORD	dwMinLiveVideoStretch;  /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+    DWORD	dwMaxLiveVideoStretch;  /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+    DWORD	dwMinHwCodecStretch;    /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+    DWORD	dwMaxHwCodecStretch;    /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+    DWORD	dwReserved1;
+    DWORD	dwReserved2;
+    DWORD	dwReserved3;
+    DWORD	dwSVBCaps;              /* driver specific capabilities for System->Vmem blts */
+    DWORD	dwSVBCKeyCaps;          /* driver color key capabilities for System->Vmem blts */
+    DWORD	dwSVBFXCaps;            /* driver FX capabilities for System->Vmem blts */
+    DWORD	dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
+    DWORD	dwVSBCaps;              /* driver specific capabilities for Vmem->System blts */
+    DWORD	dwVSBCKeyCaps;          /* driver color key capabilities for Vmem->System blts */
+    DWORD	dwVSBFXCaps;            /* driver FX capabilities for Vmem->System blts */
+    DWORD	dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
+    DWORD	dwSSBCaps;              /* driver specific capabilities for System->System blts */
+    DWORD	dwSSBCKeyCaps;          /* driver color key capabilities for System->System blts */
+    DWORD	dwSSBFXCaps;            /* driver FX capabilities for System->System blts */
+    DWORD	dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
+    DWORD	dwReserved4;
+    DWORD	dwReserved5;
+    DWORD	dwReserved6;
+} DDCAPS_DX3,*LPDDCAPS_DX3;
+
+typedef struct _DDCAPS
+{
+/*  0*/ DWORD  dwSize;			/* size of the DDDRIVERCAPS structure */
+/*  4*/ DWORD  dwCaps;			/* driver specific capabilities */
+/*  8*/ DWORD  dwCaps2;			/* more driver specific capabilites */
+/*  c*/ DWORD  dwCKeyCaps;		/* color key capabilities of the surface */
+/* 10*/ DWORD  dwFXCaps;		/* driver specific stretching and effects capabilites */
+/* 14*/ DWORD  dwFXAlphaCaps;		/* alpha driver specific capabilities */
+/* 18*/ DWORD  dwPalCaps;		/* palette capabilities */
+/* 1c*/ DWORD  dwSVCaps;		/* stereo vision capabilities */
+/* 20*/ DWORD  dwAlphaBltConstBitDepths;	/* DDBD_2,4,8 */
+/* 24*/ DWORD  dwAlphaBltPixelBitDepths;	/* DDBD_1,2,4,8 */
+/* 28*/ DWORD  dwAlphaBltSurfaceBitDepths;	/* DDBD_1,2,4,8 */
+/* 2c*/ DWORD  dwAlphaOverlayConstBitDepths;	/* DDBD_2,4,8 */
+/* 30*/ DWORD  dwAlphaOverlayPixelBitDepths;	/* DDBD_1,2,4,8 */
+/* 34*/ DWORD  dwAlphaOverlaySurfaceBitDepths;	/* DDBD_1,2,4,8 */
+/* 38*/ DWORD  dwZBufferBitDepths;		/* DDBD_8,16,24,32 */
+/* 3c*/ DWORD  dwVidMemTotal;		/* total amount of video memory */
+/* 40*/ DWORD  dwVidMemFree;		/* amount of free video memory */
+/* 44*/ DWORD  dwMaxVisibleOverlays;	/* maximum number of visible overlays */
+/* 48*/ DWORD  dwCurrVisibleOverlays;	/* current number of visible overlays */
+/* 4c*/ DWORD  dwNumFourCCCodes;	/* number of four cc codes */
+/* 50*/ DWORD  dwAlignBoundarySrc;	/* source rectangle alignment */
+/* 54*/ DWORD  dwAlignSizeSrc;		/* source rectangle byte size */
+/* 58*/ DWORD  dwAlignBoundaryDest;	/* dest rectangle alignment */
+/* 5c*/ DWORD  dwAlignSizeDest;		/* dest rectangle byte size */
+/* 60*/ DWORD  dwAlignStrideAlign;	/* stride alignment */
+/* 64*/ DWORD  dwRops[DD_ROP_SPACE];	/* ROPS supported */
+/* 84*/ DDSCAPS ddsCaps;		/* DDSCAPS structure has all the general capabilities */
+/* 88*/ DWORD  dwMinOverlayStretch;	/* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+/* 8c*/ DWORD  dwMaxOverlayStretch;	/* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+/* 90*/ DWORD  dwMinLiveVideoStretch;	/* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+/* 94*/ DWORD  dwMaxLiveVideoStretch;	/* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+/* 98*/ DWORD  dwMinHwCodecStretch;	/* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+/* 9c*/ DWORD  dwMaxHwCodecStretch;	/* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */
+/* a0*/ DWORD  dwReserved1;
+/* a4*/ DWORD  dwReserved2;
+/* a8*/ DWORD  dwReserved3;
+/* ac*/ DWORD  dwSVBCaps;	/* driver specific capabilities for System->Vmem blts */
+/* b0*/ DWORD  dwSVBCKeyCaps;	/* driver color key capabilities for System->Vmem blts */
+/* b4*/ DWORD  dwSVBFXCaps;	/* driver FX capabilities for System->Vmem blts */
+/* b8*/ DWORD  dwSVBRops[DD_ROP_SPACE];/* ROPS supported for System->Vmem blts */
+/* d8*/ DWORD  dwVSBCaps;	/* driver specific capabilities for Vmem->System blts */
+/* dc*/ DWORD  dwVSBCKeyCaps;	/* driver color key capabilities for Vmem->System blts */
+/* e0*/ DWORD  dwVSBFXCaps;	/* driver FX capabilities for Vmem->System blts */
+/* e4*/ DWORD  dwVSBRops[DD_ROP_SPACE];/* ROPS supported for Vmem->System blts */
+/*104*/ DWORD  dwSSBCaps;	/* driver specific capabilities for System->System blts */
+/*108*/ DWORD  dwSSBCKeyCaps;	/* driver color key capabilities for System->System blts */
+/*10c*/ DWORD  dwSSBFXCaps;	/* driver FX capabilities for System->System blts */
+/*110*/ DWORD  dwSSBRops[DD_ROP_SPACE];/* ROPS supported for System->System blts */
+#if       DIRECTDRAW_VERSION >= 0x0500
+/*130*/ DWORD  dwMaxVideoPorts;	/* maximum number of usable video ports */
+/*134*/ DWORD  dwCurrVideoPorts;/* current number of video ports used */
+/*138*/ DWORD  dwSVBCaps2;	/* more driver specific capabilities for System->Vmem blts */
+/*13c*/ DWORD  dwNLVBCaps;	/* driver specific capabilities for non-local->local vidmem blts */
+/*140*/ DWORD  dwNLVBCaps2;	/* more driver specific capabilities non-local->local vidmem blts */
+/*144*/ DWORD  dwNLVBCKeyCaps;	/* driver color key capabilities for non-local->local vidmem blts */
+/*148*/ DWORD  dwNLVBFXCaps;	/* driver FX capabilities for non-local->local blts */
+/*14c*/ DWORD  dwNLVBRops[DD_ROP_SPACE];/* ROPS supported for non-local->local blts */
+#else  /* DIRECTDRAW_VERSION >= 0x0500 */
+/*130*/ DWORD  dwReserved4;
+/*134*/ DWORD  dwReserved5;
+/*138*/ DWORD  dwReserved6;
+#endif /* DIRECTDRAW_VERSION >= 0x0500 */
+} DDCAPS,*LPDDCAPS;
+
+
+/* DDCAPS.dwCaps */
+#define DDCAPS_3D			0x00000001
+#define DDCAPS_ALIGNBOUNDARYDEST	0x00000002
+#define DDCAPS_ALIGNSIZEDEST		0x00000004
+#define DDCAPS_ALIGNBOUNDARYSRC		0x00000008
+#define DDCAPS_ALIGNSIZESRC		0x00000010
+#define DDCAPS_ALIGNSTRIDE		0x00000020
+#define DDCAPS_BLT			0x00000040
+#define DDCAPS_BLTQUEUE			0x00000080
+#define DDCAPS_BLTFOURCC		0x00000100
+#define DDCAPS_BLTSTRETCH		0x00000200
+#define DDCAPS_GDI			0x00000400
+#define DDCAPS_OVERLAY			0x00000800
+#define DDCAPS_OVERLAYCANTCLIP		0x00001000
+#define DDCAPS_OVERLAYFOURCC		0x00002000
+#define DDCAPS_OVERLAYSTRETCH		0x00004000
+#define DDCAPS_PALETTE			0x00008000
+#define DDCAPS_PALETTEVSYNC		0x00010000
+#define DDCAPS_READSCANLINE		0x00020000
+#define DDCAPS_STEREOVIEW		0x00040000
+#define DDCAPS_VBI			0x00080000
+#define DDCAPS_ZBLTS			0x00100000
+#define DDCAPS_ZOVERLAYS		0x00200000
+#define DDCAPS_COLORKEY			0x00400000
+#define DDCAPS_ALPHA			0x00800000
+#define DDCAPS_COLORKEYHWASSIST		0x01000000
+#define DDCAPS_NOHARDWARE		0x02000000
+#define DDCAPS_BLTCOLORFILL		0x04000000
+#define DDCAPS_BANKSWITCHED		0x08000000
+#define DDCAPS_BLTDEPTHFILL		0x10000000
+#define DDCAPS_CANCLIP			0x20000000
+#define DDCAPS_CANCLIPSTRETCHED		0x40000000
+#define DDCAPS_CANBLTSYSMEM		0x80000000
+
+/* DDCAPS.dwCaps2 */
+#define DDCAPS2_CERTIFIED		0x00000001
+#define DDCAPS2_NO2DDURING3DSCENE       0x00000002
+#define DDCAPS2_VIDEOPORT		0x00000004
+#define DDCAPS2_AUTOFLIPOVERLAY		0x00000008
+#define DDCAPS2_CANBOBINTERLEAVED	0x00000010
+#define DDCAPS2_CANBOBNONINTERLEAVED	0x00000020
+#define DDCAPS2_COLORCONTROLOVERLAY	0x00000040
+#define DDCAPS2_COLORCONTROLPRIMARY	0x00000080
+#define DDCAPS2_CANDROPZ16BIT		0x00000100
+#define DDCAPS2_NONLOCALVIDMEM		0x00000200
+#define DDCAPS2_NONLOCALVIDMEMCAPS	0x00000400
+#define DDCAPS2_NOPAGELOCKREQUIRED	0x00000800
+#define DDCAPS2_WIDESURFACES		0x00001000
+#define DDCAPS2_CANFLIPODDEVEN		0x00002000
+#define DDCAPS2_CANBOBHARDWARE		0x00004000
+
+
+/* Set/Get Colour Key Flags */
+#define DDCKEY_COLORSPACE  0x00000001  /* Struct is single colour space */
+#define DDCKEY_DESTBLT     0x00000002  /* To be used as dest for blt */
+#define DDCKEY_DESTOVERLAY 0x00000004  /* To be used as dest for CK overlays */
+#define DDCKEY_SRCBLT      0x00000008  /* To be used as src for blt */
+#define DDCKEY_SRCOVERLAY  0x00000010  /* To be used as src for CK overlays */
+
+typedef struct _DDCOLORKEY
+{
+	DWORD	dwColorSpaceLowValue;/* low boundary of color space that is to
+                                      * be treated as Color Key, inclusive
+				      */
+	DWORD	dwColorSpaceHighValue;/* high boundary of color space that is
+                                       * to be treated as Color Key, inclusive
+				       */
+} DDCOLORKEY,*LPDDCOLORKEY;
+
+/* ddCKEYCAPS bits */
+#define DDCKEYCAPS_DESTBLT			0x00000001
+#define DDCKEYCAPS_DESTBLTCLRSPACE		0x00000002
+#define DDCKEYCAPS_DESTBLTCLRSPACEYUV		0x00000004
+#define DDCKEYCAPS_DESTBLTYUV			0x00000008
+#define DDCKEYCAPS_DESTOVERLAY			0x00000010
+#define DDCKEYCAPS_DESTOVERLAYCLRSPACE		0x00000020
+#define DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV	0x00000040
+#define DDCKEYCAPS_DESTOVERLAYONEACTIVE		0x00000080
+#define DDCKEYCAPS_DESTOVERLAYYUV		0x00000100
+#define DDCKEYCAPS_SRCBLT			0x00000200
+#define DDCKEYCAPS_SRCBLTCLRSPACE		0x00000400
+#define DDCKEYCAPS_SRCBLTCLRSPACEYUV		0x00000800
+#define DDCKEYCAPS_SRCBLTYUV			0x00001000
+#define DDCKEYCAPS_SRCOVERLAY			0x00002000
+#define DDCKEYCAPS_SRCOVERLAYCLRSPACE		0x00004000
+#define DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV	0x00008000
+#define DDCKEYCAPS_SRCOVERLAYONEACTIVE		0x00010000
+#define DDCKEYCAPS_SRCOVERLAYYUV		0x00020000
+#define DDCKEYCAPS_NOCOSTOVERLAY		0x00040000
+
+typedef struct _DDPIXELFORMAT {
+    DWORD	dwSize;                 /* 0: size of structure */
+    DWORD	dwFlags;                /* 4: pixel format flags */
+    DWORD	dwFourCC;               /* 8: (FOURCC code) */
+    union {
+	DWORD	dwRGBBitCount;          /* C: how many bits per pixel */
+	DWORD	dwYUVBitCount;          /* C: how many bits per pixel */
+	DWORD	dwZBufferBitDepth;      /* C: how many bits for z buffers */
+	DWORD	dwAlphaBitDepth;        /* C: how many bits for alpha channels*/
+    } x;
+    union {
+	DWORD	dwRBitMask;             /* 10: mask for red bit*/
+	DWORD	dwYBitMask;             /* 10: mask for Y bits*/
+    } y;
+    union {
+	DWORD	dwGBitMask;             /* 14: mask for green bits*/
+	DWORD	dwUBitMask;             /* 14: mask for U bits*/
+    } z;
+    union {
+	DWORD   dwBBitMask;             /* 18: mask for blue bits*/
+	DWORD   dwVBitMask;             /* 18: mask for V bits*/
+    } xx;
+    union {
+    	DWORD	dwRGBAlphaBitMask;	/* 1C: mask for alpha channel */
+    	DWORD	dwYUVAlphaBitMask;	/* 1C: mask for alpha channel */
+	DWORD	dwRGBZBitMask;		/* 1C: mask for Z channel */
+	DWORD	dwYUVZBitMask;		/* 1C: mask for Z channel */
+    } xy;
+    					/* 20: next structure */
+} DDPIXELFORMAT,*LPDDPIXELFORMAT;
+
+/* DDCAPS.dwFXCaps */
+#define DDFXCAPS_BLTARITHSTRETCHY	0x00000020
+#define DDFXCAPS_BLTARITHSTRETCHYN	0x00000010
+#define DDFXCAPS_BLTMIRRORLEFTRIGHT	0x00000040
+#define DDFXCAPS_BLTMIRRORUPDOWN	0x00000080
+#define DDFXCAPS_BLTROTATION		0x00000100
+#define DDFXCAPS_BLTROTATION90		0x00000200
+#define DDFXCAPS_BLTSHRINKX		0x00000400
+#define DDFXCAPS_BLTSHRINKXN		0x00000800
+#define DDFXCAPS_BLTSHRINKY		0x00001000
+#define DDFXCAPS_BLTSHRINKYN		0x00002000
+#define DDFXCAPS_BLTSTRETCHX		0x00004000
+#define DDFXCAPS_BLTSTRETCHXN		0x00008000
+#define DDFXCAPS_BLTSTRETCHY		0x00010000
+#define DDFXCAPS_BLTSTRETCHYN		0x00020000
+#define DDFXCAPS_OVERLAYARITHSTRETCHY	0x00040000
+#define DDFXCAPS_OVERLAYARITHSTRETCHYN	0x00000008
+#define DDFXCAPS_OVERLAYSHRINKX		0x00080000
+#define DDFXCAPS_OVERLAYSHRINKXN	0x00100000
+#define DDFXCAPS_OVERLAYSHRINKY		0x00200000
+#define DDFXCAPS_OVERLAYSHRINKYN	0x00400000
+#define DDFXCAPS_OVERLAYSTRETCHX	0x00800000
+#define DDFXCAPS_OVERLAYSTRETCHXN	0x01000000
+#define DDFXCAPS_OVERLAYSTRETCHY	0x02000000
+#define DDFXCAPS_OVERLAYSTRETCHYN	0x04000000
+#define DDFXCAPS_OVERLAYMIRRORLEFTRIGHT	0x08000000
+#define DDFXCAPS_OVERLAYMIRRORUPDOWN	0x10000000
+
+/* DDCAPS.dwFXAlphaCaps */
+#define DDFXALPHACAPS_BLTALPHAEDGEBLEND		0x00000001
+#define DDFXALPHACAPS_BLTALPHAPIXELS		0x00000002
+#define DDFXALPHACAPS_BLTALPHAPIXELSNEG		0x00000004
+#define DDFXALPHACAPS_BLTALPHASURFACES		0x00000008
+#define DDFXALPHACAPS_BLTALPHASURFACESNEG	0x00000010
+#define DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND	0x00000020
+#define DDFXALPHACAPS_OVERLAYALPHAPIXELS	0x00000040
+#define DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG	0x00000080
+#define DDFXALPHACAPS_OVERLAYALPHASURFACES	0x00000100
+#define DDFXALPHACAPS_OVERLAYALPHASURFACESNEG	0x00000200
+
+/* DDCAPS.dwPalCaps */
+#define DDPCAPS_4BIT			0x00000001
+#define DDPCAPS_8BITENTRIES		0x00000002
+#define DDPCAPS_8BIT			0x00000004
+#define DDPCAPS_INITIALIZE		0x00000008
+#define DDPCAPS_PRIMARYSURFACE		0x00000010
+#define DDPCAPS_PRIMARYSURFACELEFT	0x00000020
+#define DDPCAPS_ALLOW256		0x00000040
+#define DDPCAPS_VSYNC			0x00000080
+#define DDPCAPS_1BIT			0x00000100
+#define DDPCAPS_2BIT			0x00000200
+#define DDPCAPS_ALPHA                   0x00000400
+
+/* DDCAPS.dwSVCaps */
+#define DDSVCAPS_ENIGMA			0x00000001l
+#define DDSVCAPS_FLICKER		0x00000002l
+#define DDSVCAPS_REDBLUE		0x00000004l
+#define DDSVCAPS_SPLIT			0x00000008l
+
+/* BitDepths */
+#define DDBD_1				0x00004000
+#define DDBD_2				0x00002000
+#define DDBD_4				0x00001000
+#define DDBD_8				0x00000800
+#define DDBD_16				0x00000400
+#define DDBD_24				0x00000200
+#define DDBD_32				0x00000100
+
+/* DDOVERLAYFX.dwDDFX */
+#define DDOVERFX_ARITHSTRETCHY		0x00000001
+#define DDOVERFX_MIRRORLEFTRIGHT	0x00000002
+#define DDOVERFX_MIRRORUPDOWN		0x00000004
+
+/* DDCOLORKEY.dwFlags */
+#define DDPF_ALPHAPIXELS		0x00000001
+#define DDPF_ALPHA			0x00000002
+#define DDPF_FOURCC			0x00000004
+#define DDPF_PALETTEINDEXED4		0x00000008
+#define DDPF_PALETTEINDEXEDTO8		0x00000010
+#define DDPF_PALETTEINDEXED8		0x00000020
+#define DDPF_RGB			0x00000040
+#define DDPF_COMPRESSED			0x00000080
+#define DDPF_RGBTOYUV			0x00000100
+#define DDPF_YUV			0x00000200
+#define DDPF_ZBUFFER			0x00000400
+#define DDPF_PALETTEINDEXED1		0x00000800
+#define DDPF_PALETTEINDEXED2		0x00001000
+#define DDPF_ZPIXELS			0x00002000
+
+/* SetCooperativeLevel dwFlags */
+#define DDSCL_FULLSCREEN		0x00000001
+#define DDSCL_ALLOWREBOOT		0x00000002
+#define DDSCL_NOWINDOWCHANGES		0x00000004
+#define DDSCL_NORMAL			0x00000008
+#define DDSCL_EXCLUSIVE			0x00000010
+#define DDSCL_ALLOWMODEX		0x00000040
+#define DDSCL_SETFOCUSWINDOW		0x00000080
+#define DDSCL_SETDEVICEWINDOW		0x00000100
+#define DDSCL_CREATEDEVICEWINDOW	0x00000200
+
+
+/* DDSURFACEDESC.dwFlags */
+#define	DDSD_CAPS		0x00000001
+#define	DDSD_HEIGHT		0x00000002
+#define	DDSD_WIDTH		0x00000004
+#define	DDSD_PITCH		0x00000008
+#define	DDSD_BACKBUFFERCOUNT	0x00000020
+#define	DDSD_ZBUFFERBITDEPTH	0x00000040
+#define	DDSD_ALPHABITDEPTH	0x00000080
+#define	DDSD_LPSURFACE		0x00000800
+#define	DDSD_PIXELFORMAT	0x00001000
+#define	DDSD_CKDESTOVERLAY	0x00002000
+#define	DDSD_CKDESTBLT		0x00004000
+#define	DDSD_CKSRCOVERLAY	0x00008000
+#define	DDSD_CKSRCBLT		0x00010000
+#define	DDSD_MIPMAPCOUNT	0x00020000
+#define	DDSD_REFRESHRATE	0x00040000
+#define	DDSD_LINEARSIZE		0x00080000
+#define	DDSD_ALL		0x000ff9ee
+
+/* EnumSurfaces flags */
+#define DDENUMSURFACES_ALL          0x00000001
+#define DDENUMSURFACES_MATCH        0x00000002
+#define DDENUMSURFACES_NOMATCH      0x00000004
+#define DDENUMSURFACES_CANBECREATED 0x00000008
+#define DDENUMSURFACES_DOESEXIST    0x00000010
+
+/* SetDisplayMode flags */
+#define DDSDM_STANDARDVGAMODE	0x00000001
+
+/* EnumDisplayModes flags */
+#define DDEDM_REFRESHRATES	0x00000001
+#define DDEDM_STANDARDVGAMODES	0x00000002
+
+
+typedef struct _DDSURFACEDESC
+{
+	DWORD	dwSize;		/* 0: size of the DDSURFACEDESC structure*/
+	DWORD	dwFlags;	/* 4: determines what fields are valid*/
+	DWORD	dwHeight;	/* 8: height of surface to be created*/
+	DWORD	dwWidth;	/* C: width of input surface*/
+	LONG	lPitch;		/*10: distance to start of next line (return value only)*/
+	DWORD	dwBackBufferCount;/* 14: number of back buffers requested*/
+	union {
+		DWORD	dwMipMapCount;/* 18:number of mip-map levels requested*/
+		DWORD	dwZBufferBitDepth;/*18: depth of Z buffer requested*/
+		DWORD	dwRefreshRate;/* 18:refresh rate (used when display mode is described)*/
+	} x;		
+	DWORD	dwAlphaBitDepth;/* 1C:depth of alpha buffer requested*/
+	DWORD	dwReserved;	/* 20:reserved*/
+	union {
+		LPVOID	lpSurface;	/* 24:pointer to the associated surface memory*/
+		DWORD	dwLinearSize;	/* 24:Formless late-allocated optimized surface size*/
+	} y;
+	DDCOLORKEY	ddckCKDestOverlay;/* 28: CK for dest overlay use*/
+	DDCOLORKEY	ddckCKDestBlt;	/* 30: CK for destination blt use*/
+	DDCOLORKEY	ddckCKSrcOverlay;/* 38: CK for source overlay use*/
+	DDCOLORKEY	ddckCKSrcBlt;	/* 40: CK for source blt use*/
+	DDPIXELFORMAT	ddpfPixelFormat;/* 48: pixel format description of the surface*/
+	DDSCAPS		ddsCaps;	/* 68: direct draw surface caps */
+} DDSURFACEDESC,*LPDDSURFACEDESC;
+
+/* DDCOLORCONTROL.dwFlags */
+#define DDCOLOR_BRIGHTNESS	0x00000001
+#define DDCOLOR_CONTRAST	0x00000002
+#define DDCOLOR_HUE		0x00000004
+#define DDCOLOR_SATURATION	0x00000008
+#define DDCOLOR_SHARPNESS	0x00000010
+#define DDCOLOR_GAMMA		0x00000020
+#define DDCOLOR_COLORENABLE	0x00000040
+
+typedef struct {
+	DWORD	dwSize;
+	DWORD	dwFlags;
+	LONG	lBrightness;
+	LONG	lContrast;
+	LONG	lHue;
+	LONG	lSaturation;
+	LONG	lSharpness;
+	LONG	lGamma;
+	LONG	lColorEnable;
+	DWORD	dwReserved1;
+} DDCOLORCONTROL,*LPDDCOLORCONTROL;
+
+typedef BOOL (CALLBACK * LPDDENUMCALLBACKA)(GUID *, LPSTR, LPSTR, LPVOID);
+typedef BOOL (CALLBACK * LPDDENUMCALLBACKW)(GUID *, LPWSTR, LPWSTR, LPVOID);
+DECL_WINELIB_TYPE_AW(LPDDENUMCALLBACK)
+
+typedef HRESULT (CALLBACK * LPDDENUMMODESCALLBACK)(LPDDSURFACEDESC, LPVOID);
+typedef HRESULT (CALLBACK * LPDDENUMSURFACESCALLBACK)(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC, LPVOID);
+
+typedef BOOL (CALLBACK * LPDDENUMCALLBACKEXA)(GUID *, LPSTR, LPSTR, LPVOID, HMONITOR);
+typedef BOOL (CALLBACK * LPDDENUMCALLBACKEXW)(GUID *, LPWSTR, LPWSTR, LPVOID, HMONITOR);
+DECL_WINELIB_TYPE_AW(LPDDENUMCALLBACKEX)
+
+HRESULT WINAPI DirectDrawEnumerateExA( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags);
+HRESULT WINAPI DirectDrawEnumerateExW( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags);
+
+/* flags for DirectDrawEnumerateEx */
+#define DDENUM_ATTACHEDSECONDARYDEVICES	0x00000001
+#define DDENUM_DETACHEDSECONDARYDEVICES	0x00000002
+#define DDENUM_NONDISPLAYDEVICES	0x00000004
+
+typedef struct _DDBLTFX
+{
+    DWORD       dwSize;                         /* size of structure */
+    DWORD       dwDDFX;                         /* FX operations */
+    DWORD       dwROP;                          /* Win32 raster operations */
+    DWORD       dwDDROP;                        /* Raster operations new for DirectDraw */
+    DWORD       dwRotationAngle;                /* Rotation angle for blt */
+    DWORD       dwZBufferOpCode;                /* ZBuffer compares */
+    DWORD       dwZBufferLow;                   /* Low limit of Z buffer */
+    DWORD       dwZBufferHigh;                  /* High limit of Z buffer */
+    DWORD       dwZBufferBaseDest;              /* Destination base value */
+    DWORD       dwZDestConstBitDepth;           /* Bit depth used to specify Z constant for destination */
+    union
+    {
+        DWORD   dwZDestConst;                   /* Constant to use as Z buffer for dest */
+        LPDIRECTDRAWSURFACE lpDDSZBufferDest;   /* Surface to use as Z buffer for dest */
+    } x;
+    DWORD       dwZSrcConstBitDepth;            /* Bit depth used to specify Z constant for source */
+    union
+    {
+        DWORD   dwZSrcConst;                    /* Constant to use as Z buffer for src */
+        LPDIRECTDRAWSURFACE lpDDSZBufferSrc;    /* Surface to use as Z buffer for src */
+    } y;
+    DWORD       dwAlphaEdgeBlendBitDepth;       /* Bit depth used to specify constant for alpha edge blend */
+    DWORD       dwAlphaEdgeBlend;               /* Alpha for edge blending */
+    DWORD       dwReserved;
+    DWORD       dwAlphaDestConstBitDepth;       /* Bit depth used to specify alpha constant for destination */
+    union
+    {
+        DWORD   dwAlphaDestConst;               /* Constant to use as Alpha Channel */
+        LPDIRECTDRAWSURFACE lpDDSAlphaDest;     /* Surface to use as Alpha Channel */
+    } z;
+    DWORD       dwAlphaSrcConstBitDepth;        /* Bit depth used to specify alpha constant for source */
+    union
+    {
+        DWORD   dwAlphaSrcConst;                /* Constant to use as Alpha Channel */
+        LPDIRECTDRAWSURFACE lpDDSAlphaSrc;      /* Surface to use as Alpha Channel */
+    } a;
+    union
+    {
+        DWORD   dwFillColor;                    /* color in RGB or Palettized */
+        DWORD   dwFillDepth;                    /* depth value for z-buffer */
+	DWORD   dwFillPixel;			/* pixel val for RGBA or RGBZ */
+        LPDIRECTDRAWSURFACE lpDDSPattern;       /* Surface to use as pattern */
+    } b;
+    DDCOLORKEY  ddckDestColorkey;               /* DestColorkey override */
+    DDCOLORKEY  ddckSrcColorkey;                /* SrcColorkey override */
+} DDBLTFX,*LPDDBLTFX;
+
+/* dwDDFX */
+/* arithmetic stretching along y axis */
+#define DDBLTFX_ARITHSTRETCHY			0x00000001
+/* mirror on y axis */
+#define DDBLTFX_MIRRORLEFTRIGHT			0x00000002
+/* mirror on x axis */
+#define DDBLTFX_MIRRORUPDOWN			0x00000004
+/* do not tear */
+#define DDBLTFX_NOTEARING			0x00000008
+/* 180 degrees clockwise rotation */
+#define DDBLTFX_ROTATE180			0x00000010
+/* 270 degrees clockwise rotation */
+#define DDBLTFX_ROTATE270			0x00000020
+/* 90 degrees clockwise rotation */
+#define DDBLTFX_ROTATE90			0x00000040
+/* dwZBufferLow and dwZBufferHigh specify limits to the copied Z values */
+#define DDBLTFX_ZBUFFERRANGE			0x00000080
+/* add dwZBufferBaseDest to every source z value before compare */
+#define DDBLTFX_ZBUFFERBASEDEST			0x00000100
+
+typedef struct _DDOVERLAYFX
+{
+    DWORD       dwSize;                         /* size of structure */
+    DWORD       dwAlphaEdgeBlendBitDepth;       /* Bit depth used to specify constant for alpha edge blend */
+    DWORD       dwAlphaEdgeBlend;               /* Constant to use as alpha for edge blend */
+    DWORD       dwReserved;
+    DWORD       dwAlphaDestConstBitDepth;       /* Bit depth used to specify alpha constant for destination */
+    union
+    {
+        DWORD   dwAlphaDestConst;               /* Constant to use as alpha channel for dest */
+        LPDIRECTDRAWSURFACE lpDDSAlphaDest;     /* Surface to use as alpha channel for dest */
+    } x;
+    DWORD       dwAlphaSrcConstBitDepth;        /* Bit depth used to specify alpha constant for source */
+    union
+    {
+        DWORD   dwAlphaSrcConst;                /* Constant to use as alpha channel for src */
+        LPDIRECTDRAWSURFACE lpDDSAlphaSrc;      /* Surface to use as alpha channel for src */
+    } y;
+    DDCOLORKEY  dckDestColorkey;                /* DestColorkey override */
+    DDCOLORKEY  dckSrcColorkey;                 /* DestColorkey override */
+    DWORD       dwDDFX;                         /* Overlay FX */
+    DWORD       dwFlags;                        /* flags */
+} DDOVERLAYFX,*LPDDOVERLAYFX;
+
+typedef struct _DDBLTBATCH
+{
+    LPRECT		lprDest;
+    LPDIRECTDRAWSURFACE	lpDDSSrc;
+    LPRECT		lprSrc;
+    DWORD		dwFlags;
+    LPDDBLTFX		lpDDBltFx;
+} DDBLTBATCH,*LPDDBLTBATCH;
+
+#define MAX_DDDEVICEID_STRING          512
+
+typedef struct tagDDDEVICEIDENTIFIER {
+  char    szDriver[MAX_DDDEVICEID_STRING];
+  char    szDescription[MAX_DDDEVICEID_STRING];
+  LARGE_INTEGER  liDriverVersion;
+  DWORD   dwVendorId;
+  DWORD   dwDeviceId;
+  DWORD   dwSubSysId;
+  DWORD   dwRevision;
+  GUID    guidDeviceIdentifier;
+} DDDEVICEIDENTIFIER, * LPDDDEVICEIDENTIFIER;
+
+
+/*****************************************************************************
+ * IDirectDrawPalette interface
+ */
+#define ICOM_INTERFACE IDirectDrawPalette
+#define IDirectDrawPalette_METHODS \
+    ICOM_METHOD1(HRESULT,GetCaps,    LPDWORD,lpdwCaps) \
+    ICOM_METHOD4(HRESULT,GetEntries, DWORD,dwFlags, DWORD,dwBase, DWORD,dwNumEntries, LPPALETTEENTRY,lpEntries) \
+    ICOM_METHOD3(HRESULT,Initialize, LPDIRECTDRAW,lpDD, DWORD,dwFlags, LPPALETTEENTRY,lpDDColorTable) \
+    ICOM_METHOD4(HRESULT,SetEntries, DWORD,dwFlags, DWORD,dwStartingEntry, DWORD,dwCount, LPPALETTEENTRY,lpEntries)
+#define IDirectDrawPalette_IMETHODS \
+    IUnknown_IMETHODS \
+    IDirectDrawPalette_METHODS
+ICOM_DEFINE(IDirectDrawPalette,IUnknown)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+    /*** IUnknown methods ***/
+#define IDirectDrawPalette_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDrawPalette_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDrawPalette_Release(p)            ICOM_CALL (Release,p)
+    /*** IDirectDrawPalette methods ***/
+#define IDirectDrawPalette_GetCaps(p,a)          ICOM_CALL1(GetCaps,p,a)
+#define IDirectDrawPalette_GetEntries(p,a,b,c,d) ICOM_CALL4(GetEntries,p,a,b,c,d)
+#define IDirectDrawPalette_Initialize(p,a,b,c)   ICOM_CALL3(Initialize,p,a,b,c)
+#define IDirectDrawPalette_SetEntries(p,a,b,c,d) ICOM_CALL4(SetEntries,p,a,b,c,d)
+#endif
+
+
+/*****************************************************************************
+ * IDirectDrawClipper interface
+ */
+#define ICOM_INTERFACE IDirectDrawClipper
+#define IDirectDrawClipper_METHODS \
+    ICOM_METHOD3(HRESULT,GetClipList,       LPRECT,lpRect, LPRGNDATA,lpClipList, LPDWORD,lpdwSize) \
+    ICOM_METHOD1(HRESULT,GetHWnd,           HWND*,lphWnd) \
+    ICOM_METHOD2(HRESULT,Initialize,        LPDIRECTDRAW,lpDD, DWORD,dwFlags) \
+    ICOM_METHOD1(HRESULT,IsClipListChanged, BOOL*,lpbChanged) \
+    ICOM_METHOD2(HRESULT,SetClipList,       LPRGNDATA,lpClipList, DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,SetHWnd,           DWORD,dwFlags, HWND,hWnd)
+#define IDirectDrawClipper_IMETHODS \
+    IUnknown_IMETHODS \
+    IDirectDrawClipper_METHODS
+ICOM_DEFINE(IDirectDrawClipper,IUnknown)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+    /*** IUnknown methods ***/
+#define IDirectDrawClipper_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDrawClipper_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDrawClipper_Release(p)            ICOM_CALL (Release,p)
+    /*** IDirectDrawClipper methods ***/
+#define IDirectDrawClipper_GetClipList(p,a,b,c)   ICOM_CALL3(GetClipList,p,a,b,c)
+#define IDirectDrawClipper_GetHWnd(p,a)           ICOM_CALL1(GetHWnd,p,a)
+#define IDirectDrawClipper_Initialize(p,a,b)      ICOM_CALL2(Initialize,p,a,b)
+#define IDirectDrawClipper_IsClipListChanged(p,a) ICOM_CALL1(IsClipListChanged,p,a)
+#define IDirectDrawClipper_SetClipList(p,a,b)     ICOM_CALL2(SetClipList,p,a,b)
+#define IDirectDrawClipper_SetHWnd(p,a,b)         ICOM_CALL2(SetHWnd,p,a,b)
+#endif
+
+
+/*****************************************************************************
+ * IDirectDraw interface
+ */
+#define ICOM_INTERFACE IDirectDraw
+#define IDirectDraw_METHODS \
+    ICOM_METHOD (HRESULT,Compact) \
+    ICOM_METHOD3(HRESULT,CreateClipper,          DWORD,dwFlags, LPDIRECTDRAWCLIPPER*,lplpDDClipper, IUnknown*,pUnkOuter) \
+    ICOM_METHOD4(HRESULT,CreatePalette,          DWORD,dwFlags, LPPALETTEENTRY,lpColorTable, LPDIRECTDRAWPALETTE*,lplpDDPalette, IUnknown*,pUnkOuter) \
+    ICOM_METHOD3(HRESULT,CreateSurface,          LPDDSURFACEDESC,lpDDSurfaceDesc, LPDIRECTDRAWSURFACE*,lplpDDSurface, IUnknown*,pUnkOuter) \
+    ICOM_METHOD2(HRESULT,DuplicateSurface,       LPDIRECTDRAWSURFACE,lpDDSurface, LPDIRECTDRAWSURFACE*,lplpDupDDSurface) \
+    ICOM_METHOD4(HRESULT,EnumDisplayModes,       DWORD,dwFlags, LPDDSURFACEDESC,lpDDSurfaceDesc, LPVOID,lpContext, LPDDENUMMODESCALLBACK,lpEnumModesCallback) \
+    ICOM_METHOD4(HRESULT,EnumSurfaces,           DWORD,dwFlags, LPDDSURFACEDESC,lpDDSD, LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpEnumSurfacesCallback) \
+    ICOM_METHOD (HRESULT,FlipToGDISurface) \
+    ICOM_METHOD2(HRESULT,GetCaps,                LPDDCAPS,lpDDDriverCaps, LPDDCAPS,lpDDHELCaps) \
+    ICOM_METHOD1(HRESULT,GetDisplayMode,         LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD2(HRESULT,GetFourCCCodes,         LPDWORD,lpNumCodes, LPDWORD,lpCodes) \
+    ICOM_METHOD1(HRESULT,GetGDISurface,          LPDIRECTDRAWSURFACE*,lplpGDIDDSurface) \
+    ICOM_METHOD1(HRESULT,GetMonitorFrequency,    LPDWORD,lpdwFrequency) \
+    ICOM_METHOD1(HRESULT,GetScanLine,            LPDWORD,lpdwScanLine) \
+    ICOM_METHOD1(HRESULT,GetVerticalBlankStatus, BOOL*,lpbIsInVB) \
+    ICOM_METHOD1(HRESULT,Initialize,             GUID*,lpGUID) \
+    ICOM_METHOD (HRESULT,RestoreDisplayMode) \
+    ICOM_METHOD2(HRESULT,SetCooperativeLevel,    HWND,hWnd, DWORD,dwFlags) \
+    ICOM_METHOD3(HRESULT,SetDisplayMode,         DWORD,, DWORD,, DWORD,) \
+    ICOM_METHOD2(HRESULT,WaitForVerticalBlank,   DWORD,dwFlags, HANDLE,hEvent)
+#define IDirectDraw_IMETHODS \
+    IUnknown_IMETHODS \
+    IDirectDraw_METHODS
+ICOM_DEFINE(IDirectDraw,IUnknown)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+    /*** IUnknown methods ***/
+#define IDirectDraw_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDraw_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDraw_Release(p)            ICOM_CALL (Release,p)
+    /*** IDirectDraw methods ***/
+#define IDirectDraw_Compact(p)                  ICOM_CALL (Compact,p)
+#define IDirectDraw_CreateClipper(p,a,b,c)      ICOM_CALL3(CreateClipper,p,a,b,c)
+#define IDirectDraw_CreatePalette(p,a,b,c,d)    ICOM_CALL4(CreatePalette,p,a,b,c,d)
+#define IDirectDraw_CreateSurface(p,a,b,c)      ICOM_CALL3(CreateSurface,p,a,b,c)
+#define IDirectDraw_DuplicateSurface(p,a,b)     ICOM_CALL2(DuplicateSurface,p,a,b)
+#define IDirectDraw_EnumDisplayModes(p,a,b,c,d) ICOM_CALL4(EnumDisplayModes,p,a,b,c,d)
+#define IDirectDraw_EnumSurfaces(p,a,b,c,d)     ICOM_CALL4(EnumSurfaces,p,a,b,c,d)
+#define IDirectDraw_FlipToGDISurface(p)         ICOM_CALL (FlipToGDISurface,p)
+#define IDirectDraw_GetCaps(p,a,b)              ICOM_CALL2(GetCaps,p,a,b)
+#define IDirectDraw_GetDisplayMode(p,a)         ICOM_CALL1(GetDisplayMode,p,a)
+#define IDirectDraw_GetFourCCCodes(p,a,b)       ICOM_CALL2(GetFourCCCodes,p,a,b)
+#define IDirectDraw_GetGDISurface(p,a)          ICOM_CALL1(GetGDISurface,p,a)
+#define IDirectDraw_GetMonitorFrequency(p,a)    ICOM_CALL1(GetMonitorFrequency,p,a)
+#define IDirectDraw_GetScanLine(p,a)            ICOM_CALL1(GetScanLine,p,a)
+#define IDirectDraw_GetVerticalBlankStatus(p,a) ICOM_CALL1(GetVerticalBlankStatus,p,a)
+#define IDirectDraw_Initialize(p,a)             ICOM_CALL1(Initialize,p,a)
+#define IDirectDraw_RestoreDisplayMode(p)       ICOM_CALL (RestoreDisplayMode,p)
+#define IDirectDraw_SetCooperativeLevel(p,a,b)  ICOM_CALL2(SetCooperativeLevel,p,a,b)
+#define IDirectDraw_SetDisplayMode(p,a,b,c)     ICOM_CALL3(SetDisplayMode,p,a,b,c)
+#define IDirectDraw_WaitForVerticalBlank(p,a,b) ICOM_CALL2(WaitForVerticalBlank,p,a,b)
+#endif
+
+
+/* flags for Lock() */
+#define DDLOCK_SURFACEMEMORYPTR	0x00000000
+#define DDLOCK_WAIT		0x00000001
+#define DDLOCK_EVENT		0x00000002
+#define DDLOCK_READONLY		0x00000010
+#define DDLOCK_WRITEONLY	0x00000020
+#define DDLOCK_NOSYSLOCK	0x00000800
+
+
+/*****************************************************************************
+ * IDirectDraw2 interface
+ */
+/* Note: IDirectDraw2 cannot derive from IDirectDraw because the number of 
+ * arguments of SetDisplayMode has changed !
+ */
+#define ICOM_INTERFACE IDirectDraw2
+#define IDirectDraw2_METHODS \
+    ICOM_METHOD (HRESULT,Compact) \
+    ICOM_METHOD3(HRESULT,CreateClipper,          DWORD,dwFlags, LPDIRECTDRAWCLIPPER*,lplpDDClipper, IUnknown*,pUnkOuter) \
+    ICOM_METHOD4(HRESULT,CreatePalette,          DWORD,dwFlags, LPPALETTEENTRY,lpColorTable, LPDIRECTDRAWPALETTE*,lplpDDPalette, IUnknown*,pUnkOuter) \
+    ICOM_METHOD3(HRESULT,CreateSurface,          LPDDSURFACEDESC,lpDDSurfaceDesc, LPDIRECTDRAWSURFACE*,lplpDDSurface, IUnknown*,pUnkOuter) \
+    ICOM_METHOD2(HRESULT,DuplicateSurface,       LPDIRECTDRAWSURFACE,lpDDSurface, LPDIRECTDRAWSURFACE*,lplpDupDDSurface) \
+    ICOM_METHOD4(HRESULT,EnumDisplayModes,       DWORD,dwFlags, LPDDSURFACEDESC,lpDDSurfaceDesc, LPVOID,lpContext, LPDDENUMMODESCALLBACK,lpEnumModesCallback) \
+    ICOM_METHOD4(HRESULT,EnumSurfaces,           DWORD,dwFlags, LPDDSURFACEDESC,lpDDSD, LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpEnumSurfacesCallback) \
+    ICOM_METHOD (HRESULT,FlipToGDISurface) \
+    ICOM_METHOD2(HRESULT,GetCaps,                LPDDCAPS,lpDDDriverCaps, LPDDCAPS,lpDDHELCaps) \
+    ICOM_METHOD1(HRESULT,GetDisplayMode,         LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD2(HRESULT,GetFourCCCodes,         LPDWORD,lpNumCodes, LPDWORD,lpCodes) \
+    ICOM_METHOD1(HRESULT,GetGDISurface,          LPDIRECTDRAWSURFACE*,lplpGDIDDSurface) \
+    ICOM_METHOD1(HRESULT,GetMonitorFrequency,    LPDWORD,lpdwFrequency) \
+    ICOM_METHOD1(HRESULT,GetScanLine,            LPDWORD,lpdwScanLine) \
+    ICOM_METHOD1(HRESULT,GetVerticalBlankStatus, BOOL*,lpbIsInVB) \
+    ICOM_METHOD1(HRESULT,Initialize,             GUID*,lpGUID) \
+    ICOM_METHOD (HRESULT,RestoreDisplayMode) \
+    ICOM_METHOD2(HRESULT,SetCooperativeLevel,    HWND,hWnd, DWORD,dwFlags) \
+    ICOM_METHOD5(HRESULT,SetDisplayMode,         DWORD,dwWidth, DWORD,dwHeight, DWORD,dwBPP, DWORD,dwRefreshRate, DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,WaitForVerticalBlank,   DWORD,dwFlags, HANDLE,hEvent) \
+    /* added in v2 */ \
+    ICOM_METHOD3(HRESULT,GetAvailableVidMem, LPDDSCAPS,lpDDCaps, LPDWORD,lpdwTotal, LPDWORD,lpdwFree)
+#define IDirectDraw2_IMETHODS \
+    IUnknown_IMETHODS \
+    IDirectDraw2_METHODS
+ICOM_DEFINE(IDirectDraw2,IUnknown)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+    /*** IUnknown methods ***/
+#define IDirectDraw2_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDraw2_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDraw2_Release(p)            ICOM_CALL (Release,p)
+    /*** IDirectDraw methods ***/
+#define IDirectDraw2_Compact(p)                  ICOM_CALL (Compact,p)
+#define IDirectDraw2_CreateClipper(p,a,b,c)      ICOM_CALL3(CreateClipper,p,a,b,c)
+#define IDirectDraw2_CreatePalette(p,a,b,c,d)    ICOM_CALL4(CreatePalette,p,a,b,c,d)
+#define IDirectDraw2_CreateSurface(p,a,b,c)      ICOM_CALL3(CreateSurface,p,a,b,c)
+#define IDirectDraw2_DuplicateSurface(p,a,b)     ICOM_CALL2(DuplicateSurface,p,a,b)
+#define IDirectDraw2_EnumDisplayModes(p,a,b,c,d) ICOM_CALL4(EnumDisplayModes,p,a,b,c,d)
+#define IDirectDraw2_EnumSurfaces(p,a,b,c,d)     ICOM_CALL4(EnumSurfaces,p,a,b,c,d)
+#define IDirectDraw2_FlipToGDISurface(p)         ICOM_CALL (FlipToGDISurface,p)
+#define IDirectDraw2_GetCaps(p,a,b)              ICOM_CALL2(GetCaps,p,a,b)
+#define IDirectDraw2_GetDisplayMode(p,a)         ICOM_CALL1(GetDisplayMode,p,a)
+#define IDirectDraw2_GetFourCCCodes(p,a,b)       ICOM_CALL2(GetFourCCCodes,p,a,b)
+#define IDirectDraw2_GetGDISurface(p,a)          ICOM_CALL1(GetGDISurface,p,a)
+#define IDirectDraw2_GetMonitorFrequency(p,a)    ICOM_CALL1(GetMonitorFrequency,p,a)
+#define IDirectDraw2_GetScanLine(p,a)            ICOM_CALL1(GetScanLine,p,a)
+#define IDirectDraw2_GetVerticalBlankStatus(p,a) ICOM_CALL1(GetVerticalBlankStatus,p,a)
+#define IDirectDraw2_Initialize(p,a)             ICOM_CALL1(Initialize,p,a)
+#define IDirectDraw2_RestoreDisplayMode(p)       ICOM_CALL (RestoreDisplayMode,p)
+#define IDirectDraw2_SetCooperativeLevel(p,a,b)  ICOM_CALL2(SetCooperativeLevel,p,a,b)
+#define IDirectDraw2_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL5(SetDisplayMode,p,a,b,c,d,e)
+#define IDirectDraw2_WaitForVerticalBlank(p,a,b) ICOM_CALL2(WaitForVerticalBlank,p,a,b)
+/*** IDirectDraw2 methods ***/
+#define IDirectDraw2_GetAvailableVidMem(p,a,b,c) ICOM_CALL3(GetAvailableVidMem,p,a,b,c)
+#endif
+
+
+/*****************************************************************************
+ * IDirectDraw4 interface
+ */
+#define ICOM_INTERFACE IDirectDraw4
+#define IDirectDraw4_METHODS \
+    ICOM_METHOD2(HRESULT,GetSurfaceFromDC,    HDC,, LPDIRECTDRAWSURFACE*,) \
+    ICOM_METHOD (HRESULT,RestoreAllSurfaces) \
+    ICOM_METHOD (HRESULT,TestCooperativeLevel) \
+    ICOM_METHOD2(HRESULT,GetDeviceIdentifier, LPDDDEVICEIDENTIFIER,, DWORD,)
+#define IDirectDraw4_IMETHODS \
+    IDirectDraw2_IMETHODS \
+    IDirectDraw4_METHODS
+ICOM_DEFINE(IDirectDraw4,IDirectDraw2)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+    /*** IUnknown methods ***/
+#define IDirectDraw4_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDraw4_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDraw4_Release(p)            ICOM_CALL (Release,p)
+    /*** IDirectDraw methods ***/
+#define IDirectDraw4_Compact(p)                  ICOM_CALL (Compact,p)
+#define IDirectDraw4_CreateClipper(p,a,b,c)      ICOM_CALL3(CreateClipper,p,a,b,c)
+#define IDirectDraw4_CreatePalette(p,a,b,c,d)    ICOM_CALL4(CreatePalette,p,a,b,c,d)
+#define IDirectDraw4_CreateSurface(p,a,b,c)      ICOM_CALL3(CreateSurface,p,a,b,c)
+#define IDirectDraw4_DuplicateSurface(p,a,b)     ICOM_CALL2(DuplicateSurface,p,a,b)
+#define IDirectDraw4_EnumDisplayModes(p,a,b,c,d) ICOM_CALL4(EnumDisplayModes,p,a,b,c,d)
+#define IDirectDraw4_EnumSurfaces(p,a,b,c,d)     ICOM_CALL4(EnumSurfaces,p,a,b,c,d)
+#define IDirectDraw4_FlipToGDISurface(p)         ICOM_CALL (FlipToGDISurface,p)
+#define IDirectDraw4_GetCaps(p,a,b)              ICOM_CALL2(GetCaps,p,a,b)
+#define IDirectDraw4_GetDisplayMode(p,a)         ICOM_CALL1(GetDisplayMode,p,a)
+#define IDirectDraw4_GetFourCCCodes(p,a,b)       ICOM_CALL2(GetFourCCCodes,p,a,b)
+#define IDirectDraw4_GetGDISurface(p,a)          ICOM_CALL1(GetGDISurface,p,a)
+#define IDirectDraw4_GetMonitorFrequency(p,a)    ICOM_CALL1(GetMonitorFrequency,p,a)
+#define IDirectDraw4_GetScanLine(p,a)            ICOM_CALL1(GetScanLine,p,a)
+#define IDirectDraw4_GetVerticalBlankStatus(p,a) ICOM_CALL1(GetVerticalBlankStatus,p,a)
+#define IDirectDraw4_Initialize(p,a)             ICOM_CALL1(Initialize,p,a)
+#define IDirectDraw4_RestoreDisplayMode(p)       ICOM_CALL (RestoreDisplayMode,p)
+#define IDirectDraw4_SetCooperativeLevel(p,a,b)  ICOM_CALL2(SetCooperativeLevel,p,a,b)
+#define IDirectDraw4_SetDisplayMode(p,a,b,c)     ICOM_CALL3(SetDisplayMode,p,a,b,c)
+#define IDirectDraw4_WaitForVerticalBlank(p,a,b) ICOM_CALL2(WaitForVerticalBlank,p,a,b)
+/*** IDirectDraw2 methods ***/
+#define IDirectDraw4_GetAvailableVidMem(p,a,b,c) ICOM_CALL3(GetAvailableVidMem,p,a,b,c)
+/*** IDirectDraw4 methods ***/
+#define IDirectDraw4_GetSurfaceFromDC(p,a,b)    ICOM_CALL2(GetSurfaceFromDC,p,a,b,c)
+#define IDirectDraw4_RestoreAllSurfaces(pc)     ICOM_CALL (RestoreAllSurfaces,p)
+#define IDirectDraw4_TestCooperativeLevel(p)    ICOM_CALL (TestCooperativeLevel,p)
+#define IDirectDraw4_GetDeviceIdentifier(p,a,b) ICOM_CALL2(GetDeviceIdentifier,p,a,b)
+#endif
+
+
+/*****************************************************************************
+ * IDirectDrawSurface interface
+ */
+#define ICOM_INTERFACE IDirectDrawSurface
+#define IDirectDrawSurface_METHODS \
+    ICOM_METHOD1(HRESULT,AddAttachedSurface,    LPDIRECTDRAWSURFACE,lpDDSAttachedSurface) \
+    ICOM_METHOD1(HRESULT,AddOverlayDirtyRect,   LPRECT,lpRect) \
+    ICOM_METHOD5(HRESULT,Blt,                   LPRECT,lpDestRect, LPDIRECTDRAWSURFACE,lpDDSrcSurface, LPRECT,lpSrcRect, DWORD,dwFlags, LPDDBLTFX,lpDDBltFx) \
+    ICOM_METHOD3(HRESULT,BltBatch,              LPDDBLTBATCH,lpDDBltBatch, DWORD,dwCount, DWORD,dwFlags) \
+    ICOM_METHOD5(HRESULT,BltFast,               DWORD,dwX, DWORD,dwY, LPDIRECTDRAWSURFACE,lpDDSrcSurface, LPRECT,lpSrcRect, DWORD,dwTrans) \
+    ICOM_METHOD2(HRESULT,DeleteAttachedSurface, DWORD,dwFlags, LPDIRECTDRAWSURFACE,lpDDSAttachedSurface) \
+    ICOM_METHOD2(HRESULT,EnumAttachedSurfaces,  LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpEnumSurfacesCallback) \
+    ICOM_METHOD3(HRESULT,EnumOverlayZOrders,    DWORD,dwFlags, LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpfnCallback) \
+    ICOM_METHOD2(HRESULT,Flip,                  LPDIRECTDRAWSURFACE,lpDDSurfaceTargetOverride, DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,GetAttachedSurface,    LPDDSCAPS,lpDDSCaps, LPDIRECTDRAWSURFACE*,lplpDDAttachedSurface) \
+    ICOM_METHOD1(HRESULT,GetBltStatus,          DWORD,dwFlags) \
+    ICOM_METHOD1(HRESULT,GetCaps,               LPDDSCAPS,lpDDSCaps) \
+    ICOM_METHOD1(HRESULT,GetClipper,            LPDIRECTDRAWCLIPPER*,lplpDDClipper) \
+    ICOM_METHOD2(HRESULT,GetColorKey,           DWORD,dwFlags, LPDDCOLORKEY,lpDDColorKey) \
+    ICOM_METHOD1(HRESULT,GetDC,                 HDC*,lphDC) \
+    ICOM_METHOD1(HRESULT,GetFlipStatus,         DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,GetOverlayPosition,    LPLONG,lplX, LPLONG,lplY) \
+    ICOM_METHOD1(HRESULT,GetPalette,            LPDIRECTDRAWPALETTE*,lplpDDPalette) \
+    ICOM_METHOD1(HRESULT,GetPixelFormat,        LPDDPIXELFORMAT,lpDDPixelFormat) \
+    ICOM_METHOD1(HRESULT,GetSurfaceDesc,        LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD2(HRESULT,Initialize,            LPDIRECTDRAW,lpDD, LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD (HRESULT,IsLost) \
+    ICOM_METHOD4(HRESULT,Lock,                  LPRECT,lpDestRect, LPDDSURFACEDESC,lpDDSurfaceDesc, DWORD,dwFlags, HANDLE,hEvent) \
+    ICOM_METHOD1(HRESULT,ReleaseDC,             HDC,hDC) \
+    ICOM_METHOD (HRESULT,Restore) \
+    ICOM_METHOD1(HRESULT,SetClipper,            LPDIRECTDRAWCLIPPER,lpDDClipper) \
+    ICOM_METHOD2(HRESULT,SetColorKey,           DWORD,dwFlags, LPDDCOLORKEY,lpDDColorKey) \
+    ICOM_METHOD2(HRESULT,SetOverlayPosition,    LONG,lX, LONG,lY) \
+    ICOM_METHOD1(HRESULT,SetPalette,            LPDIRECTDRAWPALETTE,lpDDPalette) \
+    ICOM_METHOD1(HRESULT,Unlock,                LPVOID,lpSurfaceData) \
+    ICOM_METHOD5(HRESULT,UpdateOverlay,         LPRECT,lpSrcRect, LPDIRECTDRAWSURFACE,lpDDDestSurface, LPRECT,lpDestRect, DWORD,dwFlags, LPDDOVERLAYFX,lpDDOverlayFx) \
+    ICOM_METHOD1(HRESULT,UpdateOverlayDisplay,  DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,UpdateOverlayZOrder,   DWORD,dwFlags, LPDIRECTDRAWSURFACE,lpDDSReference)
+#define IDirectDrawSurface_IMETHODS \
+    IUnknown_IMETHODS \
+    IDirectDrawSurface_METHODS
+ICOM_DEFINE(IDirectDrawSurface,IUnknown)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+    /*** IUnknown methods ***/
+#define IDirectDrawSurface_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDrawSurface_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDrawSurface_Release(p)            ICOM_CALL (Release,p)
+    /*** IDirectDrawSurface methods ***/
+#define IDirectDrawSurface_AddAttachedSurface(p,a)      ICOM_CALL1(AddAttachedSurface,p,a)
+#define IDirectDrawSurface_AddOverlayDirtyRect(p,a)     ICOM_CALL1(AddOverlayDirtyRect,p,a)
+#define IDirectDrawSurface_Blt(p,a,b,c,d,e)             ICOM_CALL5(Blt,p,a,b,c,d,e)
+#define IDirectDrawSurface_BltBatch(p,a,b,c)            ICOM_CALL3(BltBatch,p,a,b,c)
+#define IDirectDrawSurface_BltFast(p,a,b,c,d,e)         ICOM_CALL5(BltFast,p,a,b,c,d,e)
+#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) ICOM_CALL2(DeleteAttachedSurface,p,a,b)
+#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b)  ICOM_CALL2(EnumAttachedSurfaces,p,a,b)
+#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c)  ICOM_CALL3(EnumOverlayZOrders,p,a,b,c)
+#define IDirectDrawSurface_Flip(p,a,b)                  ICOM_CALL2(Flip,p,a,b)
+#define IDirectDrawSurface_GetAttachedSurface(p,a,b)    ICOM_CALL2(GetAttachedSurface,p,a,b)
+#define IDirectDrawSurface_GetBltStatus(p,a)            ICOM_CALL1(GetBltStatus,p,a)
+#define IDirectDrawSurface_GetCaps(p,a)                 ICOM_CALL1(GetCaps,p,a)
+#define IDirectDrawSurface_GetClipper(p,a)              ICOM_CALL1(GetClipper,p,a)
+#define IDirectDrawSurface_GetColorKey(p,a,b)           ICOM_CALL2(GetColorKey,p,a,b)
+#define IDirectDrawSurface_GetDC(p,a)                   ICOM_CALL1(GetDC,p,a)
+#define IDirectDrawSurface_GetFlipStatus(p,a)           ICOM_CALL1(GetFlipStatus,p,a)
+#define IDirectDrawSurface_GetOverlayPosition(p,a,b)    ICOM_CALL2(GetOverlayPosition,p,a,b)
+#define IDirectDrawSurface_GetPalette(p,a)              ICOM_CALL1(GetPalette,p,a)
+#define IDirectDrawSurface_GetPixelFormat(p,a)          ICOM_CALL1(GetPixelFormat,p,a)
+#define IDirectDrawSurface_GetSurfaceDesc(p,a)          ICOM_CALL1(GetSurfaceDesc,p,a)
+#define IDirectDrawSurface_Initialize(p,a,b)            ICOM_CALL2(Initialize,p,a,b)
+#define IDirectDrawSurface_IsLost(p)                    ICOM_CALL (IsLost,p)
+#define IDirectDrawSurface_Lock(p,a,b,c,d)              ICOM_CALL4(Lock,p,a,b,c,d)
+#define IDirectDrawSurface_ReleaseDC(p,a)               ICOM_CALL1(ReleaseDC,p,a)
+#define IDirectDrawSurface_Restore(p,a,b)               ICOM_CALL (Restore,p,a,b)
+#define IDirectDrawSurface_SetClipper(p,a,b)            ICOM_CALL1(SetClipper,p,a,b)
+#define IDirectDrawSurface_SetColorKey(p,a,b)           ICOM_CALL2(SetColorKey,p,a,b)
+#define IDirectDrawSurface_SetOverlayPosition(p,a,b)    ICOM_CALL2(SetOverlayPosition,p,a,b)
+#define IDirectDrawSurface_SetPalette(p,a)              ICOM_CALL1(SetPalette,p,a)
+#define IDirectDrawSurface_Unlock(p,a)                  ICOM_CALL1(Unlock,p,a)
+#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e)   ICOM_CALL5(UpdateOverlay,p,a,b,c,d,e)
+#define IDirectDrawSurface_UpdateOverlayDisplay(p,a)    ICOM_CALL1(UpdateOverlayDisplay,p,a)
+#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b)   ICOM_CALL2(UpdateOverlayZOrder,p,a,b)
+#endif
+
+
+/*****************************************************************************
+ * IDirectDrawSurface2 interface
+ */
+/* Cannot inherit from IDirectDrawSurface because the LPDIRECTDRAWSURFACE parameters 
+ * have been converted to LPDIRECTDRAWSURFACE2.
+ */
+#define ICOM_INTERFACE IDirectDrawSurface2
+#define IDirectDrawSurface2_METHODS \
+    ICOM_METHOD1(HRESULT,AddAttachedSurface,    LPDIRECTDRAWSURFACE2,lpDDSAttachedSurface) \
+    ICOM_METHOD1(HRESULT,AddOverlayDirtyRect,   LPRECT,lpRect) \
+    ICOM_METHOD5(HRESULT,Blt,                   LPRECT,lpDestRect, LPDIRECTDRAWSURFACE2,lpDDSrcSurface, LPRECT,lpSrcRect, DWORD,dwFlags, LPDDBLTFX,lpDDBltFx) \
+    ICOM_METHOD3(HRESULT,BltBatch,              LPDDBLTBATCH,lpDDBltBatch, DWORD,dwCount, DWORD,dwFlags) \
+    ICOM_METHOD5(HRESULT,BltFast,               DWORD,dwX, DWORD,dwY, LPDIRECTDRAWSURFACE2,lpDDSrcSurface, LPRECT,lpSrcRect, DWORD,dwTrans) \
+    ICOM_METHOD2(HRESULT,DeleteAttachedSurface, DWORD,dwFlags, LPDIRECTDRAWSURFACE2,lpDDSAttachedSurface) \
+    ICOM_METHOD2(HRESULT,EnumAttachedSurfaces,  LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpEnumSurfacesCallback) \
+    ICOM_METHOD3(HRESULT,EnumOverlayZOrders,    DWORD,dwFlags, LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpfnCallback) \
+    ICOM_METHOD2(HRESULT,Flip,                  LPDIRECTDRAWSURFACE2,lpDDSurfaceTargetOverride, DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,GetAttachedSurface,    LPDDSCAPS,lpDDSCaps, LPDIRECTDRAWSURFACE2*,lplpDDAttachedSurface) \
+    ICOM_METHOD1(HRESULT,GetBltStatus,          DWORD,dwFlags) \
+    ICOM_METHOD1(HRESULT,GetCaps,               LPDDSCAPS,lpDDSCaps) \
+    ICOM_METHOD1(HRESULT,GetClipper,            LPDIRECTDRAWCLIPPER*,lplpDDClipper) \
+    ICOM_METHOD2(HRESULT,GetColorKey,           DWORD,dwFlags, LPDDCOLORKEY,lpDDColorKey) \
+    ICOM_METHOD1(HRESULT,GetDC,                 HDC*,lphDC) \
+    ICOM_METHOD1(HRESULT,GetFlipStatus,         DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,GetOverlayPosition,    LPLONG,lplX, LPLONG,lplY) \
+    ICOM_METHOD1(HRESULT,GetPalette,            LPDIRECTDRAWPALETTE*,lplpDDPalette) \
+    ICOM_METHOD1(HRESULT,GetPixelFormat,        LPDDPIXELFORMAT,lpDDPixelFormat) \
+    ICOM_METHOD1(HRESULT,GetSurfaceDesc,        LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD2(HRESULT,Initialize,            LPDIRECTDRAW,lpDD, LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD (HRESULT,IsLost) \
+    ICOM_METHOD4(HRESULT,Lock,                  LPRECT,lpDestRect, LPDDSURFACEDESC,lpDDSurfaceDesc, DWORD,dwFlags, HANDLE,hEvent) \
+    ICOM_METHOD1(HRESULT,ReleaseDC,             HDC,hDC) \
+    ICOM_METHOD (HRESULT,Restore) \
+    ICOM_METHOD1(HRESULT,SetClipper,            LPDIRECTDRAWCLIPPER,lpDDClipper) \
+    ICOM_METHOD2(HRESULT,SetColorKey,           DWORD,dwFlags, LPDDCOLORKEY,lpDDColorKey) \
+    ICOM_METHOD2(HRESULT,SetOverlayPosition,    LONG,lX, LONG,lY) \
+    ICOM_METHOD1(HRESULT,SetPalette,            LPDIRECTDRAWPALETTE,lpDDPalette) \
+    ICOM_METHOD1(HRESULT,Unlock,                LPVOID,lpSurfaceData) \
+    ICOM_METHOD5(HRESULT,UpdateOverlay,         LPRECT,lpSrcRect, LPDIRECTDRAWSURFACE2,lpDDDestSurface, LPRECT,lpDestRect, DWORD,dwFlags, LPDDOVERLAYFX,lpDDOverlayFx) \
+    ICOM_METHOD1(HRESULT,UpdateOverlayDisplay,  DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,UpdateOverlayZOrder,   DWORD,dwFlags, LPDIRECTDRAWSURFACE2,lpDDSReference) \
+    /* added in v2 */ \
+    ICOM_METHOD1(HRESULT,GetDDInterface, LPVOID*,lplpDD) \
+    ICOM_METHOD1(HRESULT,PageLock,       DWORD,dwFlags) \
+    ICOM_METHOD1(HRESULT,PageUnlock,     DWORD,dwFlags)
+#define IDirectDrawSurface2_IMETHODS \
+    IUnknown_IMETHODS \
+    IDirectDrawSurface2_METHODS
+ICOM_DEFINE(IDirectDrawSurface2,IUnknown)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+    /*** IUnknown methods ***/
+#define IDirectDrawSurface2_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDrawSurface2_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDrawSurface2_Release(p)            ICOM_CALL (Release,p)
+/*** IDirectDrawSurface methods (almost) ***/
+#define IDirectDrawSurface2_AddAttachedSurface(p,a)      ICOM_CALL1(AddAttachedSurface,p,a)
+#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a)     ICOM_CALL1(AddOverlayDirtyRect,p,a)
+#define IDirectDrawSurface2_Blt(p,a,b,c,d,e)             ICOM_CALL5(Blt,p,a,b,c,d,e)
+#define IDirectDrawSurface2_BltBatch(p,a,b,c)            ICOM_CALL3(BltBatch,p,a,b,c)
+#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e)         ICOM_CALL5(BltFast,p,a,b,c,d,e)
+#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) ICOM_CALL2(DeleteAttachedSurface,p,a,b)
+#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b)  ICOM_CALL2(EnumAttachedSurfaces,p,a,b)
+#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c)  ICOM_CALL3(EnumOverlayZOrders,p,a,b,c)
+#define IDirectDrawSurface2_Flip(p,a,b)                  ICOM_CALL2(Flip,p,a,b)
+#define IDirectDrawSurface2_GetAttachedSurface(p,a,b)    ICOM_CALL2(GetAttachedSurface,p,a,b)
+#define IDirectDrawSurface2_GetBltStatus(p,a)            ICOM_CALL1(GetBltStatus,p,a)
+#define IDirectDrawSurface2_GetCaps(p,a)                 ICOM_CALL1(GetCaps,p,a)
+#define IDirectDrawSurface2_GetClipper(p,a)              ICOM_CALL1(GetClipper,p,a)
+#define IDirectDrawSurface2_GetColorKey(p,a,b)           ICOM_CALL2(GetColorKey,p,a,b)
+#define IDirectDrawSurface2_GetDC(p,a)                   ICOM_CALL1(GetDC,p,a)
+#define IDirectDrawSurface2_GetFlipStatus(p,a)           ICOM_CALL1(GetFlipStatus,p,a)
+#define IDirectDrawSurface2_GetOverlayPosition(p,a,b)    ICOM_CALL2(GetOverlayPosition,p,a,b)
+#define IDirectDrawSurface2_GetPalette(p,a)              ICOM_CALL1(GetPalette,p,a)
+#define IDirectDrawSurface2_GetPixelFormat(p,a)          ICOM_CALL1(GetPixelFormat,p,a)
+#define IDirectDrawSurface2_GetSurfaceDesc(p,a)          ICOM_CALL1(GetSurfaceDesc,p,a)
+#define IDirectDrawSurface2_Initialize(p,a,b)            ICOM_CALL2(Initialize,p,a,b)
+#define IDirectDrawSurface2_IsLost(p)                    ICOM_CALL (IsLost,p)
+#define IDirectDrawSurface2_Lock(p,a,b,c,d)              ICOM_CALL4(Lock,p,a,b,c,d)
+#define IDirectDrawSurface2_ReleaseDC(p,a)               ICOM_CALL1(ReleaseDC,p,a)
+#define IDirectDrawSurface2_Restore(p,a,b)               ICOM_CALL (Restore,p,a,b)
+#define IDirectDrawSurface2_SetClipper(p,a,b)            ICOM_CALL1(SetClipper,p,a,b)
+#define IDirectDrawSurface2_SetColorKey(p,a,b)           ICOM_CALL2(SetColorKey,p,a,b)
+#define IDirectDrawSurface2_SetOverlayPosition(p,a,b)    ICOM_CALL2(SetOverlayPosition,p,a,b)
+#define IDirectDrawSurface2_SetPalette(p,a)              ICOM_CALL1(SetPalette,p,a)
+#define IDirectDrawSurface2_Unlock(p,a)                  ICOM_CALL1(Unlock,p,a)
+#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e)   ICOM_CALL5(UpdateOverlay,p,a,b,c,d,e)
+#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a)    ICOM_CALL1(UpdateOverlayDisplay,p,a)
+#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b)   ICOM_CALL2(UpdateOverlayZOrder,p,a,b)
+/*** IDirectDrawSurface2 methods ***/
+#define IDirectDrawSurface2_GetDDInterface(p,a) ICOM_CALL1(GetDDInterface,p,a)
+#define IDirectDrawSurface2_PageLock(p,a)       ICOM_CALL1(PageLock,p,a)
+#define IDirectDrawSurface2_PageUnlock(p,a)     ICOM_CALL1(PageUnlock,p,a)
+#endif
+
+
+/*****************************************************************************
+ * IDirectDrawSurface3 interface
+ */
+/* Cannot inherit from IDirectDrawSurface2 because the LPDIRECTDRAWSURFACE2 parameters 
+ * have been converted to LPDIRECTDRAWSURFACE3.
+ */
+#define ICOM_INTERFACE IDirectDrawSurface3
+#define IDirectDrawSurface3_METHODS \
+    ICOM_METHOD1(HRESULT,AddAttachedSurface,    LPDIRECTDRAWSURFACE3,lpDDSAttachedSurface) \
+    ICOM_METHOD1(HRESULT,AddOverlayDirtyRect,   LPRECT,lpRect) \
+    ICOM_METHOD5(HRESULT,Blt,                   LPRECT,lpDestRect, LPDIRECTDRAWSURFACE3,lpDDSrcSurface, LPRECT,lpSrcRect, DWORD,dwFlags, LPDDBLTFX,lpDDBltFx) \
+    ICOM_METHOD3(HRESULT,BltBatch,              LPDDBLTBATCH,lpDDBltBatch, DWORD,dwCount, DWORD,dwFlags) \
+    ICOM_METHOD5(HRESULT,BltFast,               DWORD,dwX, DWORD,dwY, LPDIRECTDRAWSURFACE3,lpDDSrcSurface, LPRECT,lpSrcRect, DWORD,dwTrans) \
+    ICOM_METHOD2(HRESULT,DeleteAttachedSurface, DWORD,dwFlags, LPDIRECTDRAWSURFACE3,lpDDSAttachedSurface) \
+    ICOM_METHOD2(HRESULT,EnumAttachedSurfaces,  LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpEnumSurfacesCallback) \
+    ICOM_METHOD3(HRESULT,EnumOverlayZOrders,    DWORD,dwFlags, LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpfnCallback) \
+    ICOM_METHOD2(HRESULT,Flip,                  LPDIRECTDRAWSURFACE3,lpDDSurfaceTargetOverride, DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,GetAttachedSurface,    LPDDSCAPS,lpDDSCaps, LPDIRECTDRAWSURFACE3*,lplpDDAttachedSurface) \
+    ICOM_METHOD1(HRESULT,GetBltStatus,          DWORD,dwFlags) \
+    ICOM_METHOD1(HRESULT,GetCaps,               LPDDSCAPS,lpDDSCaps) \
+    ICOM_METHOD1(HRESULT,GetClipper,            LPDIRECTDRAWCLIPPER*,lplpDDClipper) \
+    ICOM_METHOD2(HRESULT,GetColorKey,           DWORD,dwFlags, LPDDCOLORKEY,lpDDColorKey) \
+    ICOM_METHOD1(HRESULT,GetDC,                 HDC*,lphDC) \
+    ICOM_METHOD1(HRESULT,GetFlipStatus,         DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,GetOverlayPosition,    LPLONG,lplX, LPLONG,lplY) \
+    ICOM_METHOD1(HRESULT,GetPalette,            LPDIRECTDRAWPALETTE*,lplpDDPalette) \
+    ICOM_METHOD1(HRESULT,GetPixelFormat,        LPDDPIXELFORMAT,lpDDPixelFormat) \
+    ICOM_METHOD1(HRESULT,GetSurfaceDesc,        LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD2(HRESULT,Initialize,            LPDIRECTDRAW,lpDD, LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD (HRESULT,IsLost) \
+    ICOM_METHOD4(HRESULT,Lock,                  LPRECT,lpDestRect, LPDDSURFACEDESC,lpDDSurfaceDesc, DWORD,dwFlags, HANDLE,hEvent) \
+    ICOM_METHOD1(HRESULT,ReleaseDC,             HDC,hDC) \
+    ICOM_METHOD (HRESULT,Restore) \
+    ICOM_METHOD1(HRESULT,SetClipper,            LPDIRECTDRAWCLIPPER,lpDDClipper) \
+    ICOM_METHOD2(HRESULT,SetColorKey,           DWORD,dwFlags, LPDDCOLORKEY,lpDDColorKey) \
+    ICOM_METHOD2(HRESULT,SetOverlayPosition,    LONG,lX, LONG,lY) \
+    ICOM_METHOD1(HRESULT,SetPalette,            LPDIRECTDRAWPALETTE,lpDDPalette) \
+    ICOM_METHOD1(HRESULT,Unlock,                LPVOID,lpSurfaceData) \
+    ICOM_METHOD5(HRESULT,UpdateOverlay,         LPRECT,lpSrcRect, LPDIRECTDRAWSURFACE3,lpDDDestSurface, LPRECT,lpDestRect, DWORD,dwFlags, LPDDOVERLAYFX,lpDDOverlayFx) \
+    ICOM_METHOD1(HRESULT,UpdateOverlayDisplay,  DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,UpdateOverlayZOrder,   DWORD,dwFlags, LPDIRECTDRAWSURFACE3,lpDDSReference) \
+    /* added in v2 */ \
+    ICOM_METHOD1(HRESULT,GetDDInterface, LPVOID*,lplpDD) \
+    ICOM_METHOD1(HRESULT,PageLock,       DWORD,dwFlags) \
+    ICOM_METHOD1(HRESULT,PageUnlock,     DWORD,dwFlags) \
+    /* added in v3 */ \
+    ICOM_METHOD2(HRESULT,SetSurfaceDesc, LPDDSURFACEDESC,lpDDSD, DWORD,dwFlags)
+#define IDirectDrawSurface3_IMETHODS \
+    IUnknown_IMETHODS \
+    IDirectDrawSurface3_METHODS
+ICOM_DEFINE(IDirectDrawSurface3,IUnknown)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+    /*** IUnknown methods ***/
+#define IDirectDrawSurface3_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDrawSurface3_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDrawSurface3_Release(p)            ICOM_CALL (Release,p)
+/*** IDirectDrawSurface methods (almost) ***/
+#define IDirectDrawSurface3_AddAttachedSurface(p,a)      ICOM_CALL1(AddAttachedSurface,p,a)
+#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a)     ICOM_CALL1(AddOverlayDirtyRect,p,a)
+#define IDirectDrawSurface3_Blt(p,a,b,c,d,e)             ICOM_CALL5(Blt,p,a,b,c,d,e)
+#define IDirectDrawSurface3_BltBatch(p,a,b,c)            ICOM_CALL3(BltBatch,p,a,b,c)
+#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e)         ICOM_CALL5(BltFast,p,a,b,c,d,e)
+#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) ICOM_CALL2(DeleteAttachedSurface,p,a,b)
+#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b)  ICOM_CALL2(EnumAttachedSurfaces,p,a,b)
+#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c)  ICOM_CALL3(EnumOverlayZOrders,p,a,b,c)
+#define IDirectDrawSurface3_Flip(p,a,b)                  ICOM_CALL2(Flip,p,a,b)
+#define IDirectDrawSurface3_GetAttachedSurface(p,a,b)    ICOM_CALL2(GetAttachedSurface,p,a,b)
+#define IDirectDrawSurface3_GetBltStatus(p,a)            ICOM_CALL1(GetBltStatus,p,a)
+#define IDirectDrawSurface3_GetCaps(p,a)                 ICOM_CALL1(GetCaps,p,a)
+#define IDirectDrawSurface3_GetClipper(p,a)              ICOM_CALL1(GetClipper,p,a)
+#define IDirectDrawSurface3_GetColorKey(p,a,b)           ICOM_CALL2(GetColorKey,p,a,b)
+#define IDirectDrawSurface3_GetDC(p,a)                   ICOM_CALL1(GetDC,p,a)
+#define IDirectDrawSurface3_GetFlipStatus(p,a)           ICOM_CALL1(GetFlipStatus,p,a)
+#define IDirectDrawSurface3_GetOverlayPosition(p,a,b)    ICOM_CALL2(GetOverlayPosition,p,a,b)
+#define IDirectDrawSurface3_GetPalette(p,a)              ICOM_CALL1(GetPalette,p,a)
+#define IDirectDrawSurface3_GetPixelFormat(p,a)          ICOM_CALL1(GetPixelFormat,p,a)
+#define IDirectDrawSurface3_GetSurfaceDesc(p,a)          ICOM_CALL1(GetSurfaceDesc,p,a)
+#define IDirectDrawSurface3_Initialize(p,a,b)            ICOM_CALL2(Initialize,p,a,b)
+#define IDirectDrawSurface3_IsLost(p)                    ICOM_CALL (IsLost,p)
+#define IDirectDrawSurface3_Lock(p,a,b,c,d)              ICOM_CALL4(Lock,p,a,b,c,d)
+#define IDirectDrawSurface3_ReleaseDC(p,a)               ICOM_CALL1(ReleaseDC,p,a)
+#define IDirectDrawSurface3_Restore(p,a,b)               ICOM_CALL (Restore,p,a,b)
+#define IDirectDrawSurface3_SetClipper(p,a,b)            ICOM_CALL1(SetClipper,p,a,b)
+#define IDirectDrawSurface3_SetColorKey(p,a,b)           ICOM_CALL2(SetColorKey,p,a,b)
+#define IDirectDrawSurface3_SetOverlayPosition(p,a,b)    ICOM_CALL2(SetOverlayPosition,p,a,b)
+#define IDirectDrawSurface3_SetPalette(p,a)              ICOM_CALL1(SetPalette,p,a)
+#define IDirectDrawSurface3_Unlock(p,a)                  ICOM_CALL1(Unlock,p,a)
+#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e)   ICOM_CALL5(UpdateOverlay,p,a,b,c,d,e)
+#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a)    ICOM_CALL1(UpdateOverlayDisplay,p,a)
+#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b)   ICOM_CALL2(UpdateOverlayZOrder,p,a,b)
+/*** IDirectDrawSurface2 methods ***/
+#define IDirectDrawSurface3_GetDDInterface(p,a) ICOM_CALL1(GetDDInterface,p,a)
+#define IDirectDrawSurface3_PageLock(p,a)       ICOM_CALL1(PageLock,p,a)
+#define IDirectDrawSurface3_PageUnlock(p,a)     ICOM_CALL1(PageUnlock,p,a)
+/*** IDirectDrawSurface3 methods ***/
+#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) ICOM_CALL2(SetSurfaceDesc,p,a,b)
+#endif
+
+
+/*****************************************************************************
+ * IDirectDrawSurface4 interface
+ */
+/* Cannot inherit from IDirectDrawSurface2 because the LPDIRECTDRAWSURFACE2 parameters 
+ * have been converted to LPDIRECTDRAWSURFACE3.
+ */
+/* FIXME: I assumed IDirectDrawSurface4 does not inherit from IDirectDrawSurface3 but I 
+ * have actually not proof of that. Can someone check and remove this comment or patch 
+ * accordingly ?
+ */
+#define ICOM_INTERFACE IDirectDrawSurface4
+#define IDirectDrawSurface4_METHODS \
+    ICOM_METHOD1(HRESULT,AddAttachedSurface,    LPDIRECTDRAWSURFACE4,lpDDSAttachedSurface) \
+    ICOM_METHOD1(HRESULT,AddOverlayDirtyRect,   LPRECT,lpRect) \
+    ICOM_METHOD5(HRESULT,Blt,                   LPRECT,lpDestRect, LPDIRECTDRAWSURFACE4,lpDDSrcSurface, LPRECT,lpSrcRect, DWORD,dwFlags, LPDDBLTFX,lpDDBltFx) \
+    ICOM_METHOD3(HRESULT,BltBatch,              LPDDBLTBATCH,lpDDBltBatch, DWORD,dwCount, DWORD,dwFlags) \
+    ICOM_METHOD5(HRESULT,BltFast,               DWORD,dwX, DWORD,dwY, LPDIRECTDRAWSURFACE4,lpDDSrcSurface, LPRECT,lpSrcRect, DWORD,dwTrans) \
+    ICOM_METHOD2(HRESULT,DeleteAttachedSurface, DWORD,dwFlags, LPDIRECTDRAWSURFACE4,lpDDSAttachedSurface) \
+    ICOM_METHOD2(HRESULT,EnumAttachedSurfaces,  LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpEnumSurfacesCallback) \
+    ICOM_METHOD3(HRESULT,EnumOverlayZOrders,    DWORD,dwFlags, LPVOID,lpContext, LPDDENUMSURFACESCALLBACK,lpfnCallback) \
+    ICOM_METHOD2(HRESULT,Flip,                  LPDIRECTDRAWSURFACE4,lpDDSurfaceTargetOverride, DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,GetAttachedSurface,    LPDDSCAPS,lpDDSCaps, LPDIRECTDRAWSURFACE4*,lplpDDAttachedSurface) \
+    ICOM_METHOD1(HRESULT,GetBltStatus,          DWORD,dwFlags) \
+    ICOM_METHOD1(HRESULT,GetCaps,               LPDDSCAPS,lpDDSCaps) \
+    ICOM_METHOD1(HRESULT,GetClipper,            LPDIRECTDRAWCLIPPER*,lplpDDClipper) \
+    ICOM_METHOD2(HRESULT,GetColorKey,           DWORD,dwFlags, LPDDCOLORKEY,lpDDColorKey) \
+    ICOM_METHOD1(HRESULT,GetDC,                 HDC*,lphDC) \
+    ICOM_METHOD1(HRESULT,GetFlipStatus,         DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,GetOverlayPosition,    LPLONG,lplX, LPLONG,lplY) \
+    ICOM_METHOD1(HRESULT,GetPalette,            LPDIRECTDRAWPALETTE*,lplpDDPalette) \
+    ICOM_METHOD1(HRESULT,GetPixelFormat,        LPDDPIXELFORMAT,lpDDPixelFormat) \
+    ICOM_METHOD1(HRESULT,GetSurfaceDesc,        LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD2(HRESULT,Initialize,            LPDIRECTDRAW,lpDD, LPDDSURFACEDESC,lpDDSurfaceDesc) \
+    ICOM_METHOD (HRESULT,IsLost) \
+    ICOM_METHOD4(HRESULT,Lock,                  LPRECT,lpDestRect, LPDDSURFACEDESC,lpDDSurfaceDesc, DWORD,dwFlags, HANDLE,hEvent) \
+    ICOM_METHOD1(HRESULT,ReleaseDC,             HDC,hDC) \
+    ICOM_METHOD (HRESULT,Restore) \
+    ICOM_METHOD1(HRESULT,SetClipper,            LPDIRECTDRAWCLIPPER,lpDDClipper) \
+    ICOM_METHOD2(HRESULT,SetColorKey,           DWORD,dwFlags, LPDDCOLORKEY,lpDDColorKey) \
+    ICOM_METHOD2(HRESULT,SetOverlayPosition,    LONG,lX, LONG,lY) \
+    ICOM_METHOD1(HRESULT,SetPalette,            LPDIRECTDRAWPALETTE,lpDDPalette) \
+    ICOM_METHOD1(HRESULT,Unlock,                LPVOID,lpSurfaceData) \
+    ICOM_METHOD5(HRESULT,UpdateOverlay,         LPRECT,lpSrcRect, LPDIRECTDRAWSURFACE4,lpDDDestSurface, LPRECT,lpDestRect, DWORD,dwFlags, LPDDOVERLAYFX,lpDDOverlayFx) \
+    ICOM_METHOD1(HRESULT,UpdateOverlayDisplay,  DWORD,dwFlags) \
+    ICOM_METHOD2(HRESULT,UpdateOverlayZOrder,   DWORD,dwFlags, LPDIRECTDRAWSURFACE4,lpDDSReference) \
+    /* added in v2 */ \
+    ICOM_METHOD1(HRESULT,GetDDInterface, LPVOID*,lplpDD) \
+    ICOM_METHOD1(HRESULT,PageLock,       DWORD,dwFlags) \
+    ICOM_METHOD1(HRESULT,PageUnlock,     DWORD,dwFlags) \
+    /* added in v3 */ \
+    ICOM_METHOD2(HRESULT,SetSurfaceDesc, LPDDSURFACEDESC,lpDDSD, DWORD,dwFlags) \
+    /* added in v4 */ \
+    ICOM_METHOD4(HRESULT,SetPrivateData,       REFGUID,, LPVOID,, DWORD,, DWORD,) \
+    ICOM_METHOD3(HRESULT,GetPrivateData,       REFGUID,, LPVOID,, LPDWORD,) \
+    ICOM_METHOD1(HRESULT,FreePrivateData,      REFGUID,) \
+    ICOM_METHOD1(HRESULT,GetUniquenessValue,   LPDWORD,) \
+    ICOM_METHOD (HRESULT,ChangeUniquenessValue)
+#define IDirectDrawSurface4_IMETHODS \
+    IUnknown_IMETHODS \
+    IDirectDrawSurface4_METHODS
+ICOM_DEFINE(IDirectDrawSurface4,IUnknown)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+    /*** IUnknown methods ***/
+#define IDirectDrawSurface4_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDrawSurface4_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDrawSurface4_Release(p)            ICOM_CALL (Release,p)
+/*** IDirectDrawSurface (almost) methods ***/
+#define IDirectDrawSurface4_AddAttachedSurface(p,a)      ICOM_CALL1(AddAttachedSurface,p,a)
+#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a)     ICOM_CALL1(AddOverlayDirtyRect,p,a)
+#define IDirectDrawSurface4_Blt(p,a,b,c,d,e)             ICOM_CALL5(Blt,p,a,b,c,d,e)
+#define IDirectDrawSurface4_BltBatch(p,a,b,c)            ICOM_CALL3(BltBatch,p,a,b,c)
+#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e)         ICOM_CALL5(BltFast,p,a,b,c,d,e)
+#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) ICOM_CALL2(DeleteAttachedSurface,p,a,b)
+#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b)  ICOM_CALL2(EnumAttachedSurfaces,p,a,b)
+#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c)  ICOM_CALL3(EnumOverlayZOrders,p,a,b,c)
+#define IDirectDrawSurface4_Flip(p,a,b)                  ICOM_CALL2(Flip,p,a,b)
+#define IDirectDrawSurface4_GetAttachedSurface(p,a,b)    ICOM_CALL2(GetAttachedSurface,p,a,b)
+#define IDirectDrawSurface4_GetBltStatus(p,a)            ICOM_CALL1(GetBltStatus,p,a)
+#define IDirectDrawSurface4_GetCaps(p,a)                 ICOM_CALL1(GetCaps,p,a)
+#define IDirectDrawSurface4_GetClipper(p,a)              ICOM_CALL1(GetClipper,p,a)
+#define IDirectDrawSurface4_GetColorKey(p,a,b)           ICOM_CALL2(GetColorKey,p,a,b)
+#define IDirectDrawSurface4_GetDC(p,a)                   ICOM_CALL1(GetDC,p,a)
+#define IDirectDrawSurface4_GetFlipStatus(p,a)           ICOM_CALL1(GetFlipStatus,p,a)
+#define IDirectDrawSurface4_GetOverlayPosition(p,a,b)    ICOM_CALL2(GetOverlayPosition,p,a,b)
+#define IDirectDrawSurface4_GetPalette(p,a)              ICOM_CALL1(GetPalette,p,a)
+#define IDirectDrawSurface4_GetPixelFormat(p,a)          ICOM_CALL1(GetPixelFormat,p,a)
+#define IDirectDrawSurface4_GetSurfaceDesc(p,a)          ICOM_CALL1(GetSurfaceDesc,p,a)
+#define IDirectDrawSurface4_Initialize(p,a,b)            ICOM_CALL2(Initialize,p,a,b)
+#define IDirectDrawSurface4_IsLost(p)                    ICOM_CALL (IsLost,p)
+#define IDirectDrawSurface4_Lock(p,a,b,c,d)              ICOM_CALL4(Lock,p,a,b,c,d)
+#define IDirectDrawSurface4_ReleaseDC(p,a)               ICOM_CALL1(ReleaseDC,p,a)
+#define IDirectDrawSurface4_Restore(p,a,b)               ICOM_CALL (Restore,p,a,b)
+#define IDirectDrawSurface4_SetClipper(p,a,b)            ICOM_CALL1(SetClipper,p,a,b)
+#define IDirectDrawSurface4_SetColorKey(p,a,b)           ICOM_CALL2(SetColorKey,p,a,b)
+#define IDirectDrawSurface4_SetOverlayPosition(p,a,b)    ICOM_CALL2(SetOverlayPosition,p,a,b)
+#define IDirectDrawSurface4_SetPalette(p,a)              ICOM_CALL1(SetPalette,p,a)
+#define IDirectDrawSurface4_Unlock(p,a)                  ICOM_CALL1(Unlock,p,a)
+#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e)   ICOM_CALL5(UpdateOverlay,p,a,b,c,d,e)
+#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a)    ICOM_CALL1(UpdateOverlayDisplay,p,a)
+#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b)   ICOM_CALL2(UpdateOverlayZOrder,p,a,b)
+/*** IDirectDrawSurface2 methods ***/
+#define IDirectDrawSurface4_GetDDInterface(p,a) ICOM_CALL1(GetDDInterface,p,a)
+#define IDirectDrawSurface4_PageLock(p,a)       ICOM_CALL1(PageLock,p,a)
+#define IDirectDrawSurface4_PageUnlock(p,a)     ICOM_CALL1(PageUnlock,p,a)
+/*** IDirectDrawSurface3 methods ***/
+#define IDirectDrawSurface4_SetSurfaceDesc(p,a) ICOM_CALL(SetSurfaceDesc,p,a)
+/*** IDirectDrawSurface4 methods ***/
+#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) ICOM_CALL4(SetPrivateData,p,a,b,c,d)
+#define IDirectDrawSurface4_GetPrivateData(p,a,b,c)   ICOM_CALL3(GetPrivateData,p,a,b,c)
+#define IDirectDrawSurface4_FreePrivateData(p,a)      ICOM_CALL1(FreePrivateData,p,a)
+#define IDirectDrawSurface4_GetUniquenessValue(p,a)   ICOM_CALL1(GetUniquenessValue,p,a)
+#define IDirectDrawSurface4_ChangeUniquenessValue(p)  ICOM_CALL (ChangeUniquenessValue,p)
+#endif
+
+
+/*****************************************************************************
+ * IDirectDrawColorControl interface
+ */
+#define ICOM_INTERFACE IDirectDrawColorControl
+#define IDirectDrawColorControl_METHODS \
+    ICOM_METHOD1(HRESULT,GetColorControls, LPDDCOLORCONTROL,lpColorControl) \
+    ICOM_METHOD1(HRESULT,SetColorControls, LPDDCOLORCONTROL,lpColorControl)
+#define IDirectDrawColorControl_IMETHODS \
+    IUnknown_IMETHODS \
+    IDirectDrawColorControl_METHODS
+ICOM_DEFINE(IDirectDrawColorControl,IUnknown)
+#undef ICOM_INTERFACE
+
+#ifdef ICOM_CINTERFACE
+	/*** IUnknown methods ***/
+#define IDirectDrawColorControl_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
+#define IDirectDrawColorControl_AddRef(p)             ICOM_CALL (AddRef,p)
+#define IDirectDrawColorControl_Release(p)            ICOM_CALL (Release,p)
+	/*** IDirectDrawColorControl methods ***/
+#define IDirectDrawColorControl_GetColorControls(p,a) ICOM_CALL(GetColorControls,p,a)
+#define IDirectDrawColorControl_SetColorControls(p,a) ICOM_CALL(SetColorControls,p,a)
+#endif
+
+
+HRESULT WINAPI DirectDrawCreate(LPGUID,LPDIRECTDRAW*,LPUNKNOWN);
+HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA,LPVOID);
+HRESULT WINAPI DirectDrawEnumerateW(LPDDENUMCALLBACKW,LPVOID);
+#define DirectDrawEnumerate WINELIB_NAME_AW(DirectDrawEnumerate)
+HRESULT WINAPI DirectDrawCreateClipper(DWORD,LPDIRECTDRAWCLIPPER*,LPUNKNOWN);
+
+#endif /* __WINE_DDRAW_H */
Index: xc/programs/Xserver/hw/xwin/directx.c
diff -u /dev/null xc/programs/Xserver/hw/xwin/directx.c:1.1
--- /dev/null	Mon Dec 18 14:33:02 2000
+++ xc/programs/Xserver/hw/xwin/directx.c	Thu Aug 10 13:40:37 2000
@@ -0,0 +1,174 @@
+/*
+ * (c) Copyright 2000 by Peter Busch
+ *                      <pbusch@dfki.de>
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PETER BUSCH  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Peter Busch shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Peter Busch.
+ *
+*/
+/* $XFree86: xc/programs/Xserver/hw/xwin/directx.c,v 1.1 2000/08/10 17:40:37 dawes Exp $ */
+
+
+#include <windows.h>
+#include <stdio.h>
+#include "xf_dx_xwin.h"
+
+/* external references to funcs in InitInput.c and InitOutput.c */
+extern SwitchFramebuffer( void * ptr );
+extern GenerateInputEvent( type, ix, iy, button ); 
+
+typedef BOOL (__cdecl *_DIInitKeyboard)();
+typedef BOOL (__cdecl *_DIInitMouse)();
+typedef void (__cdecl *_DITermKeyboard)();
+typedef void (__cdecl *_DITermMouse)();
+typedef BOOL (__cdecl *_DXStoreColors)(int i, int r, int g, int b);
+typedef void (__cdecl *_ListModes)(void);
+typedef void (__cdecl *_set_fn)( __SwitchFramebuffer switch_fb, __GenerateInputEvent gen_inp );
+typedef char*( __cdecl *_winDXAllocateFramebufferMemory)
+	(
+	int*		width,
+	int*		height,
+	int*		depth,
+	int*		pitch
+	);
+typedef void (__cdecl *_winfbBlockHandler)();
+typedef int  (__cdecl *_winfbWakeupHandler)();
+
+
+_DIInitKeyboard xf_DIInitKeyboard = NULL;
+_DIInitMouse xf_DIInitMouse = NULL;
+_DITermKeyboard xf_DITermKeyboard = NULL;
+_DITermMouse xf_DITermMouse = NULL;
+_DXStoreColors xf_DXStoreColors = NULL;
+_ListModes xf_ListModes = NULL;
+_set_fn xf_set_fn = NULL;
+_winDXAllocateFramebufferMemory xf_winDXAllocateFramebufferMemory = NULL;
+_winfbBlockHandler xf_winfbBlockHandler = NULL;
+_winfbWakeupHandler xf_winfbWakeupHandler = NULL;
+HINSTANCE h_xf_dx = NULL;
+
+static BOOL initialized = FALSE;
+
+
+void enable_xf_dx( )
+{
+	h_xf_dx = LoadLibrary( "xf_dx.dll" );
+	if( h_xf_dx == NULL )
+	{
+		fprintf( stderr, "cannot load xf_dx.dll\n" );
+		exit( 1 );
+	}
+
+	xf_DIInitKeyboard = 
+		(_DIInitKeyboard)GetProcAddress( h_xf_dx, "DIInitKeyboard" );
+	xf_DIInitMouse = 
+		(_DIInitMouse)GetProcAddress( h_xf_dx, "DIInitMouse" );
+	xf_DITermKeyboard = 
+		(_DITermKeyboard)GetProcAddress( h_xf_dx, "DITermKeyboard" );
+	xf_DITermMouse = 
+		(_DITermMouse)GetProcAddress( h_xf_dx, "DITermMouse" );
+	xf_DXStoreColors = 
+		(_DXStoreColors)GetProcAddress( h_xf_dx, "DXStoreColors" );
+	xf_ListModes = 
+		(_ListModes)GetProcAddress( h_xf_dx, "ListModes" );
+	xf_set_fn = 
+		(_set_fn)GetProcAddress( h_xf_dx, "set_fn" );
+	xf_winDXAllocateFramebufferMemory = 
+		(_winDXAllocateFramebufferMemory)GetProcAddress( h_xf_dx, "winDXAllocateFramebufferMemory" );
+	xf_winfbBlockHandler = 
+		(_winfbBlockHandler)GetProcAddress( h_xf_dx, "winfbBlockHandler" );
+	xf_winfbWakeupHandler = 
+		(_winfbWakeupHandler)GetProcAddress( h_xf_dx, "winfbWakeupHandler" );
+
+	xf_set_fn( 
+		(__SwitchFramebuffer)SwitchFramebuffer,
+		(__GenerateInputEvent)GenerateInputEvent
+		);
+	initialized = TRUE;
+}
+
+
+/* DX stubs */
+
+
+BOOL	DIInitKeyboard()
+{
+	return xf_DIInitKeyboard();
+}
+
+BOOL	DIInitMouse()
+{
+	return xf_DIInitMouse();
+
+}
+
+void	DITermKeyboard()
+{
+	xf_DITermKeyboard();
+}
+
+void	DITermMouse()
+{
+	xf_DITermMouse();
+
+}
+
+BOOL	DXStoreColors(int i, int r, int g, int b)
+{
+	return xf_DXStoreColors( i, r, g, b );
+
+}
+
+void	ListModes(void)
+{
+	enable_xf_dx();
+	xf_ListModes();
+}
+
+void	set_fn( __SwitchFramebuffer switch_fb, __GenerateInputEvent gen_inp )
+{
+	return xf_set_fn( switch_fb, gen_inp );
+}
+
+char*	winDXAllocateFramebufferMemory
+	(
+	int*		width,
+	int*		height,
+	int*		depth,
+	int*		pitch
+	)
+{
+	enable_xf_dx();
+	return xf_winDXAllocateFramebufferMemory( width, height, depth, pitch );
+}
+
+void winfbBlockHandler()
+{
+	xf_winfbBlockHandler();	
+}
+
+int  winfbWakeupHandler()
+{
+	return xf_winfbWakeupHandler();
+}
+
Index: xc/programs/Xserver/hw/xwin/ntux_ddx.h
diff -u /dev/null xc/programs/Xserver/hw/xwin/ntux_ddx.h:1.1
--- /dev/null	Mon Dec 18 14:33:02 2000
+++ xc/programs/Xserver/hw/xwin/ntux_ddx.h	Thu Aug 10 13:40:37 2000
@@ -0,0 +1,150 @@
+/*
+* Copyright 2000 (C) Peter Busch
+* All rights reserved.
+NO WARRANTY; NO LIABILITY FOR DAMAGES:  THE MATERIALS ARE PROVIDED "AS IS" 
+WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES
+OF SATISFACTORY QUALITY, MERCHANTABILITY, NONINFRINGEMENT OF THIRD-PARTY
+INTELLECTUAL PROPERTY, OR FITNESS FOR ANY PARTICULAR PURPOSE.
+IN NO EVENT  SHALL Peter Busch BE LIABLE FOR ANY DAMAGES WHATSOEVER
+(INCLUDING, WITHOUT  LIMITATION, DIRECT OR INDIRECT DAMAGES, DAMAGES FOR
+LOSS OF PROFITS, BUSINESS  INTERRUPTION, LOSS OF INFORMATION) ARISING OUT
+OF THE USE OF OR INABILITY TO  USE THE MATERIALS, EVEN IF
+Peter Busch HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH  DAMAGES.
+Without limiting the generality of the foregoing, no warranty is made
+that the enclosed software will generate computer programs with the
+characteristics or specifications desired by you or that the demo
+software will be error-free.
+THESE DISCLAIMERS OF WARRANTY CONSTITUTE AN ESSENTIAL PART OF THIS
+AGREEMENT. 
+*/
+/* $XFree86: xc/programs/Xserver/hw/xwin/ntux_ddx.h,v 1.1 2000/08/10 17:40:37 dawes Exp $ */
+
+/*
+* ntux_ddx.h
+* public header file for the ntux_ddx frame buffer library
+* Copyright 2000 (C) Peter Busch
+* All rights reserved.
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+* This code is BETA and will be part of the CYGWIN/XFREE Project.
+* It may not be used for purposes other than to contribute to the 
+* CYGWIN/XFree project without prior written notice from the
+* author.
+* Any commercial use of this code will be permitted
+* provided you contact Peter Busch at pbusch@dfki.de
+*/
+
+
+/*
+* for use with the gcc compiler the exported get_surface routine
+* is exported with the __cdecl calling convention
+*/
+
+#ifdef MSC_VER
+char *__cdecl get_surface( unsigned long size );
+#else
+char *get_surface( unsigned long size );
+#endif
+
+
+#ifdef MSC_VER
+char *__cdecl map_dx_fb( char *adr, unsigned long size );
+#else
+char *map_dx_fb( char *adr, unsigned long size );
+#endif
+/*
+* definitions from xfddx_escape.h 
+* (didn't want include the X-Server specific headers 
+* needed to to include xfddx_escape.h)
+*/
+#define XFDDX_MAP_VIDEO_MEM			(0x1998120E)
+#define XFDDX_UNMAP_VIDEO_MEM		(0x1998120F)
+#define XFDDX_KMAP_VIDEO_MEM		(0x1998120B)
+#define XFDDX_KUNMAP_VIDEO_MEM		(0x1998120C)
+
+
+#define FILE_DEVICE_XFMAP			(0x00008383)
+#define XFMAP_IOCTL_INDEX			(0x830)
+
+
+typedef enum {
+	NOTMAPPED,
+	XFMAP_XFMAP,
+	XFMAP_XFDDX_2,
+	XFMAP_DX,
+} xf_mapped;
+	
+/* define IOCTL codes */
+#define XFMAP_MAP			( ULONG) CTL_CODE( FILE_DEVICE_XFMAP,XFMAP_IOCTL_INDEX + 0,	METHOD_NEITHER,	FILE_ANY_ACCESS )
+
+#define XFMAP_UNMAP			( ULONG) CTL_CODE( FILE_DEVICE_XFMAP, XFMAP_IOCTL_INDEX + 1,METHOD_NEITHER,	FILE_ANY_ACCESS )
+
+
+#define XFMAP_PMAP			( ULONG) CTL_CODE( FILE_DEVICE_XFMAP, XFMAP_IOCTL_INDEX + 3,METHOD_NEITHER,	FILE_ANY_ACCESS )
+
+
+#define XFMAP_V2P			( ULONG) CTL_CODE( FILE_DEVICE_XFMAP,XFMAP_IOCTL_INDEX + 4,	METHOD_NEITHER,	FILE_ANY_ACCESS )
+
+
+
+#ifndef PAGE_SIZE
+#define PAGE_SIZE 4096
+#endif
+
+#define XFMAP_SYS					"xfmap"
+#define XFMAP_IMG					"xfmap.sys"
+
+
+
+#ifndef __BUILD_XFDDX__
+
+#ifndef _VIDEO_SHARE_MEMORY
+typedef struct _VIDEO_SHARE_MEMORY 
+{
+    HANDLE	ProcessHandle;
+    ULONG	ViewOffset;
+    ULONG	ViewSize;
+    PVOID	RequestedVirtualAddress;
+} VIDEO_SHARE_MEMORY, *PVIDEO_SHARE_MEMORY;
+#endif
+
+#ifndef _VIDEO_SHARE_MEMORY_INFORMATION
+typedef struct _VIDEO_SHARE_MEMORY_INFORMATION 
+{
+    ULONG	SharedViewOffset;
+    ULONG	SharedViewSize;
+    PVOID	VirtualAddress;
+} VIDEO_SHARE_MEMORY_INFORMATION, *PVIDEO_SHARE_MEMORY_INFORMATION;
+#endif
+
+
+#ifndef _VIDEO_MEMORY
+typedef struct _VIDEO_MEMORY
+{
+    PVOID RequestedVirtualAddress;
+} VIDEO_MEMORY, *PVIDEO_MEMORY;
+#endif
+
+#ifndef _VIDEO_MEMORY_INFORMATION 
+typedef struct _VIDEO_MEMORY_INFORMATION 
+{
+    PVOID VideoRamBase;
+    ULONG VideoRamLength;
+    PVOID FrameBufferBase;
+    ULONG FrameBufferLength;
+} VIDEO_MEMORY_INFORMATION, *PVIDEO_MEMORY_INFORMATION;
+#endif
+#endif	/* __BUILD_XFDDX__ */
+
+/* prototypes */
+HANDLE	WINAPI load_driver( 
+	char *driver_name,		/* driver name, example "xfmap" */
+	char *driver_bin		/* driver binary, example "xfmap.sys" */
+	);
+
+BOOL	WINAPI unload_driver( 
+	HANDLE h_driver,		/* handle to loaded driver */
+	char *driver_name		/* driver name, example : "xfmap" */
+	);
+
+BOOL UnloadDeviceDriver( const char * Name );
Index: xc/programs/Xserver/hw/xwin/ntux_xf.c
diff -u /dev/null xc/programs/Xserver/hw/xwin/ntux_xf.c:1.1
--- /dev/null	Mon Dec 18 14:33:03 2000
+++ xc/programs/Xserver/hw/xwin/ntux_xf.c	Thu Aug 10 13:40:38 2000
@@ -0,0 +1,267 @@
+/* $XFree86: xc/programs/Xserver/hw/xwin/ntux_xf.c,v 1.1 2000/08/10 17:40:38 dawes Exp $ */
+
+#include <windows.h>
+#include <winioctl.h>
+#include <winsvc.h>
+#include <memory.h>
+#include "stdio.h"
+#include "ntux_ddx.h"
+
+/* #define TEST_STANDALONE 0 */
+static 	HANDLE h_xfmap = NULL;
+
+
+char	*map_dx_fb( char *adr, unsigned long size )
+{
+	char	*retval = NULL;
+	unsigned long cb;	
+
+	VIDEO_SHARE_MEMORY	vsm = {0};
+	vsm.RequestedVirtualAddress = adr;
+	vsm.ViewSize = size;
+
+	if( h_xfmap == NULL )
+	{
+		h_xfmap = load_driver( XFMAP_SYS, XFMAP_IMG );
+		if( h_xfmap == NULL )
+			return NULL;
+	}
+
+	if( DeviceIoControl( h_xfmap,
+						XFMAP_PMAP,
+						(LPVOID)&vsm,
+						sizeof(vsm),
+						(LPVOID)&vsm,
+						sizeof(vsm),
+						&cb,
+						NULL
+						)
+		 )
+	{
+		retval = (char*)vsm.RequestedVirtualAddress;
+	}
+	return retval;
+}
+
+#ifndef TEST_STANDALONE
+static 
+#endif
+int main( int argc, char **argv )
+{
+	char *buf = NULL;
+	char *buf2 = NULL;
+
+	UnloadDeviceDriver( XFMAP_SYS );
+	h_xfmap = load_driver( XFMAP_SYS, XFMAP_IMG );
+
+	fprintf( stderr, "h_xfmap = %08x\n", h_xfmap );
+
+	buf = (char*)malloc( 100000 );
+	if( buf )
+	{
+		buf2 = map_dx_fb( buf, 100000 );
+		free( buf );
+	}
+
+
+	if( h_xfmap )
+		unload_driver( h_xfmap, XFMAP_SYS );
+}
+
+
+
+
+/*
+* driver load/unload routines
+*/
+BOOL InstallDriver( SC_HANDLE SchSCManager, LPCSTR DriverName, LPCSTR ServiceExe )
+{
+    SC_HANDLE  schService;
+
+
+    schService = CreateService( SchSCManager,          // SCManager database
+                                DriverName,           // name of service
+                                DriverName,           // name to display
+                                SERVICE_ALL_ACCESS,    // desired access
+                                SERVICE_KERNEL_DRIVER, // service type
+                                SERVICE_DEMAND_START,  // start type
+                                SERVICE_ERROR_NORMAL,  // error control type
+                                ServiceExe,            // service's binary
+                                NULL,                  // no load ordering group
+                                NULL,                  // no tag identifier
+                                NULL,                  // no dependencies
+                                NULL,                  // LocalSystem account
+                                NULL                   // no password
+                                );
+
+    if ( schService == NULL )
+        return FALSE;
+
+    CloseServiceHandle( schService );
+	return TRUE;
+}
+
+BOOL StartDriver( SC_HANDLE SchSCManager, LPCSTR DriverName )
+{
+    SC_HANDLE  schService;
+    BOOL       ret;
+
+    schService = OpenService( SchSCManager,
+                              DriverName,
+                              SERVICE_ALL_ACCESS
+                              );
+    if ( schService == NULL )
+        return FALSE;
+
+    ret = StartService( schService, 0, NULL )
+       || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING;
+
+    CloseServiceHandle( schService );
+
+    return ret;
+}
+
+BOOL OpenDevice( LPCSTR DriverName, HANDLE * lphDevice )
+{
+    char	completeDeviceName[64];
+    HANDLE  hDevice;
+
+
+    sprintf( completeDeviceName, TEXT("\\\\.\\%s"), DriverName );
+
+    hDevice = CreateFile( completeDeviceName,
+                          GENERIC_READ | GENERIC_WRITE,
+                          0,
+                          NULL,
+                          OPEN_EXISTING,
+                          FILE_ATTRIBUTE_NORMAL,
+                          NULL
+                          );
+    if ( hDevice == ((HANDLE)-1) )
+        return FALSE;
+
+	/* If user wants handle, give it to them.  Otherwise, just close it. */
+	if ( lphDevice )
+		*lphDevice = hDevice;
+	else
+	    CloseHandle( hDevice );
+	return TRUE;
+}
+
+BOOL StopDriver( SC_HANDLE SchSCManager, LPCSTR DriverName )
+{
+    SC_HANDLE       schService;
+    BOOL            ret;
+    SERVICE_STATUS  serviceStatus;
+
+    schService = OpenService( SchSCManager, DriverName, SERVICE_ALL_ACCESS );
+    if ( schService == NULL )
+        return FALSE;
+
+    ret = ControlService( schService, SERVICE_CONTROL_STOP, &serviceStatus );
+
+    CloseServiceHandle( schService );
+
+    return ret;
+}
+
+BOOL RemoveDriver( SC_HANDLE SchSCManager, LPCSTR DriverName )
+{
+    SC_HANDLE  schService;
+    BOOL       ret;
+
+    schService = OpenService( SchSCManager,
+                              DriverName,
+                              SERVICE_ALL_ACCESS
+                              );
+
+    if ( schService == NULL )
+        return FALSE;
+
+    ret = DeleteService( schService );
+
+    CloseServiceHandle( schService );
+
+    return ret;
+}
+
+BOOL LoadDeviceDriver( const char * Name, const char * Path, HANDLE * lphDevice )
+{
+	SC_HANDLE	schSCManager;
+	BOOL		okay;
+
+	schSCManager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
+
+	// Ignore success of installation: it may already be installed.
+	InstallDriver( schSCManager, Name, Path );
+
+	// Ignore success of start: it may already be started.
+	StartDriver( schSCManager, Name );
+
+	// Do make sure we can open it.
+	okay = OpenDevice( Name, lphDevice );
+
+ 	CloseServiceHandle( schSCManager );
+
+	return okay;
+}
+
+BOOL UnloadDeviceDriver( const char * Name )
+{
+	BOOL bResult = TRUE;
+	SC_HANDLE	schSCManager;
+	
+	schSCManager = OpenSCManager(	NULL,                 // machine (NULL == local)
+                              		NULL,                 // database (NULL == default)
+									SC_MANAGER_ALL_ACCESS // access required
+								);
+
+	if( !schSCManager )
+		return FALSE;
+
+	bResult &= StopDriver( schSCManager, Name );
+	bResult &= RemoveDriver( schSCManager, Name );
+	 
+	bResult &= CloseServiceHandle( schSCManager );
+
+	return bResult;
+}
+
+HANDLE	WINAPI	LoadDriver( LPCSTR szPath, LPCSTR Name )
+{
+	HANDLE	sys_handle;
+
+
+
+	if(	!LoadDeviceDriver( Name, szPath, &sys_handle ) )
+		return NULL;
+	else
+		return sys_handle;
+}
+
+BOOL	WINAPI	UnloadDriver( HANDLE hDriver, LPCSTR szName )
+{
+	if( !CloseHandle( hDriver ) )
+		return FALSE;
+	return UnloadDeviceDriver( szName );
+}
+
+HANDLE	WINAPI load_driver( 
+	char *driver_name,		/* driver name, example "xfmap" */
+	char *driver_bin		/* driver binary, example "xfmap.sys" */
+	)
+{
+	char Path[ MAX_PATH ];
+	GetCurrentDirectory( sizeof Path, Path );
+
+	sprintf( Path+lstrlen(Path), TEXT("\\%s"), driver_bin );
+	return LoadDriver( Path, driver_name );
+}
+
+BOOL	WINAPI unload_driver( 
+	HANDLE h_driver,		/* handle to loaded driver */
+	char *driver_name		/* driver name, example : "xfmap" */
+	)
+{
+	return UnloadDriver( h_driver, driver_name );
+}
Index: xc/programs/Xserver/hw/xwin/winkeymap.h
diff -u /dev/null xc/programs/Xserver/hw/xwin/winkeymap.h:1.1
--- /dev/null	Mon Dec 18 14:33:04 2000
+++ xc/programs/Xserver/hw/xwin/winkeymap.h	Thu Aug 10 13:40:38 2000
@@ -0,0 +1,163 @@
+/* $XFree86: xc/programs/Xserver/hw/xwin/winkeymap.h,v 1.1 2000/08/10 17:40:38 dawes Exp $ */
+/*
+ *
+ * For Scancodes see notes in atKeynames.h  !!!!
+ *
+ */
+/* $TOG: xf86Keymap.h /main/15 1997/07/19 10:02:01 kaleb $ */
+
+static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = { 
+    /* 0x00 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x01 */  XK_Escape,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x02 */  XK_1,           XK_exclam,	NoSymbol,	NoSymbol,
+    /* 0x03 */  XK_2,           XK_at,		NoSymbol,	NoSymbol,
+    /* 0x04 */  XK_3,           XK_numbersign,	NoSymbol,	NoSymbol,
+    /* 0x05 */  XK_4,           XK_dollar,	NoSymbol,	NoSymbol,
+    /* 0x06 */  XK_5,           XK_percent,	NoSymbol,	NoSymbol,
+    /* 0x07 */  XK_6,           XK_asciicircum,	NoSymbol,	NoSymbol,
+    /* 0x08 */  XK_7,           XK_ampersand,	NoSymbol,	NoSymbol,
+    /* 0x09 */  XK_8,           XK_asterisk,	NoSymbol,	NoSymbol,
+    /* 0x0a */  XK_9,           XK_parenleft,	NoSymbol,	NoSymbol,
+    /* 0x0b */  XK_0,           XK_parenright,	NoSymbol,	NoSymbol,
+    /* 0x0c */  XK_minus,       XK_underscore,	NoSymbol,	NoSymbol,
+    /* 0x0d */  XK_equal,       XK_plus,	NoSymbol,	NoSymbol,
+    /* 0x0e */  XK_BackSpace,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x0f */  XK_Tab,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x10 */  XK_Q,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x11 */  XK_W,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x12 */  XK_E,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x13 */  XK_R,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x14 */  XK_T,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x15 */  XK_Y,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x16 */  XK_U,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x17 */  XK_I,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x18 */  XK_O,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x19 */  XK_P,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1a */  XK_bracketleft, XK_braceleft,	NoSymbol,	NoSymbol,
+    /* 0x1b */  XK_bracketright,XK_braceright,	NoSymbol,	NoSymbol,
+    /* 0x1c */  XK_Return,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1d */  XK_Control_L,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1e */  XK_A,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1f */  XK_S,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x20 */  XK_D,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x21 */  XK_F,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x22 */  XK_G,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x23 */  XK_H,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x24 */  XK_J,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x25 */  XK_K,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x26 */  XK_L,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x27 */  XK_semicolon,   XK_colon,	NoSymbol,	NoSymbol,
+    /* 0x28 */  XK_quoteright,  XK_quotedbl,	NoSymbol,	NoSymbol,
+    /* 0x29 */  XK_quoteleft,	XK_asciitilde,	NoSymbol,	NoSymbol,
+    /* 0x2a */  XK_Shift_L,     NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2b */  XK_backslash,   XK_bar,		NoSymbol,	NoSymbol,
+    /* 0x2c */  XK_Z,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2d */  XK_X,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2e */  XK_C,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2f */  XK_V,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x30 */  XK_B,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x31 */  XK_N,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x32 */  XK_M,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x33 */  XK_comma,       XK_less,	NoSymbol,	NoSymbol,
+    /* 0x34 */  XK_period,      XK_greater,	NoSymbol,	NoSymbol,
+    /* 0x35 */  XK_slash,       XK_question,	NoSymbol,	NoSymbol,
+    /* 0x36 */  XK_Shift_R,     NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x37 */  XK_KP_Multiply, NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x38 */  XK_Alt_L,	XK_Meta_L,	NoSymbol,	NoSymbol,
+    /* 0x39 */  XK_space,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3a */  XK_Caps_Lock,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3b */  XK_F1,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3c */  XK_F2,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3d */  XK_F3,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3e */  XK_F4,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3f */  XK_F5,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x40 */  XK_F6,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x41 */  XK_F7,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x42 */  XK_F8,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x43 */  XK_F9,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x44 */  XK_F10,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x45 */  XK_Num_Lock,    NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x46 */  XK_Scroll_Lock,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x47 */  XK_KP_Home,	XK_KP_7,	NoSymbol,	NoSymbol,
+    /* 0x48 */  XK_KP_Up,	XK_KP_8,	NoSymbol,	NoSymbol,
+    /* 0x49 */  XK_KP_Prior,	XK_KP_9,	NoSymbol,	NoSymbol,
+    /* 0x4a */  XK_KP_Subtract, NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4b */  XK_KP_Left,	XK_KP_4,	NoSymbol,	NoSymbol,
+    /* 0x4c */  NoSymbol,	XK_KP_5,	NoSymbol,	NoSymbol,
+    /* 0x4d */  XK_KP_Right,	XK_KP_6,	NoSymbol,	NoSymbol,
+    /* 0x4e */  XK_KP_Add,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4f */  XK_KP_End,	XK_KP_1,	NoSymbol,	NoSymbol,
+    /* 0x50 */  XK_KP_Down,	XK_KP_2,	NoSymbol,	NoSymbol,
+    /* 0x51 */  XK_KP_Next,	XK_KP_3,	NoSymbol,	NoSymbol,
+    /* 0x52 */  XK_KP_Insert,	XK_KP_0,	NoSymbol,	NoSymbol,
+    /* 0x53 */  XK_KP_Delete,	XK_KP_Decimal,	NoSymbol,	NoSymbol,
+    /* 0x54 */  XK_Sys_Req,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x55 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x56 */  XK_less,	XK_greater,	NoSymbol,	NoSymbol,
+    /* 0x57 */  XK_F11,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x58 */  XK_F12,		NoSymbol,	NoSymbol,	NoSymbol,
+
+    /* 0x59 */  XK_Home,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5a */  XK_Up,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5b */  XK_Prior,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5c */  XK_Left,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5d */  XK_Begin,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5e */  XK_Right,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5f */  XK_End,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x60 */  XK_Down,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x61 */  XK_Next,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x62 */  XK_Insert,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x63 */  XK_Delete,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x64 */  XK_KP_Enter,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x65 */  XK_Control_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x66 */  XK_Pause,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x67 */  XK_Print,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x68 */  XK_KP_Divide,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x69 */  XK_Alt_R,	XK_Meta_R,	NoSymbol,	NoSymbol,
+    /* 0x6a */  XK_Break,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6b */  XK_Meta_L,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6c */  XK_Meta_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6d */  XK_Menu,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x70 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x71 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x72 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x73 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x74 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x75 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x76 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x77 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x78 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x79 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+
+    /* These are for ServerNumLock handling */
+    /* 0x80 */  XK_KP_7,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x81 */  XK_KP_8,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x82 */  XK_KP_9,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x83 */  XK_KP_4,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x84 */  XK_KP_5,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x85 */  XK_KP_6,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x86 */  XK_KP_1,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x87 */  XK_KP_2,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x88 */  XK_KP_3,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x89 */  XK_KP_0,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8a */  XK_KP_Decimal,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8b */  XK_Home,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8c */  XK_Up,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8d */  XK_Prior,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8e */  XK_Left,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8f */  XK_Begin,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x90 */  XK_Right,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x91 */  XK_End,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x92 */  XK_Down,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x93 */  XK_Next,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x94 */  XK_Insert,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x95 */  XK_Delete,	NoSymbol,	NoSymbol,	NoSymbol,
+};
Index: xc/programs/Xserver/hw/xwin/winkeynames.h
diff -u /dev/null xc/programs/Xserver/hw/xwin/winkeynames.h:1.1
--- /dev/null	Mon Dec 18 14:33:04 2000
+++ xc/programs/Xserver/hw/xwin/winkeynames.h	Thu Aug 10 13:40:38 2000
@@ -0,0 +1,335 @@
+/* $XFree86: xc/programs/Xserver/hw/xwin/winkeynames.h,v 1.1 2000/08/10 17:40:38 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $TOG: atKeynames.h /main/12 1997/07/19 10:00:17 kaleb $ */
+
+#ifndef _ATKEYNAMES_H
+#define _ATKEYNAMES_H
+
+#define XK_TECHNICAL
+#define	XK_KATAKANA
+#include "keysym.h"
+
+#define GLYPHS_PER_KEY	4
+#define NUM_KEYCODES	150
+#define NUM_STD_KEYCODES 127
+#define MIN_KEYCODE     8
+#define MAX_KEYCODE     (NUM_KEYCODES + MIN_KEYCODE - 1)
+#define MAX_STD_KEYCODE (NUM_STD_KEYCODES + MIN_KEYCODE - 1)
+
+#define AltMask		Mod1Mask
+#define NumLockMask	Mod2Mask
+#define AltLangMask	Mod3Mask
+#define KanaMask	Mod4Mask
+#define ScrollLockMask	Mod5Mask
+
+#define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7)))
+#define ModifierDown(k) ((keyc->state & (k)) == (k))
+
+#define XF86XK_ModeLock	0x1008FF01                 /* Mode Switch Lock */
+
+/*
+ * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
+ *       sets of scancodes. Set3 can only be generated by a MF keyboard.
+ *       Set2 sends a makecode for keypress, and the same code prefixed by a
+ *       F0 for keyrelease. This is a little bit ugly to handle. Thus we use
+ *       here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes.
+ *       Bit 7 ist set if the key is released. The code E0 switches to a
+ *       different meaning to add the new MF cursorkeys, while not breaking old
+ *       applications. E1 is another special prefix. Since I assume that there
+ *       will be further versions of PC/XT scancode compatible keyboards, we
+ *       may be in trouble one day.
+ *
+ * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3.
+ *       2) Use the keyboards native set and translate it to common keysyms.
+ */
+
+/*
+ * definition of the AT84/MF101/MF102 Keyboard:
+ * ============================================================
+ *       Defined             Key Cap Glyphs       Pressed value
+ *      Key Name            Main       Also       (hex)    (dec)
+ *      ----------------   ---------- -------    ------    ------
+ */
+
+#ifndef PC98
+
+#define KEY_Escape       /* Escape                0x01  */    1  
+#define KEY_1            /* 1           !         0x02  */    2 
+#define KEY_2            /* 2           @         0x03  */    3 
+#define KEY_3            /* 3           #         0x04  */    4 
+#define KEY_4            /* 4           $         0x05  */    5 
+#define KEY_5            /* 5           %         0x06  */    6 
+#define KEY_6            /* 6           ^         0x07  */    7 
+#define KEY_7            /* 7           &         0x08  */    8 
+#define KEY_8            /* 8           *         0x09  */    9 
+#define KEY_9            /* 9           (         0x0a  */   10 
+#define KEY_0            /* 0           )         0x0b  */   11 
+#define KEY_Minus        /* - (Minus)   _ (Under) 0x0c  */   12
+#define KEY_Equal        /* = (Equal)   +         0x0d  */   13 
+#define KEY_BackSpace    /* Back Space            0x0e  */   14 
+#define KEY_Tab          /* Tab                   0x0f  */   15
+#define KEY_Q            /* Q                     0x10  */   16
+#define KEY_W            /* W                     0x11  */   17
+#define KEY_E            /* E                     0x12  */   18
+#define KEY_R            /* R                     0x13  */   19
+#define KEY_T            /* T                     0x14  */   20
+#define KEY_Y            /* Y                     0x15  */   21
+#define KEY_U            /* U                     0x16  */   22
+#define KEY_I            /* I                     0x17  */   23
+#define KEY_O            /* O                     0x18  */   24
+#define KEY_P            /* P                     0x19  */   25
+#define KEY_LBrace       /* [           {         0x1a  */   26
+#define KEY_RBrace       /* ]           }         0x1b  */   27 
+#define KEY_Enter        /* Enter                 0x1c  */   28
+#define KEY_LCtrl        /* Ctrl(left)            0x1d  */   29
+#define KEY_A            /* A                     0x1e  */   30
+#define KEY_S            /* S                     0x1f  */   31
+#define KEY_D            /* D                     0x20  */   32 
+#define KEY_F            /* F                     0x21  */   33
+#define KEY_G            /* G                     0x22  */   34
+#define KEY_H            /* H                     0x23  */   35
+#define KEY_J            /* J                     0x24  */   36
+#define KEY_K            /* K                     0x25  */   37
+#define KEY_L            /* L                     0x26  */   38
+#define KEY_SemiColon    /* ;(SemiColon) :(Colon) 0x27  */   39
+#define KEY_Quote        /* ' (Apostr)  " (Quote) 0x28  */   40
+#define KEY_Tilde        /* ` (Accent)  ~ (Tilde) 0x29  */   41
+#define KEY_ShiftL       /* Shift(left)           0x2a  */   42
+#define KEY_BSlash       /* \(BckSlash) |(VertBar)0x2b  */   43
+#define KEY_Z            /* Z                     0x2c  */   44
+#define KEY_X            /* X                     0x2d  */   45
+#define KEY_C            /* C                     0x2e  */   46
+#define KEY_V            /* V                     0x2f  */   47
+#define KEY_B            /* B                     0x30  */   48
+#define KEY_N            /* N                     0x31  */   49
+#define KEY_M            /* M                     0x32  */   50
+#define KEY_Comma        /* , (Comma)   < (Less)  0x33  */   51
+#define KEY_Period       /* . (Period)  >(Greater)0x34  */   52
+#define KEY_Slash        /* / (Slash)   ?         0x35  */   53
+#define KEY_ShiftR       /* Shift(right)          0x36  */   54
+#define KEY_KP_Multiply  /* *                     0x37  */   55
+#define KEY_Alt          /* Alt(left)             0x38  */   56
+#define KEY_Space        /*   (SpaceBar)          0x39  */   57
+#define KEY_CapsLock     /* CapsLock              0x3a  */   58
+#define KEY_F1           /* F1                    0x3b  */   59
+#define KEY_F2           /* F2                    0x3c  */   60
+#define KEY_F3           /* F3                    0x3d  */   61
+#define KEY_F4           /* F4                    0x3e  */   62
+#define KEY_F5           /* F5                    0x3f  */   63
+#define KEY_F6           /* F6                    0x40  */   64
+#define KEY_F7           /* F7                    0x41  */   65
+#define KEY_F8           /* F8                    0x42  */   66
+#define KEY_F9           /* F9                    0x43  */   67
+#define KEY_F10          /* F10                   0x44  */   68
+#define KEY_NumLock      /* NumLock               0x45  */   69
+#define KEY_ScrollLock   /* ScrollLock            0x46  */   70
+#define KEY_KP_7         /* 7           Home      0x47  */   71 
+#define KEY_KP_8         /* 8           Up        0x48  */   72 
+#define KEY_KP_9         /* 9           PgUp      0x49  */   73 
+#define KEY_KP_Minus     /* - (Minus)             0x4a  */   74
+#define KEY_KP_4         /* 4           Left      0x4b  */   75
+#define KEY_KP_5         /* 5                     0x4c  */   76
+#define KEY_KP_6         /* 6           Right     0x4d  */   77
+#define KEY_KP_Plus      /* + (Plus)              0x4e  */   78
+#define KEY_KP_1         /* 1           End       0x4f  */   79
+#define KEY_KP_2         /* 2           Down      0x50  */   80
+#define KEY_KP_3         /* 3           PgDown    0x51  */   81
+#define KEY_KP_0         /* 0           Insert    0x52  */   82
+#define KEY_KP_Decimal   /* . (Decimal) Delete    0x53  */   83 
+#define KEY_SysReqest    /* SysReqest             0x54  */   84
+                         /* NOTUSED               0x55  */
+#define KEY_Less         /* < (Less)   >(Greater) 0x56  */   86
+#define KEY_F11          /* F11                   0x57  */   87
+#define KEY_F12          /* F12                   0x58  */   88
+
+#define KEY_Prefix0      /* special               0x60  */   96
+#define KEY_Prefix1      /* specail               0x61  */   97
+
+/*
+ * The 'scancodes' below are generated by the server, because the MF101/102
+ * keyboard sends them as sequence of other scancodes
+ */
+#define KEY_Home         /* Home                  0x59  */   89
+#define KEY_Up           /* Up                    0x5a  */   90
+#define KEY_PgUp         /* PgUp                  0x5b  */   91
+#define KEY_Left         /* Left                  0x5c  */   92
+#define KEY_Begin        /* Begin                 0x5d  */   93
+#define KEY_Right        /* Right                 0x5e  */   94
+#define KEY_End          /* End                   0x5f  */   95
+#define KEY_Down         /* Down                  0x60  */   96
+#define KEY_PgDown       /* PgDown                0x61  */   97
+#define KEY_Insert       /* Insert                0x62  */   98
+#define KEY_Delete       /* Delete                0x63  */   99
+#define KEY_KP_Enter     /* Enter                 0x64  */  100
+#define KEY_RCtrl        /* Ctrl(right)           0x65  */  101
+#define KEY_Pause        /* Pause                 0x66  */  102
+#define KEY_Print        /* Print                 0x67  */  103
+#define KEY_KP_Divide    /* Didive                0x68  */  104
+#define KEY_AltLang      /* AtlLang(right)        0x69  */  105
+#define KEY_Break        /* Break                 0x6a  */  106
+#define KEY_LMeta        /* Left Meta             0x6b  */  107
+#define KEY_RMeta        /* Right Meta            0x6c  */  108
+#define KEY_Menu         /* Menu                  0x6d  */  109
+#define KEY_F13          /* F13                   0x6e  */  110
+#define KEY_F14          /* F14                   0x6f  */  111
+#define KEY_F15          /* F15                   0x70  */  112
+#define KEY_F16          /* F16                   0x71  */  113
+#define KEY_F17          /* F17                   0x72  */  114
+#define KEY_KP_DEC       /* KP_DEC                0x73  */  115
+#define KEY_SN_KP_7      /* ServerNumLock 7       0x80  */  128
+#define KEY_SN_KP_8      /* ServerNumLock 8       0x81  */  129
+#define KEY_SN_KP_9      /* ServerNumLock 9       0x82  */  130
+#define KEY_SN_KP_4      /* ServerNumLock 4       0x83  */  131
+#define KEY_SN_KP_5      /* ServerNumLock 5       0x84  */  132
+#define KEY_SN_KP_6      /* ServerNumLock 6       0x85  */  133
+#define KEY_SN_KP_1      /* ServerNumLock 1       0x86  */  134
+#define KEY_SN_KP_2      /* ServerNumLock 2       0x87  */  135
+#define KEY_SN_KP_3      /* ServerNumLock 4       0x88  */  136
+#define KEY_SN_KP_0      /* ServerNumLock 0       0x89  */  137
+#define KEY_SN_KP_Dec    /* ServerNumLock Decimal 0x8a  */  138
+#define KEY_SN_KP_Home   /* ServerNumLock Home    0x8b  */  139
+#define KEY_SN_KP_Up     /* ServerNumLock Up      0x8c  */  140
+#define KEY_SN_KP_Prior  /* ServerNumLock Prior   0x8d  */  141
+#define KEY_SN_KP_Left   /* ServerNumLock Left    0x8e  */  142
+#define KEY_SN_KP_Begin  /* ServerNumLock Begin   0x8f  */  143
+#define KEY_SN_KP_Right  /* ServerNumLock Right   0x90  */  144
+#define KEY_SN_KP_End    /* ServerNumLock End     0x91  */  145
+#define KEY_SN_KP_Down   /* ServerNumLock Down    0x92  */  146
+#define KEY_SN_KP_Next   /* ServerNumLock Next    0x93  */  147
+#define KEY_SN_KP_Ins    /* ServerNumLock Ins     0x94  */  148
+#define KEY_SN_KP_Del    /* ServerNumLock Del     0x95  */  149
+
+#else
+
+#define KEY_Escape       /* Escape                0x01  */    0
+#define KEY_1            /* 1           !         0x02  */    1 
+#define KEY_2            /* 2           "         0x03  */    2 
+#define KEY_3            /* 3           #         0x04  */    3 
+#define KEY_4            /* 4           $         0x05  */    4 
+#define KEY_5            /* 5           %         0x06  */    5 
+#define KEY_6            /* 6           &         0x07  */    6 
+#define KEY_7            /* 7           '         0x08  */    7 
+#define KEY_8            /* 8           (         0x09  */    8 
+#define KEY_9            /* 9           )         0x0a  */    9 
+#define KEY_0            /* 0                     0x0b  */   10 
+#define KEY_Minus        /* - (Minus)   = (Equal) 0x0c  */   11
+#define KEY_Hat          /* ^ (Hat)     `         0x0d  */   12 
+#define KEY_BSlash       /* \(BckSlash) |(VertBar)0x2b  */   13
+#define KEY_BackSpace    /* Back Space            0x0e  */   14 
+#define KEY_Tab          /* Tab                   0x0f  */   15
+#define KEY_Q            /* Q                     0x10  */   16
+#define KEY_W            /* W                     0x11  */   17
+#define KEY_E            /* E                     0x12  */   18
+#define KEY_R            /* R                     0x13  */   19
+#define KEY_T            /* T                     0x14  */   20
+#define KEY_Y            /* Y                     0x15  */   21
+#define KEY_U            /* U                     0x16  */   22
+#define KEY_I            /* I                     0x17  */   23
+#define KEY_O            /* O                     0x18  */   24
+#define KEY_P            /* P                     0x19  */   25
+#define KEY_At           /* @           ~         0x1a  */   26
+#define KEY_LBrace       /* [           {         0x1b  */   27 
+#define KEY_Enter        /* Enter                 0x1c  */   28
+#define KEY_A            /* A                     0x1d  */   29
+#define KEY_S            /* S                     0x1e  */   30
+#define KEY_D            /* D                     0x1f  */   31 
+#define KEY_F            /* F                     0x20  */   32
+#define KEY_G            /* G                     0x21  */   33
+#define KEY_H            /* H                     0x22  */   34
+#define KEY_J            /* J                     0x23  */   35
+#define KEY_K            /* K                     0x24  */   36
+#define KEY_L            /* L                     0x25  */   37
+#define KEY_SemiColon    /* ;(SemiColon) +(Plus)  0x26  */   38
+#define KEY_Colon        /* :(Colon)     *(Quote) 0x27  */   39
+#define KEY_RBrace       /* ]           }         0x28  */   40 
+#define KEY_Z            /* Z                     0x29  */   41
+#define KEY_X            /* X                     0x2a  */   42
+#define KEY_C            /* C                     0x2b  */   43
+#define KEY_V            /* V                     0x2c  */   44
+#define KEY_B            /* B                     0x2d  */   45
+#define KEY_N            /* N                     0x2e  */   46
+#define KEY_M            /* M                     0x2f  */   47
+#define KEY_Comma        /* , (Comma)   < (Less)  0x30  */   48
+#define KEY_Period       /* . (Period)  >(Greater)0x31  */   49
+#define KEY_Slash        /* / (Slash)   ?         0x32  */   50
+#define KEY_Under        /*             _         0x33  */   51
+#define KEY_Space        /*   (SpaceBar)          0x34  */   52
+#define KEY_Xfer         /*   (XFER)              0x35  */   53
+#define KEY_PgUp         /* PgUp                  0x36  */   54
+#define KEY_Pgdown       /*   (Roll Down)         0x37  */   55
+#define KEY_Insert       /* Insert                0x38  */   56
+#define KEY_Delete       /* Delete                0x39  */   57
+#define KEY_Up           /* Up                    0x3a  */   58
+#define KEY_Left         /* Left                  0x3b  */   59
+#define KEY_Right        /* Right                 0x3c  */   60
+#define KEY_Down         /* Down                  0x3d  */   61
+#define KEY_Home         /* Home                  0x3e  */   62
+#define KEY_Help         /* Help                  0x3f  */   63
+#define KEY_KP_Subtract  /* - (Minus)             0x40  */   64
+#define KEY_KP_Minus     /* -                           */   64
+#define KEY_KP_Divide    /* / (Slash)             0x41  */   65
+#define KEY_KP_7         /* 7                     0x42  */   66
+#define KEY_KP_8         /* 8                     0x43  */   67 
+#define KEY_KP_9         /* 9                     0x44  */   68 
+#define KEY_KP_Multiply  /* *                     0x45  */   69
+#define KEY_KP_4         /* 4                     0x46  */   70
+#define KEY_KP_5         /* 5                     0x47  */   71
+#define KEY_KP_6         /* 6                     0x48  */   72
+#define KEY_KP_Add       /* + (Plus)              0x49  */   73
+#define KEY_KP_Plus      /* +                           */   73
+#define KEY_KP_1         /* 1                     0x4a  */   74
+#define KEY_KP_2         /* 2                     0x4b  */   75
+#define KEY_KP_3         /* 3                     0x4c  */   76
+#define KEY_KP_Equal     /* =                     0x4d  */   77
+#define KEY_KP_0         /* 0                     0x4e  */   78
+#define KEY_KP_Separator /* ,                     0x4f  */   79
+#define KEY_KP_Decimal   /* . (Decimal)           0x50  */   80
+#define KEY_Nfer         /*   (NFER)              0x51  */   81
+#define KEY_F11          /* F11                   0x52  */   82
+#define KEY_F12          /* F12                   0x53  */   83
+#define KEY_F13          /* F13                   0x54  */   84
+#define KEY_F14          /* F14                   0x55  */   85
+#define KEY_F15          /* F15                   0x56  */   86
+#define KEY_Break        /* (Stop)                0x60  */   96
+#define KEY_Copy         /* (Copy)                0x61  */   97
+#define KEY_Begin        /* Begin ??                    */   97
+#define KEY_F1           /* F1                    0x62  */   98
+#define KEY_F2           /* F2                    0x63  */   99
+#define KEY_F3           /* F3                    0x64  */  100
+#define KEY_F4           /* F4                    0x65  */  101
+#define KEY_F5           /* F5                    0x66  */  102
+#define KEY_F6           /* F6                    0x67  */  103
+#define KEY_F7           /* F7                    0x68  */  104
+#define KEY_F8           /* F8                    0x69  */  105
+#define KEY_F9           /* F9                    0x6a  */  106
+#define KEY_F10          /* F10                   0x6b  */  107
+#define KEY_ShiftL       /* Shift(left)           0x70  */  112
+#define KEY_CapsLock     /* CapsLock              0x71  */  113
+#define KEY_KanaLock	 /* Kana                  0x72  */  114
+#define KEY_Alt          /* Alt(left)             0x73  */  115
+#define KEY_LCtrl        /* Ctrl(left)            0x74  */  116
+
+#endif /* PC98 */
+
+#endif /* _ATKEYNAMES_H */
Index: xc/programs/Xserver/hw/xwin/xf_dx.h
diff -u /dev/null xc/programs/Xserver/hw/xwin/xf_dx.h:1.1
--- /dev/null	Mon Dec 18 14:33:05 2000
+++ xc/programs/Xserver/hw/xwin/xf_dx.h	Thu Aug 10 13:40:38 2000
@@ -0,0 +1,106 @@
+/*
+ * (c) Copyright 2000 by Peter Busch
+ *                      <pbusch@dfki.de>
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PETER BUSCH  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Peter Busch shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Peter Busch.
+ *
+*/
+/* $XFree86: xc/programs/Xserver/hw/xwin/xf_dx.h,v 1.1 2000/08/10 17:40:38 dawes Exp $ */
+
+#ifndef __XF_DX_H__
+#define __XF_DX_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef BOOL (__cdecl *_DIInitKeyboard)();
+
+typedef BOOL (__cdecl *_DIInitMouse)();
+
+typedef void (__cdecl *_DITermKeyboard)();
+
+typedef void (__cdecl *_DITermMouse)();
+
+typedef BOOL (__cdecl *_DXStoreColors)( int i, int r, int g, int b );
+
+typedef void (__cdecl *_ListModes)();
+
+typedef char*( __cdecl *_AllocateFramebuffer)
+	(
+	int*		width,
+	int*		height,
+	int*		depth,
+	int*		pitch
+	);
+
+typedef void (__cdecl *_winfbBlockHandler)();
+
+typedef int  (__cdecl *_winfbWakeupHandler)();
+
+typedef void (__cdecl *_SwitchFramebuffer)( void * ptr );
+
+typedef void (__cdecl *_GenerateInputEvent)( 
+	unsigned long type,
+	int ix,
+	int iy,
+	int button
+	); 
+
+typedef void (__cdecl *_set_fn)( 
+	_SwitchFramebuffer switch_fb, 
+	_GenerateInputEvent gen_inp
+	);
+
+
+/*
+* interface of the xf_dx_library
+*/
+
+typedef struct _xf_dx_rec
+{
+	_DIInitKeyboard			xf_dx_init_keybd;
+	_DIInitMouse			xf_dx_init_mouse;
+	_DITermKeyboard			xf_dx_term_keybd;
+	_DITermMouse			xf_dx_term_mouse;
+	_DXStoreColors			xf_dx_store_colors;
+	_ListModes				xf_dx_list_modes;
+	_AllocateFramebuffer	xf_dx_alloc_fb;
+	_winfbBlockHandler		xf_dx_block_proc;
+	_winfbWakeupHandler		xf_dx_wakeup_proc;
+	_SwitchFramebuffer		xf_dx_switch_buffer;
+	_GenerateInputEvent		xf_dx_gen_input; 
+	_set_fn					xf_dx_set_fn;
+} xf_dx_rec, *xf_dx_ptr;
+
+int __cdecl xf_dx_init( xf_dx_ptr *dx_ptr );
+
+
+#ifdef __cplusplus
+} /* extern "C" { */
+#endif
+
+
+#endif /* __XF_DX_H__ */
Index: xc/programs/Xserver/hw/xwin/xf_dx_xwin.h
diff -u /dev/null xc/programs/Xserver/hw/xwin/xf_dx_xwin.h:1.1
--- /dev/null	Mon Dec 18 14:33:05 2000
+++ xc/programs/Xserver/hw/xwin/xf_dx_xwin.h	Thu Aug 10 13:40:38 2000
@@ -0,0 +1,40 @@
+/*
+ * (c) Copyright 2000 by Peter Busch
+ *                      <pbusch@dfki.de>
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PETER BUSCH  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Peter Busch shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Peter Busch.
+ *
+*/
+/* $XFree86: xc/programs/Xserver/hw/xwin/xf_dx_xwin.h,v 1.1 2000/08/10 17:40:38 dawes Exp $ */
+
+#ifndef __XF_DX_CALLBACK_H__
+#define __XF_DX_CALLBACK_H__
+
+
+typedef void (__cdecl *__SwitchFramebuffer)( void * ptr );
+typedef void (__cdecl *__GenerateInputEvent)( type, ix, iy, button ); 
+
+
+
+#endif
Index: xc/programs/Xserver/ilbm/Imakefile
diff -u xc/programs/Xserver/ilbm/Imakefile:3.6 xc/programs/Xserver/ilbm/Imakefile:3.7
--- xc/programs/Xserver/ilbm/Imakefile:3.6	Wed Jan 19 17:37:36 2000
+++ xc/programs/Xserver/ilbm/Imakefile	Thu Aug 24 18:20:18 2000
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/ilbm/Imakefile,v 3.6 2000/01/19 22:37:36 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/ilbm/Imakefile,v 3.7 2000/08/24 22:20:18 tsi Exp $
 XCOMM $XConsortium: Imakefile,v 1.38 94/03/11 18:47:47 dpw Exp $
 #define IHaveModules
 #include <Server.tmpl>
@@ -32,7 +32,7 @@
 	   ../mfb/llib-lmfb.ln ../mi/llib-lmi.ln
 
 NormalLibraryObjectRule()
-NormalLibraryTarget(ilbm,$(OBJS))
+LibraryModuleTarget(ilbm,$(OBJS))
 LintLibraryTarget(ilbm,$(SRCS1))
 NormalLintTarget($(LINTDEFS) $(SRCS1))
 
Index: xc/programs/Xserver/include/Imakefile
diff -u xc/programs/Xserver/include/Imakefile:3.16 xc/programs/Xserver/include/Imakefile:3.20
--- xc/programs/Xserver/include/Imakefile:3.16	Mon Dec 13 20:34:00 1999
+++ xc/programs/Xserver/include/Imakefile	Tue Oct 24 14:07:52 2000
@@ -1,18 +1,21 @@
 XCOMM $XConsortium: Imakefile,v 1.2 95/01/13 20:28:14 kaleb Exp $
-XCOMM $XFree86: xc/programs/Xserver/include/Imakefile,v 3.16 1999/12/14 01:34:00 robin Exp $
+XCOMM $XFree86: xc/programs/Xserver/include/Imakefile,v 3.20 2000/10/24 18:07:52 dawes Exp $
 
-#ifdef XFree86Version
+#if defined(XFree86Version) || defined(BSDOSArchitecture)
 #if DoLoadableServer
-LinkSourceFile(xf86_libc.h,$(XF86OSSRC))
-LinkSourceFile(xf86_ansic.h,$(XF86OSSRC))
 LinkSourceFile(xf86Module.h,$(XF86COMSRC))
 LinkSourceFile(xf86Opt.h,$(XF86COMSRC))
 #endif
+LinkSourceFile(xf86_libc.h,$(XF86OSSRC))
+LinkSourceFile(xf86_ansic.h,$(XF86OSSRC))
 LinkSourceFile(xf86Version.h,$(XF86SRC))
 LinkSourceFile(compiler.h,$(XF86COMSRC))
 #endif
 
 LinkSourceFile(osdep.h,../os)
+#ifdef cygwinArchitecture
+LinkFile(xxwindow.h,window.h)
+#endif
 
 all::
 
Index: xc/programs/Xserver/include/dix.h
diff -u xc/programs/Xserver/include/dix.h:3.13 xc/programs/Xserver/include/dix.h:3.14
--- xc/programs/Xserver/include/dix.h:3.13	Thu May 18 19:46:23 2000
+++ xc/programs/Xserver/include/dix.h	Thu Aug 31 15:03:59 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/include/dix.h,v 3.13 2000/05/18 23:46:23 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/include/dix.h,v 3.14 2000/08/31 19:03:59 tsi Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -291,11 +291,7 @@
 extern ClientPtr serverClient;
 extern int currentMaxClients;
 
-#if !(defined(__alpha) || defined(__alpha__))
-typedef long HWEventQueueType;
-#else
 typedef int HWEventQueueType;
-#endif
 typedef HWEventQueueType* HWEventQueuePtr;
 
 extern HWEventQueuePtr checkForInput[2];
Index: xc/programs/Xserver/include/misc.h
diff -u xc/programs/Xserver/include/misc.h:3.22 xc/programs/Xserver/include/misc.h:3.24
--- xc/programs/Xserver/include/misc.h:3.22	Sat Aug 21 09:48:44 1999
+++ xc/programs/Xserver/include/misc.h	Wed Aug 23 18:10:15 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/include/misc.h,v 3.22 1999/08/21 13:48:44 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/include/misc.h,v 3.24 2000/08/23 22:10:15 tsi Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -84,7 +84,7 @@
 #ifndef X_NOT_STDC_ENV
 #include <stddef.h>
 #else
-#define NULL            0
+#define NULL            ((void *)0)
 #endif
 #endif
 #endif
@@ -140,6 +140,9 @@
 /* byte swap a short literal */
 #define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
 
+#undef min
+#undef max
+
 #define min(a, b) (((a) < (b)) ? (a) : (b))
 #define max(a, b) (((a) > (b)) ? (a) : (b))
 #ifndef IN_MODULE
@@ -178,6 +181,12 @@
  * Some implementations #define these through <math.h>, so preclude
  * #include'ing it later.
  */
+
+#ifdef __CYGWIN__
+/* needed to avoid INFINITY redeclarations from CYGWIN math.h */
+#define __STRICT_ANSI__
+#endif
+
 #include <math.h>
 #endif
 #undef MAXSHORT
Index: xc/programs/Xserver/include/os.h
diff -u xc/programs/Xserver/include/os.h:3.34 xc/programs/Xserver/include/os.h:3.36
--- xc/programs/Xserver/include/os.h:3.34	Thu Jun 15 21:50:21 2000
+++ xc/programs/Xserver/include/os.h	Thu Nov 30 18:30:06 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/include/os.h,v 3.34 2000/06/16 01:50:21 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/include/os.h,v 3.36 2000/11/30 23:30:06 dawes Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -544,6 +544,18 @@
 #endif
 );
 
+void OsBlockSignals (
+#if NeedFunctionPrototypes
+		     void
+#endif		     
+		     );
+
+void OsReleaseSignals (
+#if NeedFunctionPrototypes
+		     void
+#endif		     
+		     );
+
 #if !defined(WIN32) && !defined(__EMX__)
 extern int System(char *);
 extern pointer Popen(char *, char *);
@@ -555,6 +567,7 @@
 #endif
 
 extern void CheckUserParameters(int argc, char **argv, char **envp);
+extern void CheckUserAuthorization(void);
 
 extern int AddHost(
 #if NeedFunctionPrototypes
Index: xc/programs/Xserver/include/resource.h
diff -u xc/programs/Xserver/include/resource.h:1.4 xc/programs/Xserver/include/resource.h:1.5
--- xc/programs/Xserver/include/resource.h:1.4	Sat Jan  1 19:24:53 2000
+++ xc/programs/Xserver/include/resource.h	Thu Aug 10 13:40:39 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/include/resource.h,v 1.4 2000/01/02 00:24:53 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/include/resource.h,v 1.5 2000/08/10 17:40:39 dawes Exp $ */
 
 /* $TOG: resource.h /main/24 1998/02/09 14:29:47 kaleb $ */
 /***********************************************************
@@ -72,6 +72,8 @@
 #define RT_WINDOW	((RESTYPE)1|RC_CACHED|RC_DRAWABLE)
 #define RT_PIXMAP	((RESTYPE)2|RC_CACHED|RC_DRAWABLE)
 #define RT_GC		((RESTYPE)3|RC_CACHED)
+#undef RT_FONT
+#undef RT_CURSOR
 #define RT_FONT		((RESTYPE)4)
 #define RT_CURSOR	((RESTYPE)5)
 #define RT_COLORMAP	((RESTYPE)6)
Index: xc/programs/Xserver/include/servermd.h
diff -u xc/programs/Xserver/include/servermd.h:3.39 xc/programs/Xserver/include/servermd.h:3.42
--- xc/programs/Xserver/include/servermd.h:3.39	Thu May 18 12:30:02 2000
+++ xc/programs/Xserver/include/servermd.h	Mon Nov  6 14:24:09 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/include/servermd.h,v 3.39 2000/05/18 16:30:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/include/servermd.h,v 3.42 2000/11/06 19:24:09 dawes Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -149,14 +149,32 @@
 
 #endif /* __arm32__ */
 
-#if (defined(Lynx) && defined(__powerpc__))
+#ifdef __DARWIN__
 
-/* For now this is for Xvfb only */
 #define IMAGE_BYTE_ORDER        MSBFirst
 #define BITMAP_BIT_ORDER        MSBFirst
 #define GLYPHPADBYTES           4
 #define GETLEFTBITS_ALIGNMENT   1
+
+#define LARGE_INSTRUCTION_CACHE
+#define FAST_CONSTANT_OFFSET_MODE
+#define PLENTIFUL_REGISTERS
+#define AVOID_MEMORY_READ
+#define FAST_MEMCPY
+
+#endif /* __DARWIN__ */
+
+#if defined(__powerpc__)
+
+#define IMAGE_BYTE_ORDER        MSBFirst
+#define BITMAP_BIT_ORDER        MSBFirst
+#define GLYPHPADBYTES           4
+#define GETLEFTBITS_ALIGNMENT   1
+
+/* XXX Should this be for Lynx only? */
+#ifdef Lynx
 #define BITMAP_SCANLINE_UNIT	8
+#endif
 
 #define LARGE_INSTRUCTION_CACHE
 #define FAST_CONSTANT_OFFSET_MODE
@@ -165,7 +183,7 @@
 
 #define FAST_MEMCPY
 
-#endif /* LynxOS PowerPC */
+#endif /* PowerPC */
 
 #if (defined(sun) && !(defined(i386) && defined(SVR4))) || \
     (defined(AMOEBA) && (defined(sparc) || defined(mc68000))) || \
@@ -309,7 +327,7 @@
 #endif /* alpha */
 
 
-#if defined(__ia64__)
+#if defined(__ia64__) || defined(ia64)
 # define IMAGE_BYTE_ORDER	LSBFirst
 
 # if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
@@ -362,7 +380,7 @@
 
 #if	(defined(AMOEBA) && defined(i80386)) || \
 	(defined(SVR4) && defined(i386)) || \
-	defined(__alpha__) || \
+	defined(__alpha__) || defined(__alpha) || \
 	defined(__i386__) || \
 	defined(__EMX__) || \
 	defined(__OS2ELF__) || \
@@ -412,22 +430,6 @@
 #define GETLEFTBITS_ALIGNMENT  1
 
 #endif /* linux/m68k */
-
-#if defined (linux) && defined(__powerpc__)
-
-#define IMAGE_BYTE_ORDER       MSBFirst
-#define BITMAP_BIT_ORDER       MSBFirst
-#define GLYPHPADBYTES          4
-#define GETLEFTBITS_ALIGNMENT  1
-
-#define LARGE_INSTRUCTION_CACHE
-#define FAST_CONSTANT_OFFSET_MODE
-#define PLENTIFUL_REGISTERS
-#define AVOID_MEMORY_READ
-
-#define FAST_MEMCPY
-
-#endif /* Linux/PPC */
 
 #ifdef sgi
 
Index: xc/programs/Xserver/include/windowstr.h
diff -u xc/programs/Xserver/include/windowstr.h:1.1.1.3 xc/programs/Xserver/include/windowstr.h:1.3
--- xc/programs/Xserver/include/windowstr.h:1.1.1.3	Sun Sep 27 04:03:09 1998
+++ xc/programs/Xserver/include/windowstr.h	Fri Aug 11 19:59:48 2000
@@ -41,11 +41,16 @@
 SOFTWARE.
 
 ******************************************************************/
+/* $XFree86: xc/programs/Xserver/include/windowstr.h,v 1.3 2000/08/11 23:59:48 dawes Exp $ */
 
 #ifndef WINDOWSTRUCT_H
 #define WINDOWSTRUCT_H
 
+#ifndef __CYGWIN__
 #include "window.h"
+#else
+#include "xxwindow.h"
+#endif
 #include "pixmapstr.h"
 #include "regionstr.h"
 #include "cursor.h"
Index: xc/programs/Xserver/mfb/maskbits.h
diff -u xc/programs/Xserver/mfb/maskbits.h:3.6 xc/programs/Xserver/mfb/maskbits.h:3.7
--- xc/programs/Xserver/mfb/maskbits.h:3.6	Fri Feb 11 22:40:00 2000
+++ xc/programs/Xserver/mfb/maskbits.h	Tue Nov 21 19:58:13 2000
@@ -22,7 +22,7 @@
 
 ******************************************************************/
 /* $XConsortium: maskbits.h,v 1.33 94/04/17 20:28:13 dpw Exp $ */
-/* $XFree86: xc/programs/Xserver/mfb/maskbits.h,v 3.6 2000/02/12 03:40:00 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/mfb/maskbits.h,v 3.7 2000/11/22 00:58:13 tsi Exp $ */
 #include "X.h"
 #include "Xmd.h"
 #include "servermd.h"
@@ -387,9 +387,10 @@
     } \
     else \
     { \
+	register int d = PPW-(x); \
 	*(pdst) = (*(pdst) & endtab[x]) | (SCRRIGHT((src), x)); \
 	(pdst)[1] = ((pdst)[1] & starttab[n]) | \
-		(SCRLEFT(src, PPW-(x)) & endtab[n]); \
+		(SCRLEFT(src, d) & endtab[n]); \
     } \
 }
 
Index: xc/programs/Xserver/mfb/mergerop.h
diff -u xc/programs/Xserver/mfb/mergerop.h:3.9 xc/programs/Xserver/mfb/mergerop.h:3.10
--- xc/programs/Xserver/mfb/mergerop.h:3.9	Fri Feb 11 22:40:00 2000
+++ xc/programs/Xserver/mfb/mergerop.h	Tue Oct 17 12:53:20 2000
@@ -21,7 +21,7 @@
  *
  * Author:  Keith Packard, MIT X Consortium
  */
-/* $XFree86: xc/programs/Xserver/mfb/mergerop.h,v 3.9 2000/02/12 03:40:00 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/mfb/mergerop.h,v 3.10 2000/10/17 16:53:20 tsi Exp $ */
 
 #ifndef _MERGEROP_H_
 #define _MERGEROP_H_
@@ -36,7 +36,7 @@
 
 extern mergeRopRec	mergeRopBits[16];
 
-#if PPW != PGSZ	/* cfb */
+#if defined(PPW) && defined(PGSZ) && (PPW != PGSZ)	/* cfb */
 #define DeclareMergeRop() MfbBits   _ca1, _cx1, _ca2, _cx2;
 #define DeclarePrebuiltMergeRop()	MfbBits	_cca, _ccx;
 #if PSZ == 24  /* both for PGSZ == 32 and 64 */
@@ -50,7 +50,7 @@
 #define DeclarePrebuiltMergeRop()	MfbBits	_cca, _ccx;
 #endif
 
-#if PPW != PGSZ	/* cfb */
+#if defined(PPW) && defined(PGSZ) && (PPW != PGSZ)	/* cfb */
 #define InitializeMergeRop(alu,pm) {\
     MfbBits   _pm; \
     mergeRopPtr  _bits; \
Index: xc/programs/Xserver/mfb/mfbfillsp.c
diff -u xc/programs/Xserver/mfb/mfbfillsp.c:1.6 xc/programs/Xserver/mfb/mfbfillsp.c:1.7
--- xc/programs/Xserver/mfb/mfbfillsp.c:1.6	Fri Feb 11 22:40:02 2000
+++ xc/programs/Xserver/mfb/mfbfillsp.c	Wed Aug 23 18:10:17 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/mfb/mfbfillsp.c,v 1.6 2000/02/12 03:40:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/mfb/mfbfillsp.c,v 1.7 2000/08/23 22:10:17 tsi Exp $ */
 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
 /***********************************************************
 
@@ -837,7 +837,7 @@
 		    {
 			putbitsrop(*psrc, (x & PIM), nstart, pdst, rop);
 			pdst++;
-#ifdef __alpha__
+#if defined(__alpha__) || defined(__alpha)
 			/*
 			 * XXX workaround an egcs 1.1.2 code generation
 			 * bug. This version might actually be faster.
Index: xc/programs/Xserver/mi/Imakefile
diff -u xc/programs/Xserver/mi/Imakefile:3.30 xc/programs/Xserver/mi/Imakefile:3.31
--- xc/programs/Xserver/mi/Imakefile:3.30	Fri Mar 31 17:55:54 2000
+++ xc/programs/Xserver/mi/Imakefile	Mon Oct  2 18:54:35 2000
@@ -1,5 +1,5 @@
 XCOMM $XConsortium: Imakefile /main/44 1996/12/02 10:22:16 lehors $
-XCOMM $XFree86: xc/programs/Xserver/mi/Imakefile,v 3.30 2000/03/31 22:55:54 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/mi/Imakefile,v 3.31 2000/10/02 22:54:35 keithp Exp $
 #include <Server.tmpl>
 
 #if ! HasCbrt
@@ -47,7 +47,7 @@
 EXT_DEFINES = ExtensionDefines
 #endif
 
-INCLUDES = -I. -I../include -I../../../include/fonts \
+INCLUDES = -I. -I../include -I../../../include/fonts -I../render \
            -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext
 LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
 
Index: xc/programs/Xserver/mi/micmap.c
diff -u xc/programs/Xserver/mi/micmap.c:1.9 xc/programs/Xserver/mi/micmap.c:1.10
--- xc/programs/Xserver/mi/micmap.c:1.9	Sat Jan 29 13:58:37 2000
+++ xc/programs/Xserver/mi/micmap.c	Tue Sep 19 20:09:14 2000
@@ -27,7 +27,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
-/* $XFree86: xc/programs/Xserver/mi/micmap.c,v 1.9 2000/01/29 18:58:37 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/micmap.c,v 1.10 2000/09/20 00:09:14 keithp Exp $ */
 
 /*
  * This is based on cfbcmap.c.  The functions here are useful independently
@@ -104,41 +104,18 @@
     int shift = 16 - pVisual->bitsPerRGBValue;
     unsigned lim = (1 << pVisual->bitsPerRGBValue) - 1;
 
-    if ((pVisual->class == PseudoColor) || (pVisual->class == DirectColor))
+    if ((pVisual->class | DynamicClass) == GrayScale)
     {
-	/* rescale to rgb bits */
-	*pred = ((*pred >> shift) * 65535) / lim;
-	*pgreen = ((*pgreen >> shift) * 65535) / lim;
-	*pblue = ((*pblue >> shift) * 65535) / lim;
-    }
-    else if (pVisual->class == GrayScale)
-    {
 	/* rescale to gray then rgb bits */
 	*pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100;
 	*pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim;
     }
-    else if (pVisual->class == StaticGray)
-    {
-	unsigned limg = pVisual->ColormapEntries - 1;
-	/* rescale to gray then [0..limg] then [0..65535] then rgb bits */
-	*pred = (30L * *pred + 59L * *pgreen + 11L * *pblue) / 100;
-	*pred = ((((*pred * (limg + 1))) >> 16) * 65535) / limg;
-	*pblue = *pgreen = *pred = ((*pred >> shift) * 65535) / lim;
-    }
     else
     {
-	unsigned limr, limg, limb;
-
-	limr = pVisual->redMask >> pVisual->offsetRed;
-	limg = pVisual->greenMask >> pVisual->offsetGreen;
-	limb = pVisual->blueMask >> pVisual->offsetBlue;
-	/* rescale to [0..limN] then [0..65535] then rgb bits */
-	*pred = ((((((*pred * (limr + 1)) >> 16) *
-		    65535) / limr) >> shift) * 65535) / lim;
-	*pgreen = ((((((*pgreen * (limg + 1)) >> 16) *
-		      65535) / limg) >> shift) * 65535) / lim;
-	*pblue = ((((((*pblue * (limb + 1)) >> 16) *
-		     65535) / limb) >> shift) * 65535) / lim;
+	/* rescale to rgb bits */
+	*pred = ((*pred >> shift) * 65535) / lim;
+	*pgreen = ((*pgreen >> shift) * 65535) / lim;
+	*pblue = ((*pblue >> shift) * 65535) / lim;
     }
 }
 
@@ -470,6 +447,33 @@
 	return SMALL_VISUALS;
 }
 
+Bool
+miVisualTypesSet (int depth)
+{
+    miVisualsPtr    visuals;
+
+    for (visuals = miVisuals; visuals; visuals = visuals->next)
+	if (visuals->depth == depth)
+	    return TRUE;
+    return FALSE;
+}
+
+Bool
+miSetPixmapDepths (void)
+{
+    int	d, f;
+    
+    /* Add any unlisted depths from the pixmap formats */
+    for (f = 0; f < screenInfo.numPixmapFormats; f++) 
+    {
+	d = screenInfo.formats[f].depth;
+	if (!miVisualTypesSet (d))
+	{
+	    if (!miSetVisualTypes (d, 0, 0, -1))
+		return FALSE;
+	}
+    }
+}
 
 Bool
 miInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp,
Index: xc/programs/Xserver/mi/micmap.h
diff -u xc/programs/Xserver/mi/micmap.h:1.6 xc/programs/Xserver/mi/micmap.h:1.7
--- xc/programs/Xserver/mi/micmap.h:1.6	Sat Jan 29 13:58:37 2000
+++ xc/programs/Xserver/mi/micmap.h	Tue Sep 19 20:09:15 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/mi/micmap.h,v 1.6 2000/01/29 18:58:37 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/micmap.h,v 1.7 2000/09/20 00:09:15 keithp Exp $ */
 
 #include "colormapst.h"
 
@@ -24,6 +24,7 @@
 Bool miCreateDefColormap(ScreenPtr);
 void miClearVisualTypes(void);
 Bool miSetVisualTypes(int, int, int, int);
+Bool miSetPixmapDepths(void);
 Bool miSetVisualTypesAndMasks(int depth, int visuals, int bitsPerRGB, 
 			      int preferredCVC,
 			      Pixel redMask, Pixel greenMask, Pixel blueMask);
Index: xc/programs/Xserver/mi/micoord.h
diff -u /dev/null xc/programs/Xserver/mi/micoord.h:1.1
--- /dev/null	Mon Dec 18 14:33:21 2000
+++ xc/programs/Xserver/mi/micoord.h	Mon Oct 23 17:16:52 2000
@@ -0,0 +1,67 @@
+/* $XFree86: xc/programs/Xserver/mi/micoord.h,v 1.1 2000/10/23 21:16:52 tsi Exp $ */
+/*
+ * Copyright (C) 2000 The XFree86 Project, Inc.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ *
+ */
+
+#ifndef _MICOORD_H_
+#define _MICOORD_H_ 1
+
+/* Macros which handle a coordinate in a single register */
+
+/*
+ * Most compilers will convert divisions by 65536 into shifts, if signed
+ * shifts exist.  If your machine does arithmetic shifts and your compiler
+ * can't get it right, add to this line.
+ */
+
+/*
+ * mips compiler - what a joke - it CSEs the 65536 constant into a reg
+ * forcing as to use div instead of shift.  Let's be explicit.
+ */
+
+#if defined(mips) || \
+    defined(sparc) || \
+    defined(__alpha) || defined(__alpha__) || \
+    defined(__i386__) || defined(i386) || \
+    defined(__ia64__) || defined(ia64)
+#define GetHighWord(x) (((int) (x)) >> 16)
+#else
+#define GetHighWord(x) (((int) (x)) / 65536)
+#endif
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define intToCoord(i,x,y)   (((x) = GetHighWord(i)), ((y) = (int) ((short) (i))))
+#define coordToInt(x,y)	(((x) << 16) | ((y) & 0xffff))
+#define intToX(i)	(GetHighWord(i))
+#define intToY(i)	((int) ((short) i))
+#else
+#define intToCoord(i,x,y)   (((x) = (int) ((short) (i))), ((y) = GetHighWord(i)))
+#define coordToInt(x,y)	(((y) << 16) | ((x) & 0xffff))
+#define intToX(i)	((int) ((short) (i)))
+#define intToY(i)	(GetHighWord(i))
+#endif
+
+#endif /* _MICOORD_H_ */
Index: xc/programs/Xserver/mi/miinitext.c
diff -u xc/programs/Xserver/mi/miinitext.c:3.50 xc/programs/Xserver/mi/miinitext.c:3.53
--- xc/programs/Xserver/mi/miinitext.c:3.50	Mon Apr 17 12:30:14 2000
+++ xc/programs/Xserver/mi/miinitext.c	Tue Oct 24 18:45:11 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.50 2000/04/17 16:30:14 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.53 2000/10/24 22:45:11 dawes Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -209,15 +209,15 @@
 #ifdef DPMSExtension
 extern void DPMSExtensionInit(INITARGS);
 #endif
-#ifdef XANTI
-extern void XAntiExtensionInit(INITARGS);
-#endif
-#ifdef DPS
+#ifdef DPSEXT
 extern void DPSExtensionInit(INITARGS);
 #endif
 #ifdef FONTCACHE
 extern void FontCacheExtensionInit(INITARGS);
 #endif
+#ifdef RENDER
+extern void RenderExtensionInit(INITARGS);
+#endif
 
 #ifndef XFree86LOADER
 
@@ -316,9 +316,6 @@
 #ifdef FONTCACHE
     FontCacheExtensionInit();
 #endif
-#ifdef XANTI
-    XAntiExtensionInit();
-#endif
 #ifdef XF86BIGFONT
     XFree86BigfontExtensionInit();
 #endif
@@ -348,6 +345,9 @@
     DPSExtensionInit();
 #endif
 #endif
+#ifdef RENDER
+    RenderExtensionInit();
+#endif
 }
 
 void
@@ -409,11 +409,11 @@
 #else
     { NULL, "NOXINERAMA", NULL, NULL },
 #endif
-    { NULL, "XAnti", NULL, NULL },
     { NULL, "XFree86-Bigfont", NULL, NULL },
     { NULL, "XFree86-DRI", NULL, NULL },
     { NULL, "Adobe-DPS-Extension", NULL, NULL },
     { NULL, "FontCache", NULL, NULL },
+    { NULL, "RENDER", NULL, NULL },
     { NULL, NULL, NULL, NULL }
 };
 #endif
@@ -461,6 +461,9 @@
 #endif
 #ifdef XF86BIGFONT
     { XFree86BigfontExtensionInit, XF86BIGFONTNAME, NULL, NULL, NULL },
+#endif
+#ifdef RENDER
+    { RenderExtensionInit, "RENDER", NULL, NULL, NULL },
 #endif
     { NULL, NULL, NULL, NULL, NULL }
 };
Index: xc/programs/Xserver/mi/miscrinit.c
diff -u xc/programs/Xserver/mi/miscrinit.c:3.11 xc/programs/Xserver/mi/miscrinit.c:3.12
--- xc/programs/Xserver/mi/miscrinit.c:3.11	Tue Mar  7 08:37:51 2000
+++ xc/programs/Xserver/mi/miscrinit.c	Fri Aug 25 20:23:19 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/Xserver/mi/miscrinit.c,v 3.11 2000/03/07 13:37:51 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/miscrinit.c,v 3.12 2000/08/26 00:23:19 keithp Exp $ */
 
 #include "X.h"
 #include "servermd.h"
@@ -299,6 +299,13 @@
     pScreen->SetShape = miSetShape;
 #endif
     pScreen->MarkUnrealizedWindow = miMarkUnrealizedWindow;
+
+    pScreen->SaveDoomedAreas = 0;
+    pScreen->RestoreAreas = 0;
+    pScreen->ExposeCopy = 0;
+    pScreen->TranslateBackingStore = 0;
+    pScreen->ClearBackingStore = 0;
+    pScreen->DrawGuarantee = 0;
 
     miSetZeroLineBias(pScreen, DEFAULTZEROLINEBIAS);
 
Index: xc/programs/Xserver/mi/misprite.c
diff -u xc/programs/Xserver/mi/misprite.c:3.2 xc/programs/Xserver/mi/misprite.c:3.5
--- xc/programs/Xserver/mi/misprite.c:3.2	Fri Nov 19 08:55:09 1999
+++ xc/programs/Xserver/mi/misprite.c	Thu Nov 16 14:45:06 2000
@@ -26,7 +26,7 @@
 used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization from The Open Group.
 */
-/* $XFree86: xc/programs/Xserver/mi/misprite.c,v 3.2 1999/11/19 13:55:09 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/misprite.c,v 3.5 2000/11/16 19:45:06 eich Exp $ */
 
 # include   "X.h"
 # include   "Xproto.h"
@@ -44,6 +44,9 @@
 # include   "mispritest.h"
 # include   "dixfontstr.h"
 # include   "fontstruct.h"
+#ifdef RENDER
+# include   "mipict.h"
+#endif
 
 /*
  * screen wrappers
@@ -66,6 +69,31 @@
 static void	    miSpriteCopyWindow();
 static void	    miSpriteClearToBackground();
 
+#ifdef RENDER
+static void	    miSpriteComposite(CARD8	op,
+				      PicturePtr pSrc,
+				      PicturePtr pMask,
+				      PicturePtr pDst,
+				      INT16	xSrc,
+				      INT16	ySrc,
+				      INT16	xMask,
+				      INT16	yMask,
+				      INT16	xDst,
+				      INT16	yDst,
+				      CARD16	width,
+				      CARD16	height);
+
+static void	    miSpriteGlyphs(CARD8	op,
+				   PicturePtr	pSrc,
+				   PicturePtr	pDst,
+				   PictFormatPtr maskFormat,
+				   INT16	xSrc,
+				   INT16	ySrc,
+				   int		nlist,
+				   GlyphListPtr	list,
+				   GlyphPtr	*glyphs);
+#endif
+
 static void	    miSpriteSaveDoomedAreas();
 static RegionPtr    miSpriteRestoreAreas();
 static void	    miSpriteComputeSaved();
@@ -227,6 +255,9 @@
 {
     miSpriteScreenPtr	pPriv;
     VisualPtr		pVisual;
+#ifdef RENDER
+    PictureScreenPtr	ps = GetPictureScreenIfSet(pScreen);
+#endif
     
     if (miSpriteGeneration != serverGeneration)
     {
@@ -267,7 +298,14 @@
 
     pPriv->SaveDoomedAreas = pScreen->SaveDoomedAreas;
     pPriv->RestoreAreas = pScreen->RestoreAreas;
-
+#ifdef RENDER
+    if (ps)
+    {
+	pPriv->Composite = ps->Composite;
+	pPriv->Glyphs = ps->Glyphs;
+    }
+#endif
+    
     pPriv->pCursor = NULL;
     pPriv->x = 0;
     pPriv->y = 0;
@@ -302,6 +340,13 @@
 
     pScreen->SaveDoomedAreas = miSpriteSaveDoomedAreas;
     pScreen->RestoreAreas = miSpriteRestoreAreas;
+#ifdef RENDER
+    if (ps)
+    {
+	ps->Composite = miSpriteComposite;
+	ps->Glyphs = miSpriteGlyphs;
+    }
+#endif
 
     return TRUE;
 }
@@ -320,6 +365,9 @@
     ScreenPtr	pScreen;
 {
     miSpriteScreenPtr   pScreenPriv;
+#ifdef RENDER
+    PictureScreenPtr	ps = GetPictureScreenIfSet(pScreen);
+#endif
 
     pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
 
@@ -339,7 +387,13 @@
 
     pScreen->SaveDoomedAreas = pScreenPriv->SaveDoomedAreas;
     pScreen->RestoreAreas = pScreenPriv->RestoreAreas;
-
+#ifdef RENDER
+    if (ps)
+    {
+	ps->Composite = pScreenPriv->Composite;
+	ps->Glyphs = pScreenPriv->Glyphs;
+    }
+#endif
     xfree ((pointer) pScreenPriv);
 
     return (*pScreen->CloseScreen) (i, pScreen);
@@ -1842,6 +1896,133 @@
 miSpriteLineHelper()
 {
     FatalError("miSpriteLineHelper called\n");
+}
+#endif
+
+#ifdef RENDER
+
+# define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
+
+static void
+miSpritePictureOverlap (PicturePtr  pPict,
+			INT16	    x,
+			INT16	    y,
+			CARD16	    w,
+			CARD16	    h)
+{
+    if (pPict->pDrawable->type == DRAWABLE_WINDOW)
+    {
+	WindowPtr		pWin = (WindowPtr) (pPict->pDrawable);
+	miSpriteScreenPtr	pScreenPriv = (miSpriteScreenPtr)
+	    pPict->pDrawable->pScreen->devPrivates[miSpriteScreenIndex].ptr;
+	if (GC_CHECK(pWin))
+	{
+	    if (pPict->repeat)
+	    {
+		x = mod(x,pWin->drawable.width);
+		y = mod(y,pWin->drawable.height);
+	    }
+	    if (ORG_OVERLAP (&pScreenPriv->saved, pWin->drawable.x, pWin->drawable.y,
+			     x, y, w, h))
+		miSpriteRemoveCursor (pWin->drawable.pScreen);
+	}
+    }
+}
+
+#define PICTURE_PROLOGUE(ps, pScreenPriv, field) \
+    ps->field = pScreenPriv->field
+
+#define PICTURE_EPILOGUE(ps, field, wrap) \
+    ps->field = wrap
+
+static void
+miSpriteComposite(CARD8	op,
+		  PicturePtr pSrc,
+		  PicturePtr pMask,
+		  PicturePtr pDst,
+		  INT16	xSrc,
+		  INT16	ySrc,
+		  INT16	xMask,
+		  INT16	yMask,
+		  INT16	xDst,
+		  INT16	yDst,
+		  CARD16	width,
+		  CARD16	height)
+{
+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr	ps = GetPictureScreen(pScreen);
+    miSpriteScreenPtr	pScreenPriv;
+
+    pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+    PICTURE_PROLOGUE(ps, pScreenPriv, Composite);
+    miSpritePictureOverlap (pSrc, xSrc, ySrc, width, height);
+    if (pMask)
+	miSpritePictureOverlap (pMask, xMask, yMask, width, height);
+    miSpritePictureOverlap (pDst, xDst, yDst, width, height);
+
+    (*ps->Composite) (op,
+		       pSrc,
+		       pMask,
+		       pDst,
+		       xSrc,
+		       ySrc,
+		       xMask,
+		       yMask,
+		       xDst,
+		       yDst,
+		       width,
+		       height);
+    
+    PICTURE_EPILOGUE(ps, Composite, miSpriteComposite);
+}
+
+static void
+miSpriteGlyphs(CARD8		op,
+	       PicturePtr	pSrc,
+	       PicturePtr	pDst,
+	       PictFormatPtr	maskFormat,
+	       INT16		xSrc,
+	       INT16		ySrc,
+	       int		nlist,
+	       GlyphListPtr	list,
+	       GlyphPtr		*glyphs)
+{
+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr	ps = GetPictureScreen(pScreen);
+    miSpriteScreenPtr	pScreenPriv;
+
+    pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+    PICTURE_PROLOGUE(ps, pScreenPriv, Glyphs);
+    if (pSrc->pDrawable->type == DRAWABLE_WINDOW)
+    {
+	WindowPtr   pSrcWin = (WindowPtr) (pSrc->pDrawable);
+
+	if (GC_CHECK(pSrcWin))
+	    miSpriteRemoveCursor (pScreen);
+    }
+    if (pDst->pDrawable->type == DRAWABLE_WINDOW)
+    {
+	WindowPtr   pDstWin = (WindowPtr) (pDst->pDrawable);
+
+	if (GC_CHECK(pDstWin))
+	{
+	    BoxRec  extents;
+
+	    miGlyphExtents (nlist, list, glyphs, &extents);
+	    if (BOX_OVERLAP(&pScreenPriv->saved,
+			    extents.x1 + pDstWin->drawable.x,
+			    extents.y1 + pDstWin->drawable.y,
+			    extents.x2 + pDstWin->drawable.x,
+			    extents.y2 + pDstWin->drawable.y))
+	    {
+		miSpriteRemoveCursor (pScreen);
+	    }
+	}
+    }
+    
+    (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
+    
+    PICTURE_EPILOGUE (ps, Glyphs, miSpriteGlyphs);
 }
 #endif
 
Index: xc/programs/Xserver/mi/mispritest.h
diff -u xc/programs/Xserver/mi/mispritest.h:1.1.1.2 xc/programs/Xserver/mi/mispritest.h:1.3
--- xc/programs/Xserver/mi/mispritest.h:1.1.1.2	Sun Sep 27 04:04:13 1998
+++ xc/programs/Xserver/mi/mispritest.h	Tue Oct 10 10:05:49 2000
@@ -26,8 +26,12 @@
 used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization from The Open Group.
 */
+/* $XFree86: xc/programs/Xserver/mi/mispritest.h,v 1.3 2000/10/10 14:05:49 tsi Exp $ */
 
 # include   "misprite.h"
+#ifdef RENDER
+# include   "picturestr.h"
+#endif
 
 /*
  * per screen information
@@ -48,6 +52,10 @@
     ClearToBackgroundProcPtr		ClearToBackground;
     SaveDoomedAreasProcPtr		SaveDoomedAreas;
     RestoreAreasProcPtr			RestoreAreas;
+#ifdef RENDER
+    CompositeProcPtr			Composite;
+    GlyphsProcPtr			Glyphs;
+#endif
 
     CursorPtr	    pCursor;
     int		    x;
Index: xc/programs/Xserver/miext/shadow/Imakefile
diff -u /dev/null xc/programs/Xserver/miext/shadow/Imakefile:1.3
--- /dev/null	Mon Dec 18 14:33:23 2000
+++ xc/programs/Xserver/miext/shadow/Imakefile	Tue Sep 12 15:40:13 2000
@@ -0,0 +1,58 @@
+XCOMM $XFree86: xc/programs/Xserver/miext/shadow/Imakefile,v 1.3 2000/09/12 19:40:13 keithp Exp $
+XCOMM 
+XCOMM 
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#ifdef XFree86Version
+#if DoLoadableServer
+XFMODSRC = shmodule.c
+XFMODOBJ = shmodule.o
+#endif
+#endif
+
+SRCS =  $(XFMODSRC) \
+	shadow.c \
+	shalloc.c \
+	shplanar.c \
+	shplanar8.c \
+	shpacked.c \
+	shrot8pack.c \
+	shrot16pack.c \
+	shrot32pack.c
+
+OBJS =  $(XFMODOBJ) \
+	shadow.o \
+	shalloc.o \
+	shplanar.o \
+	shplanar8.o \
+	shpacked.o \
+	shrot8pack.o \
+	shrot16pack.o \
+	shrot32pack.o
+
+#if BuildRender
+RENDERINCS=-I../../render -I$(EXTINCSRC)
+#endif
+
+   INCLUDES = -I. -I../../mi -I../../fb -I../../include -I$(XINCLUDESRC) \
+	      -I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES) \
+	      $(RENDERINCS)
+   LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+	     ../../mi/llib-lmi.ln
+
+NormalLibraryObjectRule()
+LibraryModuleTarget(shadow,$(OBJS))
+LintLibraryTarget(shadow,$(SRCS))
+
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(shadow,$(MODULEDIR),.)
+
+#ifndef OS2Architecture
+DependTarget()
+#endif
+
+InstallDriverSDKLibraryModule(shadow,$(DRIVERSDKMODULEDIR),.)
+InstallDriverSDKNonExecFile(shadow.h,$(DRIVERSDKINCLUDEDIR))
Index: xc/programs/Xserver/miext/shadow/shadow.c
diff -u /dev/null xc/programs/Xserver/miext/shadow/shadow.c:1.4
--- /dev/null	Mon Dec 18 14:33:23 2000
+++ xc/programs/Xserver/miext/shadow/shadow.c	Fri Dec  8 16:42:04 2000
@@ -0,0 +1,1373 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shadow.c,v 1.4 2000/12/08 21:42:04 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include    "X.h"
+#include    "scrnintstr.h"
+#include    "windowstr.h"
+#include    "font.h"
+#include    "dixfontstr.h"
+#include    "fontstruct.h"
+#include    "mi.h"
+#include    "regionstr.h"
+#include    "globals.h"
+#include    "gcstruct.h"
+#include    "shadow.h"
+#ifdef RENDER
+#include    "picturestr.h"
+#endif
+
+typedef struct _shadowGCPriv {
+    GCOps   *ops;
+    GCFuncs *funcs;
+} shadowGCPrivRec, *shadowGCPrivPtr;
+
+int shadowScrPrivateIndex;
+int shadowGCPrivateIndex;
+int shadowGeneration;
+
+#define shadowGetGCPriv(pGC) ((shadowGCPrivPtr) (pGC)->devPrivates[shadowGCPrivateIndex].ptr)
+#define shadowGCPriv(pGC)    shadowGCPrivPtr  pGCPriv = shadowGetGCPriv(pGC)
+
+#define wrap(priv,real,mem,func) {\
+    priv->mem = real->mem; \
+    real->mem = func; \
+}
+
+#define unwrap(priv,real,mem) {\
+    real->mem = priv->mem; \
+}
+
+static void
+shadowRedisplay (ScreenPtr pScreen)
+{
+    shadowScrPriv(pScreen);
+    PixmapPtr	pShadow = (PixmapPtr) pScreen->devPrivate;
+    
+    if (REGION_NOTEMPTY (pScreen, &pScrPriv->damage))
+    {
+	REGION_INTERSECT (pScreen, &pScrPriv->damage, &pScrPriv->damage,
+			  &WindowTable[pScreen->myNum]->borderSize);
+	(*pScrPriv->update) (pScreen, pShadow, &pScrPriv->damage);
+	REGION_EMPTY (pScreen, &pScrPriv->damage);
+    }
+}
+
+static void
+shadowBlockHandler (pointer	data,
+		      OSTimePtr pTimeout,
+		      pointer pRead)
+{
+    ScreenPtr	pScreen = (ScreenPtr) data;
+
+    shadowRedisplay (pScreen);
+}
+
+static void
+shadowWakeupHandler (pointer data, int i, pointer LastSelectMask)
+{
+}
+
+static void
+shadowDamageRegion (WindowPtr pWindow, RegionPtr pRegion)
+{
+    ScreenPtr	pScreen = pWindow->drawable.pScreen;
+    shadowScrPriv (pScreen);
+
+    REGION_UNION (pScreen, &pScrPriv->damage, &pScrPriv->damage, pRegion);
+#undef ALWAYS_DISPLAY
+#ifdef ALWAYS_DISPLAY
+    shadowRedisplay (pScreen);
+#endif
+}
+
+static void 
+shadowDamageBox (WindowPtr pWindow, BoxPtr pBox)
+{
+    RegionRec	region;
+
+    REGION_INIT (pWindow->drawable.pScreen, &region, pBox, 1);
+    shadowDamageRegion (pWindow, &region);
+}    
+
+static void
+shadowDamageRect (WindowPtr pWindow, int x, int y, int w, int h)
+{
+    BoxRec	box;
+
+    x += pWindow->drawable.x;
+    y += pWindow->drawable.y;
+    box.x1 = x;
+    box.x2 = x + w;
+    box.y1 = y;
+    box.y2 = y + h;
+    shadowDamageBox (pWindow, &box);    
+}
+
+static void shadowValidateGC(GCPtr, unsigned long, DrawablePtr);
+static void shadowChangeGC(GCPtr, unsigned long);
+static void shadowCopyGC(GCPtr, unsigned long, GCPtr);
+static void shadowDestroyGC(GCPtr);
+static void shadowChangeClip(GCPtr, int, pointer, int);
+static void shadowDestroyClip(GCPtr);
+static void shadowCopyClip(GCPtr, GCPtr);
+
+GCFuncs shadowGCFuncs = {
+    shadowValidateGC, shadowChangeGC, shadowCopyGC, shadowDestroyGC,
+    shadowChangeClip, shadowDestroyClip, shadowCopyClip
+};
+
+extern GCOps shadowGCOps;
+
+static Bool
+shadowCreateGC(GCPtr pGC)
+{
+    ScreenPtr pScreen = pGC->pScreen;
+    shadowScrPriv(pScreen);
+    shadowGCPriv(pGC);
+    Bool ret;
+
+    unwrap (pScrPriv, pScreen, CreateGC);
+    if((ret = (*pScreen->CreateGC) (pGC))) {
+	pGCPriv->ops = NULL;
+	pGCPriv->funcs = pGC->funcs;
+	pGC->funcs = &shadowGCFuncs;
+    }
+    wrap (pScrPriv, pScreen, CreateGC, shadowCreateGC);
+
+    return ret;
+}
+
+#define SHADOW_GC_OP_PROLOGUE(pGC,pDraw) \
+    shadowGCPriv(pGC);  \
+    GCFuncs *oldFuncs = pGC->funcs; \
+    unwrap(pGCPriv, pGC, funcs);  \
+    unwrap(pGCPriv, pGC, ops); \
+	
+#define SHADOW_GC_OP_EPILOGUE(pGC,pDraw) \
+    wrap(pGCPriv, pGC, funcs, oldFuncs); \
+    wrap(pGCPriv, pGC, ops, &shadowGCOps)
+
+#define SHADOW_GC_FUNC_PROLOGUE(pGC) \
+    shadowGCPriv(pGC); \
+    unwrap(pGCPriv, pGC, funcs); \
+    if (pGCPriv->ops) unwrap(pGCPriv, pGC, ops)
+
+#define SHADOW_GC_FUNC_EPILOGUE(pGC) \
+    wrap(pGCPriv, pGC, funcs, &shadowGCFuncs);  \
+    if (pGCPriv->ops) wrap(pGCPriv, pGC, ops, &shadowGCOps)
+
+static void
+shadowValidateGC(
+   GCPtr         pGC,
+   unsigned long changes,
+   DrawablePtr   pDraw 
+){
+    SHADOW_GC_FUNC_PROLOGUE (pGC);
+    (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
+    if(pDraw->type == DRAWABLE_WINDOW)
+	pGCPriv->ops = pGC->ops;  /* just so it's not NULL */
+    else 
+	pGCPriv->ops = NULL;
+    SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+shadowDestroyGC(GCPtr pGC)
+{
+    SHADOW_GC_FUNC_PROLOGUE (pGC);
+    (*pGC->funcs->DestroyGC)(pGC);
+    SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+shadowChangeGC (
+    GCPtr	    pGC,
+    unsigned long   mask
+){
+    SHADOW_GC_FUNC_PROLOGUE (pGC);
+    (*pGC->funcs->ChangeGC) (pGC, mask);
+    SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+shadowCopyGC (
+    GCPtr	    pGCSrc, 
+    unsigned long   mask,
+    GCPtr	    pGCDst
+){
+    SHADOW_GC_FUNC_PROLOGUE (pGCDst);
+    (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+    SHADOW_GC_FUNC_EPILOGUE (pGCDst);
+}
+
+static void
+shadowChangeClip (
+    GCPtr   pGC,
+    int		type,
+    pointer	pvalue,
+    int		nrects 
+){
+    SHADOW_GC_FUNC_PROLOGUE (pGC);
+    (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+    SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+static void
+shadowCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+    SHADOW_GC_FUNC_PROLOGUE (pgcDst);
+    (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+    SHADOW_GC_FUNC_EPILOGUE (pgcDst);
+}
+
+static void
+shadowDestroyClip(GCPtr pGC)
+{
+    SHADOW_GC_FUNC_PROLOGUE (pGC);
+    (* pGC->funcs->DestroyClip)(pGC);
+    SHADOW_GC_FUNC_EPILOGUE (pGC);
+}
+
+#define IS_VISIBLE(pWin) 1
+
+
+#define TRIM_BOX(box, pGC) { \
+    BoxPtr extents = &pGC->pCompositeClip->extents;\
+    if(box.x1 < extents->x1) box.x1 = extents->x1; \
+    if(box.x2 > extents->x2) box.x2 = extents->x2; \
+    if(box.y1 < extents->y1) box.y1 = extents->y1; \
+    if(box.y2 > extents->y2) box.y2 = extents->y2; \
+    }
+
+#define TRANSLATE_BOX(box, pDraw) { \
+    box.x1 += pDraw->x; \
+    box.x2 += pDraw->x; \
+    box.y1 += pDraw->y; \
+    box.y2 += pDraw->y; \
+    }
+
+#define TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC) { \
+    TRANSLATE_BOX(box, pDraw); \
+    TRIM_BOX(box, pGC); \
+    }
+
+#define BOX_NOT_EMPTY(box) \
+    (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0))
+
+#ifdef RENDER
+static void
+shadowComposite (CARD8      op,
+		   PicturePtr pSrc,
+		   PicturePtr pMask,
+		   PicturePtr pDst,
+		   INT16      xSrc,
+		   INT16      ySrc,
+		   INT16      xMask,
+		   INT16      yMask,
+		   INT16      xDst,
+		   INT16      yDst,
+		   CARD16     width,
+		   CARD16     height)
+{
+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr	ps = GetPictureScreen(pScreen);
+    shadowScrPriv(pScreen);
+    
+    unwrap (pScrPriv, ps, Composite);
+    (*ps->Composite) (op,
+		       pSrc,
+		       pMask,
+		       pDst,
+		       xSrc,
+		       ySrc,
+		       xMask,
+		       yMask,
+		       xDst,
+		       yDst,
+		       width,
+		       height);
+    wrap (pScrPriv, ps, Composite, shadowComposite);
+    if (pDst->pDrawable->type == DRAWABLE_WINDOW)
+	shadowDamageRect ((WindowPtr) pDst->pDrawable, xDst, yDst,
+			    width, height);
+}
+
+static void
+shadowGlyphs (CARD8		op,
+		PicturePtr	pSrc,
+		PicturePtr	pDst,
+		PictFormatPtr	maskFormat,
+		INT16		xSrc,
+		INT16		ySrc,
+		int		nlist,
+		GlyphListPtr	list,
+		GlyphPtr	*glyphs)
+{
+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr	ps = GetPictureScreen(pScreen);
+    shadowScrPriv(pScreen);
+    int			x, y;
+    int			n;
+    GlyphPtr		glyph;
+
+    unwrap (pScrPriv, ps, Glyphs);
+    (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
+    wrap (pScrPriv, ps, Glyphs, shadowGlyphs);
+    if (pDst->pDrawable->type == DRAWABLE_WINDOW)
+    {
+	x = xSrc;
+	y = ySrc;
+	while (nlist--)
+	{
+	    x += list->xOff;
+	    y += list->yOff;
+	    n = list->len;
+	    while (n--)
+	    {
+		glyph = *glyphs++;
+		shadowDamageRect ((WindowPtr) pDst->pDrawable,
+				    x - glyph->info.x,
+				    y - glyph->info.y,
+				    glyph->info.width,
+				    glyph->info.height);
+		x += glyph->info.xOff;
+		y += glyph->info.yOff;
+	    }
+	    list++;
+	}
+    }
+}
+#endif
+
+/**********************************************************/
+
+
+static void
+shadowFillSpans(
+    DrawablePtr pDraw,
+    GC		*pGC,
+    int		nInit,	
+    DDXPointPtr pptInit,	
+    int 	*pwidthInit,		
+    int 	fSorted 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);    
+
+    if(IS_VISIBLE(pDraw) && nInit) {
+	DDXPointPtr ppt = pptInit;
+	int *pwidth = pwidthInit;
+	int i = nInit;
+	BoxRec box;
+
+	box.x1 = ppt->x;
+	box.x2 = box.x1 + *pwidth;
+	box.y2 = box.y1 = ppt->y;
+
+	while(--i) {
+	   ppt++;
+	   pwidthInit++;
+	   if(box.x1 > ppt->x) box.x1 = ppt->x;
+	   if(box.x2 < (ppt->x + *pwidth)) 
+		box.x2 = ppt->x + *pwidth;
+	   if(box.y1 > ppt->y) box.y1 = ppt->y;
+	   else if(box.y2 < ppt->y) box.y2 = ppt->y;
+	}
+
+	box.y2++;
+
+	(*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+
+	TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    } else
+	(*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+static void
+shadowSetSpans(
+    DrawablePtr		pDraw,
+    GCPtr		pGC,
+    char		*pcharsrc,
+    DDXPointPtr 	pptInit,
+    int			*pwidthInit,
+    int			nspans,
+    int			fSorted 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && nspans) {
+	DDXPointPtr ppt = pptInit;
+	int *pwidth = pwidthInit;
+	int i = nspans;
+	BoxRec box;
+
+	box.x1 = ppt->x;
+	box.x2 = box.x1 + *pwidth;
+	box.y2 = box.y1 = ppt->y;
+
+	while(--i) {
+	   ppt++;
+	   pwidth++;
+	   if(box.x1 > ppt->x) box.x1 = ppt->x;
+	   if(box.x2 < (ppt->x + *pwidth)) 
+		box.x2 = ppt->x + *pwidth;
+	   if(box.y1 > ppt->y) box.y1 = ppt->y;
+	   else if(box.y2 < ppt->y) box.y2 = ppt->y;
+	}
+
+	box.y2++;
+
+	(*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit, 
+				pwidthInit, nspans, fSorted);
+
+	TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    } else
+	(*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit, 
+				pwidthInit, nspans, fSorted);
+
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+static void
+shadowPutImage(
+    DrawablePtr pDraw,
+    GCPtr	pGC,
+    int		depth, 
+    int x, int y, int w, int h,
+    int		leftPad,
+    int		format,
+    char 	*pImage 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, 
+		leftPad, format, pImage);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw)) {
+	BoxRec box;
+
+	box.x1 = x + pDraw->x;
+	box.x2 = box.x1 + w;
+	box.y1 = y + pDraw->y;
+	box.y2 = box.y1 + h;
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+
+static RegionPtr
+shadowCopyArea(
+    DrawablePtr pSrc,
+    DrawablePtr pDst,
+    GC *pGC,
+    int srcx, int srcy,
+    int width, int height,
+    int dstx, int dsty 
+){
+    RegionPtr ret;
+    SHADOW_GC_OP_PROLOGUE(pGC, pDst);
+    ret = (*pGC->ops->CopyArea)(pSrc, pDst,
+            pGC, srcx, srcy, width, height, dstx, dsty);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDst);
+
+    if(IS_VISIBLE(pDst)) {
+	BoxRec box;
+
+	box.x1 = dstx + pDst->x;
+	box.x2 = box.x1 + width;
+	box.y1 = dsty + pDst->y;
+	box.y2 = box.y1 + height;
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDst, &box);
+    }
+
+    return ret;
+}
+
+static RegionPtr
+shadowCopyPlane(
+    DrawablePtr	pSrc,
+    DrawablePtr	pDst,
+    GCPtr pGC,
+    int	srcx, int srcy,
+    int	width, int height,
+    int	dstx, int dsty,
+    unsigned long bitPlane 
+){
+    RegionPtr ret;
+    SHADOW_GC_OP_PROLOGUE(pGC, pDst);
+    ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
+	       pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDst);
+
+    if(IS_VISIBLE(pDst)) {
+	BoxRec box;
+
+	box.x1 = dstx + pDst->x;
+	box.x2 = box.x1 + width;
+	box.y1 = dsty + pDst->y;
+	box.y2 = box.y1 + height;
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDst, &box);
+    }
+
+    return ret;
+}
+
+static void
+shadowPolyPoint(
+    DrawablePtr pDraw,
+    GCPtr pGC,
+    int mode,
+    int npt,
+    xPoint *pptInit 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && npt) {
+	BoxRec box;
+
+	box.x2 = box.x1 = pptInit->x;
+	box.y2 = box.y1 = pptInit->y;
+
+	/* this could be slow if the points were spread out */
+
+	while(--npt) {
+	   pptInit++;
+	   if(box.x1 > pptInit->x) box.x1 = pptInit->x;
+	   else if(box.x2 < pptInit->x) box.x2 = pptInit->x;
+	   if(box.y1 > pptInit->y) box.y1 = pptInit->y;
+	   else if(box.y2 < pptInit->y) box.y2 = pptInit->y;
+	}
+
+	box.x2++;
+	box.y2++;
+
+	TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+
+static void
+shadowPolylines(
+    DrawablePtr pDraw,
+    GCPtr	pGC,
+    int		mode,		
+    int		npt,		
+    DDXPointPtr pptInit 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+
+    if(IS_VISIBLE(pDraw) && npt) {
+	BoxRec box;
+	int extra = pGC->lineWidth >> 1;
+
+	box.x2 = box.x1 = pptInit->x;
+	box.y2 = box.y1 = pptInit->y;
+
+	if(npt > 1) {
+	   if(pGC->joinStyle == JoinMiter)
+		extra = 6 * pGC->lineWidth;
+	   else if(pGC->capStyle == CapProjecting)
+		extra = pGC->lineWidth;
+        }
+
+	if(mode == CoordModePrevious) {
+	   int x = box.x1;
+	   int y = box.y1;
+	   while(--npt) {
+		pptInit++;
+		x += pptInit->x;
+		y += pptInit->y;
+		if(box.x1 > x) box.x1 = x;
+		else if(box.x2 < x) box.x2 = x;
+		if(box.y1 > y) box.y1 = y;
+		else if(box.y2 < y) box.y2 = y;
+	    }
+	} else {
+	   while(--npt) {
+		pptInit++;
+		if(box.x1 > pptInit->x) box.x1 = pptInit->x;
+		else if(box.x2 < pptInit->x) box.x2 = pptInit->x;
+		if(box.y1 > pptInit->y) box.y1 = pptInit->y;
+		else if(box.y2 < pptInit->y) box.y2 = pptInit->y;
+	    }
+	}
+
+	box.x2++;
+	box.y2++;
+
+	if(extra) {
+	   box.x1 -= extra;
+	   box.x2 += extra;
+	   box.y1 -= extra;
+	   box.y2 += extra;
+        }
+
+	TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+
+static void 
+shadowPolySegment(
+    DrawablePtr	pDraw,
+    GCPtr	pGC,
+    int		nseg,
+    xSegment	*pSeg 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && nseg) {
+	BoxRec box;
+	int extra = pGC->lineWidth;
+
+        if(pGC->capStyle != CapProjecting)	
+	   extra >>= 1;
+
+	if(pSeg->x2 > pSeg->x1) {
+	    box.x1 = pSeg->x1;
+	    box.x2 = pSeg->x2;
+	} else {
+	    box.x2 = pSeg->x1;
+	    box.x1 = pSeg->x2;
+	}
+
+	if(pSeg->y2 > pSeg->y1) {
+	    box.y1 = pSeg->y1;
+	    box.y2 = pSeg->y2;
+	} else {
+	    box.y2 = pSeg->y1;
+	    box.y1 = pSeg->y2;
+	}
+
+	while(--nseg) {
+	    pSeg++;
+	    if(pSeg->x2 > pSeg->x1) {
+		if(pSeg->x1 < box.x1) box.x1 = pSeg->x1;
+		if(pSeg->x2 > box.x2) box.x2 = pSeg->x2;
+	    } else {
+		if(pSeg->x2 < box.x1) box.x1 = pSeg->x2;
+		if(pSeg->x1 > box.x2) box.x2 = pSeg->x1;
+	    }
+	    if(pSeg->y2 > pSeg->y1) {
+		if(pSeg->y1 < box.y1) box.y1 = pSeg->y1;
+		if(pSeg->y2 > box.y2) box.y2 = pSeg->y2;
+	    } else {
+		if(pSeg->y2 < box.y1) box.y1 = pSeg->y2;
+		if(pSeg->y1 > box.y2) box.y2 = pSeg->y1;
+	    }
+	}
+
+	box.x2++;
+	box.y2++;
+
+	if(extra) {
+	   box.x1 -= extra;
+	   box.x2 += extra;
+	   box.y1 -= extra;
+	   box.y2 += extra;
+        }
+
+	TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+
+static void
+shadowPolyRectangle(
+    DrawablePtr  pDraw,
+    GCPtr        pGC,
+    int	         nRects,
+    xRectangle  *pRects 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->PolyRectangle)(pDraw, pGC, nRects, pRects);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && nRects) 
+    {
+	BoxRec box;
+	int offset1, offset2, offset3;
+
+	offset2 = pGC->lineWidth;
+	if(!offset2) offset2 = 1;
+	offset1 = offset2 >> 1;
+	offset3 = offset2 - offset1;
+
+	while(nRects--) 
+	{
+	    box.x1 = pRects->x - offset1;
+	    box.y1 = pRects->y - offset1;
+	    box.x2 = box.x1 + pRects->width + offset2;
+	    box.y2 = box.y1 + offset2;		
+	    TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	    if(BOX_NOT_EMPTY(box))
+		shadowDamageBox ((WindowPtr) pDraw, &box);
+
+	    box.x1 = pRects->x - offset1;
+	    box.y1 = pRects->y + offset3;
+	    box.x2 = box.x1 + offset2;
+	    box.y2 = box.y1 + pRects->height - offset2;		
+	    TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	    if(BOX_NOT_EMPTY(box))
+		shadowDamageBox ((WindowPtr) pDraw, &box);
+
+	    box.x1 = pRects->x + pRects->width - offset1;
+	    box.y1 = pRects->y + offset3;
+	    box.x2 = box.x1 + offset2;
+	    box.y2 = box.y1 + pRects->height - offset2;		
+	    TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	    if(BOX_NOT_EMPTY(box))
+		shadowDamageBox ((WindowPtr) pDraw, &box);
+
+	    box.x1 = pRects->x - offset1;
+	    box.y1 = pRects->y + pRects->height - offset1;
+	    box.x2 = box.x1 + pRects->width + offset2;
+	    box.y2 = box.y1 + offset2;		
+	    TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	    if(BOX_NOT_EMPTY(box))
+		shadowDamageBox ((WindowPtr) pDraw, &box);
+
+	    pRects++;
+	}
+    }
+ }
+
+static void
+shadowPolyArc(
+    DrawablePtr	pDraw,
+    GCPtr	pGC,
+    int		narcs,
+    xArc	*parcs 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && narcs) {
+	int extra = pGC->lineWidth >> 1;
+	BoxRec box;
+
+	box.x1 = parcs->x;
+	box.x2 = box.x1 + parcs->width;
+	box.y1 = parcs->y;
+	box.y2 = box.y1 + parcs->height;
+
+	/* should I break these up instead ? */
+
+	while(--narcs) {
+	   parcs++;
+	   if(box.x1 > parcs->x) box.x1 = parcs->x;
+	   if(box.x2 < (parcs->x + parcs->width))
+		box.x2 = parcs->x + parcs->width;
+	   if(box.y1 > parcs->y) box.y1 = parcs->y;
+	   if(box.y2 < (parcs->y + parcs->height))
+		box.y2 = parcs->y + parcs->height;
+        }
+
+	if(extra) {
+	   box.x1 -= extra;
+	   box.x2 += extra;
+	   box.y1 -= extra;
+	   box.y2 += extra;
+        }
+
+	box.x2++;
+	box.y2++;
+
+	TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+
+static void
+shadowFillPolygon(
+    DrawablePtr	pDraw,
+    GCPtr	pGC,
+    int		shape,
+    int		mode,
+    int		count,
+    DDXPointPtr	pptInit 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && (count > 2)) {
+	DDXPointPtr ppt = pptInit;
+	int i = count;
+	BoxRec box;
+
+	box.x2 = box.x1 = ppt->x;
+	box.y2 = box.y1 = ppt->y;
+
+	if(mode != CoordModeOrigin) {
+	   int x = box.x1;
+	   int y = box.y1;
+	   while(--i) {
+		ppt++;
+		x += ppt->x;
+		y += ppt->y;
+		if(box.x1 > x) box.x1 = x;
+		else if(box.x2 < x) box.x2 = x;
+		if(box.y1 > y) box.y1 = y;
+		else if(box.y2 < y) box.y2 = y;
+	    }
+	} else {
+	   while(--i) {
+		ppt++;
+		if(box.x1 > ppt->x) box.x1 = ppt->x;
+		else if(box.x2 < ppt->x) box.x2 = ppt->x;
+		if(box.y1 > ppt->y) box.y1 = ppt->y;
+		else if(box.y2 < ppt->y) box.y2 = ppt->y;
+	    }
+	}
+
+	box.x2++;
+	box.y2++;
+
+	(*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
+
+	TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    } else
+	(*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, pptInit);
+
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+
+static void 
+shadowPolyFillRect(
+    DrawablePtr	pDraw,
+    GCPtr	pGC,
+    int		nRectsInit, 
+    xRectangle	*pRectsInit 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && nRectsInit) {
+	BoxRec box;
+	xRectangle *pRects = pRectsInit;
+	int nRects = nRectsInit;
+
+	box.x1 = pRects->x;
+	box.x2 = box.x1 + pRects->width;
+	box.y1 = pRects->y;
+	box.y2 = box.y1 + pRects->height;
+
+	while(--nRects) {
+	    pRects++;
+	    if(box.x1 > pRects->x) box.x1 = pRects->x;
+	    if(box.x2 < (pRects->x + pRects->width))
+		box.x2 = pRects->x + pRects->width;
+	    if(box.y1 > pRects->y) box.y1 = pRects->y;
+	    if(box.y2 < (pRects->y + pRects->height))
+		box.y2 = pRects->y + pRects->height;
+	}
+
+	/* cfb messes with the pRectsInit so we have to do our
+	   calculations first */
+
+	(*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
+
+	TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	if(BOX_NOT_EMPTY(box))
+	    shadowDamageBox ((WindowPtr) pDraw, &box);
+    } else
+	(*pGC->ops->PolyFillRect)(pDraw, pGC, nRectsInit, pRectsInit);
+
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+}
+
+
+static void
+shadowPolyFillArc(
+    DrawablePtr	pDraw,
+    GCPtr	pGC,
+    int		narcs,
+    xArc	*parcs 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && narcs) {
+	BoxRec box;
+
+	box.x1 = parcs->x;
+	box.x2 = box.x1 + parcs->width;
+	box.y1 = parcs->y;
+	box.y2 = box.y1 + parcs->height;
+
+	/* should I break these up instead ? */
+
+	while(--narcs) {
+	   parcs++;
+	   if(box.x1 > parcs->x) box.x1 = parcs->x;
+	   if(box.x2 < (parcs->x + parcs->width))
+		box.x2 = parcs->x + parcs->width;
+	   if(box.y1 > parcs->y) box.y1 = parcs->y;
+	   if(box.y2 < (parcs->y + parcs->height))
+		box.y2 = parcs->y + parcs->height;
+        }
+
+	TRIM_AND_TRANSLATE_BOX(box, pDraw, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+
+}
+
+static int
+shadowPolyText8(
+    DrawablePtr pDraw,
+    GCPtr	pGC,
+    int		x, 
+    int 	y,
+    int 	count,
+    char	*chars 
+){
+    int width;
+
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    width = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    width -= x;
+
+    if(IS_VISIBLE(pDraw) && (width > 0)) {
+	BoxRec box;
+
+	/* ugh */
+	box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+	box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+	if(count > 1) {
+	   if(width > 0) box.x2 += width;
+	   else box.x1 += width;
+	}
+
+	box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+	box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+
+    return (width + x);
+}
+
+static int
+shadowPolyText16(
+    DrawablePtr pDraw,
+    GCPtr	pGC,
+    int		x,
+    int		y,
+    int 	count,
+    unsigned short *chars 
+){
+    int width;
+
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    width = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    width -= x;
+
+    if(IS_VISIBLE(pDraw) && (width > 0)) {
+	BoxRec box;
+
+	/* ugh */
+	box.x1 = pDraw->x + x + FONTMINBOUNDS(pGC->font, leftSideBearing);
+	box.x2 = pDraw->x + x + FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+	if(count > 1) {
+	   if(width > 0) box.x2 += width;
+	   else box.x1 += width;
+	}
+
+	box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+	box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+
+    return (width + x);
+}
+
+static void
+shadowImageText8(
+    DrawablePtr pDraw,
+    GCPtr	pGC,
+    int		x, 
+    int		y,
+    int 	count,
+    char	*chars 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && count) {
+	int top, bot, Min, Max;
+	BoxRec box;
+
+	top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+	bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+	Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+	if(Min > 0) Min = 0;
+	Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);	
+	if(Max < 0) Max = 0;
+
+	/* ugh */
+	box.x1 = pDraw->x + x + Min +
+		FONTMINBOUNDS(pGC->font, leftSideBearing);
+	box.x2 = pDraw->x + x + Max + 
+		FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+	box.y1 = pDraw->y + y - top;
+	box.y2 = pDraw->y + y + bot;
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+static void
+shadowImageText16(
+    DrawablePtr pDraw,
+    GCPtr	pGC,
+    int		x,
+    int		y,
+    int 	count,
+    unsigned short *chars 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && count) {
+	int top, bot, Min, Max;
+	BoxRec box;
+
+	top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+	bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+	Min = count * FONTMINBOUNDS(pGC->font, characterWidth);
+	if(Min > 0) Min = 0;
+	Max = count * FONTMAXBOUNDS(pGC->font, characterWidth);	
+	if(Max < 0) Max = 0;
+
+	/* ugh */
+	box.x1 = pDraw->x + x + Min +
+		FONTMINBOUNDS(pGC->font, leftSideBearing);
+	box.x2 = pDraw->x + x + Max + 
+		FONTMAXBOUNDS(pGC->font, rightSideBearing);
+
+	box.y1 = pDraw->y + y - top;
+	box.y2 = pDraw->y + y + bot;
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+
+
+static void
+shadowImageGlyphBlt(
+    DrawablePtr pDraw,
+    GCPtr pGC,
+    int x, int y,
+    unsigned int nglyph,
+    CharInfoPtr *ppci,
+    pointer pglyphBase 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, nglyph, 
+					ppci, pglyphBase);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && nglyph) {
+	int top, bot, width = 0;
+	BoxRec box;
+
+	top = max(FONTMAXBOUNDS(pGC->font, ascent), FONTASCENT(pGC->font));
+	bot = max(FONTMAXBOUNDS(pGC->font, descent), FONTDESCENT(pGC->font));
+
+	box.x1 = ppci[0]->metrics.leftSideBearing;
+	if(box.x1 > 0) box.x1 = 0;
+	box.x2 = ppci[nglyph - 1]->metrics.rightSideBearing - 
+		ppci[nglyph - 1]->metrics.characterWidth;
+	if(box.x2 < 0) box.x2 = 0;
+
+	box.x2 += pDraw->x + x;
+	box.x1 += pDraw->x + x;
+	   
+	while(nglyph--) {
+	    width += (*ppci)->metrics.characterWidth;
+	    ppci++;
+	}
+
+	if(width > 0) 
+	   box.x2 += width;
+	else 
+	   box.x1 += width;
+
+	box.y1 = pDraw->y + y - top;
+	box.y2 = pDraw->y + y + bot;
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+
+static void
+shadowPolyGlyphBlt(
+    DrawablePtr pDraw,
+    GCPtr pGC,
+    int x, int y,
+    unsigned int nglyph,
+    CharInfoPtr *ppci,
+    pointer pglyphBase 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, nglyph, 
+				ppci, pglyphBase);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw) && nglyph) {
+	BoxRec box;
+
+	/* ugh */
+	box.x1 = pDraw->x + x + ppci[0]->metrics.leftSideBearing;
+	box.x2 = pDraw->x + x + ppci[nglyph - 1]->metrics.rightSideBearing;
+
+	if(nglyph > 1) {
+	    int width = 0;
+
+	    while(--nglyph) { 
+		width += (*ppci)->metrics.characterWidth;
+		ppci++;
+	    }
+	
+	    if(width > 0) box.x2 += width;
+	    else box.x1 += width;
+	}
+
+	box.y1 = pDraw->y + y - FONTMAXBOUNDS(pGC->font, ascent);
+	box.y2 = pDraw->y + y + FONTMAXBOUNDS(pGC->font, descent);
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+
+static void
+shadowPushPixels(
+    GCPtr	pGC,
+    PixmapPtr	pBitMap,
+    DrawablePtr pDraw,
+    int	dx, int dy, int xOrg, int yOrg 
+){
+    SHADOW_GC_OP_PROLOGUE(pGC, pDraw);
+    (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
+    SHADOW_GC_OP_EPILOGUE(pGC, pDraw);
+
+    if(IS_VISIBLE(pDraw)) {
+	BoxRec box;
+
+	box.x1 = xOrg + pDraw->x;
+	box.x2 = box.x1 + dx;
+	box.y1 = yOrg + pDraw->y;
+	box.y2 = box.y1 + dy;
+
+	TRIM_BOX(box, pGC);
+	if(BOX_NOT_EMPTY(box))
+	   shadowDamageBox ((WindowPtr) pDraw, &box);
+    }
+}
+
+
+static void
+shadowPaintWindow(
+  WindowPtr pWindow,
+  RegionPtr prgn,
+  int what 
+){
+    ScreenPtr pScreen = pWindow->drawable.pScreen;
+    shadowScrPriv(pScreen);
+    
+    if(what == PW_BACKGROUND) {
+	unwrap (pScrPriv, pScreen, PaintWindowBackground);
+	(*pScreen->PaintWindowBackground) (pWindow, prgn, what);
+	wrap (pScrPriv, pScreen, PaintWindowBackground, shadowPaintWindow);
+    } else {
+	unwrap (pScrPriv, pScreen, PaintWindowBorder);
+	(*pScreen->PaintWindowBorder) (pWindow, prgn, what);
+	wrap (pScrPriv, pScreen, PaintWindowBorder, shadowPaintWindow);
+    }
+    shadowDamageRegion (pWindow, prgn);
+}
+
+
+static void 
+shadowCopyWindow(
+   WindowPtr pWindow,
+   DDXPointRec ptOldOrg,
+   RegionPtr prgn 
+){
+    ScreenPtr pScreen = pWindow->drawable.pScreen;
+    shadowScrPriv(pScreen);
+
+    unwrap (pScrPriv, pScreen, CopyWindow);
+    (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgn);
+    wrap (pScrPriv, pScreen, CopyWindow, shadowCopyWindow);
+    shadowDamageRegion (pWindow, prgn);
+}
+
+GCOps shadowGCOps = {
+    shadowFillSpans, shadowSetSpans, 
+    shadowPutImage, shadowCopyArea, 
+    shadowCopyPlane, shadowPolyPoint, 
+    shadowPolylines, shadowPolySegment, 
+    shadowPolyRectangle, shadowPolyArc, 
+    shadowFillPolygon, shadowPolyFillRect, 
+    shadowPolyFillArc, shadowPolyText8, 
+    shadowPolyText16, shadowImageText8, 
+    shadowImageText16, shadowImageGlyphBlt, 
+    shadowPolyGlyphBlt, shadowPushPixels,
+#ifdef NEED_LINEHELPER
+    NULL,
+#endif
+    {NULL}		/* devPrivate */
+};
+
+static void
+shadowGetImage (DrawablePtr pDrawable,
+		int sx,
+		int sy,
+		int w,
+		int h,
+		unsigned int format,
+		unsigned long planeMask,
+		char * pdstLine)
+{
+    ScreenPtr pScreen = pDrawable->pScreen;
+    shadowScrPriv(pScreen);
+
+    /* Many apps use GetImage to sync with the visable frame buffer */
+    if (pDrawable->type == DRAWABLE_WINDOW)
+	shadowRedisplay (pScreen);
+    unwrap (pScrPriv, pScreen, GetImage);
+    (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+    wrap (pScrPriv, pScreen, GetImage, shadowGetImage);
+}
+
+		
+static Bool
+shadowCloseScreen (int i, ScreenPtr pScreen)
+{
+    shadowScrPriv(pScreen);
+
+    unwrap (pScrPriv, pScreen, CloseScreen);
+    xfree (pScrPriv);
+    return (*pScreen->CloseScreen) (i, pScreen);    
+}
+
+Bool
+shadowInit (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window)
+{
+    shadowScrPrivPtr	pScrPriv;
+#ifdef RENDER
+    PictureScreenPtr	ps = GetPictureScreen(pScreen);
+#endif
+    
+    if (shadowGeneration != serverGeneration)
+    {
+	shadowScrPrivateIndex = AllocateScreenPrivateIndex ();
+	if (shadowScrPrivateIndex == -1)
+	    return FALSE;
+	shadowGCPrivateIndex = AllocateGCPrivateIndex ();
+	if (shadowGCPrivateIndex == -1)
+	    return FALSE;
+	shadowGeneration = serverGeneration;
+    }
+    if (!AllocateGCPrivate (pScreen, shadowGCPrivateIndex, sizeof (shadowGCPrivRec)))
+	return FALSE;
+    pScrPriv = (shadowScrPrivPtr) xalloc (sizeof (shadowScrPrivRec));
+    if (!pScrPriv)
+	return FALSE;
+    REGION_INIT (pScreen, &pScrPriv->damage, NullBox, 0);
+    pScrPriv->update = update;
+    pScrPriv->window = window;
+    if (!RegisterBlockAndWakeupHandlers (shadowBlockHandler,
+					 shadowWakeupHandler,
+					 (pointer) pScreen))
+	return FALSE;
+    
+    wrap (pScrPriv, pScreen, CreateGC, shadowCreateGC);
+    wrap (pScrPriv, pScreen, PaintWindowBackground, shadowPaintWindow);
+    wrap (pScrPriv, pScreen, PaintWindowBorder, shadowPaintWindow);
+    wrap (pScrPriv, pScreen, CopyWindow, shadowCopyWindow);
+    wrap (pScrPriv, pScreen, CloseScreen, shadowCloseScreen);
+    wrap (pScrPriv, pScreen, GetImage, shadowGetImage);
+#ifdef RENDER
+    wrap (pScrPriv, ps, Glyphs, shadowGlyphs);
+    wrap (pScrPriv, ps, Composite, shadowComposite);
+#endif
+
+    pScreen->devPrivates[shadowScrPrivateIndex].ptr = (pointer) pScrPriv;
+    return TRUE;
+}
Index: xc/programs/Xserver/miext/shadow/shadow.h
diff -u /dev/null xc/programs/Xserver/miext/shadow/shadow.h:1.3
--- /dev/null	Mon Dec 18 14:33:24 2000
+++ xc/programs/Xserver/miext/shadow/shadow.h	Tue Sep 12 15:40:13 2000
@@ -0,0 +1,103 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shadow.h,v 1.3 2000/09/12 19:40:13 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _SHADOW_H_
+#define _SHADOW_H_
+
+#ifdef RENDER
+#include "picturestr.h"
+#endif
+
+typedef void (*ShadowUpdateProc) (ScreenPtr pScreen, 
+				  PixmapPtr pShadow,
+				  RegionPtr damage);
+
+#define SHADOW_WINDOW_RELOCATE 1
+#define SHADOW_WINDOW_READ 2
+#define SHADOW_WINDOW_WRITE 4
+
+typedef void *(*ShadowWindowProc) (ScreenPtr	pScreen,
+				   CARD32	row,
+				   CARD32	offset,
+				   int		mode,
+				   CARD32	*size);
+
+typedef struct _shadowScrPriv {
+    PaintWindowBackgroundProcPtr PaintWindowBackground;
+    PaintWindowBorderProcPtr	PaintWindowBorder;
+    CopyWindowProcPtr		CopyWindow;
+    CloseScreenProcPtr		CloseScreen;
+    CreateGCProcPtr		CreateGC;
+    GetImageProcPtr		GetImage;
+#ifdef RENDER
+    CompositeProcPtr		Composite;
+    GlyphsProcPtr		Glyphs;
+#endif    
+    ShadowUpdateProc		update;
+    ShadowWindowProc		window;
+    RegionRec			damage;
+} shadowScrPrivRec, *shadowScrPrivPtr;
+
+extern int shadowScrPrivateIndex;
+
+#define shadowGetScrPriv(pScr)  ((shadowScrPrivPtr) (pScr)->devPrivates[shadowScrPrivateIndex].ptr)
+#define shadowScrPriv(pScr)	shadowScrPrivPtr    pScrPriv = shadowGetScrPriv(pScr)
+
+Bool
+shadowInit (ScreenPtr pScreen, ShadowUpdateProc update, ShadowWindowProc window);
+
+void *
+shadowAlloc (int width, int height, int bpp);
+
+void
+shadowUpdatePacked (ScreenPtr pScreen,
+		    PixmapPtr pShadow,
+		    RegionPtr damage);
+
+void
+shadowUpdatePlanar4 (ScreenPtr pScreen,
+		     PixmapPtr pShadow,
+		     RegionPtr damage);
+
+void
+shadowUpdatePlanar4x8 (ScreenPtr pScreen,
+		       PixmapPtr pShadow,
+		       RegionPtr damage);
+
+void
+shadowUpdateRotate8 (ScreenPtr pScreen,
+		     PixmapPtr pShadow,
+		     RegionPtr damage);
+
+void
+shadowUpdateRotate16 (ScreenPtr pScreen,
+		      PixmapPtr pShadow,
+		      RegionPtr damage);
+
+void
+shadowUpdateRotate32 (ScreenPtr pScreen,
+		      PixmapPtr pShadow,
+		      RegionPtr damage);
+
+#endif /* _SHADOW_H_ */
Index: xc/programs/Xserver/miext/shadow/shalloc.c
diff -u /dev/null xc/programs/Xserver/miext/shadow/shalloc.c:1.1
--- /dev/null	Mon Dec 18 14:33:24 2000
+++ xc/programs/Xserver/miext/shadow/shalloc.c	Thu Sep  7 19:12:15 2000
@@ -0,0 +1,48 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shalloc.c,v 1.1 2000/09/07 23:12:15 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include    "X.h"
+#include    "scrnintstr.h"
+#include    "windowstr.h"
+#include    "font.h"
+#include    "dixfontstr.h"
+#include    "fontstruct.h"
+#include    "mi.h"
+#include    "regionstr.h"
+#include    "globals.h"
+#include    "gcstruct.h"
+#include    "shadow.h"
+
+void *
+shadowAlloc (int width, int height, int bpp)
+{
+    int	    stride;
+    void    *fb;
+
+    /* Cant use PixmapBytePad -- the structure is probably not initialized yet */
+    stride = BitmapBytePad (width * bpp);
+    fb = xalloc (stride * height);
+    return fb;
+}
Index: xc/programs/Xserver/miext/shadow/shmodule.c
diff -u /dev/null xc/programs/Xserver/miext/shadow/shmodule.c:1.1
--- /dev/null	Mon Dec 18 14:33:24 2000
+++ xc/programs/Xserver/miext/shadow/shmodule.c	Sun Sep  3 01:07:24 2000
@@ -0,0 +1,56 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shmodule.c,v 1.1 2000/09/03 05:07:24 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+#include    "X.h"
+#include    "scrnintstr.h"
+#include    "windowstr.h"
+#include    "font.h"
+#include    "dixfontstr.h"
+#include    "fontstruct.h"
+#include    "mi.h"
+#include    "regionstr.h"
+#include    "globals.h"
+#include    "gcstruct.h"
+#include "shadow.h"
+
+static XF86ModuleVersionInfo VersRec =
+{
+	"shadow",
+	MODULEVENDORSTRING,
+	MODINFOSTRING1,
+	MODINFOSTRING2,
+	XF86_VERSION_CURRENT,
+	1, 0, 0,
+	ABI_CLASS_ANSIC,		/* Only need the ansic layer */
+	ABI_ANSIC_VERSION,
+	MOD_CLASS_NONE,
+	{0,0,0,0}       /* signature, to be patched into the file by a tool */
+};
+
+XF86ModuleData shadowModuleData = { &VersRec, NULL, NULL };
+
+#endif
Index: xc/programs/Xserver/miext/shadow/shpacked.c
diff -u /dev/null xc/programs/Xserver/miext/shadow/shpacked.c:1.3
--- /dev/null	Mon Dec 18 14:33:24 2000
+++ xc/programs/Xserver/miext/shadow/shpacked.c	Mon Sep 18 23:33:33 2000
@@ -0,0 +1,108 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shpacked.c,v 1.3 2000/09/19 03:33:33 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include    "X.h"
+#include    "scrnintstr.h"
+#include    "windowstr.h"
+#include    "font.h"
+#include    "dixfontstr.h"
+#include    "fontstruct.h"
+#include    "mi.h"
+#include    "regionstr.h"
+#include    "globals.h"
+#include    "gcstruct.h"
+#include    "shadow.h"
+#include    "fb.h"
+
+void
+shadowUpdatePacked (ScreenPtr pScreen,
+		    PixmapPtr pShadow,
+		    RegionPtr damage)
+{
+    shadowScrPriv(pScreen);
+    int		nbox = REGION_NUM_RECTS (damage);
+    BoxPtr	pbox = REGION_RECTS (damage);
+    FbBits	*shaBase, *shaLine, *sha;
+    FbBits	s;
+    FbStride	shaStride;
+    int		scrBase, scrLine, scr;
+    int		shaBpp;
+    int		x, y, w, h, width;
+    int         i;
+    FbBits	*winBase, *winLine, *win;
+    CARD32      winSize;
+    int		plane;
+
+    fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp);
+    while (nbox--)
+    {
+	x = pbox->x1 * shaBpp;
+	y = pbox->y1;
+	w = (pbox->x2 - pbox->x1) * shaBpp;
+	h = pbox->y2 - pbox->y1;
+
+	scrLine = (x >> FB_SHIFT);
+	shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+				   
+	x &= FB_MASK;
+	w = (w + x + FB_MASK) >> FB_SHIFT;
+	
+	while (h--)
+	{
+	    winSize = 0;
+	    scrBase = 0;
+	    width = w;
+	    scr = scrLine;
+	    sha = shaLine;
+	    while (width) {
+		/* how much remains in this window */
+		i = scrBase + winSize - scr;
+		if (i <= 0 || scr < scrBase)
+		{
+		    winBase = (FbBits *) (*pScrPriv->window) (pScreen,
+							      y,
+							      scr * sizeof (FbBits),
+							      SHADOW_WINDOW_WRITE,
+							      &winSize);
+		    if(!winBase)
+			return;
+		    scrBase = scr;
+		    winSize /= sizeof (FbBits);
+		    i = winSize;
+		}
+		win = winBase + (scr - scrBase);
+		if (i > width)
+		    i = width;
+		width -= i;
+		scr += i;
+#define PickBit(a,i)	(((a) >> (i)) & 1)
+		while (i--)
+		    *win++ = *sha++;
+	    }
+	    shaLine += shaStride;
+	    y++;
+	}
+	pbox++;
+    }
+}
Index: xc/programs/Xserver/miext/shadow/shplanar.c
diff -u /dev/null xc/programs/Xserver/miext/shadow/shplanar.c:1.2
--- /dev/null	Mon Dec 18 14:33:24 2000
+++ xc/programs/Xserver/miext/shadow/shplanar.c	Mon Sep 18 23:33:33 2000
@@ -0,0 +1,166 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shplanar.c,v 1.2 2000/09/19 03:33:33 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include    "X.h"
+#include    "scrnintstr.h"
+#include    "windowstr.h"
+#include    "font.h"
+#include    "dixfontstr.h"
+#include    "fontstruct.h"
+#include    "mi.h"
+#include    "regionstr.h"
+#include    "globals.h"
+#include    "gcstruct.h"
+#include    "shadow.h"
+#include    "fb.h"
+
+/*
+ * 32 4-bit pixels per write
+ */
+
+#define PL_SHIFT    7	    
+#define PL_UNIT	    (1 << PL_SHIFT)
+#define PL_MASK	    (PL_UNIT - 1)
+
+/*
+ *  32->8 conversion:
+ *
+ *      7 6 5 4 3 2 1 0
+ *      A B C D E F G H
+ *
+ *      3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+ *      1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * m    . . . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A
+ * m1   G . . . F . . . E . . . D . . . C . . . B . . . A . . . . . . .	    m << (7 - (p))
+ * m2   . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A . .	    (m >> (p)) << 2
+ * m3   G               E               C               A                   m1 & 0x80808080
+ * m4     H               F               D               B                 m2 & 0x40404040
+ * m5   G H             E F             C D             A B                 m3 | m4
+ * m6   G H             E F             C D     G H     A B     E F         m5 | (m5 >> 20)
+ * m7   G H             E F             C D     G H     A B C D E F G H     m6 | (m6 >> 10)
+ */
+
+#if 0
+#define GetBits(p,o,d) {\
+    m = sha[o]; \
+    m1 = m << (7 - (p)); \
+    m2 = (m >> (p)) << 2; \
+    m3 = m1 & 0x80808080; \
+    m4 = m2 & 0x40404040; \
+    m5 = m3 | m4; \
+    m6 = m5 | (m5 >> 20); \
+    d = m6 | (m6 >> 10); \
+}
+#else
+#define GetBits(p,o,d) {\
+    m = sha[o]; \
+    m5 = ((m << (7 - (p))) & 0x80808080) | (((m >> (p)) << 2) & 0x40404040); \
+    m6 = m5 | (m5 >> 20); \
+    d = m6 | (m6 >> 10); \
+}
+#endif
+
+void
+shadowUpdatePlanar4 (ScreenPtr	pScreen,
+		     PixmapPtr	pShadow,
+		     RegionPtr	damage)
+{
+    shadowScrPriv(pScreen);
+    int		nbox = REGION_NUM_RECTS (damage);
+    BoxPtr	pbox = REGION_RECTS (damage);
+    CARD32	*shaBase, *shaLine, *sha;
+    FbStride	shaStride;
+    int		scrBase, scrLine, scr;
+    int		shaBpp;
+    int		x, y, w, h, width;
+    int         i;
+    CARD32	*winBase, *winLine, *win;
+    CARD32	winSize;
+    int		plane;
+    CARD32	m,m5,m6;
+    CARD8	s1, s2, s3, s4;
+
+    fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp);
+    while (nbox--)
+    {
+	x = pbox->x1 * shaBpp;
+	y = pbox->y1;
+	w = (pbox->x2 - pbox->x1) * shaBpp;
+	h = pbox->y2 - pbox->y1;
+
+	w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
+	x &= ~PL_MASK;
+	
+	scrLine = (x >> PL_SHIFT);
+	shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+	
+	while (h--)
+	{
+	    for (plane = 0; plane < 4; plane++)
+	    {
+		width = w;
+		scr = scrLine;
+		sha = shaLine;
+		winSize = 0;
+		scrBase = 0;
+		while (width) {
+		    /* how much remains in this window */
+		    i = scrBase + winSize - scr;
+		    if (i <= 0 || scr < scrBase)
+		    {
+			winBase = (CARD32 *) (*pScrPriv->window) (pScreen,
+								  y,
+								  (scr << 4) | (plane),
+								  SHADOW_WINDOW_WRITE,
+								  &winSize);
+			if(!winBase)
+			return;
+			winSize >>= 2;
+			scrBase = scr;
+			i = winSize;
+		    }
+		    win = winBase + (scr - scrBase);
+		    if (i > width)
+		    i = width;
+		    width -= i;
+		    scr += i;
+		   
+		    while (i--)
+		    {
+			GetBits(plane,0,s1);
+			GetBits(plane,1,s2);
+			GetBits(plane,2,s3);
+			GetBits(plane,3,s4);
+			*win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+			sha += 4;
+		    }
+		}
+	    }
+	    shaLine += shaStride;
+	    y++;
+	}
+	pbox++;
+    }
+}
+		    
Index: xc/programs/Xserver/miext/shadow/shplanar8.c
diff -u /dev/null xc/programs/Xserver/miext/shadow/shplanar8.c:1.2
--- /dev/null	Mon Dec 18 14:33:24 2000
+++ xc/programs/Xserver/miext/shadow/shplanar8.c	Mon Sep 18 23:33:33 2000
@@ -0,0 +1,168 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shplanar8.c,v 1.2 2000/09/19 03:33:33 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include    "X.h"
+#include    "scrnintstr.h"
+#include    "windowstr.h"
+#include    "font.h"
+#include    "dixfontstr.h"
+#include    "fontstruct.h"
+#include    "mi.h"
+#include    "regionstr.h"
+#include    "globals.h"
+#include    "gcstruct.h"
+#include    "shadow.h"
+#include    "fb.h"
+
+/*
+ * Expose 8bpp depth 4
+ */
+
+/*
+ *  32->8 conversion:
+ *
+ *      7 6 5 4 3 2 1 0
+ *      A B C D E F G H
+ *
+ *      3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+ *      1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * m1   D x x x x x x x C x x x x x x x B x x x x x x x A x x x x x x x     sha[0] << (7-(p))
+ * m2   x x x x H x x x x x x x G x x x x x x x F x x x x x x x E x x x     sha[1] << (3-(p))
+ * m3   D               C               B               A                   m1 & 0x80808080
+ * m4           H               G               F               E           m2 & 0x08080808
+ * m5   D       H       C       G       B       F       A       E	    m3 | m4
+ * m6                     D       H       C       G       B       F         m5 >> 9
+ * m7   D       H       C D     G H     B C     F G     A B     E F         m5 | m6
+ * m8                                       D       H       C D     G H     m7 >> 18
+ * m9   D       H       C D     G H     B C D   F G H   A B C D E F G H     m7 | m8
+ */
+
+#define PL_SHIFT    8
+#define PL_UNIT	    (1 << PL_SHIFT)
+#define PL_MASK	    (PL_UNIT - 1)
+
+#if 0
+#define GetBits(p,o,d) { \
+    m1 = sha[o] << (7 - (p)); \
+    m2 = sha[(o)+1] << (3 - (p)); \
+    m3 = m1 & 0x80808080; \
+    m4 = m2 & 0x08080808; \
+    m5 = m3 | m4; \
+    m6 = m5 >> 9; \
+    m7 = m5 | m6; \
+    m8 = m7 >> 18; \
+    d = m7 | m8; \
+}
+#else
+#define GetBits(p,o,d) { \
+    m5 = ((sha[o] << (7 - (p))) & 0x80808080) | ((sha[(o)+1] << (3 - (p))) & 0x08080808); \
+    m7 = m5 | (m5 >> 9); \
+    d = m7 | (m7 >> 18); \
+}
+#endif
+
+void
+shadowUpdatePlanar4x8 (ScreenPtr	pScreen,
+		       PixmapPtr	pShadow,
+		       RegionPtr	damage)
+{
+    shadowScrPriv(pScreen);
+    int		nbox = REGION_NUM_RECTS (damage);
+    BoxPtr	pbox = REGION_RECTS (damage);
+    CARD32	*shaBase, *shaLine, *sha;
+    CARD8	s1, s2, s3, s4;
+    CARD32	m;
+    FbStride	shaStride;
+    int		scrBase, scrLine, scr;
+    int		shaBpp;
+    int		x, y, w, h, width;
+    int         i;
+    CARD32	*winBase, *winLine, *win;
+    CARD32	winSize;
+    int		plane;
+    CARD32	m1,m2,m3,m4,m5,m6,m7,m8;
+
+    fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp);
+    while (nbox--)
+    {
+	x = pbox->x1 * shaBpp;
+	y = pbox->y1;
+	w = (pbox->x2 - pbox->x1) * shaBpp;
+	h = pbox->y2 - pbox->y1;
+
+	w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
+	x &= ~PL_MASK;
+	
+	scrLine = (x >> PL_SHIFT);
+	shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+	
+	while (h--)
+	{
+	    for (plane = 0; plane < 4; plane++)
+	    {
+		width = w;
+		scr = scrLine;
+		sha = shaLine;
+		winSize = 0;
+		scrBase = 0;
+		while (width) {
+		    /* how much remains in this window */
+		    i = scrBase + winSize - scr;
+		    if (i <= 0 || scr < scrBase)
+		    {
+			winBase = (CARD32 *) (*pScrPriv->window) (pScreen,
+								  y,
+								  (scr << 4) | (plane),
+								  SHADOW_WINDOW_WRITE,
+								  &winSize);
+			if(!winBase)
+			return;
+			winSize >>= 2;
+			scrBase = scr;
+			i = winSize;
+		    }
+		    win = winBase + (scr - scrBase);
+		    if (i > width)
+		    i = width;
+		    width -= i;
+		    scr += i;
+		   
+		    while (i--)
+		    {
+			GetBits(plane,0,s1);
+			GetBits(plane,2,s2);
+			GetBits(plane,4,s3);
+			GetBits(plane,6,s4);
+			*win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+			sha += 8;
+		    }
+		}
+	    }
+	    shaLine += shaStride;
+	    y++;
+	}
+	pbox++;
+    }
+}
+		    
Index: xc/programs/Xserver/miext/shadow/shrot16pack.c
diff -u /dev/null xc/programs/Xserver/miext/shadow/shrot16pack.c:1.1
--- /dev/null	Mon Dec 18 14:33:24 2000
+++ xc/programs/Xserver/miext/shadow/shrot16pack.c	Fri Sep  8 17:46:45 2000
@@ -0,0 +1,28 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shrot16pack.c,v 1.1 2000/09/08 21:46:45 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC	shadowUpdateRotate16
+#define Data	CARD16
+
+#include "shrotpack.h"
Index: xc/programs/Xserver/miext/shadow/shrot32pack.c
diff -u /dev/null xc/programs/Xserver/miext/shadow/shrot32pack.c:1.1
--- /dev/null	Mon Dec 18 14:33:25 2000
+++ xc/programs/Xserver/miext/shadow/shrot32pack.c	Fri Sep  8 17:46:45 2000
@@ -0,0 +1,28 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shrot32pack.c,v 1.1 2000/09/08 21:46:45 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC	shadowUpdateRotate32
+#define Data	CARD32
+
+#include "shrotpack.h"
Index: xc/programs/Xserver/miext/shadow/shrot8pack.c
diff -u /dev/null xc/programs/Xserver/miext/shadow/shrot8pack.c:1.1
--- /dev/null	Mon Dec 18 14:33:25 2000
+++ xc/programs/Xserver/miext/shadow/shrot8pack.c	Fri Sep  8 17:46:46 2000
@@ -0,0 +1,28 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shrot8pack.c,v 1.1 2000/09/08 21:46:46 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#define FUNC	shadowUpdateRotate8
+#define Data	CARD8
+
+#include "shrotpack.h"
Index: xc/programs/Xserver/miext/shadow/shrotpack.h
diff -u /dev/null xc/programs/Xserver/miext/shadow/shrotpack.h:1.2
--- /dev/null	Mon Dec 18 14:33:25 2000
+++ xc/programs/Xserver/miext/shadow/shrotpack.h	Wed Sep 13 19:20:13 2000
@@ -0,0 +1,150 @@
+/*
+ * $XFree86: xc/programs/Xserver/miext/shadow/shrotpack.h,v 1.2 2000/09/13 23:20:13 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include    "X.h"
+#include    "scrnintstr.h"
+#include    "windowstr.h"
+#include    "font.h"
+#include    "dixfontstr.h"
+#include    "fontstruct.h"
+#include    "mi.h"
+#include    "regionstr.h"
+#include    "globals.h"
+#include    "gcstruct.h"
+#include    "shadow.h"
+#include    "fb.h"
+
+#define NONE		    0
+#define CLOCKWISE	    1
+#define COUNTERCLOCKWISE    2
+#define UPSIDEDOWN	    3
+
+#define ROTATE	CLOCKWISE
+
+#if ROTATE == CLOCKWISE
+#define FIRSTSHA(x,y,w,h)   (((y) + (h) - 1) * shaStride + (x))
+#define SCRLEFT(x,y,w,h)    (pScreen->height - ((y) + (h)))
+#define SCRWIDTH(x,y,w,h)   (h)
+#define STEPDOWN(x,y,w,h)   ((w)--)
+#define SCRY(x,y,w,h)	    (x)
+#define SHASTEPX(stride)    -(stride)
+#define SHASTEPY(stride)    1
+#define NEXTY(x,y,w,h)	    ((x)++)
+#endif
+
+#if ROTATE == COUNTERCLOCKWISE
+#define FIRSTSHA(x,y,w,h)   ((y) * shaStride + (x))
+#define SCRLEFT(x,y,w,h)    (y)
+#define SCRWIDTH(x,y,w,h)   (h)
+#define STEPDOWN(x,y,w,h)   ((w)--)
+#define SCRY(x,y,w,h)	    (pScreen->width - (x) - 1)
+#define SHASTEPX(stride)    (stride)
+#define SHASTEPY(stride)    -1
+#define NEXTY(x,y,w,h)	    ((x)--)
+#endif
+
+#if ROTATE == UPSIDEDOWN
+#define FIRSTSHA(x,y,w,h)   (((y) + (h) - 1) * shaStride + (x) + (w) - 1)
+#define SCRLEFT(x,y,w,h)    (pScreen->width - ((x) + (w)))
+#define SCRWIDTH(x,y,w,h)   (w)
+#define STEPDOWN(x,y,w,h)   ((h)--)
+#define SCRY(x,y,w,h)	    (pScreen->height - (y) - 1)
+#define SHASTEPX(stride)    (-1)
+#define SHASTEPY(stride)    -(stride)
+#define NEXTY(x,y,w,h)	    ((y)--)
+#endif
+
+void
+FUNC (ScreenPtr pScreen,
+      PixmapPtr pShadow,
+      RegionPtr damage)
+{
+    shadowScrPriv(pScreen);
+    int		nbox = REGION_NUM_RECTS (damage);
+    BoxPtr	pbox = REGION_RECTS (damage);
+    FbBits	*shaBits;
+    Data	*shaBase, *shaLine, *sha;
+    FbStride	shaStride;
+    int		scrBase, scrLine, scr;
+    int		shaBpp;
+    int		x, y, w, h, width;
+    int         i;
+    Data	*winBase, *winLine, *win;
+    CARD32	winSize;
+    int		plane;
+
+    fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp);
+    shaBase = (Data *) shaBits;
+    shaStride = shaStride * sizeof (FbBits) / sizeof (Data);
+    while (nbox--)
+    {
+	x = pbox->x1;
+	y = pbox->y1;
+	w = (pbox->x2 - pbox->x1);
+	h = pbox->y2 - pbox->y1;
+
+
+	scrLine = SCRLEFT(x,y,w,h);
+	shaLine = shaBase + FIRSTSHA(x,y,w,h);
+				   
+	while (STEPDOWN(x,y,w,h))
+	{
+	    winSize = 0;
+	    scrBase = 0;
+	    width = SCRWIDTH(x,y,w,h);
+	    scr = scrLine;
+	    sha = shaLine;
+	    while (width) {
+		/* how much remains in this window */
+		i = scrBase + winSize - scr;
+		if (i <= 0 || scr < scrBase)
+		{
+		    winBase = (Data *) (*pScrPriv->window) (pScreen,
+							    SCRY(x,y,w,h),
+							    scr * sizeof (Data),
+							    SHADOW_WINDOW_WRITE,
+							    &winSize);
+		    if(!winBase)
+			return;
+		    scrBase = scr;
+		    winSize /= sizeof (Data);
+		    i = winSize;
+		}
+		win = winBase + (scr - scrBase);
+		if (i > width)
+		    i = width;
+		width -= i;
+		scr += i;
+		while (i--)
+		{
+		    *win++ = *sha;
+		    sha += SHASTEPX(shaStride);
+		}
+	    }
+	    shaLine += SHASTEPY(shaStride);
+	    NEXTY(x,y,w,h);
+	}
+	pbox++;
+    }
+}
Index: xc/programs/Xserver/os/Imakefile
diff -u xc/programs/Xserver/os/Imakefile:3.27 xc/programs/Xserver/os/Imakefile:3.28
--- xc/programs/Xserver/os/Imakefile:3.27	Fri May  5 13:47:29 2000
+++ xc/programs/Xserver/os/Imakefile	Thu Nov 30 18:30:06 2000
@@ -1,5 +1,5 @@
 XCOMM $TOG: Imakefile /main/85 1997/12/07 18:26:23 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/os/Imakefile,v 3.27 2000/05/05 17:47:29 keithp Exp $
+XCOMM $XFree86: xc/programs/Xserver/os/Imakefile,v 3.28 2000/11/30 23:30:06 dawes Exp $
 #include <Server.tmpl>
 
 /*
@@ -108,6 +108,9 @@
    KRB5_DEFINES = Krb5Defines
  XALLOC_DEFINES = XallocDefines
   ERROR_DEFINES = ServerErrorDefines
+#if HasPam && HasPamMisc
+    PAM_DEFINES = -DUSE_PAM
+#endif
         DEFINES = -DXSERV_t -DTRANS_SERVER $(CONNECTION_FLAGS) $(MEM_DEFINES) $(XDMAUTHDEFS) $(RPCDEFS) $(SIGNAL_DEFINES) $(OS_DEFINES) $(KRB5_DEFINES) $(RGB_DEFINES)
        INCLUDES = -I.  -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(TOP)/lib/Xau -I../lbx Krb5Includes
  DEPEND_DEFINES = $(DBM_DEFINES) $(XDMCP_DEFINES) $(EXT_DEFINES) $(TRANS_INCLUDES) $(CONNECTION_FLAGS)
@@ -145,7 +148,7 @@
 #if BuildLBX
 SpecialCObjectRule(lbxio,$(ICONFIGFILES),$(EXT_DEFINES))
 #endif
-SpecialCObjectRule(utils,$(ICONFIGFILES),$(XDMCP_DEFINES) $(EXT_DEFINES) $(ERROR_DEFINES))
+SpecialCObjectRule(utils,$(ICONFIGFILES),$(XDMCP_DEFINES) $(EXT_DEFINES) $(ERROR_DEFINES) $(PAM_DEFINES))
 SpecialCObjectRule(xalloc,$(ICONFIGFILES),$(XALLOC_DEFINES))
 #if defined(SparcArchitecture) && HasGcc && !HasGcc2
 oscolor.o: oscolor.c $(ICONFIGFILES)
Index: xc/programs/Xserver/os/WaitFor.c
diff -u xc/programs/Xserver/os/WaitFor.c:3.24 xc/programs/Xserver/os/WaitFor.c:3.26
--- xc/programs/Xserver/os/WaitFor.c:3.24	Fri May  5 13:53:50 2000
+++ xc/programs/Xserver/os/WaitFor.c	Thu Aug 31 15:03:59 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/os/WaitFor.c,v 3.24 2000/05/05 17:53:50 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/os/WaitFor.c,v 3.26 2000/08/31 19:03:59 tsi Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -144,6 +144,9 @@
 {
     int i;
     struct timeval waittime, *wt;
+#ifdef __CYGWIN__
+    struct timeval waittime0, *wt0;
+#endif
     INT32 timeout;
 #ifdef DPMSExtension
     INT32 standbyTimeout, suspendTimeout, offTimeout;
@@ -238,7 +241,12 @@
 			      (now - lastDeviceEventTime.milliseconds));
 #endif /* DPMSExtension */
 
-	    if (timeout <= 0
+	    if (
+#ifndef __CYGWIN__
+		timeout <= 0
+#else
+		timeout = 0
+#endif
 #ifdef DPMSExtension
 		 && ScreenSaverTime > 0
 #endif /* DPMSExtension */
@@ -338,6 +346,10 @@
 #ifdef XTESTEXT1
 	/* XXX how does this interact with new write block handling? */
 	if (playback_on) {
+#ifdef __CYGWIN__
+	    waittime.tv_sec = 0;
+	    waittime.tv_usec = 0;
+#endif
 	    wt = &waittime;
 	    XTestComputeWaitTime (&waittime);
 	}
@@ -350,8 +362,17 @@
 	    XFD_COPYSET(&ClientsWriteBlocked, &clientsWritable);
 	    i = Select (MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
 	}
-	else
+	else 
+	{
+#ifndef __CYGWIN__
 	    i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt);
+#else
+	    waittime0.tv_sec = 0;
+	    waittime0.tv_usec = 10000;
+	    wt0 = &waittime0;
+	    i = Select (MaxClients, &LastSelectMask, NULL, NULL, wt0);
+#endif
+	}
 	selecterr = errno;
 	WakeupHandler(i, (pointer)&LastSelectMask);
 #ifdef XTESTEXT1
@@ -540,7 +561,7 @@
 {
     register int	i, wt, nt;
     struct timeval	*wtp;
-    long        	alwaysCheckForInput[2];
+    HWEventQueueType   	alwaysCheckForInput[2];
     int 		nready;
     int 		timeout;
     unsigned long	now;
Index: xc/programs/Xserver/os/auth.c
diff -u xc/programs/Xserver/os/auth.c:1.4 xc/programs/Xserver/os/auth.c:1.5
--- xc/programs/Xserver/os/auth.c:1.4	Sun Dec  6 01:08:47 1998
+++ xc/programs/Xserver/os/auth.c	Fri Aug  4 12:13:44 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/Xserver/os/auth.c,v 1.4 1998/12/06 06:08:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/auth.c,v 1.5 2000/08/04 16:13:44 eich Exp $ */
 
 /*
  * authorization hooks for the server
@@ -150,6 +150,7 @@
 #endif
     if (!f)
 	return 0;
+
     while ((auth = XauReadAuth (f)) != 0) {
 	for (i = 0; i < NUM_AUTHORIZATION; i++) {
 	    if (protocols[i].name_length == auth->name_length &&
@@ -163,6 +164,7 @@
 	}
 	XauDisposeAuth (auth);
     }
+
 #if !defined(WIN32) && !defined(__EMX__)
     Pclose (f);
 #else
Index: xc/programs/Xserver/os/connection.c
diff -u xc/programs/Xserver/os/connection.c:3.40 xc/programs/Xserver/os/connection.c:3.43
--- xc/programs/Xserver/os/connection.c:3.40	Mon Jun 26 19:00:32 2000
+++ xc/programs/Xserver/os/connection.c	Tue Sep 19 08:46:22 2000
@@ -41,7 +41,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/programs/Xserver/os/connection.c,v 3.40 2000/06/26 23:00:32 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/connection.c,v 3.43 2000/09/19 12:46:22 eich Exp $ */
 /*****************************************************************
  *  Stuff to create connections --- OS dependent
  *
@@ -74,12 +74,12 @@
 #include <stdio.h>
 
 #ifndef WIN32
-#ifndef MINIX
-#ifndef Lynx
-#include <sys/socket.h>
-#else
+#if defined(__CYGWIN__)
+#include <cygwin/socket.h>
+#elif defined(MINIX) || defined(Lynx)
 #include <socket.h>
-#endif
+#else
+#include <sys/socket.h>
 #endif
 
 #ifdef hpux
@@ -117,7 +117,7 @@
 #if defined(TCPCONN) || defined(STREAMSCONN)
 # include <netinet/in.h>
 # include <arpa/inet.h>
-# ifndef hpux
+# if !defined(hpux) && !defined(__CYGWIN__)
 #  ifdef apollo
 #   ifndef NO_TCP_H
 #    include <netinet/tcp.h>
@@ -139,7 +139,7 @@
 #include <server/ip/gen/inet.h>
 #endif
 
-#if !defined(AMOEBA) && !defined(_MINIX) && !defined(__EMX__)
+#if !defined(AMOEBA) && !defined(_MINIX) && !defined(__EMX__) && !defined(__CYGWIN__)
 #ifndef Lynx
 #include <sys/uio.h>
 #else
@@ -205,7 +205,7 @@
 int GrabInProgress = 0;
 
 int *ConnectionTranslation = NULL;
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 /* SPAM ALERT !!!
  * On NT fds are not between 0 and MAXSOCKS, they are unrelated, and there is
  * not even a known maximum value, so use something quite arbitrary for now.
@@ -310,7 +310,7 @@
     ErrorF("InitConnectionLimits: MaxClients = %d\n", MaxClients);
 #endif
 
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__CYGWIN__)
     ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1));
 #else
     ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(MAXFD));
@@ -335,7 +335,7 @@
     FD_ZERO(&LastSelectMask);
     FD_ZERO(&ClientsWithInput);
 
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__CYGWIN__)
     for (i=0; i<MaxClients; i++) ConnectionTranslation[i] = 0;
 #else
     for (i=0; i<MAXFD; i++) ConnectionTranslation[i] = 0;
@@ -380,7 +380,7 @@
 
     if (!XFD_ANYSET (&WellKnownConnections))
         FatalError ("Cannot establish any listening sockets - Make sure an X server isn't already running");
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__CYGWIN__)
     OsSignal (SIGPIPE, SIG_IGN);
     OsSignal (SIGHUP, AutoResetServer);
 #endif
@@ -403,7 +403,7 @@
      * in the second case, the signal will be quite
      * useful
      */
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__CYGWIN__)
     if (OsSignal (SIGUSR1, SIG_IGN) == SIG_IGN)
 	RunFromSmartParent = TRUE;
     ParentProcess = getppid ();
@@ -464,7 +464,7 @@
     /*
      * See above in CreateWellKnownSockets about SIGUSR1
      */
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__CYGWIN__)
     if (RunFromSmartParent) {
 	if (ParentProcess > 0) {
 	    kill (ParentProcess, SIGUSR1);
@@ -910,7 +910,7 @@
 
 #ifndef WIN32
 	curconn = ffs (readyconnections.fds_bits[i]) - 1;
-	readyconnections.fds_bits[i] &= ~(1L << curconn);
+	readyconnections.fds_bits[i] &= ~((fd_mask)1 << curconn);
 	curconn += (i * (sizeof(fd_mask)*8));
 #else
 	curconn = XFD_FD(&readyconnections, i);
@@ -1047,7 +1047,7 @@
 }
 
 /*****************
- * CheckConections
+ * CheckConnections
  *    Some connection has died, go find which one and shut it down 
  *    The file descriptor has been closed, but is still in AllClients.
  *    If would truly be wonderful if select() would put the bogus
@@ -1087,7 +1087,7 @@
             r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
             if (r < 0)
 		CloseDownClient(clients[ConnectionTranslation[curclient]]);
-	    mask &= ~(1L << curoff);
+	    mask &= ~((fd_mask)1 << curoff);
 	}
     }	
 #else
Index: xc/programs/Xserver/os/decompress.c
diff -u xc/programs/Xserver/os/decompress.c:1.2 xc/programs/Xserver/os/decompress.c:1.3
--- xc/programs/Xserver/os/decompress.c:1.2	Sun Jan 31 07:22:20 1999
+++ xc/programs/Xserver/os/decompress.c	Tue Sep 19 08:46:23 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/Xserver/os/decompress.c,v 1.2 1999/01/31 12:22:20 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/decompress.c,v 1.3 2000/09/19 12:46:23 eich Exp $ */
 
 /* 
  * decompress - cat a compressed file
@@ -77,9 +77,9 @@
 #define INIT_BITS 9			/* initial number of bits/code */
 
 #ifdef COMPATIBLE		/* But wrong! */
-# define MAXCODE(n_bits)	(1 << (n_bits) - 1)
+# define MAXCODE(n_bits)	((code_int)1 << (n_bits) - 1)
 #else
-# define MAXCODE(n_bits)	((1 << (n_bits)) - 1)
+# define MAXCODE(n_bits)	(((code_int)1 << (n_bits)) - 1)
 #endif /* COMPATIBLE */
 
 static code_int getcode();
@@ -153,7 +153,7 @@
     file->file = f;
     file->maxbits = maxbits;
     file->block_compress = code & BLOCK_MASK;
-    file->maxmaxcode = 1 << file->maxbits;
+    file->maxmaxcode = (code_int)1 << file->maxbits;
     file->tab_suffix = (char_type *) &file[1];
     file->tab_prefix = (unsigned short *) (file->tab_suffix + file->maxmaxcode);
     /*
Index: xc/programs/Xserver/os/io.c
diff -u xc/programs/Xserver/os/io.c:3.22 xc/programs/Xserver/os/io.c:3.23
--- xc/programs/Xserver/os/io.c:3.22	Thu May 18 19:46:26 2000
+++ xc/programs/Xserver/os/io.c	Thu Aug 10 13:40:40 2000
@@ -48,7 +48,7 @@
  *   InsertFakeRequest, ResetCurrentRequest
  *
  *****************************************************************/
-/* $XFree86: xc/programs/Xserver/os/io.c,v 3.22 2000/05/18 23:46:26 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/io.c,v 3.23 2000/08/10 17:40:40 dawes Exp $ */
 
 #ifdef WIN32
 #include <X11/Xwinsock.h>
@@ -804,7 +804,7 @@
     OsCommPtr oc;
     register ClientPtr client;
     Bool newoutput = NewOutputPending;
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
     fd_set newOutputPending;
 #endif
 
Index: xc/programs/Xserver/os/osinit.c
diff -u xc/programs/Xserver/os/osinit.c:3.19 xc/programs/Xserver/os/osinit.c:3.20
--- xc/programs/Xserver/os/osinit.c:3.19	Sun Dec 26 19:39:58 1999
+++ xc/programs/Xserver/os/osinit.c	Thu Aug 10 13:40:40 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/os/osinit.c,v 3.19 1999/12/27 00:39:58 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/os/osinit.c,v 3.20 2000/08/10 17:40:40 dawes Exp $ */
 /***********************************************************
 
 Copyright 1987, 1998  The Open Group
@@ -131,7 +131,7 @@
 		dup2 (fileno (err), 2);
 		fclose (err);
 	    }
-#if defined(SYSV) || defined(SVR4) || defined(MINIX) || defined(__EMX__) || defined(WIN32)
+#if defined(SYSV) || defined(SVR4) || defined(MINIX) || defined(__EMX__) || defined(WIN32) || defined(__CYGWIN__)
 	    {
 	    static char buf[BUFSIZ];
 	    setvbuf (stderr, buf, _IOLBF, BUFSIZ);
Index: xc/programs/Xserver/os/utils.c
diff -u xc/programs/Xserver/os/utils.c:3.59 xc/programs/Xserver/os/utils.c:3.67
--- xc/programs/Xserver/os/utils.c:3.59	Fri Jun 16 20:27:34 2000
+++ xc/programs/Xserver/os/utils.c	Thu Nov 30 18:30:06 2000
@@ -45,9 +45,13 @@
 OR PERFORMANCE OF THIS SOFTWARE.
 
 */
-/* $XFree86: xc/programs/Xserver/os/utils.c,v 3.59 2000/06/17 00:27:34 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/utils.c,v 3.67 2000/11/30 23:30:06 dawes Exp $ */
+#ifdef __CYGWIN__
+#include <stdlib.h>
+#include <signal.h>
+#endif
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(__CYGWIN__)
 #include <X11/Xwinsock.h>
 #endif
 #include "Xos.h"
@@ -151,7 +155,7 @@
 #ifdef MEMBUG
 #define MEM_FAIL_SCALE 100000
 long Memory_fail = 0;
-#ifdef linux
+#ifndef X_NOT_STDC_ENV
 #include <stdlib.h>  /* for random() */
 #endif
 #endif
@@ -181,7 +185,7 @@
     return oact.sa_handler;
 #endif
 }
-
+	
 #ifdef SERVER_LOCK
 /*
  * Explicit support for a server lock file like the ones used for UUCP.
@@ -844,7 +848,7 @@
 #ifdef SERVER_LOCK
 	else if ( strcmp ( argv[i], "-nolock") == 0)
 	{
-#if !defined(WIN32) && !defined(__EMX__)
+#if !defined(WIN32) && !defined(__EMX__) && !defined(__CYGWIN__)
 	  if (getuid() != 0)
 	    ErrorF("Warning: the -nolock option can only be used by root\n");
 	  else
@@ -1121,7 +1125,7 @@
 {
     int i;
 
-#if !defined(WIN32) && !defined(__EMX__)
+#if !defined(WIN32) && !defined(__EMX__) && !defined(__CYGWIN__)
     if (getuid() != geteuid())
 	return;
 #endif
@@ -1465,12 +1469,13 @@
 #if NeedVarargsPrototypes
     va_list args;
 #endif
-    static beenhere = 0;
+    static Bool beenhere = FALSE;
 
     if (beenhere)
 	ErrorF("\nFatalError re-entered, aborting\n");
     else
 	ErrorF("\nFatal server error:\n");
+
 #if NeedVarargsPrototypes
     va_start(args, f);
     VErrorF(f, args);
@@ -1486,9 +1491,10 @@
 #ifdef ABORTONFATALERROR
     abort();
 #endif
-    if (!beenhere)
+    if (!beenhere) {
+	beenhere = TRUE;
 	AbortServer();
-    else
+    } else
 	abort();
     /*NOTREACHED*/
 }
@@ -1644,6 +1650,8 @@
 	perror ("scheduling timer");
 	return FALSE;
     }
+    /* stop the timer and wait for WaitForSomething to start it */
+    SmartScheduleStopTimer ();
     return TRUE;
 #else
     return FALSE;
@@ -1651,6 +1659,57 @@
 }
 #endif
 
+#ifdef SIG_BLOCK
+static sigset_t	PreviousSignalMask;
+static int	BlockedSignalCount;
+#endif
+
+void
+OsBlockSignals (void)
+{
+#ifdef SIG_BLOCK
+    if (BlockedSignalCount++ == 0)
+    {
+	sigset_t    set;
+	
+	sigemptyset (&set);
+#ifdef SIGALRM
+	sigaddset (&set, SIGALRM);
+#endif
+#ifdef SIGVTALRM
+	sigaddset (&set, SIGVTALRM);
+#endif
+#ifdef SIGWINCH
+	sigaddset (&set, SIGWINCH);
+#endif
+#ifdef SIGIO
+	sigaddset (&set, SIGIO);
+#endif
+#ifdef SIGTSTP
+	sigaddset (&set, SIGTSTP);
+#endif
+#ifdef SIGTTIN
+	sigaddset (&set, SIGTTIN);
+#endif
+#ifdef SIGTTOU
+	sigaddset (&set, SIGTTOU);
+#endif
+	sigprocmask (SIG_BLOCK, &set, &PreviousSignalMask);
+    }
+#endif
+}
+
+void
+OsReleaseSignals (void)
+{
+#ifdef SIG_BLOCK
+    if (--BlockedSignalCount == 0)
+    {
+	sigprocmask (SIG_SETMASK, &PreviousSignalMask, 0);
+    }
+#endif
+}
+
 #if !defined(WIN32) && !defined(__EMX__)
 /*
  * "safer" versions of system(3), popen(3) and pclose(3) which give up
@@ -1759,6 +1818,9 @@
 	_exit(127);
     }
 
+    /* Avoid EINTR during stdio calls */
+    OsBlockSignals ();
+    
     /* parent */
     if (*type == 'r') {
 	iop = fdopen(pdes[0], type);
@@ -1810,6 +1872,9 @@
 	last->next = cur->next;
     xfree(cur);
 
+    /* allow EINTR again */
+    OsReleaseSignals ();
+    
     return pid == -1 ? -1 : pstat;
 }
 #endif /* !WIN32 && !__EMX__ */
@@ -1999,4 +2064,57 @@
     FatalError("X server aborted because of unsafe environment\n");
 }
 
+/*
+ * CheckUserAuthorization: check if the user is allowed to start the
+ * X server.  This usually means some sort of PAM checking, and it is
+ * usually only done for setuid servers (uid != euid).
+ */
+
+#ifdef USE_PAM
+#include <security/pam_appl.h>
+#include <security/pam_misc.h>
+#include <pwd.h>
+#endif /* USE_PAM */
 
+void
+CheckUserAuthorization()
+{
+#ifdef USE_PAM
+    static struct pam_conv conv = {
+	misc_conv,
+	NULL
+    };
+
+    pam_handle_t *pamh = NULL;
+    struct passwd *pw;
+    int retval;
+
+    if (getuid() != geteuid()) {
+	pw = getpwuid(getuid());
+	if (pw == NULL)
+	    FatalError("getpwuid() failed for uid %d\n", getuid());
+
+	retval = pam_start("xserver", pw->pw_name, &conv, &pamh);
+	if (retval != PAM_SUCCESS)
+	    FatalError("pam_start() failed.\n"
+			"\tMissing or mangled PAM config file or module?\n");
+
+	retval = pam_authenticate(pamh, 0);
+	if (retval != PAM_SUCCESS) {
+	    pam_end(pamh, retval);
+	    FatalError("PAM authentication failed, cannot start X server.\n"
+			"\tPerhaps you do not have console ownership?\n");
+	}
+
+	retval = pam_acct_mgmt(pamh, 0);
+	if (retval != PAM_SUCCESS) {
+	    pam_end(pamh, retval);
+	    FatalError("PAM authentication failed, cannot start X server.\n"
+			"\tPerhaps you do not have console ownership?\n");
+	}
+
+	/* this is not a session, so do not do session management */
+	pam_end(pamh, PAM_SUCCESS);
+    }
+#endif
+}
Index: xc/programs/Xserver/os/xalloc.c
diff -u xc/programs/Xserver/os/xalloc.c:3.26 xc/programs/Xserver/os/xalloc.c:3.28
--- xc/programs/Xserver/os/xalloc.c:3.26	Thu May 18 19:21:42 2000
+++ xc/programs/Xserver/os/xalloc.c	Tue Nov 14 13:20:38 2000
@@ -25,7 +25,7 @@
 Pascal Haible.
 */
 
-/* $XFree86: xc/programs/Xserver/os/xalloc.c,v 3.26 2000/05/18 23:21:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/xalloc.c,v 3.28 2000/11/14 18:20:38 dawes Exp $ */
 
 /* Only used if INTERNAL_MALLOC is defined
  * - otherwise xalloc() in utils.c is used
@@ -186,7 +186,8 @@
 #define TAIL_SIZE		0
 #endif
 
-#if defined(__alpha__) || defined(__ia64__)
+#if defined(__alpha__) || defined(__alpha) || \
+    defined(__ia64__) || defined(ia64)
 #define MAGIC			0x1404196414071968
 #define MAGIC_FREE              0x1506196615061966
 #define MAGIC2			0x2515207525182079
@@ -248,6 +249,15 @@
 #define HAS_GETPAGESIZE
 #endif /* linux */
 
+#if defined(__GNU__)
+#define HAS_MMAP_ANON
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <mach/vm_param.h>     /* PAGE_SIZE */
+#define HAS_SC_PAGESIZE
+#define HAS_GETPAGESIZE
+#endif /* __GNU__ */
+
 #if defined(CSRG_BASED)
 #define HAS_MMAP_ANON
 #define HAS_GETPAGESIZE
@@ -327,7 +337,12 @@
     }
 
     /* alignment check */
-#if defined(__alpha__) || defined(__sparc__) || defined(__mips__) || defined(__powerpc__) || defined(__arm32__) || defined(__ia64__)
+#if defined(__alpha__) || defined(__alpha) || \
+    defined(__sparc__) || \
+    defined(__mips__) || \
+    defined(__powerpc__) || \
+    defined(__arm32__) || \
+    defined(__ia64__) || defined(ia64)
     amount = (amount + (sizeof(long)-1)) & ~(sizeof(long)-1);
 #endif
 
Index: xc/programs/Xserver/render/Imakefile
diff -u /dev/null xc/programs/Xserver/render/Imakefile:1.4
--- /dev/null	Mon Dec 18 14:33:29 2000
+++ xc/programs/Xserver/render/Imakefile	Tue Nov 28 17:15:31 2000
@@ -0,0 +1,27 @@
+XCOMM $XFree86: xc/programs/Xserver/render/Imakefile,v 1.4 2000/11/28 22:15:31 dawes Exp $
+#include <Server.tmpl>
+
+       SRCS =   glyph.c \
+		miglyph.c \
+		mipict.c \
+		mirect.c \
+		picture.c \
+		render.c
+
+       OBJS =   glyph.o \
+		miglyph.o \
+		mipict.o \
+		mirect.o \
+		picture.o \
+		render.o
+		
+   INCLUDES = -I../include -I../mi -I../../../include/fonts \
+   		-I../fb -I../hw/kdrive -I$(EXTINCSRC) -I$(XINCLUDESRC) -I$(FONTINCSRC) 
+   LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
+
+NormalLibraryTarget(render,$(OBJS))
+NormalLibraryObjectRule()
+LintLibraryTarget(render,$(SRCS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
Index: xc/programs/Xserver/render/glyph.c
diff -u /dev/null xc/programs/Xserver/render/glyph.c:1.4
--- /dev/null	Mon Dec 18 14:33:29 2000
+++ xc/programs/Xserver/render/glyph.c	Mon Dec  4 22:13:31 2000
@@ -0,0 +1,413 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/glyph.c,v 1.4 2000/12/05 03:13:31 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "picturestr.h"
+#include "glyphstr.h"
+
+/*
+ * From Knuth -- a good choice for hash/rehash values is p, p-2 where
+ * p and p-2 are both prime.  These tables are sized to have an extra 10%
+ * free to avoid exponential performance degradation as the hash table fills
+ */
+GlyphHashSetRec glyphHashSets[] = {
+    32,		43,		41,
+    64,		73,		71,
+    128,	151,		149,
+    256,	283,		281,
+    512,	571,		569,
+    1024,	1153,		1151,
+    2048,	2269,		2267,
+    4096,	4519,		4517,
+    8192,	9013,		9011,
+    16384,	18043,		18041,
+    32768,	36109,		36107,
+    65536,	72091,		72089,
+    131072,	144409,		144407,
+    262144,	288361,		288359,
+    524288,	576883,		576881,
+    1048576,	1153459,	1153457,
+    2097152,	2307163,	2307161,
+    4194304,	4613893,	4613891,
+    8388608,	9227641,	9227639,
+    16777216,	18455029,	18455027,
+    33554432,	36911011,	36911009,
+    67108864,	73819861,	73819859,
+    134217728,	147639589,	147639587,
+    268435456,	295279081,	295279079,
+    536870912,	590559793,	590559791,
+};
+
+#define NGLYPHHASHSETS	(sizeof(glyphHashSets)/sizeof(glyphHashSets[0]))
+
+const CARD8	glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
+
+GlyphHashRec	globalGlyphs[GlyphFormatNum];
+
+GlyphHashSetPtr
+FindGlyphHashSet (CARD32 filled)
+{
+    int	i;
+
+    for (i = 0; i < NGLYPHHASHSETS; i++)
+	if (glyphHashSets[i].entries >= filled)
+	    return &glyphHashSets[i];
+    return 0;
+}
+
+Bool
+GlyphInit (ScreenPtr pScreen)
+{
+    return TRUE;
+}
+
+GlyphRefPtr
+FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare)
+{
+    CARD32	elt, step, s;
+    GlyphPtr	glyph;
+    GlyphRefPtr	table, gr, del;
+    CARD32	tableSize = hash->hashSet->size;
+
+    table = hash->table;
+    elt = signature % tableSize;
+    step = 0;
+    del = 0;
+    for (;;)
+    {
+	gr = &table[elt];
+	s = gr->signature;
+	glyph = gr->glyph;
+	if (!glyph)
+	{
+	    if (del)
+		gr = del;
+	    break;
+	}
+	if (glyph == DeletedGlyph)
+	{
+	    if (!del)
+		del = gr;
+	    else if (gr == del)
+		break;
+	}
+	else if (s == signature &&
+		 (!match || 
+		  memcmp (&compare->info, &glyph->info, compare->size) == 0))
+	{
+	    break;
+	}
+	if (!step)
+	{
+	    step = signature % hash->hashSet->rehash;
+	    if (!step)
+		step = 1;
+	}
+	elt += step;
+	if (elt >= tableSize)
+	    elt -= tableSize;
+    }
+    return gr;
+}
+
+CARD32
+HashGlyph (GlyphPtr glyph)
+{
+    CARD32  *bits = (CARD32 *) &(glyph->info);
+    CARD32  hash;
+    int	    n = glyph->size / sizeof (CARD32);
+
+    hash = 0;
+    while (n--)
+	hash ^= *bits++;
+    return hash;
+}
+
+#ifdef CHECK_DUPLICATES
+void
+DuplicateRef (GlyphPtr glyph, char *where)
+{
+    ErrorF ("Duplicate Glyph 0x%x from %s\n", glyph, where);
+}
+
+void
+CheckDuplicates (GlyphHashPtr hash, char *where)
+{
+    GlyphPtr	g;
+    int		i, j;
+
+    for (i = 0; i < hash->hashSet->size; i++)
+    {
+	g = hash->table[i].glyph;
+	if (!g || g == DeletedGlyph)
+	    continue;
+	for (j = i + 1; j < hash->hashSet->size; j++)
+	    if (hash->table[j].glyph == g)
+		DuplicateRef (g, where);
+    }
+}
+#else
+#define CheckDuplicates(a,b)
+#define DuplicateRef(a,b)
+#endif
+
+void
+FreeGlyph (GlyphPtr glyph, int format)
+{
+    CheckDuplicates (&globalGlyphs[format], "FreeGlyph");
+    if (--glyph->refcnt == 0)
+    {
+	GlyphRefPtr gr;
+	int	    i;
+	int	    first;
+
+	first = -1;
+	for (i = 0; i < globalGlyphs[format].hashSet->size; i++)
+	    if (globalGlyphs[format].table[i].glyph == glyph)
+	    {
+		if (first != -1)
+		    DuplicateRef (glyph, "FreeGlyph check");
+		first = i;
+	    }
+
+	gr = FindGlyphRef (&globalGlyphs[format],
+			   HashGlyph (glyph), TRUE, glyph);
+	if (gr - globalGlyphs[format].table != first)
+	    DuplicateRef (glyph, "Found wrong one");
+	if (gr->glyph && gr->glyph != DeletedGlyph)
+	{
+	    gr->glyph = DeletedGlyph;
+	    gr->signature = 0;
+	    globalGlyphs[format].tableEntries--;
+	}
+	xfree (glyph);
+    }
+}
+
+void
+AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
+{
+    GlyphRefPtr	    gr;
+    CARD32	    hash;
+
+    CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph top global");
+    /* Locate existing matching glyph */
+    hash = HashGlyph (glyph);
+    gr = FindGlyphRef (&globalGlyphs[glyphSet->fdepth], hash, TRUE, glyph);
+    if (gr->glyph && gr->glyph != DeletedGlyph)
+    {
+	xfree (glyph);
+	glyph = gr->glyph;
+    }
+    else
+    {
+	gr->glyph = glyph;
+	gr->signature = hash;
+	globalGlyphs[glyphSet->fdepth].tableEntries++;
+    }
+    
+    /* Insert/replace glyphset value */
+    gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0);
+    ++glyph->refcnt;
+    if (gr->glyph && gr->glyph != DeletedGlyph)
+	FreeGlyph (gr->glyph, glyphSet->fdepth);
+    else
+	glyphSet->hash.tableEntries++;
+    gr->glyph = glyph;
+    gr->signature = id;
+    CheckDuplicates (&globalGlyphs[glyphSet->fdepth], "AddGlyph bottom");
+}
+
+Bool
+DeleteGlyph (GlyphSetPtr glyphSet, Glyph id)
+{
+    GlyphRefPtr     gr;
+    GlyphPtr	    glyph;
+
+    gr = FindGlyphRef (&glyphSet->hash, id, FALSE, 0);
+    glyph = gr->glyph;
+    if (glyph && glyph != DeletedGlyph)
+    {
+	gr->glyph = DeletedGlyph;
+	glyphSet->hash.tableEntries--;
+	FreeGlyph (glyph, glyphSet->fdepth);
+	return TRUE;
+    }
+    return FALSE;
+}
+
+GlyphPtr
+FindGlyph (GlyphSetPtr glyphSet, Glyph id)
+{
+    GlyphPtr        glyph;
+
+    glyph = FindGlyphRef (&glyphSet->hash, id, FALSE, 0)->glyph;
+    if (glyph == DeletedGlyph)
+	glyph = 0;
+    return glyph;
+}
+
+GlyphPtr
+AllocateGlyph (xGlyphInfo *gi, int fdepth)
+{
+    int		size;
+    GlyphPtr	glyph;
+
+    size = gi->height * PixmapBytePad (gi->width, glyphDepths[fdepth]);
+    glyph = (GlyphPtr) xalloc (size + sizeof (GlyphRec));
+    if (!glyph)
+	return 0;
+    glyph->refcnt = 0;
+    glyph->size = size + sizeof (xGlyphInfo);
+    glyph->info = *gi;
+    return glyph;
+}
+    
+Bool
+AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet)
+{
+    hash->table = (GlyphRefPtr) xalloc (hashSet->size * sizeof (GlyphRefRec));
+    if (!hash->table)
+	return FALSE;
+    memset (hash->table, 0, hashSet->size * sizeof (GlyphRefRec));
+    hash->hashSet = hashSet;
+    hash->tableEntries = 0;
+    return TRUE;
+}
+
+Bool
+ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global)
+{
+    CARD32	    tableEntries;
+    GlyphHashSetPtr hashSet;
+    GlyphHashRec    newHash;
+    GlyphRefPtr	    gr;
+    GlyphPtr	    glyph;
+    int		    i;
+    int		    oldSize;
+    CARD32	    s;
+
+    tableEntries = hash->tableEntries + change;
+    hashSet = FindGlyphHashSet (tableEntries);
+    if (hashSet == hash->hashSet)
+	return TRUE;
+    if (global)
+	CheckDuplicates (hash, "ResizeGlyphHash top");
+    if (!AllocateGlyphHash (&newHash, hashSet))
+	return FALSE;
+    oldSize = hash->hashSet->size;
+    for (i = 0; i < oldSize; i++)
+    {
+	glyph = hash->table[i].glyph;
+	if (glyph && glyph != DeletedGlyph)
+	{
+	    s = hash->table[i].signature;
+	    gr = FindGlyphRef (&newHash, s, global, glyph);
+	    gr->signature = s;
+	    gr->glyph = glyph;
+	    ++newHash.tableEntries;
+	}
+    }
+    xfree (hash->table);
+    *hash = newHash;
+    if (global)
+	CheckDuplicates (hash, "ResizeGlyphHash bottom");
+    return TRUE;
+}
+
+Bool
+ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change)
+{
+    return (ResizeGlyphHash (&glyphSet->hash, change, FALSE) &&
+	    ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], change, TRUE));
+}
+			    
+GlyphSetPtr
+AllocateGlyphSet (int fdepth, PictFormatPtr format)
+{
+    GlyphSetPtr	glyphSet;
+    
+    if (!globalGlyphs[fdepth].hashSet)
+    {
+	if (!AllocateGlyphHash (&globalGlyphs[fdepth], &glyphHashSets[0]))
+	    return FALSE;
+    }
+    glyphSet = xalloc (sizeof (GlyphSetRec));
+    if (!glyphSet)
+	return FALSE;
+    if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
+    {
+	xfree (glyphSet);
+	return FALSE;
+    }
+    glyphSet->refcnt = 1;
+    glyphSet->fdepth = fdepth;
+    glyphSet->format = format;
+    return glyphSet;	
+}
+
+int
+FreeGlyphSet (pointer	value,
+	      XID       gid)
+{
+    GlyphSetPtr	glyphSet = (GlyphSetPtr) value;
+    
+    if (--glyphSet->refcnt == 0)
+    {
+	CARD32	    i, tableSize = glyphSet->hash.hashSet->size;
+	GlyphRefPtr table = glyphSet->hash.table;
+	GlyphPtr    glyph;
+    
+	for (i = 0; i < tableSize; i++)
+	{
+	    glyph = table[i].glyph;
+	    if (glyph && glyph != DeletedGlyph)
+		FreeGlyph (glyph, glyphSet->fdepth);
+	}
+	if (!globalGlyphs[glyphSet->fdepth].tableEntries)
+	{
+	    xfree (globalGlyphs[glyphSet->fdepth].table);
+	    globalGlyphs[glyphSet->fdepth].table = 0;
+	    globalGlyphs[glyphSet->fdepth].hashSet = 0;
+	}
+	else
+	    ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
+	xfree (table);
+	xfree (glyphSet);
+    }
+    return Success;
+}
Index: xc/programs/Xserver/render/glyphstr.h
diff -u /dev/null xc/programs/Xserver/render/glyphstr.h:1.3
--- /dev/null	Mon Dec 18 14:33:29 2000
+++ xc/programs/Xserver/render/glyphstr.h	Mon Nov 20 02:13:13 2000
@@ -0,0 +1,125 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/glyphstr.h,v 1.3 2000/11/20 07:13:13 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _GLYPHSTR_H_
+#define _GLYPHSTR_H_
+
+#include "renderproto.h"
+
+#define GlyphFormat1	0
+#define GlyphFormat4	1
+#define GlyphFormat8	2
+#define GlyphFormat16	3
+#define GlyphFormat32	4
+#define GlyphFormatNum	5
+
+typedef struct _Glyph {
+    CARD32	refcnt;
+    CARD32	size;	/* info + bitmap */
+    xGlyphInfo	info;
+    /* bits follow */
+} GlyphRec, *GlyphPtr;
+
+typedef struct _GlyphRef {
+    CARD32	signature;
+    GlyphPtr	glyph;
+} GlyphRefRec, *GlyphRefPtr;
+
+#define DeletedGlyph	((GlyphPtr) 1)
+
+typedef struct _GlyphHashSet {
+    CARD32	entries;
+    CARD32	size;
+    CARD32	rehash;
+} GlyphHashSetRec, *GlyphHashSetPtr;
+
+typedef struct _GlyphHash {
+    GlyphRefPtr	    table;
+    GlyphHashSetPtr hashSet;
+    CARD32	    tableEntries;
+} GlyphHashRec, *GlyphHashPtr;
+
+typedef struct _GlyphSet {
+    CARD32	    refcnt;
+    PictFormatPtr   format;
+    int		    fdepth;
+    GlyphHashRec    hash;
+} GlyphSetRec, *GlyphSetPtr;
+
+typedef struct _GlyphList {
+    INT16	    xOff;
+    INT16	    yOff;
+    CARD8	    len;
+    PictFormatPtr   format;
+} GlyphListRec, *GlyphListPtr;
+
+extern GlyphHashRec	globalGlyphs[GlyphFormatNum];
+
+GlyphHashSetPtr
+FindGlyphHashSet (CARD32 filled);
+
+Bool
+GlyphInit (ScreenPtr pScreen);
+
+GlyphRefPtr
+FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare);
+
+CARD32
+HashGlyph (GlyphPtr glyph);
+
+void
+FreeGlyph (GlyphPtr glyph, int format);
+
+void
+AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id);
+
+Bool
+DeleteGlyph (GlyphSetPtr glyphSet, Glyph id);
+
+GlyphPtr
+FindGlyph (GlyphSetPtr glyphSet, Glyph id);
+
+GlyphPtr
+AllocateGlyph (xGlyphInfo *gi, int format);
+
+Bool
+AllocateGlyphHash (GlyphHashPtr hash, GlyphHashSetPtr hashSet);
+
+Bool
+ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global);
+
+Bool
+ResizeGlyphSet (GlyphSetPtr glyphSet, CARD32 change);
+
+GlyphSetPtr
+AllocateGlyphSet (int fdepth, PictFormatPtr format);
+
+int
+FreeGlyphSet (pointer   value,
+	      XID       gid);
+
+
+
+#endif /* _GLYPHSTR_H_ */
Index: xc/programs/Xserver/render/miglyph.c
diff -u /dev/null xc/programs/Xserver/render/miglyph.c:1.6
--- /dev/null	Mon Dec 18 14:33:29 2000
+++ xc/programs/Xserver/render/miglyph.c	Mon Dec  4 22:13:31 2000
@@ -0,0 +1,239 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/miglyph.c,v 1.6 2000/12/05 03:13:31 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+
+void
+miGlyphExtents (int		nlist,
+		GlyphListPtr	list,
+		GlyphPtr	*glyphs,
+		BoxPtr		extents)
+{
+    int		x1, x2, y1, y2;
+    int		n;
+    GlyphPtr	glyph;
+    int		x, y;
+    
+    x = 0;
+    y = 0;
+    extents->x1 = MAXSHORT;
+    extents->x2 = MINSHORT;
+    extents->y1 = MAXSHORT;
+    extents->y2 = MINSHORT;
+    while (nlist--)
+    {
+	x += list->xOff;
+	y += list->yOff;
+	n = list->len;
+	list++;
+	while (n--)
+	{
+	    glyph = *glyphs++;
+	    x1 = x - glyph->info.x;
+	    if (x1 < MINSHORT)
+		x1 = MINSHORT;
+	    y1 = y - glyph->info.y;
+	    if (y1 < MINSHORT)
+		y1 = MINSHORT;
+	    x2 = x1 + glyph->info.width;
+	    if (x2 > MAXSHORT)
+		x2 = MAXSHORT;
+	    y2 = y1 + glyph->info.height;
+	    if (y2 > MAXSHORT)
+		y2 = MAXSHORT;
+	    if (x1 < extents->x1)
+		extents->x1 = x1;
+	    if (x2 > extents->x2)
+		extents->x2 = x2;
+	    if (y1 < extents->y1)
+		extents->y1 = y1;
+	    if (y2 > extents->y2)
+		extents->y2 = y2;
+	    x += glyph->info.xOff;
+	    y += glyph->info.yOff;
+	}
+    }
+}
+
+#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
+
+void
+miGlyphs (CARD8		op,
+	  PicturePtr	pSrc,
+	  PicturePtr	pDst,
+	  PictFormatPtr	maskFormat,
+	  INT16		xSrc,
+	  INT16		ySrc,
+	  int		nlist,
+	  GlyphListPtr	list,
+	  GlyphPtr	*glyphs)
+{
+    PixmapPtr	pPixmap = 0;
+    PicturePtr	pPicture;
+    PixmapPtr   pMaskPixmap = 0;
+    PicturePtr  pMask;
+    ScreenPtr   pScreen = pDst->pDrawable->pScreen;
+    int		width = 0, height = 0;
+    int		x, y;
+    int		xDst = list->xOff, yDst = list->yOff;
+    int		n;
+    GlyphPtr	glyph;
+    int		error;
+    BoxRec	extents;
+    CARD32	component_alpha;
+    
+    if (maskFormat)
+    {
+	GCPtr	    pGC;
+	xRectangle  rect;
+	
+	miGlyphExtents (nlist, list, glyphs, &extents);
+	
+	if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
+	    return;
+	width = extents.x2 - extents.x1;
+	height = extents.y2 - extents.y1;
+	pMaskPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, maskFormat->depth);
+	if (!pMaskPixmap)
+	    return;
+	component_alpha = NeedsComponent(maskFormat->format);
+	pMask = CreatePicture (0, &pMaskPixmap->drawable,
+			       maskFormat, CPComponentAlpha, &component_alpha,
+			       serverClient, &error);
+	if (!pMask)
+	{
+	    (*pScreen->DestroyPixmap) (pMaskPixmap);
+	    return;
+	}
+	pGC = GetScratchGC (pMaskPixmap->drawable.depth, pScreen);
+	ValidateGC (&pMaskPixmap->drawable, pGC);
+	rect.x = 0;
+	rect.y = 0;
+	rect.width = width;
+	rect.height = height;
+	(*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect);
+	FreeScratchGC (pGC);
+	x = -extents.x1;
+	y = -extents.y1;
+    }
+    else
+    {
+	pMask = pDst;
+	x = 0;
+	y = 0;
+    }
+    pPicture = 0;
+    while (nlist--)
+    {
+	x += list->xOff;
+	y += list->yOff;
+	n = list->len;
+	while (n--)
+	{
+	    glyph = *glyphs++;
+	    if (!pPicture)
+	    {
+		pPixmap = GetScratchPixmapHeader (pScreen, glyph->info.width, glyph->info.height, 
+						  list->format->depth,
+						  list->format->depth, 
+						  0, (pointer) (glyph + 1));
+		if (!pPixmap)
+		    return;
+		component_alpha = NeedsComponent(list->format->format);
+		pPicture = CreatePicture (0, &pPixmap->drawable, list->format,
+					  CPComponentAlpha, &component_alpha, 
+					  serverClient, &error);
+		if (!pPicture)
+		{
+		    FreeScratchPixmapHeader (pPixmap);
+		    return;
+		}
+	    }
+	    (*pScreen->ModifyPixmapHeader) (pPixmap, 
+					    glyph->info.width, glyph->info.height,
+					    0, 0, -1, (pointer) (glyph + 1));
+	    pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+	    if (maskFormat)
+	    {
+		CompositePicture (PictOpAdd,
+				  pPicture,
+				  None,
+				  pMask,
+				  0, 0,
+				  0, 0,
+				  x - glyph->info.x,
+				  y - glyph->info.y,
+				  glyph->info.width,
+				  glyph->info.height);
+	    }
+	    else
+	    {
+		CompositePicture (op,
+				  pSrc,
+				  pPicture,
+				  pDst,
+				  xSrc + (x - glyph->info.x) - xDst,
+				  ySrc + (y - glyph->info.y) - yDst,
+				  0, 0,
+				  x - glyph->info.x,
+				  y - glyph->info.y,
+				  glyph->info.width,
+				  glyph->info.height);
+	    }
+	    x += glyph->info.xOff;
+	    y += glyph->info.yOff;
+	}
+	list++;
+	if (pPicture)
+	{
+	    FreeScratchPixmapHeader (pPixmap);
+	    FreePicture ((pointer) pPicture, 0);
+	    pPicture = 0;
+	    pPixmap = 0;
+	}
+    }
+    if (maskFormat)
+    {
+	x = extents.x1;
+	y = extents.y1;
+	CompositePicture (op,
+			  pSrc,
+			  pMask,
+			  pDst,
+			  xSrc + x - xDst,
+			  ySrc + y - yDst,
+			  0, 0,
+			  x, y,
+			  width, height);
+	FreePicture ((pointer) pMask, (XID) 0);
+	(*pScreen->DestroyPixmap) (pMaskPixmap);
+    }
+}
Index: xc/programs/Xserver/render/mipict.c
diff -u /dev/null xc/programs/Xserver/render/mipict.c:1.5
--- /dev/null	Mon Dec 18 14:33:29 2000
+++ xc/programs/Xserver/render/mipict.c	Thu Dec  7 01:11:30 2000
@@ -0,0 +1,423 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/mipict.c,v 1.5 2000/12/07 06:11:30 keithp Exp $
+ *
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+
+int
+miCreatePicture (PicturePtr pPicture)
+{
+    return Success;
+}
+
+void
+miDestroyPicture (PicturePtr pPicture)
+{
+    if (pPicture->freeCompClip)
+	REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->pCompositeClip);
+}
+
+void
+miDestroyPictureClip (PicturePtr pPicture)
+{
+    switch (pPicture->clientClipType) {
+    case CT_NONE:
+	return;
+    case CT_PIXMAP:
+	(*pPicture->pDrawable->pScreen->DestroyPixmap) ((PixmapPtr) (pPicture->clientClip));
+	break;
+    default:
+	/*
+	 * we know we'll never have a list of rectangles, since ChangeClip
+	 * immediately turns them into a region
+	 */
+	REGION_DESTROY(pPicture->pDrawable->pScreen, pPicture->clientClip);
+	break;
+    }
+    pPicture->clientClip = NULL;
+    pPicture->clientClipType = CT_NONE;
+}    
+
+int
+miChangePictureClip (PicturePtr    pPicture,
+		     int	   type,
+		     pointer	   value,
+		     int	   n)
+{
+    ScreenPtr		pScreen = pPicture->pDrawable->pScreen;
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+    pointer		clientClip;
+    int			clientClipType;
+    
+    switch (type) {
+    case CT_PIXMAP:
+	/* convert the pixmap to a region */
+	clientClip = (pointer) BITMAP_TO_REGION(pScreen, (PixmapPtr) value);
+	if (!clientClip)
+	    return BadAlloc;
+	clientClipType = CT_REGION;
+	(*pScreen->DestroyPixmap) ((PixmapPtr) value);
+	break;
+    case CT_REGION:
+	clientClip = value;
+	clientClipType = CT_REGION;
+	break;
+    case CT_NONE:
+	clientClip = 0;
+	clientClipType = CT_NONE;
+	break;
+    default:
+	clientClip = (pointer) RECTS_TO_REGION(pScreen, n,
+					       (xRectangle *) value,
+					       type);
+	if (!clientClip)
+	    return BadAlloc;
+	clientClipType = CT_REGION;
+	xfree(value);
+	break;
+    }
+    (*ps->DestroyPictureClip) (pPicture);
+    pPicture->clientClip = clientClip;
+    pPicture->clientClipType = clientClipType;
+    pPicture->stateChanges |= CPClipMask;
+    return Success;
+}
+
+void
+miChangePicture (PicturePtr pPicture,
+		 Mask       mask)
+{
+    return;
+}
+
+void
+miValidatePicture (PicturePtr pPicture,
+		   Mask       mask)
+{
+    DrawablePtr	    pDrawable = pPicture->pDrawable;
+
+    if ((mask & (CPClipXOrigin|CPClipYOrigin|CPClipMask|CPSubwindowMode)) ||
+	(pDrawable->serialNumber != (pPicture->serialNumber & DRAWABLE_SERIAL_BITS)))
+    {
+	if (pDrawable->type == DRAWABLE_WINDOW)
+	{
+	    WindowPtr       pWin = (WindowPtr) pDrawable;
+	    RegionPtr       pregWin;
+	    Bool            freeTmpClip, freeCompClip;
+
+	    if (pPicture->subWindowMode == IncludeInferiors)
+	    {
+		pregWin = NotClippedByChildren(pWin);
+		freeTmpClip = TRUE;
+	    }
+	    else
+	    {
+		pregWin = &pWin->clipList;
+		freeTmpClip = FALSE;
+	    }
+	    freeCompClip = pPicture->freeCompClip;
+
+	    /*
+	     * if there is no client clip, we can get by with just keeping the
+	     * pointer we got, and remembering whether or not should destroy
+	     * (or maybe re-use) it later.  this way, we avoid unnecessary
+	     * copying of regions.  (this wins especially if many clients clip
+	     * by children and have no client clip.)
+	     */
+	    if (pPicture->clientClipType == CT_NONE)
+	    {
+		if (freeCompClip)
+		    REGION_DESTROY(pScreen, pPicture->pCompositeClip);
+		pPicture->pCompositeClip = pregWin;
+		pPicture->freeCompClip = freeTmpClip;
+	    }
+	    else
+	    {
+		/*
+		 * we need one 'real' region to put into the composite clip. if
+		 * pregWin the current composite clip are real, we can get rid of
+		 * one. if pregWin is real and the current composite clip isn't,
+		 * use pregWin for the composite clip. if the current composite
+		 * clip is real and pregWin isn't, use the current composite
+		 * clip. if neither is real, create a new region.
+		 */
+
+		REGION_TRANSLATE(pScreen, pPicture->clientClip,
+				 pDrawable->x + pPicture->clipOrigin.x,
+				 pDrawable->y + pPicture->clipOrigin.y);
+
+		if (freeCompClip)
+		{
+		    REGION_INTERSECT(pPicture->pScreen, pPicture->pCompositeClip,
+				     pregWin, pPicture->clientClip);
+		    if (freeTmpClip)
+			REGION_DESTROY(pScreen, pregWin);
+		}
+		else if (freeTmpClip)
+		{
+		    REGION_INTERSECT(pScreen, pregWin, pregWin, pPicture->clientClip);
+		    pPicture->pCompositeClip = pregWin;
+		}
+		else
+		{
+		    pPicture->pCompositeClip = REGION_CREATE(pScreen, NullBox, 0);
+		    REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+				     pregWin, pPicture->clientClip);
+		}
+		pPicture->freeCompClip = TRUE;
+		REGION_TRANSLATE(pScreen, pPicture->clientClip,
+				 -(pDrawable->x + pPicture->clipOrigin.x),
+				 -(pDrawable->y + pPicture->clipOrigin.y));
+	    }
+	}	/* end of composite clip for a window */
+	else
+	{
+	    BoxRec          pixbounds;
+
+	    /* XXX should we translate by drawable.x/y here ? */
+	    /* If you want pixmaps in offscreen memory, yes */
+	    pixbounds.x1 = pDrawable->x;
+	    pixbounds.y1 = pDrawable->y;
+	    pixbounds.x2 = pDrawable->x + pDrawable->width;
+	    pixbounds.y2 = pDrawable->y + pDrawable->height;
+
+	    if (pPicture->freeCompClip)
+	    {
+		REGION_RESET(pScreen, pPicture->pCompositeClip, &pixbounds);
+	    }
+	    else
+	    {
+		pPicture->freeCompClip = TRUE;
+		pPicture->pCompositeClip = REGION_CREATE(pScreen, &pixbounds, 1);
+	    }
+
+	    if (pPicture->clientClipType == CT_REGION)
+	    {
+		if(pDrawable->x || pDrawable->y) {
+		    REGION_TRANSLATE(pScreen, pPicture->clientClip,
+				     pDrawable->x + pPicture->clipOrigin.x, 
+				     pDrawable->y + pPicture->clipOrigin.y);
+		    REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+				     pPicture->pCompositeClip, pPicture->clientClip);
+		    REGION_TRANSLATE(pScreen, pPicture->clientClip,
+				     -(pDrawable->x + pPicture->clipOrigin.x), 
+				     -(pDrawable->y + pPicture->clipOrigin.y));
+		} else {
+		    REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+				     -pPicture->clipOrigin.x, -pPicture->clipOrigin.y);
+		    REGION_INTERSECT(pScreen, pPicture->pCompositeClip,
+				     pPicture->pCompositeClip, pPicture->clientClip);
+		    REGION_TRANSLATE(pScreen, pPicture->pCompositeClip,
+				     pPicture->clipOrigin.x, pPicture->clipOrigin.y);
+		}
+	    }
+	}	/* end of composite clip for pixmap */
+    }
+}
+
+#define BOUND(v)	(INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v))
+
+static void
+miInitBox (BoxPtr   pBox,
+	   INT16    x,
+	   INT16    y,
+	   CARD16   w, 
+	   CARD16   h)
+{
+    int	    x1, y1, x2, y2;
+
+    x1 = x;
+    y1 = y;
+    x2 = x1 + (int) w;
+    y2 = y1 + (int) h;
+    pBox->x1 = BOUND(x1);
+    pBox->y1 = BOUND(y1);
+    pBox->x2 = BOUND(x2);
+    pBox->y2 = BOUND(y2);
+}
+
+Bool
+miClipPicture (RegionPtr    pRegion,
+	       PicturePtr   pPicture,
+	       INT16	    xReg,
+	       INT16	    yReg,
+	       INT16	    xPict,
+	       INT16	    yPict)
+{
+    if (pPicture->repeat)
+    {
+	if (pPicture->clientClipType != CT_NONE)
+	{
+	    REGION_TRANSLATE(pScreen, pRegion, 
+			     xPict - xReg - pPicture->clipOrigin.x,
+			     yPict - yReg - pPicture->clipOrigin.y);
+	    if (!REGION_INTERSECT (pScreen, pRegion, pRegion, 
+				   (RegionPtr) pPicture->clientClip))
+		return FALSE;
+	    REGION_TRANSLATE(pScreen, pRegion, 
+			     - (xPict - xReg - pPicture->clipOrigin.x),
+			     - (yPict - yReg - pPicture->clipOrigin.y));
+	}
+    }
+    else
+    {
+	REGION_TRANSLATE(pScreen, pRegion, 
+			 xPict - xReg,
+			 yPict - yReg);
+	if (!REGION_INTERSECT (pScreen, pRegion, pRegion,
+			       pPicture->pCompositeClip))
+	    return FALSE;
+	REGION_TRANSLATE(pScreen, pRegion,
+			 -(xPict - xReg),
+			 -(yPict - yReg));
+    }
+    return TRUE;
+}
+
+Bool
+miComputeCompositeRegion (RegionPtr	pRegion,
+			  PicturePtr	pSrc,
+			  PicturePtr	pMask,
+			  PicturePtr	pDst,
+			  INT16		xSrc,
+			  INT16		ySrc,
+			  INT16		xMask,
+			  INT16		yMask,
+			  INT16		xDst,
+			  INT16		yDst,
+			  CARD16	width,
+			  CARD16	height)
+{
+    BoxRec	dstBox;
+    RegionPtr	pDstClip = pDst->pCompositeClip;
+
+    miInitBox (&dstBox, xDst, yDst, width, height);
+    REGION_INIT (pScreen, pRegion, &dstBox, 1);
+    if (!REGION_INTERSECT (pScreen, pRegion, pRegion, pDstClip))
+    {
+	REGION_UNINIT (pScreen, pRegion);
+	return FALSE;
+    }
+    /* clip against src */
+    if (!miClipPicture (pRegion, pSrc, xDst, yDst, xSrc, ySrc))
+    {
+	REGION_UNINIT (pScreen, pRegion);
+	return FALSE;
+    }
+    /* clip against mask */
+    if (pMask)
+    {
+	if (!miClipPicture (pRegion, pMask, xDst, yDst, xMask, yMask))
+	{
+	    REGION_UNINIT (pScreen, pRegion);
+	    return FALSE;
+	}	
+    }
+    return TRUE;
+}
+
+void
+miRenderColorToPixel (PictFormatPtr format,
+		      xRenderColor  *color,
+		      CARD32	    *pixel)
+{
+    CARD32  r, g, b, a;
+    
+    switch (format->type) {
+    case PictTypeDirect:
+	r = color->red >> (16 - Ones (format->direct.redMask));
+	g = color->green >> (16 - Ones (format->direct.greenMask));
+	b = color->blue >> (16 - Ones (format->direct.blueMask));
+	a = color->alpha >> (16 - Ones (format->direct.alphaMask));
+	r = r << format->direct.red;
+	g = g << format->direct.green;
+	b = b << format->direct.blue;
+	a = a << format->direct.alpha;
+	*pixel = r|g|b|a;
+	break;
+    case PictTypeIndexed:
+	*pixel = 0;
+	break;
+    }
+}
+
+static CARD16
+miFillColor (CARD32 pixel, int bits)
+{
+    while (bits < 16)
+    {
+	pixel |= pixel << bits;
+	bits <<= 1;
+    }
+    return (CARD16) pixel;
+}
+
+void
+miRenderPixelToColor (PictFormatPtr format,
+		      CARD32	    pixel,
+		      xRenderColor  *color)
+{
+    CARD32  r, g, b, a;
+    
+    switch (format->type) {
+    case PictTypeDirect:
+	r = (pixel >> format->direct.red) & format->direct.redMask;
+	g = (pixel >> format->direct.green) & format->direct.greenMask;
+	b = (pixel >> format->direct.blue) & format->direct.blueMask;
+	a = (pixel >> format->direct.alpha) & format->direct.alphaMask;
+	color->red = miFillColor (r, Ones (format->direct.redMask));
+	color->green = miFillColor (r, Ones (format->direct.greenMask));
+	color->blue = miFillColor (r, Ones (format->direct.blueMask));
+	color->alpha = miFillColor (r, Ones (format->direct.alphaMask));
+	break;
+    case PictTypeIndexed:
+	color->red = 0;
+	color->green = 0;
+	color->blue = 0;
+	color->alpha = 0;
+	break;
+    }
+}
+
+Bool
+miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+    PictureScreenPtr    ps;
+    
+    if (!PictureInit (pScreen, formats, nformats))
+	return FALSE;
+    ps = GetPictureScreen(pScreen);
+    ps->CreatePicture = miCreatePicture;
+    ps->DestroyPicture = miDestroyPicture;
+    ps->ChangePictureClip = miChangePictureClip;
+    ps->DestroyPictureClip = miDestroyPictureClip;
+    ps->ChangePicture = miChangePicture;
+    ps->ValidatePicture = miValidatePicture;
+    return TRUE;
+}
Index: xc/programs/Xserver/render/mipict.h
diff -u /dev/null xc/programs/Xserver/render/mipict.h:1.4
--- /dev/null	Mon Dec 18 14:33:30 2000
+++ xc/programs/Xserver/render/mipict.h	Mon Dec  4 22:13:32 2000
@@ -0,0 +1,112 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/mipict.h,v 1.4 2000/12/05 03:13:32 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _MIPICT_H_
+#define _MIPICT_H_
+
+int
+miCreatePicture (PicturePtr pPicture);
+
+void
+miDestroyPicture (PicturePtr pPicture);
+
+void
+miDestroyPictureClip (PicturePtr pPicture);
+
+int
+miChangePictureClip (PicturePtr    pPicture,
+		     int	   type,
+		     pointer	   value,
+		     int	   n);
+
+void
+miChangePicture (PicturePtr pPicture,
+		 Mask       mask);
+
+void
+miValidatePicture (PicturePtr pPicture,
+		   Mask       mask);
+
+
+Bool
+miClipPicture (RegionPtr    pRegion,
+	       PicturePtr   pPicture,
+	       INT16	    xReg,
+	       INT16	    yReg,
+	       INT16	    xPict,
+	       INT16	    yPict);
+
+Bool
+miComputeCompositeRegion (RegionPtr	pRegion,
+			  PicturePtr	pSrc,
+			  PicturePtr	pMask,
+			  PicturePtr	pDst,
+			  INT16		xSrc,
+			  INT16		ySrc,
+			  INT16		xMask,
+			  INT16		yMask,
+			  INT16		xDst,
+			  INT16		yDst,
+			  CARD16	width,
+			  CARD16	height);
+
+Bool
+miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+
+void
+miGlyphExtents (int		nlist,
+		GlyphListPtr	list,
+		GlyphPtr	*glyphs,
+		BoxPtr		extents);
+
+void
+miGlyphs (CARD8		op,
+	  PicturePtr	pSrc,
+	  PicturePtr	pDst,
+	  PictFormatPtr	maskFormat,
+	  INT16		xSrc,
+	  INT16		ySrc,
+	  int		nlist,
+	  GlyphListPtr	list,
+	  GlyphPtr	*glyphs);
+
+void
+miRenderColorToPixel (PictFormatPtr pPict,
+		      xRenderColor  *color,
+		      CARD32	    *pixel);
+
+void
+miRenderPixelToColor (PictFormatPtr pPict,
+		      CARD32	    pixel,
+		      xRenderColor  *color);
+
+void
+miCompositeRects (CARD8		op,
+		  PicturePtr	pDst,
+		  xRenderColor  *color,
+		  int		nRect,
+		  xRectangle    *rects);
+
+#endif /* _MIPICT_H_ */
Index: xc/programs/Xserver/render/mirect.c
diff -u /dev/null xc/programs/Xserver/render/mirect.c:1.3
--- /dev/null	Mon Dec 18 14:33:30 2000
+++ xc/programs/Xserver/render/mirect.c	Fri Dec  8 02:52:05 2000
@@ -0,0 +1,141 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/mirect.c,v 1.3 2000/12/08 07:52:05 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "scrnintstr.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "mi.h"
+#include "picturestr.h"
+#include "mipict.h"
+
+void
+miCompositeRects (CARD8		op,
+		  PicturePtr	pDst,
+		  xRenderColor  *color,
+		  int		nRect,
+		  xRectangle    *rects)
+{
+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
+    CARD32		pixel;
+    GCPtr		pGC;
+    CARD32		tmpval[4];
+    unsigned long	mask;
+    int			error;
+    RegionPtr		pClip;
+    
+    if (color->alpha == 0xffff)
+    {
+	if (op == PictOpOver)
+	    op = PictOpSrc;
+    }
+    if (op == PictOpClear)
+	color->red = color->green = color->blue = color->alpha = 0;
+    
+    if (op == PictOpSrc || op == PictOpClear)
+    {
+	miRenderColorToPixel (pDst->pFormat, color, &pixel);
+
+	pGC = GetScratchGC (pDst->pDrawable->depth, pScreen);
+	if (!pGC)
+	    return;
+	tmpval[0] = GXcopy;
+	tmpval[1] = pixel;
+	mask = GCFunction | GCForeground;
+	if (pDst->clientClipType == CT_REGION)
+	{
+	    tmpval[2] = pDst->clipOrigin.x;
+	    tmpval[3] = pDst->clipOrigin.y;
+	    mask |= CPClipXOrigin|CPClipYOrigin;
+	    
+	    pClip = REGION_CREATE (pScreen, NULL, 1);
+	    REGION_COPY (pScreen, pClip,
+			 (RegionPtr) pDst->clientClip);
+	    (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0);
+	}
+
+	ChangeGC (pGC, mask, tmpval);
+	ValidateGC (pDst->pDrawable, pGC);
+	(*pGC->ops->PolyFillRect) (pDst->pDrawable, pGC, nRect, rects);
+	FreeScratchGC (pGC);
+    }
+    else
+    {
+	PictFormatPtr	rgbaFormat;
+	PixmapPtr	pPixmap;
+	PicturePtr	pSrc;
+	xRectangle	one;
+
+	rgbaFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
+	if (!rgbaFormat)
+	    goto bail1;
+	
+	pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1,
+					    rgbaFormat->depth);
+	if (!pPixmap)
+	    goto bail2;
+	
+	miRenderColorToPixel (rgbaFormat, color, &pixel);
+
+	pGC = GetScratchGC (rgbaFormat->depth, pScreen);
+	if (!pGC)
+	    goto bail3;
+	tmpval[0] = GXcopy;
+	tmpval[1] = pixel;
+
+	ChangeGC (pGC, GCFunction | GCForeground, tmpval);
+	ValidateGC (&pPixmap->drawable, pGC);
+	one.x = 0;
+	one.y = 0;
+	one.width = 1;
+	one.height = 1;
+	(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
+	
+	tmpval[0] = xTrue;
+	pSrc = CreatePicture (0, &pPixmap->drawable, rgbaFormat,
+			      CPRepeat, tmpval, 0, &error);
+			      
+	if (!pSrc)
+	    goto bail4;
+
+	while (nRect--)
+	{
+	    CompositePicture (op, pSrc, 0, pDst, 0, 0, 0, 0, 
+			      rects->x,
+			      rects->y,
+			      rects->width,
+			      rects->height);
+	    rects++;
+	}
+
+	FreePicture ((pointer) pSrc, 0);
+bail4:
+	FreeScratchGC (pGC);
+bail3:
+	(*pScreen->DestroyPixmap) (pPixmap);
+bail2:
+bail1:
+	;
+    }
+}
Index: xc/programs/Xserver/render/picture.c
diff -u /dev/null xc/programs/Xserver/render/picture.c:1.12
--- /dev/null	Mon Dec 18 14:33:30 2000
+++ xc/programs/Xserver/render/picture.c	Thu Dec  7 18:54:04 2000
@@ -0,0 +1,840 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/picture.c,v 1.12 2000/12/07 23:54:04 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#include "misc.h"
+#include "scrnintstr.h"
+#include "os.h"
+#include "regionstr.h"
+#include "validate.h"
+#include "windowstr.h"
+#include "input.h"
+#include "resource.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "dixstruct.h"
+#include "gcstruct.h"
+#include "servermd.h"
+#include "picturestr.h"
+
+int		PictureScreenPrivateIndex = -1;
+int		PictureWindowPrivateIndex;
+int		PictureGeneration;
+RESTYPE		PictureType;
+RESTYPE		PictFormatType;
+RESTYPE		GlyphSetType;
+
+Bool
+PictureDestroyWindow (WindowPtr pWindow)
+{
+    ScreenPtr		pScreen = pWindow->drawable.pScreen;
+    PicturePtr		pPicture;
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+    Bool		ret;
+
+    while ((pPicture = GetPictureWindow(pWindow)))
+    {
+	SetPictureWindow(pWindow, pPicture->pNext);
+	FreeResource (pPicture->id, PictureType);
+	FreePicture ((pointer) pPicture, pPicture->id);
+    }
+    pScreen->DestroyWindow = ps->DestroyWindow;
+    ret = (*pScreen->DestroyWindow) (pWindow);
+    ps->DestroyWindow = pScreen->DestroyWindow;
+    pScreen->DestroyWindow = PictureDestroyWindow;
+    return ret;
+}
+
+Bool
+PictureCloseScreen (int index, ScreenPtr pScreen)
+{
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+    Bool                ret;
+
+    pScreen->CloseScreen = ps->CloseScreen;
+    ret = (*pScreen->CloseScreen) (index, pScreen);
+    SetPictureScreen(pScreen, 0);
+    xfree (ps->formats);
+    xfree (ps);
+    return ret;
+}
+
+PictFormatPtr
+PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp)
+{
+    int		    nformats;
+    PictFormatPtr   pFormats;
+    int		    i;
+
+    nformats = 7;
+    pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
+    if (!pFormats)
+	return 0;
+    i = 0;
+    pFormats[i].id = FakeClientID (0);
+    pFormats[i].type = PictTypeDirect;
+    pFormats[i].depth = 32;
+    pFormats[i].direct.red = 16;
+    pFormats[i].direct.redMask = 0xff;
+    pFormats[i].direct.green = 8;
+    pFormats[i].direct.greenMask = 0xff;
+    pFormats[i].direct.blue = 0;
+    pFormats[i].direct.blueMask = 0xff;
+    pFormats[i].direct.alpha = 24;
+    pFormats[i].direct.alphaMask = 0xff;
+    pFormats[i].pColormap = 0;
+    i++;
+    pFormats[i].id = FakeClientID (0);
+    pFormats[i].type = PictTypeDirect;
+    pFormats[i].depth = 8;
+    pFormats[i].direct.red = 0;
+    pFormats[i].direct.redMask = 0;
+    pFormats[i].direct.green = 0;
+    pFormats[i].direct.greenMask = 0;
+    pFormats[i].direct.blue = 0;
+    pFormats[i].direct.blueMask = 0;
+    pFormats[i].direct.alpha = 0;
+    pFormats[i].direct.alphaMask = 0xff;
+    pFormats[i].pColormap = 0;
+    i++;
+    pFormats[i].id = FakeClientID (0);
+    pFormats[i].type = PictTypeDirect;
+    pFormats[i].depth = 24;
+    pFormats[i].direct.red = 16;
+    pFormats[i].direct.redMask = 0xff;
+    pFormats[i].direct.green = 8;
+    pFormats[i].direct.greenMask = 0xff;
+    pFormats[i].direct.blue = 0;
+    pFormats[i].direct.blueMask = 0xff;
+    pFormats[i].direct.alpha = 0;
+    pFormats[i].direct.alphaMask = 0x0;
+    pFormats[i].pColormap = 0;
+    i++;
+    pFormats[i].id = FakeClientID (0);
+    pFormats[i].type = PictTypeDirect;
+    pFormats[i].depth = 16;
+    pFormats[i].direct.red = 11;
+    pFormats[i].direct.redMask = 0x1f;
+    pFormats[i].direct.green = 5;
+    pFormats[i].direct.greenMask = 0x3f;
+    pFormats[i].direct.blue = 0;
+    pFormats[i].direct.blueMask = 0x1f;
+    pFormats[i].direct.alpha = 0;
+    pFormats[i].direct.alphaMask = 0x0;
+    pFormats[i].pColormap = 0;
+    i++;
+    pFormats[i].id = FakeClientID (0);
+    pFormats[i].type = PictTypeDirect;
+    pFormats[i].depth = 15;
+    pFormats[i].direct.red = 10;
+    pFormats[i].direct.redMask = 0x1f;
+    pFormats[i].direct.green = 5;
+    pFormats[i].direct.greenMask = 0x1f;
+    pFormats[i].direct.blue = 0;
+    pFormats[i].direct.blueMask = 0x1f;
+    pFormats[i].direct.alpha = 0;
+    pFormats[i].direct.alphaMask = 0x0;
+    pFormats[i].pColormap = 0;
+    i++;
+    pFormats[i].id = FakeClientID (0);
+    pFormats[i].type = PictTypeDirect;
+    pFormats[i].depth = 16;
+    pFormats[i].direct.red = 10;
+    pFormats[i].direct.redMask = 0x1f;
+    pFormats[i].direct.green = 5;
+    pFormats[i].direct.greenMask = 0x1f;
+    pFormats[i].direct.blue = 0;
+    pFormats[i].direct.blueMask = 0x1f;
+    pFormats[i].direct.alpha = 15;
+    pFormats[i].direct.alphaMask = 0x1;
+    pFormats[i].pColormap = 0;
+    i++;
+    pFormats[i].id = FakeClientID (0);
+    pFormats[i].type = PictTypeDirect;
+    pFormats[i].depth = 1;
+    pFormats[i].direct.red = 0;
+    pFormats[i].direct.redMask = 0;
+    pFormats[i].direct.green = 0;
+    pFormats[i].direct.greenMask = 0;
+    pFormats[i].direct.blue = 0;
+    pFormats[i].direct.blueMask = 0;
+    pFormats[i].direct.alpha = 0;
+    pFormats[i].direct.alphaMask = 0x1;
+    pFormats[i].pColormap = 0;
+    i++;
+    *nformatp = i;
+    return pFormats;
+}
+
+PictFormatPtr
+PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual)
+{
+    PictureScreenPtr    ps = GetPictureScreenIfSet(pScreen);
+    PictFormatPtr	format;
+    int			nformat;
+    int			type;
+
+    if (!ps)
+	return 0;
+    format = ps->formats;
+    nformat = ps->nformats;
+    switch (pVisual->class) {
+    case StaticGray:
+    case GrayScale:
+    case StaticColor:
+    case PseudoColor:
+	type = PictTypeIndexed;
+	break;
+    case TrueColor:
+	type = PictTypeDirect;
+	break;
+    case DirectColor:
+    default:
+	return 0;
+    }
+    while (nformat--)
+    {
+	if (format->depth == depth && format->type == type)
+	{
+	    if (type == PictTypeIndexed)
+	    {
+		if (format->pColormap && format->pColormap->pVisual == pVisual)
+		    return format;
+	    }
+	    else
+	    {
+		if (format->direct.redMask << format->direct.red == 
+		    pVisual->redMask &&
+		    format->direct.greenMask << format->direct.green == 
+		    pVisual->greenMask &&
+		    format->direct.blueMask << format->direct.blue == 
+		    pVisual->blueMask)
+		{
+		    return format;
+		}
+	    }
+	}
+	format++;
+    }
+    return 0;
+}
+
+PictFormatPtr
+PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 f)
+{
+    PictureScreenPtr    ps = GetPictureScreenIfSet(pScreen);
+    PictFormatPtr	format;
+    int			nformat;
+
+    if (!ps)
+	return 0;
+    format = ps->formats;
+    nformat = ps->nformats;
+    while (nformat--)
+    {
+	if (format->depth == depth && format->format == (f & 0xffffff))
+	    return format;
+	format++;
+    }
+    return 0;
+}
+
+Bool
+PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
+{
+    PictureScreenPtr	ps;
+    int			n;
+    CARD32		type, a, r, g, b;
+    
+    if (PictureGeneration != serverGeneration)
+    {
+	PictureType = CreateNewResourceType (FreePicture);
+	if (!PictureType)
+	    return FALSE;
+	PictFormatType = CreateNewResourceType (FreePictFormat);
+	if (!PictFormatType)
+	    return FALSE;
+	GlyphSetType = CreateNewResourceType (FreeGlyphSet);
+	if (!GlyphSetType)
+	    return FALSE;
+	PictureScreenPrivateIndex = AllocateScreenPrivateIndex();
+	if (PictureScreenPrivateIndex < 0)
+	    return FALSE;
+	PictureWindowPrivateIndex = AllocateWindowPrivateIndex();
+	PictureGeneration = serverGeneration;
+    }
+    if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0))
+	return FALSE;
+    
+    if (!formats)
+    {
+	formats = PictureCreateDefaultFormats (pScreen, &nformats);
+	if (!formats)
+	    return FALSE;
+    }
+    for (n = 0; n < nformats; n++)
+    {
+	if (!AddResource (formats[n].id, PictFormatType, (pointer) (formats+n)))
+	{
+	    xfree (formats);
+	    return FALSE;
+	}
+	if (formats[n].type == PictTypeIndexed)
+	{
+	    type = PICT_TYPE_INDEX;
+	    a = r = g = b = 0;
+	}
+	else
+	{
+	    if ((formats[n].direct.redMask|
+		 formats[n].direct.blueMask|
+		 formats[n].direct.greenMask) == 0)
+		type = PICT_TYPE_A;
+	    else if (formats[n].direct.red > formats[n].direct.blue)
+		type = PICT_TYPE_ARGB;
+	    else
+		type = PICT_TYPE_ABGR;
+	    a = Ones (formats[n].direct.alphaMask);
+	    r = Ones (formats[n].direct.redMask);
+	    g = Ones (formats[n].direct.greenMask);
+	    b = Ones (formats[n].direct.blueMask);
+	}
+	formats[n].format = PICT_FORMAT(0,type,a,r,g,b);
+    }
+    ps = (PictureScreenPtr) xalloc (sizeof (PictureScreenRec));
+    if (!ps)
+    {
+	xfree (formats);
+	return FALSE;
+    }
+    SetPictureScreen(pScreen, ps);
+    if (!GlyphInit (pScreen))
+    {
+	SetPictureScreen(pScreen, 0);
+	xfree (formats);
+	xfree (ps);
+	return FALSE;
+    }
+
+    ps->totalPictureSize = sizeof (PictureRec);
+    ps->PicturePrivateSizes = 0;
+    ps->PicturePrivateLen = 0;
+    
+    ps->formats = formats;
+    ps->fallback = formats;
+    ps->nformats = nformats;
+    
+    ps->CloseScreen = pScreen->CloseScreen;
+    ps->DestroyWindow = pScreen->DestroyWindow;
+    pScreen->DestroyWindow = PictureDestroyWindow;
+    pScreen->CloseScreen = PictureCloseScreen;
+
+    return TRUE;
+}
+
+void
+SetPictureToDefaults (PicturePtr    pPicture)
+{
+    pPicture->refcnt = 1;
+    pPicture->repeat = 0;
+    pPicture->graphicsExposures = FALSE;
+    pPicture->subWindowMode = ClipByChildren;
+    pPicture->polyEdge = PolyEdgeSharp;
+    pPicture->polyMode = PolyModePrecise;
+    pPicture->freeCompClip = FALSE;
+    pPicture->clientClipType = CT_NONE;
+
+    pPicture->alphaMap = 0;
+    pPicture->alphaOrigin.x = 0;
+    pPicture->alphaOrigin.y = 0;
+
+    pPicture->clipOrigin.x = 0;
+    pPicture->clipOrigin.y = 0;
+    pPicture->clientClip = 0;
+
+    pPicture->dither = None;
+    pPicture->serialNumber = GC_CHANGE_SERIAL_BIT;
+    pPicture->stateChanges = (1 << (CPLastBit+1)) - 1;
+}
+
+PicturePtr
+AllocatePicture (ScreenPtr  pScreen)
+{
+    PictureScreenPtr	ps = GetPictureScreen(pScreen);
+    PicturePtr		pPicture;
+    char		*ptr;
+    DevUnion		*ppriv;
+    unsigned int    	*sizes;
+    unsigned int    	size;
+    int			i;
+
+    pPicture = (PicturePtr) xalloc (ps->totalPictureSize);
+    if (!pPicture)
+	return 0;
+    ppriv = (DevUnion *)(pPicture + 1);
+    pPicture->devPrivates = ppriv;
+    sizes = ps->PicturePrivateSizes;
+    ptr = (char *)(ppriv + ps->PicturePrivateLen);
+    for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++)
+    {
+	if ( (size = *sizes) )
+	{
+	    ppriv->ptr = (pointer)ptr;
+	    ptr += size;
+	}
+	else
+	    ppriv->ptr = (pointer)NULL;
+    }
+    return pPicture;
+}
+
+PicturePtr
+CreatePicture (Picture		pid,
+	       DrawablePtr	pDrawable,
+	       PictFormatPtr	pFormat,
+	       Mask		vmask,
+	       XID		*vlist,
+	       ClientPtr	client,
+	       int		*error)
+{
+    PicturePtr		pPicture;
+    PictureScreenPtr	ps = GetPictureScreen(pDrawable->pScreen);
+
+    pPicture = AllocatePicture (pDrawable->pScreen);
+    if (!pPicture)
+    {
+	*error = BadAlloc;
+	return 0;
+    }
+
+    pPicture->id = pid;
+    pPicture->pDrawable = pDrawable;
+    pPicture->pFormat = pFormat;
+    pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24);
+    if (pDrawable->type == DRAWABLE_PIXMAP)
+    {
+	++((PixmapPtr)pDrawable)->refcnt;
+	pPicture->pNext = 0;
+    }
+    else
+    {
+	pPicture->pNext = GetPictureWindow(((WindowPtr) pDrawable));
+	SetPictureWindow(((WindowPtr) pDrawable), pPicture);
+    }
+
+    SetPictureToDefaults (pPicture);
+    
+    if (vmask)
+	*error = ChangePicture (pPicture, vmask, vlist, 0, client);
+    else
+	*error = Success;
+    if (*error == Success)
+	*error = (*ps->CreatePicture) (pPicture);
+    if (*error != Success)
+    {
+	FreePicture (pPicture, (XID) 0);
+	pPicture = 0;
+    }
+    return pPicture;
+}
+
+#define NEXT_VAL(_type) (vlist ? (_type) *vlist++ : (_type) ulist++->val)
+
+#define NEXT_PTR(_type) ((_type) ulist++->ptr)
+
+int
+ChangePicture (PicturePtr	pPicture,
+	       Mask		vmask,
+	       XID		*vlist,
+	       DevUnion		*ulist,
+	       ClientPtr	client)
+{
+    ScreenPtr		pScreen = pPicture->pDrawable->pScreen;
+    PictureScreenPtr	ps = GetPictureScreen(pScreen);
+    BITS32		index2;
+    int			error = 0;
+    BITS32		maskQ;
+    
+    pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
+    maskQ = vmask;
+    while (vmask && !error)
+    {
+	index2 = (BITS32) lowbit (vmask);
+	vmask &= ~index2;
+	pPicture->stateChanges |= index2;
+	switch (index2)
+	{
+	case CPRepeat:
+	    {
+		unsigned int	newr;
+		newr = NEXT_VAL(unsigned int);
+		if (newr <= xTrue)
+		    pPicture->repeat = newr;
+		else
+		{
+		    client->errorValue = newr;
+		    error = BadValue;
+		}
+	    }
+	    break;
+	case CPAlphaMap:
+	    {
+		PicturePtr  pAlpha;
+		
+		if (vlist)
+		{
+		    Picture	pid = NEXT_VAL(Picture);
+
+		    if (pid == None)
+			pAlpha = 0;
+		    else
+		    {
+			pAlpha = (PicturePtr) SecurityLookupIDByType(client,
+								     pid, 
+								     PictureType, 
+								     SecurityWriteAccess|SecurityReadAccess);
+			if (!pAlpha)
+			{
+			    client->errorValue = pid;
+			    error = BadPixmap;
+			    break;
+			}
+			if (pAlpha->pDrawable->type != DRAWABLE_PIXMAP)
+			{
+			    client->errorValue = pid;
+			    error = BadMatch;
+			    break;
+			}
+		    }
+		}
+		else
+		    pAlpha = NEXT_PTR(PicturePtr);
+		if (!error)
+		{
+		    if (pAlpha && pAlpha->pDrawable->type == DRAWABLE_PIXMAP)
+			pAlpha->refcnt++;
+		    if (pPicture->alphaMap)
+			FreePicture ((pointer) pPicture->alphaMap, (XID) 0);
+		    pPicture->alphaMap = pAlpha;
+		}
+	    }
+	    break;
+	case CPAlphaXOrigin:
+	    pPicture->alphaOrigin.x = NEXT_VAL(INT16);
+	    break;
+	case CPAlphaYOrigin:
+	    pPicture->alphaOrigin.y = NEXT_VAL(INT16);
+	    break;
+	case CPClipXOrigin:
+	    pPicture->clipOrigin.x = NEXT_VAL(INT16);
+	    break;
+	case CPClipYOrigin:
+	    pPicture->clipOrigin.y = NEXT_VAL(INT16);
+	    break;
+	case CPClipMask:
+	    {
+		Pixmap	    pid;
+		PixmapPtr   pPixmap;
+		int	    clipType;
+
+		if (vlist)
+		{
+		    pid = NEXT_VAL(Pixmap);
+		    if (pid == None)
+		    {
+			clipType = CT_NONE;
+			pPixmap = NullPixmap;
+		    }
+		    else
+		    {
+			clipType = CT_PIXMAP;
+			pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
+								    pid, 
+								    RT_PIXMAP,
+								    SecurityReadAccess);
+			if (!pPixmap)
+			{
+			    client->errorValue = pid;
+			    error = BadPixmap;
+			    break;
+			}
+		    }
+		}
+		else
+		{
+		    pPixmap = NEXT_PTR(PixmapPtr);
+		    if (pPixmap)
+			clipType = CT_PIXMAP;
+		    else
+			clipType = CT_NONE;
+		}
+
+		if (pPixmap)
+		{
+		    if ((pPixmap->drawable.depth != 1) ||
+			(pPixmap->drawable.pScreen != pScreen))
+		    {
+			error = BadMatch;
+			break;
+		    }
+		    else
+		    {
+			clipType = CT_PIXMAP;
+			pPixmap->refcnt++;
+		    }
+		}
+		error = (*ps->ChangePictureClip)(pPicture, clipType,
+						 (pointer)pPixmap, 0);
+		break;
+	    }
+	case CPGraphicsExposure:
+	    {
+		unsigned int	newe;
+		newe = NEXT_VAL(unsigned int);
+		if (newe <= xTrue)
+		    pPicture->graphicsExposures = newe;
+		else
+		{
+		    client->errorValue = newe;
+		    error = BadValue;
+		}
+	    }
+	    break;
+	case CPSubwindowMode:
+	    {
+		unsigned int	news;
+		news = NEXT_VAL(unsigned int);
+		if (news == ClipByChildren || news == IncludeInferiors)
+		    pPicture->subWindowMode = news;
+		else
+		{
+		    client->errorValue = news;
+		    error = BadValue;
+		}
+	    }
+	    break;
+	case CPPolyEdge:
+	    {
+		unsigned int	newe;
+		newe = NEXT_VAL(unsigned int);
+		if (newe == PolyEdgeSharp || newe == PolyEdgeSmooth)
+		    pPicture->polyEdge = newe;
+		else
+		{
+		    client->errorValue = newe;
+		    error = BadValue;
+		}
+	    }
+	    break;
+	case CPPolyMode:
+	    {
+		unsigned int	newm;
+		newm = NEXT_VAL(unsigned int);
+		if (newm == PolyModePrecise || newm == PolyModeImprecise)
+		    pPicture->polyMode = newm;
+		else
+		{
+		    client->errorValue = newm;
+		    error = BadValue;
+		}
+	    }
+	    break;
+	case CPDither:
+	    pPicture->dither = NEXT_VAL(Atom);
+	    break;
+	case CPComponentAlpha:
+	    {
+		unsigned int	newca;
+
+		newca = NEXT_VAL (unsigned int);
+		if (newca <= xTrue)
+		    pPicture->componentAlpha = newca;
+		else
+		{
+		    client->errorValue = newca;
+		    error = BadValue;
+		}
+	    }
+	    break;
+	default:
+	    client->errorValue = maskQ;
+	    error = BadValue;
+	    break;
+	}
+    }
+    (*ps->ChangePicture) (pPicture, maskQ);
+    return error;
+}
+
+int
+SetPictureClipRects (PicturePtr	pPicture,
+		     int	xOrigin,
+		     int	yOrigin,
+		     int	nRect,
+		     xRectangle	*rects)
+{
+    ScreenPtr		pScreen = pPicture->pDrawable->pScreen;
+    PictureScreenPtr	ps = GetPictureScreen(pScreen);
+    RegionPtr		clientClip;
+    int			result;
+
+    clientClip = RECTS_TO_REGION(pScreen,
+				 nRect, rects, CT_UNSORTED);
+    if (!clientClip)
+	return BadAlloc;
+    result =(*ps->ChangePictureClip) (pPicture, CT_REGION, 
+				      (pointer) clientClip, 0);
+    if (result == Success)
+    {
+	pPicture->clipOrigin.x = xOrigin;
+	pPicture->clipOrigin.y = yOrigin;
+	pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask;
+	pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT;
+    }
+    return result;
+}
+
+void
+ValidatePicture(PicturePtr pPicture)
+{
+    if (pPicture->serialNumber != pPicture->pDrawable->serialNumber)
+    {
+	PictureScreenPtr    ps = GetPictureScreen(pPicture->pDrawable->pScreen);
+
+	(*ps->ValidatePicture) (pPicture, pPicture->stateChanges);
+	pPicture->stateChanges = 0;
+	pPicture->serialNumber = pPicture->pDrawable->serialNumber;
+    }
+}
+
+int
+FreePicture (pointer	value,
+	     XID	pid)
+{
+    PicturePtr	pPicture = (PicturePtr) value;
+
+    if (--pPicture->refcnt == 0)
+    {
+	ScreenPtr	    pScreen = pPicture->pDrawable->pScreen;
+	PictureScreenPtr    ps = GetPictureScreen(pScreen);
+	
+	if (pPicture->alphaMap)
+	    FreePicture ((pointer) pPicture->alphaMap, (XID) 0);
+	(*ps->DestroyPicture) (pPicture);
+	if (pPicture->pDrawable->type == DRAWABLE_WINDOW)
+	{
+	    WindowPtr	pWindow = (WindowPtr) pPicture->pDrawable;
+	    PicturePtr	*pPrev;
+
+	    for (pPrev = (PicturePtr *) &((pWindow)->devPrivates[PictureWindowPrivateIndex].ptr);
+		 *pPrev;
+		 pPrev = &(*pPrev)->pNext)
+	    {
+		if (*pPrev == pPicture)
+		{
+		    *pPrev = pPicture->pNext;
+		    break;
+		}
+	    }
+	}
+	else if (pPicture->pDrawable->type == DRAWABLE_PIXMAP)
+	{
+	    (*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
+	}
+	xfree (pPicture);
+    }
+    return Success;
+}
+
+int
+FreePictFormat (pointer	pPictFormat,
+		XID     pid)
+{
+    return Success;
+}
+
+void
+CompositePicture (CARD8		op,
+		  PicturePtr	pSrc,
+		  PicturePtr	pMask,
+		  PicturePtr	pDst,
+		  INT16		xSrc,
+		  INT16		ySrc,
+		  INT16		xMask,
+		  INT16		yMask,
+		  INT16		xDst,
+		  INT16		yDst,
+		  CARD16	width,
+		  CARD16	height)
+{
+    PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
+    
+    ValidatePicture (pSrc);
+    if (pMask)
+	ValidatePicture (pMask);
+    ValidatePicture (pDst);
+    (*ps->Composite) (op,
+		       pSrc,
+		       pMask,
+		       pDst,
+		       xSrc,
+		       ySrc,
+		       xMask,
+		       yMask,
+		       xDst,
+		       yDst,
+		       width,
+		       height);
+}
+
+void
+CompositeGlyphs (CARD8		op,
+		 PicturePtr	pSrc,
+		 PicturePtr	pDst,
+		 PictFormatPtr	maskFormat,
+		 INT16		xSrc,
+		 INT16		ySrc,
+		 int		nlist,
+		 GlyphListPtr	lists,
+		 GlyphPtr	*glyphs)
+{
+    PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
+    
+    ValidatePicture (pSrc);
+    ValidatePicture (pDst);
+    (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, lists, glyphs);
+}
+
+void
+CompositeRects (CARD8		op,
+		PicturePtr	pDst,
+		xRenderColor	*color,
+		int		nRect,
+		xRectangle      *rects)
+{
+    PictureScreenPtr	ps = GetPictureScreen(pDst->pDrawable->pScreen);
+    
+    ValidatePicture (pDst);
+    (*ps->CompositeRects) (op, pDst, color, nRect, rects);
+}
Index: xc/programs/Xserver/render/picture.h
diff -u /dev/null xc/programs/Xserver/render/picture.h:1.5
--- /dev/null	Mon Dec 18 14:33:31 2000
+++ xc/programs/Xserver/render/picture.h	Mon Nov 20 23:11:42 2000
@@ -0,0 +1,105 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/picture.h,v 1.5 2000/11/21 04:11:42 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _PICTURE_H_
+#define _PICTURE_H_
+
+typedef struct _DirectFormat	*DirectFormatPtr;
+typedef struct _PictFormat	*PictFormatPtr;
+typedef struct _Picture		*PicturePtr;
+
+/*
+ * While the protocol is generous in format support, the
+ * sample implementation allows only packed RGB and GBR
+ * representations for data to simplify software rendering,
+ */
+#define PICT_FORMAT(bpp,type,a,r,g,b)	(((bpp) << 24) |  \
+					 ((type) << 16) | \
+					 ((a) << 12) | \
+					 ((r) << 8) | \
+					 ((g) << 4) | \
+					 ((b)))
+
+#define PICT_FORMAT_BPP(f)	(((f) >> 24)       )
+#define PICT_FORMAT_TYPE(f)	(((f) >> 16) & 0xff)
+#define PICT_FORMAT_A(f)	(((f) >> 12) & 0x0f)
+#define PICT_FORMAT_R(f)	(((f) >>  8) & 0x0f)
+#define PICT_FORMAT_G(f)	(((f) >>  4) & 0x0f)
+#define PICT_FORMAT_B(f)	(((f)      ) & 0x0f)
+#define PICT_FORMAT_RGB(f)	(((f)      ) & 0xfff)
+
+#define PICT_OTHER	0
+#define PICT_TYPE_A	1
+#define PICT_TYPE_ARGB	2
+#define PICT_TYPE_ABGR	3
+#define PICT_TYPE_INDEX	4
+
+#define PICT_FORMAT_COLOR(f)	(PICT_FORMAT_TYPE(f) & 2)
+
+/* 32bpp formats */
+#define PICT_a8r8g8b8	PICT_FORMAT(32,PICT_TYPE_ARGB,8,8,8,8)
+#define PICT_x8r8g8b8	PICT_FORMAT(32,PICT_TYPE_ARGB,0,8,8,8)
+#define PICT_a8b8g8r8	PICT_FORMAT(32,PICT_TYPE_ABGR,8,8,8,8)
+#define PICT_x8b8g8r8	PICT_FORMAT(32,PICT_TYPE_ABGR,0,8,8,8)
+
+/* 24bpp formats */
+#define PICT_r8g8b8	PICT_FORMAT(24,PICT_TYPE_ARGB,0,8,8,8)
+#define PICT_b8g8r8	PICT_FORMAT(24,PICT_TYPE_ABGR,0,8,8,8)
+
+/* 16bpp formats */
+#define PICT_r5g6b5	PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,6,5)
+#define PICT_b5g6r5	PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,6,5)
+
+#define PICT_a1r5g5b5	PICT_FORMAT(16,PICT_TYPE_ARGB,1,5,5,5)
+#define PICT_x1r5g5b5	PICT_FORMAT(16,PICT_TYPE_ARGB,0,5,5,5)
+#define PICT_a1b5g5r5	PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5)
+#define PICT_x1b5g5r5	PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5)
+
+/* 8bpp formats */
+#define PICT_a8		PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0)
+#define PICT_r3g3b2	PICT_FORMAT(8,PICT_TYPE_ARGB,0,3,3,2)
+#define PICT_b2g3r3	PICT_FORMAT(8,PICT_TYPE_ABGR,0,3,3,2)
+#define PICT_a2r2g2b2	PICT_FORMAT(8,PICT_TYPE_ARGB,2,2,2,2)
+#define PICT_a2b2g2r2	PICT_FORMAT(8,PICT_TYPE_ABGR,2,2,2,2)
+
+/* 4bpp formats */
+#define PICT_a4		PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0)
+#define PICT_r1g2b1	PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1)
+#define PICT_b1g2r1	PICT_FORMAT(4,PICT_TYPE_ABGR,0,1,2,1)
+#define PICT_a1r1g1b1	PICT_FORMAT(4,PICT_TYPE_ARGB,1,1,1,1)
+#define PICT_a1b1g1r1	PICT_FORMAT(4,PICT_TYPE_ABGR,1,1,1,1)
+				    
+/* 1bpp formats */
+#define PICT_a1		PICT_FORMAT(1,PICT_TYPE_A,1,0,0,0)
+
+#define FixedToInt(f)	(int) ((f) >> 8)
+#define IntToFixed(i)	((Fixed) (i) << 8)
+#define FixedE		((Fixed) 1)
+#define Fixed1		(IntToFixed(1))
+#define Fixed1minusE	(Fixed1 - FixedE)
+#define FixedCeil(f)	(((f) + Fixed1minusE) & ~Fixed1MinusE)
+#define FixedFloor(f)	((f) & ~Fixed1MinusE)
+
+#endif /* _PICTURE_H_ */
Index: xc/programs/Xserver/render/picturestr.h
diff -u /dev/null xc/programs/Xserver/render/picturestr.h:1.10
--- /dev/null	Mon Dec 18 14:33:31 2000
+++ xc/programs/Xserver/render/picturestr.h	Mon Dec  4 22:13:33 2000
@@ -0,0 +1,273 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/picturestr.h,v 1.10 2000/12/05 03:13:33 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _PICTURESTR_H_
+#define _PICTURESTR_H_
+
+#include "renderproto.h"
+#include "picture.h"
+#include "glyphstr.h"
+#include "resource.h"
+
+typedef struct _DirectFormat {
+    CARD16	    red, redMask;
+    CARD16	    green, greenMask;
+    CARD16	    blue, blueMask;
+    CARD16	    alpha, alphaMask;
+} DirectFormatRec;
+
+typedef struct _PictFormat {
+    CARD32	    id;
+    CARD32	    format;	    /* except bpp */
+    unsigned char   type;
+    unsigned char   depth;
+    DirectFormatRec direct;
+    ColormapPtr	    pColormap;
+} PictFormatRec;
+
+typedef struct _Picture {
+    DrawablePtr	    pDrawable;
+    PictFormatPtr   pFormat;
+    CARD32	    format;	    /* PICT_FORMAT */
+    int		    refcnt;
+    CARD32	    id;
+    PicturePtr	    pNext;	    /* chain on same drawable */
+    
+    unsigned int    repeat : 1;
+    unsigned int    graphicsExposures : 1;
+    unsigned int    subWindowMode : 1;
+    unsigned int    polyEdge : 1;
+    unsigned int    polyMode : 1;
+    unsigned int    freeCompClip : 1;
+    unsigned int    clientClipType : 2;
+    unsigned int    componentAlpha : 1;
+    unsigned int    unused : 23;
+
+    PicturePtr	    alphaMap;
+    DDXPointRec	    alphaOrigin;
+
+    DDXPointRec	    clipOrigin;
+    pointer	    clientClip;
+
+    Atom	    dither;
+
+    unsigned long   stateChanges;
+    unsigned long   serialNumber;
+
+    RegionPtr	    pCompositeClip;
+    
+    DevUnion	    *devPrivates;
+} PictureRec;
+
+typedef int	(*CreatePictureProcPtr)	    (PicturePtr pPicture);
+typedef void	(*DestroyPictureProcPtr)    (PicturePtr pPicture);
+typedef int	(*ChangePictureClipProcPtr) (PicturePtr	pPicture,
+					     int	clipType,
+					     pointer    value,
+					     int	n);
+typedef void	(*DestroyPictureClipProcPtr)(PicturePtr	pPicture);
+    
+typedef void	(*ChangePictureProcPtr)	    (PicturePtr pPicture,
+					     Mask	mask);
+typedef void	(*ValidatePictureProcPtr)    (PicturePtr pPicture,
+					     Mask       mask);
+typedef void	(*CompositeProcPtr)	    (CARD8	op,
+					     PicturePtr pSrc,
+					     PicturePtr pMask,
+					     PicturePtr pDst,
+					     INT16	xSrc,
+					     INT16	ySrc,
+					     INT16	xMask,
+					     INT16	yMask,
+					     INT16	xDst,
+					     INT16	yDst,
+					     CARD16	width,
+					     CARD16	height);
+
+typedef void	(*GlyphsProcPtr)	    (CARD8      op,
+					     PicturePtr pSrc,
+					     PicturePtr pDst,
+					     PictFormatPtr  maskFormat,
+					     INT16      xSrc,
+					     INT16      ySrc,
+					     int	nlists,
+					     GlyphListPtr   lists,
+					     GlyphPtr	*glyphs);
+
+typedef void	(*CompositeRectsProcPtr)    (CARD8	    op,
+					     PicturePtr	    pDst,
+					     xRenderColor   *color,
+					     int	    nRect,
+					     xRectangle	    *rects);
+
+typedef struct _PictureScreen {
+    int				totalPictureSize;
+    unsigned int		*PicturePrivateSizes;
+    int				PicturePrivateLen;
+
+    PictFormatPtr		formats;
+    PictFormatPtr		fallback;
+    int				nformats;
+    
+    CreatePictureProcPtr	CreatePicture;
+    DestroyPictureProcPtr	DestroyPicture;
+    ChangePictureClipProcPtr	ChangePictureClip;
+    DestroyPictureClipProcPtr	DestroyPictureClip;
+    
+    ChangePictureProcPtr	ChangePicture;
+    ValidatePictureProcPtr	ValidatePicture;
+
+    CompositeProcPtr		Composite;
+    GlyphsProcPtr		Glyphs;
+    CompositeRectsProcPtr	CompositeRects;
+
+    DestroyWindowProcPtr	DestroyWindow;
+    CloseScreenProcPtr		CloseScreen;
+
+} PictureScreenRec, *PictureScreenPtr;
+
+extern int		PictureScreenPrivateIndex;
+extern int		PictureWindowPrivateIndex;
+extern RESTYPE		PictureType;
+extern RESTYPE		PictFormatType;
+extern RESTYPE		GlyphSetType;
+
+#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
+#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
+#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (pointer) (p))
+#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
+#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (pointer) (p))
+
+#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
+    pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
+    if (!pPicture) { \
+	client->errorValue = pid; \
+	return err; \
+    } \
+}
+
+#define VERIFY_ALPHA(pPicture, pid, client, mode, err) {\
+    if (pid == None) \
+	pPicture = 0; \
+    else { \
+	VERIFY_PICTURE(pPicture, pid, client, mode, err); \
+    } \
+} \
+
+Bool
+PictureDestroyWindow (WindowPtr pWindow);
+
+Bool
+PictureCloseScreen (int Index, ScreenPtr pScreen);
+
+PictFormatPtr
+PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp);
+
+PictFormatPtr
+PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual);
+
+PictFormatPtr
+PictureMatchFormat (ScreenPtr pScreen, int depth, CARD32 format);
+    
+Bool
+PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+
+void
+SetPictureToDefaults (PicturePtr pPicture);
+    
+PicturePtr
+AllocatePicture (ScreenPtr  pScreen);
+
+Bool
+miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
+
+
+PicturePtr
+CreatePicture (Picture		pid,
+	       DrawablePtr	pDrawable,
+	       PictFormatPtr	pFormat,
+	       Mask		mask,
+	       XID		*list,
+	       ClientPtr	client,
+	       int		*error);
+
+int
+ChangePicture (PicturePtr	pPicture,
+	       Mask		vmask,
+	       XID		*vlist,
+	       DevUnion		*ulist,
+	       ClientPtr	client);
+
+int
+SetPictureClipRects (PicturePtr	pPicture,
+		     int	xOrigin,
+		     int	yOrigin,
+		     int	nRect,
+		     xRectangle	*rects);
+
+void
+ValidatePicture(PicturePtr pPicture);
+
+int
+FreePicture (pointer	pPicture,
+	     XID	pid);
+
+int
+FreePictFormat (pointer	pPictFormat,
+		XID     pid);
+
+void
+CompositePicture (CARD8		op,
+		  PicturePtr	pSrc,
+		  PicturePtr	pMask,
+		  PicturePtr	pDst,
+		  INT16		xSrc,
+		  INT16		ySrc,
+		  INT16		xMask,
+		  INT16		yMask,
+		  INT16		xDst,
+		  INT16		yDst,
+		  CARD16	width,
+		  CARD16	height);
+
+void
+CompositeGlyphs (CARD8		op,
+		 PicturePtr	pSrc,
+		 PicturePtr	pDst,
+		 PictFormatPtr	maskFormat,
+		 INT16		xSrc,
+		 INT16		ySrc,
+		 int		nlist,
+		 GlyphListPtr	lists,
+		 GlyphPtr	*glyphs);
+
+void
+CompositeRects (CARD8		op,
+		PicturePtr	pDst,
+		xRenderColor	*color,
+		int		nRect,
+		xRectangle      *rects);
+
+#endif /* _PICTURESTR_H_ */
Index: xc/programs/Xserver/render/render.c
diff -u /dev/null xc/programs/Xserver/render/render.c:1.8
--- /dev/null	Mon Dec 18 14:33:32 2000
+++ xc/programs/Xserver/render/render.c	Mon Dec  4 22:13:34 2000
@@ -0,0 +1,1399 @@
+/*
+ * $XFree86: xc/programs/Xserver/render/render.c,v 1.8 2000/12/05 03:13:34 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  SuSE makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author:  Keith Packard, SuSE, Inc.
+ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "os.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "colormapst.h"
+#include "extnsionst.h"
+#include "servermd.h"
+#include "render.h"
+#include "renderproto.h"
+#include "picturestr.h"
+#include "glyphstr.h"
+#include "Xfuncproto.h"
+#ifdef EXTMODULE
+#include "xf86_ansic.h"
+#endif
+
+static int ProcRenderQueryVersion (ClientPtr pClient);
+static int ProcRenderQueryPictFormats (ClientPtr pClient);
+static int ProcRenderQueryPictIndexValues (ClientPtr pClient);
+static int ProcRenderQueryDithers (ClientPtr pClient);
+static int ProcRenderCreatePicture (ClientPtr pClient);
+static int ProcRenderChangePicture (ClientPtr pClient);
+static int ProcRenderSetPictureClipRectangles (ClientPtr pClient);
+static int ProcRenderFreePicture (ClientPtr pClient);
+static int ProcRenderComposite (ClientPtr pClient);
+static int ProcRenderScale (ClientPtr pClient);
+static int ProcRenderTrapezoids (ClientPtr pClient);
+static int ProcRenderTriangles (ClientPtr pClient);
+static int ProcRenderTriStrip (ClientPtr pClient);
+static int ProcRenderTriFan (ClientPtr pClient);
+static int ProcRenderColorTrapezoids (ClientPtr pClient);
+static int ProcRenderColorTriangles (ClientPtr pClient);
+static int ProcRenderTransform (ClientPtr pClient);
+static int ProcRenderCreateGlyphSet (ClientPtr pClient);
+static int ProcRenderReferenceGlyphSet (ClientPtr pClient);
+static int ProcRenderFreeGlyphSet (ClientPtr pClient);
+static int ProcRenderAddGlyphs (ClientPtr pClient);
+static int ProcRenderAddGlyphsFromPicture (ClientPtr pClient);
+static int ProcRenderFreeGlyphs (ClientPtr pClient);
+static int ProcRenderCompositeGlyphs (ClientPtr pClient, int size);
+static int ProcRenderDispatch (ClientPtr pClient);
+static int SProcRenderQueryVersion (ClientPtr pClient);
+static int SProcRenderQueryPictFormats (ClientPtr pClient);
+static int SProcRenderQueryPictIndexValues (ClientPtr pClient);
+static int SProcRenderQueryDithers (ClientPtr pClient);
+static int SProcRenderCreatePicture (ClientPtr pClient);
+static int SProcRenderChangePicture (ClientPtr pClient);
+static int SProcRenderSetPictureClipRectangles (ClientPtr pClient);
+static int SProcRenderFreePicture (ClientPtr pClient);
+static int SProcRenderComposite (ClientPtr pClient);
+static int SProcRenderScale (ClientPtr pClient);
+static int SProcRenderTrapezoids (ClientPtr pClient);
+static int SProcRenderTriangles (ClientPtr pClient);
+static int SProcRenderTriStrip (ClientPtr pClient);
+static int SProcRenderTriFan (ClientPtr pClient);
+static int SProcRenderColorTrapezoids (ClientPtr pClient);
+static int SProcRenderColorTriangles (ClientPtr pClient);
+static int SProcRenderTransform (ClientPtr pClient);
+static int SProcRenderCreateGlyphSet (ClientPtr pClient);
+static int SProcRenderReferenceGlyphSet (ClientPtr pClient);
+static int SProcRenderFreeGlyphSet (ClientPtr pClient);
+static int SProcRenderAddGlyphs (ClientPtr pClient);
+static int SProcRenderAddGlyphsFromPicture (ClientPtr pClient);
+static int SProcRenderFreeGlyphs (ClientPtr pClient);
+static int SProcRenderDispatch (ClientPtr pClient);
+
+static void
+RenderResetProc (ExtensionEntry *extEntry);
+    
+static CARD8	RenderReqCode;
+static int	RenderErrBase;
+
+void
+RenderExtensionInit (void)
+{
+    ExtensionEntry *extEntry;
+
+    if (!PictureType)
+	return;
+    extEntry = AddExtension (RENDER_NAME, 0, RenderNumberErrors,
+			     ProcRenderDispatch, SProcRenderDispatch,
+			     RenderResetProc, StandardMinorOpcode);
+    if (!extEntry)
+	return;
+    RenderReqCode = (CARD8) extEntry->base;
+    RenderErrBase = extEntry->errorBase;							
+}
+
+static void
+RenderResetProc (ExtensionEntry *extEntry)
+{
+}
+
+static int
+ProcRenderQueryVersion (ClientPtr client)
+{
+    xRenderQueryVersionReply rep;
+    register int n;
+/*    REQUEST(xRenderQueryVersionReq); */
+
+    REQUEST_SIZE_MATCH(xRenderQueryVersionReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.majorVersion = RENDER_MAJOR;
+    rep.minorVersion = RENDER_MINOR;
+    if (client->swapped) {
+    	swaps(&rep.sequenceNumber, n);
+    	swapl(&rep.length, n);
+	swapl(&rep.majorVersion, n);
+	swapl(&rep.minorVersion, n);
+    }
+    WriteToClient(client, sizeof(xRenderQueryVersionReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+#if 0
+static int
+VisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
+{
+    DepthPtr    pDepth;
+    int		d, v;
+
+    for (d = 0; d < pScreen->numDepths; d++)
+    {
+	pDepth = pScreen->allowedDepths + d;
+	for (v = 0; v < pDepth->numVids; v++)
+	{
+	    if (pDepth->vids[v] == pVisual->vid)
+		return pDepth->depth;
+	}
+    }
+    return 0;
+}
+#endif
+
+static VisualPtr
+findVisual (ScreenPtr pScreen, VisualID vid)
+{
+    VisualPtr	pVisual;
+    int		v;
+
+    for (v = 0; v < pScreen->numVisuals; v++)
+    {
+	pVisual = pScreen->visuals + v;
+	if (pVisual->vid == vid)
+	    return pVisual;
+    }
+    return 0;
+}
+
+static int
+ProcRenderQueryPictFormats (ClientPtr client)
+{
+    xRenderQueryPictFormatsReply    *reply;
+    xPictScreen			    *pictScreen;
+    xPictDepth			    *pictDepth;
+    xPictVisual			    *pictVisual;
+    xPictFormInfo		    *pictForm;
+    ScreenPtr			    pScreen;
+    VisualPtr			    pVisual;
+    DepthPtr			    pDepth;
+    int				    v, d;
+    PictureScreenPtr		    ps;
+    PictFormatPtr		    pFormat;
+    int				    nformat;
+    int				    ndepth;
+    int				    nvisual;
+    int				    rlength;
+    int				    s;
+    int				    n;
+/*    REQUEST(xRenderQueryPictFormatsReq); */
+
+    REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq);
+
+    ndepth = nformat = nvisual = 0;
+    for (s = 0; s < screenInfo.numScreens; s++)
+    {
+	pScreen = screenInfo.screens[s];
+	for (d = 0; d < pScreen->numDepths; d++)
+	{
+	    pDepth = pScreen->allowedDepths + d;
+	    ++ndepth;
+
+	    for (v = 0; v < pDepth->numVids; v++)
+	    {
+		pVisual = findVisual (pScreen, pDepth->vids[v]);
+		if (pVisual && PictureMatchVisual (pScreen, pDepth->depth, pVisual))
+		    ++nvisual;
+	    }
+	}
+	ps = GetPictureScreenIfSet(pScreen);
+	if (ps)
+	    nformat += ps->nformats;
+    }
+    rlength = (sizeof (xRenderQueryPictFormatsReply) +
+	       nformat * sizeof (xPictFormInfo) +
+	       screenInfo.numScreens * sizeof (xPictScreen) +
+	       ndepth * sizeof (xPictDepth) +
+	       nvisual * sizeof (xPictVisual));
+    reply = (xRenderQueryPictFormatsReply *) xalloc (rlength);
+    if (!reply)
+	return BadAlloc;
+    reply->type = X_Reply;
+    reply->sequenceNumber = client->sequence;
+    reply->length = (rlength - sizeof(xGenericReply)) >> 2;
+    reply->numFormats = nformat;
+    reply->numScreens = screenInfo.numScreens;
+    reply->numDepths = ndepth;
+    reply->numVisuals = nvisual;
+    
+    pictForm = (xPictFormInfo *) (reply + 1);
+    
+    for (s = 0; s < screenInfo.numScreens; s++)
+    {
+	pScreen = screenInfo.screens[s];
+	ps = GetPictureScreenIfSet(pScreen);
+	if (ps)
+	{
+	    for (nformat = 0, pFormat = ps->formats; 
+		 nformat < ps->nformats;
+		 nformat++, pFormat++)
+	    {
+		pictForm->id = pFormat->id;
+		pictForm->type = pFormat->type;
+		pictForm->depth = pFormat->depth;
+		pictForm->direct.red = pFormat->direct.red;
+		pictForm->direct.redMask = pFormat->direct.redMask;
+		pictForm->direct.green = pFormat->direct.green;
+		pictForm->direct.greenMask = pFormat->direct.greenMask;
+		pictForm->direct.blue = pFormat->direct.blue;
+		pictForm->direct.blueMask = pFormat->direct.blueMask;
+		pictForm->direct.alpha = pFormat->direct.alpha;
+		pictForm->direct.alphaMask = pFormat->direct.alphaMask;
+		if (pFormat->pColormap)
+		    pictForm->colormap = pFormat->pColormap->mid;
+		else
+		    pictForm->colormap = None;
+		if (client->swapped)
+		{
+		    swapl (&pictForm->id, n);
+		    swaps (&pictForm->direct.red, n);
+		    swaps (&pictForm->direct.redMask, n);
+		    swaps (&pictForm->direct.green, n);
+		    swaps (&pictForm->direct.greenMask, n);
+		    swaps (&pictForm->direct.blue, n);
+		    swaps (&pictForm->direct.blueMask, n);
+		    swaps (&pictForm->direct.alpha, n);
+		    swaps (&pictForm->direct.alphaMask, n);
+		    swapl (&pictForm->colormap, n);
+		}
+		pictForm++;
+	    }
+	}
+    }
+    
+    pictScreen = (xPictScreen *) pictForm;
+    for (s = 0; s < screenInfo.numScreens; s++)
+    {
+	pScreen = screenInfo.screens[s];
+	pictDepth = (xPictDepth *) (pictScreen + 1);
+	ndepth = 0;
+	for (d = 0; d < pScreen->numDepths; d++)
+	{
+	    pictVisual = (xPictVisual *) (pictDepth + 1);
+	    pDepth = pScreen->allowedDepths + d;
+
+	    nvisual = 0;
+	    for (v = 0; v < pDepth->numVids; v++)
+	    {
+		pVisual = findVisual (pScreen, pDepth->vids[v]);
+		if (pVisual && (pFormat = PictureMatchVisual (pScreen, 
+							      pDepth->depth, 
+							      pVisual)))
+		{
+		    pictVisual->visual = pVisual->vid;
+		    pictVisual->format = pFormat->id;
+		    if (client->swapped)
+		    {
+			swapl (&pictVisual->visual, n);
+			swapl (&pictVisual->format, n);
+		    }
+		    pictVisual++;
+		    nvisual++;
+		}
+	    }
+	    pictDepth->depth = pDepth->depth;
+	    pictDepth->nPictVisuals = nvisual;
+	    if (client->swapped)
+	    {
+		swaps (&pictDepth->nPictVisuals, n);
+	    }
+	    ndepth++;
+	    pictDepth = (xPictDepth *) pictVisual;
+	}
+	pictScreen->nDepth = ndepth;
+	ps = GetPictureScreenIfSet(pScreen);
+	if (ps)
+	    pictScreen->fallback = ps->fallback->id;
+	else
+	    pictScreen->fallback = 0;
+	if (client->swapped)
+	{
+	    swapl (&pictScreen->nDepth, n);
+	    swapl (&pictScreen->fallback, n);
+	}
+	pictScreen = (xPictScreen *) pictDepth;
+    }
+    if (client->swapped)
+    {
+	swaps (&reply->sequenceNumber, n);
+	swapl (&reply->length, n);
+	swapl (&reply->numFormats, n);
+	swapl (&reply->numScreens, n);
+	swapl (&reply->numDepths, n);
+	swapl (&reply->numVisuals, n);
+    }
+    WriteToClient(client, rlength, (char *) reply);
+    xfree (reply);
+    return client->noClientException;
+}
+
+static int
+ProcRenderQueryPictIndexValues (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderQueryDithers (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderCreatePicture (ClientPtr client)
+{
+    PicturePtr	    pPicture;
+    DrawablePtr	    pDrawable;
+    PictFormatPtr   pFormat;
+    int		    len;
+    int		    error;
+    REQUEST(xRenderCreatePictureReq);
+
+    REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq);
+
+    LEGAL_NEW_RESOURCE(stuff->pid, client);
+    SECURITY_VERIFY_DRAWABLE(pDrawable, stuff->drawable, client,
+			     SecurityWriteAccess);
+    pFormat = (PictFormatPtr) SecurityLookupIDByType (client, 
+						      stuff->format,
+						      PictFormatType,
+						      SecurityReadAccess);
+    if (!pFormat)
+    {
+	client->errorValue = stuff->format;
+	return RenderErrBase + BadPictFormat;
+    }
+    if (pFormat->depth != pDrawable->depth)
+	return BadMatch;
+    len = client->req_len - (sizeof(xRenderCreatePictureReq) >> 2);
+    if (Ones(stuff->mask) != len)
+	return BadLength;
+    
+    pPicture = CreatePicture (stuff->pid,
+			      pDrawable,
+			      pFormat,
+			      stuff->mask,
+			      (XID *) (stuff + 1),
+			      client,
+			      &error);
+    if (!pPicture)
+	return error;
+    if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
+	return BadAlloc;
+    return Success;
+}
+
+static int
+ProcRenderChangePicture (ClientPtr client)
+{
+    PicturePtr	    pPicture;
+    REQUEST(xRenderChangePictureReq);
+    int len;
+
+    REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
+    VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess,
+		    RenderErrBase + BadPicture);
+    len = client->req_len - (sizeof(xRenderChangePictureReq) >> 2);
+    if (Ones(stuff->mask) != len)
+	return BadLength;
+    
+    return ChangePicture (pPicture, stuff->mask, (XID *) (stuff + 1),
+			  (DevUnion *) 0, client);
+}
+
+static int
+ProcRenderSetPictureClipRectangles (ClientPtr client)
+{
+    REQUEST(xRenderSetPictureClipRectanglesReq);
+    PicturePtr	    pPicture;
+    int		    nr;
+    int		    result;
+
+    REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
+    VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess,
+		    RenderErrBase + BadPicture);
+    nr = (client->req_len << 2) - sizeof(xRenderChangePictureReq);
+    if (nr & 4)
+	return BadLength;
+    nr >>= 3;
+    result = SetPictureClipRects (pPicture, 
+				  stuff->xOrigin, stuff->yOrigin,
+				  nr, (xRectangle *) &stuff[1]);
+    if (client->noClientException != Success)
+        return(client->noClientException);
+    else
+        return(result);
+}
+
+static int
+ProcRenderFreePicture (ClientPtr client)
+{
+    PicturePtr	pPicture;
+    REQUEST(xRenderFreePictureReq);
+
+    REQUEST_SIZE_MATCH(xRenderFreePictureReq);
+
+    VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityDestroyAccess,
+		    RenderErrBase + BadPicture);
+    FreeResource (stuff->picture, RT_NONE);
+    return(client->noClientException);
+}
+
+static int
+ProcRenderComposite (ClientPtr client)
+{
+    PicturePtr	pSrc, pMask, pDst;
+    REQUEST(xRenderCompositeReq);
+
+    if (stuff->op > PictOpMaximum)
+    {
+	client->errorValue = stuff->op;
+	return BadValue;
+    }
+    VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess, 
+		    RenderErrBase + BadPicture);
+    VERIFY_ALPHA (pMask, stuff->mask, client, SecurityReadAccess, 
+		  RenderErrBase + BadPicture);
+    VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, 
+		    RenderErrBase + BadPicture);
+    if (pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen ||
+	(pMask && pSrc->pDrawable->pScreen != pMask->pDrawable->pScreen))
+	return BadMatch;
+    CompositePicture (stuff->op,
+		      pSrc,
+		      pMask,
+		      pDst,
+		      stuff->xSrc,
+		      stuff->ySrc,
+		      stuff->xMask,
+		      stuff->yMask,
+		      stuff->xDst,
+		      stuff->yDst,
+		      stuff->width,
+		      stuff->height);
+    return Success;
+}
+
+static int
+ProcRenderScale (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderTrapezoids (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderTriangles (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderTriStrip (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderTriFan (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderColorTrapezoids (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderColorTriangles (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderTransform (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderCreateGlyphSet (ClientPtr client)
+{
+    GlyphSetPtr	    glyphSet;
+    PictFormatPtr   format;
+    int		    f;
+    REQUEST(xRenderCreateGlyphSetReq);
+
+    REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
+
+    LEGAL_NEW_RESOURCE(stuff->gsid, client);
+    format = (PictFormatPtr) SecurityLookupIDByType (client,
+						     stuff->format,
+						     PictFormatType,
+						     SecurityReadAccess);
+    if (!format)
+    {
+	client->errorValue = stuff->format;
+	return RenderErrBase + BadPictFormat;
+    }
+    switch (format->depth) {
+    case 1:
+	f = GlyphFormat1;
+	break;
+    case 4:
+	f = GlyphFormat4;
+	break;
+    case 8:
+	f = GlyphFormat8;
+	break;
+    case 16:
+	f = GlyphFormat16;
+	break;
+    case 32:
+	f = GlyphFormat32;
+	break;
+    default:
+	return BadMatch;
+    }
+    if (format->type != PictTypeDirect)
+	return BadMatch;
+    glyphSet = AllocateGlyphSet (f, format);
+    if (!glyphSet)
+	return BadAlloc;
+    if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
+	return BadAlloc;
+    return Success;
+}
+
+static int
+ProcRenderReferenceGlyphSet (ClientPtr client)
+{
+    GlyphSetPtr     glyphSet;
+    REQUEST(xRenderReferenceGlyphSetReq);
+
+    REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
+
+    LEGAL_NEW_RESOURCE(stuff->gsid, client);
+
+    glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+						     stuff->existing,
+						     GlyphSetType,
+						     SecurityWriteAccess);
+    if (!glyphSet)
+    {
+	client->errorValue = stuff->existing;
+	return RenderErrBase + BadGlyphSet;
+    }
+    glyphSet->refcnt++;
+    if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
+	return BadAlloc;
+    return client->noClientException;
+}
+
+#define NLOCALDELTA	64
+#define NLOCALGLYPH	256
+
+static int
+ProcRenderFreeGlyphSet (ClientPtr client)
+{
+    GlyphSetPtr     glyphSet;
+    REQUEST(xRenderFreeGlyphSetReq);
+
+    REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
+    glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+						     stuff->glyphset,
+						     GlyphSetType,
+						     SecurityDestroyAccess);
+    if (!glyphSet)
+    {
+	client->errorValue = stuff->glyphset;
+	return RenderErrBase + BadGlyphSet;
+    }
+    FreeResource (stuff->glyphset, RT_NONE);
+    return client->noClientException;
+}
+
+typedef struct _GlyphNew {
+    Glyph	id;
+    GlyphPtr    glyph;
+} GlyphNewRec, *GlyphNewPtr;
+
+static int
+ProcRenderAddGlyphs (ClientPtr client)
+{
+    GlyphSetPtr     glyphSet;
+    REQUEST(xRenderAddGlyphsReq);
+    GlyphNewRec	    glyphsLocal[NLOCALGLYPH];
+    GlyphNewPtr	    glyphsBase, glyphs;
+    GlyphPtr	    glyph;
+    int		    remain, nglyphs;
+    CARD32	    *gids;
+    xGlyphInfo	    *gi;
+    CARD8	    *bits;
+    int		    size;
+    int		    err = BadAlloc;
+
+    REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
+    glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+						     stuff->glyphset,
+						     GlyphSetType,
+						     SecurityWriteAccess);
+    if (!glyphSet)
+    {
+	client->errorValue = stuff->glyphset;
+	return RenderErrBase + BadGlyphSet;
+    }
+
+    nglyphs = stuff->nglyphs;
+    if (nglyphs <= NLOCALGLYPH)
+	glyphsBase = glyphsLocal;
+    else
+    {
+	glyphsBase = (GlyphNewPtr) ALLOCATE_LOCAL (nglyphs * sizeof (GlyphNewRec));
+	if (!glyphsBase)
+	    return BadAlloc;
+    }
+
+    remain = (stuff->length << 2) - sizeof (xRenderAddGlyphsReq);
+
+    glyphs = glyphsBase;
+
+    gids = (CARD32 *) (stuff + 1);
+    gi = (xGlyphInfo *) (gids + nglyphs);
+    bits = (CARD8 *) (gi + nglyphs);
+    remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs;
+    while (remain >= 0 && nglyphs)
+    {
+	glyph = AllocateGlyph (gi, glyphSet->fdepth);
+	if (!glyph)
+	{
+	    err = BadAlloc;
+	    goto bail;
+	}
+	
+	glyphs->glyph = glyph;
+	glyphs->id = *gids;	
+	
+	size = glyph->size - sizeof (xGlyphInfo);
+	if (remain < size)
+	    break;
+	memcpy ((CARD8 *) (glyph + 1), bits, size);
+	
+	if (size & 3)
+	    size += 4 - (size & 3);
+	bits += size;
+	remain -= size;
+	gi++;
+	gids++;
+	glyphs++;
+	nglyphs--;
+    }
+    if (nglyphs || remain)
+    {
+	err = BadLength;
+	goto bail;
+    }
+    nglyphs = stuff->nglyphs;
+    if (!ResizeGlyphSet (glyphSet, nglyphs))
+    {
+	err = BadAlloc;
+	goto bail;
+    }
+    glyphs = glyphsBase;
+    while (nglyphs--)
+	AddGlyph (glyphSet, glyphs->glyph, glyphs->id);
+
+    if (glyphsBase != glyphsLocal)
+	DEALLOCATE_LOCAL (glyphsBase);
+    return client->noClientException;
+bail:
+    while (glyphs != glyphsBase)
+    {
+	--glyphs;
+	xfree (glyphs->glyph);
+    }
+    if (glyphsBase != glyphsLocal)
+	DEALLOCATE_LOCAL (glyphsBase);
+    return err;
+}
+
+static int
+ProcRenderAddGlyphsFromPicture (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderFreeGlyphs (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+ProcRenderCompositeGlyphs (ClientPtr client, int size)
+{
+    GlyphSetPtr     glyphSet;
+    GlyphSet	    gs;
+    PicturePtr      pSrc, pDst;
+    PictFormatPtr   pFormat;
+    GlyphListRec    listsLocal[NLOCALDELTA];
+    GlyphListPtr    lists, listsBase;
+    GlyphPtr	    glyphsLocal[NLOCALGLYPH];
+    Glyph	    glyph;
+    GlyphPtr	    *glyphs, *glyphsBase;
+    xGlyphElt	    *elt;
+    CARD8	    *buffer, *end;
+    int		    nglyph;
+    int		    nlist;
+    int		    space;
+    int		    n;
+    
+    REQUEST(xRenderCompositeGlyphsReq);
+
+    REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq);
+
+    VERIFY_PICTURE (pSrc, stuff->src, client, SecurityReadAccess,
+		    RenderErrBase + BadPicture);
+    VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess,
+		    RenderErrBase + BadPicture);
+    if (pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen)
+	return BadMatch;
+    if (stuff->maskFormat)
+    {
+	pFormat = (PictFormatPtr) SecurityLookupIDByType (client,
+							  stuff->maskFormat,
+							  PictFormatType,
+							  SecurityReadAccess);
+	if (!pFormat)
+	{
+	    client->errorValue = stuff->maskFormat;
+	    return RenderErrBase + BadPictFormat;
+	}
+    }
+    else
+	pFormat = 0;
+
+    glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+						     stuff->glyphset,
+						     GlyphSetType,
+						     SecurityReadAccess);
+    if (!glyphSet)
+    {
+	client->errorValue = stuff->glyphset;
+	return RenderErrBase + BadGlyphSet;
+    }
+
+    buffer = (CARD8 *) (stuff + 1);
+    end = (CARD8 *) stuff + (stuff->length << 2);
+    nglyph = 0;
+    nlist = 0;
+    while (buffer + sizeof (xGlyphElt) < end)
+    {
+	elt = (xGlyphElt *) buffer;
+	buffer += sizeof (xGlyphElt);
+	
+	if (elt->len == 0xff)
+	{
+	    buffer += 4;
+	}
+	else
+	{
+	    nlist++;
+	    nglyph += elt->len;
+	    space = size * elt->len;
+	    if (space & 3)
+		space += 4 - (space & 3);
+	    buffer += space;
+	}
+    }
+    if (nglyph <= NLOCALGLYPH)
+	glyphsBase = glyphsLocal;
+    else
+    {
+	glyphsBase = (GlyphPtr *) ALLOCATE_LOCAL (nglyph * sizeof (GlyphPtr));
+	if (!glyphsBase)
+	    return BadAlloc;
+    }
+    if (nlist <= NLOCALDELTA)
+	listsBase = listsLocal;
+    else
+    {
+	listsBase = (GlyphListPtr) ALLOCATE_LOCAL (nlist * sizeof (GlyphListRec));
+	if (!listsBase)
+	    return BadAlloc;
+    }
+    buffer = (CARD8 *) (stuff + 1);
+    glyphs = glyphsBase;
+    lists = listsBase;
+    while (buffer + sizeof (xGlyphElt) < end)
+    {
+	elt = (xGlyphElt *) buffer;
+	buffer += sizeof (xGlyphElt);
+	
+	if (elt->len == 0xff)
+	{
+	    if (buffer + sizeof (GlyphSet) < end)
+	    {
+		gs = *(GlyphSet *) buffer;
+		glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
+								 gs,
+								 GlyphSetType,
+								 SecurityReadAccess);
+		if (!glyphSet)
+		{
+		    client->errorValue = gs;
+		    if (glyphsBase != glyphsLocal)
+			DEALLOCATE_LOCAL (glyphsBase);
+		    if (listsBase != listsLocal)
+			DEALLOCATE_LOCAL (listsBase);
+		    return RenderErrBase + BadGlyphSet;
+		}
+	    }
+	    buffer += 4;
+	}
+	else
+	{
+	    lists->xOff = elt->deltax;
+	    lists->yOff = elt->deltay;
+	    lists->format = glyphSet->format;
+	    lists->len = 0;
+	    n = elt->len;
+	    while (n--)
+	    {
+		if (buffer + size <= end)
+		{
+		    switch (size) {
+		    case 1:
+			glyph = *((CARD8 *)buffer); break;
+		    case 2:
+			glyph = *((CARD16 *)buffer); break;
+		    case 4:
+		    default:
+			glyph = *((CARD32 *)buffer); break;
+		    }
+		    if ((*glyphs = FindGlyph (glyphSet, glyph)))
+		    {
+			lists->len++;
+			glyphs++;
+		    }
+		}
+		buffer += size;
+	    }
+	    space = size * elt->len;
+	    if (space & 3)
+		buffer += 4 - (space & 3);
+	    lists++;
+	}
+    }
+    if (buffer > end)
+	return BadLength;
+
+    CompositeGlyphs (stuff->op,
+		     pSrc,
+		     pDst,
+		     pFormat,
+		     stuff->xSrc,
+		     stuff->ySrc,
+		     nlist,
+		     listsBase,
+		     glyphsBase);
+
+    if (glyphsBase != glyphsLocal)
+	DEALLOCATE_LOCAL (glyphsBase);
+    if (listsBase != listsLocal)
+	DEALLOCATE_LOCAL (listsBase);
+    
+    return client->noClientException;
+}
+
+static int
+ProcRenderFillRectangles (ClientPtr client)
+{
+    PicturePtr	    pDst;
+    int             things;
+    REQUEST(xRenderFillRectanglesReq);
+    
+    if (stuff->op > PictOpMaximum)
+    {
+	client->errorValue = stuff->op;
+	return BadValue;
+    }
+    VERIFY_PICTURE (pDst, stuff->dst, client, SecurityWriteAccess, 
+		    RenderErrBase + BadPicture);
+    
+    things = (client->req_len << 2) - sizeof(xRenderFillRectanglesReq);
+    if (things & 4)
+	return(BadLength);
+    things >>= 3;
+    
+    CompositeRects (stuff->op,
+		    pDst,
+		    &stuff->color,
+		    things,
+		    (xRectangle *) &stuff[1]);
+    
+    return client->noClientException;
+}
+
+static int
+ProcRenderDispatch (ClientPtr client)
+{
+    REQUEST(xReq);
+    switch (stuff->data)
+    {
+    case X_RenderQueryVersion:
+	return ProcRenderQueryVersion(client);
+    case X_RenderQueryPictFormats:
+	return ProcRenderQueryPictFormats(client);
+    case X_RenderQueryPictIndexValues:
+	return ProcRenderQueryPictIndexValues(client);
+    case X_RenderQueryDithers:
+	return ProcRenderQueryDithers(client);
+    case X_RenderCreatePicture:
+	return ProcRenderCreatePicture(client);
+    case X_RenderChangePicture:
+	return ProcRenderChangePicture(client);
+    case X_RenderSetPictureClipRectangles:
+	return ProcRenderSetPictureClipRectangles(client);
+    case X_RenderFreePicture:
+	return ProcRenderFreePicture(client);
+    case X_RenderComposite:
+	return ProcRenderComposite(client);
+    case X_RenderScale:
+	return ProcRenderScale(client);
+    case X_RenderTrapezoids:
+	return ProcRenderTrapezoids(client);
+    case X_RenderTriangles:
+	return ProcRenderTriangles(client);
+    case X_RenderTriStrip:
+	return ProcRenderTriStrip(client);
+    case X_RenderTriFan:
+	return ProcRenderTriFan(client);
+    case X_RenderColorTrapezoids:
+	return ProcRenderColorTrapezoids(client);
+    case X_RenderColorTriangles:
+	return ProcRenderColorTriangles(client);
+    case X_RenderTransform:
+	return ProcRenderTransform(client);
+    case X_RenderCreateGlyphSet:
+	return ProcRenderCreateGlyphSet(client);
+    case X_RenderReferenceGlyphSet:
+	return ProcRenderReferenceGlyphSet(client);
+    case X_RenderFreeGlyphSet:
+	return ProcRenderFreeGlyphSet(client);
+    case X_RenderAddGlyphs:
+	return ProcRenderAddGlyphs(client);
+    case X_RenderAddGlyphsFromPicture:
+	return ProcRenderAddGlyphsFromPicture(client);
+    case X_RenderFreeGlyphs:
+	return ProcRenderFreeGlyphs(client);
+    case X_RenderCompositeGlyphs8:
+	return ProcRenderCompositeGlyphs(client, 1);
+    case X_RenderCompositeGlyphs16:
+	return ProcRenderCompositeGlyphs(client, 2);
+    case X_RenderCompositeGlyphs32:
+	return ProcRenderCompositeGlyphs(client, 4);
+    case X_RenderFillRectangles:
+	return ProcRenderFillRectangles(client);
+    default:
+	return BadRequest;
+    }
+}
+
+static int
+SProcRenderQueryVersion (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderQueryVersionReq);
+
+    swaps(&stuff->length, n);
+    swapl(&stuff->majorVersion, n);
+    swapl(&stuff->minorVersion, n);
+    return ProcRenderQueryVersion(client);
+}
+
+static int
+SProcRenderQueryPictFormats (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderQueryPictFormatsReq);
+    swaps(&stuff->length, n);
+    return ProcRenderQueryPictFormats (client);
+}
+
+static int
+SProcRenderQueryPictIndexValues (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderQueryDithers (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderCreatePicture (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderCreatePictureReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->pid, n);
+    swapl(&stuff->drawable, n);
+    swapl(&stuff->format, n);
+    swapl(&stuff->mask, n);
+    SwapRestL(stuff);
+    return ProcRenderCreatePicture (client);
+}
+
+static int
+SProcRenderChangePicture (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderChangePictureReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->picture, n);
+    swapl(&stuff->mask, n);
+    SwapRestL(stuff);
+    return ProcRenderChangePicture (client);
+}
+
+static int
+SProcRenderSetPictureClipRectangles (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderSetPictureClipRectanglesReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->picture, n);
+    SwapRestS(stuff);
+    return ProcRenderSetPictureClipRectangles (client);
+}
+
+static int
+SProcRenderFreePicture (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderFreePictureReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->picture, n);
+    return ProcRenderFreePicture (client);
+}
+
+static int
+SProcRenderComposite (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderCompositeReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->src, n);
+    swapl(&stuff->mask, n);
+    swapl(&stuff->dst, n);
+    swaps(&stuff->xSrc, n);
+    swaps(&stuff->ySrc, n);
+    swaps(&stuff->xMask, n);
+    swaps(&stuff->yMask, n);
+    swaps(&stuff->xDst, n);
+    swaps(&stuff->yDst, n);
+    swaps(&stuff->width, n);
+    swaps(&stuff->height, n);
+    return ProcRenderComposite (client);
+}
+
+static int
+SProcRenderScale (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderScaleReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->src, n);
+    swapl(&stuff->dst, n);
+    swapl(&stuff->colorScale, n);
+    swapl(&stuff->alphaScale, n);
+    swaps(&stuff->xSrc, n);
+    swaps(&stuff->ySrc, n);
+    swaps(&stuff->xDst, n);
+    swaps(&stuff->yDst, n);
+    swaps(&stuff->width, n);
+    swaps(&stuff->height, n);
+    return ProcRenderScale (client);
+}
+
+static int
+SProcRenderTrapezoids (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderTriangles (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderTriStrip (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderTriFan (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderColorTrapezoids (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderColorTriangles (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderTransform (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderCreateGlyphSet (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderCreateGlyphSetReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->gsid, n);
+    swapl(&stuff->format, n);
+    return ProcRenderCreateGlyphSet (client);
+}
+
+static int
+SProcRenderReferenceGlyphSet (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderReferenceGlyphSetReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->gsid, n);
+    swapl(&stuff->existing, n);
+    return ProcRenderReferenceGlyphSet  (client);
+}
+
+static int
+SProcRenderFreeGlyphSet (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderFreeGlyphSetReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->glyphset, n);
+    return ProcRenderFreeGlyphSet (client);
+}
+
+static int
+SProcRenderAddGlyphs (ClientPtr client)
+{
+    register int n;
+    register int i;
+    CARD32  *gids;
+    void    *end;
+    xGlyphInfo *gi;
+    REQUEST(xRenderAddGlyphsReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->glyphset, n);
+    swapl(&stuff->nglyphs, n);
+    if (stuff->nglyphs & 0xe0000000)
+	return BadLength;
+    end = (CARD8 *) stuff + (stuff->length << 2);
+    gids = (CARD32 *) (stuff + 1);
+    gi = (xGlyphInfo *) (gids + stuff->nglyphs);
+    if ((char *) end - (char *) (gids + stuff->nglyphs) < 0)
+	return BadLength;
+    if ((char *) end - (char *) (gi + stuff->nglyphs) < 0)
+	return BadLength;
+    for (i = 0; i < stuff->nglyphs; i++)
+    {
+	swapl (&gids[i], n);
+	swaps (&gi[i].width, n);
+	swaps (&gi[i].height, n);
+	swaps (&gi[i].x, n);
+	swaps (&gi[i].y, n);
+	swaps (&gi[i].xOff, n);
+	swaps (&gi[i].yOff, n);
+    }
+    return ProcRenderAddGlyphs (client);
+}
+
+static int
+SProcRenderAddGlyphsFromPicture (ClientPtr client)
+{
+    return BadImplementation;
+}
+
+static int
+SProcRenderFreeGlyphs (ClientPtr client)
+{
+    register int n;
+    REQUEST(xRenderFreeGlyphsReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->glyphset, n);
+    SwapRestL(stuff);
+    return ProcRenderFreeGlyphs (client);
+}
+
+static int
+SProcRenderCompositeGlyphs (ClientPtr client, int size)
+{
+    register int n;
+    xGlyphElt	*elt;
+    CARD8	*buffer;
+    CARD8	*end;
+    int		space;
+    
+    REQUEST(xRenderCompositeGlyphsReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->src, n);
+    swapl(&stuff->dst, n);
+    swapl(&stuff->maskFormat, n);
+    swapl(&stuff->glyphset, n);
+    swaps(&stuff->xSrc, n);
+    swaps(&stuff->ySrc, n);
+    buffer = (CARD8 *) (stuff + 1);
+    end = (CARD8 *) stuff + (stuff->length << 2);
+    while (buffer + sizeof (xGlyphElt) < end)
+    {
+	elt = (xGlyphElt *) buffer;
+	buffer += sizeof (xGlyphElt);
+	
+	swaps (&elt->deltax, n);
+	swaps (&elt->deltay, n);
+	
+	if (elt->len == 0xff)
+	{
+	    buffer += 4;
+	}
+	else
+	{
+	    space = size * elt->len;
+	    if (space & 3)
+		space += 4 - (space & 3);
+	    buffer += space;
+	}
+    }
+    return ProcRenderCompositeGlyphs (client, size);
+}
+
+static int
+SProcRenderFillRectangles (ClientPtr client)
+{
+    register int n;
+    
+    REQUEST(xRenderFillRectanglesReq);
+    swaps(&stuff->length, n);
+    swapl(&stuff->dst, n);
+    swaps(&stuff->color.red, n);
+    swaps(&stuff->color.green, n);
+    swaps(&stuff->color.blue, n);
+    swaps(&stuff->color.alpha, n);
+    SwapRestS(stuff);
+    return ProcRenderFillRectangles (client);
+}
+    
+static int
+SProcRenderDispatch (ClientPtr client)
+{
+    REQUEST(xReq);
+    switch (stuff->data)
+    {
+    case X_RenderQueryVersion:
+	return SProcRenderQueryVersion(client);
+    case X_RenderQueryPictFormats:
+	return SProcRenderQueryPictFormats(client);
+    case X_RenderQueryPictIndexValues:
+	return SProcRenderQueryPictIndexValues(client);
+    case X_RenderQueryDithers:
+	return SProcRenderQueryDithers(client);
+    case X_RenderCreatePicture:
+	return SProcRenderCreatePicture(client);
+    case X_RenderChangePicture:
+	return SProcRenderChangePicture(client);
+    case X_RenderSetPictureClipRectangles:
+	return SProcRenderSetPictureClipRectangles(client);
+    case X_RenderFreePicture:
+	return SProcRenderFreePicture(client);
+    case X_RenderComposite:
+	return SProcRenderComposite(client);
+    case X_RenderScale:
+	return SProcRenderScale(client);
+    case X_RenderTrapezoids:
+	return SProcRenderTrapezoids(client);
+    case X_RenderTriangles:
+	return SProcRenderTriangles(client);
+    case X_RenderTriStrip:
+	return SProcRenderTriStrip(client);
+    case X_RenderTriFan:
+	return SProcRenderTriFan(client);
+    case X_RenderColorTrapezoids:
+	return SProcRenderColorTrapezoids(client);
+    case X_RenderColorTriangles:
+	return SProcRenderColorTriangles(client);
+    case X_RenderTransform:
+	return SProcRenderTransform(client);
+    case X_RenderCreateGlyphSet:
+	return SProcRenderCreateGlyphSet(client);
+    case X_RenderReferenceGlyphSet:
+	return SProcRenderReferenceGlyphSet(client);
+    case X_RenderFreeGlyphSet:
+	return SProcRenderFreeGlyphSet(client);
+    case X_RenderAddGlyphs:
+	return SProcRenderAddGlyphs(client);
+    case X_RenderAddGlyphsFromPicture:
+	return SProcRenderAddGlyphsFromPicture(client);
+    case X_RenderFreeGlyphs:
+	return SProcRenderFreeGlyphs(client);
+    case X_RenderCompositeGlyphs8:
+	return SProcRenderCompositeGlyphs(client, 1);
+    case X_RenderCompositeGlyphs16:
+	return SProcRenderCompositeGlyphs(client, 2);
+    case X_RenderCompositeGlyphs32:
+	return SProcRenderCompositeGlyphs(client, 4);
+    case X_RenderFillRectangles:
+	return SProcRenderFillRectangles(client);
+    default:
+	return BadRequest;
+    }
+}
Index: xc/programs/Xserver/xkb/Imakefile
diff -u xc/programs/Xserver/xkb/Imakefile:3.13 xc/programs/Xserver/xkb/Imakefile:3.14
--- xc/programs/Xserver/xkb/Imakefile:3.13	Tue Jun 13 19:15:52 2000
+++ xc/programs/Xserver/xkb/Imakefile	Fri Oct 20 10:59:09 2000
@@ -1,5 +1,5 @@
 XCOMM $TOG: Imakefile /main/12 1997/07/16 14:51:50 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/xkb/Imakefile,v 3.13 2000/06/13 23:15:52 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/xkb/Imakefile,v 3.14 2000/10/20 14:59:09 alanh Exp $
 #define SGIHyperOpt
 #include <Server.tmpl>
 
@@ -66,5 +66,7 @@
 LinkSourceFile(XKBMAlloc.c,$(XLIBSRC))
 LinkSourceFile(XKBAlloc.c,$(XLIBSRC))
 LinkSourceFile(XKBGAlloc.c,$(XLIBSRC))
+
+LinkConfDirectory(xkb,.,xkb,.)
 
 DependTarget()
Index: xc/programs/Xserver/xkb/ddxCtrls.c
diff -u xc/programs/Xserver/xkb/ddxCtrls.c:1.1.1.4 xc/programs/Xserver/xkb/ddxCtrls.c:1.2
--- xc/programs/Xserver/xkb/ddxCtrls.c:1.1.1.4	Sun Feb  4 02:39:21 1996
+++ xc/programs/Xserver/xkb/ddxCtrls.c	Sat Aug 26 11:11:27 2000
@@ -24,6 +24,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxCtrls.c,v 1.2 2000/08/26 15:11:27 dawes Exp $ */
 
 #include <stdio.h>
 #define	NEED_EVENTS 1
@@ -104,7 +105,8 @@
     XkbControlsPtr new;
 #endif
 {
-unsigned	changed;
+unsigned	changed, i;
+unsigned 	char *rep_old, *rep_new, *rep_fb;
 
     changed= new->enabled_ctrls^old->enabled_ctrls;
 #ifdef NOTDEF
@@ -124,6 +126,16 @@
 	}
     }
 #endif
+    for (rep_old = old->per_key_repeat,
+         rep_new = new->per_key_repeat,
+	 rep_fb  = dev->kbdfeed->ctrl.autoRepeats,
+         i = 0; i < XkbPerKeyBitArraySize; i++) {
+        if (rep_old[i] != rep_new[i]) {
+            rep_fb[i] = rep_new[i];
+            changed &= XkbPerKeyRepeatMask;
+        }
+    }
+
     if (changed&XkbPerKeyRepeatMask) {
 	if (dev->kbdfeed->CtrlProc)
 	    (*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl);
Index: xc/programs/Xserver/xkb/ddxLoad.c
diff -u xc/programs/Xserver/xkb/ddxLoad.c:3.25 xc/programs/Xserver/xkb/ddxLoad.c:3.26
--- xc/programs/Xserver/xkb/ddxLoad.c:3.25	Thu Jun 15 18:04:13 2000
+++ xc/programs/Xserver/xkb/ddxLoad.c	Tue Nov 14 13:20:38 2000
@@ -24,7 +24,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
-/* $XFree86: xc/programs/Xserver/xkb/ddxLoad.c,v 3.25 2000/06/15 22:04:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/ddxLoad.c,v 3.26 2000/11/14 18:20:38 dawes Exp $ */
 
 #include <stdio.h>
 #include <ctype.h>
@@ -41,7 +41,7 @@
 #include "XKBsrv.h"
 #include "XI.h"
 
-#if defined(CSRG_BASED) || defined(linux) || defined(__sgi) || defined(AIXV3) || defined(__osf__)
+#if defined(CSRG_BASED) || defined(linux) || defined(__sgi) || defined(AIXV3) || defined(__osf__) || defined(__GNU__)
 #include <paths.h>
 #endif
 
Index: xc/programs/Xserver/xkb/xkbAccessX.c
diff -u xc/programs/Xserver/xkb/xkbAccessX.c:1.4 xc/programs/Xserver/xkb/xkbAccessX.c:1.5
--- xc/programs/Xserver/xkb/xkbAccessX.c:1.4	Sun Dec 26 19:40:00 1999
+++ xc/programs/Xserver/xkb/xkbAccessX.c	Sat Aug 26 11:11:27 2000
@@ -24,7 +24,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
-/* $XFree86: xc/programs/Xserver/xkb/xkbAccessX.c,v 1.4 1999/12/27 00:40:00 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkbAccessX.c,v 1.5 2000/08/26 15:11:27 dawes Exp $ */
 
 #include <stdio.h>
 #include <math.h>
@@ -609,6 +609,11 @@
 	if (XkbAX_NeedFeedback(ctrls,XkbAX_BKRejectFBMask))
 	    XkbDDXAccessXBeep(keybd,_BEEP_BOUNCE_REJECT,XkbBounceKeysMask);
 	ignoreKeyEvent = TRUE;
+    }
+
+    if ((ctrls->enabled_ctrls & XkbMouseKeysAccelMask) && 
+					(key == xkbi->mouseKey)) {
+        ignoreKeyEvent = TRUE;
     }
 
     /* Start repeating if necessary.  Stop autorepeating if the user
Index: xc/programs/Xserver/xkb/xkbEvents.c
diff -u xc/programs/Xserver/xkb/xkbEvents.c:3.5 xc/programs/Xserver/xkb/xkbEvents.c:3.6
--- xc/programs/Xserver/xkb/xkbEvents.c:3.5	Tue Jun 13 19:15:52 2000
+++ xc/programs/Xserver/xkb/xkbEvents.c	Sat Aug 26 11:11:28 2000
@@ -24,7 +24,7 @@
 THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
-/* $XFree86: xc/programs/Xserver/xkb/xkbEvents.c,v 3.5 2000/06/13 23:15:52 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkbEvents.c,v 3.6 2000/08/26 15:11:28 dawes Exp $ */
 
 #include <stdio.h>
 #define NEED_EVENTS 1
@@ -261,6 +261,10 @@
 	changedControls|= XkbMouseKeysAccelMask;
     if (old->ax_options!=new->ax_options)
 	changedControls|= XkbAccessXKeysMask;
+    if ((old->ax_options^new->ax_options) & XkbAX_SKOptionsMask)
+	changedControls|= XkbStickyKeysMask;
+    if ((old->ax_options^new->ax_options) & XkbAX_FBOptionsMask)
+	changedControls|= XkbAccessXFeedbackMask;
     if ((old->ax_timeout!=new->ax_timeout)||
 	(old->axt_ctrls_mask!=new->axt_ctrls_mask)||
 	(old->axt_ctrls_values!=new->axt_ctrls_values)||
Index: xc/programs/Xserver/xkb/xkbUtils.c
diff -u xc/programs/Xserver/xkb/xkbUtils.c:3.10 xc/programs/Xserver/xkb/xkbUtils.c:3.11
--- xc/programs/Xserver/xkb/xkbUtils.c:3.10	Thu Jul 10 04:17:47 1997
+++ xc/programs/Xserver/xkb/xkbUtils.c	Tue Oct 24 18:45:14 2000
@@ -1,5 +1,5 @@
 /* $XConsortium: xkbUtils.c /main/24 1996/09/28 17:16:26 rws $ */
-/* $XFree86: xc/programs/Xserver/xkb/xkbUtils.c,v 3.10 1997/07/10 08:17:47 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkbUtils.c,v 3.11 2000/10/24 22:45:14 dawes Exp $ */
 /************************************************************
 Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
 
@@ -855,7 +855,7 @@
 {
 XkbStatePtr	state= &xkbi->state;
 XkbControlsPtr	ctrls= xkbi->desc->ctrls;
-unsigned	grp;
+char		grp;
 
     state->mods= (state->base_mods|state->latched_mods);
     state->mods|= state->locked_mods;
@@ -866,11 +866,11 @@
 
 
     grp= state->locked_group;
-    if (grp>=ctrls->num_groups)
+    if ((grp>=ctrls->num_groups) || (grp<0))
 	state->locked_group= XkbAdjustGroup(grp,ctrls);
 
     grp= state->locked_group+state->base_group+state->latched_group;
-    if (grp>=ctrls->num_groups)
+    if ((grp>=ctrls->num_groups) || (grp<0))
 	 state->group= XkbAdjustGroup(grp,ctrls);
     else state->group= grp;
     XkbComputeCompatState(xkbi);
Index: xc/programs/glxinfo/Imakefile
diff -u /dev/null xc/programs/glxinfo/Imakefile:1.1
--- /dev/null	Mon Dec 18 14:33:37 2000
+++ xc/programs/glxinfo/Imakefile	Fri Sep 22 07:35:46 2000
@@ -0,0 +1,57 @@
+XCOMM $XConsortium: Imakefile /main/7 1995/12/04 15:10:00 dpw $
+XCOMM $XFree86: xc/programs/glxinfo/Imakefile,v 1.1 2000/09/22 11:35:46 alanh Exp $
+        DEPLIBS = $(DEPXTESTLIB) $(DEPXIELIB) $(DEPXLIB) $(DEPXKBFILELIB) $(DEPXF86LIBS) $(DEPXILIB)
+#ifndef OS2Architecture
+LOCAL_LIBRARIES = $(GLXLIB) $(XLIB) 
+#else
+LOCAL_LIBRARIES = $(GLXLIB) $(XLIB)
+#endif
+  SYS_LIBRARIES = MathLibrary
+
+
+#if HasShm
+        SHMDEFINES = -DMITSHM
+#endif
+
+#if BuildXF86VidModeExt
+    VIDMODEDEFINES = -DXF86VIDMODE
+    VIDMODEDEPLIBS = $(DEPXXF86VMLIB)
+       VIDMODELIBS = $(XXF86VMLIB)
+#endif
+
+#if BuildXF86DGA
+        DGADEFINES = -DXFreeXDGA
+        DGADEPLIBS = $(DEPXXF86DGALIB)
+           DGALIBS = $(XXF86DGALIB)
+#endif
+
+#if BuildXF86MiscExt
+   XF86MISCDEFINES = -DXF86MISC
+   XF86MISCDEPLIBS = $(DEPXXF86MISCLIB)
+      XF86MISCLIBS = $(XXF86MISCLIB)
+#endif
+
+#if BuildXInputExt
+     XINPUTDEFINES = -DXINPUT
+     XINPUTDEPLIBS = $(DEPXILIB)
+        XINPUTLIBS = $(XILIB)
+#endif
+
+       XF86DEFINES = $(VIDMODEDEFINES) $(DGADEFINES) $(XF86MISCDEFINES)
+       DEPXF86LIBS = $(VIDMODEDEPLIBS) $(DGADEPLIBS) $(XF86MISCDEPLIBS)
+          XF86LIBS = $(VIDMODELIBS) $(DGALIBS) $(XF86MISCLIBS)
+
+#if BuildMultibuffer
+   MULTIBUFDEFINES = -DMULTIBUFFER
+#endif
+
+#if BuildXKB
+        XKBDEFINES = -DXKB
+#endif
+
+   OTHERDEFINES = $(SHMDEFINES) $(XKBDEFINES) $(XINPUTDEFINES) \
+			$(MULTIBUFDEFINES)
+
+        DEFINES = $(OTHERDEFINES) $(XF86DEFINES)
+
+SimpleProgramTarget(glxinfo)
Index: xc/programs/glxinfo/glxinfo.c
diff -u /dev/null xc/programs/glxinfo/glxinfo.c:1.2
--- /dev/null	Mon Dec 18 14:33:37 2000
+++ xc/programs/glxinfo/glxinfo.c	Tue Sep 26 11:57:23 2000
@@ -0,0 +1,542 @@
+/* $Id: glxinfo.c,v 1.10 2000/05/08 14:53:57 brianp Exp $ */
+
+/*
+ * Copyright (C) 1999  Brian Paul   All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/glxinfo/glxinfo.c,v 1.2 2000/09/26 15:57:23 tsi Exp $ */
+
+/*
+ * This program is a work-alike of the IRIX glxinfo program.
+ * Command line options:
+ *  -t                     print wide table
+ *  -v                     print verbose information
+ *  -display DisplayName   specify the X display to interogate
+ *
+ * Brian Paul  26 January 2000
+ * Mark Paton  09 September 2000 - Minor mods for XFree86
+ */
+
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/gl.h>
+
+/* This is commented out because at this time the GLU library
+ * is not part of XFree86.
+ * #include <GL/glu.h>
+ * */
+
+#include <GL/glx.h>
+#include <stdio.h>
+#include <string.h>
+
+
+typedef enum
+{
+   Normal,
+   Wide,
+   Verbose
+} InfoMode;
+
+
+struct visual_attribs
+{
+   /* X visual attribs */
+   int id;
+   int klass;
+   int depth;
+   int redMask, greenMask, blueMask;
+   int colormapSize;
+   int bitsPerRGB;
+
+   /* GL visual attribs */
+   int supportsGL;
+   int transparent;
+   int bufferSize;
+   int level;
+   int rgba;
+   int doubleBuffer;
+   int stereo;
+   int auxBuffers;
+   int redSize, greenSize, blueSize, alphaSize;
+   int depthSize;
+   int stencilSize;
+   int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize;
+   int numSamples, numMultisample;
+   int visualCaveat;
+};
+
+   
+/*
+ * Print a list of extensions, with word-wrapping.
+ */
+static void
+print_extension_list(const char *ext)
+{
+   const char *indentString = "    ";
+   const int indent = 4;
+   const int max = 79;
+   int width, i, j;
+
+   if (!ext || !ext[0])
+      return;
+
+   width = indent;
+   printf(indentString);
+   i = j = 0;
+   while (1) {
+      if (ext[j] == ' ' || ext[j] == 0) {
+         /* found end of an extension name */
+         const int len = j - i;
+         if (width + len > max) {
+            /* start a new line */
+            printf("\n");
+            width = indent;
+            printf(indentString);
+         }
+         /* print the extension name between ext[i] and ext[j] */
+         while (i < j) {
+            printf("%c", ext[i]);
+            i++;
+         }
+         /* either we're all done, or we'll continue with next extension */
+         width += len + 1;
+         if (ext[j] == 0) {
+            break;
+         }
+         else {
+            i++;
+            j++;
+            if (ext[j] == 0)
+               break;
+            printf(", ");
+            width += 2;
+         }
+      }
+      j++;
+   }
+   printf("\n");
+}
+
+
+static void
+print_screen_info(Display *dpy, int scrnum)
+{
+   Window win;
+   int attribSingle[] = {
+      GLX_RGBA,
+      GLX_RED_SIZE, 1,
+      GLX_GREEN_SIZE, 1,
+      GLX_BLUE_SIZE, 1,
+      None };
+   int attribDouble[] = {
+      GLX_RGBA,
+      GLX_RED_SIZE, 1,
+      GLX_GREEN_SIZE, 1,
+      GLX_BLUE_SIZE, 1,
+      GLX_DOUBLEBUFFER,
+      None };
+
+   XSetWindowAttributes attr;
+   unsigned long mask;
+   Window root;
+   GLXContext ctx;
+   XVisualInfo *visinfo;
+   int width = 100, height = 100;
+
+   root = RootWindow(dpy, scrnum);
+
+   visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
+   if (!visinfo) {
+      visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
+      if (!visinfo) {
+         fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
+         return;
+      }
+   }
+
+   attr.background_pixel = 0;
+   attr.border_pixel = 0;
+   attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
+   attr.event_mask = StructureNotifyMask | ExposureMask;
+   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+   win = XCreateWindow(dpy, root, 0, 0, width, height,
+		       0, visinfo->depth, InputOutput,
+		       visinfo->visual, mask, &attr);
+
+   ctx = glXCreateContext( dpy, visinfo, NULL, True );
+   if (!ctx) {
+      fprintf(stderr, "Error: glXCreateContext failed\n");
+      XDestroyWindow(dpy, win);
+      return;
+   }
+
+   if (glXMakeCurrent(dpy, win, ctx)) {
+      const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR);
+      const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION);
+      const char *serverExtensions = glXQueryServerString(dpy, scrnum, GLX_EXTENSIONS);
+      const char *clientVendor = glXGetClientString(dpy, GLX_VENDOR);
+      const char *clientVersion = glXGetClientString(dpy, GLX_VERSION);
+      const char *clientExtensions = glXGetClientString(dpy, GLX_EXTENSIONS);
+      const char *glxExtensions = glXQueryExtensionsString(dpy, scrnum);
+      const char *glVendor = (const char *) glGetString(GL_VENDOR);
+      const char *glRenderer = (const char *) glGetString(GL_RENDERER);
+      const char *glVersion = (const char *) glGetString(GL_VERSION);
+      const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS);
+/*MP - Commented out glu stuff as the library is not currently part of XF86
+      const char *gluVersion = (const char *) gluGetString(GLU_VERSION);
+      const char *gluExtensions = (const char *) gluGetString(GLU_EXTENSIONS);
+*/
+      printf("display: %s  screen:%d\n", DisplayString(dpy), scrnum);
+      printf("direct rendering: %s\n", glXIsDirect(dpy, ctx) ? "Yes" : "No");
+      printf("server glx vendor string: %s\n", serverVendor);
+      printf("server glx version string: %s\n", serverVersion);
+      printf("server glx extensions:\n");
+      print_extension_list(serverExtensions);
+      printf("client glx vendor string: %s\n", clientVendor);
+      printf("client glx version string: %s\n", clientVersion);
+      printf("client glx extensions:\n");
+      print_extension_list(clientExtensions);
+      printf("GLX extensions:\n");
+      print_extension_list(glxExtensions);
+      printf("OpenGL vendor string: %s\n", glVendor);
+      printf("OpenGL renderer string: %s\n", glRenderer);
+      printf("OpenGL version string: %s\n", glVersion);
+      printf("OpenGL extensions:\n");
+      print_extension_list(glExtensions);
+/*
+      printf("glu version: %s\n", gluVersion);
+      printf("glu extensions:\n");
+      print_extension_list(gluExtensions);
+*/
+   }
+   else {
+      fprintf(stderr, "Error: glXMakeCurrent failed\n");
+   }
+
+   glXDestroyContext(dpy, ctx);
+   XDestroyWindow(dpy, win);
+}
+
+
+static const char *
+visual_class_name(int cls)
+{
+   switch (cls) {
+      case StaticColor:
+         return "StaticColor";
+      case PseudoColor:
+         return "PseudoColor";
+      case StaticGray:
+         return "StaticGray";
+      case GrayScale:
+         return "GrayScale";
+      case TrueColor:
+         return "TrueColor";
+      case DirectColor:
+         return "DirectColor";
+      default:
+         return "";
+   }
+}
+
+
+static const char *
+visual_class_abbrev(int cls)
+{
+   switch (cls) {
+      case StaticColor:
+         return "sc";
+      case PseudoColor:
+         return "pc";
+      case StaticGray:
+         return "sg";
+      case GrayScale:
+         return "gs";
+      case TrueColor:
+         return "tc";
+      case DirectColor:
+         return "dc";
+      default:
+         return "";
+   }
+}
+
+
+static void
+get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
+                   struct visual_attribs *attribs)
+{
+   const char *ext = glXQueryExtensionsString(dpy, vInfo->screen);
+
+   memset(attribs, 0, sizeof(struct visual_attribs));
+
+   attribs->id = vInfo->visualid;
+#if defined(__cplusplus) || defined(c_plusplus)
+   attribs->klass = vInfo->c_class;
+#else
+   attribs->klass = vInfo->class;
+#endif
+   attribs->depth = vInfo->depth;
+   attribs->redMask = vInfo->red_mask;
+   attribs->greenMask = vInfo->green_mask;
+   attribs->blueMask = vInfo->blue_mask;
+   attribs->colormapSize = vInfo->colormap_size;
+   attribs->bitsPerRGB = vInfo->bits_per_rgb;
+
+   if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0)
+      return;
+   glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize);
+   glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level);
+   glXGetConfig(dpy, vInfo, GLX_RGBA, &attribs->rgba);
+   glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
+   glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo);
+   glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers);
+   glXGetConfig(dpy, vInfo, GLX_RED_SIZE, &attribs->redSize);
+   glXGetConfig(dpy, vInfo, GLX_GREEN_SIZE, &attribs->greenSize);
+   glXGetConfig(dpy, vInfo, GLX_BLUE_SIZE, &attribs->blueSize);
+   glXGetConfig(dpy, vInfo, GLX_ALPHA_SIZE, &attribs->alphaSize);
+   glXGetConfig(dpy, vInfo, GLX_DEPTH_SIZE, &attribs->depthSize);
+   glXGetConfig(dpy, vInfo, GLX_STENCIL_SIZE, &attribs->stencilSize);
+   glXGetConfig(dpy, vInfo, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
+   glXGetConfig(dpy, vInfo, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
+   glXGetConfig(dpy, vInfo, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
+   glXGetConfig(dpy, vInfo, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
+
+   /* transparent pixel value not implemented yet */
+   attribs->transparent = 0;
+
+   /* multisample tests not implemented yet */
+   attribs->numSamples = 0;
+   attribs->numMultisample = 0;
+
+#if defined(GLX_EXT_visual_rating)
+   if (ext && strstr(ext, "GLX_EXT_visual_rating")) {
+      glXGetConfig(dpy, vInfo, GLX_VISUAL_CAVEAT_EXT, &attribs->visualCaveat);
+   }
+   else {
+      attribs->visualCaveat = GLX_NONE_EXT;
+   }
+#else
+   attribs->visualCaveat = 0;
+#endif
+}
+
+
+static void
+print_visual_attribs_verbose(const struct visual_attribs *attribs)
+{
+   printf("Visual ID: %x  depth=%d  class=%s\n",
+          attribs->id, attribs->depth, visual_class_name(attribs->klass));
+   printf("    bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
+          attribs->bufferSize, attribs->level, attribs->rgba ? "rgba" : "ci",
+          attribs->doubleBuffer, attribs->stereo);
+   printf("    rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
+          attribs->redSize, attribs->greenSize,
+          attribs->blueSize, attribs->alphaSize);
+   printf("    auxBuffers=%d depthSize=%d stencilSize=%d\n",
+          attribs->auxBuffers, attribs->depthSize, attribs->stencilSize);
+   printf("    accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
+          attribs->accumRedSize, attribs->accumGreenSize,
+          attribs->accumBlueSize, attribs->accumAlphaSize);
+   printf("    multiSample=%d  multiSampleBuffers=%d\n",
+          attribs->numSamples, attribs->numMultisample);
+#ifdef GLX_EXT_visual_rating
+   if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0)
+      printf("    visualCaveat=None\n");
+   else if (attribs->visualCaveat == GLX_SLOW_VISUAL_EXT)
+      printf("    visualCaveat=Slow\n");
+   else if (attribs->visualCaveat == GLX_NON_CONFORMANT_VISUAL_EXT)
+      printf("    visualCaveat=Nonconformant\n");
+#endif
+   printf("    %s\n", attribs->transparent ? "Transparent." : "Opaque.");
+}
+
+
+static void
+print_visual_attribs_short_header(void)
+{
+ printf("   visual  x  bf lv rg d st colorbuffer ax dp st accumbuffer  ms  cav\n");
+ printf(" id dep cl sp sz l  ci b ro  r  g  b  a bf th cl  r  g  b  a ns b eat\n");
+ printf("----------------------------------------------------------------------\n");
+}
+
+
+static void
+print_visual_attribs_short(const struct visual_attribs *attribs)
+{
+   char *caveat;
+#ifdef GLX_EXT_visual_rating
+   if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0)
+      caveat = "None";
+   else if (attribs->visualCaveat == GLX_SLOW_VISUAL_EXT)
+      caveat = "Slow";
+   else if (attribs->visualCaveat == GLX_NON_CONFORMANT_VISUAL_EXT)
+      caveat = "Ncon";
+#else
+   caveat = "None";
+#endif 
+
+   printf("0x%2x %2d %2s %2d %2d %2d %1s %2s %2s %2d %2d %2d %2d %2d %2d %2d",
+          attribs->id,
+          attribs->depth,
+          visual_class_abbrev(attribs->klass),
+          attribs->transparent,
+          attribs->bufferSize,
+          attribs->level,
+          attribs->rgba ? "r" : "c",
+          attribs->doubleBuffer ? "y" : ".",
+          attribs->stereo ? "y" : ".",
+          attribs->redSize, attribs->greenSize,
+          attribs->blueSize, attribs->alphaSize,
+          attribs->auxBuffers,
+          attribs->depthSize,
+          attribs->stencilSize
+          );
+
+   printf(" %2d %2d %2d %2d %2d %1d %s\n",
+          attribs->accumRedSize, attribs->accumGreenSize,
+          attribs->accumBlueSize, attribs->accumAlphaSize,
+          attribs->numSamples, attribs->numMultisample,
+          caveat
+          );
+}
+
+
+static void
+print_visual_attribs_long_header(void)
+{
+ printf("Vis  Vis   Visual Trans  buff lev render DB ste  r   g   b   a  aux dep ste  accum buffers  MS   MS\n");
+ printf(" ID Depth   Type  parent size el   type     reo sz  sz  sz  sz  buf th  ncl  r   g   b   a  num bufs\n");
+ printf("----------------------------------------------------------------------------------------------------\n");
+}
+
+
+static void
+print_visual_attribs_long(const struct visual_attribs *attribs)
+{
+   printf("0x%2x %2d %-11s %2d     %2d %2d  %4s %3d %3d %3d %3d %3d %3d",
+          attribs->id,
+          attribs->depth,
+          visual_class_name(attribs->klass),
+          attribs->transparent,
+          attribs->bufferSize,
+          attribs->level,
+          attribs->rgba ? "rgba" : "ci  ",
+          attribs->doubleBuffer,
+          attribs->stereo,
+          attribs->redSize, attribs->greenSize,
+          attribs->blueSize, attribs->alphaSize
+          );
+
+   printf(" %3d %4d %2d %3d %3d %3d %3d  %2d  %2d\n",
+          attribs->auxBuffers,
+          attribs->depthSize,
+          attribs->stencilSize,
+          attribs->accumRedSize, attribs->accumGreenSize,
+          attribs->accumBlueSize, attribs->accumAlphaSize,
+          attribs->numSamples, attribs->numMultisample
+          );
+}
+
+
+static void
+print_visual_info(Display *dpy, int scrnum, InfoMode mode)
+{
+   XVisualInfo template;
+   XVisualInfo *visuals;
+   int numVisuals;
+   long mask;
+   int i;
+
+   /* get list of all visuals on this screen */
+   template.screen = scrnum;
+   mask = VisualScreenMask;
+   visuals = XGetVisualInfo(dpy, mask, &template, &numVisuals);
+
+   if (mode == Verbose) {
+      for (i = 0; i < numVisuals; i++) {
+         struct visual_attribs attribs;
+         get_visual_attribs(dpy, &visuals[i], &attribs);
+         print_visual_attribs_verbose(&attribs);
+      }
+   }
+   else if (mode == Normal) {
+      print_visual_attribs_short_header();
+      for (i = 0; i < numVisuals; i++) {
+         struct visual_attribs attribs;
+         get_visual_attribs(dpy, &visuals[i], &attribs);
+         print_visual_attribs_short(&attribs);
+      }
+   }
+   else if (mode == Wide) {
+      print_visual_attribs_long_header();
+      for (i = 0; i < numVisuals; i++) {
+         struct visual_attribs attribs;
+         get_visual_attribs(dpy, &visuals[i], &attribs);
+         print_visual_attribs_long(&attribs);
+      }
+   }
+
+   XFree(visuals);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   char *displayName = ":0";
+   Display *dpy;
+   int numScreens, scrnum;
+   InfoMode mode = Normal;
+   int i;
+
+   for (i = 1; i < argc; i++) {
+      if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
+         displayName = argv[i + 1];
+         i++;
+      }
+      else if (strcmp(argv[i], "-t") == 0) {
+         mode = Wide;
+      }
+      else if (strcmp(argv[i], "-v") == 0) {
+         mode = Verbose;
+      }
+   }
+
+   dpy = XOpenDisplay(displayName);
+   if (!dpy) {
+      fprintf(stderr, "Error: unable to open display %s\n", displayName);
+      return -1;
+   }
+
+   numScreens = ScreenCount(dpy);
+   for (scrnum = 0; scrnum < numScreens; scrnum++) {
+      print_screen_info(dpy, scrnum);
+      printf("\n");
+      print_visual_info(dpy, scrnum, mode);
+      if (scrnum + 1 < numScreens)
+         printf("\n\n");
+   }
+
+   XCloseDisplay(dpy);
+
+   return 0;
+}
Index: xc/programs/glxinfo/glxinfo.man
diff -u /dev/null xc/programs/glxinfo/glxinfo.man:1.1
--- /dev/null	Mon Dec 18 14:33:38 2000
+++ xc/programs/glxinfo/glxinfo.man	Fri Sep 22 07:35:46 2000
@@ -0,0 +1,62 @@
+.\" $TOG: xdpyinfo.man /main/22 1998/02/09 13:57:10 kaleb $
+.\" Copyright 1988, 1989, 1994, 1998  The Open Group
+.\" 
+.\" All Rights Reserved.
+.\" 
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\" 
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\" 
+.\" Except as contained in this notice, the name of The Open Group shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from The Open Group.
+.\"
+.\" $XFree86: xc/programs/glxinfo/glxinfo.man,v 1.1 2000/09/22 11:35:46 alanh Exp $
+.\"
+.TH GLXINFO 1 "Release 6.4" "X Version 11"
+.SH NAME
+glxinfo \- display info about a GLX extension and OpenGL renderer.
+.SH SYNOPSIS
+.B "glxinfo"
+[\-t]
+[\-v]
+[\-display \fIdisplayname\fP]
+.SH DESCRIPTION
+.PP
+.I glxinfo
+lists information about the GLX extension, OpenGL capable visuals, and the
+OpenGL renderer on an X server. The GLX and renderer info includes the version
+and extension attributes. The visual info lists the GLX visual attributes 
+available for each OpenGL capable visual (e.g. whether the visual is double
+buffered, the component sizes, Z-buffering depth, etc).
+.PP
+Command line options include:
+.PP
+\fB-t\fP By default the visual info is presented in a conccise 80 character wide
+tabular format. The -t option directs glxinfo to produce a wider, more readable
+tabular format.
+.PP
+\fB-v\fP Directs glxinfo to generate a verbose format output style for
+the visual list similar to the info of xdpyinfo.
+.PP
+     \fB-display displayName\fP Specify the display to query.
+.PP
+.SH ENVIRONMENT
+.PP
+.TP 8
+.B DISPLAY
+To get the default host, display number, and screen.
+.SH "SEE ALSO"
+xdpyinfo(1)
+.SH AUTHOR
+Brian Paul
+.br
+Modifications for XFree86 added by Mark Paton
Index: xc/programs/lbxproxy/os/connection.c
diff -u xc/programs/lbxproxy/os/connection.c:1.12 xc/programs/lbxproxy/os/connection.c:1.13
--- xc/programs/lbxproxy/os/connection.c:1.12	Thu May 18 19:46:26 2000
+++ xc/programs/lbxproxy/os/connection.c	Thu Aug 10 13:40:40 2000
@@ -56,7 +56,7 @@
  *      socket ids aren't small nums (0 - 2^8)
  *
  *****************************************************************/
-/* $XFree86: xc/programs/lbxproxy/os/connection.c,v 1.12 2000/05/18 23:46:26 dawes Exp $ */
+/* $XFree86: xc/programs/lbxproxy/os/connection.c,v 1.13 2000/08/10 17:40:40 dawes Exp $ */
 
 #include "misc.h"
 #include <X11/Xtrans.h>
@@ -88,7 +88,7 @@
 
 #if defined (TCPCONN) || defined(STREAMSCONN)
 # include <netinet/in.h>
-# ifndef hpux
+# if !defined(hpux) && !defined(__CYGWIN__)
 #  ifdef apollo
 #   ifndef NO_TCP_H
 #    include <netinet/tcp.h>
Index: xc/programs/mkcfm/Imakefile
diff -u xc/programs/mkcfm/Imakefile:1.3 xc/programs/mkcfm/Imakefile:1.4
--- xc/programs/mkcfm/Imakefile:1.3	Sat May 15 08:10:36 1999
+++ xc/programs/mkcfm/Imakefile	Tue Nov 14 20:36:16 2000
@@ -1,6 +1,6 @@
-XCOMM $XFree86: xc/programs/mkcfm/Imakefile,v 1.3 1999/05/15 12:10:36 dawes Exp $
+XCOMM $XFree86: xc/programs/mkcfm/Imakefile,v 1.4 2000/11/15 01:36:16 dawes Exp $
 
-SYS_LIBRARIES = -lm
+SYS_LIBRARIES = MathLibrary
 
 INCLUDES = -I$(FONTLIBSRC)/Type1 -I$(FONTINCSRC) -I$(FONTLIBSRC)/include \
 	-I$(XINCLUDESRC) -I$(SERVERSRC)/include
Index: xc/programs/mkcfm/mkcfm.c
diff -u xc/programs/mkcfm/mkcfm.c:1.9 xc/programs/mkcfm/mkcfm.c:1.10
--- xc/programs/mkcfm/mkcfm.c:1.9	Thu May 11 14:14:39 2000
+++ xc/programs/mkcfm/mkcfm.c	Tue Nov 14 12:33:01 2000
@@ -16,7 +16,7 @@
  * The Original Software is CID font code that was developed by Silicon
  * Graphics, Inc.
  */
-/* $XFree86: xc/programs/mkcfm/mkcfm.c,v 1.9 2000/05/11 18:14:39 tsi Exp $ */
+/* $XFree86: xc/programs/mkcfm/mkcfm.c,v 1.10 2000/11/14 17:33:01 dawes Exp $ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -256,7 +256,18 @@
 		   struct font_encoding_mapping *m) { return NULL; }
 
 FontPtr 
-CreateFontRec(void) { return NULL; }
+CreateFontRec (void)
+{
+    FontPtr pFont;
 
-void 
-DestroyFontRec(FontPtr p) { ; }
+    pFont = (FontPtr)xalloc(sizeof(FontRec));
+    if(pFont)
+        bzero((char*)pFont, sizeof(FontRec));
+
+    return pFont;
+}
+
+void DestroyFontRec (FontPtr pFont)
+{
+   xfree(pFont);
+}
Index: xc/programs/mkfontdir/mkfontdir.c
diff -u xc/programs/mkfontdir/mkfontdir.c:3.10 xc/programs/mkfontdir/mkfontdir.c:3.11
--- xc/programs/mkfontdir/mkfontdir.c:3.10	Sat Aug 21 09:48:46 1999
+++ xc/programs/mkfontdir/mkfontdir.c	Wed Nov  8 20:35:50 2000
@@ -47,7 +47,7 @@
 ******************************************************************/
 
 /* $XConsortium: mkfontdir.c /main/13 1996/09/28 17:17:17 rws $ */
-/* $XFree86: xc/programs/mkfontdir/mkfontdir.c,v 3.10 1999/08/21 13:48:46 dawes Exp $ */
+/* $XFree86: xc/programs/mkfontdir/mkfontdir.c,v 3.11 2000/11/09 01:35:50 dawes Exp $ */
 
 #ifdef WIN32
 #define _WILLWINSOCK_
@@ -126,6 +126,7 @@
 char *progName;
 char *prefix = "";
 Bool relative = FALSE;
+char *excludesuf = NULL;
 
 /* The possible extensions for encoding files, in decreasing priority */
 #ifdef X_GZIP_FONT_COMPRESSION
@@ -401,6 +402,10 @@
 	if (renderer)
 	{
 	    extension = renderer->fileSuffix;
+	    if (excludesuf &&
+		strncmp(excludesuf, extension + 1, strlen(excludesuf)) == 0) {
+		continue;
+	    }
 	    Estrip (extension, FileName(file));
 	    hash = Hash (FileName(file));
 	    prev = &hashTable[hash];
@@ -732,6 +737,17 @@
           fprintf(stderr, "%s: unknown option `%s'\n", progName, argv[argn]);
           continue;
         }
+      } else if(argv[argn][1]=='x') {
+        if(argv[argn][2]=='\0') {
+          argn++;
+	  if (argn < argc)
+            excludesuf=argv[argn];
+	  else {
+	    fprintf(stderr, "%s: -x requires an argument\n", progName);
+	    break;
+	  }
+        } else
+          excludesuf=argv[argn]+2;
       } else
         fprintf(stderr, "%s: unknown option `%s'\n", progName, argv[argn]);
     }
Index: xc/programs/mkfontdir/mkfontdir.man
diff -u xc/programs/mkfontdir/mkfontdir.man:1.8 xc/programs/mkfontdir/mkfontdir.man:1.9
--- xc/programs/mkfontdir/mkfontdir.man:1.8	Sun May 23 02:33:52 1999
+++ xc/programs/mkfontdir/mkfontdir.man	Wed Nov  8 20:35:51 2000
@@ -19,13 +19,15 @@
 .\" other dealings in this Software without prior written authorization
 .\" from The Open Group.
 .\"
-.\" $XFree86: xc/programs/mkfontdir/mkfontdir.man,v 1.8 1999/05/23 06:33:52 dawes Exp $
+.\" $XFree86: xc/programs/mkfontdir/mkfontdir.man,v 1.9 2000/11/09 01:35:51 dawes Exp $
 .\"
 .TH MKFONTDIR 1 "Release 6.4" "X Version 11"
 .SH NAME
 mkfontdir, fonts.dir, fonts.scale, fonts.alias, encodings.dir \- create an index of X font files in a directory
 .SH SYNOPSIS
 .B "mkfontdir"
+.RB [ \-x
+.IR suffix ]
 .RB [ \-r ]
 .RB [ \-p
 .IR prefix ]
@@ -132,6 +134,10 @@
 option only applies to subsequent
 .B \-e
 options.
+.TP
+.BI "\-x " suffix
+Ignore fonts files of type
+.IR suffix .
 .TP
 .B \-\-
 End options.
Index: xc/programs/proxymngr/config.c
diff -u xc/programs/proxymngr/config.c:1.4 xc/programs/proxymngr/config.c:1.5
--- xc/programs/proxymngr/config.c:1.4	Mon Mar 29 08:17:09 1999
+++ xc/programs/proxymngr/config.c	Tue Sep 26 11:57:23 2000
@@ -21,11 +21,12 @@
 other dealings in this Software without prior written authorization
 from The Open Group.
 */
-/* $XFree86: xc/programs/proxymngr/config.c,v 1.4 1999/03/29 13:17:09 dawes Exp $ */
+/* $XFree86: xc/programs/proxymngr/config.c,v 1.5 2000/09/26 15:57:23 tsi Exp $ */
 
+#include <stdlib.h>
+
 #include "pmint.h"
 #include "config.h"
-
 
 static Bool
 getnextline (
Index: xc/programs/rstart/Imakefile
diff -u xc/programs/rstart/Imakefile:3.8 xc/programs/rstart/Imakefile:3.9
--- xc/programs/rstart/Imakefile:3.8	Mon Jan 31 14:33:41 2000
+++ xc/programs/rstart/Imakefile	Sat Aug 26 00:30:57 2000
@@ -1,5 +1,5 @@
 XCOMM $XConsortium: Imakefile,v 1.12 94/12/01 20:16:44 kaleb Exp $
-XCOMM $XFree86: xc/programs/rstart/Imakefile,v 3.8 2000/01/31 19:33:41 dawes Exp $
+XCOMM $XFree86: xc/programs/rstart/Imakefile,v 3.9 2000/08/26 04:30:57 dawes Exp $
 XCOMM
 XCOMM Copyright (c) 1993 Quarterdeck Office Systems
 XCOMM
@@ -30,11 +30,13 @@
 #ifndef OS2Architecture
 SSERVERNAME=$(SERVERNAME)
 RSERVERNAME=$(SERVERNAME).real
+SSERVERSRC=server.cpp
 OS=
 CLIENTNAME=rstart
 #else
 SSERVERNAME=$(SERVERNAME).cmd
 RSERVERNAME=$(SERVERNAME)
+SSERVERSRC=server.os2
 OS=-DOS2
 CLIENTNAME=rstart.cmd
 #endif
@@ -74,7 +76,7 @@
 SpecialCObjectRule(server,NullParameter,$(SRVDEFS) $(PEDEFS))
 
 AllTarget($(SSERVERNAME))
-CppScriptTarget($(SSERVERNAME),server.cpp,$(OS) -DLIBDIR=$(MYLIBDIR) -DSERVERNAME=$(SERVERNAME),NullParameter)
+CppScriptTarget($(SSERVERNAME),$(SSERVERSRC),$(OS) -DLIBDIR=$(MYLIBDIR) -DSERVERNAME=$(SERVERNAME),NullParameter)
 InstallNamedProg($(SSERVERNAME),$(SSERVERNAME),$(BINDIR))
 
 AllTarget($(CLIENTNAME))
Index: xc/programs/rstart/server.cpp
diff -u xc/programs/rstart/server.cpp:3.0 xc/programs/rstart/server.cpp:3.1
--- xc/programs/rstart/server.cpp:3.0	Sat Mar 11 09:20:38 1995
+++ xc/programs/rstart/server.cpp	Sat Aug 26 00:30:57 2000
@@ -1,10 +1,5 @@
-#ifndef OS2
 XCOMM! /bin/sh
-#else
-/* REXX script */
-#endif
 XCOMM $XConsortium: server.cpp,v 1.4 94/02/06 19:52:05 mor Exp $
-XCOMM $XFree86: xc/programs/rstart/server.cpp,v 3.0 1995/03/11 14:20:38 dawes Exp $
 XCOMM
 
 XCOMM Copyright (c) 1993 Quarterdeck Office Systems
@@ -28,9 +23,7 @@
 XCOMM PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS
 XCOMM OF WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT
 XCOMM OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM $XFree86: xc/programs/rstart/server.cpp,v 3.1 2000/08/26 04:30:57 dawes Exp $
 
-#ifndef OS2
 exec LIBDIR/SERVERNAME.real -c LIBDIR/config
-#else
-start LIBDIR/SERVERNAME -c LIBDIR/config
-#endif
Index: xc/programs/rstart/server.os2
diff -u /dev/null xc/programs/rstart/server.os2:1.1
--- /dev/null	Mon Dec 18 14:33:46 2000
+++ xc/programs/rstart/server.os2	Sat Aug 26 00:30:57 2000
@@ -0,0 +1,29 @@
+/* REXX script */
+XCOMM $XConsortium: server.cpp,v 1.4 94/02/06 19:52:05 mor Exp $
+XCOMM
+
+XCOMM Copyright (c) 1993 Quarterdeck Office Systems
+XCOMM
+XCOMM Permission to use, copy, modify, distribute, and sell this software
+XCOMM and software and its documentation for any purpose is hereby granted
+XCOMM without fee, provided that the above copyright notice appear in all
+XCOMM copies and that both that copyright notice and this permission
+XCOMM notice appear in supporting documentation, and that the name
+XCOMM Quarterdeck Office Systems, Inc. not be used in advertising or
+XCOMM publicity pertaining to distribution of this software without
+XCOMM specific, written prior permission.
+XCOMM
+XCOMM THIS SOFTWARE IS PROVIDED "AS-IS".  QUARTERDECK OFFICE SYSTEMS,
+XCOMM INC., DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+XCOMM INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+XCOMM NONINFRINGEMENT.  IN NO EVENT SHALL QUARTERDECK OFFICE SYSTEMS,
+XCOMM INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL,
+XCOMM INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR
+XCOMM PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS
+XCOMM OF WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT
+XCOMM OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+XCOMM
+XCOMM $XFree86: xc/programs/rstart/server.os2,v 1.1 2000/08/26 04:30:57 dawes Exp $
+
+start LIBDIR/SERVERNAME -c LIBDIR/config
Index: xc/programs/twm/Imakefile
diff -u xc/programs/twm/Imakefile:3.9 xc/programs/twm/Imakefile:3.11
--- xc/programs/twm/Imakefile:3.9	Mon Jan 31 14:33:42 2000
+++ xc/programs/twm/Imakefile	Sun Oct 29 09:24:13 2000
@@ -1,5 +1,5 @@
 XCOMM $XConsortium: Imakefile /main/42 1996/01/14 16:50:01 kaleb $
-XCOMM $XFree86: xc/programs/twm/Imakefile,v 3.9 2000/01/31 19:33:42 dawes Exp $
+XCOMM $XFree86: xc/programs/twm/Imakefile,v 3.11 2000/10/29 14:24:13 tsi Exp $
 
 
 
Index: xc/programs/twm/add_window.c
diff -u xc/programs/twm/add_window.c:1.6 xc/programs/twm/add_window.c:1.7
--- xc/programs/twm/add_window.c:1.6	Fri Feb 19 16:27:23 1999
+++ xc/programs/twm/add_window.c	Tue Oct 24 18:45:14 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/twm/add_window.c,v 1.6 1999/02/19 21:27:23 hohndel Exp $ */
+/* $XFree86: xc/programs/twm/add_window.c,v 1.7 2000/10/24 22:45:14 dawes Exp $ */
 /*****************************************************************************/
 /*
 
@@ -163,9 +163,6 @@
     unsigned long valuemask;		/* mask for create windows */
     XSetWindowAttributes attributes;	/* attributes for create windows */
     int width, height;			/* tmp variable */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems, bytesafter;
     int ask_user;		/* don't know where to put the window */
     int gravx, gravy;			/* gravity signs for positioning */
     int namelen;
@@ -201,7 +198,7 @@
 
     XGetWindowAttributes(dpy, tmp_win->w, &tmp_win->attr);
 
-    XFetchName(dpy, tmp_win->w, &name);
+    I18N_FetchName(dpy, tmp_win->w, &name);
     tmp_win->class = NoClass;
     XGetClassHint(dpy, tmp_win->w, &tmp_win->class);
     FetchWmProtocols (tmp_win);
@@ -279,7 +276,7 @@
 	tmp_win->name = strdup(NoName);
     else {
       tmp_win->name = strdup(name);
-      XFree(name);
+      free(name);
     }
     if (tmp_win->class.res_name == NULL)
     	tmp_win->class.res_name = NoName;
@@ -487,7 +484,7 @@
 		    break;
 	    }
 
-	    width = (SIZE_HINDENT + XTextWidth (Scr->SizeFont.font,
+	    width = (SIZE_HINDENT + MyFont_TextWidth (&Scr->SizeFont,
 						tmp_win->name, namelen));
 	    height = Scr->SizeFont.height + SIZE_VINDENT * 2;
 	    
@@ -495,12 +492,13 @@
 	    XMapRaised(dpy, Scr->SizeWindow);
 	    InstallRootColormap();
 
-	    FBF(Scr->DefaultC.fore, Scr->DefaultC.back,
-		Scr->SizeFont.font->fid);
-	    XDrawImageString (dpy, Scr->SizeWindow, Scr->NormalGC,
-			      SIZE_HINDENT,
-			      SIZE_VINDENT + Scr->SizeFont.font->ascent,
-			      tmp_win->name, namelen);
+	    MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back,
+			    &Scr->SizeFont);
+	    MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont,
+				    Scr->NormalGC,
+				    SIZE_HINDENT,
+				    SIZE_VINDENT + Scr->SizeFont.ascent,
+				    tmp_win->name, namelen);
 
 	    AddingW = tmp_win->attr.width + bw2;
 	    AddingH = tmp_win->attr.height + tmp_win->title_height + bw2;
@@ -595,11 +593,12 @@
 		int lastx, lasty;
 
 		Scr->SizeStringOffset = width +
-		  XTextWidth(Scr->SizeFont.font, ": ", 2);
+		  MyFont_TextWidth(&Scr->SizeFont, ": ", 2);
 		XResizeWindow (dpy, Scr->SizeWindow, Scr->SizeStringOffset +
 			       Scr->SizeStringWidth, height);
-		XDrawImageString (dpy, Scr->SizeWindow, Scr->NormalGC, width,
-				  SIZE_VINDENT + Scr->SizeFont.font->ascent,
+		MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont,
+				  Scr->NormalGC, width,
+				  SIZE_VINDENT + Scr->SizeFont.ascent,
 				  ": ", 2);
 		if (0/*Scr->AutoRelativeResize*/) {
 		    int dx = (tmp_win->attr.width / 4);
@@ -725,19 +724,17 @@
 
     if (tmp_win->old_bw) XSetWindowBorderWidth (dpy, tmp_win->w, 0);
 
-    tmp_win->name_width = XTextWidth(Scr->TitleBarFont.font, tmp_win->name,
-				     namelen);
+    tmp_win->name_width = MyFont_TextWidth(&Scr->TitleBarFont, tmp_win->name,
+					    namelen);
 
-    if (XGetWindowProperty (dpy, tmp_win->w, XA_WM_ICON_NAME, 0L, 200L, False,
-			    XA_STRING, &actual_type, &actual_format, &nitems,
-			    &bytesafter,(unsigned char **)&name)) {
+    if (!I18N_GetIconName(dpy, tmp_win->w, &name)) {
 	tmp_win->icon_name = strdup(tmp_win->name);
     } else {
 	if (name == NULL) {
 	    tmp_win->icon_name = strdup(tmp_win->name);
 	} else {
 	    tmp_win->icon_name = strdup(name);
-	    XFree(name);
+	    free(name);
 	}
     }
 
Index: xc/programs/twm/events.c
diff -u xc/programs/twm/events.c:1.5 xc/programs/twm/events.c:1.7
--- xc/programs/twm/events.c:1.5	Fri Feb 19 16:27:24 1999
+++ xc/programs/twm/events.c	Tue Oct 24 18:45:14 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/twm/events.c,v 1.5 1999/02/19 21:27:24 hohndel Exp $ */
+/* $XFree86: xc/programs/twm/events.c,v 1.7 2000/10/24 22:45:14 dawes Exp $ */
 /*****************************************************************************/
 /*
 
@@ -769,10 +769,7 @@
 void
 HandlePropertyNotify()
 {
-    char *prop = NULL;
-    Atom actual = None;
-    int actual_format;
-    unsigned long nitems, bytesafter;
+    char *name = NULL;
     unsigned long valuemask;		/* mask for create windows */
     XSetWindowAttributes attributes;	/* attributes for create windows */
     Pixmap pm;
@@ -804,22 +801,16 @@
 
     switch (Event.xproperty.atom) {
       case XA_WM_NAME:
-	if (XGetWindowProperty (dpy, Tmp_win->w, Event.xproperty.atom, 0L, 
-				MAX_NAME_LEN, False, XA_STRING, &actual,
-				&actual_format, &nitems, &bytesafter,
-				(unsigned char **) &prop) != Success ||
-	    actual == None)
-	  return;
+	if (!I18N_FetchName(dpy, Tmp_win->w, &name)) return;
 	free_window_names (Tmp_win, True, True, False);
 
-	Tmp_win->full_name = strdup(prop ? prop : NoName);
-	Tmp_win->name = strdup(prop ? prop : NoName);
-	if (prop)
-	    XFree(prop);
+	Tmp_win->full_name = strdup(name ? name : NoName);
+	Tmp_win->name = strdup(name ? name : NoName);
+	if (name) free(name);
 
 	Tmp_win->nameChanged = 1;
 
-	Tmp_win->name_width = XTextWidth (Scr->TitleBarFont.font,
+	Tmp_win->name_width = MyFont_TextWidth (&Scr->TitleBarFont,
 					  Tmp_win->name,
 					  strlen (Tmp_win->name));
 
@@ -839,16 +830,10 @@
 	break;
 
       case XA_WM_ICON_NAME:
-	if (XGetWindowProperty (dpy, Tmp_win->w, Event.xproperty.atom, 0, 
-				MAX_ICON_NAME_LEN, False, XA_STRING, &actual,
-				&actual_format, &nitems, &bytesafter,
-				(unsigned char **) &prop) != Success ||
-	    actual == None)
-	  return;
+	if (!I18N_GetIconName(dpy, Tmp_win->w, &name)) return;
 	free_window_names (Tmp_win, False, False, True);
-	Tmp_win->icon_name = strdup(prop ? prop : NoName);
-	if (prop)
-	    XFree(prop);
+	Tmp_win->icon_name = strdup(name ? name : NoName);
+	if (name) free(name);
 
 	RedoIconName();
 	break;
@@ -1014,7 +999,7 @@
     if (Tmp_win->icon_not_ours)
 	return;
 
-    Tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font,
+    Tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont,
 	Tmp_win->icon_name, strlen(Tmp_win->icon_name));
 
     Tmp_win->icon_w_width += 6;
@@ -1113,14 +1098,15 @@
 	int i;
 	int height;
 
-	FBF(Scr->DefaultC.fore, Scr->DefaultC.back,
-	    Scr->DefaultFont.font->fid);
+	MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back,
+	    &Scr->DefaultFont);
 
 	height = Scr->DefaultFont.height+2;
 	for (i = 0; i < InfoLines; i++)
 	{
-	    XDrawString(dpy, Scr->InfoWindow, Scr->NormalGC,
-		5, (i*height) + Scr->DefaultFont.y, Info[i], strlen(Info[i]));
+	    MyFont_DrawString(dpy, Scr->InfoWindow, &Scr->DefaultFont, 
+		Scr->NormalGC, 5, (i*height) + Scr->DefaultFont.y, Info[i], 
+		strlen(Info[i]));
 	}
 	flush_expose (Event.xany.window);
     } 
@@ -1128,22 +1114,21 @@
     {
 	if (Event.xany.window == Tmp_win->title_w)
 	{
-	    FBF(Tmp_win->title.fore, Tmp_win->title.back,
-		Scr->TitleBarFont.font->fid);
+	    MyFont_ChangeGC(Tmp_win->title.fore, Tmp_win->title.back,
+		&Scr->TitleBarFont);
 
-	    XDrawString (dpy, Tmp_win->title_w, Scr->NormalGC,
-			 Scr->TBInfo.titlex, Scr->TitleBarFont.y, 
-			 Tmp_win->name, strlen(Tmp_win->name));
+	    MyFont_DrawString (dpy, Tmp_win->title_w, &Scr->TitleBarFont,
+		Scr->NormalGC, Scr->TBInfo.titlex, Scr->TitleBarFont.y, 
+		Tmp_win->name, strlen(Tmp_win->name));
 	    flush_expose (Event.xany.window);
 	}
 	else if (Event.xany.window == Tmp_win->icon_w)
 	{
-	    FBF(Tmp_win->iconc.fore, Tmp_win->iconc.back,
-		Scr->IconFont.font->fid);
+	    MyFont_ChangeGC(Tmp_win->iconc.fore, Tmp_win->iconc.back,
+		&Scr->IconFont);
 
-	    XDrawString (dpy, Tmp_win->icon_w,
-		Scr->NormalGC,
-		Tmp_win->icon_x, Tmp_win->icon_y,
+	    MyFont_DrawString (dpy, Tmp_win->icon_w, &Scr->IconFont,
+		Scr->NormalGC, Tmp_win->icon_x, Tmp_win->icon_y,
 		Tmp_win->icon_name, strlen(Tmp_win->icon_name));
 	    flush_expose (Event.xany.window);
 	    return;
@@ -1169,9 +1154,10 @@
 	if (Tmp_win->list) {
 	    if (Event.xany.window == Tmp_win->list->w)
 	    {
-		FBF(Tmp_win->list->fore, Tmp_win->list->back,
-		    Scr->IconManagerFont.font->fid);
-		XDrawString (dpy, Event.xany.window, Scr->NormalGC, 
+		MyFont_ChangeGC(Tmp_win->list->fore, Tmp_win->list->back,
+		    &Scr->IconManagerFont);
+		MyFont_DrawString (dpy, Event.xany.window,
+		    &Scr->IconManagerFont, Scr->NormalGC,
 		    iconmgr_textx, Scr->IconManagerFont.y+4,
 		    Tmp_win->icon_name, strlen(Tmp_win->icon_name));
 		DrawIconManagerBorder(Tmp_win->list);
@@ -1681,10 +1667,12 @@
 	      case F_FORCEMOVE:
 		ButtonPressed = -1;
 		break;
+	      case F_WARPTOSCREEN:
+		XUngrabPointer(dpy, CurrentTime);
+		/* fall through */
 	      case F_CIRCLEUP:
 	      case F_CIRCLEDOWN:
 	      case F_REFRESH:
-	      case F_WARPTOSCREEN:
 		PopDownMenu();
 		break;
 	      default:
Index: xc/programs/twm/gc.c
diff -u xc/programs/twm/gc.c:1.3 xc/programs/twm/gc.c:1.4
--- xc/programs/twm/gc.c:1.3	Sat Feb 20 10:07:22 1999
+++ xc/programs/twm/gc.c	Tue Oct 24 18:45:15 2000
@@ -44,7 +44,7 @@
 /**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
 /**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
 /*****************************************************************************/
-/* $XFree86: xc/programs/twm/gc.c,v 1.3 1999/02/20 15:07:22 hohndel Exp $ */
+/* $XFree86: xc/programs/twm/gc.c,v 1.4 2000/10/24 22:45:15 dawes Exp $ */
 
 
 /**********************************************************************
@@ -97,7 +97,8 @@
     gcm = 0;
     gcm |= GCForeground;    gcv.foreground = Scr->MenuC.fore;
     gcm |= GCBackground;    gcv.background = Scr->MenuC.back;
-    gcm |= GCFont;	    gcv.font =  Scr->MenuFont.font->fid;
+    if (!use_fontset)
+	{gcm |= GCFont;	    gcv.font =  Scr->MenuFont.font->fid;}
 
     Scr->MenuGC = XCreateGC(dpy, Scr->Root, gcm, &gcv);
 
Index: xc/programs/twm/iconmgr.c
diff -u xc/programs/twm/iconmgr.c:1.3 xc/programs/twm/iconmgr.c:1.4
--- xc/programs/twm/iconmgr.c:1.3	Sat Feb 20 10:07:23 1999
+++ xc/programs/twm/iconmgr.c	Wed Nov  1 21:51:24 2000
@@ -18,7 +18,7 @@
 used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization from The Open Group.
  * */
-/* $XFree86: xc/programs/twm/iconmgr.c,v 1.3 1999/02/20 15:07:23 hohndel Exp $ */
+/* $XFree86: xc/programs/twm/iconmgr.c,v 1.4 2000/11/02 02:51:24 dawes Exp $ */
 
 /***********************************************************************
  *
@@ -29,6 +29,7 @@
  * 09-Mar-89 Tom LaStrange		File Created
  *
  ***********************************************************************/
+/* $XFree86: xc/programs/twm/iconmgr.c,v 1.4 2000/11/02 02:51:24 dawes Exp $ */
 
 #include <stdio.h>
 #include "twm.h"
@@ -487,6 +488,8 @@
 	XMapWindow(dpy, ip->w);
 	XMapWindow(dpy, ip->twm_win->frame);
     }
+
+    if (Active == NULL) Active = tmp;
 
     return (tmp);
 }
Index: xc/programs/twm/icons.c
diff -u xc/programs/twm/icons.c:1.3 xc/programs/twm/icons.c:1.4
--- xc/programs/twm/icons.c:1.3	Sat Feb 20 10:07:23 1999
+++ xc/programs/twm/icons.c	Tue Oct 24 18:45:15 2000
@@ -18,7 +18,7 @@
 used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization from The Open Group.
  * */
-/* $XFree86: xc/programs/twm/icons.c,v 1.3 1999/02/20 15:07:23 hohndel Exp $ */
+/* $XFree86: xc/programs/twm/icons.c,v 1.4 2000/10/24 22:45:15 dawes Exp $ */
 
 /**********************************************************************
  *
@@ -491,7 +491,7 @@
 	attributes.background_pixmap = pm;
     }
 
-    tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font,
+    tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont,
 	tmp_win->icon_name, strlen(tmp_win->icon_name));
 
     tmp_win->icon_w_width += 6;
Index: xc/programs/twm/menus.c
diff -u xc/programs/twm/menus.c:1.6 xc/programs/twm/menus.c:1.8
--- xc/programs/twm/menus.c:1.6	Fri Feb 19 16:27:29 1999
+++ xc/programs/twm/menus.c	Tue Oct 24 18:45:15 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/twm/menus.c,v 1.6 1999/02/19 21:27:29 hohndel Exp $ */
+/* $XFree86: xc/programs/twm/menus.c,v 1.8 2000/10/24 22:45:15 dawes Exp $ */
 /*****************************************************************************/
 /*
 
@@ -403,9 +403,9 @@
 	    XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset,
 		mr->width, Scr->EntryHeight);
 
-	    FBF(mi->hi_fore, mi->hi_back, Scr->MenuFont.font->fid);
+	    MyFont_ChangeGC(mi->hi_fore, mi->hi_back, &Scr->MenuFont);
 
-	    XDrawString(dpy, mr->w, Scr->NormalGC, mi->x,
+	    MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, Scr->NormalGC, mi->x,
 		text_y, mi->item, mi->strlen);
 
 	    gc = Scr->NormalGC;
@@ -419,14 +419,15 @@
 		XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset,
 		    mr->width, Scr->EntryHeight);
 
-		FBF(mi->fore, mi->back, Scr->MenuFont.font->fid);
+		MyFont_ChangeGC(mi->fore, mi->back, &Scr->MenuFont);
 		gc = Scr->NormalGC;
 	    }
 	    else
 		gc = Scr->MenuGC;
 
-	    XDrawString(dpy, mr->w, gc, mi->x,
-		text_y, mi->item, mi->strlen);
+	    MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, gc, 
+		    mi->x, text_y, mi->item, mi->strlen);
+
 	}
 
 	if (mi->func == F_MENU)
@@ -463,9 +464,9 @@
 	    XDrawLine(dpy, mr->w, Scr->NormalGC, 0, y, mr->width, y);
 	}
 
-	FBF(mi->fore, mi->back, Scr->MenuFont.font->fid);
+	MyFont_ChangeGC(mi->fore, mi->back, &Scr->MenuFont);
 	/* finally render the title */
-	XDrawString(dpy, mr->w, Scr->NormalGC, mi->x,
+	MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, Scr->NormalGC, mi->x,
 	    text_y, mi->item, mi->strlen);
     }
 }
@@ -756,7 +757,7 @@
     tmp->func = func;
 
     if (!Scr->HaveFonts) CreateFonts();
-    width = XTextWidth(Scr->MenuFont.font, item, tmp->strlen);
+    width = MyFont_TextWidth(&Scr->MenuFont, item, tmp->strlen);
     if (width <= 0)
 	width = 1;
     if (width > menu->width)
@@ -834,7 +835,7 @@
 		cur->x = 5;
 	    else
 	    {
-		cur->x = width - XTextWidth(Scr->MenuFont.font, cur->item,
+		cur->x = width - MyFont_TextWidth(&Scr->MenuFont, cur->item,
 		    cur->strlen);
 		cur->x /= 2;
 	    }
@@ -1253,8 +1254,8 @@
   bw2 = tmp_win->frame_bw * 2;
   AddingW = tmp_win->attr.width + bw2;
   AddingH = tmp_win->attr.height + tmp_win->title_height + bw2;
-  width = (SIZE_HINDENT + XTextWidth (Scr->SizeFont.font,
-				      tmp_win->name, namelen));
+  width = (SIZE_HINDENT + MyFont_TextWidth (&Scr->SizeFont,
+					     tmp_win->name, namelen));
   height = Scr->SizeFont.height + SIZE_VINDENT * 2;
   XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY,
 	       (unsigned int *)&DragWidth, (unsigned int *)&DragHeight, 
@@ -1266,11 +1267,11 @@
 		 &AddingX, &AddingY, &JunkMask);
 /*****
   Scr->SizeStringOffset = width +
-    XTextWidth(Scr->SizeFont.font, ": ", 2);
+    MyFont_TextWidth(&Scr->SizeFont, ": ", 2);
   XResizeWindow (dpy, Scr->SizeWindow, Scr->SizeStringOffset +
 		 Scr->SizeStringWidth, height);
-  XDrawImageString (dpy, Scr->SizeWindow, Scr->NormalGC, width,
-		    SIZE_VINDENT + Scr->SizeFont.font->ascent,
+  MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont, Scr->NormalGC,
+		    width, SIZE_VINDENT + Scr->SizeFont.ascent,
 		    ": ", 2);
 *****/
   lastx = -10000;
@@ -2023,7 +2024,8 @@
 		InstallWindowColormaps (0, tmp_win);
 		if (tmp_win->hilite_w) XMapWindow (dpy, tmp_win->hilite_w);
 		SetBorder (tmp_win, True);
-		SetFocus (tmp_win, eventp->xbutton.time);
+		if (!tmp_win->wmhints || tmp_win->wmhints->input)
+		    SetFocus (tmp_win, eventp->xbutton.time);
 		Scr->FocusRoot = FALSE;
 		Scr->Focus = tmp_win;
 	    }
@@ -2744,7 +2746,7 @@
     width = 1;
     for (i = 0; i < n; i++)
     {
-	twidth = XTextWidth(Scr->DefaultFont.font, Info[i],
+	twidth = MyFont_TextWidth(&Scr->DefaultFont, Info[i], 
 	    strlen(Info[i]));
 	if (twidth > width)
 	    width = twidth;
Index: xc/programs/twm/parse.c
diff -u xc/programs/twm/parse.c:1.5 xc/programs/twm/parse.c:1.7
--- xc/programs/twm/parse.c:1.5	Fri Feb 19 16:27:30 1999
+++ xc/programs/twm/parse.c	Sun Oct 29 09:24:13 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/twm/parse.c,v 1.5 1999/02/19 21:27:30 hohndel Exp $ */
+/* $XFree86: xc/programs/twm/parse.c,v 1.7 2000/10/29 14:24:13 tsi Exp $ */
 /*****************************************************************************/
 /*
 
@@ -78,7 +78,7 @@
 static int ptr = 0;
 static int len = 0;
 static char buff[BUF_LEN+1];
-static char overflowbuff[20];		/* really only need one */
+static unsigned char overflowbuff[20];		/* really only need one */
 static int overflowlen;
 static char **stringListSource, *currentString;
 
@@ -304,7 +304,7 @@
     int c;
 {
     if (overflowlen < sizeof overflowbuff) {
-	overflowbuff[overflowlen++] = (char) c;
+	overflowbuff[overflowlen++] = (unsigned char) c;
     } else {
 	twmrc_error_prefix ();
 	fprintf (stderr, "unable to unput character (%d)\n",
Index: xc/programs/twm/parse.h
diff -u xc/programs/twm/parse.h:1.5 xc/programs/twm/parse.h:1.7
--- xc/programs/twm/parse.h:1.5	Fri Feb 19 16:27:30 1999
+++ xc/programs/twm/parse.h	Sun Oct 29 09:24:14 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/twm/parse.h,v 1.5 1999/02/19 21:27:30 hohndel Exp $ */
+/* $XFree86: xc/programs/twm/parse.h,v 1.7 2000/10/29 14:24:14 tsi Exp $ */
 /*****************************************************************************/
 /*
 
Index: xc/programs/twm/resize.c
diff -u xc/programs/twm/resize.c:1.5 xc/programs/twm/resize.c:1.6
--- xc/programs/twm/resize.c:1.5	Fri Feb 19 16:27:30 1999
+++ xc/programs/twm/resize.c	Tue Oct 24 18:45:15 2000
@@ -56,7 +56,7 @@
  *
  ***********************************************************************/
 
-/* $XFree86: xc/programs/twm/resize.c,v 1.5 1999/02/19 21:27:30 hohndel Exp $ */
+/* $XFree86: xc/programs/twm/resize.c,v 1.6 2000/10/24 22:45:15 dawes Exp $ */
 
 #include <stdio.h>
 #include "twm.h"
@@ -553,11 +553,11 @@
 
     (void) sprintf (str, " %4d x %-4d ", dwidth, dheight);
     XRaiseWindow(dpy, Scr->SizeWindow);
-    FBF(Scr->DefaultC.fore, Scr->DefaultC.back, Scr->SizeFont.font->fid);
-    XDrawImageString (dpy, Scr->SizeWindow, Scr->NormalGC,
-		      Scr->SizeStringOffset,
-		      Scr->SizeFont.font->ascent + SIZE_VINDENT,
-		      str, 13);
+    MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back, &Scr->SizeFont);
+    MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont, 
+			    Scr->NormalGC, Scr->SizeStringOffset,
+			    Scr->SizeFont.ascent + SIZE_VINDENT,
+			    str, 13);
 }
 
 /***********************************************************************
Index: xc/programs/twm/twm.c
diff -u xc/programs/twm/twm.c:3.5 xc/programs/twm/twm.c:3.6
--- xc/programs/twm/twm.c:3.5	Thu Feb 25 01:01:03 1999
+++ xc/programs/twm/twm.c	Tue Oct 24 18:45:15 2000
@@ -55,7 +55,7 @@
  * 27-Oct-87 Thomas E. LaStrange	File created
  * 10-Oct-90 David M. Sternlicht        Storing saved colors on root
  ***********************************************************************/
-/* $XFree86: xc/programs/twm/twm.c,v 3.5 1999/02/25 06:01:03 dawes Exp $ */
+/* $XFree86: xc/programs/twm/twm.c,v 3.6 2000/10/24 22:45:15 dawes Exp $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -78,6 +78,7 @@
 #include <X11/SM/SMlib.h>
 #include <X11/Xmu/Error.h>
 #include <X11/extensions/sync.h>
+#include <X11/Xlocale.h>
 
 XtAppContext appContext;	/* Xt application context */
 
@@ -139,6 +140,8 @@
 
 Atom TwmAtoms[11];
 
+Bool use_fontset;		/* use XFontSet-related functions or not */
+
 /* don't change the order of these strings */
 static char* atom_names[11] = {
     "_MIT_PRIORITY_COLORS",
@@ -175,6 +178,7 @@
     int zero = 0;
     char *restore_filename = NULL;
     char *client_id = NULL;
+    char *loc;
 
     ProgramName = argv[0];
     Argc = argc;
@@ -217,6 +221,14 @@
 	exit (1);
     }
 
+    loc = setlocale(LC_ALL, "");
+    if (!loc || !strcmp(loc, "C") || !strcmp(loc, "POSIX") ||
+	!XSupportsLocale()) {
+	 use_fontset = False;
+    } else {
+	 use_fontset = True;
+    }
+
 #define newhandler(sig) \
     if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, Done)
 
@@ -564,7 +576,7 @@
 					 (Visual *) CopyFromParent,
 					 valuemask, &attributes);
 
-	Scr->SizeStringWidth = XTextWidth (Scr->SizeFont.font,
+	Scr->SizeStringWidth = MyFont_TextWidth (&Scr->SizeFont,
 					   " 8888 x 8888 ", 13);
 	valuemask = (CWBorderPixel | CWBackPixel | CWBitGravity);
 	attributes.bit_gravity = NorthWestGravity;
@@ -734,16 +746,22 @@
 #define DEFAULT_FAST_FONT "fixed"
 
     Scr->TitleBarFont.font = NULL;
+    Scr->TitleBarFont.fontset = NULL;
     Scr->TitleBarFont.name = DEFAULT_NICE_FONT;
     Scr->MenuFont.font = NULL;
+    Scr->MenuFont.fontset = NULL;
     Scr->MenuFont.name = DEFAULT_NICE_FONT;
     Scr->IconFont.font = NULL;
+    Scr->IconFont.fontset = NULL;
     Scr->IconFont.name = DEFAULT_NICE_FONT;
     Scr->SizeFont.font = NULL;
+    Scr->SizeFont.fontset = NULL;
     Scr->SizeFont.name = DEFAULT_FAST_FONT;
     Scr->IconManagerFont.font = NULL;
+    Scr->IconManagerFont.fontset = NULL;
     Scr->IconManagerFont.name = DEFAULT_NICE_FONT;
     Scr->DefaultFont.font = NULL;
+    Scr->DefaultFont.fontset = NULL;
     Scr->DefaultFont.name = DEFAULT_FAST_FONT;
 
 }
Index: xc/programs/twm/twm.h
diff -u xc/programs/twm/twm.h:3.4 xc/programs/twm/twm.h:3.5
--- xc/programs/twm/twm.h:3.4	Thu Feb 25 01:01:03 1999
+++ xc/programs/twm/twm.h	Tue Oct 24 18:45:15 2000
@@ -56,7 +56,7 @@
  * 28-Oct-87 Thomas E. LaStrange	File created
  * 10-Oct-90 David M. Sternlicht        Storeing saved colors on root
  ***********************************************************************/
-/* $XFree86: xc/programs/twm/twm.h,v 3.4 1999/02/25 06:01:03 dawes Exp $ */
+/* $XFree86: xc/programs/twm/twm.h,v 3.5 2000/10/24 22:45:15 dawes Exp $ */
 
 #ifndef _TWM_
 #define _TWM_
@@ -138,12 +138,6 @@
 /* defines for zooming/unzooming */
 #define ZOOM_NONE 0
 
-#define FBF(fix_fore, fix_back, fix_font)\
-    Gcv.foreground = fix_fore;\
-    Gcv.background = fix_back;\
-    Gcv.font = fix_font;\
-    XChangeGC(dpy, Scr->NormalGC, GCFont|GCForeground|GCBackground,&Gcv)
-
 #define FB(fix_fore, fix_back)\
     Gcv.foreground = fix_fore;\
     Gcv.background = fix_back;\
@@ -153,8 +147,11 @@
 {
     char *name;			/* name of the font */
     XFontStruct *font;		/* font structure */
+    XFontSet fontset;		/* fontset structure */
     int height;			/* height of the font */
     int y;			/* Y coordinate to draw characters */
+    int ascent;
+    int descent;
 } MyFont;
 
 typedef struct ColorPair
@@ -422,6 +419,8 @@
 extern void RemoveDQuote ( char *str );
 
 extern Atom TwmAtoms[];
+
+extern Bool use_fontset;
 
 #define _XA_MIT_PRIORITY_COLORS		TwmAtoms[0]
 #define _XA_WM_CHANGE_STATE		TwmAtoms[1]
Index: xc/programs/twm/util.c
diff -u xc/programs/twm/util.c:1.4 xc/programs/twm/util.c:1.6
--- xc/programs/twm/util.c:1.4	Thu Feb 25 01:01:04 1999
+++ xc/programs/twm/util.c	Sat Nov 18 14:37:26 2000
@@ -44,7 +44,7 @@
 /**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
 /**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
 /*****************************************************************************/
-/* $XFree86: xc/programs/twm/util.c,v 1.4 1999/02/25 06:01:04 dawes Exp $ */
+/* $XFree86: xc/programs/twm/util.c,v 1.6 2000/11/18 19:37:26 tsi Exp $ */
 
 
 /***********************************************************************
@@ -619,11 +619,68 @@
     }
 }
 
+/* 
+ * The following functions are sensible to 'use_fontset'.
+ * When 'use_fontset' is True,
+ *  - XFontSet-related internationalized functions are used
+ *     so as multibyte languages can be displayed.
+ * When 'use_fontset' is False,
+ *  - XFontStruct-related conventional functions are used
+ *     so as 8-bit characters can be displayed even when
+ *     locale is not set properly.
+ */
 void
 GetFont(font)
 MyFont *font;
 {
     char *deffontname = "fixed";
+    char **missing_charset_list_return;
+    int missing_charset_count_return;
+    char *def_string_return;
+    XFontSetExtents *font_extents;
+    XFontStruct **xfonts;
+    char **font_names;
+    register int i;
+    int ascent;
+    int descent;
+    int fnum;
+    char *basename2;
+
+    if (use_fontset) {
+	if (font->fontset != NULL){
+	    XFreeFontSet(dpy, font->fontset);
+	}
+
+	basename2 = (char *)malloc(strlen(font->name) + 3);
+	if (basename2) sprintf(basename2, "%s,*", font->name);
+	else basename2 = font->name;
+	if( (font->fontset = XCreateFontSet(dpy, basename2,
+					    &missing_charset_list_return,
+					    &missing_charset_count_return,
+					    &def_string_return)) == NULL) {
+	    fprintf (stderr, "%s:  unable to open fontset \"%s\"\n",
+			 ProgramName, font->name);
+	    exit(1);
+	}
+	if (basename2 != font->name) free(basename2);
+	for(i=0; i<missing_charset_count_return; i++){
+	    printf("%s: warning: font for charset %s is lacking.\n",
+		   ProgramName, missing_charset_list_return[i]);
+	}
+
+	font_extents = XExtentsOfFontSet(font->fontset);
+	fnum = XFontsOfFontSet(font->fontset, &xfonts, &font_names);
+	for( i = 0, ascent = 0, descent = 0; i<fnum; i++){
+	    if (ascent < (*xfonts)->ascent) ascent = (*xfonts)->ascent;
+	    if (descent < (*xfonts)->descent) descent = (*xfonts)->descent;
+	    xfonts++;
+	}
+	font->height = font_extents->max_logical_extent.height;
+	font->y = ascent;
+	font->ascent = ascent;
+	font->descent = descent;
+	return;
+    }
 
     if (font->font != NULL)
 	XFreeFont(dpy, font->font);
@@ -643,8 +700,139 @@
     }
     font->height = font->font->ascent + font->font->descent;
     font->y = font->font->ascent;
+    font->ascent = font->font->ascent;
+    font->descent = font->font->descent;
+}
+
+int
+MyFont_TextWidth(font, string, len)
+    MyFont *font;
+    char *string;
+    int len;
+{
+    XRectangle ink_rect;
+    XRectangle logical_rect;
+
+    if (use_fontset) {
+	XmbTextExtents(font->fontset, string, len,
+		       &ink_rect, &logical_rect);
+	return logical_rect.width;
+    }
+    return XTextWidth(font->font, string, len);
+}
+
+void
+MyFont_DrawImageString(dpy, d, font, gc, x, y, string, len)
+    Display *dpy;
+    Drawable d;
+    MyFont *font;
+    GC gc;
+    int x,y;
+    char *string;
+    int len;
+{
+    if (use_fontset) {
+	XmbDrawImageString(dpy, d, font->fontset, gc, x, y, string, len);
+	return;
+    }
+    XDrawImageString (dpy, d, gc, x, y, string, len);
+}
+
+void
+MyFont_DrawString(dpy, d, font, gc, x, y, string, len)
+    Display *dpy;
+    Drawable d;
+    MyFont *font;
+    GC gc;
+    int x,y;
+    char *string;
+    int len;
+{
+    if (use_fontset) {
+	XmbDrawString(dpy, d, font->fontset, gc, x, y, string, len);
+	return;
+    }
+    XDrawString (dpy, d, gc, x, y, string, len);
+}
+
+void
+MyFont_ChangeGC(fix_fore, fix_back, fix_font)
+    unsigned long fix_fore, fix_back;
+    MyFont *fix_font;
+{
+    Gcv.foreground = fix_fore;
+    Gcv.background = fix_back;
+    if (use_fontset) {
+	XChangeGC(dpy, Scr->NormalGC, GCForeground|GCBackground, &Gcv);
+	return;
+    }
+    Gcv.font = fix_font->font->fid;
+    XChangeGC(dpy, Scr->NormalGC, GCFont|GCForeground|GCBackground,&Gcv);
 }
 
+/*
+ * The following functions are internationalized substitutions
+ * for XFetchName and XGetIconName using XGetWMName and
+ * XGetWMIconName.  
+ *
+ * Please note that the third arguments have to be freed using free(), 
+ * not XFree().
+ */
+Status
+I18N_FetchName(dpy, w, winname)
+    Display *dpy;
+    Window w;
+    char ** winname;
+{
+    int    status;
+    XTextProperty text_prop;
+
+    status = XGetWMName(dpy, w, &text_prop);
+    if (!status || !text_prop.value || !text_prop.nitems) return 0;
+    if (text_prop.encoding == XA_STRING) {
+	if (!text_prop.value) {*winname = NULL; return 0;}
+	*winname = (char *)strdup((char *)text_prop.value);
+	XFree(text_prop.value);
+	return 1;
+    } else {
+	char **list;
+	int    num;
+	status = XmbTextPropertyToTextList(dpy, &text_prop, &list, &num);
+	if (!num || !*list) return 0;
+	XFree(text_prop.value);
+	*winname = (char *)strdup(*list);
+	XFreeStringList(list);
+	return 1;
+    }
+}
+
+Status
+I18N_GetIconName(dpy, w, iconname)
+    Display *dpy;
+    Window w;
+    char ** iconname;
+{
+    int    status;
+    XTextProperty text_prop;
+	
+    status = XGetWMIconName(dpy, w, &text_prop);
+    if (!status || !text_prop.value || !text_prop.nitems) return 0;
+    if (text_prop.encoding == XA_STRING) {
+	if (!text_prop.value) {*iconname = NULL; return 0;}
+	*iconname = (char *)strdup((char *)text_prop.value);
+	XFree(text_prop.value);
+	return 1;
+    } else {
+	char **list;
+	int    num;
+	status = XmbTextPropertyToTextList(dpy, &text_prop, &list, &num);
+	if (!num || !*list) return 0;
+	XFree(text_prop.value);
+	*iconname = (char *)strdup(*list);
+	XFreeStringList(list);
+	return 1;
+    }
+}
 
 /*
  * SetFocus - separate routine to set focus to make things more understandable
Index: xc/programs/twm/util.h
diff -u xc/programs/twm/util.h:1.4 xc/programs/twm/util.h:1.5
--- xc/programs/twm/util.h:1.4	Thu Feb 25 01:01:04 1999
+++ xc/programs/twm/util.h	Tue Oct 24 18:45:15 2000
@@ -44,7 +44,7 @@
 /**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
 /**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
 /*****************************************************************************/
-/* $XFree86: xc/programs/twm/util.h,v 1.4 1999/02/25 06:01:04 dawes Exp $ */
+/* $XFree86: xc/programs/twm/util.h,v 1.5 2000/10/24 22:45:15 dawes Exp $ */
 
 
 /***********************************************************************
@@ -75,6 +75,16 @@
 extern void GetColor ( int kind, Pixel *what, char *name );
 extern void GetColorValue ( int kind, XColor *what, char *name );
 extern void GetFont ( MyFont *font );
+extern int MyFont_TextWidth( MyFont *font, char *string, int len);
+extern void MyFont_DrawImageString( Display *dpy, Drawable d, MyFont *font, 
+				    GC gc, int x, int y, char * string, 
+				    int len);
+extern void MyFont_DrawString( Display *dpy, Drawable d, MyFont *font, 
+			       GC gc, int x, int y, char * string, int len);
+extern void MyFont_ChangeGC( unsigned long fix_fore, unsigned long fix_back, 
+			     MyFont *fix_font);
+extern Status I18N_FetchName( Display *dpy, Window win, char **winname);
+extern Status I18N_GetIconName( Display *dpy, Window win, char **iconname);
 extern void SetFocus ( TwmWindow *tmp_win, Time time );
 extern void Bell ( int type, int percent, Window win );
 
Index: xc/programs/viewres/viewres.c
diff -u xc/programs/viewres/viewres.c:1.4 xc/programs/viewres/viewres.c:1.5
--- xc/programs/viewres/viewres.c:1.4	Fri Feb 18 07:20:17 2000
+++ xc/programs/viewres/viewres.c	Tue Sep 26 11:57:23 2000
@@ -27,7 +27,7 @@
  * *
  * Author:  Jim Fulton, MIT X Consortium
  */
-/* $XFree86: xc/programs/viewres/viewres.c,v 1.4 2000/02/18 12:20:17 tsi Exp $ */
+/* $XFree86: xc/programs/viewres/viewres.c,v 1.5 2000/09/26 15:57:23 tsi Exp $ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -447,7 +447,7 @@
     XtPointer closure;			/* TRUE or FALSE */
     XtPointer data;
 {
-    set_labeltype_menu ((Boolean) (int) closure, True);
+    set_labeltype_menu ((Boolean) (long) closure, True);
 }
 
 /* ARGSUSED */
@@ -456,7 +456,7 @@
     XtPointer closure;			/* TRUE or FALSE */
     XtPointer data;
 {
-    set_orientation_menu ((XtGravity) closure, True);
+    set_orientation_menu ((XtGravity) (long) closure, True);
 }
 
 
@@ -562,7 +562,7 @@
     XtPointer closure;			/* BOOL_OFF, BOOL_ON, BOOL_TOGGLE */
     XtPointer data;			/* undefined */
 {
-    int op = (int) closure;
+    int op = (long) closure;
     XmuWidgetNode *node = widget_to_node (gw);
 
     if (node) {
@@ -594,7 +594,7 @@
     int nselected = selected_list.n_elements;
     XmuWidgetNode *node;
 
-    switch ((int) closure) {
+    switch ((long) closure) {
       case SELECT_NOTHING:		/* clear selection_list */
 	remove_nodes_from_selected_list (0, nselected, True);
 	break;
@@ -708,7 +708,7 @@
     XtPointer data;		/* on or off */
 {
     XmuWidgetNode *node = (XmuWidgetNode *) closure;
-    Boolean selected = (Boolean) (int) data;
+    Boolean selected = (Boolean) (long) data;
 
     if (selected) {
 	add_to_selected_list (node, FALSE);
@@ -1193,7 +1193,7 @@
     /*
      * use any old widget
      */
-    (*proc) (w, (XtPointer) obj, (XtPointer) NULL);
+    (*proc) (w, (XtPointer) (long) obj, (XtPointer) NULL);
 }
 
 
Index: xc/programs/x11perf/Imakefile
diff -u xc/programs/x11perf/Imakefile:3.0 xc/programs/x11perf/Imakefile:3.3
--- xc/programs/x11perf/Imakefile:3.0	Fri Feb  9 03:22:44 1996
+++ xc/programs/x11perf/Imakefile	Thu Nov 30 12:07:20 2000
@@ -1,5 +1,5 @@
 XCOMM $XConsortium: Imakefile,v 2.31 93/09/04 19:58:26 rws Exp $
-XCOMM $XFree86: xc/programs/x11perf/Imakefile,v 3.0 1996/02/09 08:22:44 dawes Exp $
+XCOMM $XFree86: xc/programs/x11perf/Imakefile,v 3.3 2000/11/30 17:07:20 dawes Exp $
 #ifndef X11perfcompLib
 #define X11perfcompLib $(LIBDIR)/x11perfcomp
 #endif
@@ -7,7 +7,12 @@
 #if HasShm
         SHMDEFS = -DMITSHM
 #endif
-        DEFINES = $(SIGNAL_DEFINES) $(SHMDEFS)
+#if BuildXftLibrary
+        XFTDEFS = -DXFT
+        XFTDEPS = XftClientDepLibs $(DEPXRENDERLIB)
+        XFTLIBS = XftClientLibs $(XRENDERLIB)
+#endif
+        DEFINES = $(SIGNAL_DEFINES) $(SHMDEFS) $(XFTDEFS)
         PERFLIB = X11perfcompLib
         HEADERS = x11perf.h bitmaps.h
            SRCS = x11perf.c bitmaps.c do_tests.c \
@@ -22,8 +27,8 @@
 		  do_dots.o do_windows.o do_movewin.o do_text.o \
 		  do_blt.o do_arcs.o \
 		  do_tris.o do_complex.o do_traps.o
-LOCAL_LIBRARIES = $(XMULIB) $(XLIB)
-        DEPLIBS = $(DEPXMULIB) $(DEPXLIB)
+LOCAL_LIBRARIES = $(XFTLIBS) $(XMULIB) $(XLIB)
+        DEPLIBS = $(XFTDEPS) $(DEPXMULIB) $(DEPXLIB)
   SYS_LIBRARIES = MathLibrary
 
 #ifndef OS2Architecture
@@ -38,6 +43,7 @@
 InstallNamedProg(perfboth.sh,perfboth,$(PERFLIB))
 InstallNamedProg(perfratio.sh,perfratio,$(PERFLIB))
 InstallNamedProg(Xmark.sh,Xmark,$(BINDIR))
+InstallManPage(Xmark,$(MANDIR))
 InstallManPageLong(x11pcomp,$(MANDIR),x11perfcomp)
 #else
 all::
Index: xc/programs/x11perf/Xmark.man
diff -u /dev/null xc/programs/x11perf/Xmark.man:1.1
--- /dev/null	Mon Dec 18 14:34:01 2000
+++ xc/programs/x11perf/Xmark.man	Sat Aug 26 00:30:59 2000
@@ -0,0 +1,69 @@
+.\" This manpage was written by Richard Braakman and is licensed under the
+.\" XFree86 license.
+.\" $XFree86: xc/programs/x11perf/Xmark.man,v 1.1 2000/08/26 04:30:59 dawes Exp $
+.TH Xmark 1 "Release 6.4" "X Version 11"
+.SH NAME
+Xmark \- summarize x11perf results
+.SH SYNTAX
+.B Xmark
+datafile
+.SH DESCRIPTION
+.B Xmark
+is a shell script that reads the indicated datafile and compiles a
+benchmark which it writes to standard output.  It writes three
+numbers:
+.PP
+.RS
+A weighted performance number for the
+.I x11perf
+results.
+.PP
+A weighted performance number for a standard SparcStation 1, with
+SunOS 4.1.2, X11R5 Xsun, and a CG3 dumb Color Frame Buffer.
+.\" I assume the latter is a graphics card.
+.PP
+The Xmark, which is the ratio of the two numbers above.
+.RE
+.PP
+The datafile must be an ordinary file, produced by x11perf in the
+following way:
+.PP
+.BI "x11perf -display " display " -v1.3 -rop GXcopy GXxor -all > " datafile
+.PP
+It is possible to run the GXcopy and GXxor tests separately, as long as they
+are concatenated to the same output file:
+.PP
+.BI "x11perf -display " display " -v1.3 -rop GXcopy -all > " datafile 
+.br
+.BI "x11perf -display " display " -v1.3 -rop GXxor -all >> " datafile 
+.PP
+or
+.PP
+.BI "x11perf -display " display " -v1.3 -rop GXxor -all > " datafile 
+.br
+.BI "x11perf -display " display " -v1.3 -rop GXcopy -all >> " datafile 
+.PP
+.SH FILES
+.TP
+.B temp.$$
+Temporary file created in the current directory, deleted after use.
+.SH DIAGNOSTICS
+.TP
+.B Usage: Xmark datafile
+.I Xmark
+was invoked without arguments or with more than one argument, or 
+with options.  Xmark takes no options.
+.TP
+.B "Error: data file does not exist or is not ordinary."
+.I Xmark
+cannot find the datafile named on its command line, or the datafile
+is a special file such as a directory.
+.TP
+.BR "WARNING: datafile contains " nnn ", not 441 or 447 'trep' results;"
+The file named on the command line does not seem to be a file generated
+by x11perf in the expected way.
+.TP
+.BR "Diagnostic: ERROR: sum of weights =" nnn ", not equal to 4566.0;"
+There is an internal error in Xmark.
+.SH "SEE ALSO"
+X(1), x11perf(1), x11perfcomp(1)
Index: xc/programs/x11perf/do_arcs.c
diff -u xc/programs/x11perf/do_arcs.c:1.3 xc/programs/x11perf/do_arcs.c:1.4
--- xc/programs/x11perf/do_arcs.c:1.3	Tue Mar  2 06:49:29 1999
+++ xc/programs/x11perf/do_arcs.c	Wed Nov 29 03:58:19 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_arcs.c,v 1.3 1999/03/02 11:49:29 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_arcs.c,v 1.4 2000/11/29 08:58:19 keithp Exp $ */
 
 #include "x11perf.h"
 
@@ -468,6 +468,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
@@ -486,6 +487,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/do_blt.c
diff -u xc/programs/x11perf/do_blt.c:1.4 xc/programs/x11perf/do_blt.c:1.6
--- xc/programs/x11perf/do_blt.c:1.4	Sun Feb 28 06:19:52 1999
+++ xc/programs/x11perf/do_blt.c	Wed Nov 29 03:58:19 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_blt.c,v 1.4 1999/02/28 11:19:52 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_blt.c,v 1.6 2000/11/29 08:58:19 keithp Exp $ */
 
 #include "x11perf.h"
 #include <stdio.h>
@@ -108,6 +108,7 @@
 		x = xorg;
 	    }
 	}
+	CheckAbort ();
     }
 }
 
@@ -245,6 +246,7 @@
 	    sb->x2, sb->y2, size, size, sb->x1, sb->y1);
 	XCopyArea(xp->d, src, dst, xp->fggc,
 	    sb->x1, sb->y1, size, size, sb->x2, sb->y2);
+	CheckAbort ();
     }
 }
 
@@ -311,6 +313,7 @@
 	(void) XGetSubImage(xp->d, xp->w, sb->x1, sb->y1, size, size,
 	    xp->planemask, ZPixmap, image, sb->x2, sb->y2);
 */
+	CheckAbort ();
     }
 }
 
@@ -330,6 +333,7 @@
 	    sb->x2, sb->y2, sb->x2, sb->y2, size, size);
 	XPutImage(xp->d, xp->w, xp->fggc, image,
 	    sb->x1, sb->y1, sb->x2, sb->y2, size, size);
+	CheckAbort ();
     }
 }
 
@@ -337,7 +341,11 @@
 
 #include <sys/types.h>
 #ifndef Lynx
+#ifndef __CYGWIN__
 #include <sys/ipc.h>
+#else
+#include <sys/cygipc.h>
+#endif
 #include <sys/shm.h>
 #else
 #include <ipc.h>
@@ -424,6 +432,7 @@
 	    sb->x2, sb->y2, sb->x2, sb->y2, size, size, False);
 	XShmPutImage(xp->d, xp->w, xp->fggc, &shm_image,
 	    sb->x1, sb->y1, sb->x2, sb->y2, size, size, False);
+	CheckAbort ();
     }
 }
 
@@ -518,6 +527,7 @@
 	    sb->x2, sb->y2, size, size, sb->x1, sb->y1, 1);
 	XCopyPlane(xp->d, pix, xp->w, xp->fggc,
 	    sb->x1, sb->y1, size, size, sb->x2, sb->y2, 1);
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/do_complex.c
diff -u xc/programs/x11perf/do_complex.c:1.4 xc/programs/x11perf/do_complex.c:1.5
--- xc/programs/x11perf/do_complex.c:1.4	Sun Dec 26 19:40:07 1999
+++ xc/programs/x11perf/do_complex.c	Wed Nov 29 03:58:19 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_complex.c,v 1.4 1999/12/27 00:40:07 robin Exp $ */
+/* $XFree86: xc/programs/x11perf/do_complex.c,v 1.5 2000/11/29 08:58:19 keithp Exp $ */
 
 #include "x11perf.h"
 
@@ -122,6 +122,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
@@ -198,5 +199,6 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
Index: xc/programs/x11perf/do_dots.c
diff -u xc/programs/x11perf/do_dots.c:1.3 xc/programs/x11perf/do_dots.c:1.4
--- xc/programs/x11perf/do_dots.c:1.3	Tue Mar  2 06:49:29 1999
+++ xc/programs/x11perf/do_dots.c	Wed Nov 29 03:58:19 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_dots.c,v 1.3 1999/03/02 11:49:29 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_dots.c,v 1.4 2000/11/29 08:58:19 keithp Exp $ */
 
 #include "x11perf.h"
 
@@ -55,6 +55,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/do_lines.c
diff -u xc/programs/x11perf/do_lines.c:1.3 xc/programs/x11perf/do_lines.c:1.4
--- xc/programs/x11perf/do_lines.c:1.3	Tue Mar  2 06:49:29 1999
+++ xc/programs/x11perf/do_lines.c	Wed Nov 29 03:58:19 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_lines.c,v 1.3 1999/03/02 11:49:29 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_lines.c,v 1.4 2000/11/29 08:58:19 keithp Exp $ */
 
 #include "x11perf.h"
 
@@ -290,6 +290,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/do_movewin.c
diff -u xc/programs/x11perf/do_movewin.c:1.3 xc/programs/x11perf/do_movewin.c:1.4
--- xc/programs/x11perf/do_movewin.c:1.3	Tue Mar  2 06:49:29 1999
+++ xc/programs/x11perf/do_movewin.c	Wed Nov 29 03:58:19 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_movewin.c,v 1.3 1999/03/02 11:49:29 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_movewin.c,v 1.4 2000/11/29 08:58:19 keithp Exp $ */
 
 #include "x11perf.h"
 
@@ -80,6 +80,7 @@
 	    XMoveWindow(xp->d, children[j],
 	    positions[j].x + x_offset, positions[j].y + y_offset);
 	}
+	CheckAbort ();
     }
 }
 
@@ -103,6 +104,7 @@
 	    XResizeWindow(xp->d, children[j],
 		CHILDSIZE+delta2, CHILDSIZE-delta2);
 	}
+	CheckAbort ();
     }
 }
 
@@ -132,8 +134,11 @@
     int     i, j;
 
     for (i = 0; i != reps; i++)
+    {
 	for (j = 0; j != p->objects; j++)
 	    XCirculateSubwindows (xp->d, xp->w, RaiseLowest);
+	CheckAbort ();
+    }
 }
 
 void 
@@ -189,6 +194,7 @@
 	if (x_offset + xmax > WIDTH)
 	    x_offset = 0;
 	XMoveWindow(xp->d, cover, x_offset, y_offset);
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/do_rects.c
diff -u xc/programs/x11perf/do_rects.c:1.3 xc/programs/x11perf/do_rects.c:1.4
--- xc/programs/x11perf/do_rects.c:1.3	Tue Mar  2 06:49:30 1999
+++ xc/programs/x11perf/do_rects.c	Wed Nov 29 03:58:19 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_rects.c,v 1.3 1999/03/02 11:49:30 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_rects.c,v 1.4 2000/11/29 08:58:19 keithp Exp $ */
 
 #include "x11perf.h"
 #include "bitmaps.h"
@@ -96,6 +96,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
@@ -110,6 +111,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/do_segs.c
diff -u xc/programs/x11perf/do_segs.c:1.3 xc/programs/x11perf/do_segs.c:1.4
--- xc/programs/x11perf/do_segs.c:1.3	Tue Mar  2 06:49:30 1999
+++ xc/programs/x11perf/do_segs.c	Wed Nov 29 03:58:20 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_segs.c,v 1.3 1999/03/02 11:49:30 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_segs.c,v 1.4 2000/11/29 08:58:20 keithp Exp $ */
 
 #include "x11perf.h"
 
@@ -373,6 +373,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/do_simple.c
diff -u xc/programs/x11perf/do_simple.c:1.3 xc/programs/x11perf/do_simple.c:1.4
--- xc/programs/x11perf/do_simple.c:1.3	Tue Mar  2 06:49:30 1999
+++ xc/programs/x11perf/do_simple.c	Wed Nov 29 03:58:20 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_simple.c,v 1.3 1999/03/02 11:49:30 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_simple.c,v 1.4 2000/11/29 08:58:20 keithp Exp $ */
 
 #ifndef VMS
 #include <X11/Xatom.h>
@@ -41,6 +41,7 @@
 
     for (i = 0; i != reps; i++) {
 	XNoOp(xp->d);
+	CheckAbort ();
     }
 }
 
@@ -54,6 +55,7 @@
     for (i = 0; i != reps; i++) {
 	atom = XGetAtomName (xp->d, 1);
  	XFree(atom); /* fix XBUG 6480 */
+	CheckAbort ();
     }
 }
 
@@ -67,6 +69,7 @@
 
     for (i = 0; i != reps; i++) {
 	XQueryPointer (xp->d, xp->w, &w, &w, &x, &x, &x, &x, &m);
+	CheckAbort ();
     }
 }
 
@@ -102,5 +105,6 @@
 		xp->d, xp->w, XA_PK_TEMP, 0, 4,
 		False, AnyPropertyType, &actual_type, &actual_format,
 		&actual_length, &bytes_remaining, &prop);
+	CheckAbort ();
     }
 }
Index: xc/programs/x11perf/do_tests.c
diff -u xc/programs/x11perf/do_tests.c:1.3 xc/programs/x11perf/do_tests.c:1.6
--- xc/programs/x11perf/do_tests.c:1.3	Tue Mar  2 06:49:31 1999
+++ xc/programs/x11perf/do_tests.c	Fri Dec  8 04:51:03 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_tests.c,v 1.3 1999/03/02 11:49:31 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_tests.c,v 1.6 2000/12/08 09:51:03 keithp Exp $ */
 
 #include "x11perf.h"
 
@@ -905,6 +905,44 @@
 		{30, False, 
 		"-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1",
  		NULL}},
+#ifdef XFT
+  {"-aa10text", "Char in 80-char aa line (Charter 10)", NULL,
+	        InitAAText, DoAAText, ClearTextWin, EndAAText,
+		V1_5FEATURE, NONROP, 0,
+		{80, 10, "charter:antialias=true:rgba=0:pixelsize=10", NULL}},
+  {"-aa24text", "Char in 30-char aa line (Charter 24)", NULL,
+	        InitAAText, DoAAText, ClearTextWin, EndAAText,
+		V1_5FEATURE, NONROP, 0,
+		{30, 24, "charter:antialias=true:rgba=0:pixelsize=24", NULL}},
+  {"-aaftext", "Char in 80-char aa line (Courier 12)", NULL,
+	        InitAAText, DoAAText, ClearTextWin, EndAAText,
+		V1_5FEATURE, NONROP, 0,
+		{80, 12, "courier:antialias=true:rgba=0:pixelsize=12", NULL}},
+  {"-a10text", "Char in 80-char a line (Charter 10)", NULL,
+	        InitAAText, DoAAText, ClearTextWin, EndAAText,
+		V1_5FEATURE, NONROP, 0,
+		{80, 10, "charter:antialias=false:rgba=0:pixelsize=10", NULL}},
+  {"-a24text", "Char in 30-char a line (Charter 24)", NULL,
+	        InitAAText, DoAAText, ClearTextWin, EndAAText,
+		V1_5FEATURE, NONROP, 0,
+		{30, 24, "charter:antialias=false:rgba=0:pixelsize=24", NULL}},
+  {"-aftext", "Char in 80-char a line (Courier 12)", NULL,
+	        InitAAText, DoAAText, ClearTextWin, EndAAText,
+		V1_5FEATURE, NONROP, 0,
+		{80, 12, "courier:antialias=false:rgba=0:pixelsize=12", NULL}},
+  {"-rgb10text", "Char in 80-char rgb line (Charter 10)", NULL,
+	        InitAAText, DoAAText, ClearTextWin, EndAAText,
+		V1_5FEATURE, NONROP, 0,
+		{80, 10, "charter:antialias=true:rgba=rgb:pixelsize=10", NULL}},
+  {"-rgb24text", "Char in 30-char rgb line (Charter 24)", NULL,
+	        InitAAText, DoAAText, ClearTextWin, EndAAText,
+		V1_5FEATURE, NONROP, 0,
+		{30, 24, "charter:antialias=true:rgba=rgb:pixelsize=24", NULL}},
+  {"-rgbftext", "Char in 80-char rgb line (Courier 12)", NULL,
+	        InitAAText, DoAAText, ClearTextWin, EndAAText,
+		V1_5FEATURE, NONROP, 0,
+		{80, 12, "courier:antialias=true:rgba=rgb:pixelsize=12", NULL}},
+#endif
   {"-scroll10", "Scroll 10x10 pixels", NULL,
 		InitScroll, DoScroll, MidScroll, EndScroll,
 		V1_2FEATURE, ROP, 0,
Index: xc/programs/x11perf/do_text.c
diff -u xc/programs/x11perf/do_text.c:1.3 xc/programs/x11perf/do_text.c:1.6
--- xc/programs/x11perf/do_text.c:1.3	Tue Mar  2 06:49:31 1999
+++ xc/programs/x11perf/do_text.c	Fri Dec  8 23:48:45 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_text.c,v 1.3 1999/03/02 11:49:31 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_text.c,v 1.6 2000/12/09 04:48:45 keithp Exp $ */
 
 #include "x11perf.h"
 #include <stdio.h>
@@ -237,6 +237,7 @@
 	    startLine = (startLine + 1) % totalLines;
 	}
 	line = (line + 1) % totalLines;
+	CheckAbort ();
     }
 }
 
@@ -258,6 +259,7 @@
 	    startLine = (startLine + 1) % totalLines;
 	}
 	line = (line + 1) % totalLines;
+	CheckAbort ();
     }
 }
 
@@ -279,6 +281,7 @@
 	    startLine = (startLine + 1) % totalLines;
 	}
 	line = (line + 1) % totalLines;
+	CheckAbort ();
     }
 }
 
@@ -300,6 +303,7 @@
 	    startLine = (startLine + 1) % totalLines;
 	}
 	line = (line + 1) % totalLines;
+	CheckAbort ();
     }
 }
 
@@ -321,6 +325,7 @@
 	    line = startLine;
 	}
 	line = (line + 1) % totalLines;
+	CheckAbort ();
     }
 }
 
@@ -342,6 +347,7 @@
 	    line = startLine;
 	}
 	line = (line + 1) % totalLines;
+	CheckAbort ();
     }
 }
 
@@ -392,3 +398,125 @@
     }
 }
 
+#ifdef XFT
+#include <X11/extensions/Xrender.h>
+#include <X11/Xft/Xft.h>
+
+static XftFont	*aafont;
+static XftDraw	*aadraw;
+static XftColor	aacolor;
+
+int 
+InitAAText(XParms xp, Parms p, int reps)
+{
+    int			i, j;
+    char		ch;
+    XRenderColor	color;
+
+    aafont = XftFontOpenName (xp->d, DefaultScreen (xp->d), p->font);
+    
+    if (aafont == NULL) 
+    {
+	printf("Could not load font '%s', benchmark omitted\n", 
+	       p->font);
+	return 0;
+    }
+
+    if (aafont->core)
+    {
+	printf ("FreeType font '%s' not available, benchmark omitted\n",
+		p->font);
+	XftFontClose (xp->d, aafont);
+	return 0;
+    }
+    
+    aadraw = XftDrawCreate (xp->d, xp->w, 
+			    DefaultVisual (xp->d, DefaultScreen (xp->d)), 
+			    DefaultColormap (xp->d, DefaultScreen (xp->d)));
+
+    if (!aadraw) 
+    {
+	printf ("Render extension not supported in window\n");
+	XftFontClose (xp->d, aafont);
+	return 0;
+    }
+    color.red = 0;
+    color.green = 0;
+    color.blue = 0;
+    color.alpha = 0xffff;
+    if (!XftColorAllocValue (xp->d,
+			     DefaultVisual (xp->d, DefaultScreen (xp->d)), 
+			     DefaultColormap (xp->d, DefaultScreen (xp->d)),
+			     &color, &aacolor))
+    {
+	printf ("Cannot allocate black\n");
+	XftFontClose (xp->d, aafont);
+	XftDrawDestroy (aadraw);
+	aafont = 0;
+	aadraw = 0;
+	return 0;
+    }
+    
+    ypos = XPOS;
+    height = aafont->height;
+    
+    charsPerLine = p->objects;
+    charsPerLine = (charsPerLine + 3) & ~3;
+    p->objects = charsPerLine;
+
+    totalLines = '\177' - ' ' + 1;
+    if (totalLines > reps) totalLines = reps;
+
+    charBuf = (char **) malloc(totalLines*sizeof (char *));
+
+    for (i = 0; i != totalLines; i++) {
+	charBuf[i] = (char *) malloc (sizeof (char)*charsPerLine);
+	ch = i + ' ';
+	for (j = 0; j != charsPerLine; j++) {
+	    charBuf[i][j] = ch;
+	    if (ch == '\177') ch = ' '; else ch++;
+	}
+    }
+    return reps;
+}
+
+void 
+DoAAText(XParms xp, Parms p, int reps)
+{
+    int     i, line, startLine;
+
+    startLine = 0;
+    line = 0;
+    for (i = 0; i != reps; i++) {
+	XftDrawString8 (aadraw, &aacolor, aafont, 
+		       XPOS, ypos, (unsigned char *) charBuf[line], charsPerLine);
+	ypos += height;
+	if (ypos > HEIGHT - height) {
+	    /* Wraparound to top of window */
+	    ypos = XPOS;
+	    line = startLine;
+	    startLine = (startLine + 1) % totalLines;
+	}
+	line = (line + 1) % totalLines;
+	CheckAbort ();
+    }
+}
+
+void 
+EndAAText(XParms xp, Parms p)
+{
+    int i;
+
+    if(!aadraw)return;
+    for (i = 0; i != totalLines; i++)
+	free(charBuf[i]);
+    free(charBuf);
+    XftDrawDestroy (aadraw);
+    XftFontClose (xp->d, aafont);
+    XftColorFree (xp->d,
+		  DefaultVisual (xp->d, DefaultScreen (xp->d)), 
+		  DefaultColormap (xp->d, DefaultScreen (xp->d)),
+		  &aacolor);
+}
+
+#endif
Index: xc/programs/x11perf/do_traps.c
diff -u xc/programs/x11perf/do_traps.c:1.3 xc/programs/x11perf/do_traps.c:1.4
--- xc/programs/x11perf/do_traps.c:1.3	Tue Mar  2 06:49:32 1999
+++ xc/programs/x11perf/do_traps.c	Wed Nov 29 03:58:20 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_traps.c,v 1.3 1999/03/02 11:49:32 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_traps.c,v 1.4 2000/11/29 08:58:20 keithp Exp $ */
 
 #include "x11perf.h"
 #include "bitmaps.h"
@@ -96,6 +96,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/do_tris.c
diff -u xc/programs/x11perf/do_tris.c:1.3 xc/programs/x11perf/do_tris.c:1.4
--- xc/programs/x11perf/do_tris.c:1.3	Tue Mar  2 06:49:32 1999
+++ xc/programs/x11perf/do_tris.c	Wed Nov 29 03:58:20 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_tris.c,v 1.3 1999/03/02 11:49:32 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_tris.c,v 1.4 2000/11/29 08:58:20 keithp Exp $ */
 
 
 #undef POLYTRIANGLE_HACK    /* don't use this code */
@@ -150,6 +150,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 
@@ -220,6 +221,7 @@
             pgc = xp->fggc;
         else
             pgc = xp->bggc;
+	CheckAbort ();
     }
 }
 #endif
Index: xc/programs/x11perf/do_valgc.c
diff -u xc/programs/x11perf/do_valgc.c:1.3 xc/programs/x11perf/do_valgc.c:1.4
--- xc/programs/x11perf/do_valgc.c:1.3	Tue Mar  2 06:49:32 1999
+++ xc/programs/x11perf/do_valgc.c	Wed Nov 29 03:58:20 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_valgc.c,v 1.3 1999/03/02 11:49:32 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_valgc.c,v 1.4 2000/11/29 08:58:20 keithp Exp $ */
 
 #ifndef VMS
 #include <X11/Xatom.h>
@@ -65,6 +65,7 @@
         gcv.foreground = xp->foreground;
         XChangeGC(xp->d, xp->fggc, GCForeground , &gcv);
         XDrawPoint(xp->d, win[1], xp->fggc, 5, 5);       
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/do_windows.c
diff -u xc/programs/x11perf/do_windows.c:1.3 xc/programs/x11perf/do_windows.c:1.4
--- xc/programs/x11perf/do_windows.c:1.3	Tue Mar  2 06:49:32 1999
+++ xc/programs/x11perf/do_windows.c	Wed Nov 29 03:58:20 2000
@@ -21,7 +21,7 @@
 SOFTWARE.
 
 ******************************************************************************/
-/* $XFree86: xc/programs/x11perf/do_windows.c,v 1.3 1999/03/02 11:49:32 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/do_windows.c,v 1.4 2000/11/29 08:58:20 keithp Exp $ */
 
 #include "x11perf.h"
 
@@ -268,6 +268,7 @@
     for (i = 0; i != reps; i++) {
         XMapWindow(xp->d, popup);
 	XUnmapWindow(xp->d, popup);
+	CheckAbort ();
     }
 }
 
Index: xc/programs/x11perf/x11perf.c
diff -u xc/programs/x11perf/x11perf.c:3.2 xc/programs/x11perf/x11perf.c:3.3
--- xc/programs/x11perf/x11perf.c:3.2	Mon Jun 19 11:01:03 2000
+++ xc/programs/x11perf/x11perf.c	Wed Nov 29 03:58:20 2000
@@ -1,5 +1,5 @@
 /* $XConsortium: x11perf.c,v 2.54 94/03/30 19:40:27 gildea Exp $ */
-/* $XFree86: xc/programs/x11perf/x11perf.c,v 3.2 2000/06/19 15:01:03 tsi Exp $ */
+/* $XFree86: xc/programs/x11perf/x11perf.c,v 3.3 2000/11/29 08:58:20 keithp Exp $ */
 /****************************************************************************
 Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
 
@@ -48,6 +48,8 @@
 /* Only for working on ``fake'' servers, for hardware that doesn't exist */
 static Bool     drawToFakeServer = False;
 static Pixmap   tileToQuery     = None;
+static char *displayName;
+int	abortTest;
 
 typedef struct _RopNames { char	*name; int  rop; } RopNameRec, *RopNamePtr;
 
@@ -404,15 +406,20 @@
 #endif
 Cleanup(int sig)
 {
+    abortTest = sig;
+}
+
+void
+AbortTest(void)
+{
     fflush(stdout);
-    /* This will screw up if Xlib is in the middle of something */
+    
     XSetScreenSaver(xparms.d, ssTimeout, ssInterval, ssPreferBlanking,
 	ssAllowExposures);
     XFlush(xparms.d);
-    exit(sig);
+    exit (abortTest);
 }
 
-
 /************************************************
 *		Performance stuff		*
 ************************************************/
@@ -509,6 +516,7 @@
     
     for (i = 0; i != reps; i++) {
 	HardwareSync(xp);
+	CheckAbort ();
     }
 }
 
@@ -594,6 +602,7 @@
     HardwareSync(xp);
 
     time = ElapsedTime(syncTime);
+    CheckAbort ();
     if (drawToFakeServer)
         XQueryBestSize(xp->d, TileShape, tileToQuery,
 		       32, 32, &ret_width, &ret_height);
@@ -628,6 +637,7 @@
 	XDestroySubwindows(xp->d, xp->w);
 	XClearWindow(xp->d, xp->w);
 	didreps = (*test->init) (xp, &test->parms, reps);
+	CheckAbort ();
 	if (didreps == 0) {
 	    return 0;
 	}
@@ -642,6 +652,7 @@
 	usecs = ElapsedTime(syncTime);
 	(*test->cleanup) (xp, &test->parms);
 	DestroyClipWindows(xp, test->clips);
+	CheckAbort ();
 
 	if (didreps != reps) {
 	    /* The test can't do the number of reps as we asked for.  
@@ -791,6 +802,8 @@
 	XDestroySubwindows(xp->d, xp->w);
 	XClearWindow(xp->d, xp->w);
 	reps = (*test->init) (xp, &test->parms, reps);
+	if (abortTest)
+	    AbortTest ();
 	/*
 	 * if using fixedReps then will not have done CalibrateTest so must
 	 * check result of init for 0 here
@@ -852,12 +865,12 @@
     int		i, j, n, skip;
     int		numTests;       /* Even though the linker knows, we don't. */
     char	hostname[100];
-    char	*displayName;
     Bool	foundOne = False;
     Bool	synchronous = False;
     XGCValues	tgcv;
     int		screen;
     int		rop, pm;
+    int		window_y, window_x;
     XVisualInfo *vinfolist, vinfotempl;
     unsigned long vmask;
 
@@ -1214,14 +1227,20 @@
 	AllocateColor(xparms.d, background, WhitePixel(xparms.d, screen));
     xparms.ddbackground =
 	AllocateColor(xparms.d, ddbackground, WhitePixel(xparms.d, screen));
-    xparms.w = CreatePerfWindow(&xparms, 2, 2, WIDTH, HEIGHT);
+    window_x = 2;
+    if (DisplayWidth(xparms.d, screen) < WIDTH + window_x + 1)
+	window_x = -1;
+    window_y = 2;
+    if (DisplayHeight(xparms.d, screen) < HEIGHT + window_y + 1)
+	window_y = -1;
+    xparms.w = CreatePerfWindow(&xparms, window_x, window_y, WIDTH, HEIGHT);
     HSx = WIDTH-1;
-    if (3 + WIDTH > DisplayWidth(xparms.d, screen))
-	HSx = DisplayWidth(xparms.d, screen) - 4;
+    if (window_x + 1 + WIDTH > DisplayWidth(xparms.d, screen))
+	HSx = DisplayWidth(xparms.d, screen) - (1 + window_x + 1);
     HSy = HEIGHT-1;
-    if (3 + HEIGHT > DisplayHeight(xparms.d, screen))
-	HSy = DisplayHeight(xparms.d, screen) - 4;
-    status = CreatePerfWindow(&xparms, 2, HEIGHT+5, WIDTH, 20);
+    if (window_y + 1 + HEIGHT > DisplayHeight(xparms.d, screen))
+	HSy = DisplayHeight(xparms.d, screen) - (1 + window_y + 1);
+    status = CreatePerfWindow(&xparms, window_x, HEIGHT+5, WIDTH, 20);
     tgcv.foreground = 
 	AllocateColor(xparms.d, "black", BlackPixel(xparms.d, screen));
     tgcv.background = 
@@ -1237,7 +1256,7 @@
        software cursor machines it will slow graphics performance.  On
        all current MIT-derived servers it will slow window 
        creation/configuration performance. */
-    XWarpPointer(xparms.d, None, status, 0, 0, 0, 0, WIDTH+10, 20+10);
+    XWarpPointer(xparms.d, None, status, 0, 0, 0, 0, WIDTH+32, 20+32);
 
     /* Figure out how long to call HardwareSync, so we can adjust for that
        in our total elapsed time */
Index: xc/programs/x11perf/x11perf.h
diff -u xc/programs/x11perf/x11perf.h:3.1 xc/programs/x11perf/x11perf.h:3.2
--- xc/programs/x11perf/x11perf.h:3.1	Sun Feb 28 06:20:01 1999
+++ xc/programs/x11perf/x11perf.h	Wed Nov 29 03:58:20 2000
@@ -1,5 +1,5 @@
 /* $XConsortium: x11perf.h,v 2.13 94/03/17 20:25:53 dpw Exp $ */
-/* $XFree86: xc/programs/x11perf/x11perf.h,v 3.1 1999/02/28 11:20:01 dawes Exp $ */
+/* $XFree86: xc/programs/x11perf/x11perf.h,v 3.2 2000/11/29 08:58:20 keithp Exp $ */
 /*****************************************************************************
 Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
 
@@ -125,6 +125,11 @@
 
 extern Test test[];
 
+extern int abortTest;
+
+extern void AbortTest (void);
+
+#define CheckAbort()  if (abortTest) AbortTest ()
 #define ForEachTest(x) for (x = 0; test[x].option != NULL; x++)
 
 
@@ -250,6 +255,11 @@
 extern void ClearTextWin ( XParms xp, Parms p );
 extern void EndText ( XParms xp, Parms p );
 extern void EndText16 ( XParms xp, Parms p );
+#ifdef XFT
+extern int InitAAText (XParms xp, Parms p, int reps );
+extern void DoAAText (XParms xp, Parms p, int reps );
+extern void EndAAText ( XParms xp, Parms p );
+#endif
 
 /* do_traps.c */
 extern int InitTrapezoids ( XParms xp, Parms p, int reps );
Index: xc/programs/xclock/Clock.c
diff -u xc/programs/xclock/Clock.c:3.6 xc/programs/xclock/Clock.c:3.8
--- xc/programs/xclock/Clock.c:3.6	Fri Feb 25 13:28:12 2000
+++ xc/programs/xclock/Clock.c	Wed Nov  1 21:51:24 2000
@@ -42,7 +42,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/programs/xclock/Clock.c,v 3.6 2000/02/25 18:28:12 dawes Exp $ */
+/* $XFree86: xc/programs/xclock/Clock.c,v 3.8 2000/11/02 02:51:24 dawes Exp $ */
 
 #include <X11/Xlib.h>
 #include <X11/StringDefs.h>
@@ -50,6 +50,7 @@
 #include "ClockP.h"
 #include <X11/Xosdefs.h>
 #include <stdio.h>
+#include <X11/Xos.h>
 
 #if defined(__STDC__) && !defined(AIXV3) /* AIX is broken */
 #define Const const
@@ -109,6 +110,8 @@
         offset(Hdpixel), XtRString, XtDefaultForeground},
     {XtNhighlight, XtCForeground, XtRPixel, sizeof(Pixel),
         offset(Hipixel), XtRString, XtDefaultForeground},
+    {XtNutime, XtCBoolean, XtRBoolean, sizeof(Boolean),
+	offset(utime), XtRImmediate, (XtPointer) FALSE},
     {XtNanalog, XtCBoolean, XtRBoolean, sizeof(Boolean),
         offset(analog), XtRImmediate, (XtPointer) TRUE},
     {XtNbrief, XtCBoolean, XtRBoolean, sizeof(Boolean),
@@ -216,6 +219,14 @@
       sprintf (brief, "%02d:%02d", tm->tm_hour, tm->tm_min);
       return brief;
    }
+   else if (w->clock.utime)
+   {
+      static char utime[35];
+      Time_t tsec;
+      tsec = time(NULL);
+      sprintf (utime, "%10lu seconds since Epoch", (unsigned long)tsec);
+      return utime;
+   }
    return asctime (tm);
 }
 
@@ -359,15 +370,17 @@
         ClockWidget w = (ClockWidget)client_data;    
 	struct tm tm; 
 	Time_t	time_value;
+	struct timeval	tv;
 	char	*time_ptr;
         register Display *dpy = XtDisplay(w);
         register Window win = XtWindow(w);
 
+	X_GETTIMEOFDAY (&tv);
 	if (id || !w->clock.interval_id)
 	    w->clock.interval_id =
 		XtAppAddTimeOut( XtWidgetToApplicationContext( (Widget) w),
-				w->clock.update*1000, clock_tic, (XtPointer)w );
-	(void) time(&time_value);
+				(w->clock.update - 1) * 1000 + (1000000 - tv.tv_usec)/1000, clock_tic, (XtPointer)w );
+	time_value = tv.tv_sec;
 	tm = *localtime(&time_value);
 	/*
 	 * Beep on the half hour; double-beep on the hour.
Index: xc/programs/xclock/Clock.h
diff -u xc/programs/xclock/Clock.h:1.3 xc/programs/xclock/Clock.h:1.4
--- xc/programs/xclock/Clock.h:1.3	Fri Jan 21 13:41:50 2000
+++ xc/programs/xclock/Clock.h	Wed Nov  1 21:51:24 2000
@@ -45,7 +45,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/programs/xclock/Clock.h,v 1.3 2000/01/21 18:41:50 dawes Exp $ */
+/* $XFree86: xc/programs/xclock/Clock.h,v 1.4 2000/11/02 02:51:24 dawes Exp $ */
 
 #ifndef _XawClock_h
 #define _XawClock_h
@@ -76,6 +76,7 @@
  highlight	     Foreground		Pixel		black
  mappedWhenManaged   MappedWhenManaged	Boolean		True
  padding	     Margin		int		8
+ utime		     Boolean		Boolean		False
  update		     Interval		int		60 (seconds)
  width		     Width		Dimension	164
  x		     Position		Position	0
@@ -94,6 +95,9 @@
 
 		/* Boolean: only hour/minute if TRUE */
 #define XtNbrief  "brief"
+
+		/* Boolean: show seconds since Epoch if TRUE */
+#define XtNutime  "utime"
 
 		/* Boolean:  */
 #define XtNchime "chime"
Index: xc/programs/xclock/ClockP.h
diff -u xc/programs/xclock/ClockP.h:1.3 xc/programs/xclock/ClockP.h:1.4
--- xc/programs/xclock/ClockP.h:1.3	Fri Jan 21 13:41:51 2000
+++ xc/programs/xclock/ClockP.h	Wed Nov  1 21:51:24 2000
@@ -45,7 +45,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/programs/xclock/ClockP.h,v 1.3 2000/01/21 18:41:51 dawes Exp $ */
+/* $XFree86: xc/programs/xclock/ClockP.h,v 1.4 2000/11/02 02:51:24 dawes Exp $ */
 
 #ifndef _XawClockP_h
 #define _XawClockP_h
@@ -75,6 +75,7 @@
 	 Boolean beeped;
 	 Boolean analog;
 	 Boolean brief;
+	 Boolean utime;
 	 Boolean show_second_hand;
 	 Dimension second_hand_length;
 	 Dimension minute_hand_length;
Index: xc/programs/xclock/xclock.c
diff -u xc/programs/xclock/xclock.c:1.4 xc/programs/xclock/xclock.c:1.5
--- xc/programs/xclock/xclock.c:1.4	Thu Jan 20 20:12:26 2000
+++ xc/programs/xclock/xclock.c	Wed Nov  1 21:51:24 2000
@@ -23,7 +23,7 @@
 used in advertising or otherwise to promote the sale, use or other dealings
 in this Software without prior written authorization from The Open Group.
  */
-/* $XFree86: xc/programs/xclock/xclock.c,v 1.4 2000/01/21 01:12:26 dawes Exp $ */
+/* $XFree86: xc/programs/xclock/xclock.c,v 1.5 2000/11/02 02:51:24 dawes Exp $ */
 
 #include <stdio.h>
 #include <X11/Xatom.h>
@@ -58,6 +58,7 @@
 {"-digital",	"*clock.analog",	XrmoptionNoArg,		"FALSE"},
 {"-analog",	"*clock.analog",	XrmoptionNoArg,		"TRUE"},
 {"-brief",      "*clock.brief",	        XrmoptionNoArg,	        "TRUE"},
+{"-utime",      "*clock.utime",	        XrmoptionNoArg,	        "TRUE"},
 };
 
 static void quit ( Widget w, XEvent *event, String *params, 
@@ -75,7 +76,7 @@
 static void
 Syntax(char *call)
 {
-	(void) printf ("Usage: %s [-analog] [-bw <pixels>] [-digital] [-brief]\n", call);
+	(void) printf ("Usage: %s [-analog] [-bw <pixels>] [-digital] [-brief] [-utime]\n", call);
 	(void) printf ("       [-fg <color>] [-bg <color>] [-hd <color>]\n");
 	(void) printf ("       [-hl <color>] [-bd <color>]\n");
 	(void) printf ("       [-fn <font_name>] [-help] [-padding <pixels>]\n");
Index: xc/programs/xclock/xclock.man
diff -u xc/programs/xclock/xclock.man:1.5 xc/programs/xclock/xclock.man:1.6
--- xc/programs/xclock/xclock.man:1.5	Fri Feb 25 13:28:12 2000
+++ xc/programs/xclock/xclock.man	Wed Nov  1 21:51:25 2000
@@ -19,7 +19,7 @@
 .\" other dealings in this Software without prior written authorization
 .\" from The Open Group.
 .\"
-.\" $XFree86: xc/programs/xclock/xclock.man,v 1.5 2000/02/25 18:28:12 dawes Exp $
+.\" $XFree86: xc/programs/xclock/xclock.man,v 1.6 2000/11/02 02:51:25 dawes Exp $
 .\"
 .TH XCLOCK 1 "Release 6.4" "X Version 11"
 .SH NAME
@@ -54,6 +54,11 @@
 \fB\-brief\fP
 This option indicates that the digital clock should only display the hours
 and minutes fields.  The default is to show the full time and date information.
+.TP 8
+\fB\-utime\fP or \fB\-d\fP
+This option indicates that a digital clock should display seconds since
+the Epoch (in format '970012340 seconds since Epoch' instead of a standard
+24-hour time.
 .TP 8
 .B \-chime
 This option indicates that the clock should chime 
Index: xc/programs/xditview/Dvi.c
diff -u xc/programs/xditview/Dvi.c:1.1 xc/programs/xditview/Dvi.c:1.2
--- xc/programs/xditview/Dvi.c:1.1	Wed Feb 23 15:35:27 2000
+++ xc/programs/xditview/Dvi.c	Sun Dec  3 00:20:53 2000
@@ -28,7 +28,7 @@
 from the X Consortium.
 
 */
-/* $XFree86: xc/programs/xditview/Dvi.c,v 1.1 2000/02/23 20:35:27 dawes Exp $ */
+/* $XFree86: xc/programs/xditview/Dvi.c,v 1.2 2000/12/03 05:20:53 keithp Exp $ */
 
 
 /*
@@ -64,6 +64,10 @@
 I	-*-times-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\
 B	-*-times-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\
 F	-*-times-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\
+TR	-*-times-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\
+TI	-*-times-medium-i-normal--*-*-*-*-*-*-iso8859-1\n\
+TB	-*-times-bold-r-normal--*-*-*-*-*-*-iso8859-1\n\
+TF	-*-times-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\
 BI	-*-times-bold-i-normal--*-*-*-*-*-*-iso8859-1\n\
 C	-*-courier-medium-r-normal--*-*-*-*-*-*-iso8859-1\n\
 CO	-*-courier-medium-o-normal--*-*-*-*-*-*-iso8859-1\n\
@@ -114,6 +118,8 @@
 	 offset(dvi.page_width), XtRString, "8.5"},
 	{XtNpageHeight, XtCPageHeight, XtRFloat, sizeof (float),
 	 offset(dvi.page_height), XtRString, "11"},
+	{XtNsizeScale, XtCSizeScale, XtRInt, sizeof (int),
+	 offset(dvi.size_scale_set), XtRImmediate, (XtPointer) 0},
 };
 
 #undef offset
@@ -144,7 +150,7 @@
 	XtNumber(resources),		/* resource_count	  */
 	NULLQUARK,			/* xrm_class		  */
 	FALSE,				/* compress_motion	  */
-	TRUE,				/* compress_exposure	  */
+	XtExposeCompressMaximal,    	/* compress_exposure	  */
 	TRUE,				/* compress_enterleave    */
 	FALSE,				/* visible_interest	  */
 	Destroy,			/* destroy		  */
@@ -219,6 +225,8 @@
     dw->dvi.state = 0;
     dw->dvi.cache.index = 0;
     dw->dvi.cache.font = 0; 
+    dw->dvi.size_scale = 0;
+    dw->dvi.size_scale_set = 0;
     RequestDesiredSize (dw);
 }
 
@@ -240,6 +248,28 @@
     values.foreground = dw->dvi.foreground;
     dw->dvi.normal_GC = XCreateGC (XtDisplay (w), XtWindow (w),
 				    GCForeground, &values);
+#ifdef USE_XFT
+    {
+	int		scr;
+	Visual		*visual;
+	Colormap	cmap;
+	XRenderColor	black;
+
+	scr = XScreenNumberOfScreen (dw->core.screen);
+	visual = DefaultVisual (XtDisplay (w), scr);
+	cmap = DefaultColormap (XtDisplay (w), scr);
+	dw->dvi.draw = XftDrawCreate (XtDisplay (w), XtWindow (w), 
+				      visual, cmap);
+
+	black.red = black.green = black.blue = 0;
+	black.alpha = 0xffff;
+	XftColorAllocValue (XtDisplay (w), visual, cmap,
+			    &black, &dw->dvi.black);
+	dw->dvi.default_font = XftFontOpenName (XtDisplay (w),
+						scr,
+						"serif-12");
+    }
+#endif
     if (dw->dvi.file)
 	OpenFile (dw);
     ParseFontMap (dw);
@@ -270,11 +300,21 @@
 	DviWidget	dw = (DviWidget) w;
 	XRectangle	extents;
 	
+#ifdef USE_XFT
+	XClearArea (XtDisplay (dw),
+		    XtWindow (dw),
+		    0, 0, 0, 0, False);
+	dw->dvi.extents.x1 = 0;
+	dw->dvi.extents.y1 = 0;
+	dw->dvi.extents.x2 = dw->core.width;
+	dw->dvi.extents.y2 = dw->core.height;
+#else
 	XClipBox (region, &extents);
 	dw->dvi.extents.x1 = extents.x;
 	dw->dvi.extents.y1 = extents.y;
 	dw->dvi.extents.x2 = extents.x + extents.width;
 	dw->dvi.extents.y2 = extents.y + extents.height;
+#endif
 	ShowDvi (dw);
 }
 
@@ -439,9 +479,6 @@
 	dw->dvi.device_resolution = resolution;
 	dw->dvi.scale = ((double)  dw->dvi.screen_resolution) /
 			((double) resolution);
-	if (dw->dvi.state)
-	    dw->dvi.state->line_width =
-		FontSizeInDevice(dw, dw->dvi.state->line_width/10.0);
     }
 }
 
Index: xc/programs/xditview/Dvi.h
diff -u xc/programs/xditview/Dvi.h:1.1 xc/programs/xditview/Dvi.h:1.3
--- xc/programs/xditview/Dvi.h:1.1	Wed Feb 23 15:35:28 2000
+++ xc/programs/xditview/Dvi.h	Mon Dec  4 16:01:01 2000
@@ -1,6 +1,7 @@
 /*
 * $XConsortium: Dvi.h,v 1.5 91/07/25 21:33:53 keith Exp $
 */
+/* $XFree86: xc/programs/xditview/Dvi.h,v 1.3 2000/12/04 21:01:01 dawes Exp $ */
 
 #ifndef _XtDvi_h
 #define _XtDvi_h
@@ -29,6 +30,7 @@
 #define XtNscreenResolution "screenResolution"
 #define XtNpageWidth	"pageWidth"
 #define XtNpageHeight	"pageHeight"
+#define XtNsizeScale	"sizeScale"
 
 #define XtCFontMap	"FontMap"
 #define XtCPageNumber	"PageNumber"
@@ -38,6 +40,7 @@
 #define XtCScreenResolution "ScreenResolution"
 #define XtCPageWidth	"PageWidth"
 #define XtCPageHeight	"PageHeight"
+#define XtCSizeScale	"SizeScale"
 
 typedef struct _DviRec *DviWidget;  /* completely defined in DviPrivate.h */
 typedef struct _DviClassRec *DviWidgetClass;    /* completely defined in DviPrivate.h */
Index: xc/programs/xditview/DviP.h
diff -u xc/programs/xditview/DviP.h:1.1 xc/programs/xditview/DviP.h:1.3
--- xc/programs/xditview/DviP.h:1.1	Wed Feb 23 15:35:28 2000
+++ xc/programs/xditview/DviP.h	Mon Dec  4 16:01:01 2000
@@ -1,6 +1,7 @@
 /*
  * $XConsortium: DviP.h,v 1.10 92/02/11 01:27:15 keith Exp $
  */
+/* $XFree86: xc/programs/xditview/DviP.h,v 1.3 2000/12/04 21:01:01 dawes Exp $ */
 
 /* 
  * DviP.h - Private definitions for Dvi widget
@@ -9,6 +10,10 @@
 #ifndef _XtDviP_h
 #define _XtDviP_h
 
+#ifdef USE_XFT
+#include <X11/Xft/Xft.h>
+#endif
+
 #include "Dvi.h"
 #include <X11/Xaw/SimpleP.h>
 #include "DviChar.h"
@@ -59,7 +64,12 @@
 	struct _dviFontSizeList	*next;
 	int			size;
 	char			*x_name;
+#ifdef USE_XFT
+	XftFont			*font;
+	Bool			core;
+#else
 	XFontStruct		*font;
+#endif
 	int			doesnt_exist;
 } DviFontSizeList;
 
@@ -83,15 +93,32 @@
 #define DVI_TEXT_CACHE_SIZE	256
 #define DVI_CHAR_CACHE_SIZE	1024
 
+#ifdef USE_XFT
+typedef struct _dviTextItem {
+	char		*chars;
+	int		nchars;
+	int		x;
+	XftFont		*font;
+} DviTextItem;
+#endif
+
 typedef struct _dviCharCache {
+#ifdef USE_XFT
+	DviTextItem	cache[DVI_TEXT_CACHE_SIZE];
+#else
 	XTextItem	cache[DVI_TEXT_CACHE_SIZE];
+#endif
 	char		char_cache[DVI_CHAR_CACHE_SIZE];
 	int		index;
 	int		max;
 	int		char_index;
 	int		font_size;
 	int		font_number;
+#ifdef USE_XFT
+	XftFont		*font;
+#else
 	XFontStruct	*font;
+#endif
 	int		start_x, start_y;
 	int		x, y;
 } DviCharCache;
@@ -127,12 +154,17 @@
 	int		last_page;
 	FILE		*file;
 	Boolean		seek;		/* file is "seekable" */
+#ifdef USE_XFT
+	XftFont		*default_font;
+#else
 	XFontStruct	*default_font;
+#endif
 	int		backing_store;
 	Boolean		noPolyText;
 	int		screen_resolution;
 	float		page_width;
 	float		page_height;
+	int		size_scale_set;
 	/*
  	 * private state
  	 */
@@ -140,6 +172,10 @@
 	char		readingTmp;	/* reading now from tmp */
 	char		ungot;		/* have ungetc'd a char */
 	GC		normal_GC;
+#ifdef USE_XFT
+	XftDraw		*draw;
+	XftColor	black;
+#endif
 	DviFileMap	*file_map;
 	DviFontList	*fonts;
 	DviFontMap	*font_map;
@@ -151,7 +187,12 @@
 	int		line_style;
 	int		desired_width;
 	int		desired_height;
+	int		size_scale;	/* font size scale */
+#ifdef USE_XFT
+	XftFont		*font;
+#else
 	XFontStruct	*font;
+#endif
 	int		display_enable;
 	double		scale;		/* device coordinates to pixels */
 	struct ExposedExtents {
@@ -191,8 +232,8 @@
 
 #define ToX(dw,device)		    ((int) ((device) * (dw)->dvi.scale + 0.5))
 #define ToDevice(dw,x)		    ((int) ((x) / (dw)->dvi.scale + 0.5))
-#define FontSizeInPixels(dw,size)   ((int) ((size) * (dw)->dvi.screen_resolution / 72))
-#define FontSizeInDevice(dw,size)   ((int) ((size) * (dw)->dvi.device_resolution / 72))
+#define FontSizeInPixels(dw,size)   ((int) ((size) * (dw)->dvi.screen_resolution / ((dw)->dvi.size_scale * 72)))
+#define FontSizeInDevice(dw,size)   ((int) ((size) * (dw)->dvi.device_resolution / ((dw)->dvi.size_scale * 72)))
 
 /*
  * Full widget declaration
@@ -204,7 +245,11 @@
     DviPart	dvi;
 } DviRec;
 
+#ifdef USE_XFT
+extern XftFont		*QueryFont ();
+#else
 extern XFontStruct	*QueryFont ();
+#endif
 
 extern DviCharNameMap	*QueryFontMap ();
 #endif /* _XtDviP_h */
Index: xc/programs/xditview/Imakefile
diff -u xc/programs/xditview/Imakefile:1.1 xc/programs/xditview/Imakefile:1.3
--- xc/programs/xditview/Imakefile:1.1	Wed Feb 23 15:35:28 2000
+++ xc/programs/xditview/Imakefile	Sun Dec  3 00:20:53 2000
@@ -3,16 +3,22 @@
 
 
 
-XCOMM $XFree86: xc/programs/xditview/Imakefile,v 1.1 2000/02/23 20:35:28 dawes Exp $
+XCOMM $XFree86: xc/programs/xditview/Imakefile,v 1.3 2000/12/03 05:20:53 keithp Exp $
 
 
 #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
+#if BuildXftLibrary
+    DEPFONTLIBS = XftClientDepLibs
+       FONTLIBS = XftClientLibs
+       FONTDEFS = -DUSE_XFT
+#endif
 #if HasMkstemp
-        DEFINES = -DHAS_MKSTEMP
+       TEMPDEFS = -DHAS_MKSTEMP
 #endif
-        DEPLIBS = XawClientDepLibs
-LOCAL_LIBRARIES = XawClientLibs
+        DEPLIBS = XawClientDepLibs $(DEPFONTLIBS)
+LOCAL_LIBRARIES = XawClientLibs $(FONTLIBS)
   SYS_LIBRARIES = MathLibrary
+        DEFINES = $(TEMPDEFS) $(FONTDEFS)
         BITMAPS = ldblarrow rdblarrow
            SRCS = xditview.c Dvi.c draw.c font.c lex.c page.c parse.c\
 	   	  XFontName.c DviChar.c
@@ -23,4 +29,4 @@
 BuildIncludes($(BITMAPS),X11/bitmaps,../..)
 InstallAppDefaults(Xditview)
 InstallAppDefaultsLong(Xdit-chrtr,Xditview-chrtr)
-InstallMultipleFlags($(BITMAPS),$(INCDIR)/bitmaps,$(INSTINCFLAGS))
+InstallMultipleFlags($(BITMAPS),$(INCDIR)/X11/bitmaps,$(INSTINCFLAGS))
Index: xc/programs/xditview/draw.c
diff -u xc/programs/xditview/draw.c:1.1 xc/programs/xditview/draw.c:1.2
--- xc/programs/xditview/draw.c:1.1	Wed Feb 23 15:35:30 2000
+++ xc/programs/xditview/draw.c	Sun Dec  3 00:20:53 2000
@@ -1,6 +1,6 @@
 /*
  * $XConsortium: draw.c,v 1.8 94/04/17 20:43:35 gildea Exp $
- * $XFree86: xc/programs/xditview/draw.c,v 1.1 2000/02/23 20:35:30 dawes Exp $
+ * $XFree86: xc/programs/xditview/draw.c,v 1.2 2000/12/03 05:20:53 keithp Exp $
  *
 Copyright (c) 1991  X Consortium
 
@@ -105,6 +105,27 @@
     dw->dvi.state->y = NewPosition;
 }
 
+#ifdef USE_XFT
+DrawText (DviWidget dw)
+{
+    int	    i;
+    XftFont *font;
+
+    font = dw->dvi.cache.font;
+    for (i = 0; i <= dw->dvi.cache.index; i++)
+    {
+	if (dw->dvi.cache.cache[i].font)
+	    font = dw->dvi.cache.cache[i].font;
+	XftDrawString8 (dw->dvi.draw, &dw->dvi.black,
+			font,
+			dw->dvi.cache.cache[i].x,
+			dw->dvi.cache.start_y,
+			(unsigned char *) dw->dvi.cache.cache[i].chars,
+			dw->dvi.cache.cache[i].nchars);
+    }
+}
+#endif
+
 FlushCharCache (dw)
 	DviWidget	dw;
 {
@@ -113,9 +134,15 @@
     xx = ToX(dw, dw->dvi.state->x);
     yx = ToX(dw, dw->dvi.state->y);
     if (dw->dvi.cache.char_index != 0)
+    {
+#ifdef USE_XFT
+	DrawText (dw);
+#else
 	XDrawText (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC,
 		    dw->dvi.cache.start_x, dw->dvi.cache.start_y,
 		    dw->dvi.cache.cache, dw->dvi.cache.index + 1);
+#endif
+    }
     dw->dvi.cache.index = 0;
     dw->dvi.cache.max = DVI_TEXT_CACHE_SIZE;
     if (dw->dvi.noPolyText)
Index: xc/programs/xditview/font.c
diff -u xc/programs/xditview/font.c:1.1 xc/programs/xditview/font.c:1.3
--- xc/programs/xditview/font.c:1.1	Wed Feb 23 15:35:30 2000
+++ xc/programs/xditview/font.c	Mon Dec  4 16:01:01 2000
@@ -3,6 +3,7 @@
  *
  * map dvi fonts to X fonts
  */
+/* $XFree86: xc/programs/xditview/font.c,v 1.3 2000/12/04 21:01:01 dawes Exp $ */
 
 #include <X11/Xos.h>
 #include <X11/IntrinsicP.h>
@@ -67,9 +68,22 @@
 	fontNameAttributes |= FontNamePointSize;
 	fontName.ResolutionX = dw->dvi.screen_resolution;
 	fontName.ResolutionY = dw->dvi.screen_resolution;
-	fontName.PointSize = size * 10;
+	fontName.PointSize = size * 10 / dw->dvi.size_scale;
 	XFormatFontName (&fontName, fontNameAttributes, fontNameString);
 	best->x_name = savestr (fontNameString);
+#ifdef USE_XFT
+	/*
+	 * Force a match of a core font for adobe-fontspecific
+	 * encodings; we dont have a scalable font in
+	 * the right encoding
+	 */
+	best->core = False;
+	if (!strcmp (fontName.CharSetRegistry, "adobe") &&
+	    !strcmp (fontName.CharSetEncoding, "fontspecific"))
+	{
+	    best->core = True;
+	}
+#endif
 	best->doesnt_exist = 0;
 	best->font = 0;
 	f->sizes = best;
@@ -145,8 +159,12 @@
 		XtFree (fs->x_name);
 	if (fs->font)
 	{
+#ifdef USE_XFT
+	    XftFontClose (XtDisplay (dw), fs->font);
+#else
 	    XUnloadFont (XtDisplay (dw), fs->font->fid);
 	    XFree ((char *)fs->font);
+#endif
 	}
 	XtFree ((char *) fs);
     }
@@ -191,9 +209,14 @@
     XFontName	    fontName;
     unsigned int    fontNameAttributes;
 
+    sizes = 0;
+#ifdef USE_XFT
+    *scalablep = TRUE;
+#else
     *scalablep = FALSE;
     if (!XParseFontName (x_name, &fontName, &fontNameAttributes))
 	return 0;
+    
     fontNameAttributes &= ~(FontNamePixelSize|FontNamePointSize);
     fontNameAttributes |= FontNameResolutionX;
     fontNameAttributes |= FontNameResolutionY;
@@ -201,7 +224,6 @@
     fontName.ResolutionY = dw->dvi.screen_resolution;
     XFormatFontName (&fontName, fontNameAttributes, fontNameString);
     fonts = XListFonts (XtDisplay (dw), fontNameString, 10000000, &count);
-    sizes = 0;
     for (i = 0; i < count; i++) {
 	size = ConvertFontNameToSize (fonts[i]);
 	if (size == 0)
@@ -222,6 +244,7 @@
 	}
     }
     XFreeFontNames (fonts);
+#endif
     return sizes;
 }
 
@@ -284,6 +307,7 @@
     for (fm = dw->dvi.font_map; fm; fm=fm->next)
 	if (!strcmp (fm->dvi_name, dvi_name))
 	    return fm->x_name;
+    ++dvi_name;
     for (fm = dw->dvi.font_map; fm; fm=fm->next)
 	if (!strcmp (fm->dvi_name, "R"))
 	    return fm->x_name;
@@ -370,7 +394,11 @@
     (void) InstallFont (dw, position, dvi_name, x_name);
 }
 
+#ifdef USE_XFT
+XftFont *
+#else
 XFontStruct *
+#endif
 QueryFont (dw, position, size)
     DviWidget	dw;
     int		position;
@@ -391,7 +419,27 @@
 	return dw->dvi.default_font;
     if (!fs->font) {
 	if (fs->x_name)
+	{
+#ifdef USE_XFT
+	    XftPattern	*pat;
+	    XftPattern	*match;
+	    XftResult	result;
+
+	    pat = XftXlfdParse (fs->x_name, False, False);
+	    XftPatternAddBool (pat, XFT_CORE, fs->core);
+	    match = XftFontMatch (XtDisplay (dw),
+				  XScreenNumberOfScreen(dw->core.screen),
+				  pat, &result);
+	    XftPatternDestroy (pat);
+	    if (match)
+		fs->font = XftFontOpenPattern (XtDisplay (dw),
+					       match);
+	    else
+		fs->font = 0;
+#else
 	    fs->font = XLoadQueryFont (XtDisplay (dw), fs->x_name);
+#endif
+	}
 	if (!fs->font)
 	    fs->font = dw->dvi.default_font;
     }
@@ -428,6 +476,7 @@
     return 0;
 }
 
+#if 0
 LoadFont (dw, position, size)
 	DviWidget	dw;
 	int		position;
@@ -442,3 +491,4 @@
 	XSetFont (XtDisplay (dw), dw->dvi.normal_GC, font->fid);
 	return;
 }
+#endif
Index: xc/programs/xditview/lex.c
diff -u xc/programs/xditview/lex.c:1.1 xc/programs/xditview/lex.c:1.3
--- xc/programs/xditview/lex.c:1.1	Wed Feb 23 15:35:30 2000
+++ xc/programs/xditview/lex.c	Mon Dec  4 16:01:01 2000
@@ -1,3 +1,5 @@
+/* $XFree86: xc/programs/xditview/lex.c,v 1.3 2000/12/04 21:01:01 dawes Exp $ */
+
 #include <X11/Xos.h>
 #include <X11/IntrinsicP.h>
 #include <X11/StringDefs.h>
@@ -33,11 +35,13 @@
 	
 	Length--;			    /* Save room for final NULL */
 	
-	while (i < Length && DviGetC (dw, &c) != EOF && c != '\n')
+	while ((!p || i < Length) && DviGetC (dw, &c) != EOF && c != '\n')
 		if (p)
 			*p++ = c;
+#if 0
 	if (c == '\n' && p)		    /* Retain the newline like fgets */
 		*p++ = c;
+#endif
 	if (c == '\n')
 		DviUngetC(dw, c);
 	if (p)	
Index: xc/programs/xditview/parse.c
diff -u xc/programs/xditview/parse.c:1.1 xc/programs/xditview/parse.c:1.3
--- xc/programs/xditview/parse.c:1.1	Wed Feb 23 15:35:31 2000
+++ xc/programs/xditview/parse.c	Mon Dec  4 16:01:01 2000
@@ -28,6 +28,7 @@
 from the X Consortium.
 
 */
+/* $XFree86: xc/programs/xditview/parse.c,v 1.3 2000/12/04 21:01:01 dawes Exp $ */
 
 /*
  * parse.c
@@ -50,12 +51,24 @@
 
 #define HorizontalMove(dw, delta)	((dw)->dvi.state->x += (delta))
 
-#define charWidth(fi,c) (\
+#ifdef USE_XFT
+int
+charWidth (DviWidget dw, XftFont *font, char c)
+{
+    XGlyphInfo	extents;
+
+    XftTextExtents8 (XtDisplay (dw), font, 
+		     (unsigned char *) &c, 1, &extents);
+    return extents.xOff;
+}
+#else
+#define charWidth(dw,fi,c) (\
     (fi)->per_char ?\
 	(fi)->per_char[(c) - (fi)->min_char_or_byte2].width\
     :\
 	(fi)->max_bounds.width\
 )
+#endif
     
 ParseInput(dw)
     register DviWidget	dw;
@@ -151,8 +164,21 @@
 			break;
 		case 's':	/* ignore fractional sizes */
 			n = GetNumber(dw);
+			if (!dw->dvi.size_scale)
+			{
+			    static int	guesses[] = { 1, 4, 100, 1000, 1 };
+			    int		i;
+
+			    for (i = 0; i < 4; i++)
+				if (8 <= n/guesses[i] && n/guesses[i] <= 24)
+				{
+				    break;
+				}
+    			    dw->dvi.size_scale = guesses[i];
+			}
 			dw->dvi.state->font_size = n;
-			dw->dvi.state->line_width = FontSizeInDevice(dw, n / 10.0);
+			dw->dvi.state->line_width = n * (dw->dvi.device_resolution / 
+							 (720 * dw->dvi.size_scale));
 			break;
 		case 'f':
 			n = GetNumber(dw);
@@ -190,8 +216,14 @@
 			HorizontalGoto(dw, 0);
 			break;
 		case '#':	/* comment */
+		case 'F':	/* file info */
 			GetLine(dw, NULL, 0);
 			break;
+		case 't':	/* text */
+			GetLine(dw, Buffer, BUFSIZ);
+			PutCharacters (dw, Buffer, strlen (Buffer));
+			dw->dvi.state->x = ToDevice (dw, dw->dvi.cache.x);
+			break;
 		case 'x':	/* device control */
 			ParseDeviceControl(dw);
 			break;
@@ -200,6 +232,8 @@
 			FlushCharCache (dw);
 			return dw->dvi.current_page;
 		default:
+			GetLine (dw, Buffer, BUFSIZ);
+			fprintf (stderr, "Unknown command %c%s\n", Buffer);
 			break;
 		}
 	}
@@ -215,10 +249,10 @@
 	if (dw->dvi.state)
 		*new = *(dw->dvi.state);
 	else {
-		new->font_size = 10;
+		new->font_size = 10 * dw->dvi.size_scale;
 		new->font_number = 1;
 		new->line_style = 0;
-		new->line_width = FontSizeInDevice(dw, 10/10);
+		new->line_width = 10;
 		new->x = 0;
 		new->y = 0;
 	}
@@ -243,6 +277,7 @@
 {
 	while (dw->dvi.state)
 		pop_env (dw);
+	dw->dvi.size_scale = dw->dvi.size_scale_set;
 	push_env (dw);
 	FlushCharCache (dw);
 }
@@ -279,8 +314,13 @@
 	xx + fx >= dw->dvi.extents.x1 &&
 	xx - fx <= dw->dvi.extents.x2)
     {
+#ifdef USE_XFT
+	XftFont	    *font;
+	DviTextItem *text;
+#else
 	register XFontStruct	*font;
 	register XTextItem		*text;
+#endif
 
 	if (!dw->dvi.display_enable)
 	    return FALSE;
@@ -311,18 +351,32 @@
 		dw->dvi.cache.cache[dw->dvi.cache.index].nchars = 0;
 	    }
 	}
+	if (!dw->dvi.cache.font)
+	    SetFont (dw);
 	text = &dw->dvi.cache.cache[dw->dvi.cache.index];
 	font = dw->dvi.cache.font;
 	dst = &dw->dvi.cache.char_cache[dw->dvi.cache.char_index];
 	if (text->nchars == 0) {
 	    text->chars = dst;
+#ifdef USE_XFT
+	    text->x = xx;
+#else
 	    text->delta = xx - dw->dvi.cache.x;
+#endif
+#ifdef USE_XFT
+	    text->font = font;
+#endif
 	    if (font != dw->dvi.font) {
+#ifndef USE_XFT
 		text->font = font->fid;
+#endif
 		dw->dvi.font = font;
-	    } else
+	    }
+#ifndef USE_XFT
+	    else
 		text->font = None;
-	    dw->dvi.cache.x += text->delta;
+#endif
+	    dw->dvi.cache.x = xx;
 	}
 	dw->dvi.cache.char_index += len;
 	text->nchars += len;
@@ -330,7 +384,8 @@
 	{
 	    c = *src++;
 	    *dst++ = c;
-	    dw->dvi.cache.x += charWidth(font,c);
+	    if (font)
+		dw->dvi.cache.x += charWidth(dw,font,c);
 	}
 	return TRUE;
     }
@@ -379,13 +434,14 @@
     }
 } 
 
+extern int LastPage, CurrentPage;
+
 static
 ParseDeviceControl(dw)				/* Parse the x commands */
 	DviWidget	dw;
 {
     char str[20], str1[50];
     int c, n;
-    extern int LastPage, CurrentPage;
 
     GetWord (dw, str, 20);
     switch (str[0]) {			/* crude for now */
Index: xc/programs/xdm/Imakefile
diff -u xc/programs/xdm/Imakefile:3.36 xc/programs/xdm/Imakefile:3.38
--- xc/programs/xdm/Imakefile:3.36	Fri Jun 16 20:27:34 2000
+++ xc/programs/xdm/Imakefile	Tue Nov 14 18:58:32 2000
@@ -2,7 +2,7 @@
 XCOMM
 XCOMM
 XCOMM
-XCOMM $XFree86: xc/programs/xdm/Imakefile,v 3.36 2000/06/17 00:27:34 dawes Exp $
+XCOMM $XFree86: xc/programs/xdm/Imakefile,v 3.38 2000/11/14 23:58:32 dawes Exp $
 #define IHaveSubdirs
 #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
 
@@ -68,16 +68,17 @@
 
 XPM_DEFINES = -DXPM 
 
+/* This is correct for Linux and FreeBSD */
+#if HasPam
+PAM_LIBRARIES = PamLibraries
+PAM_DEFINES = -DUSE_PAM
+#endif
+
 #if SystemV4 || HasShadowPasswd
 #if !LinuxShadowSuite
 PWD_DEFINES = -DUSESHADOW
 #else
 PWD_DEFINES = -DUSESHADOW -DSHADOWSUITE
-#endif
-
-#if HasPam
-PAM_LIBRARIES = -lpam DlLibrary
-PAM_DEFINES = -DUSE_PAM
 #endif
 
 #if !defined(i386IscArchitecture) && !defined(i386ScoArchitecture) && !defined(LinuxArchitecture) && !defined(NTOArchitecture) && !defined(SGIArchitecture)
Index: xc/programs/xdm/choose.c
diff -u xc/programs/xdm/choose.c:3.9 xc/programs/xdm/choose.c:3.10
--- xc/programs/xdm/choose.c:3.9	Wed May 31 03:15:11 2000
+++ xc/programs/xdm/choose.c	Mon Nov 27 12:45:57 2000
@@ -22,7 +22,7 @@
  * Author:  Keith Packard, MIT X Consortium
  */
 
-/* $XFree86: xc/programs/xdm/choose.c,v 3.9 2000/05/31 07:15:11 eich Exp $ */
+/* $XFree86: xc/programs/xdm/choose.c,v 3.10 2000/11/27 17:45:57 dawes Exp $ */
 
 /*
  * choose.c
@@ -305,8 +305,10 @@
 	    break;
 	}
     }
+#if 0
     if (!found)
 	return 0;
+#endif
 
     insert = 0;
     if (!c)
Index: xc/programs/xdm/daemon.c
diff -u xc/programs/xdm/daemon.c:3.10 xc/programs/xdm/daemon.c:3.12
--- xc/programs/xdm/daemon.c:3.10	Sun Dec 26 19:40:08 1999
+++ xc/programs/xdm/daemon.c	Tue Nov 14 13:20:39 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xdm/daemon.c,v 3.10 1999/12/27 00:40:08 robin Exp $ */
+/* $XFree86: xc/programs/xdm/daemon.c,v 3.12 2000/11/14 18:20:39 dawes Exp $ */
 
 /*
  * xdm - display manager daemon
@@ -36,7 +36,7 @@
 #else
 #include <sys/ioctl.h>
 #endif
-#if defined(__osf__) || defined(linux) || defined(MINIX)
+#if defined(__osf__) || defined(linux) || defined(MINIX) || defined(__GNU__)
 #define setpgrp setpgid
 #endif
 #ifdef hpux
@@ -98,7 +98,7 @@
 	stat = setpgid(child_id, child_id);
 	/* This gets error EPERM.  Why? */
 #else
-#if defined(SYSV)||defined(__GNU__)
+#if defined(SYSV)
 	stat = 0;	/* don't know how to set child's process group */
 #else
 	stat = setpgrp(child_id, child_id);
@@ -124,7 +124,7 @@
      * Close standard file descriptors and get rid of controlling tty
      */
 
-#if defined(SYSV) || defined(SVR4) || defined(__GNU__) || defined(__QNXNTO__)
+#if defined(SYSV) || defined(SVR4) || defined(__QNXNTO__)
     setpgrp ();
 #else
     setpgrp (0, getpid());
@@ -145,7 +145,7 @@
     	_exit(0);
 #endif
 #else /* !MINIX */
-#if !((defined(SYSV) || defined(SVR4)) && defined(i386))
+#if !((defined(SYSV) || defined(SVR4)) && defined(i386)) && !defined(__CYGWIN__)
     if ((i = open ("/dev/tty", O_RDWR)) >= 0) {	/* did open succeed? */
 #if defined(USG) && defined(TCCLRCTTY)
 	int zero = 0;
Index: xc/programs/xdm/dm.h
diff -u xc/programs/xdm/dm.h:3.19 xc/programs/xdm/dm.h:3.21
--- xc/programs/xdm/dm.h:3.19	Tue Jun 13 20:16:14 2000
+++ xc/programs/xdm/dm.h	Tue Nov 14 16:59:25 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xdm/dm.h,v 3.19 2000/06/14 00:16:14 dawes Exp $ */
+/* $XFree86: xc/programs/xdm/dm.h,v 3.21 2000/11/14 21:59:25 dawes Exp $ */
 
 /*
  * xdm - display manager daemon
@@ -276,7 +276,7 @@
 };
 
 /* setgroups is not covered by POSIX, arg type varies */
-#if defined(SYSV) || defined(SVR4) || defined(__osf__) || defined(linux)
+#if defined(SYSV) || defined(SVR4) || defined(__osf__) || defined(linux) || defined(__GNU__)
 #define GID_T gid_t
 #else
 #define GID_T int
@@ -417,6 +417,7 @@
 
 /* in session.c */
 #ifdef USE_PAM
+extern pam_handle_t **thepamhp(void);
 extern pam_handle_t *thepamh(void);
 #endif
 extern char **defaultEnv (void);
Index: xc/programs/xdm/greet.h
diff -u xc/programs/xdm/greet.h:1.5 xc/programs/xdm/greet.h:1.6
--- xc/programs/xdm/greet.h:1.5	Wed May 31 03:15:11 2000
+++ xc/programs/xdm/greet.h	Tue Nov 14 16:59:25 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xdm/greet.h,v 1.5 2000/05/31 07:15:11 eich Exp $ */
+/* $XFree86: xc/programs/xdm/greet.h,v 1.6 2000/11/14 21:59:25 dawes Exp $ */
 
 /*
  * greet.h - interface to xdm's dynamically-loadable modular greeter
@@ -82,7 +82,7 @@
 #endif
     char *(*_crypt)(CRYPT_ARGS);
 #ifdef USE_PAM
-    pam_handle_t *(*_thepamh)(void);
+    pam_handle_t **(*_thepamhp)(void);
 #endif
 };
 
@@ -178,7 +178,7 @@
 #endif
 extern	char    *(*__xdm_crypt)(CRYPT_ARGS);
 #ifdef USE_PAM
-extern  pam_handle_t    *(*__xdm_thepamh)(void);
+extern  pam_handle_t    **(*__xdm_thepamhp)(void);
 #endif
 
 /*
@@ -217,6 +217,6 @@
 #endif
 #define	getpwnam	(*__xdm_getpwnam)
 #define	crypt		(*__xdm_crypt)
-#define thepamh		(*__xdm_thepamh)
+#define thepamhp	(*__xdm_thepamhp)
 
 #endif /* GREET_LIB */
Index: xc/programs/xdm/session.c
diff -u xc/programs/xdm/session.c:3.23 xc/programs/xdm/session.c:3.26
--- xc/programs/xdm/session.c:3.23	Fri Jun 16 20:27:34 2000
+++ xc/programs/xdm/session.c	Thu Nov 30 18:30:07 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xdm/session.c,v 3.23 2000/06/17 00:27:34 dawes Exp $ */
+/* $XFree86: xc/programs/xdm/session.c,v 3.26 2000/11/30 23:30:07 dawes Exp $ */
 
 /*
  * xdm - display manager daemon
@@ -72,7 +72,7 @@
 
 static	int	runAndWait (char **args, char **environ);
 
-#if defined(CSRG_BASED) || defined(__osf__)
+#if defined(CSRG_BASED) || defined(__osf__) || defined(__DARWIN__)
 #include <sys/types.h>
 #include <grp.h>
 #else
@@ -97,10 +97,21 @@
 extern	char	*crypt(CRYPT_ARGS);
 #endif
 #ifdef USE_PAM
-pam_handle_t *thepamh()
+pam_handle_t **thepamhp()
 {
 	static pam_handle_t *pamh = NULL;
-	return pamh;
+	return &pamh;
+}
+
+pam_handle_t *thepamh()
+{
+	pam_handle_t **pamhp;
+
+	pamhp = thepamhp();
+	if (pamhp)
+		return *pamhp;
+	else
+		return NULL;
 }
 #endif
 
@@ -139,7 +150,7 @@
 #endif
 	crypt,
 #ifdef USE_PAM
-	thepamh,
+	thepamhp,
 #endif
 	};
 
@@ -460,6 +471,18 @@
 void
 SessionExit (struct display *d, int status, int removeAuth)
 {
+#ifdef USE_PAM
+	pam_handle_t *pamh = thepamh();
+#endif
+#ifdef USE_PAM
+    if (pamh) {
+        /* shutdown PAM session */
+	pam_close_session(pamh, 0);
+	pam_end(pamh, PAM_SUCCESS);
+	pamh = NULL;
+    }
+#endif
+
     /* make sure the server gets reset after the session is over */
     if (d->serverPid >= 2 && d->resetSignal)
 	kill (d->serverPid, d->resetSignal);
@@ -467,9 +490,6 @@
 	ResetServer (d);
     if (removeAuth)
     {
-#ifdef USE_PAM
-	pam_handle_t *pamh = thepamh();
-#endif
 	setgid (verify.gid);
 	setuid (verify.uid);
 	RemoveUserAuthorization (d, &verify);
@@ -497,14 +517,6 @@
 	    }
 	}
 #endif /* K5AUTH */
-#ifdef USE_PAM
-	if (pamh) {
-	    /* shutdown PAM session */
-	    pam_close_session(pamh, 0);
-	    pam_end(pamh, PAM_SUCCESS);
-	    pamh = NULL;
-	}
-#endif
     }
     Debug ("Display %s exiting with status %d\n", d->name, status);
     exit (status);
Index: xc/programs/xdm/sessreg.c
diff -u xc/programs/xdm/sessreg.c:3.13 xc/programs/xdm/sessreg.c:3.15
--- xc/programs/xdm/sessreg.c:3.13	Wed May 31 03:15:12 2000
+++ xc/programs/xdm/sessreg.c	Tue Nov 28 12:25:13 2000
@@ -26,7 +26,7 @@
  *   by Andreas Stolcke <stolcke@icsi.berkeley.edu>
  */
 
-/* $XFree86: xc/programs/xdm/sessreg.c,v 3.13 2000/05/31 07:15:12 eich Exp $ */
+/* $XFree86: xc/programs/xdm/sessreg.c,v 3.15 2000/11/28 17:25:13 dawes Exp $ */
 
 /*
  * sessreg
@@ -51,7 +51,7 @@
 # include	<stdio.h>
 # include	<utmp.h>
 
-#if defined(SYSV) || defined(SVR4) || defined(Lynx) || defined(__QNX__)
+#if defined(SYSV) || defined(SVR4) || defined(Lynx) || defined(__QNX__) || defined(__DARWIN__)
 #define NO_LASTLOG
 #endif
 
@@ -75,8 +75,10 @@
 #endif
 
 #ifdef CSRG_BASED
+#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
 /* *BSD doesn't like a ':0' type entry in utmp */
 #define NO_UTMP
+#endif
 #endif
 
 #ifndef WTMP_FILE
Index: xc/programs/xdm/util.c
diff -u xc/programs/xdm/util.c:3.13 xc/programs/xdm/util.c:3.15
--- xc/programs/xdm/util.c:3.13	Wed May 31 03:15:12 2000
+++ xc/programs/xdm/util.c	Tue Nov 14 13:20:39 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xdm/util.c,v 3.13 2000/05/31 07:15:12 eich Exp $ */
+/* $XFree86: xc/programs/xdm/util.c,v 3.15 2000/11/14 18:20:39 dawes Exp $ */
 
 /*
  * xdm - display manager daemon
@@ -51,7 +51,7 @@
 #undef _POSIX_SOURCE
 #endif
 #endif
-#if defined(__osf__) || defined(linux) || defined(MINIX) || defined(__QNXNTO__)
+#if defined(__osf__) || defined(linux) || defined(MINIX) || defined(__QNXNTO__) || defined(__GNU__)
 #define setpgrp setpgid
 #endif
 
@@ -239,7 +239,7 @@
 #ifdef CSRG_BASED
 	setsid();
 #else
-#if defined(SYSV) || defined(SVR4) || defined(__GNU__)
+#if defined(SYSV) || defined(SVR4) || defined(__CYGWIN__)
 #if !(defined(SVR4) && defined(i386)) || defined(SCO325) || defined(__GNU__)
 	setpgrp ();
 #endif
Index: xc/programs/xdm/xdmcp.c
diff -u xc/programs/xdm/xdmcp.c:3.10 xc/programs/xdm/xdmcp.c:3.11
--- xc/programs/xdm/xdmcp.c:3.10	Sat Oct 10 11:25:40 1998
+++ xc/programs/xdm/xdmcp.c	Sun Nov 26 19:10:06 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xdm/xdmcp.c,v 3.10 1998/10/10 15:25:40 dawes Exp $ */
+/* $XFree86: xc/programs/xdm/xdmcp.c,v 3.11 2000/11/27 00:10:06 dawes Exp $ */
 
 /*
  * xdm - display manager daemon
@@ -1128,7 +1128,7 @@
     XdmcpHeader	header;
     ARRAY8	status;
 
-    sprintf (buf, "Session %ld failed for display %s: %s",
+    sprintf (buf, "Session %ld failed for display %.100s: %.100s",
 	     (long) sessionID, name, reason);
     Debug ("Send failed %ld %s\n", (long) sessionID, buf);
     status.length = strlen (buf);
Index: xc/programs/xdm/config/Xaccess
diff -u xc/programs/xdm/config/Xaccess:1.1.1.1 xc/programs/xdm/config/Xaccess:1.2
--- xc/programs/xdm/config/Xaccess:1.1.1.1	Wed Apr 27 03:20:02 1994
+++ xc/programs/xdm/config/Xaccess	Sun Nov 26 19:10:06 2000
@@ -1,5 +1,7 @@
 # $XConsortium: Xaccess,v 1.5 91/08/26 11:52:51 rws Exp $
 #
+# $XFree86: xc/programs/xdm/config/Xaccess,v 1.2 2000/11/27 00:10:06 dawes Exp $
+#
 # Access control file for XDMCP connections
 #
 # To control Direct and Broadcast access:
@@ -37,7 +39,7 @@
 # right hand sides can match.
 #
 
-*					#any host can get a login window
+#*					#any host can get a login window
 
 #
 # To hardwire a specific terminal to a specific host, you can
@@ -55,7 +57,7 @@
 # so this may not work in all environments.
 #
 
-*		CHOOSER BROADCAST	#any indirect host can get a chooser
+#*		CHOOSER BROADCAST	#any indirect host can get a chooser
 
 #
 # If you'd prefer to configure the set of hosts each terminal sees,
Index: xc/programs/xdm/config/Xres.cpp
diff -u xc/programs/xdm/config/Xres.cpp:1.1 xc/programs/xdm/config/Xres.cpp:1.3
--- xc/programs/xdm/config/Xres.cpp:1.1	Sat Mar 13 22:22:24 1999
+++ xc/programs/xdm/config/Xres.cpp	Mon Nov 27 00:06:46 2000
@@ -1,10 +1,17 @@
 ! $XConsortium: Xresources /main/8 1996/11/11 09:24:46 swick $
-! $XFree86: xc/programs/xdm/config/Xres.cpp,v 1.1 1999/03/14 03:22:24 dawes Exp $
+! $XFree86: xc/programs/xdm/config/Xres.cpp,v 1.3 2000/11/27 05:06:46 dawes Exp $
 #define BS \ /* cpp can be trickier than m4 */
 #define NLBS \n\ /* don't remove these comments */
 xlogin*login.translations: #override BS
 	Ctrl<Key>R: abort-display()NLBS
 	<Key>F1: set-session-argument(failsafe) finish-field()NLBS
+	<Key>Delete: delete-character()NLBS
+	<Key>Left: move-backward-character()NLBS
+	<Key>Right: move-forward-character()NLBS
+	<Key>Home: move-to-begining()NLBS
+	<Key>End: move-to-end()NLBS\
+	Ctrl<Key>KP_Enter: set-session-argument(failsafe) finish-field()NLBS
+	<Key>KP_Enter: set-session-argument() finish-field()NLBS
 	Ctrl<Key>Return: set-session-argument(failsafe) finish-field()NLBS
 	<Key>Return: set-session-argument() finish-field()
 #ifndef XPM
@@ -76,6 +83,6 @@
 Chooser*allowShellResize:	false
 Chooser*viewport.forceBars:	true
 Chooser*label.font:		*-new century schoolbook-bold-i-normal-*-240-*
-Chooser*label.label:		XDMCP Host Menu  from CLIENTHOST
+Chooser*label.label:		XDMCP Host Menu from CLIENTHOST
 Chooser*list.font:		-*-*-medium-r-normal-*-*-230-*-*-c-*-iso8859-1
 Chooser*Command.font:		*-new century schoolbook-bold-r-normal-*-180-*
Index: xc/programs/xdm/greeter/Login.c
diff -u xc/programs/xdm/greeter/Login.c:3.9 xc/programs/xdm/greeter/Login.c:3.11
--- xc/programs/xdm/greeter/Login.c:3.9	Mon Jun 19 11:01:03 2000
+++ xc/programs/xdm/greeter/Login.c	Tue Sep 19 08:46:23 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xdm/greeter/Login.c,v 3.9 2000/06/19 15:01:03 tsi Exp $ */
+/* $XFree86: xc/programs/xdm/greeter/Login.c,v 3.11 2000/09/19 12:46:23 eich Exp $ */
 
 /*
  * xdm - display manager daemon
@@ -1120,8 +1120,15 @@
             &(w->login.logoHeight),
             &(w->login.logoBorderWidth),
             &myPixmapDepth);
+    } else {
+	w->login.logoX = 0;
+	w->login.logoY = 0;
+	w->login.logoWidth = 0;
+	w->login.logoHeight = 0;
+	w->login.logoBorderWidth = 0;
     }
 
+
 SkipXpmLoad:
 #endif /* XPM */
     w->login.data.name[0] = '\0';
@@ -1294,7 +1301,7 @@
 "<KeyPress>:	insert-char()"
 #else
 "<Key>Tab:	tab-field() \n"
-"<KeyPress>:	insert-char()\n"
+"<KeyPress>:	insert-char()"
 #endif /* XPM */
 ;
 
Index: xc/programs/xdm/greeter/greet.c
diff -u xc/programs/xdm/greeter/greet.c:3.7 xc/programs/xdm/greeter/greet.c:3.9
--- xc/programs/xdm/greeter/greet.c:3.7	Tue Jun 13 20:16:16 2000
+++ xc/programs/xdm/greeter/greet.c	Thu Nov 30 19:24:36 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xdm/greeter/greet.c,v 3.7 2000/06/14 00:16:16 dawes Exp $ */
+/* $XFree86: xc/programs/xdm/greeter/greet.c,v 3.9 2000/12/01 00:24:36 dawes Exp $ */
 
 /*
  * xdm - display manager daemon
@@ -83,7 +83,7 @@
 #endif
 char     *(*__xdm_crypt)(CRYPT_ARGS) = NULL;
 #ifdef USE_PAM
-pam_handle_t *(*__xdm_thepamh)(void) = NULL;
+pam_handle_t **(*__xdm_thepamhp)(void) = NULL;
 #endif
 
 #endif
@@ -180,7 +180,7 @@
     int opcode, evbase, errbase, majret, minret;
     unsigned int value = XkbPCF_GrabsUseXKBStateMask;
     if (XkbQueryExtension (dpy, &opcode, &evbase, &errbase, &majret, &minret)) {
-	if (XkbSetPerClientControls (dpy, XkbPCF_GrabsUseXKBStateMask, &value))
+	if (!XkbSetPerClientControls (dpy, XkbPCF_GrabsUseXKBStateMask, &value))
 	    LogError ("%s\n", "SetPerClientControls failed");
     }
     }
Index: xc/programs/xdm/greeter/verify.c
diff -u xc/programs/xdm/greeter/verify.c:3.9 xc/programs/xdm/greeter/verify.c:3.10
--- xc/programs/xdm/greeter/verify.c:3.9	Tue Jun 13 20:16:16 2000
+++ xc/programs/xdm/greeter/verify.c	Tue Nov 14 16:59:25 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xdm/greeter/verify.c,v 3.9 2000/06/14 00:16:16 dawes Exp $ */
+/* $XFree86: xc/programs/xdm/greeter/verify.c,v 3.10 2000/11/14 21:59:25 dawes Exp $ */
 
 /*
  * xdm - display manager daemon
@@ -163,7 +163,7 @@
 {
 	struct passwd	*p;
 #ifdef USE_PAM
-	pam_handle_t *pamh = thepamh();
+	pam_handle_t **pamhp = thepamhp();
 #else
 #ifdef USESHADOW
 	struct spwd	*sp;
@@ -312,19 +312,19 @@
 
 #else /* USE_PAM */
 #define PAM_BAIL	\
-	if (pam_error != PAM_SUCCESS) { pam_end(pamh, 0); return 0; }
+	if (pam_error != PAM_SUCCESS) { pam_end(*pamhp, 0); return 0; }
 
 	PAM_password = greet->password;
-	pam_error = pam_start("xdm", p->pw_name, &PAM_conversation, &pamh);
+	pam_error = pam_start("xdm", p->pw_name, &PAM_conversation, pamhp);
 	PAM_BAIL;
-	pam_error = pam_set_item(pamh, PAM_TTY, d->name);
+	pam_error = pam_set_item(*pamhp, PAM_TTY, d->name);
 	PAM_BAIL;
-	pam_error = pam_authenticate(pamh, 0);
+	pam_error = pam_authenticate(*pamhp, 0);
 	PAM_BAIL;
-	pam_error = pam_acct_mgmt(pamh, 0);
+	pam_error = pam_acct_mgmt(*pamhp, 0);
 	/* really should do password changing, but it doesn't fit well */
 	PAM_BAIL;
-	pam_error = pam_setcred(pamh, 0);
+	pam_error = pam_setcred(*pamhp, 0);
 	PAM_BAIL;
 #undef PAM_BAIL
 #endif /* USE_PAM */
Index: xc/programs/xedit/commands.c
diff -u xc/programs/xedit/commands.c:1.21 xc/programs/xedit/commands.c:1.22
--- xc/programs/xedit/commands.c:1.21	Mon Sep 27 02:30:08 1999
+++ xc/programs/xedit/commands.c	Tue Sep 26 11:57:24 2000
@@ -24,7 +24,7 @@
  * used in advertising or publicity pertaining to distribution of the software
  * without specific, written prior permission.
  */
-/* $XFree86: xc/programs/xedit/commands.c,v 1.21 1999/09/27 06:30:08 dawes Exp $ */
+/* $XFree86: xc/programs/xedit/commands.c,v 1.22 2000/09/26 15:57:24 tsi Exp $ */
 
 #include <X11/Xfuncs.h>
 #include <X11/Xos.h>
@@ -506,7 +506,7 @@
 SourceChanged(Widget w, XtPointer client_data, XtPointer call_data)
 {
     xedit_flist_item *item = (xedit_flist_item*)client_data;
-    Bool changed = (Bool)call_data;
+    Bool changed = (Bool)(long)call_data;
 
     if (changed) {
 	if (item->flags & CHANGED_BIT)
Index: xc/programs/xedit/ispell.c
diff -u xc/programs/xedit/ispell.c:1.13 xc/programs/xedit/ispell.c:1.14
--- xc/programs/xedit/ispell.c:1.13	Sun Aug 15 09:00:55 1999
+++ xc/programs/xedit/ispell.c	Tue Sep 26 11:57:24 2000
@@ -27,7 +27,7 @@
  * Author: Paulo César Pereira de Andrade
  */
 
-/* $XFree86: xc/programs/xedit/ispell.c,v 1.13 1999/08/15 13:00:55 dawes Exp $ */
+/* $XFree86: xc/programs/xedit/ispell.c,v 1.14 2000/09/26 15:57:24 tsi Exp $ */
 
 #include "xedit.h"
 #ifndef X_NOT_STDC_ENV
@@ -1343,7 +1343,7 @@
 static void
 PopdownIspell(Widget w, XtPointer client_data, XtPointer call_data)
 {
-    (void)IspellEndProcess((Bool)client_data, True);
+    (void)IspellEndProcess((Bool)(long)client_data, True);
     XtPopdown(ispell.shell);
     *ispell.sentbuf = '\0';
 }
@@ -1627,7 +1627,7 @@
 {
     Arg args[1];
     char *text;
-    int cmd = (int)client_data;
+    int cmd = (long)client_data;
 
     if (!ispell.lock || ispell.repeat)
 	return;
Index: xc/programs/xedit/options.c
diff -u xc/programs/xedit/options.c:1.7 xc/programs/xedit/options.c:1.8
--- xc/programs/xedit/options.c:1.7	Mon Sep 27 02:30:09 1999
+++ xc/programs/xedit/options.c	Tue Sep 26 11:57:24 2000
@@ -27,7 +27,7 @@
  * Author: Paulo César Pereira de Andrade
  */
 
-/* $XFree86: xc/programs/xedit/options.c,v 1.7 1999/09/27 06:30:09 dawes Exp $ */
+/* $XFree86: xc/programs/xedit/options.c,v 1.8 2000/09/26 15:57:24 tsi Exp $ */
 
 #include <stdio.h>
 #ifndef X_NOT_STDC_ENV
@@ -362,7 +362,7 @@
     Boolean auto_fill;
     XawTextScrollMode scroll;
 
-    switch ((int)client_data) {
+    switch ((long)client_data) {
 	case WRAP_NEVER:
 	    XtSetArg(args[0], XtNwrap, XawtextWrapNever);
 	    break;
@@ -530,7 +530,7 @@
 	(params[0][0] == 'o' || params[0][0] == 'O'))
 	ok = True;
 
-    ProcessColumnsCallback(w, (XtPointer)ok, NULL);
+    ProcessColumnsCallback(w, (XtPointer)(long)ok, NULL);
 }
 
 /*ARGSUSED*/
Index: xc/programs/xfontsel/xfontsel.c
diff -u xc/programs/xfontsel/xfontsel.c:1.2 xc/programs/xfontsel/xfontsel.c:1.3
--- xc/programs/xfontsel/xfontsel.c:1.2	Thu May 11 14:14:43 2000
+++ xc/programs/xfontsel/xfontsel.c	Tue Sep 26 11:57:24 2000
@@ -31,7 +31,7 @@
 	one weekend in November, 1989
 Modified: Mark Leisher <mleisher@crl.nmsu.edu> to deal with UCS sample text.
 */
-/* $XFree86: xc/programs/xfontsel/xfontsel.c,v 1.2 2000/05/11 18:14:43 tsi Exp $ */
+/* $XFree86: xc/programs/xfontsel/xfontsel.c,v 1.3 2000/09/26 15:57:24 tsi Exp $ */
 
 #include <stdio.h>
 #include <X11/Intrinsic.h>
@@ -311,8 +311,10 @@
 		FieldMenuRec *makeRec = XtNew(FieldMenuRec);
 		sprintf( name, "field%d", f );
 		XtCreateManagedWidget("dash",labelWidgetClass,fieldBox,NZ);
-		field = XtCreateManagedWidget(name,menuButtonWidgetClass,fieldBox,NZ);
-		XtAddCallback(field, XtNcallback, SelectField, (XtPointer)f);
+		field = XtCreateManagedWidget(name, menuButtonWidgetClass,
+			fieldBox, NZ);
+		XtAddCallback(field, XtNcallback, SelectField,
+			(XtPointer)(long)f);
 		makeRec->field = f;
 		makeRec->button = field;
 		ScheduleWork(MakeFieldMenu, (XtPointer)makeRec, 2);
@@ -849,12 +851,12 @@
     XtGetSubresources(menu, (XtPointer) values, "options", "Options",
 		      menuResources, XtNumber(menuResources), NZ);
     XtAddCallback(menu, XtNpopupCallback, EnableOtherValues,
-		  (XtPointer)makeRec->field );
+		  (XtPointer)(long)makeRec->field );
 
     if (!patternFieldSpecified[val->field]) {
 	XtSetArg( args[0], XtNlabel, "*" );
 	item = XtCreateManagedWidget("any",smeBSBObjectClass,menu,args,ONE);
-	XtAddCallback(item, XtNcallback, AnyValue, (XtPointer)val->field);
+	XtAddCallback(item, XtNcallback, AnyValue, (XtPointer)(long)val->field);
     }
 
     for (i = values->count; i; i--, val++) {
@@ -971,7 +973,7 @@
     Widget w;
     XtPointer closure, callData;
 {
-    int field = (int)closure;
+    int field = (long)closure;
     currentFont.value_index[field] = -1;
     SetCurrentFont(NULL);
     EnableAllItems(field);
@@ -1195,7 +1197,7 @@
     {
 	int f;
 	for (f = 0; f < FIELD_COUNT; f++)
-	    ScheduleWork(EnableMenu, (XtPointer)f, BACKGROUND);
+	    ScheduleWork(EnableMenu, (XtPointer)(long)f, BACKGROUND);
     }
 }
 
@@ -1215,7 +1217,7 @@
     Widget w;
     XtPointer closure, callData;
 {
-    int field = (int)closure;
+    int field = (long)closure;
     FieldValue *values = fieldValues[field]->value;
     int count = fieldValues[field]->count;
     printf( "field %d:\n", field );
@@ -1262,7 +1264,7 @@
     Widget w;
     XtPointer closure, callData;
 {
-    int field = (int)closure;
+    int field = (long)closure;
     Boolean *font_in_set = (Boolean*)XtMalloc(numFonts*sizeof(Boolean));
     Boolean *b;
     int f, count;
@@ -1319,14 +1321,14 @@
     }
     XtFree((char *)font_in_set);
     if (enabledMenuIndex < field)
-	EnableMenu((XtPointer)field);
+	EnableMenu((XtPointer)(long)field);
 }
 
 
 void EnableMenu(closure)
     XtPointer closure;
 {
-    int field = (int)closure;
+    int field = (long)closure;
     FieldValue *val = fieldValues[field]->value;
     int f;
     Widget *managed = NULL, *pManaged = NULL;
@@ -1450,8 +1452,8 @@
     XtPointer closure, callData;
 {
     Time time = XtLastTimestampProcessed(XtDisplay(w));
-    Boolean primary = (Boolean) (int) closure;
-    Boolean own = (Boolean) (int) callData;
+    Boolean primary = (Boolean) (long) closure;
+    Boolean own = (Boolean) (long) callData;
 
     if (_XA_PRIMARY_FONT == NULL)
 	_XA_PRIMARY_FONT = XmuMakeAtom("PRIMARY_FONT");
Index: xc/programs/xfs/xfs.man
diff -u xc/programs/xfs/xfs.man:3.8 xc/programs/xfs/xfs.man:3.11
--- xc/programs/xfs/xfs.man:3.8	Sun Oct  4 05:41:07 1998
+++ xc/programs/xfs/xfs.man	Wed Dec  6 15:39:55 2000
@@ -31,14 +31,19 @@
 .\" suitability of this software for any purpose.  It is provided "as is"
 .\" without express or implied warranty.
 .\" $TOG: xfs.man /main/16 1998/02/09 13:58:02 kaleb $
-.\" $XFree86: xc/programs/xfs/xfs.man,v 3.8 1998/10/04 09:41:07 dawes Exp $
+.\" $XFree86: xc/programs/xfs/xfs.man,v 3.11 2000/12/06 20:39:55 dawes Exp $
 .TH XFS 1 "Release 6.4" "X Version 11"
 .SH NAME
 xfs \- X font server
 .SH SYNOPSIS
 .B "xfs"
 [\-config \fIconfiguration_file\fP]
+[\-daemon]
+[\-droppriv]
+[\-ls \fIlisten_socket\fP]
+[\-nodaemon]
 [\-port \fItcp_port\fP]
+[\-user \fIusername\fP]
 .SH DESCRIPTION
 .PP
 .I Xfs
@@ -51,9 +56,11 @@
 .SH "OPTIONS"
 .TP 8
 .B \-config configuration_file
-Specifies the configuration file the font server will use.
+Specifies the configuration file the font server will use.  If this
+parameter is not specified, the default file, \fI/usr/X11R6/lib/X11/fs/config\fR
+will be used.
 .TP 8
-.B \-ls listen-socket
+.B \-ls listen_socket
 Specifies a file descriptor which is already set up to be used as the
 listen socket.  This option is only intended to be used by the font server
 itself when automatically spawning another copy of itself to handle
@@ -62,6 +69,31 @@
 .B \-port tcp_port
 Specifies the TCP port number on which the server will listen for connections.
 The default port number is 7100.
+.TP 8
+.B \-daemon
+Instructs xfs to fork and go into the background automatically at
+startup  If this option is not specified, xfs will run as a regular
+process (unless xfs was built to daemonize by default).
+.TP 8
+.B \-droppriv
+If specified, xfs will attempt to run as user and group \fIxfs\fR (unless
+the
+.TP 8
+.B \-nodaemon
+When xfs is built to daemonize (run in the background) by default,
+this prevents that and starts xfs up as a regular process.
+.B \-user
+option is used). This
+has been implemented for security reasons, as xfs may have undiscovered
+buffer overflows or other paths for possible exploit, both local and
+remote.  With this option, you may also wish to specify
+"no-listen = tcp"
+in the config file, which ensures that xfs will not to use a TCP port at all.
+.TP 8
+.B \-user username
+This is equivalent to
+.B \-droppriv
+except that xfs will run as user \fIusername\fR.
 .SH "SIGNALS"
 .TP 8
 .I SIGTERM
@@ -113,11 +145,11 @@
 .IP "error-file (string)"
 Filename of the error file.  All warnings and errors
 will be logged here.
-.IP "port (cardinal)"
-TCP port on which the server will listen for connections.
 .IP "no-listen (trans-type)"
 Disable a transport  type. For example, TCP/IP connections can
 be disabled with no-listen tcp
+.IP "port (cardinal)"
+TCP port on which the server will listen for connections.
 .IP "use-syslog (boolean)"
 Whether syslog(3) (on supported systems) is to be used 
 for errors.
Index: xc/programs/xfs/difs/fonts.c
diff -u xc/programs/xfs/difs/fonts.c:3.5 xc/programs/xfs/difs/fonts.c:3.7
--- xc/programs/xfs/difs/fonts.c:3.5	Sat Aug 21 09:48:48 1999
+++ xc/programs/xfs/difs/fonts.c	Thu Dec 14 11:52:50 2000
@@ -42,7 +42,7 @@
  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  * THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/xfs/difs/fonts.c,v 3.5 1999/08/21 13:48:48 dawes Exp $ */
+/* $XFree86: xc/programs/xfs/difs/fonts.c,v 3.7 2000/12/14 16:52:50 dawes Exp $ */
 
 #include        "FS.h"
 #include        "FSproto.h"
@@ -576,7 +576,7 @@
 }
 
 /*
- * search all the knwon FPE prefixes looking for one to match the given
+ * search all the known FPE prefixes looking for one to match the given
  * FPE name
  */
 static int
@@ -613,7 +613,7 @@
 
     for (i = 0; i < num; i++) {
 	fpe = list[i];
-	if (fpe->name_length == len &&  memcmp(name, fpe->name, len) == 0)
+	if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
 	    return fpe;
     }
     return (FontPathElementPtr) 0;
@@ -630,11 +630,13 @@
     char       *paths,
     int        *bad)
 {
-    int         i,
-                err;
+    int		i,
+		validpaths,
+		err;
     int		len;
     int		type;
     char       *cp = paths;
+    char       *name;
     FontPathElementPtr fpe,
                *fplist;
 
@@ -648,10 +650,9 @@
 	if (fpe_functions[i].set_path_hook)
 	    (*fpe_functions[i].set_path_hook) ();
     }
-    for (i = 0; i < npaths; i++) {
+    for (i = 0, validpaths = 0; i < npaths; i++) {
 	len = *cp++;
 	if (len) {
-	    char *name;
 	    /* if it's already in our active list, just reset it */
 	    /*
 	     * note that this can miss FPE's in limbo -- may be worth catching
@@ -663,7 +664,7 @@
 		if (err == Successful) {
 		    UseFPE(fpe);/* since it'll be decref'd later when freed
 				 * from the old list */
-		    fplist[i] = fpe;
+		    fplist[validpaths++] = fpe;
 		    cp += len;
 		    continue;
 		}
@@ -679,9 +680,9 @@
 	    type = determine_fpe_type(name);
 	    if (type == -1)
 	    {
+		NoticeF("ignoring font path element %s (bad font path descriptor)\n", name);
 		fsfree(name);
-		err = FSBadName;
-		goto bail;
+		continue;
 	    }
 	    /* must be new -- make it */
 	    fpe = (FontPathElementPtr) fsalloc(sizeof(FontPathElementRec));
@@ -693,19 +694,28 @@
 	    fpe->type = type;
 	    fpe->name = name;
 	    fpe->refcount = 1;
-	    fplist[i] = fpe;
 
 	    cp += len;
 	    fpe->name_length = len;
 	    err = (*fpe_functions[fpe->type].init_fpe) (fpe);
 	    if (err != Successful) {
+		NoticeF("ignoring font path element %s (unreadable)\n", fpe->name);
 		fsfree(fpe->name);
 		fsfree(fpe);
-		err = FontToFSError(err);
-		goto bail;
+		continue;
 	    }
+	    fplist[validpaths++] = fpe;
 	}
     }
+    if (validpaths < npaths) {
+	fplist = (FontPathElementPtr *)
+	    fsrealloc(fplist, sizeof(FontPathElementPtr) * validpaths);
+	npaths = validpaths;
+    }
+    if (validpaths == 0) {
+	err = FontToFSError(err);
+	goto bail;
+    }
     free_font_path(font_path_elements, num_fpes);
     font_path_elements = fplist;
     num_fpes = npaths;
@@ -713,8 +723,8 @@
 	EmptyFontPatternCache(fontPatternCache);
     return FSSuccess;
 bail:
-    *bad = i;
-    while (--i >= 0)
+    *bad = validpaths;
+    while (--validpaths >= 0)
 	FreeFPE(fplist[i]);
     fsfree(fplist);
     return err;
Index: xc/programs/xfs/difs/main.c
diff -u xc/programs/xfs/difs/main.c:3.3 xc/programs/xfs/difs/main.c:3.5
--- xc/programs/xfs/difs/main.c:3.3	Sun Mar  7 06:40:54 1999
+++ xc/programs/xfs/difs/main.c	Thu Dec  7 15:26:26 2000
@@ -42,7 +42,7 @@
  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  * THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/xfs/difs/main.c,v 3.3 1999/03/07 11:40:54 dawes Exp $ */
+/* $XFree86: xc/programs/xfs/difs/main.c,v 3.5 2000/12/07 20:26:26 dawes Exp $ */
 
 #include	"FS.h"
 #include	"FSproto.h"
@@ -79,7 +79,8 @@
 int
 main(int argc, char *argv[])
 {
-    int         i;
+    int         i, oldumask;
+    struct passwd *pwent;
 
     argcGlobal = argc;
     argvGlobal = argv;
@@ -89,14 +90,22 @@
     /* init stuff */
     ProcessCmdLine(argc, argv);
     InitErrors();
+
     /*
      * do this first thing, to get any options that only take effect at
-     * startup time.  it is erad again each time the server resets
+     * startup time.  it is read again each time the server resets
      */
     if (ReadConfigFile(configfilename) != FSSuccess) {
 	ErrorF("fatal: couldn't read config file\n");
 	exit(1);
     }
+
+    /* make sure at least world write access is disabled */
+    if (((oldumask = umask(022)) & 002) == 002)
+	(void)umask(oldumask);
+
+    SetDaemonState();
+    SetUserId();
 
     while (1) {
 	serverGeneration++;
Index: xc/programs/xfs/include/os.h
diff -u xc/programs/xfs/include/os.h:3.8 xc/programs/xfs/include/os.h:3.9
--- xc/programs/xfs/include/os.h:3.8	Sun Feb 13 01:15:45 2000
+++ xc/programs/xfs/include/os.h	Thu Nov 30 18:30:09 2000
@@ -43,7 +43,7 @@
  * $NCDId: @(#)os.h,v 4.2 1991/05/10 07:59:16 lemke Exp $
  *
  */
-/* $XFree86: xc/programs/xfs/include/os.h,v 3.8 2000/02/13 06:15:45 dawes Exp $ */
+/* $XFree86: xc/programs/xfs/include/os.h,v 3.9 2000/11/30 23:30:09 dawes Exp $ */
 
 #ifndef	_OS_H_
 #define	_OS_H_
@@ -100,6 +100,11 @@
 extern	void	CloseSockets(void);
 extern	void	StopListening(void);
 
+/* os/daemon.c */
+extern	void	BecomeOrphan(void);
+extern	void	BecomeDaemon(void);
+extern	int	StorePid(void);
+
 /* os/error.c */
 extern void	Error(char *str);
 extern void	InitErrors(void);
@@ -143,6 +148,8 @@
 extern	void	OsInitAllocator (void);
 extern	void	ProcessCmdLine (int argc, char **argv);
 extern	void	ProcessLSoption (char *str);
+extern	void	SetUserId(void);
+extern	void	SetDaemonState(void);
 
 /* os/waitfor.c */
 extern	int	WaitForSomething(int *pClientsReady);
Index: xc/programs/xfs/os/Imakefile
diff -u xc/programs/xfs/os/Imakefile:3.5 xc/programs/xfs/os/Imakefile:3.6
--- xc/programs/xfs/os/Imakefile:3.5	Sun Feb 13 01:15:45 2000
+++ xc/programs/xfs/os/Imakefile	Thu Nov 30 18:30:09 2000
@@ -1,5 +1,5 @@
 XCOMM $XConsortium: Imakefile /main/17 1995/12/19 16:35:21 mor $
-XCOMM $XFree86: xc/programs/xfs/os/Imakefile,v 3.5 2000/02/13 06:15:45 dawes Exp $
+XCOMM $XFree86: xc/programs/xfs/os/Imakefile,v 3.6 2000/11/30 23:30:09 dawes Exp $
 #undef ServerDefines
 #include <Server.tmpl>
 
@@ -10,9 +10,9 @@
 SpecialCObjectRule(os2_stubs,$(ICONFIGFILES),-DOS2NULLSELECT)
 #endif
 
-SRCS =	connection.c waitfor.c io.c utils.c osinit.c \
+SRCS =	connection.c waitfor.c daemon.c io.c utils.c osinit.c \
 	config.c access.c osglue.c error.c $(SRCS1)
-OBJS =  connection.o waitfor.o io.o utils.o osinit.o \
+OBJS =  connection.o waitfor.o daemon.o io.o utils.o osinit.o \
 	config.o access.o osglue.o error.o $(OBJS1)
 
 INCLUDES = -I../include -I$(FONTINCSRC) -I$(EXTINCSRC)
@@ -23,7 +23,9 @@
 SOCK_DEFINES = -DBSD44SOCKETS
 #endif
 
-/* ERROR_DEFINES = -DUSE_SYSLOG */
+#if FSUseSyslog
+ERROR_DEFINES = -DUSE_SYSLOG
+#endif
 
 OS_DEFINES = ServerOSDefines
 
Index: xc/programs/xfs/os/config.c
diff -u xc/programs/xfs/os/config.c:3.8 xc/programs/xfs/os/config.c:3.9
--- xc/programs/xfs/os/config.c:3.8	Sun Feb 13 01:15:46 2000
+++ xc/programs/xfs/os/config.c	Thu Nov 30 18:30:10 2000
@@ -43,7 +43,7 @@
  * $NCDId: @(#)config.c,v 4.6 1991/07/09 14:08:09 lemke Exp $
  *
  */
-/* $XFree86: xc/programs/xfs/os/config.c,v 3.8 2000/02/13 06:15:46 dawes Exp $ */
+/* $XFree86: xc/programs/xfs/os/config.c,v 3.9 2000/11/30 23:30:10 dawes Exp $ */
 
 #include	<stdio.h>
 #include	<ctype.h>
@@ -58,6 +58,8 @@
 #include	"fontcacheP.h"
 #endif
 
+extern int portFromCmdline;
+
 static char *font_catalogue = NULL;
 
 static char *config_set_int(ConfigOptionPtr parm, char *val);
@@ -450,7 +452,7 @@
 	return val;
 
     /* now do individual attribute checks */
-    if (!strcmp(parm->parm_name, "port")) {
+    if (!strcmp(parm->parm_name, "port") && !portFromCmdline) {
 	ListenPort = ival;
     } else if (!strcmp(parm->parm_name, "client-limit")) {
 	AccessSetConnectionLimit(ival);
Index: xc/programs/xfs/os/connection.c
diff -u xc/programs/xfs/os/connection.c:3.18 xc/programs/xfs/os/connection.c:3.19
--- xc/programs/xfs/os/connection.c:3.18	Tue Apr  4 15:25:26 2000
+++ xc/programs/xfs/os/connection.c	Thu Nov 30 18:30:10 2000
@@ -63,7 +63,7 @@
  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  * THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/xfs/os/connection.c,v 3.18 2000/04/04 19:25:26 dawes Exp $ */
+/* $XFree86: xc/programs/xfs/os/connection.c,v 3.19 2000/11/30 23:30:10 dawes Exp $ */
 
 #include	<X11/Xtrans.h>
 #include	<stdlib.h>
@@ -261,11 +261,11 @@
 		FD_SET (fd, &WellKnownConnections);
 	    }
 	}
+	NoticeF("listening on port %s\n", port);
     }
 
     if (! XFD_ANYSET(&WellKnownConnections))
 	FatalError("Cannot establish any listening sockets\n");
-
 
     /* set up all the signal handlers */
     signal(SIGPIPE, SIG_IGN);
Index: xc/programs/xfs/os/daemon.c
diff -u /dev/null xc/programs/xfs/os/daemon.c:1.1
--- /dev/null	Mon Dec 18 14:34:27 2000
+++ xc/programs/xfs/os/daemon.c	Thu Nov 30 18:30:10 2000
@@ -0,0 +1,199 @@
+/*
+
+Copyright (c) 1988  X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+*/
+/* $XFree86: xc/programs/xfs/os/daemon.c,v 1.1 2000/11/30 23:30:10 dawes Exp $ */
+
+#include <X11/Xos.h>
+#include <stdio.h>
+
+#if defined(SVR4) || defined(USG)
+#include <termios.h>
+#else
+#include <sys/ioctl.h>
+#endif
+#if defined(__osf__) || defined(linux) || defined(MINIX)
+#define setpgrp setpgid
+#endif
+#ifdef hpux
+#include <sys/ptyio.h>
+#endif
+#include <errno.h>
+#ifdef X_NOT_STDC_ENV
+extern int errno;
+#endif
+#include <sys/types.h>
+#ifdef X_NOT_POSIX
+#define Pid_t int
+#else
+#define Pid_t pid_t
+#endif
+
+#include "os.h"
+
+void
+BecomeOrphan ()
+{
+    Pid_t child_id;
+    int stat;
+
+    /*
+     * fork so that the process goes into the background automatically. Also
+     * has a nice side effect of having the child process get inherited by
+     * init (pid 1).
+     * Separate the child into its own process group before the parent
+     * exits.  This eliminates the possibility that the child might get
+     * killed when the init script that's running xfs exits.
+     */
+
+    child_id = fork();
+    switch (child_id) {
+    case 0:
+	/* child */
+	break;
+    case -1:
+	/* error */
+	FatalError("daemon fork failed, errno = %d\n", errno);
+	break;
+
+    default:
+	/* parent */
+
+#ifndef CSRG_BASED
+#if defined(SVR4)
+	stat = setpgid(child_id, child_id);
+	/* This gets error EPERM.  Why? */
+#else
+#if defined(SYSV)
+	stat = 0;	/* don't know how to set child's process group */
+#else
+	stat = setpgrp(child_id, child_id);
+#ifndef MINIX
+	if (stat != 0)
+	    FatalError("setting process grp for daemon failed, errno = %d\n",
+		     errno);
+#endif /* MINIX */
+#endif
+#endif
+#endif /* !CSRG_BASED */
+	exit (0);
+    }
+}
+
+void
+BecomeDaemon ()
+{
+    register int i;
+
+    /*
+     * Close standard file descriptors and get rid of controlling tty
+     */
+
+#ifdef CSRG_BASED
+    daemon (0, 0);
+#else
+#if defined(SYSV) || defined(SVR4)
+    setpgrp ();
+#else
+    setpgrp (0, getpid());
+#endif
+
+    close (0); 
+    close (1);
+    close (2);
+
+#ifndef __EMX__
+#ifdef MINIX
+#if 0
+    /* Use setsid() to get rid of our controlling tty, this requires an extra
+     * fork though.
+     */
+    setsid();
+    if (fork() > 0)
+    	_exit(0);
+#endif
+#else /* !MINIX */
+#if !((defined(SYSV) || defined(SVR4)) && defined(i386))
+    if ((i = open ("/dev/tty", O_RDWR)) >= 0) {	/* did open succeed? */
+#if defined(USG) && defined(TCCLRCTTY)
+	int zero = 0;
+	(void) ioctl (i, TCCLRCTTY, &zero);
+#else
+#if (defined(SYSV) || defined(SVR4)) && defined(TIOCTTY)
+	int zero = 0;
+	(void) ioctl (i, TIOCTTY, &zero);
+#else
+	(void) ioctl (i, TIOCNOTTY, (char *) 0);    /* detach, BSD style */
+#endif
+#endif
+	(void) close (i);
+    }
+#endif /* !((SYSV || SVR4) && i386) */
+#endif /* MINIX */
+#endif /* !__EMX__ */
+
+    /*
+     * Set up the standard file descriptors.
+     */
+    (void) open ("/", O_RDONLY);	/* root inode already in core */
+    (void) dup2 (0, 1);
+    (void) dup2 (0, 2);
+#endif /* CSRG_BASED */
+}
+
+#if defined(linux) || defined(CSRG_BASED)
+FILE *pidFilePtr;
+static int pidFd;
+char *pidFile = "/var/run/xfs.pid";
+#endif
+
+int
+StorePid ()
+{
+#if defined(linux) || defined(CSRG_BASED)
+    int         oldpid;
+
+    if (pidFile[0] != '\0') {
+        pidFd = open (pidFile, 2);
+        if (pidFd == -1 && errno == ENOENT)
+            pidFd = open (pidFile, O_RDWR|O_CREAT, 0666);
+        if (pidFd == -1 || !(pidFilePtr = fdopen (pidFd, "r+")))
+        {
+            ErrorF ("process-id file %s cannot be opened\n",
+                      pidFile);
+            return -1;
+        }
+        if (fscanf (pidFilePtr, "%d\n", &oldpid) != 1)
+            oldpid = -1;
+        fseek (pidFilePtr, 0l, 0);
+        fprintf (pidFilePtr, "%5d\n", getpid ());
+        (void) fflush (pidFilePtr);
+    }
+#endif
+    return 0;
+}
Index: xc/programs/xfs/os/error.c
diff -u xc/programs/xfs/os/error.c:1.5 xc/programs/xfs/os/error.c:1.6
--- xc/programs/xfs/os/error.c:1.5	Sun Oct 25 07:48:07 1998
+++ xc/programs/xfs/os/error.c	Thu Nov 30 18:30:10 2000
@@ -40,7 +40,7 @@
  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  * THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/xfs/os/error.c,v 1.5 1998/10/25 12:48:07 dawes Exp $ */
+/* $XFree86: xc/programs/xfs/os/error.c,v 1.6 2000/11/30 23:30:10 dawes Exp $ */
 
 #include	<stdio.h>
 #include	<stdarg.h>
@@ -70,11 +70,16 @@
 #include	<syslog.h>
 #endif
 
+#include	<errno.h>
+
 #include	"misc.h"
 
 extern char *progname;
 
 Bool        UseSyslog;
+#ifdef USE_SYSLOG
+Bool        log_open = FALSE;
+#endif
 char        ErrorFile[PATH_MAX];
 
 static void
@@ -128,7 +133,12 @@
 void
 Error(char *str)
 {
-    /* XXX this should also go to syslog() */
+#ifdef USE_SYSLOG
+    if (UseSyslog) {
+	syslog(LOG_ERR, "%s: %s", str, strerror(errno));
+	return;
+    }
+#endif
     perror(str);
 }
 
@@ -139,17 +149,15 @@
 void
 NoticeF(char *f, ...)
 {
-
+    /* XXX should Notices just be ignored if not using syslog? */
+    va_list args;
+    va_start(args, f);
 #ifdef USE_SYSLOG
     if (UseSyslog) {
-	syslog(LOG_NOTICE, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
+	vsyslog(LOG_NOTICE, f, args);
 	return;
     }
 #endif
-
-    /* XXX should Notices just be ignored if not using syslog? */
-    va_list args;
-    va_start(args, f);
     fprintf(stderr, "%s notice: ", progname);
     vfprintf(stderr, f, args);
     va_end(args);
@@ -162,14 +170,14 @@
 void
 ErrorF(char * f, ...)
 {
+    va_list args;
+    va_start(args, f);
 #ifdef USE_SYSLOG
     if (UseSyslog) {
-	syslog(LOG_ERR, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
+	vsyslog(LOG_NOTICE, f, args);
 	return;
     }
 #endif
-    va_list args;
-    va_start(args, f);
     fprintf(stderr, "%s error: ", progname);
     vfprintf(stderr, f, args);
     va_end(args);
Index: xc/programs/xfs/os/io.c
diff -u xc/programs/xfs/os/io.c:3.10 xc/programs/xfs/os/io.c:3.11
--- xc/programs/xfs/os/io.c:3.10	Sun Feb 13 01:15:46 2000
+++ xc/programs/xfs/os/io.c	Thu Nov 30 18:30:11 2000
@@ -42,7 +42,7 @@
  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  * THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/xfs/os/io.c,v 3.10 2000/02/13 06:15:46 dawes Exp $ */
+/* $XFree86: xc/programs/xfs/os/io.c,v 3.11 2000/11/30 23:30:11 dawes Exp $ */
 
 #include	<X11/Xtrans.h>
 #include	<stdio.h>
@@ -456,7 +456,8 @@
 		obuf = (unsigned char *) fsrealloc(oco->buf,
 					      notWritten + OutputBufferSize);
 		if (!obuf) {
-		    _FontTransClose(oc->trans_conn);
+		    if (oc->trans_conn)
+			_FontTransClose(oc->trans_conn);
 		    oc->trans_conn = NULL;
 		    MarkClientException(client);
 		    oco->count = 0;
Index: xc/programs/xfs/os/utils.c
diff -u xc/programs/xfs/os/utils.c:3.9 xc/programs/xfs/os/utils.c:3.11
--- xc/programs/xfs/os/utils.c:3.9	Sun Mar  7 06:41:08 1999
+++ xc/programs/xfs/os/utils.c	Thu Nov 30 18:30:11 2000
@@ -42,11 +42,11 @@
  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  * THIS SOFTWARE.
  */
-/* $XFree86: xc/programs/xfs/os/utils.c,v 3.9 1999/03/07 11:41:08 dawes Exp $ */
+/* $XFree86: xc/programs/xfs/os/utils.c,v 3.11 2000/11/30 23:30:11 dawes Exp $ */
 
 #include	<stdio.h>
 #include	<X11/Xos.h>
-#ifdef linux
+#ifndef X_NOT_STDC_ENV
 #include	<stdlib.h>
 #endif
 #include	"misc.h"
@@ -56,6 +56,10 @@
 #include	<util/memleak/memleak.h>
 #endif
 #include	<sys/wait.h>
+#include	<unistd.h>
+#include	<pwd.h>
+#include	<grp.h>
+#include	<sys/types.h>
 
 #ifndef X_NOT_POSIX
 #ifdef _POSIX_SOURCE
@@ -91,8 +95,16 @@
 #endif
 
 extern char *configfilename;
+static Bool dropPriv = FALSE; /* whether or not to drop root privileges */
+#ifdef DEFAULT_DAEMON
+static Bool becomeDaemon = TRUE; /* whether to become a daemon or not */
+#else
+static Bool becomeDaemon = FALSE; /* whether to become a daemon or not */
+#endif
+static const char *userId = NULL;
 char       *progname;
 Bool        CloneSelf;
+Bool        portFromCmdline = FALSE;
 
 OldListenRec *OldListen = NULL;
 int 	     OldListenCount = 0;
@@ -189,7 +201,7 @@
 static void
 usage(void)
 {
-    fprintf(stderr, "usage: %s [-config config_file] [-port tcp_port]\n",
+    fprintf(stderr, "usage: %s [-config config_file] [-port tcp_port] [-droppriv] [-daemon] [-nodaemon] [-user user_name]\n",
 	    progname);
     exit(1);
 }
@@ -284,15 +296,27 @@
     progname = argv[0];
     for (i = 1; i < argc; i++) {
 	if (!strcmp(argv[i], "-port")) {
-	    if (argv[i + 1])
+	    if (argv[i + 1]) {
 		ListenPort = atoi(argv[++i]);
-	    else
+		portFromCmdline = TRUE;
+	    } else
 		usage();
 	} else if (!strcmp(argv[i], "-ls")) {
 	    if (argv[i + 1])
 		ProcessLSoption (argv[++i]);
 	    else
 		usage();
+	} else if (!strcmp(argv[i], "-droppriv")) {
+	        dropPriv = TRUE;
+	} else if (!strcmp(argv[i], "-daemon")) {
+	        becomeDaemon = TRUE;
+	} else if (!strcmp(argv[i], "-nodaemon")) {
+	        becomeDaemon = FALSE;
+	} else if (!strcmp(argv[i], "-user")) {
+	    if (argv[i + 1])
+		userId = argv[++i];
+	    else
+		usage();
 	} else if (!strcmp(argv[i], "-cf") || !strcmp(argv[i], "-config")) {
 	    if (argv[i + 1])
 		configfilename = argv[++i];
@@ -430,3 +454,61 @@
 }
 
 #endif /* SPECIAL_MALLOC */
+
+
+void
+SetUserId(void)
+{
+    /* become xfs user (or other specified on command line) if possible */
+    if ((geteuid() == 0) && (dropPriv || userId)) {
+	const char *user;
+	struct passwd *pwent;
+
+	if (!userId)
+	    user = "xfs";
+	else
+	    user = userId;
+	pwent = getpwnam(user);
+	if (pwent) {
+	    if (setgid(pwent->pw_gid)) {
+		ErrorF("fatal: couldn't set groupid to xfs user's group\n");
+		exit(1);
+	    }
+	    if (setgroups(0, NULL)) {
+		ErrorF("fatal: couldn't drop supplementary groups\n");
+		exit(1);
+	    }
+	    if (initgroups(user, pwent->pw_gid)) {
+		ErrorF("fatal: couldn't init supplementary groups\n");
+		exit(1);
+	    }
+	    if (setuid(pwent->pw_uid)) {
+		ErrorF("fatal: couldn't set userid to %s user\n", user);
+		exit(1);
+	    }
+	}
+    } else if (dropPriv || userId) {
+	ErrorF("fatal: -droppriv or -user flag specified, but xfs not run as root\n");
+	exit(1);
+    }
+}
+
+
+void
+SetDaemonState(void)
+{
+    int oldpid;
+
+    if (becomeDaemon) {
+	BecomeOrphan();
+	BecomeDaemon();
+	if ((oldpid = StorePid())) {
+	    if (oldpid == -1)
+		ErrorF ("can't create/lock pid file\n");
+	    else
+		ErrorF ("can't lock pid file, another xfs is running (pid %s)\n",
+			oldpid);
+	    exit(1);
+	}
+    }
+}
Index: xc/programs/xgc/tests.c
diff -u xc/programs/xgc/tests.c:1.3 xc/programs/xgc/tests.c:1.5
--- xc/programs/xgc/tests.c:1.3	Wed Apr  5 14:14:07 2000
+++ xc/programs/xgc/tests.c	Tue Nov 14 13:20:39 2000
@@ -1,6 +1,6 @@
 /*
 ** $XConsortium: tests.c,v 1.20 91/06/08 18:57:07 rws Exp $
-** $XFree86: xc/programs/xgc/tests.c,v 1.3 2000/04/05 18:14:07 dawes Exp $
+** $XFree86: xc/programs/xgc/tests.c,v 1.5 2000/11/14 18:20:39 dawes Exp $
 **
 */
 
@@ -28,7 +28,7 @@
 #define random lrand48
 #endif
 
-#if !defined(sgi) && !defined(linux) && !defined(__alpha__)
+#ifdef X_NOT_STDC_ENV
 extern long random();
 #endif
 
Index: xc/programs/xhost/xhost.c
diff -u xc/programs/xhost/xhost.c:3.11 xc/programs/xhost/xhost.c:3.12
--- xc/programs/xhost/xhost.c:3.11	Sat Mar 13 22:22:29 1999
+++ xc/programs/xhost/xhost.c	Thu Aug 10 13:40:41 2000
@@ -22,7 +22,7 @@
 from The Open Group.
 
 */
-/* $XFree86: xc/programs/xhost/xhost.c,v 3.11 1999/03/14 03:22:29 dawes Exp $ */
+/* $XFree86: xc/programs/xhost/xhost.c,v 3.12 2000/08/10 17:40:41 dawes Exp $ */
 
 #if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
 #define NEEDSOCKETS
@@ -682,3 +682,12 @@
     XmuPrintDefaultErrorMessage (dpy, rep, stderr);
     return 0;
 }
+
+#ifdef __CYGWIN__
+void sethostent(int x)
+{}
+
+void endhostent()
+{}
+#endif
+
Index: xc/programs/xinit/Imakefile
diff -u xc/programs/xinit/Imakefile:3.6 xc/programs/xinit/Imakefile:3.8
--- xc/programs/xinit/Imakefile:3.6	Mon Jan 31 14:33:44 2000
+++ xc/programs/xinit/Imakefile	Sat Dec  2 14:06:58 2000
@@ -1,5 +1,5 @@
 XCOMM $XConsortium: Imakefile /main/25 1996/01/15 12:19:07 gildea $
-XCOMM $XFree86: xc/programs/xinit/Imakefile,v 3.6 2000/01/31 19:33:44 dawes Exp $
+XCOMM $XFree86: xc/programs/xinit/Imakefile,v 3.8 2000/12/02 19:06:58 herrb Exp $
 #if HasVFork
   VFORK_DEFINES = -DHAS_VFORK
 #endif
@@ -17,7 +17,9 @@
           OBJS1 = xinit.o 
    SAMPLECONFIG = xinitrc
        PROGRAMS = ProgramTargetName(xinit) startx $(SAMPLECONFIG)
-
+#if HasCookieMaker
+     COOKIEDEFS = -DHAS_COOKIE_MAKER -DMK_COOKIE=MkCookieCmd
+#endif
 
 ComplexProgramTarget_1(xinit,$(LOCAL_LIBRARIES),$(DEFFILE))
 
@@ -28,7 +30,7 @@
 #ifdef i386ScoArchitecture
 MakeScriptFromCpp(startx, -DXINITDIR=$(XINITDIR) -DBINDIR=$(BINDIR))
 #else
-MakeScriptFromCpp(startx, -DXINITDIR=$(XINITDIR))
+MakeScriptFromCpp(startx, -DXINITDIR=$(XINITDIR) $(COOKIEDEFS))
 #endif
 
 #ifdef OS2Architecture
Index: xc/programs/xinit/startx.cpp
diff -u xc/programs/xinit/startx.cpp:3.2 xc/programs/xinit/startx.cpp:3.5
--- xc/programs/xinit/startx.cpp:3.2	Sun Dec 20 06:58:22 1998
+++ xc/programs/xinit/startx.cpp	Sat Dec  2 13:06:58 2000
@@ -1,7 +1,7 @@
 XCOMM!/bin/sh
 
 XCOMM $XConsortium: startx.cpp,v 1.4 91/08/22 11:41:29 rws Exp $
-XCOMM $XFree86: xc/programs/xinit/startx.cpp,v 3.2 1998/12/20 11:58:22 dawes Exp $
+XCOMM $XFree86: xc/programs/xinit/startx.cpp,v 3.5 2000/12/02 18:06:58 herrb Exp $
 XCOMM 
 XCOMM This is just a sample implementation of a slightly less primitive 
 XCOMM interface than xinit.  It looks for user .xinitrc and .xserverrc
@@ -78,6 +78,7 @@
 fi
 fi
 
+display=:0
 whoseargs="client"
 while [ "x$1" != "x" ]; do
     case "$1" in
@@ -98,11 +99,34 @@
 	*)	if [ "$whoseargs" = "client" ]; then
 		    clientargs="$clientargs $1"
 		else
-		    serverargs="$serverargs $1"
+		    case "$1" in
+			:[0-9]*) display="$1"; serverargs="$serverargs $1";;
+			*) serverargs="$serverargs $1" ;;
+		    esac
 		fi ;;
     esac
     shift
 done
+
+#if defined(HAS_COOKIE_MAKER) && defined(MK_COOKIE)
+XCOMM set up default Xauth info for this machine
+#ifndef HOSTNAME
+#ifdef __linux__
+#define HOSTNAME hostname -f
+#else
+#define HOSTNAME hostname
+#endif
+#endif
+mcookie=`MK_COOKIE`
+if [ X"$XAUTHORITY" = X ]; then
+    authfile="$HOME/.Xauthority"
+else
+    authfile="$XAUTHORITY"
+fi
+serverargs="$serverargs -auth $authfile"
+xauth add $display . $mcookie
+xauth add `HOSTNAME`$display . $mcookie
+#endif
 
 xinit $clientargs -- $serverargs
 
Index: xc/programs/xinit/xinit.c
diff -u xc/programs/xinit/xinit.c:3.22 xc/programs/xinit/xinit.c:3.23
--- xc/programs/xinit/xinit.c:3.22	Wed Apr  5 14:14:08 2000
+++ xc/programs/xinit/xinit.c	Wed Nov  1 21:51:25 2000
@@ -21,7 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/programs/xinit/xinit.c,v 3.22 2000/04/05 18:14:08 dawes Exp $ */
+/* $XFree86: xc/programs/xinit/xinit.c,v 3.23 2000/11/02 02:51:25 dawes Exp $ */
 
 #include <X11/Xlib.h>
 #include <X11/Xos.h>
@@ -126,6 +126,10 @@
 #ifdef XFREE86
     "XFree86     XFree86 displays",
 #endif
+#ifdef __DARWIN__
+    "Xdarwin   Apple darwin / Mac OS/X",
+#endif
+    
     NULL};
 
 #ifndef XINITRC
Index: xc/programs/xkbcomp/action.c
diff -u xc/programs/xkbcomp/action.c:3.6 xc/programs/xkbcomp/action.c:3.7
--- xc/programs/xkbcomp/action.c:3.6	Sun Oct  4 05:41:26 1998
+++ xc/programs/xkbcomp/action.c	Tue Oct 24 18:45:16 2000
@@ -24,7 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
-/* $XFree86: xc/programs/xkbcomp/action.c,v 3.6 1998/10/04 09:41:26 dawes Exp $ */
+/* $XFree86: xc/programs/xkbcomp/action.c,v 3.7 2000/10/24 22:45:16 dawes Exp $ */
 
 #include "xkbcomp.h"
 #include "tokens.h"
@@ -908,7 +908,6 @@
 	{	"accessxkeys",		XkbAccessXKeysMask	},
 	{	"accessxtimeout",	XkbAccessXTimeoutMask	},
 	{	"accessxfeedback",	XkbAccessXFeedbackMask	},
-	{	"groupswrap",		XkbGroupsWrapMask	},
 	{	"audiblebell",		XkbAudibleBellMask	},
 	{	"overlay1",		XkbOverlay1Mask		},
 	{	"overlay2",		XkbOverlay2Mask		},
Index: xc/programs/xkbcomp/compat.c
diff -u xc/programs/xkbcomp/compat.c:3.0 xc/programs/xkbcomp/compat.c:3.2
--- xc/programs/xkbcomp/compat.c:3.0	Mon Mar  4 00:29:23 1996
+++ xc/programs/xkbcomp/compat.c	Sun Aug 27 22:43:18 2000
@@ -24,6 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
+/* $XFree86: xc/programs/xkbcomp/compat.c,v 3.2 2000/08/28 02:43:18 tsi Exp $ */
 
 #include <X11/Xos.h>
 #include "xkbcomp.h"
@@ -287,9 +288,8 @@
 
     merge= newGC->merge;
     gc= &info->groupCompat[group];
-    if ((gc->fileID<1)||
+    if ((newGC->fileID<1)||
 	((gc->real_mods==newGC->real_mods)&&(gc->vmods==newGC->vmods))) {
-	*gc= *newGC;
 	return True;
     }
     if (((gc->fileID==newGC->fileID)&&(warningLevel>0))||(warningLevel>9)) {
Index: xc/programs/xkbcomp/expr.c
diff -u xc/programs/xkbcomp/expr.c:3.3 xc/programs/xkbcomp/expr.c:3.4
--- xc/programs/xkbcomp/expr.c:3.3	Sun Oct 26 08:25:28 1997
+++ xc/programs/xkbcomp/expr.c	Tue Oct 24 18:45:16 2000
@@ -24,7 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
-/* $XFree86: xc/programs/xkbcomp/expr.c,v 3.3 1997/10/26 13:25:28 dawes Exp $ */
+/* $XFree86: xc/programs/xkbcomp/expr.c,v 3.4 2000/10/24 22:45:16 dawes Exp $ */
 
 #include "xkbcomp.h"
 #include "tokens.h"
@@ -960,6 +960,8 @@
 	while (values && values->name) {
 	    if (nOut!=0)	INFO1(", %s",values->name);
 	    else		INFO1("%s",values->name);
+	    values++;
+	    nOut++;
 	}
 	INFO(")\n");
 	return False;
Index: xc/programs/xkbcomp/indicators.c
diff -u xc/programs/xkbcomp/indicators.c:1.1.1.3 xc/programs/xkbcomp/indicators.c:1.3
--- xc/programs/xkbcomp/indicators.c:1.1.1.3	Tue Jan 16 05:20:37 1996
+++ xc/programs/xkbcomp/indicators.c	Fri Oct 27 20:34:04 2000
@@ -24,6 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
+/* $XFree86: xc/programs/xkbcomp/indicators.c,v 1.3 2000/10/28 00:34:04 dawes Exp $ */
 
 #include "xkbcomp.h"
 #include "misc.h"
@@ -171,6 +172,7 @@
 	{	NULL,		0			}
 };
 LookupEntry	groupComponentNames[] = {
+	{	"base",		XkbIM_UseBase		},
 	{	"latched",	XkbIM_UseLatched	},
 	{	"locked",	XkbIM_UseLocked		},
 	{	"effective",	XkbIM_UseEffective	},
@@ -254,13 +256,6 @@
 						(XPointer)groupComponentNames)){
 	    return ReportIndicatorBadType(xkb->dpy,led,field,
 					"mask of group state components");
-	}
-	if ((rtrn.uval&XkbIM_UseCompat)&&(warningLevel>0)) {
-	    WARN("Cannot use the compatibilty state for groups\n");
-	    ACTION2("Not set in the %s field of the map for indicator %s\n",
-				field,
-				XkbAtomText(NULL,led->name,XkbMessage));
-	    rtrn.uval&= ~XkbIM_UseCompat;
 	}
 	led->which_groups= rtrn.uval;
     } 
Index: xc/programs/xkbcomp/keytypes.c
diff -u xc/programs/xkbcomp/keytypes.c:1.1.1.3 xc/programs/xkbcomp/keytypes.c:1.3
--- xc/programs/xkbcomp/keytypes.c:1.1.1.3	Tue Jan 16 05:20:41 1996
+++ xc/programs/xkbcomp/keytypes.c	Mon Nov  6 16:57:11 2000
@@ -24,6 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
+/* $XFree86: xc/programs/xkbcomp/keytypes.c,v 1.3 2000/11/06 21:57:11 dawes Exp $ */
 
 #include "xkbcomp.h"
 #include "tokens.h"
@@ -1139,10 +1140,7 @@
 {
 ParseCommon	*stmt;
 
-    if ((merge==MergeOverride)||(info->name==None))
-	info->name= file->name;
-
-    info->name= file->name;
+    info->name= uStringDup(file->name);
     stmt= file->defs;
     while (stmt) {
 	switch (stmt->stmtType) {
Index: xc/programs/xkbcomp/listing.c
diff -u xc/programs/xkbcomp/listing.c:3.5 xc/programs/xkbcomp/listing.c:3.6
--- xc/programs/xkbcomp/listing.c:3.5	Sun Oct  4 05:41:26 1998
+++ xc/programs/xkbcomp/listing.c	Tue Aug  1 16:05:44 2000
@@ -66,7 +66,7 @@
 SOFTWARE.
 
 ******************************************************************/
-/* $XFree86: xc/programs/xkbcomp/listing.c,v 3.5 1998/10/04 09:41:26 dawes Exp $ */
+/* $XFree86: xc/programs/xkbcomp/listing.c,v 3.6 2000/08/01 20:05:44 dawes Exp $ */
 
 
 #include <stdio.h>
@@ -480,6 +480,7 @@
 		    WARN1("Couldn't open \"%s\"\n",list[i].file);
 		continue;
 	    }
+	    setScanState(list[i].file, 1);
 	    if (XKBParseFile(inputFile,&rtrn)&&(rtrn!=NULL)) {
 		mapName= list[i].map;
 		mapToUse= rtrn;
Index: xc/programs/xkbcomp/symbols.c
diff -u xc/programs/xkbcomp/symbols.c:3.8 xc/programs/xkbcomp/symbols.c:3.9
--- xc/programs/xkbcomp/symbols.c:3.8	Sun Oct  4 05:41:27 1998
+++ xc/programs/xkbcomp/symbols.c	Mon Nov  6 13:21:57 2000
@@ -24,7 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
-/* $XFree86: xc/programs/xkbcomp/symbols.c,v 3.8 1998/10/04 09:41:27 dawes Exp $ */
+/* $XFree86: xc/programs/xkbcomp/symbols.c,v 3.9 2000/11/06 18:21:57 dawes Exp $ */
 
 #include "xkbcomp.h"
 #include "tokens.h"
@@ -553,19 +553,27 @@
 
 static Bool
 #if NeedFunctionPrototypes
-AddKeySymbols(SymbolsInfo *info,KeyInfo *key)
+AddKeySymbols(SymbolsInfo *info,KeyInfo *key,XkbDescPtr xkb)
 #else
 AddKeySymbols(info,key)
     SymbolsInfo *	  info;
     KeyInfo *		  key;
+    XkbDescPtr		xkb;
 #endif
 {
 register int i;
+unsigned long real_name;
 
     for (i=0;i<info->nKeys;i++) {
 	if (info->keys[i].name==key->name)
 	    return MergeKeys(info,&info->keys[i],key);
     }
+    if(FindKeyNameForAlias(xkb, key->name, &real_name)) {
+        for (i=0;i<info->nKeys;i++) {
+	    if (info->keys[i].name==real_name)
+	        return MergeKeys(info,&info->keys[i],key);
+        }
+    }
     if (info->nKeys>=info->szKeys) {
 	info->szKeys+= SYMBOLS_CHUNK;
 	info->keys= uTypedRecalloc(info->keys,info->nKeys,info->szKeys,KeyInfo);
@@ -651,12 +659,14 @@
 
 static void
 #if NeedFunctionPrototypes
-MergeIncludedSymbols(SymbolsInfo *into,SymbolsInfo *from,unsigned merge)
+MergeIncludedSymbols(SymbolsInfo *into,SymbolsInfo *from,
+                     unsigned merge,XkbDescPtr xkb)
 #else
-MergeIncludedSymbols(into,from,merge)
+MergeIncludedSymbols(into,from,merge,xkb)
     SymbolsInfo *	into;
     SymbolsInfo *	from;
     unsigned		merge;
+    XkbDescPtr		xkb;
 #endif
 {
 register int 	i;
@@ -679,7 +689,7 @@
     for (i=0,key=from->keys;i<from->nKeys;i++,key++) {
 	if (merge!=MergeDefault)
 	    key->defs.merge= merge;
-	if (!AddKeySymbols(into,key))
+	if (!AddKeySymbols(into,key,xkb))
 	    into->errorCount++;
     }
     if (from->modMap!=NULL) {
@@ -757,7 +767,7 @@
 	for (next=stmt->next;next!=NULL;next=next->next) {
 	    if ((next->file==NULL)&&(next->map==NULL)) {
 		haveSelf= True;
-		MergeIncludedSymbols(&included,info,next->merge);
+		MergeIncludedSymbols(&included,info,next->merge,xkb);
 		FreeSymbolsInfo(info);
 	    }
 	    else if (ProcessIncludeFile(next,XkmSymbolsIndex,&rtrn,&op)) {
@@ -765,7 +775,7 @@
 		next_incl.fileID= next_incl.dflt.defs.fileID= rtrn->id;
 		next_incl.merge= next_incl.dflt.defs.merge= MergeOverride;
 		(*hndlr)(rtrn,xkb,MergeOverride,&next_incl);
-		MergeIncludedSymbols(&included,&next_incl,op);
+		MergeIncludedSymbols(&included,&next_incl,op,xkb);
 		FreeSymbolsInfo(&next_incl);
 	    }
 	    else {
@@ -777,7 +787,7 @@
     if (haveSelf)
 	*info= included;
     else {
-	MergeIncludedSymbols(info,&included,newMerge);
+	MergeIncludedSymbols(info,&included,newMerge,xkb);
 	FreeSymbolsInfo(&included);
     }
     return (info->errorCount==0);
@@ -1442,7 +1452,7 @@
 	return False;
     }
 
-    if (!AddKeySymbols(info,&key)) {
+    if (!AddKeySymbols(info,&key,xkb)) {
 	info->errorCount++;
 	return False;
     }
@@ -1513,7 +1523,7 @@
 {
 ParseCommon	*stmt;
 
-    info->name= file->name;
+    info->name= uStringDup(file->name);
     stmt= file->defs;
     while (stmt) {
 	switch (stmt->stmtType) {
Index: xc/programs/xkbcomp/utils.h
diff -u xc/programs/xkbcomp/utils.h:3.1 xc/programs/xkbcomp/utils.h:3.2
--- xc/programs/xkbcomp/utils.h:3.1	Mon Aug 26 06:52:26 1996
+++ xc/programs/xkbcomp/utils.h	Tue Oct 24 18:45:16 2000
@@ -3,7 +3,7 @@
 
   /*\
    * $XConsortium: utils.h /main/3 1996/01/14 16:48:26 kaleb $
-   * $XFree86: xc/programs/xkbcomp/utils.h,v 3.1 1996/08/26 10:52:26 dawes Exp $
+   * $XFree86: xc/programs/xkbcomp/utils.h,v 3.2 2000/10/24 22:45:16 dawes Exp $
    *
    *		              COPYRIGHT 1990
    *		        DIGITAL EQUIPMENT CORPORATION
@@ -350,7 +350,8 @@
 #define	uStringText(s)		((s)==NullString?"<NullString>":(s))
 #define	uStringEqual(s1,s2)	(uStringCompare(s1,s2)==Equal)
 #define	uStringPrefix(p,s)	(strncmp(p,s,strlen(p))==0)
-#define	uStringCompare(s1,s2)	(strcmp(s1,s2))
+#define	uStringCompare(s1,s2)	(((s1)==NullString||(s2)==NullString)?\
+                                 (s1)!=(s2):strcmp(s1,s2))
 #define	uStrCaseEqual(s1,s2)	(uStrCaseCmp(s1,s2)==0)
 #ifdef HAVE_STRCASECMP
 #define	uStrCaseCmp(s1,s2)	(strcasecmp(s1,s2))
Index: xc/programs/xkbcomp/xkbcomp.h
diff -u xc/programs/xkbcomp/xkbcomp.h:3.5 xc/programs/xkbcomp/xkbcomp.h:3.6
--- xc/programs/xkbcomp/xkbcomp.h:3.5	Sun Oct 26 08:25:30 1997
+++ xc/programs/xkbcomp/xkbcomp.h	Tue Aug  1 16:05:44 2000
@@ -24,7 +24,7 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
-/* $XFree86: xc/programs/xkbcomp/xkbcomp.h,v 3.5 1997/10/26 13:25:30 dawes Exp $ */
+/* $XFree86: xc/programs/xkbcomp/xkbcomp.h,v 3.6 2000/08/01 20:05:44 dawes Exp $ */
 
 #ifndef XKBCOMP_H
 #define	XKBCOMP_H 1
@@ -233,6 +233,7 @@
     unsigned	 merge;
     Atom	 name;
     VarDef *	 body;
+    void *	 pad;	/* so that sizeof(IndicatorMapDef) == sizeof(DoodadDef) */
 } IndicatorMapDef;
 
 typedef struct _IndicatorNameDef {
Index: xc/programs/xkbcomp/xkbcomp.man
diff -u xc/programs/xkbcomp/xkbcomp.man:1.4 xc/programs/xkbcomp/xkbcomp.man:1.6
--- xc/programs/xkbcomp/xkbcomp.man:1.4	Sun Oct  4 05:41:28 1998
+++ xc/programs/xkbcomp/xkbcomp.man	Thu Aug  3 08:24:03 2000
@@ -1,4 +1,5 @@
 .\" $TOG: xkbcomp.man /main/5 1997/11/04 20:57:14 kaleb $
+.\" $XFree86: xc/programs/xkbcomp/xkbcomp.man,v 1.6 2000/08/03 12:24:03 dawes Exp $
 .TH XKBCOMP 1 "Release 6.4" "X Version 11"
 .SH NAME
 xkbcomp \- compile XKB keyboard description
@@ -38,7 +39,7 @@
 .SH OPTIONS
 .TP 8
 .B \-a
-Show all keyboard information, reporting implicit or dervied information
+Show all keyboard information, reporting implicit or derived information
 as a comment.  Only affects \fI.xkb\fP format output.
 .TP 8
 .B \-C
Index: xc/programs/xkbcomp/xkbparse.y
diff -u xc/programs/xkbcomp/xkbparse.y:3.6 xc/programs/xkbcomp/xkbparse.y:3.8
--- xc/programs/xkbcomp/xkbparse.y:3.6	Sun Jun 22 06:17:04 1997
+++ xc/programs/xkbcomp/xkbparse.y	Fri Oct 27 20:34:04 2000
@@ -24,6 +24,8 @@
  THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
  ********************************************************/
+/* $XFree86: xc/programs/xkbcomp/xkbparse.y,v 3.8 2000/10/28 00:34:04 dawes Exp $ */
+
 %token
 	END_OF_FILE	0
 	ERROR_TOK	255
@@ -405,6 +407,7 @@
 			{ $$= (VarDef *)AppendStmt(&$1->common,&$3->common); }
 		|	SymbolsVarDecl
 			{ $$= $1; }
+		|	{ $$= NULL; }
 		;
 
 SymbolsVarDecl	:	Lhs EQUALS Expr
Index: xc/programs/xkbcomp/compat/Imakefile
diff -u xc/programs/xkbcomp/compat/Imakefile:3.6 xc/programs/xkbcomp/compat/Imakefile:3.7
--- xc/programs/xkbcomp/compat/Imakefile:3.6	Sun Aug 29 22:34:20 1999
+++ xc/programs/xkbcomp/compat/Imakefile	Sat Aug 26 11:11:29 2000
@@ -1,8 +1,8 @@
 XCOMM $TOG: Imakefile /main/5 1997/08/02 10:10:30 kaleb $
-XCOMM $XFree86: xc/programs/xkbcomp/compat/Imakefile,v 3.6 1999/08/30 02:34:20 dawes Exp $
+XCOMM $XFree86: xc/programs/xkbcomp/compat/Imakefile,v 3.7 2000/08/26 15:11:29 dawes Exp $
 
      DATAFILES = accessx basic complete default group_led iso9995 japan \
-		 keypad misc mousekeys norepeat pc pc98 xtest
+		 keypad misc mousekeys norepeat pc pc98 xtest leds
 
 all::
 
Index: xc/programs/xkbcomp/compat/basic
diff -u xc/programs/xkbcomp/compat/basic:1.1.1.2 xc/programs/xkbcomp/compat/basic:1.2
--- xc/programs/xkbcomp/compat/basic:1.1.1.2	Wed Jan  3 02:40:18 1996
+++ xc/programs/xkbcomp/compat/basic	Mon Nov  6 14:24:10 2000
@@ -5,6 +5,8 @@
 // caps lock and mode switch) and set up the 
 // automatic updating of common keyboard LEDs.
 
+// $XFree86: xc/programs/xkbcomp/compat/basic,v 1.2 2000/11/06 19:24:10 dawes Exp $
+
 default xkb_compatibility "basic"  {
     virtual_modifiers NumLock,AltGr;
 
@@ -29,7 +31,7 @@
     interpret Mode_switch {
 	useModMapMods= level1;
 	virtualModifier= AltGr;
-	action= SetGroup(group=2,clearLocks);
+	action= SetGroup(group=+1);
     };
 
     interpret Any + Any {
Index: xc/programs/xkbcomp/compat/leds
diff -u /dev/null xc/programs/xkbcomp/compat/leds:1.1
--- /dev/null	Mon Dec 18 14:34:42 2000
+++ xc/programs/xkbcomp/compat/leds	Sat Aug 26 11:11:29 2000
@@ -0,0 +1,24 @@
+// Use keyboard LEDs to show alternative group
+//
+// $XFree86: xc/programs/xkbcomp/compat/leds,v 1.1 2000/08/26 15:11:29 dawes Exp $
+
+partial xkb_compatibility "scroll" {
+   indicator "Scroll Lock" {
+       modifiers= None;
+       groups=All-group1;
+   };
+};
+
+partial xkb_compatibility "num"    {
+   indicator "Num Lock" {
+       modifiers= None;
+       groups=All-group1;
+   };
+};
+
+partial xkb_compatibility "caps"   {
+   indicator "Caps Lock" {
+       modifiers= None;
+       groups=All-group1;
+   };
+};
Index: xc/programs/xkbcomp/geometry/macintosh
diff -u xc/programs/xkbcomp/geometry/macintosh:1.1 xc/programs/xkbcomp/geometry/macintosh:1.2
--- xc/programs/xkbcomp/geometry/macintosh:1.1	Sun May 23 01:27:50 1999
+++ xc/programs/xkbcomp/geometry/macintosh	Sat Aug 26 00:30:59 2000
@@ -1,4 +1,4 @@
-// $XFree86: xc/programs/xkbcomp/geometry/macintosh,v 1.1 1999/05/23 05:27:50 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/geometry/macintosh,v 1.2 2000/08/26 04:30:59 dawes Exp $
 default xkb_geometry "macintosh" {
 
     description= "Apple Extended Keyboard II";
@@ -19,7 +19,7 @@
     shape "RCTL" { { [ 28,18] }, { [2,1], [ 26,17] } };
     shape "RALT" { { [ 28,18] }, { [2,1], [ 26,17] } };
     shape "RMTA" { { [ 28,18] }, { [2,1], [ 26,17] } };
-    shape "RFSH" { { [ 42,18] }, { [2,1], [ 40,17] } };
+    shape "RTSH" { { [ 42,18] }, { [2,1], [ 40,17] } };
     shape "SPCE" { { [112,18] }, { [2,1], [110,17] } };
     shape "KP0"  { { [ 37,18] }, { [2,1], [ 35,17] } };
     shape "KPEN" { { [ 18,37] }, { [2,1], [ 16,36] } };
@@ -57,8 +57,8 @@
 	    top= 1;
 	    keys {  <ESC>,  <FK01>, <FK02>, <FK03>, <FK04>,
                     <FK05>, <FK06>, <FK07>, <FK08>, <FK09>,
-		    <FK10>, <FK11>, <FK12>, <FK13>, <FK14>,
-                    <FK15> 
+                    <FK10>, <FK11>, <FK12>, <PRSC>, <SCLK>,
+                    <PAUS>
 	    };
 	};
     }; // End of "Function" section
@@ -90,7 +90,7 @@
 	    top= 58;
 	    keys { { <LFSH>, "LFSH" }, <AB01>, <AB02>, <AB03>,
                    <AB04>, <AB05>, <AB06>, <AB07>, <AB08>, <AB09>,
-                   <AB10>, { <RFSH>, "RFSH" }
+                   <AB10>, { <RTSH>, "RTSH" }
 	    };
 	};
 	row {
@@ -132,7 +132,7 @@
 	left= 375;
 	row {
 	    top= 1;
-	    keys { <KPCL>, <KPEQ>, <KPDV>, <KPMU> };
+            keys { <NMLK>, <KPEQ>, <KPDV>, <KPMU> };
 	};
 	row {
 	    top= 20;
Index: xc/programs/xkbcomp/keycodes/Imakefile
diff -u xc/programs/xkbcomp/keycodes/Imakefile:3.9 xc/programs/xkbcomp/keycodes/Imakefile:3.10
--- xc/programs/xkbcomp/keycodes/Imakefile:3.9	Sun May 23 01:27:50 1999
+++ xc/programs/xkbcomp/keycodes/Imakefile	Tue Sep 19 08:46:23 2000
@@ -1,9 +1,9 @@
 XCOMM $TOG: Imakefile /main/13 1997/08/02 10:10:54 kaleb $
-XCOMM $XFree86: xc/programs/xkbcomp/keycodes/Imakefile,v 3.9 1999/05/23 05:27:50 dawes Exp $
+XCOMM $XFree86: xc/programs/xkbcomp/keycodes/Imakefile,v 3.10 2000/09/19 12:46:23 eich Exp $
 #define IHaveSubdirs
 
     DATAFILES = amiga ataritt fujitsu hp ibm macintosh sony sun xfree86 \
-		xfree98
+		xfree98 powerpcps2
       SUBDIRS = digital sgi
 
 all::
Index: xc/programs/xkbcomp/keycodes/macintosh
diff -u xc/programs/xkbcomp/keycodes/macintosh:1.1 xc/programs/xkbcomp/keycodes/macintosh:1.3
--- xc/programs/xkbcomp/keycodes/macintosh:1.1	Sun May 23 01:27:51 1999
+++ xc/programs/xkbcomp/keycodes/macintosh	Tue Sep 19 08:46:23 2000
@@ -26,7 +26,7 @@
 //other dealings in this Software without prior written authorization
 //from the X Consortium.
 //
-// $XFree86: xc/programs/xkbcomp/keycodes/macintosh,v 1.1 1999/05/23 05:27:51 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/keycodes/macintosh,v 1.3 2000/09/19 12:46:23 eich Exp $
 //
 default xkb_keycodes "macintosh" {
 
@@ -78,6 +78,7 @@
     <AC11> = 47;
     <RTRN> = 44;
 
+    <LSGT> = 18;
     <AB01> = 14;
     <AB02> = 15;
     <AB03> = 16;
@@ -91,14 +92,14 @@
 
     <SPCE> = 57;
 
-    <LCTL> = 62;
-    <LMTA> = 63;
-    <LFSH> = 64;
-    <LALT> = 66;
-    <RFSH> = 131;
-    <RALT> = 132;
-    <RCTL> = 133;
-    <RMTA> = 134;
+    <LCTL> = 62;  // Left Control
+    <LALT> = 63;  // Left Option
+    <LFSH> = 64;  // Left Shift
+    <RALT> = 66;  // Left Command
+//    <RTSH> = 131; // Right Shift
+//    <RALT> = 132; // Right Command
+//    <RCTL> = 133; // Right Control
+//    <RMTA> = 134; // Right Option
 
     <FK01> = 130;
     <FK02> = 128;
@@ -112,10 +113,11 @@
     <FK10> = 117;
     <FK11> = 111;
     <FK12> = 119;
-    <FK13> = 113;
-    <FK14> = 115;
-    <FK15> = 121;
 
+    <PRSC> = 113;
+    <SCLK> = 115;
+    <PAUS> = 121;
+
     <INS>  = 122;
     <HOME> = 123;
     <PGUP> = 124;
@@ -128,7 +130,7 @@
     <DOWN> = 69;
     <RGHT> = 68;
 
-    <KPCL> = 79;
+    <NMLK> = 79;
     <KPEQ> = 89;
     <KPDV> = 83;
     <KPMU> = 75;
@@ -151,10 +153,9 @@
     <KP0>  = 90;
     <KPDL> = 73;
 
-//    indicator 3 = "Caps Lock";
-//    indicator 2 = "Scroll Lock";
-//    indicator 1 = "Num Lock";
     indicator 3 = "Scroll Lock";
     indicator 2 = "Num Lock";
     indicator 1 = "Caps Lock";
+
+    alias <ALGR> = <RALT>;
 };
Index: xc/programs/xkbcomp/keycodes/powerpcps2
diff -u /dev/null xc/programs/xkbcomp/keycodes/powerpcps2:1.1
--- /dev/null	Mon Dec 18 14:34:45 2000
+++ xc/programs/xkbcomp/keycodes/powerpcps2	Tue Sep 19 08:46:23 2000
@@ -0,0 +1,134 @@
+// $XConsortium: xfree86 /main/4 1996/08/31 12:16:59 kaleb $
+// $XFree86: xc/programs/xkbcomp/keycodes/powerpcps2,v 1.1 2000/09/19 12:46:23 eich Exp $
+default xkb_keycodes "powerpcps2" {
+
+    minimum= 8;
+    maximum= 135;
+
+    <TLDE> =  49;
+    <AE01> =  10;
+    <AE02> =  11;
+    <AE03> =  12;
+    <AE04> =  13;
+    <AE05> =  14;
+    <AE06> =  15;
+    <AE07> =  16;
+    <AE08> =  17;
+    <AE09> =  18;
+    <AE10> =  19;
+    <AE11> =  20;
+    <AE12> =  21;
+    <BKSP> =  22;
+
+    <TAB>  =  23;
+    <AD01> =  24;
+    <AD02> =  25;
+    <AD03> =  26;
+    <AD04> =  27;
+    <AD05> =  28;
+    <AD06> =  29;
+    <AD07> =  30;
+    <AD08> =  31;
+    <AD09> =  32;
+    <AD10> =  33;
+    <AD11> =  34;
+    <AD12> =  35;
+    <RTRN> =  36;
+
+    <CAPS> =  66;
+    <AC01> =  38;
+    <AC02> =  39;
+    <AC03> =  40;
+    <AC04> =  41;
+    <AC05> =  42;
+    <AC06> =  43;
+    <AC07> =  44;
+    <AC08> =  45;
+    <AC09> =  46;
+    <AC10> =  47;
+    <AC11> =  48;
+
+    <LFSH> =  50;
+    <AB01> =  52;
+    <AB02> =  53;
+    <AB03> =  54;
+    <AB04> =  55;
+    <AB05> =  56;
+    <AB06> =  57;
+    <AB07> =  58;
+    <AB08> =  59;
+    <AB09> =  60;
+    <AB10> =  61;
+    <RTSH> =  62;
+    <BKSL> =  51;
+    <LSGT> =  94;
+
+    <LALT> =  64;
+    <LCTL> =  37;
+    <SPCE> =  65;
+    <RCTL> = 105;
+    <RALT> = 108;
+    // Microsoft keyboard extra keys
+    <LWIN> = 133;
+    <RWIN> = 134;
+    <MENU> = 135;
+
+    <ESC>  =   9;
+    <FK01> =  67;
+    <FK02> =  68;
+    <FK03> =  69;
+    <FK04> =  70;
+    <FK05> =  71;
+    <FK06> =  72;
+    <FK07> =  73;
+    <FK08> =  74;
+    <FK09> =  75;
+    <FK10> =  76;
+    <FK11> =  95;
+    <FK12> =  96;
+
+    <PRSC> = 107;
+    <SCLK> =  78;
+    <PAUS> = 127;
+
+    <INS>  = 118;
+    <HOME> = 110;
+    <PGUP> = 112;
+    <DELE> = 119;
+    <END>  = 115;
+    <PGDN> = 117;
+
+    <UP>   = 111;
+    <LEFT> = 113;
+    <DOWN> = 116;
+    <RGHT> = 114;
+
+    <NMLK> =  77;
+    <KPDV> = 106;
+    <KPMU> =  63;
+    <KPSU> =  82;
+
+    <KP7>  =  79;
+    <KP8>  =  80;
+    <KP9>  =  81;
+    <KPAD> =  86;
+
+    <KP4>  =  83;
+    <KP5>  =  84;
+    <KP6>  =  85;
+
+    <KP1>  =  87;
+    <KP2>  =  88;
+    <KP3>  =  89;
+    <KPEN> = 104;
+
+    <KP0>  =  90;
+    <KPDL> = 91;
+
+    indicator 1 = "Caps Lock";
+    indicator 2 = "Num Lock";
+    indicator 3 = "Scroll Lock";
+
+    alias <ALGR> = <RALT>;
+};
+
Index: xc/programs/xkbcomp/keycodes/xfree86
diff -u xc/programs/xkbcomp/keycodes/xfree86:3.12 xc/programs/xkbcomp/keycodes/xfree86:3.14
--- xc/programs/xkbcomp/keycodes/xfree86:3.12	Sat Jun 17 13:44:25 2000
+++ xc/programs/xkbcomp/keycodes/xfree86	Mon Aug 14 13:47:08 2000
@@ -1,5 +1,5 @@
 // $TOG: xfree86 /main/5 1997/08/02 10:11:05 kaleb $
-// $XFree86: xc/programs/xkbcomp/keycodes/xfree86,v 3.12 2000/06/17 17:44:25 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/keycodes/xfree86,v 3.14 2000/08/14 17:47:08 dawes Exp $
 default xkb_keycodes "xfree86" {
 
     minimum= 8;
@@ -127,10 +127,18 @@
     <KP0>  =  90;
     <KPDL> =  91;
 
+    <FK13> =  118;
+    <FK14> =  119;
+    <FK15> =  120;
+    <FK16> =  121;
+    <FK17> =  122;
+    <KPDC> =  123;
+
     // Extended keys that may be generated on "Internet" keyboards.
     // These are not standardised, hence the meaningless names.
     // The entries commented out are never generated because the raw codes
     // in those positions are already used for well-defined keys.
+
     <I01> =   129;
     <I02> =   130;
     <I03> =   131;
@@ -159,7 +167,7 @@
     <I1A> =   154;
     <I1B> =   155;
     // <I1C> =   156;
-    <I1D> =   157;
+    // <I1D> =   157;
     <I1E> =   158;
     <I1F> =   159;
     <I20> =   160;
@@ -180,24 +188,24 @@
     <I2F> =   175;
     <I30> =   176;
     <I31> =   177;
-    // <I32> =   178;
+    <I32> =   178;
     <I33> =   179;
     <I34> =   180;
-    <I35> =   181;
+    // <I35> =   181;
     // <I36> =   182;
     // <I37> =   183;
-    <I38> =   184;
+    // <I38> =   184;
     <I39> =   185;
     <I3A> =   186;
     <I3B> =   187;
     <I3C> =   188;
-    <I3D> =   189;
-    <I3E> =   190;
-    <I3F> =   191;
-    <I40> =   192;
-    <I41> =   193;
+    // <I3D> =   189;
+    // <I3E> =   190;
+    // <I3F> =   191;
+    // <I40> =   192;
+    // <I41> =   193;
     <I42> =   194;
-    // <I43> =   195;
+    <I43> =   195;
     <I44> =   196;
     <I45> =   197;
     // <I46> =   198;
@@ -208,7 +216,7 @@
     // <I4B> =   203;
     // <I4C> =   204;
     // <I4D> =   205;
-    <I4E> =   206;
+    // <I4E> =   206;
     // <I4F> =   207;
     // <I50> =   208;
     // <I51> =   209;
@@ -230,11 +238,11 @@
     <I61> =   225;
     <I62> =   226;
     <I63> =   227;
-    // <I64> =   228;
-    // <I65> =   229;
-    // <I66> =   230;
-    // <I67> =   231;
-    // <I68> =   232;
+    <I64> =   228;
+    <I65> =   229;
+    <I66> =   230;
+    <I67> =   231;
+    <I68> =   232;
     <I69> =   233;
     <I6A> =   234;
     <I6B> =   235;
@@ -245,8 +253,8 @@
     <I70> =   240;
     <I71> =   241;
     <I72> =   242;
-    // <I73> =   243;
-    // <I74> =   244;
+    <I73> =   243;
+    <I74> =   244;
     <I75> =   245;
     <I76> =   246;
     <I77> =   247;
@@ -658,131 +666,4 @@
     alias <ALGR> = <RALT>;
 };
 
-xkb_keycodes "sol8x86" {
-
-    minimum= 8;
-    maximum= 135;
-
-    <TLDE> =  9;
-    <AE01> =  10;
-    <AE02> =  11;
-    <AE03> =  12;
-    <AE04> =  13;
-    <AE05> =  14;
-    <AE06> =  15;
-    <AE07> =  16;
-    <AE08> =  17;
-    <AE09> =  18;
-    <AE10> =  19;
-    <AE11> =  20;
-    <AE12> =  21;
-    <BKSP> =  23;
-
-    <TAB>  =  24;
-    <AD01> =  25;
-    <AD02> =  26;
-    <AD03> =  27;
-    <AD04> =  28;
-    <AD05> =  29;
-    <AD06> =  30;
-    <AD07> =  31;
-    <AD08> =  32;
-    <AD09> =  33;
-    <AD10> =  34;
-    <AD11> =  35;
-    <AD12> =  36;
-    <BKSL> =  37;
-
-    <CAPS> =  38;
-    <AC01> =  39;
-    <AC02> =  40;
-    <AC03> =  41;
-    <AC04> =  42;
-    <AC05> =  43;
-    <AC06> =  44;
-    <AC07> =  45;
-    <AC08> =  46;
-    <AC09> =  47;
-    <AC10> =  48;
-    <AC11> =  49;
-    <RTRN> =  51;
-
-    <LFSH> =  52;
-    <LSGT> =  53;
-    <AB01> =  54;
-    <AB02> =  55;
-    <AB03> =  56;
-    <AB04> =  57;
-    <AB05> =  58;
-    <AB06> =  59;
-    <AB07> =  60;
-    <AB08> =  61;
-    <AB09> =  62;
-    <AB10> =  63;
-    <RTSH> =  65;
-
-    <LCTL> =  66;
-    <LALT> =  68;
-    <SPCE> =  69;
-    <RALT> = 70;
-    <RCTL> = 72;
-
-    <ESC>  =  118;
-    <FK01> =  120;
-    <FK02> =  121;
-    <FK03> =  122;
-    <FK04> =  123;
-    <FK05> =  124;
-    <FK06> =  125;
-    <FK07> =  126;
-    <FK08> =  127;
-    <FK09> =  128;
-    <FK10> =  129;
-    <FK11> =  130;
-    <FK12> =  131;
-
-    <PRSC> = 132;
-    <SCLK> =  133;
-    <PAUS> = 134;
-
-    <INS>  = 83;
-    <HOME> = 88;
-    <PGUP> = 93;
-    <DELE> = 84;
-    <END>  = 89;
-    <PGDN> = 94;
-
-    <UP>   = 91;
-    <LEFT> = 87;
-    <DOWN> = 92;
-    <RGHT> = 97;
-
-    <NMLK> =  98;
-    <KPDV> =  103;
-    <KPMU> =  108;
-    <KPSU> =  113;
-
-    <KP7>  =  99;
-    <KP8>  =  104;
-    <KP9>  =  109;
-    <KPAD> =  114;
-
-    <KP4>  =  100;
-    <KP5>  =  105;
-    <KP6>  =  110;
-
-    <KP1>  =  101;
-    <KP2>  =  106;
-    <KP3>  =  111;
-    <KPEN> =  116;
-
-    <KP0>  =  107;
-    <KPDL> =  112;
-
-    indicator 1 = "Caps Lock";
-    indicator 2 = "Num Lock";
-    indicator 3 = "Scroll Lock";
-
-    alias <ALGR> = <RALT>;
-};
 
Index: xc/programs/xkbcomp/keymap/xfree86
diff -u xc/programs/xkbcomp/keymap/xfree86:3.12 xc/programs/xkbcomp/keymap/xfree86:3.17
--- xc/programs/xkbcomp/keymap/xfree86:3.12	Thu Jun 15 16:50:04 2000
+++ xc/programs/xkbcomp/keymap/xfree86	Wed Dec  6 15:18:07 2000
@@ -1,5 +1,5 @@
 // $TOG: xfree86 /main/13 1997/08/02 10:11:21 kaleb $
-// $XFree86: xc/programs/xkbcomp/keymap/xfree86,v 3.12 2000/06/15 20:50:04 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/keymap/xfree86,v 3.17 2000/12/06 20:18:07 eich Exp $
 default xkb_keymap "us" {
     xkb_keycodes	{ include "xfree86"		};
     xkb_types		{ include "default"		};
@@ -49,6 +49,13 @@
     xkb_symbols		{ include "en_US(pc105)+cs"	};
     xkb_geometry 	{ include "pc(pc102)"		};
 };
+xkb_keymap "cs_qwerty"	{
+    xkb_keycodes	{ include "xfree86"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "en_US(pc105)+cs_qwerty"	};
+    xkb_geometry 	{ include "pc(pc102)"		};
+};
 xkb_keymap "de"	{
     xkb_keycodes	{ include "xfree86"		};
     xkb_types		{ include "default"		};
@@ -98,6 +105,27 @@
     xkb_symbols		{ include "en_US(pc105)+it"	};
     xkb_geometry 	{ include "pc(pc102)"		};
 };
+xkb_keymap "lt"	{
+    xkb_keycodes	{ include "xfree86"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "en_US(pc105)+lt"	};
+    xkb_geometry 	{ include "pc(pc102)"		};
+};
+xkb_keymap "lt_std"	{
+    xkb_keycodes	{ include "xfree86"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "en_US(pc105)+lt_std"	};
+    xkb_geometry 	{ include "pc(pc102)"		};
+};
+xkb_keymap "lt_p"	{
+    xkb_keycodes	{ include "xfree86"		};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols		{ include "en_US(pc105)+lt_p"	};
+    xkb_geometry 	{ include "pc(pc102)"		};
+};
 xkb_keymap "mk" {
     xkb_keycodes        { include "xfree86"                     };
     xkb_types           { include "default"                     };
@@ -298,3 +326,42 @@
     xkb_symbols       { include "czsk(sk_us_prog)"    };
     xkb_geometry      { include "pc"                  };
 };   
+xkb_keymap "sl"        {
+    xkb_keycodes       { include "xfree86"             };
+    xkb_types          { include "default"             };
+    xkb_compatibility  { include "default"             };
+    xkb_symbols                { include "en_US(pc105)+si"     };
+    xkb_geometry       { include "pc(pc102)"           };
+};
+xkb_keymap "sl_SI"     {
+    xkb_keycodes       { include "xfree86"             };
+    xkb_types          { include "default"             };
+    xkb_compatibility  { include "default"             };
+    xkb_symbols                { include "en_US(pc105)+si"     };
+    xkb_geometry       { include "pc(pc102)"           };
+};
+
+// Additions by Cristian Gafton, <gafton@redhat.com>
+xkb_keymap "ro"        {
+    xkb_keycodes       { include "xfree86"                     };
+    xkb_types          { include "default"                     };
+    xkb_compatibility  { include "default"                     };
+    xkb_symbols                { include "en_US(pc101)+ro(pc101)"
+    };
+    xkb_geometry       { include "pc(pc101)"                   };
+};
+xkb_keymap "ro_microsoft"      {
+    xkb_keycodes       { include "xfree86"                     };
+    xkb_types          { include "default"                     };
+    xkb_compatibility  { include "default"                     };
+    xkb_symbols                { include "en_US(pc105)+ro(pc105)"
+    };
+    xkb_geometry       { include "pc(pc105)"                   };
+};
+xkb_keymap "tr"         {
+    xkb_keycodes        { include "xfree86"             };
+    xkb_types           { include "default"             };
+    xkb_compatibility   { include "default"             };
+    xkb_symbols         { include "en_US(pc105)+tr"     };
+    xkb_geometry        { include "pc(pc102)"           };
+};
Index: xc/programs/xkbcomp/keymap/sun/Imakefile
diff -u xc/programs/xkbcomp/keymap/sun/Imakefile:3.3 xc/programs/xkbcomp/keymap/sun/Imakefile:3.4
--- xc/programs/xkbcomp/keymap/sun/Imakefile:3.3	Sun Dec 20 17:19:01 1998
+++ xc/programs/xkbcomp/keymap/sun/Imakefile	Fri Oct 27 14:31:07 2000
@@ -1,7 +1,7 @@
 XCOMM $XConsortium: Imakefile /main/2 1996/08/31 12:18:50 kaleb $
-XCOMM $XFree86: xc/programs/xkbcomp/keymap/sun/Imakefile,v 3.3 1998/12/20 22:19:01 dawes Exp $
+XCOMM $XFree86: xc/programs/xkbcomp/keymap/sun/Imakefile,v 3.4 2000/10/27 18:31:07 dawes Exp $
 
-     DATAFILES = de se us 
+     DATAFILES = de es fi fr no pl ru se uk us 
 
 all::
 
Index: xc/programs/xkbcomp/keymap/sun/es
diff -u /dev/null xc/programs/xkbcomp/keymap/sun/es:1.2
--- /dev/null	Mon Dec 18 14:34:50 2000
+++ xc/programs/xkbcomp/keymap/sun/es	Fri Oct 27 20:34:05 2000
@@ -0,0 +1,58 @@
+// $TOG: de /main/3 1998/02/10 13:44:36 kaleb $
+//
+//Copyright 1996, 1998  The Open Group
+//
+//All Rights Reserved.
+//
+//The above copyright notice and this permission notice shall be
+//included in all copies or substantial portions of the Software.
+//
+//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+//IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+//OTHER DEALINGS IN THE SOFTWARE.
+//
+//Except as contained in this notice, the name of The Open Group shall
+//not be used in advertising or otherwise to promote the sale, use or
+//other dealings in this Software without prior written authorization
+//from The Open Group.
+//
+// $XFree86: xc/programs/xkbcomp/keymap/sun/es,v 1.2 2000/10/28 00:34:05 dawes Exp $
+//
+xkb_keymap "type4_es" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4)+iso9995-3(basic)+es"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+xkb_keymap "type4_es_openlook" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4ol)+iso9995-3(basic)+es"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+default xkb_keymap "type5_es" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun5)+iso9995-3(basic)+es"
+    };
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
+xkb_keymap "type5_es_openlook" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(sun5ol)+iso9995-3+es"	};
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
Index: xc/programs/xkbcomp/keymap/sun/fi
diff -u /dev/null xc/programs/xkbcomp/keymap/sun/fi:1.2
--- /dev/null	Mon Dec 18 14:34:50 2000
+++ xc/programs/xkbcomp/keymap/sun/fi	Fri Oct 27 20:34:05 2000
@@ -0,0 +1,58 @@
+// $TOG: de /main/3 1998/02/10 13:44:36 kaleb $
+//
+//Copyright 1996, 1998  The Open Group
+//
+//All Rights Reserved.
+//
+//The above copyright notice and this permission notice shall be
+//included in all copies or substantial portions of the Software.
+//
+//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+//IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+//OTHER DEALINGS IN THE SOFTWARE.
+//
+//Except as contained in this notice, the name of The Open Group shall
+//not be used in advertising or otherwise to promote the sale, use or
+//other dealings in this Software without prior written authorization
+//from The Open Group.
+//
+// $XFree86: xc/programs/xkbcomp/keymap/sun/fi,v 1.2 2000/10/28 00:34:05 dawes Exp $
+//
+xkb_keymap "type4_fi" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4)+iso9995-3(basic)+fi"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+xkb_keymap "type4_fi_openlook" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4ol)+iso9995-3(basic)+fi"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+default xkb_keymap "type5_fi" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun5)+iso9995-3(basic)+fi"
+    };
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
+xkb_keymap "type5_fi_openlook" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(sun5ol)+iso9995-3+fi"	};
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
Index: xc/programs/xkbcomp/keymap/sun/fr
diff -u /dev/null xc/programs/xkbcomp/keymap/sun/fr:1.2
--- /dev/null	Mon Dec 18 14:34:50 2000
+++ xc/programs/xkbcomp/keymap/sun/fr	Fri Oct 27 20:34:05 2000
@@ -0,0 +1,58 @@
+// $TOG: de /main/3 1998/02/10 13:44:36 kaleb $
+//
+//Copyright 1996, 1998  The Open Group
+//
+//All Rights Reserved.
+//
+//The above copyright notice and this permission notice shall be
+//included in all copies or substantial portions of the Software.
+//
+//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+//IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+//OTHER DEALINGS IN THE SOFTWARE.
+//
+//Except as contained in this notice, the name of The Open Group shall
+//not be used in advertising or otherwise to promote the sale, use or
+//other dealings in this Software without prior written authorization
+//from The Open Group.
+//
+// $XFree86: xc/programs/xkbcomp/keymap/sun/fr,v 1.2 2000/10/28 00:34:05 dawes Exp $
+//
+xkb_keymap "type4_fr" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4)+iso9995-3(basic)+fr"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+xkb_keymap "type4_fr_openlook" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4ol)+iso9995-3(basic)+fr"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+default xkb_keymap "type5_fr" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun5)+iso9995-3(basic)+fr"
+    };
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
+xkb_keymap "type5_fr_openlook" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(sun5ol)+iso9995-3+fr"	};
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
Index: xc/programs/xkbcomp/keymap/sun/no
diff -u /dev/null xc/programs/xkbcomp/keymap/sun/no:1.2
--- /dev/null	Mon Dec 18 14:34:50 2000
+++ xc/programs/xkbcomp/keymap/sun/no	Fri Oct 27 20:34:05 2000
@@ -0,0 +1,58 @@
+// $TOG: de /main/3 1998/02/10 13:44:36 kaleb $
+//
+//Copyright 1996, 1998  The Open Group
+//
+//All Rights Reserved.
+//
+//The above copyright notice and this permission notice shall be
+//included in all copies or substantial portions of the Software.
+//
+//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+//IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+//OTHER DEALINGS IN THE SOFTWARE.
+//
+//Except as contained in this notice, the name of The Open Group shall
+//not be used in advertising or otherwise to promote the sale, use or
+//other dealings in this Software without prior written authorization
+//from The Open Group.
+//
+// $XFree86: xc/programs/xkbcomp/keymap/sun/no,v 1.2 2000/10/28 00:34:05 dawes Exp $
+//
+xkb_keymap "type4_no" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4)+iso9995-3(basic)+no"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+xkb_keymap "type4_no_openlook" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4ol)+iso9995-3(basic)+no"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+default xkb_keymap "type5_no" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun5)+iso9995-3(basic)+no"
+    };
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
+xkb_keymap "type5_no_openlook" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(sun5ol)+iso9995-3+no"	};
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
Index: xc/programs/xkbcomp/keymap/sun/pl
diff -u /dev/null xc/programs/xkbcomp/keymap/sun/pl:1.2
--- /dev/null	Mon Dec 18 14:34:51 2000
+++ xc/programs/xkbcomp/keymap/sun/pl	Fri Oct 27 20:34:05 2000
@@ -0,0 +1,58 @@
+// $TOG: de /main/3 1998/02/10 13:44:36 kaleb $
+//
+//Copyright 1996, 1998  The Open Group
+//
+//All Rights Reserved.
+//
+//The above copyright notice and this permission notice shall be
+//included in all copies or substantial portions of the Software.
+//
+//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+//IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+//OTHER DEALINGS IN THE SOFTWARE.
+//
+//Except as contained in this notice, the name of The Open Group shall
+//not be used in advertising or otherwise to promote the sale, use or
+//other dealings in this Software without prior written authorization
+//from The Open Group.
+//
+// $XFree86: xc/programs/xkbcomp/keymap/sun/pl,v 1.2 2000/10/28 00:34:05 dawes Exp $
+//
+xkb_keymap "type4_pl" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4)+iso9995-3(basic)+pl"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+xkb_keymap "type4_pl_openlook" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4ol)+iso9995-3(basic)+pl"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+default xkb_keymap "type5_pl" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun5)+iso9995-3(basic)+pl"
+    };
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
+xkb_keymap "type5_pl_openlook" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(sun5ol)+iso9995-3+pl"	};
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
Index: xc/programs/xkbcomp/keymap/sun/ru
diff -u /dev/null xc/programs/xkbcomp/keymap/sun/ru:1.2
--- /dev/null	Mon Dec 18 14:34:52 2000
+++ xc/programs/xkbcomp/keymap/sun/ru	Fri Oct 27 20:34:05 2000
@@ -0,0 +1,58 @@
+// $TOG: de /main/3 1998/02/10 13:44:36 kaleb $
+//
+//Copyright 1996, 1998  The Open Group
+//
+//All Rights Reserved.
+//
+//The above copyright notice and this permission notice shall be
+//included in all copies or substantial portions of the Software.
+//
+//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+//IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+//OTHER DEALINGS IN THE SOFTWARE.
+//
+//Except as contained in this notice, the name of The Open Group shall
+//not be used in advertising or otherwise to promote the sale, use or
+//other dealings in this Software without prior written authorization
+//from The Open Group.
+//
+// $XFree86: xc/programs/xkbcomp/keymap/sun/ru,v 1.2 2000/10/28 00:34:05 dawes Exp $
+//
+xkb_keymap "type4_ru" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4)+iso9995-3(basic)+ru"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+xkb_keymap "type4_ru_openlook" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4ol)+iso9995-3(basic)+ru"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+default xkb_keymap "type5_ru" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun5)+iso9995-3(basic)+ru"
+    };
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
+xkb_keymap "type5_ru_openlook" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(sun5ol)+iso9995-3+ru"	};
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
Index: xc/programs/xkbcomp/keymap/sun/se
diff -u xc/programs/xkbcomp/keymap/sun/se:1.2 xc/programs/xkbcomp/keymap/sun/se:1.3
--- xc/programs/xkbcomp/keymap/sun/se:1.2	Sun Dec 20 04:34:42 1998
+++ xc/programs/xkbcomp/keymap/sun/se	Tue Aug  1 16:05:45 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/xkbcomp/keymap/sun/se,v 1.2 1998/12/20 09:34:42 dawes Exp $ */
+// $XFree86: xc/programs/xkbcomp/keymap/sun/se,v 1.3 2000/08/01 20:05:45 dawes Exp $
 
 default xkb_keymap "type5c_se_fixdollar" {
     xkb_keycodes	{ include "sun(type5_se)"	};
Index: xc/programs/xkbcomp/keymap/sun/uk
diff -u /dev/null xc/programs/xkbcomp/keymap/sun/uk:1.2
--- /dev/null	Mon Dec 18 14:34:53 2000
+++ xc/programs/xkbcomp/keymap/sun/uk	Fri Oct 27 20:34:05 2000
@@ -0,0 +1,58 @@
+// $TOG: de /main/3 1998/02/10 13:44:36 kaleb $
+//
+//Copyright 1996, 1998  The Open Group
+//
+//All Rights Reserved.
+//
+//The above copyright notice and this permission notice shall be
+//included in all copies or substantial portions of the Software.
+//
+//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+//IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+//OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+//ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+//OTHER DEALINGS IN THE SOFTWARE.
+//
+//Except as contained in this notice, the name of The Open Group shall
+//not be used in advertising or otherwise to promote the sale, use or
+//other dealings in this Software without prior written authorization
+//from The Open Group.
+//
+// $XFree86: xc/programs/xkbcomp/keymap/sun/uk,v 1.2 2000/10/28 00:34:05 dawes Exp $
+//
+xkb_keymap "type4_uk" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4)+iso9995-3(basic)+uk"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+xkb_keymap "type4_uk_openlook" {
+    xkb_keycodes	{ include "sun(type4_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun4ol)+iso9995-3(basic)+uk"
+    };
+    xkb_geometry	{ include "sun(type4)"		};
+};
+default xkb_keymap "type5_uk" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ 
+	include "sun/us(sun5)+iso9995-3(basic)+uk"
+    };
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
+xkb_keymap "type5_uk_openlook" {
+    xkb_keycodes	{ include "sun(type5_euro)"	};
+    xkb_types		{ include "default"		};
+    xkb_compatibility	{ include "default"		};
+    xkb_symbols 	{ include "sun/us(sun5ol)+iso9995-3+uk"	};
+    xkb_geometry	{ include "sun(type5euro)"	};
+};
Index: xc/programs/xkbcomp/rules/sgi.lst
diff -u xc/programs/xkbcomp/rules/sgi.lst:3.1 xc/programs/xkbcomp/rules/sgi.lst:3.4
--- xc/programs/xkbcomp/rules/sgi.lst:3.1	Sun Jun 22 06:17:15 1997
+++ xc/programs/xkbcomp/rules/sgi.lst	Fri Dec  8 11:45:16 2000
@@ -1,4 +1,5 @@
 // $TOG: sgi.lst /main/3 1997/06/13 06:28:54 kaleb $
+// $XFree86: xc/programs/xkbcomp/rules/sgi.lst,v 3.4 2000/12/08 16:45:16 dawes Exp $
 
 ! model
   indy			SGI O2, Indigo^2 or Indy
@@ -43,6 +44,7 @@
   se			Swedish
   th			Thai
   us			US/ASCII
+  tr			Turkish
 
 ! variant
   nodeadkeys		Eliminate dead keys from European keyboards
Index: xc/programs/xkbcomp/rules/sun.lst
diff -u xc/programs/xkbcomp/rules/sun.lst:3.1 xc/programs/xkbcomp/rules/sun.lst:3.3
--- xc/programs/xkbcomp/rules/sun.lst:3.1	Thu May 18 19:21:43 2000
+++ xc/programs/xkbcomp/rules/sun.lst	Wed Dec  6 15:18:08 2000
@@ -1,4 +1,4 @@
-// $XFree86: xc/programs/xkbcomp/rules/sun.lst,v 3.1 2000/05/18 23:21:43 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/rules/sun.lst,v 3.3 2000/12/06 20:18:08 eich Exp $
 
 ! model
   type4			Sun Type4
@@ -32,6 +32,7 @@
   se			Swedish
   th			Thai
   us			US/ASCII
+  tr			Turkish
 
 ! variant
   nodeadkeys		Eliminate dead keys from European keyboards
Index: xc/programs/xkbcomp/rules/xfree86
diff -u xc/programs/xkbcomp/rules/xfree86:3.18 xc/programs/xkbcomp/rules/xfree86:3.26
--- xc/programs/xkbcomp/rules/xfree86:3.18	Fri Jun 16 20:27:34 2000
+++ xc/programs/xkbcomp/rules/xfree86	Fri Dec  1 20:16:25 2000
@@ -4,7 +4,7 @@
 //  Rules for resolving XKB components for use with XFree86
 //  Copyright 1996 by Joseph Moss
 //
-//  $XFree86: xc/programs/xkbcomp/rules/xfree86,v 3.18 2000/06/17 00:27:34 dawes Exp $
+//  $XFree86: xc/programs/xkbcomp/rules/xfree86,v 3.26 2000/12/02 01:16:25 dawes Exp $
 //
 
 ! model 	=	keycodes	geometry
@@ -13,7 +13,6 @@
   flexpro	=	xfree86		keytronic(FlexPro)
   omnikey101	=	xfree86		northgate(omnikey101)
   pc101		=	xfree86		pc(pc101)
-  pc101_sol8x86 = 	xfree86(sol8x86) pc(pc101)
   pc102		=	xfree86		pc(pc102)
   pc104		=	xfree86		pc(pc104)
   pc105		=	xfree86		pc(pc105)
@@ -21,8 +20,15 @@
   everex	=	xfree86		everex(STEPnote)
   winbook	=	xfree86		winbook(XP5)
   pc98		=	xfree98(pc98)	nec(pc98)
-  abnt2		=	xfree86(abnt2)	pc(abnt2)
-  hp            =       xfree86         pc(pc104)
+  abnt2		=	xfree86(abnt2)	pc
+  hp		=       xfree86         pc(pc104)
+  itouch	=       xfree86         pc(pc104)
+  logicordless  =	xfree86		pc(pc104)
+  compaq	=       xfree86         pc(pc104)
+  microsoftpro	=	xfree86		microsoft(natural)
+  btc9000	=       xfree86         pc(pc104)
+  macintosh	=	macintosh	macintosh(macintosh)
+  powerpcps2	=	powerpcps2	pc(pc104)
 
 //! model		layout	=	symbols
 //  microsoft	us	=	us(pc104)
@@ -41,6 +47,8 @@
   pc104		nodeadkeys	=	en_US(pc104%_v)+%l%(v)
   pc105		nodeadkeys	=	en_US(pc105%_v)+%l%(v)
   microsoft	nodeadkeys	=	en_US(pc104%_v)+%l%(v)
+  macintosh	nodeadkeys	=	macintosh/us(extended)+macintosh/%l%(v)
+  powerpcps2	nodeadkeys	=	en_US(pc104%_v)+%l%(v)
   *		nodeadkeys	=	en_US(pc101%_v)+%l%(v)
 
 ! model		layout	=	symbols
@@ -78,9 +86,20 @@
   itouch	us	=	us(pc104)+inet(itouch)
   itouch	en_US	=	en_US(pc104)+inet(itouch)
   itouch	*	=	en_US(pc104)+inet(itouch)+%l%(v)
+  logicordless	us	=	us(pc104)+inet(logicordless)
+  logicordless	en_US	=	en_US(pc104)+inet(logicordless)
+  logicordless	*	=	en_US(pc104)+inet(logicordless)+%l%(v)
   microsoftpro	us	=	us(pc104)+inet(microsoftpro)
   microsoftpro	en_US	=	en_US(pc104)+inet(microsoftpro)
   microsoftpro	*	=	en_US(pc104)+inet(microsoftpro)+%l%(v)
+  btc9000	us	=	us(pc104)+inet(btc9000)
+  btc9000	en_US	=	en_US(pc104)+inet(btc9000)
+  btc9000	*	=	en_US(pc104)+inet(btc9000)+%l%(v)
+  macintosh	us	=	macintosh/us(extended)
+  macintosh	*	=	macintosh/us(extended)+macintosh/%l%(v)
+  powerpcps2	us	=	us(pc104)
+  powerpcps2	en_US	=	en_US(pc104)
+  powerpcps2	*	=	en_US(pc104)+%l%(v)
   *		us	=	us(pc101)
   *		en_US	=	en_US(pc101)
   *		intl	=	us(pc101compose)
@@ -98,8 +117,15 @@
   grp:ctrl_shift_toggle	=	+group(ctrl_shift_toggle)
   grp:caps_toggle	=	+group(caps_toggle)
   grp:ctrl_alt_toggle	=	+group(ctrl_alt_toggle)
+  grp:alt_shift_toggle	=	+group(alt_shift_toggle)
+  grp:menu_toggle	=	+group(menu_toggle)
   ctrl:nocaps		=	+ctrl(nocaps)
   ctrl:swapcaps		=	+ctrl(swapcaps)
   ctrl:ctrl_ac		=	+ctrl(ctrl_ac)
   ctrl:ctrl_aa		=	+ctrl(ctrl_aa)
+
+! option		=	compat
+  grp_led:num		=	+leds(num)
+  grp_led:caps		=	+leds(caps)
+  grp_led:scroll	=	+leds(scroll)
 
Index: xc/programs/xkbcomp/rules/xfree86.lst
diff -u xc/programs/xkbcomp/rules/xfree86.lst:3.9 xc/programs/xkbcomp/rules/xfree86.lst:3.20
--- xc/programs/xkbcomp/rules/xfree86.lst:3.9	Tue Apr  4 15:25:29 2000
+++ xc/programs/xkbcomp/rules/xfree86.lst	Wed Dec  6 15:18:08 2000
@@ -4,7 +4,7 @@
 //  Rules descriptions for XFree86
 //  Copyright 1996 by Joseph Moss
 //
-//  $XFree86: xc/programs/xkbcomp/rules/xfree86.lst,v 3.9 2000/04/04 19:25:29 dawes Exp $
+//  $XFree86: xc/programs/xkbcomp/rules/xfree86.lst,v 3.20 2000/12/06 20:18:08 eich Exp $
 
 ! model
   pc101		Generic 101-key PC
@@ -20,35 +20,55 @@
   jp106		Japanese 106-key
   pc98		PC-98xx Series
   abnt2		Brazilian ABNT2
+  hp		HP Internet
+  itouch	Logitech iTouch
+  logicordless	Logitech Cordless Desktop Pro
+  compaq	Compaq Internet
+  microsoftpro	Microsoft Natural Pro
 
 ! layout
   us		U.S. English
   en_US		U.S. English w/ISO9995-3
+  us_intl	U.S. English w/ deadkeys
+  am		Armenian
+  az		Azerbaidjani
   be		Belgian
   br		Brazilian
   bg		Bulgarian
   ca		Canadian
   cs		Czechoslovakian
-  de		German
-  de_CH		Swiss German
   dk		Danish
-  es		Spanish
+  ee		Estonian
   fi		Finnish
   fr		French
   fr_CH		Swiss French
-  gb		United Kingdom
+  de		German
+  de_CH		Swiss German
+  gr		Greek
   hu		Hungarian
+  is		Icelandic
+  il		Israeli
   it		Italian
   jp		Japanese
-  lt		Lithuanian
+  lt		Lithuanian querty "numeric"
+  lt_std	Lithuanian azerty standard
+  lt_p		Lithuanian querty "programmer's"
+  mk		Macedonian
   no		Norwegian
   pl		Polish
-  pt		Portugese
+  pt		Portuguese
+  ro		Romanian
   ru		Russian
+  sr		Serbian
+  si		Slovenian
+  es		Spanish
   se		Swedish
   th		Thai
+  uk		Ukrainian 
+  gb		United Kingdom
+  vn		Vietnamese
   nec/jp	PC-98xx Series
-  us_intl	U.S. English w/ deadkeys
+  tr		Turkish 
 
 ! variant
   nodeadkeys	Eliminate dead keys
@@ -57,12 +77,19 @@
   grp			Group Shift/Lock behavior
   grp:switch		R-Alt switches group while pressed
   grp:toggle		Right Alt key changes group
+  grp:caps_toggle	Caps Lock key changes group
+  grp:menu_toggle	Menu key changes group
   grp:shift_toggle 	Both Shift keys together change group
   grp:ctrl_shift_toggle Control+Shift changes group
   grp:ctrl_alt_toggle	Alt+Control changes group
+  grp:alt_shift_toggle	Alt+Shift changes group
   ctrl			Control Key Position
   ctrl:nocaps		Make CapsLock an additional Control
   ctrl:swapcaps		Swap Control and Caps Lock
   ctrl:ctrl_ac		Control key at left of 'A'
   ctrl:ctrl_aa		Control key at bottom left
+  grp_led		Use keyboard LED to show alternative group
+  grp_led:num		Num_Lock LED shows alternative group
+  grp_led:caps		Caps_Lock LED shows alternative group
+  grp_led:scroll	Scroll_Lock LED shows alternative group
 
Index: xc/programs/xkbcomp/symbols/Imakefile
diff -u xc/programs/xkbcomp/symbols/Imakefile:3.22 xc/programs/xkbcomp/symbols/Imakefile:3.32
--- xc/programs/xkbcomp/symbols/Imakefile:3.22	Wed Feb  9 17:00:07 2000
+++ xc/programs/xkbcomp/symbols/Imakefile	Thu Dec  7 04:04:19 2000
@@ -1,13 +1,14 @@
 XCOMM $TOG: Imakefile /main/16 1997/10/24 14:30:46 kaleb $
-XCOMM $XFree86: xc/programs/xkbcomp/symbols/Imakefile,v 3.22 2000/02/09 22:00:07 dawes Exp $
+XCOMM $XFree86: xc/programs/xkbcomp/symbols/Imakefile,v 3.32 2000/12/07 09:04:19 alanh Exp $
 #define IHaveSubdirs
 
       TESTDATA = 
-     DATAFILES = be bg br ca ca_enhanced cs czsk ctrl de de_CH dk dvorak \
-		 ee en_US es fi fr fr_CH \
-		 gb group hu iso9995-3 inet is it jp keypad lock no pc104 \
+     DATAFILES = am az be bg br ca ca_enhanced cs cs_qwerty czsk ctrl \
+		 de de_CH dk dvorak ee en_US es fi fr fr_CH \
+		 gb gr group hu hu_US il il_phonetic iso9995-3 inet is it jp \
+		 keypad lock lt lt_std lt_p mk no pc104 \
 		 pl pt \
-		 ralt ru se si th ua us us_intl us_group3
+		 ralt ro ru se si sr th ua us us_intl us_group3 vn tr
        SUBDIRS = digital fujitsu hp macintosh nec sgi sony sun xfree68
 
 MakeXkbDir($(LIBDIR)/xkb,symbols)
Index: xc/programs/xkbcomp/symbols/am
diff -u /dev/null xc/programs/xkbcomp/symbols/am:1.2
--- /dev/null	Mon Dec 18 14:34:59 2000
+++ xc/programs/xkbcomp/symbols/am	Fri Oct 27 20:34:06 2000
@@ -0,0 +1,125 @@
+// $XConsortium: am /main/3 1997/12/18 12:40:12 rch $
+//
+// $XFree86: xc/programs/xkbcomp/symbols/am,v 1.2 2000/10/28 00:34:06 dawes Exp $
+
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Armenian keyboard
+
+    name[Group1]= "US/ASCII";
+    name[Group2]= "Armenian";
+
+    // Alphanumeric section
+    key <TLDE> {	[    grave,	asciitilde	],
+			[ Armenian_but, Armenian_exclam	]	};
+    key	<LSGT> {	[ Armenian_eternity,   greater	],
+			[  question,  Armenian_hyphen	]	};
+    key <BKSL> {        [ backslash,		bar	],
+                        [ Armenian_guillemotright, Armenian_guillemotleft ] };
+
+    key <AE01> {	[	  1,	exclam		],
+			[ Armenian_fe,  Armenian_FE	]	};
+    key <AE02> {	[	  2,	at		],
+			[ Armenian_dza, Armenian_DZA	]	};
+    key <AE03> {	[	  3,	numbersign	],
+			[ Armenian_en_dash, Armenian_em_dash ]	};
+    key <AE04> {	[	  4,	dollar		],
+			[ Armenian_comma, dollar	]	};
+    key <AE05> {	[         5,	percent		],
+    			[ Armenian_verjaket, Armenian_ellipsis	] };
+    key <AE06> {	[	  6,	asciicircum	],
+			[ Armenian_question, percent	]	};
+    key <AE07> {	[	  7,	ampersand	],
+			[ Armenian_mijaket, Armenian_ligature_ew ] };
+    key <AE08> {	[	  8,	asterisk	],
+			[ Armenian_shesht, Armenian_apostroph ] };
+    key <AE09> {	[	  9,	parenleft	],
+			[ Armenian_parenright, Armenian_parenleft ] };
+    key <AE10> {	[	  0,	parenright	],
+			[ Armenian_o,	Armenian_O	]	};
+    key <AE11> {	[     minus,	underscore	],
+			[ Armenian_e,	Armenian_E	]	};
+    key <AE12> {	[     equal,	plus      	],
+			[ Armenian_ghat, Armenian_GHAT	]	};
+
+
+    key <AD01> {        [         q,    Q               ],
+			[ Armenian_tche, Armenian_TCHE	]       };
+    key <AD02> {        [         w,    W               ],
+			[ Armenian_pyur, Armenian_PYUR	]	};
+    key <AD03> {        [         e,    E               ],
+			[ Armenian_ben, Armenian_BEN	]       };
+    key <AD04> {        [         r,    R               ],
+			[ Armenian_se,  Armenian_SE	]	};
+    key <AD05> {        [         t,    T               ],
+			[ Armenian_men, Armenian_MEN	]       };
+    key <AD06> {        [         y,    Y               ],
+			[ Armenian_vo,	Armenian_VO	]       };
+    key <AD07> {        [         u,    U               ],
+			[ Armenian_vyun, Armenian_VYUN	]       };
+    key <AD08> {        [         i,    I               ],
+			[ Armenian_ken, Armenian_KEN	]       };
+    key <AD09> {        [         o,    O               ],
+			[ Armenian_at,	Armenian_AT	]       };
+    key <AD10> {        [         p,    P               ],
+			[ Armenian_to,	Armenian_TO	]       };
+    key <AD11> {        [ bracketleft,  braceleft       ],
+			[ Armenian_tsa, Armenian_TSA	]       };
+    key <AD12> {        [ bracketright, braceright      ],
+			[ Armenian_tso,	Armenian_TSO	]       };
+
+    key <AC01> {        [         a,    A               ],
+			[ Armenian_je,  Armenian_JE	]       };
+    key <AC02> {        [         s,    S               ],
+			[ Armenian_vev, Armenian_VEV	]	};
+    key <AC03> {        [         d,    D               ],
+			[ Armenian_gim, Armenian_GIM	]       };
+    key <AC04> {        [         f,    F               ],
+			[ Armenian_yech, Armenian_YECH	]       };
+    key <AC05> {        [         g,    G               ],
+			[ Armenian_ayb, Armenian_AYB	]       };
+    key <AC06> {        [         h,    H               ],
+			[ Armenian_nu,	Armenian_NU	]	};
+    key <AC07> {        [         j,    J               ],
+			[ Armenian_ini, Armenian_INI	]       };
+    key <AC08> {        [         k,    K               ],
+			[ Armenian_tyun, Armenian_TYUN	]       };
+    key <AC09> {        [         l,    L               ],
+			[ Armenian_ho,  Armenian_HO	]       };
+    key <AC10> {        [ semicolon,    colon           ],
+			[ Armenian_pe,  Armenian_PE	]       };
+    key <AC11> {        [ apostrophe,   quotedbl        ], 
+			[ Armenian_re,  Armenian_RE	]       };
+
+    key <AB01> {        [         z,    Z               ],
+			[ Armenian_zhe, Armenian_ZHE	]       };
+    key <AB02> {        [         x,    X               ],
+			[ Armenian_da,  Armenian_DA	]       };
+    key <AB03> {        [         c,    C               ],
+			[ Armenian_cha, Armenian_CHA	]       };
+    key <AB04> {        [         v,    V               ],
+			[ Armenian_hi,  Armenian_HI	]       };
+    key <AB05> {        [         b,    B               ],
+			[ Armenian_za,  Armenian_ZA	]       };
+    key <AB06> {        [         n,    N               ],
+			[ Armenian_lyun, Armenian_LYUN	]       };
+    key <AB07> {        [         m,    M               ],
+			[ Armenian_ke,  Armenian_KE	]       };
+    key <AB08> {        [     comma,    less            ],
+			[ Armenian_khe, Armenian_KHE	]       };
+    key <AB09> {        [    period,    greater         ],
+			[ Armenian_sha, Armenian_SHA	]       };
+    key <AB10> {        [     slash,    question        ],
+			[ Armenian_ra,  Armenian_RA	]       };
+    
+    // Begin modifier mappings 
+
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock, ISO_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+
Index: xc/programs/xkbcomp/symbols/az
diff -u /dev/null xc/programs/xkbcomp/symbols/az:1.1
--- /dev/null	Mon Dec 18 14:35:00 2000
+++ xc/programs/xkbcomp/symbols/az	Fri Oct 27 14:31:08 2000
@@ -0,0 +1,202 @@
+// $TOG: us /main/12 1997/06/14 06:37:07 kaleb $
+
+// symbols definition for a very simple Azerbaidjani keyboard layout.
+
+// $XFree86: xc/programs/xkbcomp/symbols/az,v 1.1 2000/10/27 18:31:08 dawes Exp $
+
+partial hidden alphanumeric_keys modifier_keys 
+xkb_symbols "basic" {
+
+    name[Group1]= "Azeri";
+
+    // Alphanumeric section
+    key <TLDE> {	[    grave,	asciitilde	],
+			[ dead_grave,	dead_tilde	]	};
+
+    key <AE02> {	[	  2,	quotedbl	],
+			[        at			]	};
+    key <AE03> {	[	  3,	apostrophe	],
+			[     slash			]	};
+    key <AE04> {	[	  4,	semicolon	],
+			[    dollar			]	};
+    key <AE05> {	[	  5,	percent		],
+			[  sterling			]	};
+    key <AE06> {	[	  6,	colon		],
+			[  EuroSign,	periodcentered	]	};
+    key <AE07> {	[	  7,	question	],
+			[ ampersand			]	};
+    key <AE08> {	[	  8,	asterisk	],
+			[ asciicircum,	dead_circumflex	]	};
+    key <AE09> {	[	  9,	parenleft	],
+			[ numbersign			]	};
+    key <AE10> {	[	  0,	parenright	],
+			[   section			]	};
+    key <AE11> {	[     minus,	underscore	],
+			[    hyphen			]	};
+
+    key <AD02> {	[ udiaeresis,	Udiaeresis	],
+			[	  w,	W		]	};
+    key <AD03> {	[	  e,	E		],
+			[	  e,	E		]	};
+    key <AD04> {	[	  r,	R		],
+			[ registered			]	};
+    key <AD05> {	[	  t,	T		],
+			[ brokenbar,	brokenbar	]	};
+    key <AD08> {	[	  i,	Iabovedot	]	};
+    key <AD11> {	[ odiaeresis,	Odiaeresis	],
+			[ bracketleft,	braceleft	]	};
+    key <AD12> {	[    gbreve,	Gbreve		],
+			[ bracketright,	braceright	]	};
+
+    key <AC10> {	[  idotless,	I		],
+			[ semicolon,	colon		]	};
+    key <AC11> {	[     schwa,	SCHWA		],
+			[ apostrophe,	quotedbl	]	};
+
+    key <AB03> {	[	  c,	C		],
+			[ copyright,	division	]	};
+    key <AB07> {	[	  m,	M		],
+			[ periodcentered, currency	]	};
+    key <AB08> {	[  ccedilla,	Ccedilla	],
+			[     comma,	less		]	};
+    key <AB09> {	[  scedilla,	Scedilla	],
+			[    period,	greater		]	};
+    key <AB10> {	[    period,	comma		]	};
+
+    key <BKSL> {	[    gcaron,	Gcaron		],
+			[ backslash,	bar		]	};
+    key <LSGT> {	[      less,    greater		],
+			[ backslash,	slash		]	};
+
+    // End alphanumeric section
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock };
+    modifier_map Control{ Control_L };
+};
+
+partial alphanumeric_keys
+xkb_symbols "latin" {
+    include "az(basic)"
+};
+
+partial alphanumeric_keys
+xkb_symbols "cyrillic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Azerbaidjani cyrillic keybaord
+
+    name[Group1]= "Cyrillic";
+    name[Group2]= "Latin";
+
+    key <TLDE> {	[    grave,	asciitilde	],
+			[        w,	W		]	};
+
+    key <AE02> {	[	  2,	at		],
+			[         2,	quotedbl	]	};
+    key <AE03> {	[	  3,	numbersign	],
+			[	  3,    apostrophe	]	};
+    key <AE04> {	[	  4,	semicolon	],
+			[         4,	dollar		]	};
+    key <AE05> {	[	  5,	percent		],
+			[  	  5,    percent		]	};
+    key <AE06> {	[	  6,	colon		],
+			[         6,	asciicircum	]	};
+    key <AE07> {	[	  7,	question	],
+			[	  7,	ampersand	]	};
+    key <AE08> {	[	  8,	asterisk	],
+			[	  8,	braceleft	]	};
+    key <AE09> {	[	  9,	parenleft	],
+			[	  9,	bracketleft	]	};
+    key <AE10> {	[	  0,	parenright	],
+			[	  0,	bracketright	]	};
+    key <AE11> {	[     minus,	underscore	],
+			[     minus,	braceright	]	};
+
+    key	<AD01> {	[     Cyrillic_je,     Cyrillic_JE	],
+			[               y,               Y	]	};
+    key	<AD02> {	[ Cyrillic_u_straight, Cyrillic_U_straight ],
+			[      udiaeresis,      Udiaeresis	]	};
+    key	<AD03> {	[      Cyrillic_u,	Cyrillic_U	],
+			[               u,	         U	]	};
+    key	<AD04> {	[     Cyrillic_ka,     Cyrillic_KA	],
+			[               k,               K	]	};
+    key	<AD05> {	[     Cyrillic_ie,     Cyrillic_IE      ],
+			[               e,               E	]	};
+    key	<AD06> {	[     Cyrillic_en,     Cyrillic_EN      ],
+			[               n,               N	]	};
+    key	<AD07> {	[    Cyrillic_ghe,    Cyrillic_GHE      ],
+			[               q,               Q	]	};
+    key	<AD08> {	[    Cyrillic_sha,    Cyrillic_SHA      ],
+			[        scedilla,        Scedilla	]	};
+    key	<AD09> {	[   Cyrillic_shha,   Cyrillic_SHHA      ],
+			[               h,               H	]	};
+    key	<AD10> {	[     Cyrillic_ze,     Cyrillic_ZE      ],
+			[               z,               Z	]	};
+    key	<AD11> {	[     Cyrillic_ha,     Cyrillic_HA      ],
+			[               x,               X	]	};
+    key	<AD12> {	[ Cyrillic_che_vertstroke, Cyrillic_CHE_vertstroke ],
+			[               c,               C	]	};
+
+    key	<AC01> {	[     Cyrillic_ef,     Cyrillic_EF      ],
+			[               f,               F	]	};
+    key	<AC02> {	[   Cyrillic_yeru,   Cyrillic_YERU	],
+			[        idotless,               I	]	};
+    key	<AC03> {	[     Cyrillic_ve,     Cyrillic_VE      ],
+			[               v,               V	]	};
+    key	<AC04> {	[      Cyrillic_a,      Cyrillic_A      ],
+			[               a,	         A	]	};
+    key	<AC05> {	[     Cyrillic_pe,     Cyrillic_PE      ],
+			[               p,               P	]	};
+    key	<AC06> {	[     Cyrillic_er,     Cyrillic_ER      ],
+			[               r,               R	]	};
+    key	<AC07> {	[      Cyrillic_o,      Cyrillic_O      ],
+			[               o,	         O	]	};
+    key	<AC08> {	[     Cyrillic_el,     Cyrillic_EL      ],
+			[               l,               L	]	};
+    key	<AC09> {	[     Cyrillic_de,     Cyrillic_DE      ],
+			[               d,               D	]	};
+    key	<AC10> {	[    Cyrillic_zhe,    Cyrillic_ZHE      ],
+			[               j,               J	]	};
+    key	<AC11> {	[ Cyrillic_ka_vertstroke, Cyrillic_KA_vertstroke ],
+			[               g,	         G	]	};
+
+    key	<AB01> {	[  Cyrillic_schwa,  Cyrillic_SCHWA	],
+			[           schwa,           SCHWA	]	};
+    key	<AB02> {	[    Cyrillic_che,    Cyrillic_CHE      ],
+			[        ccedilla,        Ccedilla	]	};
+    key	<AB03> {	[     Cyrillic_es,     Cyrillic_ES      ],
+			[               s,               S	]	};
+    key	<AB04> {	[     Cyrillic_em,     Cyrillic_EM      ],
+			[               m,               M	]	};
+    key	<AB05> {	[      Cyrillic_i,      Cyrillic_I      ],
+			[               i,	 Iabovedot	]	};
+    key	<AB06> {	[     Cyrillic_te,     Cyrillic_TE      ],
+			[               t,               T	]	};
+    key	<AB07> {	[ Cyrillic_ghe_bar, Cyrillic_GHE_bar	],
+			[          gbreve,          Gbreve	]	};
+    key	<AB08> {	[     Cyrillic_be,     Cyrillic_BE      ],
+			[               b,               B	]	};
+    key	<AB09> {	[  Cyrillic_o_bar,  Cyrillic_O_bar	],
+			[      odiaeresis,      Odiaeresis	]	};
+    key	<AB10> {	[	    slash,	  question	],
+			[	   period,	     comma	]	};
+
+
+    key <BKSL> {	[ backslash,	bar		],
+			[ apostrophe			]	};
+    key <LSGT> {	[      less,    greater		],
+			[       bar,	brokenbar	]	};
+
+    // End alphanumeric section
+    
+    // Begin modifier mappings 
+
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock, ISO_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+
Index: xc/programs/xkbcomp/symbols/be
diff -u xc/programs/xkbcomp/symbols/be:3.3 xc/programs/xkbcomp/symbols/be:3.4
--- xc/programs/xkbcomp/symbols/be:3.3	Mon Dec 23 02:13:11 1996
+++ xc/programs/xkbcomp/symbols/be	Fri Oct 27 14:31:08 2000
@@ -1,10 +1,10 @@
 // $XConsortium: be /main/3 1996/08/31 12:19:05 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/be,v 3.3 1996/12/23 07:13:11 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/be,v 3.4 2000/10/27 18:31:08 dawes Exp $
 partial default alphanumeric_keys 
 xkb_symbols "basic" {
 
     // Describes the differences between a very simple US/ASCII
-    // keyboard and a very simple Belgian keybaord
+    // keyboard and a very simple Belgian keyboard
 
     name[Group1]= "Belgian";
 
@@ -29,24 +29,27 @@
     key <AE12> {	[           minus,      underscore 	]	};
     key <AD01> {	[               a,               A 	]	};
     key <AD02> {	[               z,               Z 	]	};
-    key <AD11> {	[ dead_circumflex,       diaeresis 	],
+    key <AD03> {        [               e,               E      ],
+                        [        EuroSign,            cent      ]	};
+    key <AD11> {	[ dead_circumflex,  dead_diaeresis 	],
 			[     bracketleft			]	};
     key <AD12> {	[          dollar,        asterisk	],
 			[    bracketright			]	};
     key <AC01> {	[               q,               Q 	]	};
     key <AC10> {	[               m,               M	]	};
     key <AC11> {	[          ugrave,         percent 	],
-			[      quoteright 			]	};
+			[      dead_acute 			]	};
     key <BKSL> {	[              mu,        sterling 	],
-			[       quoteleft			]	};
+			[      dead_grave			]	};
     key <LSGT> {	[            less,         greater	],
 			[       backslash			]	};
     key <AB01> {	[               w,               W 	]	};
-    key <AB07> {	[           comma,        question 	]	};
+    key <AB07> {	[           comma,        question 	],
+			[    dead_cedilla			]	};
     key <AB08> {	[       semicolon,          period 	]	};
     key <AB09> {	[           colon,           slash 	]	};
     key <AB10> {	[           equal,            plus	],
-			[      asciitilde			]	};
+			[      dead_tilde			]	};
     // End alphanumeric section
 
     // begin modifier mappings
@@ -70,7 +73,7 @@
     replace key <AB01> {[               w,               W 	],
 			[         lstroke,         Lstroke      ]	};
     replace key <AB07> {[           comma,        question 	],
-			[      dead_acute, dead_doubleacute	]	};
+			[    dead_cedilla, dead_doubleacute	]	};
 };
 
 partial alphanumeric_keys 
@@ -78,8 +81,16 @@
 
     // Use the Sun dead keys
     include "be(basic)"
-    key <AD11> {	[    SunFA_Circum,       diaeresis 	],
+    key <AD11> {	[    SunFA_Circum,  SunFA_Diaeresis 	],
 			[     bracketleft			]	};
+    key <AC11> {        [          ugrave,         percent      ],
+                        [     SunFA_Acute                       ]       };
+    key <BKSL> {        [              mu,        sterling      ],
+                        [     SunFA_Grave                       ]       };
+    key <AB07> {        [           comma,        question      ],
+                        [   SunFA_Cedilla                       ]       };
+    key <AB10> {        [           equal,            plus      ],
+                        [     SunFA_Tilde                       ]       };
 };
 
 partial alphanumeric_keys 
@@ -96,4 +107,10 @@
     include "be(basic)"
     key <AD11> {	[ 	asciicircum,       diaeresis 	],
 			[     bracketleft			]	};
+    key <AC11> {        [          ugrave,         percent      ],
+                        [      quoteright                       ]       };
+    key <BKSL> {        [              mu,        sterling      ],
+                        [       quoteleft                       ]       };
+    key <AB10> {        [           equal,            plus      ],
+                        [      asciitilde                       ]       };
 };
Index: xc/programs/xkbcomp/symbols/bg
diff -u xc/programs/xkbcomp/symbols/bg:3.1 xc/programs/xkbcomp/symbols/bg:3.2
--- xc/programs/xkbcomp/symbols/bg:3.1	Mon Dec 23 02:13:12 1996
+++ xc/programs/xkbcomp/symbols/bg	Mon Nov  6 14:24:10 2000
@@ -1,119 +1,513 @@
-// $XConsortium: bg /main/3 1996/08/31 12:19:08 kaleb $
-partial default alphanumeric_keys 
-xkb_symbols "typewriter" {
-
-    // Describes the differences between a very simple US/ASCII
-    // keyboard and a very simple Bulgarian keybaord
-
-    name[Group1]= "Bulgarian";
-
-    key <TLDE> {	[           grave,      asciitilde	],
-			[       parenleft,        NoSymbol	]	};
-    key <LSGT> {	[            less,         greater	],
-			[             bar		    	]	};
-    key <AD01> { [ ],	[   Cyrillic_yeru,        NoSymbol	] 	};
-    key <AB01> {	[               z,               Z 	],
-			[     Cyrillic_yu,        NoSymbol 	]	};
-    key <AC02> {	[               s,               S 	],
-			[     Cyrillic_ya,        NoSymbol 	]	};
-    key <AC01> {	[               a,               A 	],
-			[ Cyrillic_softsign,        NoSymbol 	]	};
-    key <AD02> {	[               w,               W 	],
-			[      Cyrillic_u,        NoSymbol	]	};
-    key <AE02> {	[               2,              at	],
-			[               2,        NoSymbol	]	};
-    key <AB03> {	[               c,               C	],
-			[ Cyrillic_hardsign,      NoSymbol	]	};
-    key <AB02> {	[               x,               X	],
-			[ Cyrillic_shorti,        NoSymbol	]	};
-    key <AC03> {	[               d,               D	],
-			[      Cyrillic_a,        NoSymbol	]	};
-    key <AD03> {	[               e,               E	],
-			[     Cyrillic_ie,        NoSymbol	]	};
-    key <AE04> {	[               4,          dollar	],
-			[               4,        NoSymbol	]	};
-    key <AE03> {	[               3,      numbersign	],
-			[               3,        NoSymbol	]	};
-    key <SPCE> {	 type= "CTRL+ALT",
-			[           space,  ISO_Next_Group	]	};
-    key <AB04> {	[               v,               V	],
-			[      Cyrillic_e,        NoSymbol	]	};
-    key <AC04> {	[               f,               F	],
-			[      Cyrillic_o,        NoSymbol	]	};
-    key <AD05> {	[               t,               T	],
-			[    Cyrillic_sha,        NoSymbol	]	};
-    key <AD04> {	[               r,               R	],
-			[      Cyrillic_i,        NoSymbol	]	};
-    key <AB06> {	[               n,               N	],
-			[     Cyrillic_ha,        NoSymbol	]	};
-    key <AB05> {	[               b,               B	],
-			[     Cyrillic_ef,        NoSymbol	]	};
-    key <AC06> {	[               h,               H	],
-			[    Cyrillic_ghe,        NoSymbol	]	};
-    key <AC05> {	[               g,               G	],
-			[    Cyrillic_zhe,        NoSymbol	]	};
-    key <AD06> {	[               y,               Y	],
-			[  Cyrillic_shcha,        NoSymbol	]	};
-    key <RALT> {        [     Mode_switch,       Multi_key	]	};
-    key <AB07> {	[               m,               M	],
-			[     Cyrillic_pe,        NoSymbol	]	};
-    key <AC07> {	[               j,               J	],
-			[     Cyrillic_te,        NoSymbol	]	};
-    key <AD07> {	[               u,               U	],
-			[     Cyrillic_ka,        NoSymbol	]	};
-    key <AB08> {	[           comma,            less	],
-			[     Cyrillic_er,        NoSymbol	]	};
-    key <AC08> {	[               k,               K	],
-			[     Cyrillic_en,        NoSymbol	]	};
-    key <AD08> {	[               i,               I	],
-			[     Cyrillic_es,        NoSymbol	]	};
-    key <AD09> {	[               o,               O	],
-			[     Cyrillic_de,        NoSymbol	]	};
-    key <AB09> {	[          period,         greater	],
-			[     Cyrillic_el,        NoSymbol	]	};
-    key <AB10> {	[           slash,        question	],
-			[     Cyrillic_be,        NoSymbol	]	};
-    key <AC09> {	[               l,               L	],
-			[     Cyrillic_ve,        NoSymbol	]	};
-    key <AC10> {	[       semicolon,           colon	],
-			[     Cyrillic_em,        NoSymbol	]	};
-    key <AD10> {	[               p,               P	],
-			[     Cyrillic_ze,        NoSymbol	]	};
-    key <AE11> {	[           minus,      underscore	],
-			[           minus,        NoSymbol	]	};
-    key <AC11> {	[      apostrophe,        quotedbl	],
-			[    Cyrillic_che,        NoSymbol	]	};
-    key     <> {	[       backslash,             bar	],
-			[   Cyrillic_yeru,        NoSymbol	]	};
-    key <AD11> {	[     bracketleft,       braceleft	],
-			[    Cyrillic_tse,        NoSymbol	]	};
-    key <AE12> {	[           equal,            plus	],
-			[          period,        NoSymbol	]	};
-    key <AD12> {	[    bracketright,      braceright	],
-			[       semicolon,        NoSymbol	]	};
-    key <BKSL> {	[       backslash,             bar	],
-			[   Cyrillic_yeru,        NoSymbol	]	};
-    // End alphanumeric section
-
-    // begin modifier mappings
-    modifier_map Shift  { Shift_L };
-    modifier_map Lock   { Caps_Lock };
-    modifier_map Control{ Control_L };
-    modifier_map Mod3	{ Mode_switch };
+//////////////////////////////////////////////////////////////////////////
+// Copyright (C) 1999, 2000 by Anton Zinoviev <anton@lml.bas.bg>
+//
+// This software may be used, modified, copied, distributed, and sold,
+// in both source and binary form provided that the above copyright
+// and these terms are retained. Under no circumstances is the author
+// responsible for the proper functioning of this software, nor does
+// the author assume any responsibility for damages incurred with its
+// use.
+//
+////////////////////////////////////////////////////////////////////////// 
+
+// $XFree86: xc/programs/xkbcomp/symbols/bg,v 3.2 2000/11/06 19:24:10 dawes Exp $
+
+// Version 1.6r1
+
+// Thanks to Ivan Pascal <pascal@tsu.ru> for improvements in this file.
+
+partial alphanumeric_keys
+xkb_symbols "bds_enhanced" {
+
+  // Describes the differences between a very simple en_US keyboard
+  // and a very simple Bulgarian keyboard with publishing symbols in
+  // the third level.
+
+  name[Group1]= "Latin";
+  name[Group2]= "Cyrillic";
+
+  key.type = "THREE_LEVEL";
+
+  key <TLDE> {[ quoteleft,         asciitilde,        degree               ],
+              [ parenleft,         parenright,        degree               ]};
+  key <AE01> {[ 1,                 exclam,            multiply             ],
+              [ 1,                 exclam,            multiply             ]};
+  key <AE02> {[ 2,                 at,                division             ],
+              [ 2,                 question,          division             ]};
+  key <AE03> {[ 3,                 numbersign,        plusminus            ],
+              [ 3,                 plus,              plusminus            ]};
+  key <AE04> {[ 4,                 dollar,            notsign              ],
+              [ 4,                 quotedbl,          notsign              ]};
+  // I want here per mille sign, but it is not defined X keysym.
+  key <AE05> {[ 5,                 percent,           NoSymbol             ],
+              [ 5,                 percent,           NoSymbol             ]};
+  key <AE06> {[ 6,                 asciicircum,       notequal             ],
+              [ 6,                 equal,             notequal             ]};
+  key <AE07> {[ 7,                 ampersand,         ampersand            ],
+              [ 7,                 colon,             ampersand            ]};
+  key <AE08> {[ 8,                 asterisk,          asterisk             ],
+              [ 8,                 slash,             asterisk             ]};
+  key <AE09> {[ 9,                 parenleft,         bracketleft          ],
+              [ 9,                 emdash,            bracketleft          ]};
+  key <AE10> {[ 0,                 parenright,        bracketright         ],
+              [ 0,                 numerosign,        bracketright         ]};
+  key <AE11> {[ minus,             underscore,        X                    ],
+              [ minus,             I,                 X                    ]};
+  key <AE12> {[ equal,             plus,              L                    ],
+              [ period,            V,                 L                    ]};
+
+  key <AD01> {[ q,                 Q,                 apostrophe           ],
+              [ comma,             Cyrillic_yeru,     apostrophe           ]};
+  key <AD02> {[ w,                 W,                 grave                ],
+              [ Cyrillic_u,        Cyrillic_U,        grave                ]};
+  key <AD03> {[ e,                 E,                 EuroSign             ],
+              [ Cyrillic_ie,       Cyrillic_IE,       EuroSign             ]};
+  key <AD04> {[ r,                 R,                 registered           ],
+              [ Cyrillic_i,        Cyrillic_I,        registered           ]};
+  key <AD05> {[ t,                 T,                 trademark            ],
+              [ Cyrillic_sha,      Cyrillic_SHA,      trademark            ]};
+  key <AD06> {[ y,                 Y,                 yen                  ],
+              [ Cyrillic_shcha,    Cyrillic_SHCHA,    yen                  ]};
+  key <AD07> {[ u,                 U,                 doublelowquotemark   ],
+              [ Cyrillic_ka,       Cyrillic_KA,       doublelowquotemark   ]};
+  key <AD08> {[ i,                 I,                 leftdoublequotemark  ],
+              [ Cyrillic_es,       Cyrillic_ES,       leftdoublequotemark  ]};
+  key <AD09> {[ o,                 O,                 rightdoublequotemark ],
+              [ Cyrillic_de,       Cyrillic_DE,       rightdoublequotemark ]};
+  // I want here `P' in a circle, but it is not defined X keysym.
+  key <AD10> {[ p,                 P,                 NoSymbol             ],
+              [ Cyrillic_ze,       Cyrillic_ZE,       NoSymbol             ]};
+  key <AD11> {[ bracketleft,       braceleft,         braceleft            ],
+              [ Cyrillic_tse,      Cyrillic_TSE,      braceleft            ]};
+  key <AD12> {[ bracketright,      braceright,        braceright           ],
+              [ semicolon,         section,           braceright           ]};
+
+  key <AC01> {[ a,                 A,                 mu                   ],
+              [ Cyrillic_softsign, Cyrillic_SOFTSIGN, mu                   ]};
+  key <AC02> {[ s,                 S,                 sterling             ],
+              [ Cyrillic_ya,       Cyrillic_YA,       sterling             ]};
+  key <AC03> {[ d,                 D,                 dollar               ],
+              [ Cyrillic_a,        Cyrillic_A,        dollar               ]};
+  key <AC04> {[ f,                 F,                 cent                 ],
+              [ Cyrillic_o,        Cyrillic_O,        cent                 ]};
+  key <AC05> {[ g,                 G,                 Cyrillic_yeru        ],
+              [ Cyrillic_zhe,      Cyrillic_ZHE,      Cyrillic_yeru        ]};
+  key <AC06> {[ h,                 H,                 Cyrillic_YERU        ],
+              [ Cyrillic_ghe,      Cyrillic_GHE,      Cyrillic_YERU        ]};
+  key <AC07> {[ j,                 J,                 Cyrillic_e           ],
+              [ Cyrillic_te,       Cyrillic_TE,       Cyrillic_e           ]};
+  key <AC08> {[ k,                 K,                 Cyrillic_E           ],
+              [ Cyrillic_en,       Cyrillic_EN,       Cyrillic_E           ]};
+  key <AC09> {[ l,                 L,                 numerosign           ],
+              [ Cyrillic_ve,       Cyrillic_VE,       numerosign           ]};
+  key <AC10> {[ semicolon,         colon,             section              ],
+              [ Cyrillic_em,       Cyrillic_EM,       section              ]};
+  key <AC11> {[ quoteright,        quotedbl,          ellipsis             ],
+              [ Cyrillic_che,      Cyrillic_CHE,      ellipsis             ]};
+  key <BKSL> {[ backslash,         bar,               bar                  ],
+              [ apostrophe,        Cyrillic_YERU,     bar                  ]};
+
+  key <LSGT> {[ less,              greater,           NoSymbol             ],
+              [ less,              greater,           NoSymbol             ]};
+  key <AB01> {[ z,                 Z,                 emdash               ],
+              [ Cyrillic_yu,       Cyrillic_YU,       emdash               ]};
+  key <AB02> {[ x,                 X,                 endash               ],
+              [ Cyrillic_shorti,   Cyrillic_SHORTI,   endash               ]};
+  key <AB03> {[ c,                 C,                 copyright            ],
+              [ Cyrillic_hardsign, Cyrillic_HARDSIGN, copyright            ]};
+  key <AB04> {[ v,                 V,                 NoSymbol             ],
+              [ Cyrillic_e,        Cyrillic_E,        NoSymbol             ]};
+  key <AB05> {[ b,                 B,                 NoSymbol             ],
+              [ Cyrillic_ef,       Cyrillic_EF,       NoSymbol             ]};
+  key <AB06> {[ n,                 N,                 less                 ],
+              [ Cyrillic_ha,       Cyrillic_HA,       less                 ]};
+  key <AB07> {[ m,                 M,                 greater              ],
+              [ Cyrillic_pe,       Cyrillic_PE,       greater              ]};
+  key <AB08> {[ comma,             less,              guillemotleft        ],
+              [ Cyrillic_er,       Cyrillic_ER,       guillemotleft        ]};
+  key <AB09> {[ period,            greater,           guillemotright       ],
+              [ Cyrillic_el,       Cyrillic_EL,       guillemotright       ]};
+  key <AB10> {[ slash,             question,          backslash            ],
+              [ Cyrillic_be,       Cyrillic_BE,       backslash            ]};
+
+  // End alphanumeric section
+
+  key <SPCE> {[ space,             space,             nobreakspace         ]};
+  key <RALT> {  type="TWO_LEVEL",[ Alt_R,             Meta_R               ]};
+  
+  // Begin modifier mappings 
+  
+  modifier_map Shift  { Shift_L };
+  modifier_map Lock   { Caps_Lock, ISO_Lock };
+  modifier_map Control{ Control_L };
+  modifier_map Mod3   { Mode_switch };
+};
+
+partial alphanumeric_keys 
+xkb_symbols "phonetic_enhanced" {
+
+  // Describes the differences between a very simple en_US keyboard
+  // and a very simple Bulgarian phonetic keyboard with publishing
+  // symbols in the third level.
+
+  name[Group1]= "Latin";
+  name[Group2]= "Cyrillic";
+
+  key.type = "THREE_LEVEL";
+
+  key <TLDE> {[ quoteleft,         asciitilde,        degree               ],
+              [ Cyrillic_che,      Cyrillic_CHE,      degree               ]};
+  key <AE01> {[ 1,                 exclam,            multiply             ],
+              [ 1,                 exclam,            multiply             ]};
+  key <AE02> {[ 2,                 at,                division             ],
+              [ 2,                 at,                division             ]};
+  key <AE03> {[ 3,                 numbersign,        plusminus            ],
+              [ 3,                 numbersign,        plusminus            ]};
+  key <AE04> {[ 4,                 dollar,            notsign              ],
+              [ 4,                 dollar,            notsign              ]};
+  // I want here per mille sign, but it is not defined X keysym.
+  key <AE05> {[ 5,                 percent,           NoSymbol             ],
+              [ 5,                 percent,           NoSymbol             ]};
+  key <AE06> {[ 6,                 asciicircum,       notequal             ],
+              [ 6,                 asciicircum,       notequal             ]};
+  key <AE07> {[ 7,                 ampersand,         ampersand            ],
+              [ 7,                 ampersand,         ampersand            ]};
+  key <AE08> {[ 8,                 asterisk,          asterisk             ],
+              [ 8,                 asterisk,          asterisk             ]};
+  key <AE09> {[ 9,                 parenleft,         bracketleft          ],
+              [ 9,                 parenleft,         bracketleft          ]};
+  key <AE10> {[ 0,                 parenright,        bracketright         ],
+              [ 0,                 parenright,        bracketright         ]};
+  key <AE11> {[ minus,             underscore,        X                    ],
+              [ minus,             underscore,        X                    ]};
+  key <AE12> {[ equal,             plus,              L                    ],
+              [ equal,             plus,              L                    ]};
+
+  key <AD01> {[ q,                 Q,                 apostrophe           ],
+              [ Cyrillic_ya,       Cyrillic_YA,       apostrophe           ]};
+  key <AD02> {[ w,                 W,                 grave                ],
+              [ Cyrillic_ve,       Cyrillic_VE,       grave                ]};
+  key <AD03> {[ e,                 E,                 EuroSign             ],
+              [ Cyrillic_ie,       Cyrillic_IE,       EuroSign             ]};
+  key <AD04> {[ r,                 R,                 registered           ],
+              [ Cyrillic_er,       Cyrillic_ER,       registered           ]};
+  key <AD05> {[ t,                 T,                 trademark            ],
+              [ Cyrillic_te,       Cyrillic_TE,       trademark            ]};
+  key <AD06> {[ y,                 Y,                 yen                  ],
+              [ Cyrillic_hardsign, Cyrillic_HARDSIGN, yen                  ]};
+  key <AD07> {[ u,                 U,                 doublelowquotemark   ],
+              [ Cyrillic_u,        Cyrillic_U,        doublelowquotemark   ]};
+  key <AD08> {[ i,                 I,                 leftdoublequotemark  ],
+              [ Cyrillic_i,        Cyrillic_I,        leftdoublequotemark  ]};
+  key <AD09> {[ o,                 O,                 rightdoublequotemark ],
+              [ Cyrillic_o,        Cyrillic_O,        rightdoublequotemark ]};
+  // I want here `P' in a circle, but it is not defined X keysym.
+  key <AD10> {[ p,                 P,                 NoSymbol             ],
+              [ Cyrillic_pe,       Cyrillic_PE,       NoSymbol             ]};
+  key <AD11> {[ bracketleft,       braceleft,         braceleft            ],
+              [ Cyrillic_sha,      Cyrillic_SHA,      braceleft            ]};
+  key <AD12> {[ bracketright,      braceright,        braceright           ],
+              [ Cyrillic_shcha,    Cyrillic_SHCHA,    braceright           ]};
+
+  key <AC01> {[ a,                 A,                 mu                   ],
+              [ Cyrillic_a,        Cyrillic_A,        mu                   ]};
+  key <AC02> {[ s,                 S,                 sterling             ],
+              [ Cyrillic_es,       Cyrillic_ES,       sterling             ]};
+  key <AC03> {[ d,                 D,                 dollar               ],
+              [ Cyrillic_de,       Cyrillic_DE,       dollar               ]};
+  key <AC04> {[ f,                 F,                 cent                 ],
+              [ Cyrillic_ef,       Cyrillic_EF,       cent                 ]};
+  key <AC05> {[ g,                 G,                 Cyrillic_yeru        ],
+              [ Cyrillic_ghe,      Cyrillic_GHE,      Cyrillic_yeru        ]};
+  key <AC06> {[ h,                 H,                 Cyrillic_YERU        ],
+              [ Cyrillic_ha,       Cyrillic_HA,       Cyrillic_YERU        ]};
+  key <AC07> {[ j,                 J,                 Cyrillic_e           ],
+              [ Cyrillic_shorti,   Cyrillic_SHORTI,   Cyrillic_e           ]};
+  key <AC08> {[ k,                 K,                 Cyrillic_E           ],
+              [ Cyrillic_ka,       Cyrillic_KA,       Cyrillic_E           ]};
+  key <AC09> {[ l,                 L,                 numerosign           ],
+              [ Cyrillic_el,       Cyrillic_EL,       numerosign           ]};
+  key <AC10> {[ semicolon,         colon,             section              ],
+              [ semicolon,         colon,             section              ]};
+  key <AC11> {[ quoteright,        quotedbl,          ellipsis             ],
+              [ quoteright,        quotedbl,          ellipsis             ]};
+  key <BKSL> {[ backslash,         bar,               bar                  ],
+              [ Cyrillic_yu,       Cyrillic_YU,       bar                  ]};
+
+  key <LSGT> {[ less,              greater,           NoSymbol             ],
+              [ less,              greater,           NoSymbol             ]};
+  key <AB01> {[ z,                 Z,                 emdash               ],
+              [ Cyrillic_ze,       Cyrillic_ZE,       emdash               ]};
+  key <AB02> {[ x,                 X,                 endash               ],
+              [ Cyrillic_softsign, Cyrillic_SOFTSIGN, endash               ]};
+  key <AB03> {[ c,                 C,                 copyright            ],
+              [ Cyrillic_tse,      Cyrillic_TSE,      copyright            ]};
+  key <AB04> {[ v,                 V,                 NoSymbol             ],
+              [ Cyrillic_zhe,      Cyrillic_ZHE,      NoSymbol             ]};
+  key <AB05> {[ b,                 B,                 NoSymbol             ],
+              [ Cyrillic_be,       Cyrillic_BE,       NoSymbol             ]};
+  key <AB06> {[ n,                 N,                 less                 ],
+              [ Cyrillic_en,       Cyrillic_EN,       less                 ]};
+  key <AB07> {[ m,                 M,                 greater              ],
+              [ Cyrillic_em,       Cyrillic_EM,       greater              ]};
+  key <AB08> {[ comma,             less,              guillemotleft        ],
+              [ comma,             less,              guillemotleft        ]};
+  key <AB09> {[ period,            greater,           guillemotright       ],
+              [ period,            greater,           guillemotright       ]};
+  key <AB10> {[ slash,             question,          backslash            ],
+              [ slash,             question,          backslash            ]};
+
+  // End alphanumeric section
+
+  key <SPCE> {[ space,             space,             nobreakspace         ]};
+  key <RALT> {  type="TWO_LEVEL",[ Alt_R,             Meta_R               ]};
+  
+  // Begin modifier mappings 
+  
+  modifier_map Shift  { Shift_L };
+  modifier_map Lock   { Caps_Lock, ISO_Lock };
+  modifier_map Control{ Control_L };
+  modifier_map Mod3   { Mode_switch };
+};
+
+partial default alphanumeric_keys
+xkb_symbols "bds" {
+
+  // Describes the differences between a very simple en_US keyboard
+  // and a very simple Bulgarian keyboard.
+
+  name[Group1]= "Latin";
+  name[Group2]= "Cyrillic";
+  
+  key <TLDE> {   [ quoteleft,         asciitilde          ],
+                 [ parenleft,         parenright          ]    };
+  key <AE01> {   [ 1,                 exclam              ],
+                 [ 1,                 exclam              ]    };
+  key <AE02> {   [ 2,                 at                  ],
+                 [ 2,                 question            ]    };
+  key <AE03> {   [ 3,                 numbersign          ],
+                 [ 3,                 plus                ]    };
+  key <AE04> {   [ 4,                 dollar              ],
+                 [ 4,                 quotedbl            ]    };
+  key <AE05> {   [ 5,                 percent             ],
+                 [ 5,                 percent             ]    };
+  key <AE06> {   [ 6,                 asciicircum         ],
+                 [ 6,                 equal               ]    };
+  key <AE07> {   [ 7,                 ampersand           ],
+                 [ 7,                 colon               ]    };
+  key <AE08> {   [ 8,                 asterisk            ],
+                 [ 8,                 slash               ]    };
+  key <AE09> {   [ 9,                 parenleft           ],
+                 [ 9,                 emdash              ]    };
+  key <AE10> {   [ 0,                 parenright          ],
+                 [ 0,                 numerosign          ]    };
+  key <AE11> {   [ minus,             underscore          ],
+                 [ minus,             I                   ]    };
+  key <AE12> {   [ equal,             plus                ],
+                 [ period,            V                   ]    };
+
+  key <AD01> {   [ q,                 Q                   ],
+                 [ comma,             Cyrillic_yeru       ]    };
+  key <AD02> {   [ w,                 W                   ],
+                 [ Cyrillic_u,        Cyrillic_U          ]    };
+  key <AD03> {   [ e,                 E                   ],
+                 [ Cyrillic_ie,       Cyrillic_IE         ]    };
+  key <AD04> {   [ r,                 R                   ],
+                 [ Cyrillic_i,        Cyrillic_I          ]    };
+  key <AD05> {   [ t,                 T                   ],
+                 [ Cyrillic_sha,      Cyrillic_SHA        ]    };
+  key <AD06> {   [ y,                 Y                   ],
+                 [ Cyrillic_shcha,    Cyrillic_SHCHA      ]    };
+  key <AD07> {   [ u,                 U                   ],
+                 [ Cyrillic_ka,       Cyrillic_KA         ]    };
+  key <AD08> {   [ i,                 I                   ],
+                 [ Cyrillic_es,       Cyrillic_ES         ]    };
+  key <AD09> {   [ o,                 O                   ],
+                 [ Cyrillic_de,       Cyrillic_DE         ]    };
+  key <AD10> {   [ p,                 P                   ],
+                 [ Cyrillic_ze,       Cyrillic_ZE         ]    };
+  key <AD11> {   [ bracketleft,       braceleft           ],
+                 [ Cyrillic_tse,      Cyrillic_TSE        ]    };
+  key <AD12> {   [ bracketright,      braceright          ],
+                 [ semicolon,         section             ]    };
+
+  key <AC01> {   [ a,                 A                   ],
+                 [ Cyrillic_softsign, Cyrillic_SOFTSIGN   ]    };
+  key <AC02> {   [ s,                 S                   ],
+                 [ Cyrillic_ya,       Cyrillic_YA         ]    };
+  key <AC03> {   [ d,                 D                   ],
+                 [ Cyrillic_a,        Cyrillic_A          ]    };
+  key <AC04> {   [ f,                 F                   ],
+                 [ Cyrillic_o,        Cyrillic_O          ]    };
+  key <AC05> {   [ g,                 G                   ],
+                 [ Cyrillic_zhe,      Cyrillic_ZHE        ]    };
+  key <AC06> {   [ h,                 H                   ],
+                 [ Cyrillic_ghe,      Cyrillic_GHE        ]    };
+  key <AC07> {   [ j,                 J                   ],
+                 [ Cyrillic_te,       Cyrillic_TE         ]    };
+  key <AC08> {   [ k,                 K                   ],
+                 [ Cyrillic_en,       Cyrillic_EN         ]    };
+  key <AC09> {   [ l,                 L                   ],
+                 [ Cyrillic_ve,       Cyrillic_VE         ]    };
+  key <AC10> {   [ semicolon,         colon               ],
+                 [ Cyrillic_em,       Cyrillic_EM         ]    };
+  key <AC11> {   [ quoteright,        quotedbl            ],
+                 [ Cyrillic_che,      Cyrillic_CHE        ]    };
+  key <BKSL> {   [ backslash,         bar                 ],
+                 [ apostrophe,        Cyrillic_YERU       ]    };
+
+  key <LSGT> {   [ less,              greater             ],
+                 [ less,              greater             ]    };
+  key <AB01> {   [ z,                 Z                   ],
+                 [ Cyrillic_yu,       Cyrillic_YU         ]    };
+  key <AB02> {   [ x,                 X                   ],
+                 [ Cyrillic_shorti,   Cyrillic_SHORTI     ]    };
+  key <AB03> {   [ c,                 C                   ],
+                 [ Cyrillic_hardsign, Cyrillic_HARDSIGN   ]    };
+  key <AB04> {   [ v,                 V                   ],
+                 [ Cyrillic_e,        Cyrillic_E          ]    };
+  key <AB05> {   [ b,                 B                   ],
+                 [ Cyrillic_ef,       Cyrillic_EF         ]    };
+  key <AB06> {   [ n,                 N                   ],
+                 [ Cyrillic_ha,       Cyrillic_HA         ]    };
+  key <AB07> {   [ m,                 M                   ],
+                 [ Cyrillic_pe,       Cyrillic_PE         ]    };
+  key <AB08> {   [ comma,             less                ],
+                 [ Cyrillic_er,       Cyrillic_ER         ]    };
+  key <AB09> {   [ period,            greater             ],
+                 [ Cyrillic_el,       Cyrillic_EL         ]    };
+  key <AB10> {   [ slash,             question            ],
+                 [ Cyrillic_be,       Cyrillic_BE         ]    };
+    
+  // End alphanumeric section
+  
+  key <RALT> {   [ Alt_R,             Meta_R              ]    };
+
+  // Begin modifier mappings 
+  
+  modifier_map Shift  { Shift_L };
+  modifier_map Lock   { Caps_Lock, ISO_Lock };
+  modifier_map Control{ Control_L };
+  modifier_map Mod3   { Mode_switch };
 };
 
 partial alphanumeric_keys 
-xkb_symbols "iso-alternate" {
-    include "be(basic)"
-    replace key <AD01> {[		a,               A 	],
-			[              ae,              AE	]	};
-    replace key <AD02> {[               z,               Z 	],
-			[   guillemotleft,            less	]	};
-    replace key <AC01> {[               q,               Q 	]	};
-    replace key <AC10> {[               m,               M	],
-			[              mu,       masculine	]	};
-    replace key <AB01> {[               w,               W 	],
-			[         lstroke,         Lstroke     	]	};
-    replace key <AB07> {[           comma,        question 	],
-			[      dead_acute, dead_doubleacute	]	};
+xkb_symbols "phonetic" {
+  
+  // Describes the differences between a very simple en_US keyboard
+  // and a very simple Bulgarian phonetic keyboard.
+
+  name[Group1]= "Latin";
+  name[Group2]= "Cyrillic";
+  
+  key <TLDE> {   [ quoteleft,         asciitilde          ],
+                 [ Cyrillic_che,      Cyrillic_CHE        ]    };
+  key <AE01> {   [ 1,                 exclam              ],
+                 [ 1,                 exclam              ]    };
+  key <AE02> {   [ 2,                 at                  ],
+                 [ 2,                 at                  ]    };
+  key <AE03> {   [ 3,                 numbersign          ],
+                 [ 3,                 numbersign          ]    };
+  key <AE04> {   [ 4,                 dollar              ],
+                 [ 4,                 dollar              ]    };
+  key <AE05> {   [ 5,                 percent             ],
+                 [ 5,                 percent             ]    };
+  key <AE06> {   [ 6,                 asciicircum         ],
+                 [ 6,                 asciicircum         ]    };
+  key <AE07> {   [ 7,                 ampersand           ],
+                 [ 7,                 ampersand           ]    };
+  key <AE08> {   [ 8,                 asterisk            ],
+                 [ 8,                 asterisk            ]    };
+  key <AE09> {   [ 9,                 parenleft           ],
+                 [ 9,                 parenleft           ]    };
+  key <AE10> {   [ 0,                 parenright          ],
+                 [ 0,                 parenright          ]    };
+  key <AE11> {   [ minus,             underscore          ],
+                 [ minus,             underscore          ]    };
+  key <AE12> {   [ equal,             plus                ],
+                 [ equal,             plus                ]    };
+
+  key <AD01> {   [ q,                 Q                   ],
+                 [ Cyrillic_ya,       Cyrillic_YA         ]    };
+  key <AD02> {   [ w,                 W                   ],
+                 [ Cyrillic_ve,       Cyrillic_VE         ]    };
+  key <AD03> {   [ e,                 E                   ],
+                 [ Cyrillic_ie,       Cyrillic_IE         ]    };
+  key <AD04> {   [ r,                 R                   ],
+                 [ Cyrillic_er,       Cyrillic_ER         ]    };
+  key <AD05> {   [ t,                 T                   ],
+                 [ Cyrillic_te,       Cyrillic_TE         ]    };
+  key <AD06> {   [ y,                 Y                   ],
+                 [ Cyrillic_hardsign, Cyrillic_HARDSIGN   ]    };
+  key <AD07> {   [ u,                 U                   ],
+                 [ Cyrillic_u,        Cyrillic_U          ]    };
+  key <AD08> {   [ i,                 I                   ],
+                 [ Cyrillic_i,        Cyrillic_I          ]    };
+  key <AD09> {   [ o,                 O                   ],
+                 [ Cyrillic_o,        Cyrillic_O          ]    };
+  key <AD10> {   [ p,                 P                   ],
+                 [ Cyrillic_pe,       Cyrillic_PE         ]    };
+  key <AD11> {   [ bracketleft,       braceleft           ],
+                 [ Cyrillic_sha,      Cyrillic_SHA        ]    };
+  key <AD12> {   [ bracketright,      braceright          ],
+                 [ Cyrillic_shcha,    Cyrillic_SHCHA      ]    };
+
+  key <AC01> {   [ a,                 A                   ],
+                 [ Cyrillic_a,        Cyrillic_A          ]    };
+  key <AC02> {   [ s,                 S                   ],
+                 [ Cyrillic_es,       Cyrillic_ES         ]    };
+  key <AC03> {   [ d,                 D                   ],
+                 [ Cyrillic_de,       Cyrillic_DE         ]    };
+  key <AC04> {   [ f,                 F                   ],
+                 [ Cyrillic_ef,       Cyrillic_EF         ]    };
+  key <AC05> {   [ g,                 G                   ],
+                 [ Cyrillic_ghe,      Cyrillic_GHE        ]    };
+  key <AC06> {   [ h,                 H                   ],
+                 [ Cyrillic_ha,       Cyrillic_HA         ]    };
+  key <AC07> {   [ j,                 J                   ],
+                 [ Cyrillic_shorti,   Cyrillic_SHORTI     ]    };
+  key <AC08> {   [ k,                 K                   ],
+                 [ Cyrillic_ka,       Cyrillic_KA         ]    };
+  key <AC09> {   [ l,                 L                   ],
+                 [ Cyrillic_el,       Cyrillic_EL         ]    };
+  key <AC10> {   [ semicolon,         colon               ],
+                 [ semicolon,         colon               ]    };
+  key <AC11> {   [ quoteright,        quotedbl            ],
+                 [ quoteright,        quotedbl            ]    };
+  key <BKSL> {   [ backslash,         bar                 ],
+                 [ Cyrillic_yu,       Cyrillic_YU         ]    };
+
+  key <LSGT> {   [ less,              greater             ],
+                 [ less,              greater             ]    };
+  key <AB01> {   [ z,                 Z                   ],
+                 [ Cyrillic_ze,       Cyrillic_ZE         ]    };
+  key <AB02> {   [ x,                 X                   ],
+                 [ Cyrillic_softsign, Cyrillic_SOFTSIGN   ]    };
+  key <AB03> {   [ c,                 C                   ],
+                 [ Cyrillic_tse,      Cyrillic_TSE        ]    };
+  key <AB04> {   [ v,                 V                   ],
+                 [ Cyrillic_zhe,      Cyrillic_ZHE        ]    };
+  key <AB05> {   [ b,                 B                   ],
+                 [ Cyrillic_be,       Cyrillic_BE         ]    };
+  key <AB06> {   [ n,                 N                   ],
+                 [ Cyrillic_en,       Cyrillic_EN         ]    };
+  key <AB07> {   [ m,                 M                   ],
+                 [ Cyrillic_em,       Cyrillic_EM         ]    };
+  key <AB08> {   [ comma,             less                ],
+                 [ comma,             less                ]    };
+  key <AB09> {   [ period,            greater             ],
+                 [ period,            greater             ]    };
+  key <AB10> {   [ slash,             question            ],
+                 [ slash,             question            ]    };
+
+  // End alphanumeric section
+
+  key <RALT> {   [ Alt_R,             Meta_R              ]    };
+
+  // Begin modifier mappings 
+  
+  modifier_map Shift  { Shift_L };
+  modifier_map Lock   { Caps_Lock, ISO_Lock };
+  modifier_map Control{ Control_L };
+  modifier_map Mod3   { Mode_switch };
 };
Index: xc/programs/xkbcomp/symbols/br
diff -u xc/programs/xkbcomp/symbols/br:1.2 xc/programs/xkbcomp/symbols/br:1.4
--- xc/programs/xkbcomp/symbols/br:1.2	Sun Aug 29 22:28:56 1999
+++ xc/programs/xkbcomp/symbols/br	Tue Nov 28 12:25:14 2000
@@ -1,5 +1,5 @@
 //
-// $XFree86: xc/programs/xkbcomp/symbols/br,v 1.2 1999/08/30 02:28:56 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/br,v 1.4 2000/11/28 17:25:14 dawes Exp $
 //
 partial default alphanumeric_keys 
 xkb_symbols "abnt2" {
@@ -13,25 +13,52 @@
     name[Group1]= "Brazilian";
 
     key <TLDE> {        [      apostrophe,        quotedbl      ]       };
+    key <AE01> {        [               1,          exclam      ],
+                        [     onesuperior,      exclamdown	]       };
+    key <AE02> {        [               2,              at      ],
+                        [     twosuperior,         onehalf      ]       };
+    key <AE03> {        [               3,      numbersign      ],
+                        [   threesuperior,   threequarters      ]       };
     key <AE04> {        [               4,          dollar      ],
-                        [        sterling                       ]       };
+                        [        sterling,      onequarter      ]       };
     key <AE05> {        [               5,         percent      ],
                         [            cent                       ]       };
     key <AE06> {        [               6,  dead_diaeresis      ],
-                        [         notsign                       ]       };
+                        [         notsign,       diaeresis      ]       };
+    key <AE07> {        [               7,       ampersand     	],
+                        [       braceleft                       ]       };
+    key <AE08> {        [               8,        asterisk      ],   
+                        [     bracketleft                       ]       };
+    key <AE09> {        [               9,       parenleft      ],
+                        [    bracketright                       ]       };
+    key <AE10> {        [               0,      parenright      ],
+                        [      braceright                       ]       };
+    key <AE11> {        [     	    minus,      underscore      ],
+                        [       backslash                       ]       };
     key <AE12> {        [           equal,            plus      ],
                         [         section                       ]       };
-    key <AD11> {        [      dead_acute,      dead_grave      ]       };
+    key <AD03> {        [               e,               E      ],
+                        [        EuroSign                       ]       };
+    key <AD04> {        [               r,               R      ],
+			[      registered                       ]       };
+    key <AD11> {        [      dead_acute,      dead_grave      ],
+			[           acute,           grave      ]       };
     key <AD12> {        [     bracketleft,       braceleft      ],
                         [     ordfeminine                       ]       };
     key <AC10> {        [        ccedilla,        Ccedilla      ]       };
-    key <AC11> {        [      dead_tilde, dead_circumflex      ]       };
+    key <AC11> {        [      dead_tilde, dead_circumflex      ],
+			[      asciitilde,     asciicircum      ]	};
     key <AC12> {        [    bracketright,      braceright      ],
                         [       masculine                       ]       };
+    key <AB03> {        [               c,               C      ],
+			[       copyright                       ]       };
+    key <AB07> {        [               m,               M      ],
+			[              mu                       ]       };
     key <BKSL> {        [       backslash,             bar      ]       };
     key <AB10> {        [       semicolon,           colon      ]       };
+// ABNT-2 keyboard has this special key
     key <AB11> {        [           slash,        question      ],
-                        [          degree                       ]       };
+                        [          degree,    questiondown	]       };
 
     key <KPPT> {	[  KP_Decimal				]	};
     key <KPDL> {	[  KP_Delete,	comma			]	};
@@ -41,8 +68,10 @@
     modifier_map Shift  { Shift_L };
     modifier_map Lock   { Caps_Lock };
     modifier_map Control{ Control_L };
-    modifier_map Mod3   { Mode_switch };
-
+    key <RALT> {
+	symbols[Group1]= [ Mode_switch, Multi_key ],
+	virtualMods= AltGr
+    };
 };
 
 partial alphanumeric_keys 
Index: xc/programs/xkbcomp/symbols/cs
diff -u xc/programs/xkbcomp/symbols/cs:3.1 xc/programs/xkbcomp/symbols/cs:3.3
--- xc/programs/xkbcomp/symbols/cs:3.1	Mon Dec 23 02:13:14 1996
+++ xc/programs/xkbcomp/symbols/cs	Tue Sep 26 11:57:25 2000
@@ -1,9 +1,10 @@
     // $XConsortium: cs /main/3 1996/08/31 12:19:14 kaleb $
+    // $XFree86: xc/programs/xkbcomp/symbols/cs,v 3.3 2000/09/26 15:57:25 tsi Exp $
 partial default alphanumeric_keys 
 xkb_symbols "basic" {
 
     // Describes the differences between a very simple en_US
-    // keyboard and a very simple Czech(Czechoslovakia) keybaord
+    // keyboard and a very simple Czech 'qwertz' keyboard
 
     name[Group1]= "Czech";
 
@@ -23,6 +24,10 @@
 			[		w,		W	]	};
     key <AE02> {	[	   ecaron,		2	],
 			[		2,	       at	]	};
+    key <AB05> {        [               b,              B       ],       
+			[		b,		B	]	};
+    key <AB04> {        [               v,              V       ],       
+			[		v,		V	]	};
     key <AB03> {        [               c,              C       ],       
 			[		c,		C	]	};
     key <AB02> {        [               x,              X       ],       
@@ -61,6 +66,8 @@
 			[	    comma,	     less	]	};
     key <AC08> {        [               k,              K       ],       
 			[		k,		K	]	};
+    key <AC09> {        [               l,              L       ],       
+			[		l,		L	]	};
     key <AD08> {        [               i,              I       ],       
 			[		i,		I	]	};
     key <AD09> {        [               o,              O       ],       
Index: xc/programs/xkbcomp/symbols/cs_qwerty
diff -u /dev/null xc/programs/xkbcomp/symbols/cs_qwerty:1.2
--- /dev/null	Mon Dec 18 14:35:07 2000
+++ xc/programs/xkbcomp/symbols/cs_qwerty	Tue Sep 26 11:57:25 2000
@@ -0,0 +1,117 @@
+    // $XConsortium: cs /main/3 1996/08/31 12:19:14 kaleb $
+    // $XFree86: xc/programs/xkbcomp/symbols/cs_qwerty,v 1.2 2000/09/26 15:57:25 tsi Exp $
+    //
+
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Czech 'qwerty' keyboard
+
+    name[Group1]= "Czech";
+
+    key <TLDE> {        [  dead_diaeresis, dead_abovering       ],        
+			[           grave,     asciitilde	]	};
+    key <AD01> {	[	        q,		Q	],	
+			[		q,		Q	]	};
+    key <AE01> {	[	     plus,		1	],
+			[		1,	   exclam	]	};
+    key <AB01> {	[	        z,		Z	],
+			[		z,	        Z	]	};
+    key <AC02> {        [               s,              S       ],       
+			[		s,		S	]	};
+    key <AC01> {        [               a,              A       ],       
+			[		a,		A	]	};
+    key <AD02> {        [               w,              W       ],       
+			[		w,		W	]	};
+    key <AE02> {	[	   ecaron,		2	],
+			[		2,	       at	]	};
+    key <AB05> {        [               b,              B       ],       
+			[		b,		B	]	};
+    key <AB04> {        [               v,              V       ],       
+			[		v,		V	]	};
+    key <AB03> {        [               c,              C       ],       
+			[		c,		C	]	};
+    key <AB02> {        [               x,              X       ],       
+			[		x,		X	]	};
+    key <AC03> {        [               d,              D       ],       
+			[		d,		D	]	};
+    key <AE04> {	[	   ccaron,		4	],
+			[		4,	   dollar	]	};
+    key <AE03> {	[	   scaron,		3	],
+			[		3,     numbersign	]	};
+    key <AC04> {        [               f,              F       ],       
+			[		f,		F	]	};
+    key <AD05> {        [               t,              T       ],       
+			[		t,		T	]	};
+    key <AD04> {        [               r,              R       ],       
+			[		r,		R	]	};
+    key <AE05> {	[	   rcaron,		5	],
+			[		5,        percent	]	};
+    key <AC06> {        [               h,              H       ],       
+			[		h,		H	]	};
+    key <AC05> {        [               g,              G       ],       
+			[		g,		G	]	};
+    key <AD06> {	[	        y,		Y	],
+			[		y,	        Y	]	};
+    key <AE06> {	[	   zcaron,		6	],
+			[		6,    asciicircum	]	};
+    key <AB07> {	[	        m,		M	],	
+			[		m,		M	]	};
+    key <AD07> {	[	        u,		U	],	
+			[		u,		U	]	};
+    key <AE07> {	[	   yacute,		7	],
+			[		7,      ampersand	]	};
+    key <AE08> {	[	   aacute,		8	],
+			[		8,       asterisk	]	};
+    key <AB08> {	[	    comma,	 question	],
+			[	    comma,	     less	]	};
+    key <AC08> {        [               k,              K       ],       
+			[		k,		K	]	};
+    key <AC09> {        [               l,              L       ],       
+			[		l,		L	]	};
+    key <AD08> {        [               i,              I       ],       
+			[		i,		I	]	};
+    key <AD09> {        [               o,              O       ],       
+			[		o,		O	]	};
+    key <AE10> {	[	   eacute,		0	],
+			[		0,     parenright	]	};
+    key <AE09> {	[	   iacute,		9	],
+			[		9,      parenleft	]	};
+    key <AB09> {	[	   period,	    colon	],
+			[	   period,	  greater	]	};
+    key <AB10> {	[	    minus,     underscore	],
+			[	    slash,	 question	]	};
+    key <AC10> {	[	    uring,       quotedbl	],
+			[       semicolon,	    colon	]	};
+    key <AD10> {        [               p,              P       ],       
+			[		p,		P	]	};
+    key <AE11> {	[	    equal,        percent	],
+			[           minus,     underscore	]	};
+    key <AC11> {	[	  section,         exclam	],
+			[      apostrophe,       quotedbl	]	};
+    key <AD11> {	[	   uacute,          slash	],
+			[     bracketleft,      braceleft	]	};
+    key <AE12> {	[      dead_acute,     dead_caron	],
+			[           equal,           plus	]	};
+
+    key <BKSL> {	[	backslash,	      bar	],	
+			[	backslash,	      bar	]	};
+    key <LSGT> {	[            less,	  greater	],
+			[	backslash,	brokenbar	]	};
+
+    key <AD12> {	[      parenright,      parenleft	],
+			[    bracketright,     braceright	]	};
+
+    key <SCLK> {	[	Scroll_Lock			]	};
+
+    // End alphanumeric section
+
+    // begin modifier mappings
+    
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
Index: xc/programs/xkbcomp/symbols/dk
diff -u xc/programs/xkbcomp/symbols/dk:3.4 xc/programs/xkbcomp/symbols/dk:3.5
--- xc/programs/xkbcomp/symbols/dk:3.4	Mon Dec 13 22:26:18 1999
+++ xc/programs/xkbcomp/symbols/dk	Fri Oct 27 14:31:08 2000
@@ -1,5 +1,5 @@
 // $XConsortium: dk /main/3 1996/08/31 12:19:29 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/dk,v 3.4 1999/12/14 03:26:18 robin Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/dk,v 3.5 2000/10/27 18:31:08 dawes Exp $
 partial alphanumeric_keys 
 xkb_symbols "basic" {
 
@@ -48,7 +48,7 @@
     key <AC03> {        [               d,               D      ],
                         [             eth,             ETH      ]};
     key <AD03> {        [               e,               E      ],
-                        [        NoSymbol,            cent      ]};
+                        [        EuroSign,            cent      ]};
     key <AD04> {        [               r,               R      ],
                         [      registered,        NoSymbol      ]};
     key <AD05> {        [               t,               T      ],
Index: xc/programs/xkbcomp/symbols/dvorak
diff -u xc/programs/xkbcomp/symbols/dvorak:3.2 xc/programs/xkbcomp/symbols/dvorak:3.4
--- xc/programs/xkbcomp/symbols/dvorak:3.2	Mon Jan 11 00:13:39 1999
+++ xc/programs/xkbcomp/symbols/dvorak	Mon Nov 27 00:06:46 2000
@@ -6,9 +6,9 @@
 // uses the punctuation keys configurations common on PC 
 // keyboards (e.g. key <ABO9> is { [ period greater ] })
 
-// $XFree86: xc/programs/xkbcomp/symbols/dvorak,v 3.2 1999/01/11 05:13:39 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/dvorak,v 3.4 2000/11/27 05:06:46 dawes Exp $
 
-partial default alphanumeric_keys 
+partial default alphanumeric_keys
 xkb_symbols "basic" {
 
 
@@ -16,26 +16,33 @@
     key <ESC>  {	[ Escape			]	};
 
     // Alphanumeric section
-    key <TLDE> {	[       grave,	asciitilde	]	};
+    key <TLDE> {	[       grave,	asciitilde	],
+			[  dead_grave,	dead_tilde	]	};
 
     key <AE01> {	[	    1,	exclam 		]	};
     key <AE02> {	[	    2,	at		]	};
     key <AE03> {	[	    3,	numbersign	]	};
     key <AE04> {	[	    4,	dollar		]	};
     key <AE05> {	[	    5,	percent		]	};
-    key <AE06> {	[	    6,	asciicircum	]	};
+    key <AE06> {	[	    6,	asciicircum	],
+			[ dead_circumflex, dead_circumflex ]	};
     key <AE07> {	[	    7,	ampersand	]	};
     key <AE08> {	[	    8,	asterisk	]	};
-    key <AE09> {	[	    9,	parenleft	]	};
+    key <AE09> {	[	    9,	parenleft	],
+			[  dead_grave			]	};
     key <AE10> {	[	    0,	parenright	]	};
     key <AE11> {	[ bracketleft,	braceleft	]	};
-    key <AE12> {	[ bracketright,	braceright	]	};
+    key <AE12> {	[ bracketright,	braceright	],
+			[  dead_tilde			]	};
     key <BKSP> {	[   BackSpace,	Delete 		]	};
 
     key  <TAB> {	[ 	  Tab,	ISO_Left_Tab	]	};
-    key <AD01> {	[  apostrophe,  quotedbl	] 	};
-    key <AD02> {	[       comma,	less		]	};
-    key <AD03> {	[      period,	greater		]	};
+    key <AD01> {	[  apostrophe,	quotedbl	],
+			[  dead_acute,	dead_diaeresis	] 	};
+    key <AD02> {	[	comma,	less		],
+			[ dead_cedilla,	dead_caron	]	};
+    key <AD03> {	[      period,	greater		],
+			[ dead_abovedot, periodcentered ]	};
     key <AD04> {	[	    p,	P		]	};
     key <AD05> {	[	    y,	Y		]	};
     key <AD06> {	[	    f,	F		]	};
@@ -43,8 +50,8 @@
     key <AD08> {	[	    c,	C		]	};
     key <AD09> {	[	    r,	R		]	};
     key <AD10> {	[	    l,	L		]	};
-    key <AD11> {	[       slash,	question	]	};
-    key <AD12> {	[       equal,	plus		]	};
+    key <AD11> {	[	slash,	question	]	};
+    key <AD12> {	[	equal,	plus		]	};
     key <RTRN> {	[ Return			]	};
 
     key <CAPS> {	[	Caps_Lock		]	};
@@ -57,21 +64,22 @@
     key <AC07> {	[	    h,	H		]	};
     key <AC08> {	[	    t,	T		]	};
     key <AC09> {	[	    n,	N		]	};
-    key <AC10> {	[           s,	S		]	};
-    key <AC11> {	[       minus,	underscore	]	};
+    key <AC10> {	[	    s,	S		]	};
+    key <AC11> {	[	minus,	underscore	]	};
 
-    key <LFSH> {	[ 	 Shift_L		]	};
-    key <AB01> {	[   semicolon,	colon 		]	};
-    key <AB02> {	[	  q,	Q		]	};
-    key <AB03> {	[	  j,	J		]	};
-    key <AB04> {	[	  k,	K		]	};
-    key <AB05> {	[	  x,	X		]	};
-    key <AB06> {	[	  b,	B		]	};
-    key <AB07> {	[	  m,	M		]	};
-    key <AB08> {	[         w,	W		]	};
-    key <AB09> {	[         v,	V		]	};
-    key <AB10> {	[         z,	Z		]	};
-    key <BKSL> {	[ backslash,	bar		]	};
+    key <LFSH> {	[	Shift_L			]	};
+    key <AB01> {	[   semicolon,	colon 		],
+			[ dead_ogonek, dead_doubleacute ]	};
+    key <AB02> {	[	    q,	Q		]	};
+    key <AB03> {	[	    j,	J		]	};
+    key <AB04> {	[	    k,	K		]	};
+    key <AB05> {	[	    x,	X		]	};
+    key <AB06> {	[	    b,	B		]	};
+    key <AB07> {	[	    m,	M		]	};
+    key <AB08> {	[	    w,	W		]	};
+    key <AB09> {	[	    v,	V		]	};
+    key <AB10> {	[	    z,	Z		]	};
+    key <BKSL> {	[   backslash,	bar		]	};
 
     key <LCTL> {	[ 	 Control_L		]	};
     key <SPCE> {	[ 	 space			]	};
@@ -81,4 +89,86 @@
     modifier_map Shift  { Shift_L };
     modifier_map Lock   { Caps_Lock };
     modifier_map Control{ Control_L };
+};
+
+// Norwegian Dvorak
+partial alphanumeric_keys 
+xkb_symbols "no" {
+    include "dvorak(basic)"
+
+    key <TLDE> {	[	  bar,	section		],
+			[   brokenbar,	 paragraph	]	};
+
+    key <AE01> {	[	    1,	exclam 		],
+			[  exclamdown,	onesuperior	]	};
+    key <AE02> {	[	    2,	quotedbl	],
+			[	   at,	twosuperior	]	};
+    key <AE03> {	[	    3,	numbersign	],
+			[    sterling,	threesuperior	]	};
+    key <AE04> {	[	    4,	dollar		],
+			[    currency,	onequarter	]	};
+    key <AE05> {	[	    5,	percent		],
+			[     onehalf,	onehalf		]	};
+    key <AE06> {	[	    6,	ampersand	],
+			[ threequarters, threequarters	]	};
+    key <AE07> {	[	    7,	slash		],
+			[   braceleft,	division	]	};
+    key <AE08> {	[	    8,	parenleft	],
+			[ bracketleft			]	};
+    key <AE09> {	[	    9,	parenright	],
+			[ bracketright			]	};
+    key <AE10> {	[	    0,	equal		],
+			[  braceright			]	};
+    key <AE11> {	[	 plus,	question	],
+			[   plusminus,	questiondown	]	};
+    key <AE12> {	[   backslash,	grave		],
+			[  dead_acute,	dead_grave	]	};
+
+    key <AD01> {	[       aring,	Aring		],
+			[  braceright,	bracketright	]	};
+    key <AD02> {	[	comma,	semicolon	],
+			[ dead_cedilla,	cedilla		]	};
+    key <AD03> {	[      period,	colon		],
+			[ periodcentered		]	};
+    key <AD04> {	[	    p,	P		],
+			[       thorn,	THORN		]	};
+    key <AD05> {	[	    y,	Y		],
+			[         yen			]	};
+    key <AD06> {	[	    f,	F		],
+			[ ordfeminine			]	};
+    key <AD08> {	[	    c,	C		],
+			[    ccedilla,	copyright	]	};
+    key <AD09> {	[	    r,	R		],
+			[  registered			]	};
+    key <AD11> {	[  apostrophe,	asterisk	],
+			[ dead_circumflex,	acute	]	};
+    key <AD12> {	[  asciitilde,	asciicircum	],
+			[ dead_diaeresis, dead_tilde	]	};
+
+    key <AC03> {	[	    e,	E		],
+			[    EuroSign,	cent		]	};
+    key <AC05> {	[	    i,	I		],
+			[    idotless,	Iabovedot	]	};
+    key <AC06> {	[	    d,	D		],
+			[	  eth,	ETH		]	};
+    key <AC10> {	[	    s,	S		],
+			[      ssharp			]	};
+    key <AC11> {	[	minus,	underscore	],
+			[      hyphen,	diaeresis	]	};
+
+    key <AB01> {	[	   ae,	AE 		],
+			[   braceleft,	bracketleft	]	};
+    key <AB05> {	[	    x,	X		],
+			[    multiply			]	};
+    key <AB07> {	[	    m,	M		],
+			[	   mu			]	};
+    key <BKSL> {	[	 less,	greater		],
+			[ guillemotleft, guillemotright	]	};
+
+    key <SPCE> {	[	 space,	space		],
+			[ nobreakspace,	nobreakspace	]	};
+
+    key <LSGT> {	[	oslash,	Ooblique	],
+			[	   bar,	backslash	]	};
+
 };
Index: xc/programs/xkbcomp/symbols/ee
diff -u xc/programs/xkbcomp/symbols/ee:1.1 xc/programs/xkbcomp/symbols/ee:1.3
--- xc/programs/xkbcomp/symbols/ee:1.1	Mon Jan 24 19:09:02 2000
+++ xc/programs/xkbcomp/symbols/ee	Wed Nov  1 21:51:27 2000
@@ -1,4 +1,4 @@
-// $XFree86: xc/programs/xkbcomp/symbols/ee,v 1.1 2000/01/25 00:09:02 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/ee,v 1.3 2000/11/02 02:51:27 dawes Exp $
 // Estonian XKB-keymap by Ville Hallik <ville@linux.ee>
 
 partial default alphanumeric_keys 
@@ -6,7 +6,7 @@
 
     // Describes the differences between a very simple en_US
     // keyboard and a very simple Estonian keyboard
-    // This layout conforms to both EVS8:1993 and EVS8:1999 standards
+    // This layout conforms to both EVS8:1993 and EVS8:2000 standards
 
     name[Group1]= "Estonian";
 
@@ -28,7 +28,8 @@
 			[      braceright			]	};
     key <AE11> {	[            plus,        question      ],
 			[       backslash			]	};
-    key <AE12> {	[      dead_acute,      dead_grave	]	};
+    key <AE12> {	[      dead_acute,      dead_grave	],
+			[       quoteleft,      quoteright	]	};
     key <AD03> {	[               e,               E	],
 			[        EuroSign			]	};
     key <AD11> {	[      udiaeresis,      Udiaeresis     	]	};
@@ -41,8 +42,10 @@
 			[     asciicircum			]	};
     key <AB01> {	[               z,               Z	],
 			[          zcaron,          Zcaron	]	};
-    key <AB08> {	[           comma,       semicolon     	]	};
-    key <AB09> {	[          period,           colon     	]	};
+    key <AB08> {	[           comma,       semicolon     	],
+			[            less			]	};
+    key <AB09> {	[          period,           colon     	],
+			[	  greater			]	};
     key <AB10> {	[           minus,      underscore     	]	};
     key <BKSL> {	[      apostrophe,        asterisk	],
 			[	  onehalf			]	};
Index: xc/programs/xkbcomp/symbols/es
diff -u xc/programs/xkbcomp/symbols/es:3.3 xc/programs/xkbcomp/symbols/es:3.4
--- xc/programs/xkbcomp/symbols/es:3.3	Mon Dec 23 02:13:22 1996
+++ xc/programs/xkbcomp/symbols/es	Fri Oct 27 14:31:08 2000
@@ -1,5 +1,5 @@
 // $XConsortium: es /main/3 1996/08/31 12:19:38 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/es,v 3.3 1996/12/23 07:13:22 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/es,v 3.4 2000/10/27 18:31:08 dawes Exp $
 // Modified for a real Spanish Keyboard by Jon Tombs
 partial default alphanumeric_keys 
 xkb_symbols "basic" {
@@ -43,6 +43,8 @@
 			[      asciitilde,      asciitilde	]	};
     key <AD12> {	[            plus,        asterisk	],
 			[    bracketright,     dead_macron	]	};
+    key <AD03> {        [               e,               E      ],
+                        [        EuroSign,            cent      ]	};
 
     // End alphanumeric section
 
Index: xc/programs/xkbcomp/symbols/fi
diff -u xc/programs/xkbcomp/symbols/fi:3.4 xc/programs/xkbcomp/symbols/fi:3.5
--- xc/programs/xkbcomp/symbols/fi:3.4	Sat Dec 20 09:20:58 1997
+++ xc/programs/xkbcomp/symbols/fi	Fri Oct 27 14:31:09 2000
@@ -1,44 +1,76 @@
-// $XConsortium: fi /main/4 1996/09/13 09:23:11 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/fi,v 3.4 1997/12/20 14:20:58 hohndel Exp $
-partial default alphanumeric_keys 
-xkb_symbols "basic" {
-
-    // Describes the differences between a very simple en_US
-    // keyboard and a very simple Swedish(Finland) keybaord
-
-    name[Group1]= "Finnish";
-
-    key <TLDE> {	[         section,         onehalf      ]	};
-    key <AE02> {	[               2,        quotedbl     	],	
-			[	       at,	 oneeighth	]	};
-    key <AE04> {	[               4,        currency     	],	
-			[	   dollar,	    dollar	]	};
-    key <AE03> {	[               3,      numbersign 	],	
-			[        sterling,        sterling	]	};
-    key <AE06> {	[               6,       ampersand     	]	};
+// $XConsortium: fi /main/3 1996/08/31 12:19:29 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/fi,v 3.5 2000/10/27 18:31:09 dawes Exp $
+partial alphanumeric_keys 
+ xkb_symbols "basic" {
+ 
+     // Describes the differences between a very simple en_US
+    // keyboard and a Finnish keyboard with dead key support
+    // and all of ISO-8859-1 characters available.
+ 
+     name[Group1]= "Finnish";
+ 
+    key <TLDE> {	[         section,         onehalf      ],
+			[       paragraph,   threequarters      ]};
+    key <LSGT> {	[	     less,	   greater	],
+                 	[             bar,       brokenbar      ]};
+    key <SPCE> {	[	    space,	     space	],
+			[    nobreakspace,    nobreakspace	]};
+    key <AE01> {	[               1,          exclam  	],
+			[      exclamdown,     onesuperior	]};
+    key <AE02> {	[               2,        quotedbl  	],
+			[	       at,     twosuperior	]};
+    key <AE03> {	[              	3,	numbersign	],
+			[	 sterling,   threesuperior	]};
+    key <AE04> {	[               4,        currency     	],
+			[	   dollar,	onequarter	]};
+    key <AE05> {	[               5,         percent     	],
+			[        NoSymbol,	      cent	]};
+    key <AE06> {	[               6,       ampersand     	],
+			[	      yen,	  NoSymbol	]};
     key <AE07> {	[               7,           slash     	],
-			[	braceleft,	 braceleft	]	};
+			[       braceleft,        division	]};
     key <AE08> {	[               8,       parenleft     	],
-			[     bracketleft,     bracketleft	]	};
-    key <AB08> {	[           comma,       semicolon     	]	};
-    key <AE10> {	[               0,           equal     	],
-			[      braceright,      braceright	]	};
+			[     bracketleft,   guillemotleft	]};
     key <AE09> {	[               9,      parenright     	],
-			[    bracketright,    bracketright	]	};
-    key <AB09> {	[          period,           colon     	]	};
-    key <AB10> {	[           minus,      underscore     	]	};
-    key	<AC10> {	[      odiaeresis,      Odiaeresis     	]	};
+			[    bracketright,  guillemotright	]};
+    key <AE10> {	[               0,           equal     	],
+                        [      braceright,          degree      ]};
+    key <AB08> {	[           comma,       semicolon     	],
+			[    dead_cedilla,     dead_ogonek	]};
+    key <AB09> {	[          period,           colon     	],
+			[  periodcentered,   dead_abovedot	]};
+    key <AB03> {        [               c,               C      ],
+                        [       copyright,        NoSymbol      ]};
+    key <AB10> {	[           minus,      underscore     	],
+			[	   hyphen,          macron	]};
+    key <AC01> {        [               a,               A      ],
+                        [     ordfeminine,       masculine      ]};
+    key <AC03> {        [               d,               D      ],
+                        [             eth,             ETH      ]};
+    key <AD03> {        [               e,               E      ],
+                        [        EuroSign,            cent      ]};
+    key <AD04> {        [               r,               R      ],
+                        [      registered,        NoSymbol      ]};
+    key <AD05> {        [               t,               T      ],
+                        [           thorn,           THORN      ]};
+    key <AD08> {        [               i,               I      ],
+                        [        NoSymbol,        NoSymbol      ]};
+    key <AD09> {        [               o,               O      ],
+                        [              oe,              OE      ]};
+    key <AC10> {	[      odiaeresis,      Odiaeresis	],
+			[	   oslash,        Ooblique 	]};
     key <AE11> {	[            plus,        question      ],
-			[	backslash,	 backslash	]	};
-    key <AC11> {	[      adiaeresis,      Adiaeresis 	]	};
-    key <AD11> {	[	    aring,           Aring     	]	};
-    key <AE12> {	[      dead_acute,      dead_grave	]	};
-    key <AD12> {	[  dead_diaeresis, dead_circumflex     	],
-			[      dead_tilde,	dead_tilde	]	};
-    key <BKSL> {	[      apostrophe,        asterisk	]	};
-    key <LSGT> {	[	     less,	   greater	],
-			[	      bar,       brokenbar	]	};
-    key <KPDL> {	[	KP_Delete,    KP_Separator	]	};
+			[       backslash,    questiondown	]};
+    key	<AC11> {	[      adiaeresis,      Adiaeresis	],
+			[	       ae,	        AE	]};
+    key <BKSL> {	[      apostrophe,        asterisk	],
+                 	[           acute,        multiply      ]};
+    key <AD11> {	[	    aring,           Aring 	]};
+    key <AE12> {   	[      dead_acute,      dead_grave      ],
+			[	plusminus,         notsign	]};
+    key <AD12> {   	[  dead_diaeresis, dead_circumflex      ],
+                 	[      dead_tilde,      dead_caron      ]};
+
 
     // End alphanumeric section
 
@@ -64,3 +96,4 @@
 xkb_symbols "nodeadkeys" {
     include "fi(basic)"	// for consistent naming
 };
+ 
Index: xc/programs/xkbcomp/symbols/fr
diff -u xc/programs/xkbcomp/symbols/fr:3.4 xc/programs/xkbcomp/symbols/fr:3.5
--- xc/programs/xkbcomp/symbols/fr:3.4	Fri Mar 20 16:08:27 1998
+++ xc/programs/xkbcomp/symbols/fr	Fri Oct 27 14:31:09 2000
@@ -1,5 +1,5 @@
 // $XConsortium: fr /main/3 1996/08/31 12:19:45 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/fr,v 3.4 1998/03/20 21:08:27 hohndel Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/fr,v 3.5 2000/10/27 18:31:09 dawes Exp $
 partial default alphanumeric_keys 
 xkb_symbols "basic" {
 
@@ -36,6 +36,8 @@
 			[              ae,              AE	]	};
     key <AD02> {	[               z,               Z	],
 			[   guillemotleft,            less	]	};
+    key <AD03> {        [               e,               E      ],
+                        [        EuroSign,            cent      ]	};
     key <AD11> {	[ dead_circumflex,  dead_diaeresis	]	};
     key <AD12> {	[          dollar,        sterling	],
 			[        currency,     dead_macron	]	};
Index: xc/programs/xkbcomp/symbols/gr
diff -u /dev/null xc/programs/xkbcomp/symbols/gr:1.2
--- /dev/null	Mon Dec 18 14:35:15 2000
+++ xc/programs/xkbcomp/symbols/gr	Fri Oct 27 20:34:06 2000
@@ -0,0 +1,83 @@
+// $XConsortium: gr /main/3 1997/12/18 12:40:12 rch $
+//
+// $XFree86: xc/programs/xkbcomp/symbols/gr,v 1.2 2000/10/28 00:34:06 dawes Exp $
+
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Greek keyboard
+
+    name[Group1]= "US/ASCII";
+    name[Group2]= "Greek";
+
+    key	<LSGT> {	[	     less,	   greater	],
+			[	      bar,	 brokenbar	]	};
+
+    key <AD01> {        [         q,    Q               ],
+			[ semicolon,	colon		]       };
+    key <AD02> {        [         w,    W               ],
+			[ Greek_finalsmallsigma, dead_circumflex ]};
+    key <AD03> {        [         e,    E               ],
+			[ Greek_epsilon, Greek_EPSILON	]       };
+    key <AD04> {        [         r,    R               ],
+			[ Greek_rho, Greek_rho		]	};
+    key <AD05> {        [         t,    T               ],
+			[ Greek_tau, Greek_TAU		]       };
+    key <AD06> {        [         y,    Y               ],
+			[ Greek_upsilon, Greek_UPSILON	]       };
+    key <AD07> {        [         u,    U               ],
+			[ Greek_theta, Greek_THETA	]       };
+    key <AD08> {        [         i,    I               ],
+			[ Greek_iota, Greek_IOTA	]       };
+    key <AD09> {        [         o,    O               ],
+			[ Greek_omicron, Greek_OMICRON	]       };
+    key <AD10> {        [         p,    P               ],
+			[ Greek_pi, Greek_PI		]       };
+
+    key <AC01> {        [         a,    A               ],
+			[ Greek_alpha, Greek_ALPHA	]       };
+    key <AC02> {        [         s,    S               ],
+			[ Greek_sigma, Greek_SIGMA	]       };
+    key <AC03> {        [         d,    D               ],
+			[ Greek_delta, Greek_DELTA	]       };
+    key <AC04> {        [         f,    F               ],
+			[ Greek_phi, Greek_PHI		]       };
+    key <AC05> {        [         g,    G               ],
+			[ Greek_gamma, Greek_GAMMA	]       };
+    key <AC06> {        [         h,    H               ],
+			[ Greek_eta, Greek_ETA		]       };
+    key <AC07> {        [         j,    J               ],
+			[ Greek_xi, Greek_XI		]       };
+    key <AC08> {        [         k,    K               ],
+			[ Greek_kappa, Greek_KAPPA	]       };
+    key <AC09> {        [         l,    L               ],
+			[ Greek_lamda, Greek_LAMDA	]       };
+    key <AC10> {        [ semicolon,    colon           ],
+			[ dead_acute,  dead_diaeresis	]       };
+    key <AC11> {        [ apostrophe,   quotedbl        ]       };
+
+    key <AB01> {        [         z,    Z               ],
+			[ Greek_zeta, Greek_ZETA	]       };
+    key <AB02> {        [         x,    X               ],
+			[ Greek_chi, Greek_CHI		]       };
+    key <AB03> {        [         c,    C               ],
+			[ Greek_psi, Greek_PSI		]       };
+    key <AB04> {        [         v,    V               ],
+			[ Greek_omega, Greek_OMEGA	]       };
+    key <AB05> {        [         b,    B               ],
+			[ Greek_beta, Greek_BETA	]       };
+    key <AB06> {        [         n,    N               ],
+			[ Greek_nu, Greek_NU		]       };
+    key <AB07> {        [         m,    M               ],
+			[ Greek_mu, Greek_MU		]       };
+    
+    // Begin modifier mappings 
+
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock, ISO_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+
Index: xc/programs/xkbcomp/symbols/group
diff -u xc/programs/xkbcomp/symbols/group:3.1 xc/programs/xkbcomp/symbols/group:3.4
--- xc/programs/xkbcomp/symbols/group:3.1	Sun Jun 22 05:53:19 1997
+++ xc/programs/xkbcomp/symbols/group	Mon Nov  6 14:24:10 2000
@@ -1,6 +1,8 @@
 // $TOG: group /main/3 1997/06/13 06:25:02 kaleb $
 // using the group(switch) map, the right alt key temporarily chooses 
 // the second keyboard group (until it is released).
+//
+// $XFree86: xc/programs/xkbcomp/symbols/group,v 3.4 2000/11/06 19:24:10 dawes Exp $
 partial modifier_keys 
 xkb_symbols "switch" {
     key <RALT>	{ 	
@@ -65,12 +67,12 @@
     virtual_modifiers Alt;
     key <LALT> {
 	type="PC_BREAK",
-	symbols[Group1]= [ Alt_L,	ISO_Prev_Group ],
+	symbols[Group1]= [ NoSymbol,	ISO_Prev_Group ],
 	virtualMods= Alt
     };
     key <RALT> {
 	type="PC_BREAK",
-	symbols[Group1]= [ Alt_R,	ISO_Next_Group ],
+	symbols[Group1]= [ NoSymbol,	ISO_Next_Group ],
 	virtualMods= Alt
     };
     key <LCTL> {
@@ -81,4 +83,38 @@
 	type="PC_SYSRQ",
 	symbols[Group1]= [ Control_R,	ISO_Next_Group ]
     };
+};
+
+// using the group(alt_shift_toggle) map, pressing:
+//     Shift_L+Alt_L locks the previous group
+//     Shift_R+Alt_R locks the next group
+// If you have two groups and group wrap is enabled, the effect is
+// indistinguishable.
+partial modifier_keys 
+xkb_symbols "alt_shift_toggle" {
+    virtual_modifiers Alt;
+    key <LALT> {
+	symbols[Group1]= [ NoSymbol,	ISO_Prev_Group ],
+	virtualMods= Alt
+    };
+    key <RALT> {
+	symbols[Group1]= [ NoSymbol,	ISO_Next_Group ],
+	virtualMods= Alt
+    };
+    key <LFSH> {
+	type="PC_SYSRQ",
+	symbols[Group1]= [ Shift_L,	ISO_Prev_Group ]
+    };
+    key <RTSH> {
+	type="PC_SYSRQ",
+	symbols[Group1]= [ Shift_R,	ISO_Next_Group ]
+    };
+};
+
+// using the group(menu_toggle) map, pressing:
+//     Menu key toggles groups
+//     Shift+Menu acts as Menu
+partial modifier_keys
+xkb_symbols "menu_toggle" {
+    key	<MENU> {	[  ISO_Next_Group,	 Menu	]	};
 };
Index: xc/programs/xkbcomp/symbols/hu
diff -u xc/programs/xkbcomp/symbols/hu:1.2 xc/programs/xkbcomp/symbols/hu:1.3
--- xc/programs/xkbcomp/symbols/hu:1.2	Sun Jun 22 05:53:19 1997
+++ xc/programs/xkbcomp/symbols/hu	Mon Aug 28 11:29:24 2000
@@ -1,10 +1,14 @@
-// $XFree86: xc/programs/xkbcomp/symbols/hu,v 1.2 1997/06/22 09:53:19 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/hu,v 1.3 2000/08/28 15:29:24 dawes Exp $
 
 default partial alphanumeric_keys 
 xkb_symbols "basic" {
 
     // Describes the differences between a very simple US/ASCII
-    // keyboard and a very simple Hungarian keybaord
+    // keyboard and a very simple Hungarian keybaord using the
+    // (recommended) Hungarian locale (hu_HU).
+    // You have to set your locale settings (at least LC_CTYPE)
+    // to hu_HU. If you have to use another locale (eg. us) try
+    // the hu_US xkb file.
     // Peter Soos <sp@osb.hu>
 
     // Alphanumeric section
@@ -43,10 +47,10 @@
     key <AD06> {        [         z,    Z               ]       };
     key <AD08> {        [         i,    I               ],
                         [    Iacute                     ]       };
-//    key <AD11> {      [ odoubleacute, Odoubleacute    ],
-//                      [  division                     ]       };
-    key <AD11> {        [    otilde,    Otilde          ],
-                        [  division                     ]       };
+    key <AD11> {      [ odoubleacute, Odoubleacute    ],
+                      [  division                     ]       };
+//    key <AD11> {        [    otilde,    Otilde          ],
+//                        [  division                     ]       };
     key <AD12> {        [    uacute,    Uacute          ],
                         [  multiply                     ]       };
 
@@ -88,10 +92,10 @@
     key <AB09> {        [    period,    colon           ]       };
     key <AB10> {        [     minus,    underscore      ],
                         [  asterisk                     ]       };
-    key <BKSL> {        [ ucircumflex,  Ucircumflex     ],
-                        [  currency                     ]       };
-//    key <BKSL> {      [ udoubleacute, Udoubleacute    ],
-//                      [  currency                     ]       };
+//    key <BKSL> {        [ ucircumflex,  Ucircumflex     ],
+//                        [  currency                     ]       };
+    key <BKSL> {      [ udoubleacute, Udoubleacute    ],
+                      [  currency                     ]       };
     key <RALT> {        [  Mode_switch, Multi_key       ]       };
     key <LALT> {        [        Alt_L, Meta_L          ]       };
 
Index: xc/programs/xkbcomp/symbols/hu_US
diff -u /dev/null xc/programs/xkbcomp/symbols/hu_US:1.1
--- /dev/null	Mon Dec 18 14:35:17 2000
+++ xc/programs/xkbcomp/symbols/hu_US	Mon Aug 28 11:29:24 2000
@@ -0,0 +1,150 @@
+// $XFree86: xc/programs/xkbcomp/symbols/hu_US,v 1.1 2000/08/28 15:29:24 dawes Exp $
+
+default partial alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple Hungarian keybaord used with
+    // us or another ISO-8859-1 based locale settings.
+    // If you use the standard Hungarian locale (hu_HU) use the hu
+    // xkb file instead.
+    // Peter Soos <sp@osb.hu>
+
+    // Alphanumeric section
+    name[Group1]= "Hungarian";
+    key <TLDE> {        [         0,    section         ],
+                        [   notsign                     ]       };
+    key <AE01> {        [         1,    apostrophe      ],
+                        [ asciitilde,   dead_tilde      ]       };
+    key <AE02> {        [         2,    quotedbl        ],
+                        [     caron,    dead_caron      ]       };
+    key <AE03> {        [         3,    plus            ],
+                        [ asciicircum,  dead_circumflex ]       };
+    key <AE04> {        [         4,    exclam          ],
+                        [     breve,    dead_breve      ]       };
+    key <AE05> {        [         5,    percent         ],
+                        [    degree,    dead_abovering  ]       };
+    key <AE06> {        [         6,    slash           ],
+                        [    ogonek,    dead_ogonek     ]       };
+    key <AE07> {        [         7,    equal           ],
+                        [     grave,    dead_grave      ]       };
+    key <AE08> {        [         8,    parenleft       ],
+                        [  abovedot,    dead_abovedot   ]       };
+    key <AE09> {        [         9,    parenright      ],
+                        [     acute,    dead_acute      ]       };
+    key <AE10> {        [ odiaeresis,   Odiaeresis      ],
+                        [ doubleacute,  dead_doubleacute ]       };
+    key <AE11> {        [ udiaeresis,   Udiaeresis      ],
+                        [   diaeresis,  dead_diaeresis  ]       };
+    key <AE12> {        [    oacute,    Oacute          ],
+                        [   cedilla,    dead_cedilla    ]       };
+
+    key <AD01> {        [         q,    Q               ],
+                        [ backslash                     ]       };
+    key <AD02> {        [         w,    W               ],
+                        [       bar                     ]       };
+    key <AD06> {        [         z,    Z               ]       };
+    key <AD08> {        [         i,    I               ],
+                        [    Iacute                     ]       };
+//    key <AD11> {      [ odoubleacute, Odoubleacute    ],
+//                      [  division                     ]       };
+    key <AD11> {        [    otilde,    Otilde          ],
+                        [  division                     ]       };
+    key <AD12> {        [    uacute,    Uacute          ],
+                        [  multiply                     ]       };
+
+    key <AC02> {        [         s,    S               ],
+                        [   dstroke                     ]       };
+    key <AC03> {        [         d,    D               ],
+                        [   Dstroke                     ]       };
+    key <AC04> {        [         f,    F               ],
+                        [ bracketleft                   ]       };
+    key <AC05> {        [         g,    G               ],
+                        [ bracketright                  ]       };
+    key <AC07> {        [         j,    J               ],
+                        [    iacute                     ]       };
+    key <AC08> {        [         k,    K               ],
+                        [   lstroke                     ]       };
+    key <AC09> {        [         l,    L               ],
+                        [   Lstroke                     ]       };
+    key <AC10> {        [    eacute,    Eacute          ],
+                        [    dollar                     ]       };
+    key <AC11> {        [    aacute,    Aacute          ],
+                        [    ssharp                     ]       };
+
+    key <LSGT> {        [    iacute,    Iacute          ],
+                        [      less                     ]       };
+    key <AB01> {        [         y,    Y               ],
+                        [   greater                     ]       };
+    key <AB02> {        [         x,    X               ],
+                        [ numbersign                    ]       };
+    key <AB03> {        [         c,    C               ],
+                        [ ampersand                     ]       };
+    key <AB04> {        [         v,    V               ],
+                        [        at                     ]       };
+    key <AB05> {        [         b,    B               ],
+                        [ braceleft                     ]       };
+    key <AB06> {        [         n,    N               ],
+                        [ braceright                    ]       };
+    key <AB08> {        [     comma,    question        ],
+                        [ semicolon                     ]       };
+    key <AB09> {        [    period,    colon           ]       };
+    key <AB10> {        [     minus,    underscore      ],
+                        [  asterisk                     ]       };
+    key <BKSL> {        [ ucircumflex,  Ucircumflex     ],
+                        [  currency                     ]       };
+//    key <BKSL> {      [ udoubleacute, Udoubleacute    ],
+//                      [  currency                     ]       };
+    key <RALT> {        [  Mode_switch, Multi_key       ]       };
+    key <LALT> {        [        Alt_L, Meta_L          ]       };
+
+    // End alphanumeric section
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+partial alphanumeric_keys
+xkb_symbols "Sundeadkeys" {
+    include "hu(basic)" // for consistent naming
+};
+
+partial alphanumeric_keys
+xkb_symbols "sundeadkeys" {
+    include "hu(Sundeadkeys)" // for consistent naming
+};
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    // modify the default Hungarian layout to not have any dead keys
+    include "hu(basic)"
+    key <AE01> {        [         1,    apostrophe      ],
+                        [ asciitilde                    ]       };
+    key <AE02> {        [         2,    quotedbl        ],
+                        [     caron                     ]       };
+    key <AE03> {        [         3,    plus            ],
+                        [ asciicircum                   ]       };
+    key <AE04> {        [         4,    exclam          ],
+                        [     breve                     ]       };
+    key <AE05> {        [         5,    percent         ],
+                        [    degree                     ]       };
+    key <AE06> {        [         6,    slash           ],
+                        [    ogonek                     ]       };
+    key <AE07> {        [         7,    equal           ],
+                        [     grave                     ]       };
+    key <AE08> {        [         8,    parenleft       ],
+                        [  abovedot                     ]       };
+    key <AE09> {        [         9,    parenright      ],
+                        [     acute                     ]       };
+    key <AE10> {        [ odiaeresis,   Odiaeresis      ],
+                        [ doubleacute                   ]       };
+    key <AE11> {        [ udiaeresis,   Udiaeresis      ],
+                        [ diaeresis                     ]       };
+    key <AE12> {        [    oacute,    Oacute          ],
+                        [   cedilla                     ]       };
+
+};
+
Index: xc/programs/xkbcomp/symbols/il
diff -u /dev/null xc/programs/xkbcomp/symbols/il:1.2
--- /dev/null	Mon Dec 18 14:35:17 2000
+++ xc/programs/xkbcomp/symbols/il	Fri Oct 27 20:34:06 2000
@@ -0,0 +1,93 @@
+// $XConsortium: il /main/3 1997/12/18 12:40:12 rch $
+//
+// $XFree86: xc/programs/xkbcomp/symbols/il,v 1.2 2000/10/28 00:34:06 dawes Exp $
+
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Israelian keyboard
+
+    // uses the kbd layout in use in Israel
+
+    name[Group1]= "US/ASCII";
+    name[Group2]= "Israelian";
+
+
+    key <TLDE> {        [     grave,   asciitilde       ],
+			[ semicolon,   asciitilde	]	};
+
+    key <AD01> {        [         q,    Q               ],
+			[     slash,     Q		]	};
+    key <AD02> {        [         w,    W               ],
+			[apostrophe,     W		]	};
+    key <AD03> {        [         e,    E               ],
+			[ hebrew_qoph,  E		]       };
+    key <AD04> {        [         r,    R               ],
+			[ hebrew_resh,  R		]	};
+    key <AD05> {        [         t,    T               ],
+			[ hebrew_aleph, T		]       };
+    key <AD06> {        [         y,    Y               ],
+			[ hebrew_tet,   Y		]       };
+    key <AD07> {        [         u,    U               ],
+			[ hebrew_waw,   U		]       };
+    key <AD08> {        [         i,    I               ],
+			[ hebrew_finalnun, I		]       };
+    key <AD09> {        [         o,    O               ],
+			[ hebrew_finalmem, O		]       };
+    key <AD10> {        [         p,    P               ],
+			[ hebrew_pe,    P		]	};
+
+    key <AC01> {        [         a,    A               ],
+			[ hebrew_shin,  A		]	};
+    key <AC02> {        [         s,    S               ],
+			[ hebrew_dalet, S		]       };
+    key <AC03> {        [         d,    D               ],
+			[ hebrew_gimel, D		]       };
+    key <AC04> {        [         f,    F               ],
+			[ hebrew_kaph,  F		]	};
+    key <AC05> {        [         g,    G               ],
+			[ hebrew_ayin,  G		]       };
+    key <AC06> {        [         h,    H               ],
+			[ hebrew_yod,   H		]       };
+    key <AC07> {        [         j,    J               ],
+			[ hebrew_chet,  J		]	};
+    key <AC08> {        [         k,    K               ],
+			[ hebrew_lamed, K		]	};
+    key <AC09> {        [         l,    L               ],
+			[ hebrew_finalkaph, L		]       };
+    key <AC10> {        [ semicolon,    colon           ],
+			[ hebrew_finalpe, colon		]       };
+    key <AC11> {        [ apostrophe,   quotedbl        ],
+			[     comma,    quotedbl	]	};
+
+    key <AB01> {        [         z,    Z               ],
+			[ hebrew_zain,  Z		]       };
+    key <AB02> {        [         x,    X               ],
+			[ hebrew_samech, X		]       };
+    key <AB03> {        [         c,    C               ],
+			[ hebrew_bet,   C		]       };
+    key <AB04> {        [         v,    V               ],
+			[ hebrew_he,    V		]       };
+    key <AB05> {        [         b,    B               ],
+			[ hebrew_nun,   B		]       };
+    key <AB06> {        [         n,    N               ],
+			[ hebrew_mem,   N		]	};
+    key <AB07> {        [         m,    M               ],
+			[ hebrew_zade,  M		]	};
+    key <AB08> {        [     comma,    less            ],
+			[ hebrew_taw,   less		]	};
+    key <AB09> {        [    period,    greater         ],
+			[ hebrew_finalzade,  greater	]	};
+    key <AB10> {        [     slash,    question        ],
+			[    period,    question	]	};
+    
+    // Begin modifier mappings 
+
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock, ISO_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+
Index: xc/programs/xkbcomp/symbols/il_phonetic
diff -u /dev/null xc/programs/xkbcomp/symbols/il_phonetic:1.2
--- /dev/null	Mon Dec 18 14:35:18 2000
+++ xc/programs/xkbcomp/symbols/il_phonetic	Fri Oct 27 20:34:07 2000
@@ -0,0 +1,83 @@
+// $XConsortium: il_phonetic /main/3 1997/12/18 12:40:12 rch $
+//
+// $XFree86: xc/programs/xkbcomp/symbols/il_phonetic,v 1.2 2000/10/28 00:34:07 dawes Exp $
+
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Israelian keyboard
+
+    // uses the phonetic layout from old Slackware 'il.map' file
+
+    name[Group1]= "US/ASCII";
+    name[Group2]= "Israelian";
+
+
+    key <AE12> {        [     equal,    plus            ],
+			[ hebrew_doublelowline, hebrew_doublelowline ]};
+
+    key <AD01> {        [         q,    Q               ],
+			[ hebrew_qoph, hebrew_qoph	]	};
+    key <AD02> {        [         w,    W               ],
+			[ hebrew_waw, hebrew_waw	]	};
+    key <AD03> {        [         e,    E               ],
+			[ hebrew_aleph, hebrew_aleph	]       };
+    key <AD04> {        [         r,    R               ],
+			[ hebrew_resh, hebrew_resh	]	};
+    key <AD05> {        [         t,    T               ],
+			[ hebrew_taw, hebrew_tet	]       };
+    key <AD06> {        [         y,    Y               ],
+			[ hebrew_ayin, hebrew_ayin	]       };
+    key <AD07> {        [         u,    U               ],
+			[ hebrew_waw, hebrew_waw	]       };
+    key <AD08> {        [         i,    I               ],
+			[ hebrew_yod, hebrew_yod	]       };
+    key <AD09> {        [         o,    O               ],
+			[ hebrew_samech, hebrew_samech	]       };
+    key <AD10> {        [         p,    P               ],
+			[ hebrew_pe, hebrew_finalpe	]	};
+
+    key <AC01> {        [         a,    A               ],
+			[ hebrew_aleph, hebrew_aleph	]	};
+    key <AC02> {        [         s,    S               ],
+			[ hebrew_shin, hebrew_shin	]       };
+    key <AC03> {        [         d,    D               ],
+			[ hebrew_dalet, hebrew_dalet	]       };
+    key <AC04> {        [         f,    F               ],
+			[ hebrew_pe, hebrew_finalpe	]	};
+    key <AC05> {        [         g,    G               ],
+			[ hebrew_gimel, hebrew_gimel	]       };
+    key <AC06> {        [         h,    H               ],
+			[ hebrew_he, hebrew_he		]       };
+    key <AC07> {        [         j,    J               ],
+			[ hebrew_yod, hebrew_yod	]	};
+    key <AC08> {        [         k,    K               ],
+			[ hebrew_kaph, hebrew_finalkaph	]	};
+    key <AC09> {        [         l,    L               ],
+			[ hebrew_lamed, hebrew_lamed	]       };
+
+    key <AB01> {        [         z,    Z               ],
+			[ hebrew_zain, hebrew_zain	]       };
+    key <AB02> {        [         x,    X               ],
+			[ hebrew_chet, hebrew_chet	]       };
+    key <AB03> {        [         c,    C               ],
+			[ hebrew_zade, hebrew_finalzade	]       };
+    key <AB04> {        [         v,    V               ],
+			[ hebrew_waw, hebrew_waw	]       };
+    key <AB05> {        [         b,    B               ],
+			[ hebrew_bet, hebrew_bet	]       };
+    key <AB06> {        [         n,    N               ],
+			[ hebrew_nun, hebrew_finalnun	]	};
+    key <AB07> {        [         m,    M               ],
+			[ hebrew_mem, hebrew_finalmem	]	};
+    
+    // Begin modifier mappings 
+
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock, ISO_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+
Index: xc/programs/xkbcomp/symbols/inet
diff -u xc/programs/xkbcomp/symbols/inet:1.5 xc/programs/xkbcomp/symbols/inet:1.8
--- xc/programs/xkbcomp/symbols/inet:1.5	Fri Jun 16 20:27:35 2000
+++ xc/programs/xkbcomp/symbols/inet	Fri Dec  1 20:16:26 2000
@@ -1,4 +1,4 @@
-// $XFree86: xc/programs/xkbcomp/symbols/inet,v 1.5 2000/06/17 00:27:35 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/inet,v 1.8 2000/12/02 01:16:26 dawes Exp $
 
 partial alphanumeric_keys 
 xkb_symbols "hp" {
@@ -49,11 +49,31 @@
     key <I66>	{	[ XF86Start		]	};
 };
 
+partial alphanumeric_keys
+xkb_symbols "logicordless" {
+ 
+    // Describes the extra keys on a Logitech Desktop Pro keyboard.
+ 
+    name[Group1]= "CordLess";
+    key <I5F>   {   [ XF86Standby       ]   };
+    key <I20>   {   [ XF86AudioMute     ]   };
+    key <I2E>   {   [ XF86AudioLowerVolume  ]   };
+    key <I30>   {   [ XF86AudioRaiseVolume  ]   };
+    key <I22>   {   [ XF86AudioPlay     ]   };
+    key <I24>   {   [ XF86AudioStop     ]   };
+    key <I10>   {   [ XF86AudioPrev     ]   };
+    key <I19>   {   [ XF86AudioNext     ]   };
+    key <I32>   {   [ XF86HomePage      ]   };
+    key <I6C>   {   [ XF86Mail      ]   };
+    key <I65>   {   [ XF86Search        ]   };
+    key <I66>   {   [ XF86Start     ]   };
+};
+
 
 partial alphanumeric_keys 
 xkb_symbols "microsoftpro" {
 
-    // Describes the extra keys on a Microsoft Natrual Keyboard Pro
+    // Describes the extra keys on a Microsoft Natural Keyboard Pro
 
     name[Group1]= "MicrosoftPro";
     key <I6A>	{	[ XF86Back		]	};
@@ -73,7 +93,30 @@
     key <I19>	{	[ XF86AudioNext		]	};
     key <I6D>	{	[ XF86AudioMedia	]	};
     key <I6B>	{	[ XF86MyComputer	]	};
+    key <I21>	{	[ XF86Calculator	]	};
     key <I5F>	{	[ XF86Standby		]	};
 };
 
+xkb_symbols "btc9000" {
+    // from <supercava@libero.it>
+    // Describes the extra keys on a BTC model 9000 keyboard
+    // found in many computers sold by Computer Discount 
+    name[Group1]= "btc9000";
+    key <I26>	{	[ XF86Refresh		]	};
+    key <I32>	{	[ XF86Search		]	};
+    key <I20>	{	[ XF86Favorites		]	};
+    key <I30>	{	[ XF86HomePage		]	};
+    key <I2E>	{	[ XF86Mail		]	};
+    key <I12>	{	[ XF86AudioMute		]	};
+    key <I25>	{	[ XF86AudioLowerVolume	]	};
+    key <I1E>	{	[ XF86AudioRaiseVolume	]	};
+    key <I19>	{	[ XF86AudioPlay, XF86AudioPause		]	};
+    key <I10>	{	[ XF86AudioStop		]	};
+    key <I22>	{	[ XF86AudioPrev		]	};
+    key <I24>	{	[ XF86AudioNext		]	};
+    key <I21>	{	[ XF86AudioMedia	]	};
+    key <I5F>	{	[ XF86Standby		]	};
+    key <I5E>   {	[ XF86PowerOff		]	};
+    key <I63>   {	[ XF86WakeUp		]	};
+};
 
Index: xc/programs/xkbcomp/symbols/is
diff -u xc/programs/xkbcomp/symbols/is:3.1 xc/programs/xkbcomp/symbols/is:3.4
--- xc/programs/xkbcomp/symbols/is:3.1	Sun Oct 26 08:25:39 1997
+++ xc/programs/xkbcomp/symbols/is	Fri Oct 27 14:31:09 2000
@@ -1,5 +1,6 @@
 // $TOG: is /main/1 1997/08/27 15:27:24 kaleb $
 // XKB keyboard by Hrafnkell Eiriksson - hkelle@rhi.hi.is
+// $XFree86: xc/programs/xkbcomp/symbols/is,v 3.4 2000/10/27 18:31:09 dawes Exp $
 
 default partial alphanumeric_keys 
 xkb_symbols "default" {
@@ -35,6 +36,8 @@
 			[ ccedilla			]	};
     key <AD01> {	[	  q,	Q 		],
 			[	 at			]	};
+    key <AD03> {        [         e,    E		],
+                        [  EuroSign,    cent		]	};
 //    key <AD05> {	[	  t,	T		]	};
 //    key <AD06> {	[	  z,	Z		]	};
 //    key <AD07> {	[	  u,	U		]	};
@@ -46,7 +49,7 @@
 //    key <AC04> {	[	  f,	F		]	};
 //    key <AC05> {	[	  g,	G		]	};
     key <AC10> {	[ ae,			AE	],
-			[ circumflex			]	};
+			[ asciircum			]	};
     key <AC11> {	[ dead_acute,	Adiaeresis	],
 			[ dead_circumflex		]	};
 
Index: xc/programs/xkbcomp/symbols/it
diff -u xc/programs/xkbcomp/symbols/it:3.3 xc/programs/xkbcomp/symbols/it:3.4
--- xc/programs/xkbcomp/symbols/it:3.3	Mon Dec 23 02:13:27 1996
+++ xc/programs/xkbcomp/symbols/it	Fri Oct 27 14:31:09 2000
@@ -1,5 +1,5 @@
 // $XConsortium: it /main/3 1996/08/31 12:19:59 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/it,v 3.3 1996/12/23 07:13:27 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/it,v 3.4 2000/10/27 18:31:09 dawes Exp $
 partial default alphanumeric_keys 
 xkb_symbols "basic" {
 
@@ -34,6 +34,8 @@
     key <LSGT> {	[	    less,        greater	],
 			[	     bar,	brokenbar	]	};
     key <BKSL> {	[          ugrave,         section	]	};
+    key <AD03> {        [               e,               E      ],
+                        [        EuroSign,            cent      ]	};
 
     // End alphanumeric section
 
Index: xc/programs/xkbcomp/symbols/lock
diff -u xc/programs/xkbcomp/symbols/lock:3.1 xc/programs/xkbcomp/symbols/lock:3.3
--- xc/programs/xkbcomp/symbols/lock:3.1	Sun Jun 22 05:53:20 1997
+++ xc/programs/xkbcomp/symbols/lock	Thu Aug  3 08:24:03 2000
@@ -1,4 +1,5 @@
 // $TOG: lock /main/2 1997/06/13 06:25:10 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/lock,v 3.3 2000/08/03 12:24:03 dawes Exp $
 
 partial hidden modifier_keys
 xkb_symbols "shift" {
@@ -8,7 +9,7 @@
 partial hidden modifier_keys
 xkb_symbols "caps" {
     key <CAPS> {	[	Caps_Lock		]	};
-    modifier_map Lock { Caps_Lock }
+    modifier_map Lock { Caps_Lock };
 };
 partial hidden modifier_keys
 xkb_symbols "group" {
Index: xc/programs/xkbcomp/symbols/lt
diff -u xc/programs/xkbcomp/symbols/lt:1.2 xc/programs/xkbcomp/symbols/lt:1.5
--- xc/programs/xkbcomp/symbols/lt:1.2	Tue Apr  4 15:25:29 2000
+++ xc/programs/xkbcomp/symbols/lt	Tue Nov 28 14:09:36 2000
@@ -1,39 +1,23 @@
-// $XFree86: xc/programs/xkbcomp/symbols/lt,v 1.2 2000/04/04 19:25:29 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/lt,v 1.5 2000/11/28 19:09:36 dawes Exp $
+// Lithuanian keyboard map by Rièardas Èepas <rch@richard.eu.org>
 
-partial alphanumeric_keys modifier_keys 
+// Describes popular Lithuanian keymap 'Baltic' aka querty/numeric
+// Don't rename this file because it includes 'lt'
+// Extensions:  „ “ instead of 9 0 in Lithuanian mode, endash/Euro on 102nd key
+//  Usage:  setxkbmap -option grp:shift_toggle 'lt'
+//   # +lt(left_switch) turns key between left ctrl and shift on "German" keyboards into AltGr
+// Option	"XkbModel"	"pc105"
+// Option	"XkbLayout"	"lt+lt(left_switch)"
+//   # Double shift toggles between numbers and Lithuanian letters, you may choose other keys
+// Option	"XkbOptions"	"grp:shift_toggle"
+
+partial default alphanumeric_keys modifier_keys 
 xkb_symbols "basic" {
 
-    // Describes the differences between a very simple en_US
-    // keyboard and a very simple Lithuanian keyboard
-    // RiÄ�ardas ÄŒepas <rch@richard.eu.org>
-    //  Usage: put these commands in `XF86Config' file
-    // and remove other Xkb* commands:
-
-    // # XFree86 4.x syntax:
-    //  Section "InputDevice"
-    //  	Identifier  "Keyboard0"
-    //  	Driver      "keyboard"
-    //  	Option	"XkbRules"        "xfree86"
-    //  	Option	"XkbModel"        "pc102"
-    //   # +lt(left_switch) turns key between left ctrl and shift on "German" keyboards into AltGr
-    //  	Option	"XkbLayout"       "lt+lt(left_switch)"
-    //  	Option	"XkbOptions"      "grp:shift_toggle"
-    //  EndSection
-    //
-    // # XFree86 3.x syntax:
-    //  Section "Keyboard"
-    //...
-    //     XkbRules        "xfree86"
-    //     XkbModel        "pc102"
-    // # +lt(left_switch) turns key between left ctrl and shift on "German" keyboards into AltGr
-    //     XkbLayout       "lt+lt(left_switch)"
-    //     XkbOptions      "grp:ctrl_shift_toggle"
-    //  EndSection
-    //  
     name[Group1]= "US/ASCII";
     name[Group2]= "Lithuanian";
+    include "lt(us_group2)"
 
-    key	<TLDE> {	[], [	    grave,	asciitilde	]	};
     key	<AE01> {	[		1,	    exclam	],
 			[	  aogonek,	   Aogonek	]	};
     key	<AE02> {	[		2,		at	],
@@ -53,45 +37,13 @@
     key	<AE09> {	[		9,	 parenleft	],
 			[ doublelowquotemark,    parenleft	]	};
     key	<AE10> {	[		0,	parenright	],
+// this is actually right quote for Lithuanian
 			[ leftdoublequotemark,  parenright	]	};
-    key	<AE11> {	[], [	    minus,	underscore	]	};
+
     key	<AE12> {	[	    equal,	      plus	],
 			[	   zcaron,	    Zcaron	]	};
-    key	<AD01> {	[], [		q,		 Q	]	};
-    key	<AD02> {	[], [		w,		 W	]	};
-    key	<AD03> {	[], [		e,		 E	]	};
-    key	<AD04> {	[], [		r,		 R	]	};
-    key	<AD05> {	[], [		t,		 T	]	};
-    key	<AD06> {	[], [		y,		 Y	]	};
-    key	<AD07> {	[], [		u,		 U	]	};
-    key	<AD08> {	[], [		i,		 I	]	};
-    key	<AD09> {	[], [		o,		 O	]	};
-    key	<AD10> {	[], [		p,		 P	]	};
-    key	<AD11> {	[], [     bracketleft,	 braceleft	]	};
-    key	<AD12> {	[], [    bracketright,	braceright	]	};
-    key <RTRN> {	[	   Return,  ISO_Next_Group	]	};
-    key	<AC01> {	[], [		a,		 A	]	};
-    key	<AC02> {	[], [		s,		 S	]	};
-    key	<AC03> {	[], [		d,		 D	]	};
-    key	<AC04> {	[], [		f,		 F	]	};
-    key	<AC05> {	[], [		g,		 G	]	};
-    key	<AC06> {	[], [		h,		 H	]	};
-    key	<AC07> {	[], [		j,		 J	]	};
-    key	<AC08> {	[], [		k,		 K	]	};
-    key	<AC09> {	[], [		l,		 L	]	};
-    key	<AC10> {	[], [	semicolon,	     colon	]	};
-    key	<AC11> {	[], [      apostrophe,	  quotedbl	]	};
-    key	<AB01> {	[], [		z,		 Z	]	};
-    key	<AB02> {	[], [		x,		 X	]	};
-    key	<AB03> {	[], [		c,		 C	]	};
-    key	<AB04> {	[], [		v,		 V	]	};
-    key	<AB05> {	[], [		b,		 B	]	};
-    key	<AB06> {	[], [		n,		 N	]	};
-    key	<AB07> {	[], [		m,		 M	]	};
-    key	<AB08> {	[], [	    comma,	      less	]	};
-    key	<AB09> {	[], [	   period,	   greater	]	};
-    key	<AB10> {	[], [	    slash,	  question	]	};
-    key	<BKSL> {	[], [	backslash,             bar	]	};
+    key	<LSGT> {	[	   endash,	  EuroSign 	],
+			[	   endash,	  EuroSign 	]	};
 
     // End alphanumeric section
     
@@ -103,20 +55,65 @@
     modifier_map Mod3   { Mode_switch };
 };
 
-xkb_symbols "generic101" {
-    include "lt(basic)"
-};
+partial alphanumeric_keys 
+xkb_symbols "us_group2" {
 
-xkb_symbols "pc101" {
-    include "lt(generic101)"
-};
+    // Keyboard must work as usual when "Lithuanian" group is locked.
+    key <TLDE> {	[], [ quoteleft,	asciitilde	]	};
+    key <AE01> {	[], [	  1,	exclam 		]	};
+    key <AE02> {	[], [	  2,	at		]	};
+    key <AE03> {	[], [	  3,	numbersign	]	};
+    key <AE04> {	[], [	  4,	dollar		]	};
+    key <AE05> {	[], [	  5,	percent		]	};
+    key <AE06> {	[], [	  6,	asciicircum	]	};
+    key <AE07> {	[], [	  7,	ampersand	]	};
+    key <AE08> {	[], [	  8,	asterisk	]	};
+    key <AE09> {	[], [	  9,	parenleft	]	};
+    key <AE10> {	[], [	  0,	parenright	]	};
+    key <AE11> {	[], [     minus,	underscore	]	};
+    key <AE12> {	[], [     equal,	plus		]	};
+
+    key <AD01> {	[], [	  q,	Q 		]	};
+    key <AD02> {	[], [	  w,	W		]	};
+    key <AD03> {	[], [	  e,	E		]	};
+    key <AD04> {	[], [	  r,	R		]	};
+    key <AD05> {	[], [	  t,	T		]	};
+    key <AD06> {	[], [	  y,	Y		]	};
+    key <AD07> {	[], [	  u,	U		]	};
+    key <AD08> {	[], [	  i,	I		]	};
+    key <AD09> {	[], [	  o,	O		]	};
+    key <AD10> {	[], [	  p,	P		]	};
+    key <AD11> {	[], [ bracketleft,	braceleft	]	};
+    key <AD12> {	[], [ bracketright,	braceright	]	};
+
+    key <AC01> {	[], [	  a,	A 		]	};
+    key <AC02> {	[], [	  s,	S		]	};
+    key <AC03> {	[], [	  d,	D		]	};
+    key <AC04> {	[], [	  f,	F		]	};
+    key <AC05> {	[], [	  g,	G		]	};
+    key <AC06> {	[], [	  h,	H		]	};
+    key <AC07> {	[], [	  j,	J		]	};
+    key <AC08> {	[], [	  k,	K		]	};
+    key <AC09> {	[], [	  l,	L		]	};
+    key <AC10> {	[], [ semicolon,	colon		]	};
+    key <AC11> {	[], [ quoteright,	quotedbl	]	};
+
+    key <AB01> {	[], [	  z,	Z 		]	};
+    key <AB02> {	[], [	  x,	X		]	};
+    key <AB03> {	[], [	  c,	C		]	};
+    key <AB04> {	[], [	  v,	V		]	};
+    key <AB05> {	[], [	  b,	B		]	};
+    key <AB06> {	[], [	  n,	N		]	};
+    key <AB07> {	[], [	  m,	M		]	};
+    key <AB08> {	[], [     comma,	less		]	};
+    key <AB09> {	[], [    period,	greater		]	};
+    key <AB10> {	[], [     slash,	question	]	};
+    key <BKSL> {	[], [ backslash,	bar		]	};
 
-default
-xkb_symbols "pc102" {
-    include "lt(pc101)"
-    include "lt(left_switch)"
 };
 
+
+
 partial alphanumeric_keys 
 xkb_symbols "Sundeadkeys" {
     include "lt(basic)" // for consistent naming
@@ -132,15 +129,12 @@
     include "lt(basic)" // for consistent naming
 };
 
-// definition for the extra key on 102-key keyboards
-// between left Control and Alt
+// definition for the extra key on 102-key keyboards between left Control and Alt
+// in case you want use it as AltGr
 xkb_symbols "left_switch" {
     key	<LSGT> {	[     Mode_switch,	 Multi_key 	],
 			[     Mode_switch,	 Multi_key 	]	};
     // Begin modifier mappings 
     modifier_map Mod3   { Mode_switch };
 };
-
-
-
 
Index: xc/programs/xkbcomp/symbols/lt_p
diff -u /dev/null xc/programs/xkbcomp/symbols/lt_p:1.3
--- /dev/null	Mon Dec 18 14:35:22 2000
+++ xc/programs/xkbcomp/symbols/lt_p	Tue Nov 28 14:09:38 2000
@@ -0,0 +1,75 @@
+// $XConsortium: lt_p /main/3 1997/12/18 12:40:12 rch $
+//
+// $XFree86: xc/programs/xkbcomp/symbols/lt_p,v 1.3 2000/11/28 19:09:38 dawes Exp $
+
+partial default alphanumeric_keys modifier_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Lithuanian "programmer's" keyboard
+    // (qwerty layout with Lithuanian letters on the closer ascii ones)
+    // Don't rename this file because it includes 'lt_p'
+    // Extentions:  less/Euro/endash on 102nd key, AltGr+Space is nobreakspace
+    //  Usage:  setxkbmap lt_p
+    // Option	"XkbModel"	"pc105"
+    // Option	"XkbLayout"	"lt_p"
+
+    name[Group1]= "US/ASCII";
+    name[Group2]= "Lithuanian";
+
+    key <RTRN> {	[   Return,  ISO_Next_Group	]};
+    key <AD01> {        [         q,    Q               ],
+			[   umacron,    Umacron		]};
+    key <AD02> {        [         w,    W               ],
+			[ eabovedot,    Eabovedot	]};
+    key <AD03> {        [         e,    E               ],
+			[   eogonek,    Eogonek		]};
+    key <AD07> {        [         u,    U               ],
+			[   uogonek,	Uogonek		]};
+    key <AD08> {        [         i,    I               ],
+			[   iogonek,	Iogonek		]};
+    key <AC01> {        [         a,    A               ],
+			[   aogonek,	Aogonek		]};
+    key <AC02> {        [         s,    S               ],
+			[    scaron,	Scaron		]};
+    key <AC11> {        [ quoteright,   quotedbl        ],
+// this is actually right quote for Lithuanian
+			[ leftdoublequotemark, doublelowquotemark]};
+    key <AB01> {        [         z,    Z               ],
+			[    zcaron,	Zcaron		]};
+    key <AB03> {        [         c,    C               ],
+			[    ccaron,	Ccaron		]};
+    key <SPCE> {	[     space,	space		],
+			[ nobreakspace,	nobreakspace	]};
+
+    key	<LSGT> {	[      less,	EuroSign	],
+			[     endash			]};
+
+    // End alphanumeric section
+    
+    // Begin modifier mappings 
+
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock, ISO_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3   { Mode_switch };
+};
+
+
+
+partial alphanumeric_keys 
+xkb_symbols "Sundeadkeys" {
+    include "lt_p(basic)" // for consistent naming
+};
+
+partial alphanumeric_keys 
+xkb_symbols "sundeadkeys" {
+    include "lt_p(Sundeadkeys)" // for consistent naming
+};
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    include "lt_p(basic)" // for consistent naming
+};
+
+
Index: xc/programs/xkbcomp/symbols/lt_std
diff -u /dev/null xc/programs/xkbcomp/symbols/lt_std:1.1
--- /dev/null	Mon Dec 18 14:35:23 2000
+++ xc/programs/xkbcomp/symbols/lt_std	Tue Nov 28 16:00:38 2000
@@ -0,0 +1,107 @@
+// $XFree86: xc/programs/xkbcomp/symbols/lt_std,v 1.1 2000/11/28 21:00:38 dawes Exp $
+// Lithuanian keyboard map by Gediminas Paulauskas <menesis@delfi.lt>
+// Minor modification by Rièardas Èepas according to http://sun3.mif.vu.lt/cs/TK4/lithkeyb.html
+
+// Describes Lithuanian keymap LST 1582:2000
+// Don't rename this file because it includes 'lt_std'
+// Extensions:  B01 L3 is "<" , B02 L3 is ">" and B03 L3 is endash to make this
+// layout usable with pc101 and pc104 keyboards.
+// Usage: setxkbmap lt_std
+// Option	"XkbModel"	"pc105"
+// Option	"XkbLayout"	"lt_std"
+ 
+partial default alphanumeric_keys
+xkb_symbols "basic" {
+
+    name[	Group1]= "Lithuanian";
+
+    key <TLDE> {[	grave,		asciitilde	],
+		[	acute				]};
+    key <AE01> {[	exclam,		1		],
+		[	at				]};
+    key <AE02> {[	minus,		2		],
+		[	underscore			]};
+    key <AE03> {[	slash,		3		],
+		[	numbersign			]};
+    key <AE04> {[	semicolon,	4		],
+		[	dollar				]};
+    key <AE05> {[	colon,		5		],
+		[	section				]};
+    key <AE06> {[	comma,		6		],
+		[	asciicircum			]};
+    key <AE07> {[	period,		7		],
+		[	ampersand			]};
+    key <AE08> {[	equal,		8		],
+		[	asterisk			]};
+    key <AE09> {[	parenleft,	9		],
+		[	bracketleft			]};
+    key <AE10> {[	parenright,	0		],
+		[	bracketright			]};
+    key <AE11> {[	question,	plus		],
+		[	apostrophe			]};
+    key <AE12> {[	x,		X		],
+		[	percent				]};
+    key	<AD01> {[	aogonek,	Aogonek		]
+		 					 };
+    key	<AD02> {[	zcaron,		Zcaron		]
+							};
+    key	<AD03> {[	e,		E		],
+		[	EuroSign			]};
+    key	<AD11> {[	iogonek,	Iogonek		],
+		[	braceleft			]};
+    key	<AD12> {[	w,		W		],
+		[	braceright			]};
+    key	<AC04> {[	scaron,		Scaron		]
+							 };
+    key <AC10> {[	uogonek,	Uogonek		]
+							 };
+    key <AC11> {[	eabovedot,	Eabovedot	],
+		[	quotedbl			]};
+    key	<AB01> {[	z,		Z		],
+		[	less				]};
+    key	<AB02> {[	umacron,	Umacron		],
+		[	greater				]};
+    key	<AB03> {[	c,		C		],
+		[	endash				]};
+    key	<AB08> {[	ccaron,		Ccaron		],
+		[	doublelowquotemark		]};
+    key	<AB09> {[	f,		F		],
+// this is actually right quote for Lithuanian
+		[	leftdoublequotemark		]};
+    key	<AB10> {[	eogonek,	Eogonek		],
+		[	backslash			]};
+    key <BKSL> {[	q,		Q		],
+		[	bar				]};
+    key <SPCE> {[	space,		space		],
+		[	nobreakspace,	nobreakspace	]};
+
+    key	<LSGT> {[	less,		greater		],
+		[	endash				]};
+
+// End alphanumeric section
+
+// Begin modifier mappings 
+
+    modifier_map Shift	{ Shift_L			};
+    modifier_map Lock	{ Caps_Lock,	ISO_Lock	};
+    modifier_map Control{ Control_L			};
+    modifier_map Mod3	{ Mode_switch			};
+};
+
+
+
+partial alphanumeric_keys 
+xkb_symbols "Sundeadkeys" {
+    include "lt_std(basic)" // for consistent naming
+};
+
+partial alphanumeric_keys 
+xkb_symbols "sundeadkeys" {
+    include "lt_std(Sundeadkeys)" // for consistent naming
+};
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    include "lt_std(basic)" // for consistent naming
+};
+
Index: xc/programs/xkbcomp/symbols/mk
diff -u xc/programs/xkbcomp/symbols/mk:3.1 xc/programs/xkbcomp/symbols/mk:3.4
--- xc/programs/xkbcomp/symbols/mk:3.1	Thu Jun 15 16:34:14 2000
+++ xc/programs/xkbcomp/symbols/mk	Mon Nov 27 12:45:57 2000
@@ -1,120 +1,130 @@
 // Author: Damjan Georgievski <gdamjan@freemail.org.mk>
-// usage: xkbcomp mk.xkb :0
+// Revision: 1.4
+// Quick usage: setxkbmap -layout mk
 //
 // shift-leftALT and win95 menu key  toggles cyrillic/latin
-// rightALT and win95 start keys  temporarily alternate
+// rightALT and left win95-logo keys are Mode_switch
+// right win95-logo key is Multi_key (Compose)
 //
-// $XFree86: xc/programs/xkbcomp/symbols/mk,v 3.1 2000/06/15 20:34:14 dawes Exp $
-
+// $XFree86: xc/programs/xkbcomp/symbols/mk,v 3.4 2000/11/27 17:45:57 dawes Exp $
+//
 partial default alphanumeric_keys
-xkb_symbols         { 
-
-    name[Group1]= "US/ASCII";
+xkb_symbols "basic" { 
     name[Group2]= "Macedonian";
+    key <AB01> {  [ ], [     Cyrillic_ze,     Cyrillic_ZE	]	};
+    key <AC02> {  [ ], [     Cyrillic_es,     Cyrillic_ES	]	};
+    key <AC01> {  [ ], [      Cyrillic_a,      Cyrillic_A	]	};
+    key <AD01> {  [ ], [    Cyrillic_lje,    Cyrillic_LJE	]	};
+    key <AD02> {  [ ], [    Cyrillic_nje,    Cyrillic_NJE	]	};
+    key <AB03> {  [ ], [    Cyrillic_tse,    Cyrillic_TSE	]	};
+    key <AB02> {  [ ], [   Cyrillic_dzhe,   Cyrillic_DZHE	]	};
+    key <AC03> {  [ ], [     Cyrillic_de,     Cyrillic_DE	]	};
+    key <AD03> {  [ ], [     Cyrillic_ie,     Cyrillic_IE	]	};
+    key <AB04> {  [ ], [     Cyrillic_ve,     Cyrillic_VE	]	};
+    key <AC04> {  [ ], [     Cyrillic_ef,     Cyrillic_EF	]	};
+    key <AD05> {  [ ], [     Cyrillic_te,     Cyrillic_TE	]	};
+    key <AD04> {  [ ], [     Cyrillic_er,     Cyrillic_ER	]	};
+    key <AB06> {  [ ], [     Cyrillic_en,     Cyrillic_EN	]	};
+    key <AB05> {  [ ], [     Cyrillic_be,     Cyrillic_BE	]	};
+    key <AC06> {  [ ], [     Cyrillic_ha,     Cyrillic_HA	]	};
+    key <AC05> {  [ ], [    Cyrillic_ghe,    Cyrillic_GHE	]	};
+    key <AD06> {  [ ], [   Macedonia_dse,   Macedonia_DSE	]	};
+    key <AB07> {  [ ], [     Cyrillic_em,     Cyrillic_EM	]	};
+    key <AC07> {  [ ], [     Cyrillic_je,     Cyrillic_JE	]	};
+    key <AD07> {  [ ], [      Cyrillic_u,      Cyrillic_U	]	};
+    key <AC08> {  [ ], [     Cyrillic_ka,     Cyrillic_KA	]	};
+    key <AD08> {  [ ], [      Cyrillic_i,      Cyrillic_I	]	};
+    key <AD09> {  [ ], [      Cyrillic_o,      Cyrillic_O	]	};
+    key <AC09> {  [ ], [     Cyrillic_el,     Cyrillic_EL	]	};
+    key <AC10> {  [ ], [    Cyrillic_che,    Cyrillic_CHE	]	};
+    key <AD10> {  [ ], [     Cyrillic_pe,     Cyrillic_PE	]	};
+    key <AC11> {  [ ], [   Macedonia_kje,   Macedonia_KJE	]	};
+    key <AD11> {  [ ], [    Cyrillic_sha,    Cyrillic_SHA	]	};
+    key <AD12> {  [ ], [   Macedonia_gje,   Macedonia_GJE	]	};
+    key <BKSL> {  [ ], [    Cyrillic_zhe,    Cyrillic_ZHE	]	};
+    key <AE12> {  [ ], [           equal,            plus	]	};
+    key <AE11> {  [ ], [           minus,      underscore	]	};
+    key <TLDE> {  [ ], [           grave,      asciitilde	]	};
+    key <AE01> {  [ ], [               1,          exclam	]	};
+    key <AE02> {  [ ], [               2, doublelowquotemark	]	};
+    key <AE03> {  [ ], [               3, leftdoublequotemark	]	};
+    key <AE04> {  [ ], [               4,          dollar	]	};
+    key <AE05> {  [ ], [               5,         percent	]	};
+    key <AE06> {  [ ], [               6,     asciicircum	]	};
+    key <AE07> {  [ ], [               7,       ampersand	]	};
+    key <AE08> {  [ ], [               8,        asterisk	]	};
+    key <AE09> {  [ ], [               9,       parenleft	]	};
+    key <AE10> {  [ ], [               0,      parenright	]	};
+    key <AB08> {  [ ], [           comma,       semicolon	]	};
+    key <AB09> {  [ ], [          period,           colon	]	};
+    key <AB10> {  [ ], [           slash,        question	]	};
+
+};
+
+partial alphanumeric_keys
+xkb_symbols "group1" { 
+    name[Group1]= "Macedonian";
+    name[Group2]= "US/ASCII";
+    key <AB01> {  [  Cyrillic_ze,   Cyrillic_ZE	], [ z, Z ]	};
+    key <AC02> {  [  Cyrillic_es,   Cyrillic_ES	], [ s, S ]	};
+    key <AC01> {  [   Cyrillic_a,    Cyrillic_A	], [ a, A ]	};
+    key <AD01> {  [ Cyrillic_lje,  Cyrillic_LJE	], [ q, Q ]	};
+    key <AD02> {  [ Cyrillic_nje,  Cyrillic_NJE	], [ w, W ]	};
+    key <AD03> {  [  Cyrillic_ie,   Cyrillic_IE	], [ e, E ]	};
+    key <AD04> {  [  Cyrillic_er,   Cyrillic_ER	], [ r, R ]	};
+    key <AB03> {  [ Cyrillic_tse,  Cyrillic_TSE	], [ c, C ]	};
+    key <AB02> {  [Cyrillic_dzhe, Cyrillic_DZHE	], [ x, X ]	};
+    key <AC03> {  [  Cyrillic_de,   Cyrillic_DE	], [ d, D ]	};
+    key <AB04> {  [  Cyrillic_ve,   Cyrillic_VE	], [ v, V ]	};
+    key <AC04> {  [  Cyrillic_ef,   Cyrillic_EF	], [ f, F ]	};
+    key <AD05> {  [  Cyrillic_te,   Cyrillic_TE	], [ t, T ]	};
+    key <AB06> {  [  Cyrillic_en,   Cyrillic_EN	], [ n, N ]	};
+    key <AB05> {  [  Cyrillic_be,   Cyrillic_BE	], [ b, B ]	};
+    key <AC06> {  [  Cyrillic_ha,   Cyrillic_HA	], [ h, H ]	};
+    key <AC05> {  [ Cyrillic_ghe,  Cyrillic_GHE	], [ g, G ]	};
+    key <AD06> {  [Macedonia_dse, Macedonia_DSE	], [ y, Y ]	};
+    key <AB07> {  [  Cyrillic_em,   Cyrillic_EM	], [ m, M ]	};
+    key <AC07> {  [  Cyrillic_je,   Cyrillic_JE	], [ j, J ]	};
+    key <AD07> {  [   Cyrillic_u,    Cyrillic_U	], [ u, U ]	};
+    key <AC08> {  [  Cyrillic_ka,   Cyrillic_KA	], [ k, K ]	};
+    key <AD08> {  [   Cyrillic_i,    Cyrillic_I	], [ i, I ]	};
+    key <AD09> {  [   Cyrillic_o,    Cyrillic_O	], [ o, O ]	};
+    key <AD10> {  [  Cyrillic_pe,   Cyrillic_PE	], [ p, P ]	};
+    key <AC09> {  [  Cyrillic_el,   Cyrillic_EL	], [ l, L ]	};
+
+    key <AC10> {  [ Cyrillic_che,  Cyrillic_CHE	], [ semicolon, colon ] };
+    key <AC11> {  [Macedonia_kje, Macedonia_KJE	], [ quoteright, quotedbl ] }; 
+    key <AD11> {  [ Cyrillic_sha,  Cyrillic_SHA	], [ bracketleft, braceleft ] };
+    key <AD12> {  [Macedonia_gje, Macedonia_GJE	], [bracketright, braceright] };
+    key <BKSL> {  [ Cyrillic_zhe,  Cyrillic_ZHE	], [ backslash, bar ] };
+
+    key <AB10> {  [  slash,  question  ], [  slash, question  ] };
+    key <AE12> {  [  equal,       plus	], [ equal,       plus ] };
+    key <AE11> {  [  minus, underscore	], [ minus, underscore ] };
+    key <TLDE> {  [  grave, asciitilde	], [ grave, asciitilde ] };
+    key <AE01> {  [      1,     exclam	], [     1,     exclam ] };
+    key <AE02> {  [      2, doublelowquotemark ], [  2,     at ] };
+    key <AE03> {  [      3, leftdoublequotemark ], [  3, numbersign ] };
+    key <AE04> {  [      4,     dollar	], [     4,     dollar ] };
+    key <AE05> {  [      5,    percent	], [     5,    percent ] };
+    key <AE06> {  [      6,asciicircum	], [     6,asciicircum ] };
+    key <AE07> {  [      7,  ampersand	], [     7,  ampersand ] };
+    key <AE08> {  [      8,   asterisk	], [     8,   asterisk ] };
+    key <AE09> {  [      9,  parenleft	], [     9,  parenleft ] };
+    key <AE10> {  [      0, parenright	], [     0, parenright ] };
+    key <AB08> {  [  comma,  semicolon	], [  comma,    less	] };
+    key <AB09> {  [ period,      colon	], [ period, greater	] };
+};
+
+partial alphanumeric_keys
+xkb_symbols "pc104" {
+    include "mk(basic)"
+    include "mk(win)"	
+};
 
-    modifier_map Mod3 { Mode_switch };
-    key <CAPS> {        [           Caps_Lock 		     	]	};	
-    key <MENU> {	[ 		ISO_Next_Group		]	};
-    key <RWIN> {	[		Mode_switch		]	};
-    key <LWIN> {	[		Mode_switch		]	};
-    key <LALT> {	[	    Alt_L,	ISO_Next_Group	]	};
-    key <RALT> {	[           	Mode_switch		]	};
-    key <SPCE> {        [               space                  	]      	};
-    key	<AE12> {	[	    equal,	      plus	],
-			[	    equal,	      plus	]	};
-    key	<AB09> {	[	   period,	   greater	],
-			[          period,           colon	]	};
-    key	<AB10> {	[	    slash,	  question	],
-			[	    slash,	  question	]	};
-    key	<AE11> {	[	    minus,	underscore	],
-			[	    minus,	underscore	]	};
-    key	<TLDE> {	[	    grave,	asciitilde	],
-			[	    grave,	asciitilde	]	};
-    key	<LSGT> {	[	     less,	   greater	],
-			[	     less,	   greater	]	};
-    key	<AE01> {	[		1,	    exclam	],
-			[		1,	    exclam 	]	};
-    key	<AE02> {	[		2,		at	],
-			[		2,        	at	]	};
-    key	<AE03> {	[		3,	numbersign	],
-			[		3,      numbersign	]	};
-    key	<AE04> {	[		4,	    dollar	],
-			[		4,          dollar	]	};
-    key	<AE05> {	[		5,	   percent	],
-			[		5,	   percent	]	};
-    key	<AE06> {	[		6,     asciicircum	],
-			[		6,     asciicircum	]	};
-    key	<AE07> {	[		7,	 ampersand	],
-			[		7,	 ampersand	]	};
-    key	<AE08> {	[		8,	  asterisk	],
-			[		8,	  asterisk	]	};
-    key	<AE09> {	[		9,	 parenleft	],
-			[		9,	 parenleft	]	};
-    key	<AE10> {	[		0,	parenright	],
-			[		0,	parenright	]	};
-    key	<AB01> {	[		z,		 Z	],
-			[     Cyrillic_ze,     Cyrillic_ZE	]	};
-    key	<AC02> {	[		s,		 S	],
-			[     Cyrillic_es,     Cyrillic_ES	]	};
-    key	<AC01> {	[		a,		 A	],
-			[      Cyrillic_a,      Cyrillic_A	]	};
-    key	<AD01> {	[		q,		 Q	],
-			[    Cyrillic_lje,    Cyrillic_LJE	]	};
-    key	<AD02> {	[		w,		 W	],
-			[    Cyrillic_nje,    Cyrillic_NJE	]	};
-    key	<AB03> {	[		c,		 C	],
-			[    Cyrillic_tse,    Cyrillic_TSE	]	};
-    key	<AB02> {	[		x,		 X	],
-			[   Cyrillic_dzhe,   Cyrillic_DZHE	]	};
-    key	<AC03> {	[		d,		 D	],
-			[     Cyrillic_de,     Cyrillic_DE	]	};
-    key	<AD03> {	[		e,		 E	],
-			[     Cyrillic_ie,     Cyrillic_IE	]	};
-    key	<AB04> {	[		v,		 V	],
-			[     Cyrillic_ve,     Cyrillic_VE	]	};
-    key	<AC04> {	[		f,		 F	],
-			[     Cyrillic_ef,     Cyrillic_EF	]	};
-    key	<AD05> {	[		t,		 T	],
-			[     Cyrillic_te,     Cyrillic_TE	]	};
-    key	<AD04> {	[		r,		 R	],
-			[     Cyrillic_er,     Cyrillic_ER	]	};
-    key	<AB06> {	[		n,		 N	],
-			[     Cyrillic_en,     Cyrillic_EN	]	};
-    key	<AB05> {	[		b,		 B	],
-			[     Cyrillic_be,     Cyrillic_BE	]	};
-    key	<AC06> {	[		h,		 H	],
-			[     Cyrillic_ha,     Cyrillic_HA	]	};
-    key	<AC05> {	[		g,		 G	],
-			[    Cyrillic_ghe,    Cyrillic_GHE	]	};
-    key	<AD06> {	[		y,		 Y	],
-			[   Macedonia_dse,   Macedonia_DSE	]	};
-    key	<AB07> {	[		m,		 M	],
-			[     Cyrillic_em,     Cyrillic_EM	]	};
-    key	<AC07> {	[		j,		 J	],
-			[     Cyrillic_je,     Cyrillic_JE	]	};
-    key	<AD07> {	[		u,		 U	],
-			[      Cyrillic_u,      Cyrillic_U	]	};
-    key	<AB08> {	[	    comma,	      less	],
-			[	    comma,       semicolon	]	};
-    key	<AC08> {	[		k,		 K	],
-			[     Cyrillic_ka,     Cyrillic_KA	]	};
-    key	<AD08> {	[		i,		 I	],
-			[      Cyrillic_i,      Cyrillic_I	]	};
-    key	<AD09> {	[		o,		 O	],
-			[      Cyrillic_o,      Cyrillic_O	]	};
-    key	<AC09> {	[		l,		 L	],
-			[     Cyrillic_el,     Cyrillic_EL	]	};
-    key	<AC10> {	[	semicolon,	     colon	],
-			[    Cyrillic_che,    Cyrillic_CHE	]	};
-    key	<AD10> {	[		p,		 P	],
-			[     Cyrillic_pe,     Cyrillic_PE	]	};
-    key	<AC11> {	[      apostrophe,	  quotedbl	],
-			[   Macedonia_kje,   Macedonia_KJE	]	};
-    key	<AD11> {	[     bracketleft,	 braceleft	],
-			[    Cyrillic_sha,    Cyrillic_SHA	]	};
-    key	<AD12> {	[    bracketright,	braceright	],
-			[   Macedonia_gje,   Macedonia_GJE	]	};
-    key	<BKSL> {	[	backslash,	       bar	],
-			[    Cyrillic_zhe,    Cyrillic_ZHE	]	};
-    };
+partial alphanumeric_keys
+xkb_symbols "win" {
+    key <MENU> { [ 		ISO_Next_Group		]	};
+    key <RWIN> { [		Multi_key		]	};
+    key <LWIN> { [		Mode_switch		]	};
 };
Index: xc/programs/xkbcomp/symbols/no
diff -u xc/programs/xkbcomp/symbols/no:3.6 xc/programs/xkbcomp/symbols/no:3.8
--- xc/programs/xkbcomp/symbols/no:3.6	Mon Feb 14 19:40:38 2000
+++ xc/programs/xkbcomp/symbols/no	Thu Nov  2 14:10:59 2000
@@ -1,40 +1,75 @@
-// $XConsortium: no /main/3 1996/08/31 12:20:02 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/no,v 3.6 2000/02/15 00:40:38 dawes Exp $
-partial default alphanumeric_keys 
-xkb_symbols "basic" {
+// $XConsortium: no /main/3 1996/08/31 12:19:29 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/no,v 3.8 2000/11/02 19:10:59 dawes Exp $
+partial alphanumeric_keys 
+ xkb_symbols "basic" {
+ 
+     // Describes the differences between a very simple en_US
+    // keyboard and a Norwegian keyboard with dead key support
+    // and all of ISO-8859-1 characters available.
+ 
+     name[Group1]= "Norwegian";
+ 
+    key <TLDE> {	[             bar,         section      ],
+			[       brokenbar,       paragraph	]};
+    key <LSGT> {	[	     less,	   greater	],
+			[	  onehalf,   threequarters	]};
+    key <SPCE> {	[	    space,	     space	],
+			[    nobreakspace,    nobreakspace	]};
+    key <AE01> {	[               1,          exclam  	],
+			[      exclamdown,     onesuperior	]};
+    key <AE02> {	[               2,        quotedbl  	],
+			[	       at,     twosuperior	]};
+    key <AE03> {	[              	3,	numbersign	],
+			[	 sterling,   threesuperior	]};
+    key <AE04> {	[               4,        currency     	],
+			[	   dollar,	onequarter	]};
+    key <AE05> {	[               5,         percent     	],
+			[        NoSymbol,	      cent	]};
+    key <AE06> {	[               6,       ampersand     	],
+			[	      yen,	  NoSymbol	]};
+    key <AE07> {	[               7,           slash     	],
+			[       braceleft,        division	]};
+    key <AE08> {	[               8,       parenleft     	],
+			[     bracketleft,   guillemotleft	]};
+    key <AE09> {	[               9,      parenright     	],
+			[    bracketright,  guillemotright	]};
+    key <AE10> {	[               0,           equal     	],
+                        [      braceright,          degree      ]};
+    key <AB08> {	[           comma,       semicolon     	],
+			[    dead_cedilla,     dead_ogonek	]};
+    key <AB09> {	[          period,           colon     	],
+			[  periodcentered,   dead_abovedot	]};
+    key <AB03> {        [               c,               C      ],
+                        [       copyright,        NoSymbol      ]};
+    key <AB10> {	[           minus,      underscore     	],
+			[	   hyphen,          macron	]};
+    key <AC01> {        [               a,               A      ],
+                        [     ordfeminine,       masculine      ]};
+    key <AC03> {        [               d,               D      ],
+                        [             eth,             ETH      ]};
+    key <AD03> {        [               e,               E      ],
+                        [        EuroSign,            cent      ]};
+    key <AD04> {        [               r,               R      ],
+                        [      registered,        NoSymbol      ]};
+    key <AD05> {        [               t,               T      ],
+                        [           thorn,           THORN      ]};
+    key <AD08> {        [               i,               I      ],
+                        [        NoSymbol,        NoSymbol      ]};
+    key <AD09> {        [               o,               O      ],
+                        [              oe,              OE      ]};
+    key	<AC10> {	[	   oslash,        Ooblique 	]}; 
+    key <AE11> {	[            plus,        question      ],
+			[       plusminus,    questiondown	]};
+    key <AC11> {	[	      ae,	        AE	]};
+    key <BKSL> {	[      apostrophe,        asterisk	],
+                 	[dead_doubleacute,        multiply      ]};
+    key <AD11> {	[	    aring,           Aring 	]};
+    key <AE12> {   	[       backslash,      dead_grave      ],
+                 	[      dead_acute,         notsign      ]};
+    key <AD12> {   	[  dead_diaeresis, dead_circumflex      ],
+                 	[      dead_tilde,      dead_caron      ]};
 
-    // Describes the differences between a very simple en_US
-    // keyboard and a very simple Norwegian keybaord
-
-    name[Group1]= "Norwegian";
-
-    key <TLDE> {	[             bar,         section      ]	};
-    key <AE02> {	[               2,        quotedbl     	],	
-			[	       at,	 oneeighth	]	};
-    key <AE04> {	[	        4,        currency	],
-			[	   dollar,	    dollar	]	};
-    key <AE03> {	[               3,	numbersign 	],
-			[        sterling,        sterling	]	};
-    key <AE06> {	[               6,       ampersand     	]	};
-    key <AE07> {	[               7,           slash     	]	};
-    key <AE08> {	[               8,       parenleft     	]	};
-    key <AB08> {	[           comma,       semicolon     	]	};
-    key <AE10> {	[               0,           equal     	]	};
-    key <AE09> {	[               9,      parenright     	]	};
-    key <LSGT> {	[            less,         greater	]	};
-    key <AB09> {	[          period,           colon     	]	};
-    key <AB10> {	[           minus,      underscore     	]	};
-    key	<AC10> {	[	   oslash,        Ooblique  	]	};
-    key <AE11> {	[            plus,        question      ]	};
-    key <AC11> {	[              ae,              AE 	]	};
-    key <AD11> {	[	    aring,           Aring     	]	};
-    key <AE12> {	[       backslash,      dead_grave	],
-			[      dead_acute,     dead_ogonek 	]	};
-    key <AD12> {	[  dead_diaeresis, dead_circumflex     	],	
-			[      dead_tilde,     dead_macron     	]      	};
-    key <BKSL> {	[      apostrophe,        asterisk	]	};
-    key <LSGT> {	[            less,         greater	]	};
-
+ 
     // End alphanumeric section
 
     // begin modifier mappings
Index: xc/programs/xkbcomp/symbols/pc104
diff -u xc/programs/xkbcomp/symbols/pc104:3.1 xc/programs/xkbcomp/symbols/pc104:3.3
--- xc/programs/xkbcomp/symbols/pc104:3.1	Sun Jun 22 05:53:20 1997
+++ xc/programs/xkbcomp/symbols/pc104	Thu Aug  3 08:24:03 2000
@@ -1,4 +1,5 @@
 // $TOG: pc104 /main/2 1997/06/13 06:25:12 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/pc104,v 3.3 2000/08/03 12:24:03 dawes Exp $
 // Use "Alt_*" for both alt keys, "Meta_*" for both windows keys, and Menu for
 // the menu key
 default partial modifier_keys 
@@ -17,4 +18,4 @@
     key <RALT> {	[ 	Alt_R		]	};
     key <RWIN> {	[ 	Meta_R		]	};
     key <MENU> {	[ 	Multi_key	]	};
-}
+};
Index: xc/programs/xkbcomp/symbols/pt
diff -u xc/programs/xkbcomp/symbols/pt:3.4 xc/programs/xkbcomp/symbols/pt:3.5
--- xc/programs/xkbcomp/symbols/pt:3.4	Fri Nov 19 08:55:13 1999
+++ xc/programs/xkbcomp/symbols/pt	Fri Oct 27 14:31:09 2000
@@ -1,5 +1,5 @@
 // $XConsortium: pt /main/3 1996/08/31 12:20:08 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/pt,v 3.4 1999/11/19 13:55:13 hohndel Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/pt,v 3.5 2000/10/27 18:31:09 dawes Exp $
 partial default alphanumeric_keys 
 xkb_symbols "basic" {
 
@@ -33,6 +33,9 @@
     key <AE12> {	[   guillemotleft,  guillemotright     	]	};
     key <AD12> {	[      dead_acute,      dead_grave 	]	};
     key <BKSL> {	[      dead_tilde, dead_circumflex	]	};
+    key <AD03> {        [               e,               E      ],
+                        [        EuroSign,            cent      ]	};
+
     // End alphanumeric section
 
     // begin modifier mappings
Index: xc/programs/xkbcomp/symbols/ro
diff -u /dev/null xc/programs/xkbcomp/symbols/ro:3.1
--- /dev/null	Mon Dec 18 14:35:26 2000
+++ xc/programs/xkbcomp/symbols/ro	Tue Aug 15 12:51:32 2000
@@ -0,0 +1,48 @@
+// symbols definition for a very simple Romanian Keyboard layout.
+//
+// We basically override some modifier_keys so that using the Right Alt
+// and the corresponing letter we are able to generate the romanian characters
+//
+// Created by Cristian Gafton, <gafton@redhat.com> (C) 2000
+// 
+// $XFree86: xc/programs/xkbcomp/symbols/ro,v 3.1 2000/08/15 16:51:32 dawes Exp $
+
+partial hidden alphanumeric_keys modifier_keys
+xkb_symbols "basic" {
+    name[Group1]= "Romanian";
+
+    key <TLDE> { [], [ acircumflex,     acircumflex	] };
+    key <AC01> { [], [ atilde,		acircumflex	] };   
+    key <AC02> { [], [ scedilla,	Scedilla	] };
+    key <AD05> { [], [ thorn,		Thorn		] };
+    key <AD08> { [], [ icircumflex,	Icircumflex	] };
+};
+
+default
+xkb_symbols "pc101" {
+    key <RALT> { [ Mode_switch,  Multi_key ] };
+
+    include "ro(basic)"
+
+    modifier_map Mod3 { Mode_switch };
+};
+
+xkb_symbols "pc104" {
+    key <RALT> { [ Mode_switch ] };
+    key <RWIN> { [ Multi_key ] };
+
+    include "ro(basic)"
+
+    modifier_map Mod3 { Mode_switch };
+};
+
+xkb_symbols "alt_is_meta" {
+    key <LALT> {  [  Meta_L ]  };
+    key <LWIN> {  [  Alt_L  ]  };
+
+    include "ro(pc104)"
+
+    // modifier mappings
+    modifier_map Mod1   { Meta_L, Meta_R };
+    modifier_map Mod4   { Alt_L,  Alt_R  };
+};
Index: xc/programs/xkbcomp/symbols/se
diff -u xc/programs/xkbcomp/symbols/se:3.5 xc/programs/xkbcomp/symbols/se:3.6
--- xc/programs/xkbcomp/symbols/se:3.5	Sun Dec 20 06:58:24 1998
+++ xc/programs/xkbcomp/symbols/se	Fri Oct 27 14:31:09 2000
@@ -1,39 +1,77 @@
-// $XConsortium: se /main/3 1996/08/31 12:20:15 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/se,v 3.5 1998/12/20 11:58:24 dawes Exp $
-partial default alphanumeric_keys 
-xkb_symbols "basic" {
+// $XConsortium: se /main/3 1996/08/31 12:19:29 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/se,v 3.6 2000/10/27 18:31:09 dawes Exp $
+partial alphanumeric_keys 
+ xkb_symbols "basic" {
+ 
+     // Describes the differences between a very simple en_US
+    // keyboard and a Swedish keyboard with dead key support
+    // and all of ISO-8859-1 characters available.
+ 
+     name[Group1]= "Swedish";
+ 
+    key <TLDE> {	[         section,         onehalf      ],
+			[       paragraph,   threequarters      ]};
+    key <LSGT> {	[	     less,	   greater	],
+                 	[             bar,       brokenbar      ]};
+    key <SPCE> {	[	    space,	     space	],
+			[    nobreakspace,    nobreakspace	]};
+    key <AE01> {	[               1,          exclam  	],
+			[      exclamdown,     onesuperior	]};
+    key <AE02> {	[               2,        quotedbl  	],
+			[	       at,     twosuperior	]};
+    key <AE03> {	[              	3,	numbersign	],
+			[	 sterling,   threesuperior	]};
+    key <AE04> {	[               4,        currency     	],
+			[	   dollar,	onequarter	]};
+    key <AE05> {	[               5,         percent     	],
+			[        NoSymbol,	      cent	]};
+    key <AE06> {	[               6,       ampersand     	],
+			[	      yen,	  NoSymbol	]};
+    key <AE07> {	[               7,           slash     	],
+			[       braceleft,        division	]};
+    key <AE08> {	[               8,       parenleft     	],
+			[     bracketleft,   guillemotleft	]};
+    key <AE09> {	[               9,      parenright     	],
+			[    bracketright,  guillemotright	]};
+    key <AE10> {	[               0,           equal     	],
+                        [      braceright,          degree      ]};
+    key <AB08> {	[           comma,       semicolon     	],
+			[    dead_cedilla,     dead_ogonek	]};
+    key <AB09> {	[          period,           colon     	],
+			[  periodcentered,   dead_abovedot	]};
+    key <AB03> {        [               c,               C      ],
+                        [       copyright,        NoSymbol      ]};
+    key <AB10> {	[           minus,      underscore     	],
+			[	   hyphen,          macron	]};
+    key <AC01> {        [               a,               A      ],
+                        [     ordfeminine,       masculine      ]};
+    key <AC03> {        [               d,               D      ],
+                        [             eth,             ETH      ]};
+    key <AD03> {        [               e,               E      ],
+                        [        EuroSign,            cent      ]};
+    key <AD04> {        [               r,               R      ],
+                        [      registered,        NoSymbol      ]};
+    key <AD05> {        [               t,               T      ],
+                        [           thorn,           THORN      ]};
+    key <AD08> {        [               i,               I      ],
+                        [        NoSymbol,        NoSymbol      ]};
+    key <AD09> {        [               o,               O      ],
+                        [              oe,              OE      ]};
+    key <AC10> {	[      odiaeresis,      Odiaeresis	],
+			[	   oslash,        Ooblique 	]};
+    key <AE11> {	[            plus,        question      ],
+			[       backslash,    questiondown	]};
+    key	<AC11> {	[      adiaeresis,      Adiaeresis	],
+			[	       ae,	        AE	]};
+    key <BKSL> {	[      apostrophe,        asterisk	],
+                 	[           acute,        multiply      ]};
+    key <AD11> {	[	    aring,           Aring 	]};
+    key <AE12> {   	[      dead_acute,      dead_grave      ],
+			[	plusminus,         notsign	]};
+    key <AD12> {   	[  dead_diaeresis, dead_circumflex      ],
+                 	[      dead_tilde,      dead_caron      ]};
 
-    // Describes the differences between a very simple en_US
-    // keyboard and a very simple Swedish(Sweden) keybaord
-
-    name[Group1]= "Swedish";
-
-    key <TLDE> {	[         section,         onehalf      ]	};
-    key <AE02> {	[               2,        quotedbl     	],	
-			[	       at,	 oneeighth	]	};
-    key <AE03> {	[               3,      numbersign      ],	
-			[        sterling,        sterling	]	};
-    key <AE04> {	[               4,        currency     	],	
-			[	   dollar,	    dollar	]	};
-    key <AE06> {	[               6,       ampersand     	]	};
-    key <AE07> {	[               7,           slash     	]	};
-    key <AE08> {	[               8,       parenleft     	]	};
-    key <AB08> {	[           comma,       semicolon     	]	};
-    key <AE09> {	[               9,      parenright     	]	};
-    key <AB09> {	[          period,           colon     	]	};
-    key <AE10> {	[               0,           equal     	]	};
-    key <AB10> {	[           minus,      underscore     	]	};
-    key	<AC10> {	[      odiaeresis,      Odiaeresis     	]	};
-    key <AE11> {	[            plus,        question      ]	};
-    key <AC11> {	[      adiaeresis,      Adiaeresis 	]	};
-    key <AD11> {	[	    aring,           Aring     	]	};
-    key <AE12> {	[      dead_acute,      dead_grave	]	};
-    key <AD12> {	[  dead_diaeresis,     asciicircum     	]	};
-    key <BKSL> {	[      apostrophe,        asterisk	]	};
-    key <LSGT> {        [            less,         greater      ],
-                        [             bar,       brokenbar      ]       };
-    key <KPDL> {	[	KP_Delete,    KP_Separator	]	};
-
+ 
     // End alphanumeric section
 
     // begin modifier mappings
Index: xc/programs/xkbcomp/symbols/sr
diff -u /dev/null xc/programs/xkbcomp/symbols/sr:1.1
--- /dev/null	Mon Dec 18 14:35:28 2000
+++ xc/programs/xkbcomp/symbols/sr	Tue Nov 14 12:33:03 2000
@@ -0,0 +1,130 @@
+// Serbian standard keyboard, version 1.1
+
+// Authors of this keyboard map are Milos Rancic <millosh@galeb.etf.bg.ac.yu>
+//                              and Anton Zinoviev <anton@lml.bas.bg>.
+
+// $XFree86: xc/programs/xkbcomp/symbols/sr,v 1.1 2000/11/14 17:33:03 dawes Exp $
+
+default partial alphanumeric_keys 
+xkb_symbols "basic" {
+  
+  // Describes the differences between a very simple en_US keyboard
+  // and a very simple Serbian keyboard.
+
+  // Note that the letter Serbian_dje is on the key with latin letter
+  // `Z' and in Cyrillic mode on the key with right bracket and brace
+  // you will find left and right bracket.
+
+  name[Group1]= "Latin";
+  name[Group2]= "Cyrillic";
+  
+  key <TLDE> {   [ quoteleft,         asciitilde          ],
+                 [ quoteleft,         asciitilde          ]    };
+  key <AE01> {   [ 1,                 exclam              ],
+                 [ 1,                 exclam              ]    };
+  key <AE02> {   [ 2,                 at                  ],
+                 [ 2,                 quotedbl            ]    };
+  key <AE03> {   [ 3,                 numbersign          ],
+                 [ 3,                 numbersign          ]    };
+  key <AE04> {   [ 4,                 dollar              ],
+                 [ 4,                 dollar              ]    };
+  key <AE05> {   [ 5,                 percent             ],
+                 [ 5,                 percent             ]    };
+  key <AE06> {   [ 6,                 asciicircum         ],
+                 [ 6,                 ampersand           ]    };
+  key <AE07> {   [ 7,                 ampersand           ],
+                 [ 7,                 slash               ]    };
+  key <AE08> {   [ 8,                 asterisk            ],
+                 [ 8,                 parenleft           ]    };
+  key <AE09> {   [ 9,                 parenleft           ],
+                 [ 9,                 parenright          ]    };
+  key <AE10> {   [ 0,                 parenright          ],
+                 [ 0,                 equal               ]    };
+  key <AE11> {   [ minus,             underscore          ],
+                 [ apostrophe,        question            ]    };
+  key <AE12> {   [ equal,             plus                ],
+                 [ plus,              asterisk            ]    };
+
+  key <AD01> {   [ q,                 Q                   ],
+                 [ Cyrillic_lje,      Cyrillic_LJE        ]    };
+  key <AD02> {   [ w,                 W                   ],
+                 [ Cyrillic_nje,      Cyrillic_NJE        ]    };
+  key <AD03> {   [ e,                 E                   ],
+                 [ Cyrillic_ie,       Cyrillic_IE         ]    };
+  key <AD04> {   [ r,                 R                   ],
+                 [ Cyrillic_er,       Cyrillic_ER         ]    };
+  key <AD05> {   [ t,                 T                   ],
+                 [ Cyrillic_te,       Cyrillic_TE         ]    };
+  key <AD06> {   [ y,                 Y                   ],
+                 [ Cyrillic_ze,       Cyrillic_ZE         ]    };
+  key <AD07> {   [ u,                 U                   ],
+                 [ Cyrillic_u,        Cyrillic_U          ]    };
+  key <AD08> {   [ i,                 I                   ],
+                 [ Cyrillic_i,        Cyrillic_I          ]    };
+  key <AD09> {   [ o,                 O                   ],
+                 [ Cyrillic_o,        Cyrillic_O          ]    };
+  key <AD10> {   [ p,                 P                   ],
+                 [ Cyrillic_pe,       Cyrillic_PE         ]    };
+  key <AD11> {   [ bracketleft,       braceleft           ],
+                 [ Cyrillic_sha,      Cyrillic_SHA        ]    };
+  key <AD12> {   [ bracketright,      braceright          ],
+                 [ bracketleft,       bracketright        ]    };
+
+  key <AC01> {   [ a,                 A                   ],
+                 [ Cyrillic_a,        Cyrillic_A          ]    };
+  key <AC02> {   [ s,                 S                   ],
+                 [ Cyrillic_es,       Cyrillic_ES         ]    };
+  key <AC03> {   [ d,                 D                   ],
+                 [ Cyrillic_de,       Cyrillic_DE         ]    };
+  key <AC04> {   [ f,                 F                   ],
+                 [ Cyrillic_ef,       Cyrillic_EF         ]    };
+  key <AC05> {   [ g,                 G                   ],
+                 [ Cyrillic_ghe,      Cyrillic_GHE        ]    };
+  key <AC06> {   [ h,                 H                   ],
+                 [ Cyrillic_ha,       Cyrillic_HA         ]    };
+  key <AC07> {   [ j,                 J                   ],
+                 [ Cyrillic_je,       Cyrillic_JE         ]    };
+  key <AC08> {   [ k,                 K                   ],
+                 [ Cyrillic_ka,       Cyrillic_KA         ]    };
+  key <AC09> {   [ l,                 L                   ],
+                 [ Cyrillic_el,       Cyrillic_EL         ]    };
+  key <AC10> {   [ semicolon,         colon               ],
+                 [ Cyrillic_che,      Cyrillic_CHE        ]    };
+  key <AC11> {   [ quoteright,        quotedbl            ],
+                 [ Serbian_tshe,      Serbian_TSHE        ]    };
+  key <BKSL> {   [ backslash,         bar                 ],
+                 [ minus,             underscore          ]    };
+
+  key <LSGT> {   [ less,              greater             ],
+                 [ less,              greater             ]    };
+  key <AB01> {   [ z,                 Z                   ],
+                 [ Serbian_dje,       Serbian_DJE         ]    };
+  key <AB02> {   [ x,                 X                   ],
+                 [ Cyrillic_dzhe,     Cyrillic_DZHE       ]    };
+  key <AB03> {   [ c,                 C                   ],
+                 [ Cyrillic_tse,      Cyrillic_TSE        ]    };
+  key <AB04> {   [ v,                 V                   ],
+                 [ Cyrillic_zhe,      Cyrillic_ZHE        ]    };
+  key <AB05> {   [ b,                 B                   ],
+                 [ Cyrillic_be,       Cyrillic_BE         ]    };
+  key <AB06> {   [ n,                 N                   ],
+                 [ Cyrillic_en,       Cyrillic_EN         ]    };
+  key <AB07> {   [ m,                 M                   ],
+                 [ Cyrillic_em,       Cyrillic_EM         ]    };
+  key <AB08> {   [ comma,             less                ],
+                 [ comma,             semicolon           ]    };
+  key <AB09> {   [ period,            greater             ],
+                 [ period,            colon               ]    };
+  key <AB10> {   [ slash,             question            ],
+                 [ Cyrillic_zhe,      Cyrillic_ZHE        ]    };
+
+  // End alphanumeric section
+
+  // Begin modifier mappings 
+  
+  modifier_map Shift  { Shift_L };
+  modifier_map Lock   { Caps_Lock, ISO_Lock };
+  modifier_map Control{ Control_L };
+  modifier_map Mod3   { Mode_switch };
+};
+
Index: xc/programs/xkbcomp/symbols/th
diff -u xc/programs/xkbcomp/symbols/th:3.2 xc/programs/xkbcomp/symbols/th:3.3
--- xc/programs/xkbcomp/symbols/th:3.2	Sat Jul 26 08:59:09 1997
+++ xc/programs/xkbcomp/symbols/th	Fri Oct 27 14:31:09 2000
@@ -1,64 +1,63 @@
 // $XConsortium: th /main/3 1996/08/31 12:20:18 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/th,v 3.2 1997/07/26 12:59:09 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/th,v 3.3 2000/10/27 18:31:09 dawes Exp $
 partial default alphanumeric_keys 
 xkb_symbols "basic" {
     name[Group2]= "Thai";
     // The thai layout defines a second keyboard group and changes
     // the behavior of a few modifier keys.  
 
-    // THIS KEYMAP IS A HORRIBLE HACK.  INSTEAD OF PROPERLY USING
-    // THE THAI KEYSYMS, IT USES THE LATIN-1 KEYSYMS AT THE CORRESPONDING
-    // CODE POINT.  BLECH.
+    // converted to THai keysysms - Pablo Saratxaga <pablo@mandrakesoft.com>
     key <TLDE> {	[], [  underscore,	percent		]	};
-    key <AE01> {	[], [       aring,  	plus 		]	};
-    key <AE02> {	[], [       slash,  	ntilde		]	};
-    key <AE03> {	[], [       minus,	ograve		]	};
-    key <AE04> {	[], [      Agrave,    	oacute		]	};
-    key <AE05> {	[], [   paragraph,    	ocircumflex	]	};
-    key <AE06> {	[], [    Ooblique,      Ugrave		]	};
-    key <AE07> {	[], [  Odiaeresis,	ssharp		]	};
-    key <AE08> {	[], [    currency,	otilde		]	};
-    key <AE09> {	[], [          mu,	odiaeresis	]	};
-    key <AE10> {	[], [   diaeresis,	division	]	};
-    key <AE11> {	[], [        cent,	oslash		]	};
-    key <AE12> {	[], [ ordfeminine,	ugrave		]	};
+    key <AE01> {	[], [ Thai_lakkhangyao,  plus 		]	};
+    key <AE02> {	[], [       slash,  	Thai_leknung	]	};
+    key <AE03> {	[], [       minus,	Thai_leksong	]	};
+    key <AE04> {	[], [ Thai_phosamphao, 	Thai_leksam	]	};
+    key <AE05> {	[], [ Thai_thothung,   	Thai_leksi	]	};
+    key <AE06> {	[], [  Thai_sarau,      Thai_sarauu	]	};
+    key <AE07> {	[], [ Thai_saraue,	Thai_baht	]	};
+    key <AE08> {	[], [ Thai_khokhwai,	Thai_lekha	]	};
+    key <AE09> {	[], [  Thai_totao,	Thai_lekhok	]	};
+    key <AE10> {	[], [ Thai_chochan,	Thai_lekchet	]	};
+    key <AE11> {	[], [ Thai_khokhai,	Thai_lekpaet	]	};
+    key <AE12> {	[], [ Thai_chochang,	Thai_lekkao	]	};
 
-    key <AD01> {	[], [          ae,	eth		]	};
-    key <AD02> {	[], [  adiaeresis,	quotedbl	]	};
-    key <AD03> {	[], [      Oacute,      registered	]	};
-    key <AD04> {	[], [ threequarters,	plusminus	]	};
-    key <AD05> {	[], [         ETH,	cedilla		]	};
-    key <AD06> {	[], [      Ntilde,	iacute		]	};
-    key <AD07> {	[], [      Otilde,	ecircumflex	]	};
-    key <AD08> {	[], [      Atilde,	threesuperior	]	};
-    key <AD09> {	[], [ onesuperior,	Idiaeresis	]	};
-    key <AD10> {	[], [ Acircumflex,	hyphen		]	};
-    key <AD11> {	[], [   masculine,	degree		]	};
-    key <AD12> {	[], [       Aring,	comma		]	};
+    key <AD01> {	[], [ Thai_maiyamok,	Thai_leksun	]	};
+    key <AD02> {	[], [ Thai_saraaimaimalai, quotedbl	]	};
+    key <AD03> {	[], [ Thai_saraam,      Thai_dochada	]	};
+    key <AD04> {	[], [ Thai_phophan,	Thai_thonangmontho ]	};
+    key <AD05> {	[], [  Thai_saraa,	Thai_thothong	]	};
+    key <AD06> {	[], [ Thai_maihanakat,	Thai_nikhahit	]	};
+    key <AD07> {	[], [ Thai_saraii,	Thai_maitri	]	};
+    key <AD08> {	[], [  Thai_rorua,	Thai_nonen	]	};
+    key <AD09> {	[], [   Thai_nonu,	Thai_paiyannoi	]	};
+    key <AD10> {	[], [  Thai_yoyak,	Thai_yoying	]	};
+    key <AD11> {	[], [ Thai_bobaimai,	Thai_thothan	]	};
+    key <AD12> {	[], [ Thai_loling,	comma		]	};
 
-    key <AC01> {	[], [ questiondown,	Adiaeresis	]	};
-    key <AC02> {	[], [  Ediaeresis,	brokenbar	]	};
-    key <AC03> {	[], [  exclamdown,	macron		]	};
-    key <AC04> {	[], [       acute,	acircumflex	]	};
-    key <AC05> {	[], [      agrave,	notsign		]	};
-    key <AC06> {	[], [      eacute,	ccedilla	]	};
-    key <AC07> {	[], [      egrave,	ediaeresis	]	};
-    key <AC08> {	[], [      Ograve,	Eacute		]	};
-    key <AC09> {	[], [ Ecircumflex,	Egrave		]	};
-    key <AC10> {	[], [    Ccedilla,	guillemotleft	]	};
-    key <AC11> {	[], [     section,	period		]	};
+    key <AC01> {	[], [  Thai_fofan,	Thai_ru		]	};
+    key <AC02> {	[], [  Thai_hohip,	Thai_khorakhang	]	};
+    key <AC03> {	[], [  Thai_kokai,	Thai_topatak	]	};
+    key <AC04> {	[], [  Thai_dodek,	Thai_sarao	]	};
+    key <AC05> {	[], [  Thai_sarae,	Thai_chochoe	]	};
+    key <AC06> {	[], [ Thai_maitho,	Thai_maitaikhu	]	};
+    key <AC07> {	[], [  Thai_maiek,	Thai_maichattawa ]	};
+    key <AC08> {	[], [ Thai_saraaa,	Thai_sorusi	]	};
+    key <AC09> {	[], [  Thai_sosua,	Thai_sosala	]	};
+    key <AC10> {	[], [ Thai_wowaen,	Thai_soso	]	};
+    key <AC11> {	[], [ Thai_ngongu,	period		]	};
 
-    key <AB01> {	[], [  onequarter,	parenleft	]	};
-    key <AB02> {	[], [ guillemotright,	parenright	]	};
-    key <AB03> {	[], [      aacute,	copyright	]	};
-    key <AB04> {	[], [      Iacute,	Icircumflex	]	};
-    key <AB05> {	[], [ Ocircumflex,	Uacute		]	};
-    key <AB06> {	[], [    multiply,	igrave		]	};
-    key <AB07> {	[], [ periodcentered,	question	]	};
-    key <AB08> {	[], [      Aacute,	twosuperior	]	};
-    key <AB09> {	[], [      atilde,	Igrave		]	};
-    key <AB10> {	[], [     onehalf,	AE		]	};
-    key <BKSL> {	[], [    sterling,	yen		]	};
+    key <AB01> {	[], [ Thai_phophung,	parenleft	]	};
+    key <AB02> {	[], [  Thai_popla,	parenright	]	};
+    key <AB03> {	[], [ Thai_saraae,	Thai_choching	]	};
+    key <AB04> {	[], [   Thai_oang,	Thai_honokhuk	]	};
+    key <AB05> {	[], [  Thai_sarai,	Thai_phinthu	]	};
+    key <AB06> {	[], [ Thai_sarauee,	Thai_thanthakhat ]	};
+    key <AB07> {	[], [ Thai_thothahan,	question	]	};
+    key <AB08> {	[], [   Thai_moma,	Thai_thophuthao	]	};
+    key <AB09> {	[], [ Thai_saraaimaimuan, Thai_lochula 	]	};
+    key <AB10> {	[], [   Thai_fofa,	Thai_lu		]	};
+
+    key <BKSL> {	[], [ Thai_khokhuat,    Thai_khokhon	]	};
     override key <LFSH> {
 	type="PC_SYSRQ",
 	[ 	 Shift_L,		ISO_First_Group		]
Index: xc/programs/xkbcomp/symbols/tr
diff -u /dev/null xc/programs/xkbcomp/symbols/tr:1.1
--- /dev/null	Mon Dec 18 14:35:29 2000
+++ xc/programs/xkbcomp/symbols/tr	Wed Dec  6 15:18:08 2000
@@ -0,0 +1,119 @@
+// $XFree86: xc/programs/xkbcomp/symbols/tr,v 1.1 2000/12/06 20:18:08 eich Exp $
+default partial alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple Turkish Q keyboard Togan Muftuoglu
+    // toganm@yahoo.com 23 November 2000 
+
+    // Alphanumeric section
+    name[Group1]= "Turkish";
+    key <TLDE> {	[ quotedbl,	eacute	],
+			[   notsign 			]	};
+    key <AE02> {	[  2,	apostrophe	],
+			[ twosuperior			]	};
+    key <AE03> {	[  3,	asciicircum	],
+			[ numbersign	]	};
+    key <AE04> {	[  4,	plus		],
+			[ dollar	]	};
+    key <AE05> {	[  5,	percent		],
+			[   onehalf			]	};
+    key <AE06> {	[  6,	ampersand	],
+			[ threequarters			]	};
+    key <AE07> {	[  7,	slash		],
+			[ braceleft			]	};
+    key <AE08> {	[  8,	parenleft	],
+			[ bracketleft			]	};
+    key <AE09> {	[  9,	parenright	],
+			[ bracketright,	plusminus	]	};
+    key <AE10> {	[  0,	equal		],
+			[ braceright,	degree		]	};
+    key <AE11> {	[    asterisk,	question	],
+			[ backslash,	questiondown	]	};
+    key <AE12> {	[ minus,		underscore	]		};
+
+    key <AD01> {	[  q,	Q 		],
+			[	 at			]	};
+    key <AD03> {	[  e,	E		],
+			[  EuroSign			]	};
+    key <AD05> {	[  t,	T		]	};
+    key <AD07> {	[  u,	U		]	};
+    key <AD08> {	[  yacute,	I		]	};
+    key <AD11> {	[ eth,	Eth	],
+			[ dead_diaeresis 		]	};
+    key <AD12> {	[ udiaeresis,	Udiaeresis	],
+			[ asciitilde,	dead_macron	]	};
+    key <AC10> {	[ thorn,	Thorn	],
+			[ acute			]	};
+    key <AC11> {	[ i,	Yacute	],
+			[ dead_circumflex		]	};
+    key <BKSL> {	[ comma,	semicolon	],
+			[ grave			]	};
+
+    key <LSGT> {	[      less,	greater		],
+			[       bar			]	};
+    key <AB07> {	[	  m,	M		],
+			[	 mu			]	};
+    key <AB08> {	[     odiaeresis,	Odiaeresis	]	};
+    key <AB09> {	[    ccedilla,	Ccedilla		],
+			[ periodcentered, division	]	};
+    key <AB10> {	[     period,	colon	],
+    			[slash		]		};
+    key <RALT> {	[ Mode_switch,	Multi_key	]	};
+
+    // End alphanumeric section, begin "Keypad"
+    key <KPDL> {	[  KP_Delete,	KP_Separator	]	};
+    // End "Keypad" section
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock };
+    modifier_map Control{ Control_L };
+    modifier_map Mod3	{ Mode_switch };
+};
+
+partial alphanumeric_keys 
+xkb_symbols "Sundeadkeys" {
+    // modify the default Turkish Q layout to use Sun dead keys
+    include "tr(basic)"
+    key <TLDE> {	[ quotedbl,	eacute		],
+			[   notsign 			]	};
+    key <AE12> {	[ minus,		underscore	]		};
+    key <AD11> {	[ eth,	Eth	],
+			[ SunFA_Diaeresis		]	};
+    key <AD12> {	[      udiaeresis,	Udiaeresis	],
+			[ SunFA_Tilde,	dead_macron	]	};
+    key <AC10> {	[ thorn,	Thorn	],
+			[ SunFA_Acute			]	};
+    key <AC11> {	[ i,	Yacute	],
+			[ SunFA_Circum			]	};
+
+    key <BKSL> {	[ comma,	semicolon		],
+			[ SunFA_Grave			]	};
+};
+
+partial alphanumeric_keys 
+xkb_symbols "sundeadkeys" {
+    include "tr(Sundeadkeys)"
+};
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    // modify the default Turkish Q layout to not have any dead keys
+    include "tr(basic)"
+    key <TLDE> {	[ quotedbl,	eacute		],
+			[   notsign 			]	};
+    key <AE12> {	[ minus,		underscore		]	};
+    key <AD11> {	[ eth,	Eth	],
+			[ diaeresis 			]	};
+    key <AD12> {	[      udiaeresis,	Udiaeresis	],
+			[ asciitilde,	macron		]	};
+    key <AC10> {	[ thorn,	Thorn	],
+			[ acute				]	};
+    key <AC11> {	[ i,	Yacute	],
+			[ asciicircum			]	};
+
+    key <BKSL> {	[ comma,	semicolon	],
+			[ grave				]	};
+};
+
Index: xc/programs/xkbcomp/symbols/us
diff -u xc/programs/xkbcomp/symbols/us:3.8 xc/programs/xkbcomp/symbols/us:3.9
--- xc/programs/xkbcomp/symbols/us:3.8	Sat Jun 17 14:23:24 2000
+++ xc/programs/xkbcomp/symbols/us	Fri Oct 27 14:31:09 2000
@@ -6,7 +6,7 @@
 // uses the punctuation keys configurations common on PC 
 // keyboards (e.g. key <ABO9> is { [ period greater ] })
 
-// $XFree86: xc/programs/xkbcomp/symbols/us,v 3.8 2000/06/17 18:23:24 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/us,v 3.9 2000/10/27 18:31:09 dawes Exp $
 
 partial hidden alphanumeric_keys modifier_keys 
 xkb_symbols "basic" {
@@ -223,7 +223,7 @@
     key <LALT> {	[ 	Alt_L		]	};
     key <RALT> {	[	Alt_R		]	};
     key <LWIN> {	[	Meta_L		]	};
-    key <RWIN> {	[	Meta_R		]	};
+    key <RWIN> {	[	Multi_key	]	};
     key <MENU> {	[	Menu		]	};
 
     // modifier mappings
@@ -234,7 +234,8 @@
 // definition of Euro-style, Right "logo" key == [Mode_switch, Multi_key]
 xkb_symbols "pc104euro" {
     include "us(pc104)"
-    key <RWIN> {	[	Mode_switch, Multi_key	]	};
+    key <RALT> {        [       Mode_switch             ]       };
+    key <RWIN> {	[	Multi_key		]	};
 };
 
 // put the compose key on the right "logo" key
Index: xc/programs/xkbcomp/symbols/us_intl
diff -u xc/programs/xkbcomp/symbols/us_intl:1.2 xc/programs/xkbcomp/symbols/us_intl:1.3
--- xc/programs/xkbcomp/symbols/us_intl:1.2	Sun Aug 29 22:28:57 1999
+++ xc/programs/xkbcomp/symbols/us_intl	Fri Oct 27 14:31:10 2000
@@ -1,5 +1,5 @@
 //
-// $XFree86: xc/programs/xkbcomp/symbols/us_intl,v 1.2 1999/08/30 02:28:57 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/us_intl,v 1.3 2000/10/27 18:31:10 dawes Exp $
 //
 // Dead-keys definition for a very simple US/ASCII layout.
 // by Conectiva (http://www.conectiva.com.br)
@@ -11,9 +11,12 @@
     name[Group1]= "US/ASCII";
 
     // Alphanumeric section
-    key <TLDE> {	[ dead_grave,	dead_tilde	]	};
-    key <AE06> {	[	  6,	dead_circumflex	]	};
-    key <AC11> {	[ dead_acute,	dead_diaeresis	]	};
+    key <TLDE> {	[ dead_grave,	dead_tilde	],
+			[      grave,	asciitilde	]	};
+    key <AE06> {	[	  6,	dead_circumflex	],
+			[ asciicircum,	asciicircum	]	};
+    key <AC11> {	[ dead_acute,	dead_diaeresis	],
+			[ apostrophe,	quotedbl	]	};
 
     // End alphanumeric section
 };
Index: xc/programs/xkbcomp/symbols/vn
diff -u /dev/null xc/programs/xkbcomp/symbols/vn:1.2
--- /dev/null	Mon Dec 18 14:35:32 2000
+++ xc/programs/xkbcomp/symbols/vn	Fri Oct 27 20:34:07 2000
@@ -0,0 +1,394 @@
+// vn,  TCVN 5712:1993
+// Le Hong Boi <le.hong.boi@bigfoot.com>
+// August 1999
+// Further modified by Ashley Clark <aclark@debian.org>
+// July 2000 for X 4.0
+//
+// Symbols definition for a very simple US and VN keyboard layout.
+// This is a terrible hack, I use temporarily for myself:
+// Instead of using VN char keysyms (which requires hacking X source
+// and recompile) it use the latin-1 keysyms at the same code
+//
+// toggle US and VN keyboard by Shift + Caps_Lock key
+//
+// --------
+// aclark (2000-07-27)
+// I've modified this to refer to the correct keysyms in the server
+//
+// $XFree86: xc/programs/xkbcomp/symbols/vn,v 1.2 2000/10/28 00:34:07 dawes Exp $
+
+partial modifier_keys
+xkb_symbols "toggle" {
+    include "vn(basic)"
+    key <CAPS> {	[ Control_L,		ISO_Next_Group] };
+    modifier_map Control { <CAPS>, <LCTL> };
+};
+
+
+//partial hidden alphanumeric_keys modifier_keys 
+partial default alphanumeric_keys  
+xkb_symbols "basic" {
+
+    name[Group1]= "US/ASCII";
+    name[Group2]= "Vietnamese";
+    
+    key <ESC>  {	[ Escape			]	};
+
+    // Alphanumeric section
+    key <TLDE> {	[ quoteleft,	asciitilde	],
+			[ quoteleft,	asciitilde	]	};
+    key <AE01> {	[	  1,	exclam 		],
+			[    abreve,	Abreve		]	};
+    key <AE02> {	[	  2,	at		],
+			[ acircumflex,	Acircumflex	]	};
+    key <AE03> {	[	  3,	numbersign	],
+			[ ecircumflex,	Ecircumflex	]	};
+    key <AE04> {	[	  4,	dollar		],
+			[ ocircumflex,	Ocircumflex	]	};
+    key <AE05> {	[	  5,	percent		],
+			[ dead_grave,	percent		]	};
+    key <AE06> {	[	  6,	asciicircum	],	
+			[ dead_hook,	asciicircum	]	};
+    key <AE07> {	[	  7,	ampersand	],
+			[ dead_tilde,	ampersand	]	};
+    key <AE08> {	[	  8,	asterisk	],
+			[ dead_acute,	asterisk	]	};
+    key <AE09> {	[	  9,	parenleft	],
+			[ dead_belowdot,parenleft	]	};
+    key <AE10> {	[	  0,	parenright	],
+			[   dstroke,	Dstroke		]	};
+    key <AE11> {	[     minus,	underscore	],
+			[     minus,	underscore	]	};
+    key <AE12> {	[     equal,	plus		],
+			[     equal,	plus		]	};
+    key <BKSP> {	[ 	BackSpace		],
+			[	BackSpace		]	};
+
+    key  <TAB> {	[ 	Tab,	ISO_Left_Tab	],
+			[	Tab,	ISO_Left_Tab	]	};
+    key <AD01> {	[	  q,	Q 		],
+			[	  q,	Q		]	};
+    key <AD02> {	[	  w,	W		],
+			[	  w,	W		]	};
+    key <AD03> {	[	  e,	E		],
+			[	  e,	E		]	};
+    key <AD04> {	[	  r,	R		],
+			[	  r,	R		]	};
+    key <AD05> {	[	  t,	T		],
+			[	  t,	T		]	};
+    key <AD06> {	[	  y,	Y		],
+			[	  y,	Y		]	};
+    key <AD07> {	[	  u,	U		],
+			[	  u,	U		]	};
+    key <AD08> {	[	  i,	I		],
+			[	  i,	I		]	};
+    key <AD09> {	[	  o,	O		],
+			[	  o,	O		]	};
+    key <AD10> {	[	  p,	P		],
+			[	  p,	P		]	};
+    key <AD11> {	[ bracketleft,	braceleft	],
+			[     uhorn,	Uhorn		]	};
+    key <AD12> {	[ bracketright,	braceright	],
+			[     ohorn,	Ohorn		]	};
+    key <RTRN> {	[ Return			],
+			[ Return			]	};
+
+    key <AC01> {	[	  a,	A 		],
+			[	  a,	A		]	};
+    key <AC02> {	[	  s,	S		],
+			[	  s,	S		]	};
+    key <AC03> {	[	  d,	D		],
+			[	  d,	D		]	};
+    key <AC04> {	[	  f,	F		],
+			[	  f,	F		]	};
+    key <AC05> {	[	  g,	G		],
+			[	  g,	G		]	};
+    key <AC06> {	[	  h,	H		],
+			[	  h,	H		]	};
+    key <AC07> {	[	  j,	J		],
+			[	  j,	J		]	};
+    key <AC08> {	[	  k,	K		],
+			[	  k,	K		]	};
+    key <AC09> {	[	  l,	L		],
+			[	  l,	L		]	};
+    key <AC10> {	[ semicolon,	colon		],
+			[ semicolon,	colon		]	};
+    key <AC11> {	[ quoteright,	quotedbl	],
+			[ quoteright,	quotedbl	]	};
+
+    key <LFSH> {	[ 	 Shift_L		],
+			[	 Shift_L		]	};
+    key <AB01> {	[	  z,	Z 		],
+			[	  z,	Z		]	};
+    key <AB02> {	[	  x,	X		],
+			[	  x,	X		]	};
+    key <AB03> {	[	  c,	C		],
+			[	  c,	C		]	};
+    key <AB04> {	[	  v,	V		],
+			[	  v,	V		]	};
+    key <AB05> {	[	  b,	B		],
+			[	  b,	B		]	};
+    key <AB06> {	[	  n,	N		],
+			[	  n,	N		]	};
+    key <AB07> {	[	  m,	M		],
+			[	  m,	M		]	};
+    key <AB08> {	[     comma,	less		],
+			[     comma,	less		]	};
+    key <AB09> {	[    period,	greater		],
+			[    period,	greater		]	};
+    key <AB10> {	[     slash,	question	],
+			[     slash,	question	]	};
+    key <BKSL> {	[ backslash,	bar		],
+			[ backslash,	bar		]	};
+
+    key <LCTL> {	[ 	 Control_L		],
+			[	 Control_L		]	};
+    key <SPCE> {	[ 	 space			],
+			[	 space			]	};
+    // End alphanumeric section
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_L };
+    modifier_map Lock   { Caps_Lock };
+    modifier_map Control{ Control_L };
+};
+
+// definition of a US/ASCII layout for a typical 101-key keyboard. 
+// Includes the basic alphanumeric and punctuation keys and then 
+// defines the "extra" (right) modifier keys, function keys, cursor,
+// edit, and keypad keys.
+xkb_symbols "generic101" {
+    include "vn(basic)"
+    key <RTSH> {	[ 	Shift_R		],
+			[	Shift_R		]	};
+    key <LALT> {	[ 	Alt_L	 	],
+			[	Alt_L		]	};
+    key <RCTL> {	[ 	Control_R	],
+			[	Control_R	]	};
+    key <RALT> {	[	Alt_R		],
+			[	Alt_R		]	};
+
+    // Begin "Function" section
+    key <FK01> {	[ 	 F1		],
+			[	 F1		]	};
+    key <FK02> {	[	 F2		],
+			[	 F2		]	};
+    key <FK03> {	[	 F3		],
+			[	 F3		]	};
+    key <FK04> {	[	 F4		],
+			[	 F4		]	};
+    key <FK05> {	[	 F5		],
+			[	 F5		]	};
+    key <FK06> {	[	 F6		],
+			[	 F6		]	};
+    key <FK07> {	[	 F7		],
+			[	 F7		]	};
+    key <FK08> {	[	 F8		],
+			[	 F8		]	};
+    key <FK09> {	[        F9		],
+			[	 F9		]	};
+    key <FK10> {	[        F10		],
+			[	 F10		]	};
+    key <FK11> {	[        F11		],
+			[	 F11		]	};
+    key <FK12> {	[ 	 F12		],
+			[	 F12		]	};
+    // End "Function" section
+
+    // Begin "Editing" section
+    key <PRSC> {
+	type= "PC_SYSRQ",
+	symbols[Group1]= [ Print, Execute ]
+    };
+    key <SCLK> {  [  Scroll_Lock	],
+		  [  Scroll_Lock	]	};
+    key <PAUS> {
+	type= "PC_BREAK",
+	symbols[Group1]= [ Pause, Break ]
+    };
+    key  <INS> {  [  Insert		],
+		  [  Insert		]	};
+    key <HOME> {	[  Home			],
+			[  Home			]	};
+    key <PGUP> {	[  Prior		],
+			[  Prior		]	};
+    key <DELE> { 	[  Delete		],
+			[  Delete		]	};
+    key  <END> {	[  End			],
+			[  End			]	};
+    key <PGDN> {	[  Next			],
+			[  Next			]	};
+
+    key   <UP> {	[  Up			],
+			[  Up			]	};
+    key <LEFT> {	[  Left			],
+			[  Left			]	};
+    key <DOWN> {	[  Down			],
+			[  Down			]	};
+    key <RGHT> {	[  Right		],
+			[  Right		]	};
+
+    // End "Editing" section, begin "Keypad"
+    key <NMLK> {	[  Num_Lock, Pointer_EnableKeys	],
+			[  Num_Lock, Pointer_EnableKeys	]	};
+    key <KPDV> {	[  KP_Divide		],
+			[  KP_Divide		]	};
+    key <KPMU> {	[  KP_Multiply		],
+			[  KP_Multiply		]	};
+    key <KPSU> {	[  KP_Subtract		],
+			[  KP_Subtract		]	};
+
+    key  <KP7> {	[  KP_Home,	KP_7	],
+			[  KP_Home,	KP_7	]	};
+    key  <KP8> {	[  KP_Up,	KP_8	],
+			[  KP_Up,	KP_8	]	};
+    key  <KP9> {	[  KP_Prior,	KP_9	],
+			[  KP_Prior,	KP_9	]	};
+    key <KPAD> {	[  	KP_Add		],
+			[	KP_Add		]	};
+
+    key  <KP4> {	[  KP_Left,	KP_4	],
+			[  KP_Left,	KP_4	]	};
+    key  <KP5> {	[  KP_Begin,	KP_5	],
+			[  KP_Begin,	KP_5	]	};
+    key  <KP6> {	[  KP_Right,	KP_6	],
+			[  KP_Right,	KP_6	]	};
+
+    key  <KP1> {	[  KP_End,	KP_1	],
+			[  KP_End,	KP_1	]	};
+    key  <KP2> {	[  KP_Down,	KP_2	],
+			[  KP_Down,	KP_2	]	};
+    key  <KP3> {	[  KP_Next,	KP_3	],
+			[  KP_Next,	KP_3	]	};
+    key <KPEN> {	[  	KP_Enter	],
+			[	KP_Enter	]	};
+
+    key  <KP0> {	[  KP_Insert,	KP_0	],
+			[  KP_Insert,	KP_0	]	};
+    key <KPDL> {  	[  KP_Delete,	KP_Decimal ],
+			[  KP_Delete,	KP_Decimal ]	};
+    // End "Keypad" section
+
+
+    // begin modifier mappings
+    modifier_map Shift  { Shift_R };
+    modifier_map Control{ Control_R };
+    modifier_map Mod1   { Alt_L, Alt_R };
+    modifier_map Mod2   { Num_Lock };
+    modifier_map Mod5   { Scroll_Lock };
+};
+
+// definition for the PC-AT type 101 key keyboard
+//default 
+xkb_symbols "pc101" {
+    include "vn(generic101)"
+    key <LALT> {	[ 	Alt_L,	Meta_L 		],
+			[	Alt_L,	Meta_L		]	};
+    key <RALT> {	[	Alt_R,	Meta_R		],
+			[	Alt_R,	Meta_R		]	};
+
+    // begin modifier mappings
+    modifier_map Mod1   { Alt_L, Alt_R, Meta_L, Meta_R };
+};
+
+// definition for the extra key on 102-key keyboards
+xkb_symbols "pc102" {
+    include "vn(pc101)"
+    key <LSGT> {	[      less,    greater		],
+			[      less,	greater		]	};
+};
+
+// definition of Euro-style, Alt_R == [Mode_switch, Multi_key]
+xkb_symbols "pc101euro" {
+    include "vn(generic101)"
+    key <LALT> {	[ 	Alt_L,	Meta_L 		],
+			[	Alt_L,	Meta_L		]	};
+    key <RALT> {	[ Mode_switch,	Multi_key	],
+			[ Mode_switch,	Multi_key	]	};
+
+    // begin modifier mappings
+    modifier_map Mod1   { Alt_L, Meta_L };
+};
+
+// definition of Alternate Euro-style, Alt_R == [Multi_key]
+xkb_symbols "pc101compose" {
+    include "vn(generic101)"
+    key <LALT> {	[ 	Alt_L,	Meta_L 		],
+			[	Alt_L,	Meta_L		]	};
+    key <RALT> {	[ 	Multi_key		],
+			[	Multi_key		]	};
+
+    // begin modifier mappings
+    modifier_map Mod1   { Alt_L, Meta_L };
+};
+
+xkb_symbols "pc102euro" {
+    include "us(pc101euro)"
+    key <LSGT> {	[      less,    greater		]	};
+};
+
+xkb_symbols "pc102compose" {
+    include "us(pc101compose)"
+    key <LSGT> {	[      less,    greater		]	};
+};
+
+// definition for the extra keys on 104-key "Windows95" keyboards
+xkb_symbols "pc104" {
+    include "vn(generic101)"
+    key <LALT> {	[ 	Alt_L		],
+			[	Alt_L		]	};
+    key <RALT> {	[	Alt_R		],
+			[	Alt_R		]	};
+    key <LWIN> {	[	Meta_L		],
+			[	Meta_L		]	};
+    key <RWIN> {	[	Meta_R		],
+			[	Meta_R		]	};
+    key <MENU> {	[	Menu		],
+			[	Menu		]	};
+
+    // modifier mappings
+    modifier_map Mod1   { Alt_L, Alt_R };
+    modifier_map Mod4   { Meta_L, Meta_R };
+};
+
+// definition of Euro-style, Right "logo" key == [Mode_switch, Multi_key]
+xkb_symbols "pc104euro" {
+    include "vn(pc104)"
+    key <RWIN> {	[	Mode_switch, Multi_key	],
+			[	Mode_switch, Multi_key	]	};
+};
+
+// put the compose key on the right "logo" key
+xkb_symbols "pc104compose" {
+    include "vn(pc104)"
+    key <RWIN> {	[	Multi_key	],
+			[	Multi_key	]	};
+};
+
+// defintion which includes both the Windows95 keyboards _and_
+// the extra key on most European keyboards.
+xkb_symbols "pc105" {
+    include "us(pc104)"
+    key <LSGT> {	[      less,    greater		]	};
+};
+xkb_symbols "pc105euro" {
+    include "us(pc104euro)"
+    key <LSGT> {	[      less,    greater		]	};
+};
+xkb_symbols "pc105compose" {
+    include "us(pc104compose)"
+    key <LSGT> {	[      less,    greater		]	};
+};
+// universam maps are identical to pc105; wish we had aliases for map names.
+xkb_symbols "pc_universal" {
+    include "us(pc104)"
+    key <LSGT> {	[      less,    greater		]	};
+};
+xkb_symbols "pc105euro" {
+    include "us(pc104euro)"
+    key <LSGT> {	[      less,    greater		]	};
+};
+xkb_symbols "pc105compose" {
+    include "us(pc104compose)"
+    key <LSGT> {	[      less,    greater		]	};
+};
Index: xc/programs/xkbcomp/symbols/macintosh/Imakefile
diff -u xc/programs/xkbcomp/symbols/macintosh/Imakefile:1.1 xc/programs/xkbcomp/symbols/macintosh/Imakefile:1.3
--- xc/programs/xkbcomp/symbols/macintosh/Imakefile:1.1	Sun May 23 01:27:52 1999
+++ xc/programs/xkbcomp/symbols/macintosh/Imakefile	Sun Oct  1 22:32:17 2000
@@ -1,9 +1,9 @@
 XCOMM $XConsortium: Imakefile /main/1 1996/01/23 06:59:52 kaleb $
 XCOMM
 XCOMM
-XCOMM $XFree86: xc/programs/xkbcomp/symbols/macintosh/Imakefile,v 1.1 1999/05/23 05:27:52 dawes Exp $
+XCOMM $XFree86: xc/programs/xkbcomp/symbols/macintosh/Imakefile,v 1.3 2000/10/02 02:32:17 tsi Exp $
 
-     DATAFILES = us
+     DATAFILES = de de_CH dk es fi fr fr_CH gb it nl no pt se us
 
 all::
 
Index: xc/programs/xkbcomp/symbols/macintosh/de
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/de:1.1
--- /dev/null	Mon Dec 18 14:35:36 2000
+++ xc/programs/xkbcomp/symbols/macintosh/de	Tue Sep 19 08:46:25 2000
@@ -0,0 +1,144 @@
+// $XConsortium: de /main/4 1996/08/31 12:19:20 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/de,v 1.1 2000/09/19 12:46:25 eich Exp $
+
+// olh@suse.de   very close to MacOS map
+
+default partial alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple German keybaord
+
+    // Alphanumeric section
+    name[Group1]= "German";
+    key <TLDE> {	[ dead_circumflex,	degree	],
+			[   notsign 			]	};
+    key <AE01> {	[         1,    exclam		],
+			[ exclamdown,   at		]	};
+    key <AE02> {	[	  2,	quotedbl	],
+			[ twosuperior			]	};
+    key <AE03> {	[	  3,	section		],
+			[ threesuperior,sterling	]	};
+    key <AE04> {	[	  4,	dollar		],
+			[ onequarter,	currency	]	};
+    key <AE05> {	[	  5,	percent		],
+			[ bracketleft			]	};
+    key <AE06> {	[	  6,	ampersand	],
+			[ bracketright			]	};
+    key <AE07> {	[	  7,	slash		],
+			[       bar,    backslash	]	};
+    key <AE08> {	[	  8,	parenleft	],
+			[ braceleft,    asciitilde	]	};
+    key <AE09> {	[	  9,	parenright	],
+			[braceright			]	};
+    key <AE10> {	[	  0,	equal		],
+			[ braceright,	degree		]	};
+    key <AE11> {	[    ssharp,	question	],
+			[ backslash,	questiondown	]	};
+    key <AE12> {	[ dead_acute,	dead_grave	],
+			[ dead_cedilla			]	};
+
+    key <AD01> {	[	  q,	Q 		],
+			[guillemotleft,guillemotright	]	};
+    key <AD03> {	[	  e,	E		],
+			[  EuroSign			]	};
+    key <AD04> {	[         r,    R		],
+			[ registered			]	};
+    key <AD05> {	[	  t,	T		]	};
+    key <AD06> {	[	  z,	Z		]	};
+    key <AD07> {	[	  u,	U		],
+			[diaeresis,    Aacute		]	};
+    key <AD08> {	[	  i,	I		],
+			[     slash,    Ucircumflex	]	};
+    key <AD09> {	[         o,    O		],
+			[     oslash,   Ooblique	]	};
+    key <AD11> {	[ udiaeresis,	Udiaeresis	],
+			[ periodcentered, degree	]	};
+    key <AD12> {	[      plus,	asterisk	],
+			[ asciitilde			]	}; 
+    key <AC01> {	[         a,    A		],
+			[     aring,    Aring		]	};
+    key <AC04> {	[	  f,	F		]	};
+    key <AC05> {	[	  g,	G		],
+			[ copyright			]	};
+    key <AC06> {	[         h,    H		],
+			[ ordfeminine			]	};
+    key <AC09> {	[	  l,    L		],
+			[	at			]	};
+    key <AC10> {	[ odiaeresis,	Odiaeresis	],
+			[ dead_acute			]	};
+    key <AC11> {	[ adiaeresis,	Adiaeresis	],
+			[ dead_circumflex		]	};
+
+    key <LSGT> {	[      less,	greater		],
+			[       bar			]	};
+    key <AB01> {	[	  y,	Y 		],
+			[ guillemotleft,less		]	};
+    key <AB06> {	[         n,    N		],
+			[asciitilde			]	};
+    key <AB07> {	[	  m,	M		],
+			[	 mu			]	};
+    key <AB08> {	[     comma,	semicolon	]	};
+    key <AB09> {	[    period,	colon		],
+			[ periodcentered, division	]	};
+    key <AB10> {	[     minus,	underscore	]	};
+    key <BKSL> {	[ numbersign,	apostrophe	],
+			[ dead_grave			]	};
+
+    // End alphanumeric section, begin "Keypad"
+    key <KPDL> {	[  KP_Delete,	KP_Separator	]	};
+    // End "Keypad" section
+
+    // begin modifier mappings
+//    modifier_map Shift  { Shift_L };
+//    modifier_map Lock   { Caps_Lock };
+//    modifier_map Control{ Control_L };
+//    modifier_map Mod3	{ Mode_switch };
+};
+
+partial alphanumeric_keys 
+xkb_symbols "Sundeadkeys" {
+    // modify the default German layout to use Sun dead keys
+    include "macintosh/de(basic)"
+    key <TLDE> {	[ SunFA_Circum,	degree		],
+			[   notsign 			]	};
+    key <AE12> {	[ SunFA_Acute,	SunFA_Grave	],
+			[ SunFA_Cedilla			]	};
+    key <AD11> {	[ udiaeresis,	Udiaeresis	],
+			[ SunFA_Diaeresis		]	};
+    key <AD12> {	[      plus,	asterisk	],
+			[ SunFA_Tilde,	dead_macron	]	};
+    key <AC10> {	[ odiaeresis,	Odiaeresis	],
+			[ SunFA_Acute			]	};
+    key <AC11> {	[ adiaeresis,	Adiaeresis	],
+			[ SunFA_Circum			]	};
+
+    key <BKSL> {	[ numbersign,	acute		],
+			[ SunFA_Grave			]	};
+};
+
+partial alphanumeric_keys 
+xkb_symbols "sundeadkeys" {
+    include "macintosh/de(Sundeadkeys)"
+};
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    // modify the default German layout to not have any dead keys
+    include "macintosh/de(basic)"
+    key <TLDE> {	[ asciicircum,	degree		],
+			[   notsign 			]	};
+    key <AE12> {	[ acute,	grave		],
+			[ cedilla			]	};
+    key <AD11> {	[ udiaeresis,	Udiaeresis	],
+			[ diaeresis 			]	};
+    key <AD12> {	[      plus,	asterisk	],
+			[ asciitilde,	macron		]	};
+    key <AC10> {	[ odiaeresis,	Odiaeresis	],
+			[ acute				]	};
+    key <AC11> {	[ adiaeresis,	Adiaeresis	],
+			[ asciicircum			]	};
+
+    key <BKSL> {	[ numbersign,	apostrophe	],
+			[ grave				]	};
+};
Index: xc/programs/xkbcomp/symbols/macintosh/de_CH
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/de_CH:1.2
--- /dev/null	Mon Dec 18 14:35:37 2000
+++ xc/programs/xkbcomp/symbols/macintosh/de_CH	Tue Sep 26 11:57:25 2000
@@ -0,0 +1,150 @@
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/de_CH,v 1.2 2000/09/26 15:57:25 tsi Exp $
+//
+// 06.07.2000
+// Andreas Tobler a.tobler@schweiz.ch
+// modified for Swiss German Apple Extended Keyboard II
+
+xkb_symbols "extended" {
+
+    
+    name[Group1]= "Swiss German Apple Extended Keyboard II";
+    // Alphanumeric section
+    key <TLDE> {	[      less, greater		],
+			[ lessthanequal, greaterthanequal ]	};
+	key <COIN> {	[ section, degree		]	};
+    key <AE01> {	[	  1,	plus 		],
+			[ plusminus,	onesuperior	]	};
+    key <AE02> {	[	  2,	quotedbl	],
+			[ twosuperior,	oneeighth	    ]	};
+    key <AE03> {	[	  3,	asterisk	],
+			[ numbersign, threesuperior	]	};
+    key <AE04> {	[	  4,	ccedilla	],
+    				[	Ccedilla	]	};
+    key <AE05> {	[	  5,	percent		],
+    				[	bracketleft		]	};
+    key <AE06> {	[	  6,	ampersand	],
+					[	bracketright		]	};
+    key <AE07> {	[	  7,	slash		],
+			[ bar, backslash				]	};
+    key <AE08> {	[	  8,	parenleft	],
+			[	braceleft, Ograve			]	};
+    key <AE09> {	[	  9,	parenright	],
+    		[	braceright, Ocircumflex		]	};
+    key <AE10> {	[	  0,	equal		],
+    				[  notequal,	Uacute	]	};
+    key <AE11> {	[ apostrophe,	question	],
+			[         questiondown		]	};
+    key <AE12> {	[ asciicircum,	grave		],
+			[ dead_acute,asciitilde			]	};
+			
+
+    key <AD01> {	[	  q,	Q 		]	};
+
+    key <AD02> {	[	  w,	W		],
+			[    Greek_SIGMA, Aacute	]	};
+
+    key <AD03> {	[	  e,	E		],
+			[    trademark, Ediaeresis	]	};
+
+    key <AD04> {	[	  r,	R		],
+			[ registered, Egrave		]	};
+
+    key <AD05> {	[	  t,	T		],
+			[    dagger, Icircumflex	]	}; 
+
+    key <AD06> {	[	  z,	Z		],
+			[  Greek_OMEGA, Iacute		]	};
+
+    key <AD07> {	[	  u,	U		],
+			[    degree, Ugrave		]	};
+
+    key <AD08> {	[	  i,	I		],
+			[         exclamdown		]	};
+
+    key <AD09> {	[	  o,	O		],
+			[    oslash	]	};
+
+    key <AD10> {	[	  p,	P		],
+			[  Greek_pi,  Greek_PI		]	};
+
+    key <AD11> {	[ udiaeresis, egrave		],
+			[ section, ydiaeresis		]	};
+			
+
+    key <AD12> {	[ dead_diaeresis, exclam	],
+			[      quoteleft, quoteright	]	};
+			
+	key <BKSL> {	[  dollar,   sterling		],
+			[ paragraph, enfilledcircbullet	]	};
+
+
+    key <AC01> {	[	  a,	A 		],
+			[     aring, Aring		]	};
+
+    key <AC02> {	[	  s,	S		],
+			[         ssharp		]	}; 
+
+    key <AC03> {	[	  d,	D		],
+			[	Greek_delta		]	};
+
+    key <AC04> {	[	  f,	F		],
+			[   section, doubledagger	]	};
+
+    key <AC05> {	[	  g,	G		],
+			[        at, comma		]	};
+
+    key <AC06> {	[	  h,	H		],
+			[  ordfeminine, periodcentered	]	};
+
+    key <AC07> {	[	  j,	J		],
+			[	masculine]		};
+
+    key <AC08> {	[	  k,	K		]	};
+
+    key <AC09> {	[	  l,	L		],
+    			[	notsign	]	};
+
+    key <AC10> {	[ odiaeresis,   eacute		],
+    			[	cent	]	};
+
+    key <AC11> {	[ adiaeresis,   agrave		],
+			[         ae, AE		]	};
+
+    
+    
+    key <AB01> {	[	  y,	Y 		],
+			[	yen, Ydiaeresis		]	};
+
+    key <AB02> {	[	  x,	X		],
+			[similarequal,	ydiaeresis	]	};
+
+    key <AB03> {	[	  c,	C		],
+			[ copyright, diamond		]	};
+
+    key <AB04> {	[	  v,	V		]	};
+
+    key <AB05> {	[	  b,	B		],
+			[    ssharp			]	};  
+
+    key <AB06> {	[	  n,	N		],
+			[       dead_tilde		]       };
+
+    key <AB07> {	[	  m,	M		],
+			[        mu			]       };
+
+    key <AB08> {	[     comma,	semicolon	],
+			[ guillemotleft, guillemotright ]	};
+
+    key <AB09> {	[    period, colon		],
+			[    Nosymbol, division		]	};
+
+    key <AB10> {        [     minus, underscore		],
+			[    emdash, endash		]	};
+
+    key <SPCE> {	[  space			],
+			[nobreakspace,	nobreakspace	]	};
+    // End alphanumeric section
+    
+    key <KPDL> {	[  KP_Separator , KP_Delete	]	};
+
+};
Index: xc/programs/xkbcomp/symbols/macintosh/dk
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/dk:1.1
--- /dev/null	Mon Dec 18 14:35:38 2000
+++ xc/programs/xkbcomp/symbols/macintosh/dk	Tue Sep 19 08:46:25 2000
@@ -0,0 +1,92 @@
+// $XConsortium: dk /main/3 1996/08/31 12:19:29 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/dk,v 1.1 2000/09/19 12:46:25 eich Exp $
+partial alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a Danish keyboard with dead key support
+    // and all of ISO-8859-1 characters available.
+
+    name[Group1]= "Danish";
+
+    key <TLDE> {	[         onehalf,         section      ],
+			[   threequarters,       paragraph	]};
+    key <LSGT> {	[	     less,	   greater	],
+			[	backslash,         notsign	]};
+    key <SPCE> {	[	    space,	     space	],
+			[    nobreakspace,    nobreakspace	]};
+    key <AE01> {	[               1,          exclam  	],
+			[      exclamdown,     onesuperior	]};
+    key <AE02> {	[               2,        quotedbl  	],
+			[	       at,     twosuperior	]};
+    key <AE03> {	[              	3,	numbersign	],
+			[	 sterling,   threesuperior	]};
+    key <AE04> {	[               4,        currency     	],
+			[	   dollar,	onequarter	]};
+    key <AE05> {	[               5,         percent     	],
+			[        NoSymbol,	      cent	]};
+    key <AE06> {	[               6,       ampersand     	],
+			[	      yen,	  NoSymbol	]};
+    key <AE07> {	[               7,           slash     	],
+			[       braceleft,        division	]};
+    key <AE08> {	[               8,       parenleft     	],
+			[     bracketleft,   guillemotleft	]};
+    key <AE09> {	[               9,      parenright     	],
+			[    bracketright,  guillemotright	]};
+    key <AE10> {	[               0,           equal     	],
+                        [      braceright,          degree      ]};
+    key <AB08> {	[           comma,       semicolon     	],
+			[    dead_cedilla,     dead_ogonek	]};
+    key <AB09> {	[          period,           colon     	],
+			[  periodcentered,   dead_abovedot	]};
+    key <AB03> {        [               c,               C      ],
+                        [       copyright,        NoSymbol      ]};
+    key <AB10> {	[           minus,      underscore     	],
+			[	   hyphen,          macron	]};
+    key <AC01> {        [               a,               A      ],
+                        [     ordfeminine,       masculine      ]};
+    key <AC03> {        [               d,               D      ],
+                        [             eth,             ETH      ]};
+    key <AD03> {        [               e,               E      ],
+                        [        NoSymbol,            cent      ]};
+    key <AD04> {        [               r,               R      ],
+                        [      registered,        NoSymbol      ]};
+    key <AD05> {        [               t,               T      ],
+                        [           thorn,           THORN      ]};
+    key <AD08> {        [               i,               I      ],
+                        [        NoSymbol,        NoSymbol      ]};
+    key <AD09> {        [               o,               O      ],
+                        [              oe,              OE      ]};
+    key	<AC10> {	[	       ae,	        AE	]};
+    key <AE11> {	[            plus,        question      ],
+			[       plusminus,    questiondown	]};
+    key <AC11> {	[	   oslash,        Ooblique 	]};
+    key <BKSL> {	[      apostrophe,        asterisk	],
+                 	[dead_doubleacute,        multiply      ]};
+    key <AD11> {	[	    aring,           Aring 	]};
+    key <AE12> {   	[      dead_acute,      dead_grave      ],
+                 	[             bar,       brokenbar      ]};
+    key <AD12> {   	[  dead_diaeresis, dead_circumflex      ],
+                 	[      dead_tilde,      dead_caron      ]};
+
+
+    // End alphanumeric section
+
+};
+
+
+partial default alphanumeric_keys 
+xkb_symbols "full" {
+    include "iso9995-3(full)"
+    include "dk(basic)"
+};
+
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    include "macintosh/dk(basic)"
+    key <AE12> {	[	    acute,	     grave	],	
+			[	      bar,	    ogonek	]	};
+    key <AD12> {	[       diaeresis,     asciicircum     	],	
+			[      asciitilde,     dead_macron     	]      	};
+};
Index: xc/programs/xkbcomp/symbols/macintosh/es
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/es:1.2
--- /dev/null	Mon Dec 18 14:35:38 2000
+++ xc/programs/xkbcomp/symbols/macintosh/es	Tue Sep 26 11:57:25 2000
@@ -0,0 +1,50 @@
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/es,v 1.2 2000/09/26 15:57:25 tsi Exp $
+//
+
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple mac_US
+    // keyboard and a very simple Spanish keybaord
+
+    name[Group1]= "Spanish";
+
+    key <TLDE> {	[     bracketleft,    bracketright	],	
+    			[       braceleft,      braceright	]	};
+    key <LSGT> {	[	     less,	   greater	],
+			[     bracketleft,       braceleft	]	};
+    key <AE01> {	[         	1,	exclam 		]	};
+    key <AE02> {	[               2,      exclamdown     	],	
+			[	       at,	 oneeighth	]	};
+    key <AE03> {	[               3,      numbersign     	],
+			[   guillemotleft,  guillemotright	]	};
+    key <AE04> {	[               4,          dollar     	],	
+			[	      yen,     Icircumflex	]	};
+    key <AE05> {	[		5,         percent	]	};
+    key <AE06> {	[               6,           slash     	],	
+			[	backslash,      Idiaeresis	]	};
+    key <AE07> {	[               7,       ampersand     	],
+			[	      bar,          Iacute	]	};
+    key <AE08> {	[               8,        asterisk     	],
+			[		degree			]	};
+    key <AE09> {	[               9,       parenleft     	],
+			[	 sterling,     Ocircumflex	]	};
+    key <AE10> {	[               0,      parenright     	]	};
+    key <AE11> {	[           minus,      underscore	]	};
+    key <AE12> {	[           equal,            plus	],
+			[               plusminus		]	};
+    key <AD11> {	[      dead_grave,          degree 	]	};
+    key <AD12> {	[      dead_acute,   dead_diaeresis    	],
+			[               bar			]	};
+
+    key <AB08> {	[           comma,    questiondown   	]	};
+    key <AB09> {	[          period,        question     	]	};
+    key <AB10> {	[        ccedilla,        Ccedilla     	]	};
+    key	<AC10> {	[	   ntilde,          Ntilde  	],	
+			[      asciitilde,dead_doubleacute	]	};
+    key <AC11> {	[       semicolon,    	     colon 	]	};
+    key <BKSL> {	[      apostrophe,        quotedbl	]	};
+
+    // End alphanumeric section
+
+};
Index: xc/programs/xkbcomp/symbols/macintosh/fi
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/fi:1.2
--- /dev/null	Mon Dec 18 14:35:39 2000
+++ xc/programs/xkbcomp/symbols/macintosh/fi	Tue Sep 26 11:57:25 2000
@@ -0,0 +1,19 @@
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/fi,v 1.2 2000/09/26 15:57:25 tsi Exp $
+//
+
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple mac_US
+    // keyboard and a very simple Swedish(Finland) keybaord
+
+    name[Group1]= "Finnish";
+    include "macintosh/se(basic)" // for consistent naming
+
+};
+
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    include "macintosh/se(basic)"	// for consistent naming
+};
Index: xc/programs/xkbcomp/symbols/macintosh/fr
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/fr:1.2
--- /dev/null	Mon Dec 18 14:35:39 2000
+++ xc/programs/xkbcomp/symbols/macintosh/fr	Tue Sep 26 11:57:25 2000
@@ -0,0 +1,101 @@
+// $XConsortium: macintosh /main/10 1996/01/29 19:54:54 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/fr,v 1.2 2000/09/26 15:57:25 tsi Exp $
+//
+
+xkb_symbols "extended" {
+
+    name[Group1]= "FR-1";
+
+    // Alphanumeric section
+    key <LSGT> {	[        less,	  greater   	]	};
+    key <TLDE> {        [        at,    numbersign      ],
+                        [   periodcentered              ]	};
+    key <AE01> {	[   ampersand,	  1    		],
+	 					[   dead_acute,   dead_acute] };
+    key <AE02> {	[      eacute,	  2 		]	};
+    key <AE03> {	[    quotedbl,	  3         	]	};
+    key <AE04> {	[  quoteright,	  4    		],
+                        [   quoteleft                   ]	};
+    key <AE05> {	[   parenleft,	  5    		],
+              	        [   braceleft,    bracketleft 	]	};
+    key <AE06> {	[     section,	  6          	],
+                        [   paragraph                   ]	};
+    key <AE07> {	[      egrave,	  7        	],
+                        [ guillemotleft, guillemotright ]	};
+    key <AE08> {	[      exclam,	  8       	],
+                        [  exclamdown,    Ucircumflex   ]	};
+    key <AE09> {	[    ccedilla,    9        	],
+                        [    Ccedilla,    Aacute        ]	};
+    key <AE10> {	[      agrave,	  0         	],
+                        [      oslash,    Ooblique      ]	};
+    key <AE11> {	[  parenright,	  degree       	],
+                	[  braceright,	  bracketright  ] 	};
+    key <AE12> {	[       minus, 	  underscore	]	};
+
+    key <AD01> {	[	    a,	A 		],
+                	[          ae,	AE              ] 	};
+    key <AD02> {	[	    z,	Z		],
+                	[ Acircumflex,	Aring           ] 	};
+    key <AD03> {	[	    e,	E		],
+                	[ ecircumflex,	Ecircumflex     ] 	};
+    key <AD04> {	[	    r,	R		],
+                	[  registered,	currency        ] 	};
+    key <AD05> {	[	    t,	T		]	};
+    key <AD06> {	[	    y,	Y		],
+                	[      Uacute,	ydiaeresis      ] 	};
+    key <AD07> {	[	    u,	U		]	};
+    key <AD08> {	[	    i,	I		],
+                	[ icircumflex,	idiaeresis      ] 	};
+    key <AD09> {	[	    o,	O		]	};
+    key <AD10> {	[	    p,	P		]	};
+    key <AD11> {	[ dead_circumflex,  dead_diaeresis  ],
+                	[ ocircumflex,	Ocircumflex     ] 	};
+    key <AD12> {	[      dollar,	asterisk        ],
+                	[       comma,	yen             ] 	};
+    key <BKSL> {	[   	dead_grave,  sterling        ],
+			[          at,  numbersign      ]	};
+
+    key <AC01> {	[	  q,	Q 		]	,
+                	[ acircumflex,	Acircumflex     ] 	};
+    key <AC02> {	[	  s,	S		],
+			[    Ograve,    S               ]	};
+    key <AC03> {	[	  d,	D		]	};
+    key <AC04> {	[	  f,	F		],
+			[         f,    periodcentered  ]	};
+    key <AC05> {	[	  g,	G		]	};
+    key <AC06> {	[	  h,	H		],
+			[    Igrave,    Icircumflex     ]	};
+    key <AC07> {	[	  j,	J		],
+			[ Idiaeresis,   Iacute          ]	};
+    key <AC08> {	[	  k,	K		],
+			[    Egrave,    Ediaeresis      ]	};
+    key <AC09> {	[	  l,	L		],
+			[    ssharp,    bar		]	};
+    key <AC10> {	[         m,	M    		],
+			[        mu,    Oacute		]	};
+    key <AC11> {	[    ugrave,	percent 	],
+			[    Ugrave,    ucircumflex	]	};
+    key <RTRN> {	[    Return,	Return		],
+			[    hyphen,    hyphen		]	};
+
+    key <AB01> {	[	  w,	W 		]	};
+    key <AB02> {	[	  x,	X		]	};
+    key <AB03> {	[	  c,	C		],
+			[ copyright,    copyright	]	};
+    key <AB04> {	[	  v,	V		]	};
+    key <AB05> {	[	  b,	B		]	};
+    key <AB06> {	[	  n,	N		],
+                        [ dead_tilde                    ]       };
+    key <AB07> {	[     comma,	question	],
+			[        at,    questiondown	]	};
+    key <AB08> {	[ semicolon,	period          ]	};
+    key <AB09> {	[     colon,	slash  		],
+			[  division,    backslash	]	};
+    key <AB10> {	[     equal,	plus    	],
+			[    macron,    plusminus	]	};
+
+    // End alphanumeric section
+    key <KPDL> {        [ KP_Separator , KP_Delete      ]       };
+
+};
+
Index: xc/programs/xkbcomp/symbols/macintosh/fr_CH
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/fr_CH:1.2
--- /dev/null	Mon Dec 18 14:35:40 2000
+++ xc/programs/xkbcomp/symbols/macintosh/fr_CH	Wed Dec  6 17:00:46 2000
@@ -0,0 +1,28 @@
+// $XConsortium: fr_CH /main/3 1996/08/31 12:19:48 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/fr_CH,v 1.2 2000/12/06 22:00:46 dawes Exp $
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple US/ASCII
+    // keyboard and a very simple Swiss/French keybaord
+
+    include "macintosh/de_CH"
+    name[Group1]= "Swiss French";
+
+    override key <AD11> {
+	[ egrave,	udiaeresis	],
+	[ bracketleft			]
+    };
+    override key <AC10> {
+	[ eacute,	odiaeresis	]
+    };
+    override key <AC11> {
+	[ agrave,	adiaeresis	],
+	[  braceleft			]
+    };
+};
+
+partial alphanumeric_keys
+xkb_symbols "nodeadkeys" {
+    include "macintosh/fr_CH" // for consistent naming
+};
Index: xc/programs/xkbcomp/symbols/macintosh/gb
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/gb:1.1
--- /dev/null	Mon Dec 18 14:35:41 2000
+++ xc/programs/xkbcomp/symbols/macintosh/gb	Tue Sep 19 08:46:25 2000
@@ -0,0 +1,19 @@
+// $XConsortium: gb /main/3 1996/08/31 12:19:51 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/gb,v 1.1 2000/09/19 12:46:25 eich Exp $
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple U.K. keyboard layout
+
+
+    name[Group1]= "Great Britain";
+
+    key <AE03> {	[               3,        sterling     	],
+			[      numbersign			]	};
+
+    // End alphanumeric section
+    
+};
+
+
Index: xc/programs/xkbcomp/symbols/macintosh/it
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/it:1.2
--- /dev/null	Mon Dec 18 14:35:41 2000
+++ xc/programs/xkbcomp/symbols/macintosh/it	Tue Sep 26 11:57:25 2000
@@ -0,0 +1,95 @@
+// $XConsortium: macintosh /main/10 1996/01/29 19:54:54 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/it,v 1.2 2000/09/26 15:57:25 tsi Exp $
+//
+
+xkb_symbols "extended" {
+
+    name[Group1]= "italian";
+
+    // Alphanumeric section
+    key <LSGT> {	[        less,	  greater   	]	};
+    key <TLDE> {        [        at,    numbersign      ],
+                        [   periodcentered              ]	};
+    key <AE01> {	[   ampersand,	  1    		],
+			[guillemotleft,guillemotright	]	};
+    key <AE02> {	[    quotedbl,	  2 		]	};
+    key <AE03> {	[       acute,	  3         	]	};
+    key <AE04> {	[   parenleft,	  4    		],
+                        [   braceleft,    bracketleft	]	};
+    key <AE05> {	[    ccedilla,	  5    		],
+              	        [    Ccedilla,    Iacute	]	};
+    key <AE06> {	[      eacute,	  6          	],
+                        [   paragraph,    periodcentered]	};
+    key <AE07> {	[  parenright,	  7        	],
+                        [  braceright,	  bracketright	]	};
+    key <AE08> {	[    sterling,	  8       	],
+                        [  infinity			]	};
+    key <AE09> {	[      aacute,    9        	],
+                        [       acute,    Ocircumflex	]	};
+    key <AE10> {	[      egrave,	  0         	],
+                        [       grave,    Oacute	]	};
+    key <AE11> {	[       minus,	  underscore	]	};
+    key <AE12> {	[       equal, 	  plus		],
+			[    notequal,    plusminus	]	};
+
+    key <AD01> {	[           q,	Q 		]	};
+    key <AD02> {	[	    z,	Z		]	};
+    key <AD03> {	[	    e,	E		]	};
+    key <AD04> {	[	    r,	R		],
+                	[  registered			] 	};
+    key <AD05> {	[	    t,	T		]	};
+    key <AD06> {	[	    y,	Y		],
+                	[      Uacute,	ydiaeresis      ] 	};
+    key <AD07> {	[	    u,	U		]	};
+    key <AD08> {	[	    i,	I		],
+                	[ icircumflex,	idiaeresis      ] 	};
+    key <AD09> {	[	    o,	O		]	};
+    key <AD10> {	[	    p,	P		]	};
+    key <AD11> {	[      iacute,  dead_diaeresis  ]	};
+    key <AD12> {	[      dollar,	asterisk        ]	};
+    key <BKSL> {	[     section,  degree		],
+			[          at,  numbersign      ]	};
+
+    key <AC01> {	[	  a,	A 		]	,
+                	[     aring,   Aring		] 	};
+    key <AC02> {	[	  s,	S		],
+			[    ssharp			]	};
+    key <AC03> {	[	  d,	D		]	};
+    key <AC04> {	[	  f,	F		]	};
+    key <AC05> {	[	  g,	G		]	};
+    key <AC06> {	[	  h,	H		],
+			[    Igrave,    Icircumflex     ]	};
+    key <AC07> {	[	  j,	J		],
+			[ Idiaeresis,   Iacute          ]	};
+    key <AC08> {	[	  k,	K		],
+			[    Egrave,    Ediaeresis      ]	};
+    key <AC09> {	[	  l,	L		],
+			[    ssharp,    bar		]	};
+    key <AC10> {	[         m,	M    		],
+			[        mu,    Oacute		]	};
+    key <AC11> {	[    ugrave,	percent 	],
+			[        ae,    AE		]	};
+
+    key <AB01> {	[	  w,	W 		]	};
+    key <AB02> {	[	  x,	X		]	};
+    key <AB03> {	[	  c,	C		],
+			[ copyright,    copyright	]	};
+    key <AB04> {	[	  v,	V		]	};
+    key <AB05> {	[	  b,	B		]	};
+    key <AB06> {	[	  n,	N		],
+                        [ dead_tilde                    ]       };
+    key <AB07> {	[     comma,	question	],
+			[         questiondown		]	};
+    key <AB08> {	[ semicolon,	period          ]	};
+    key <AB09> {	[     colon,	slash  		],
+			[       bar,    backslash	]	};
+    key <AB10> {	[    oacute,	exclam    	],
+			[    exclamdown			]	};
+
+    // End alphanumeric section
+
+    key <KPDL> {	[ KP_Decimal , KP_Delete	]	};
+    // End "Keypad" section
+
+};
+
Index: xc/programs/xkbcomp/symbols/macintosh/nl
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/nl:1.2
--- /dev/null	Mon Dec 18 14:35:42 2000
+++ xc/programs/xkbcomp/symbols/macintosh/nl	Tue Sep 26 11:57:25 2000
@@ -0,0 +1,15 @@
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/nl,v 1.2 2000/09/26 15:57:25 tsi Exp $
+//
+
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple mac_US
+    // keyboard and a very simple netherland keybaord
+
+    name[Group1]= "Netherland";
+
+// do just nothing
+
+};
+
Index: xc/programs/xkbcomp/symbols/macintosh/no
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/no:1.1
--- /dev/null	Mon Dec 18 14:35:42 2000
+++ xc/programs/xkbcomp/symbols/macintosh/no	Tue Sep 19 08:46:25 2000
@@ -0,0 +1,58 @@
+// $XConsortium: no /main/3 1996/08/31 12:20:02 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/no,v 1.1 2000/09/19 12:46:25 eich Exp $
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Norwegian keybaord
+
+    name[Group1]= "Norwegian";
+
+    key <TLDE> {	[             bar,         section      ]	};
+    key <AE02> {	[               2,        quotedbl     	],	
+			[	       at,	 oneeighth	]	};
+    key <AE04> {	[	        4,        currency	],
+			[	   dollar,	    dollar	]	};
+    key <AE03> {	[               3,	numbersign 	],
+			[        sterling,        sterling	]	};
+    key <AE06> {	[               6,       ampersand     	]	};
+    key <AE07> {	[               7,           slash     	],
+			[	      bar,       backslash	]  	};
+    key <AE08> {	[               8,       parenleft     	],
+			[     bracketleft,	 braceleft	]	};
+    key <AE09> {	[               9,      parenright     	],
+			[    bracketright,      braceright	]	};
+    key <AE10> {	[               0,           equal     	]	};
+
+    key <AB08> {	[           comma,       semicolon     	]	};
+    key <AB09> {	[          period,           colon     	]	};
+    key <AB10> {	[           minus,      underscore     	]	};
+    key	<AC10> {	[	   oslash,        Ooblique  	],
+			[      odiaeresis,     Odiaeresis	]	};
+    key <AE11> {	[            plus,        question      ]	};
+    key <AC11> {	[              ae,              AE 	]	};
+    key <AD11> {	[	    aring,           Aring     	]	};
+    key <AE12> {	[      dead_grave,      dead_acute	],
+			[	    acute,     dead_ogonek 	]	};
+    key <AD12> {	[       diaeresis,     asciicircum     	],	
+			[      asciitilde,     dead_macron     	]      	};
+    key <BKSL> {	[              at,        asterisk	]	};
+    key <LSGT> {	[            less,         greater	]	};
+
+    // End alphanumeric section
+
+};
+
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+
+    // Modifies the basic Norwegian layout to eliminate dead keys
+
+    include "macintosh/no(basic)"
+    key <AE12> {	[           grave,           acute	],
+			[	    acute,          ogonek 	]	};
+    key <AD12> {	[       diaeresis,     asciicircum     	],	
+			[      asciitilde,          macron     	]      	};
+
+};
Index: xc/programs/xkbcomp/symbols/macintosh/pt
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/pt:1.1
--- /dev/null	Mon Dec 18 14:35:43 2000
+++ xc/programs/xkbcomp/symbols/macintosh/pt	Tue Sep 19 08:46:25 2000
@@ -0,0 +1,66 @@
+// $XConsortium: pt /main/3 1996/08/31 12:20:08 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/pt,v 1.1 2000/09/19 12:46:25 eich Exp $
+// mac version from Ricardo Cabral <bfe00991@mail.telepac.pt>
+
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Portuguese keybaord
+
+    name[Group1]= "Portuguese";
+
+    key <LSGT> {	[	     less,	   greater	],
+			[	      bar,       brokenbar	]	};
+    key <AE02> {	[               2,	  quotedbl    	],	
+			[	       at,       oneeighth	]	};
+    key <AE04> {	[               4,	    dollar     	],
+			[         section,          dollar	]	};
+    key <AE03> {	[               3,	numbersign     	],
+			[        sterling,        sterling     	]	};
+    key <AE06> {	[               6,       ampersand     	]	};
+    key <AE07> {	[               7,           slash     	]	};
+    key <AE08> {	[               8,       parenleft     	],
+			[     bracketleft,       braceleft     	]	};
+    key <AE09> {	[               9,      parenright      ],
+			[    bracketright,      braceright     	]	};
+    key <AE10> {	[               0,           equal      ]	};
+    key <AE11> {	[      apostrophe,        question      ]	};
+    key <AE12> {	[	     plus,        asterisk 	],
+    			[            dead_diaeresis             ]	};
+    key <AB08> {	[           comma,       semicolon     	]	};
+    key <AB09> {	[          period,           colon      ]	};
+    key <AB10> {	[           minus,      underscore      ]	};
+    key <AC10> {	[        ccedilla,        Ccedilla      ]	};
+    key <AC11> {	[      dead_tilde, dead_circumflex	]	};
+    key <AC12> {	[       backslash,	       bar     	]	};
+    key <AD11> {	[       masculine,     ordfeminine      ]	};
+    key <AD12> {	[      dead_acute,      dead_grave 	]	};
+    // End alphanumeric section
+
+};
+
+partial alphanumeric_keys 
+xkb_symbols "Sundeadkeys" {
+    include "macintosh/pt(basic)" // for consistent naming
+    
+    key <AE12> {	[	     plus,        asterisk 	],
+			[ SunFA_Diaeresis, SunFA_Diaeresis      ]	};
+    key <AC11> {	[     SunFA_Tilde,    SunFA_Circum	]	};
+    key <AD12> {	[     SunFA_Acute,     SunFA_Grave 	]	};
+};
+
+partial alphanumeric_keys 
+xkb_symbols "sundeadkeys" {
+    include "macintosh/pt(Sundeadkeys)" // for consistent naming
+};
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    include "macintosh/pt(basic)" // for consistent naming
+
+    key <AE12> {	[	     plus,        asterisk 	],
+			[	 quotedbl,        quotedbl      ]	};
+    key <AC11> {	[      asciitilde,     asciicircum	]	};
+    key <AD12> {	[	    acute,           grave 	]	};
+};
Index: xc/programs/xkbcomp/symbols/macintosh/se
diff -u /dev/null xc/programs/xkbcomp/symbols/macintosh/se:1.2
--- /dev/null	Mon Dec 18 14:35:43 2000
+++ xc/programs/xkbcomp/symbols/macintosh/se	Tue Dec  5 16:18:39 2000
@@ -0,0 +1,56 @@
+// $XConsortium: se /main/3 1996/08/31 12:20:15 kaleb $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/se,v 1.2 2000/12/05 21:18:39 dawes Exp $
+partial default alphanumeric_keys 
+xkb_symbols "basic" {
+
+    // Describes the differences between a very simple en_US
+    // keyboard and a very simple Swedish(Sweden) keybaord
+
+    name[Group1]= "Swedish";
+
+    key <TLDE> {	[         section,         degree	]	};
+
+    key <AE01> {	[               1,          exclam	],
+			[       copyright,      exclamdown	]	};
+    key <AE02> {	[               2,        quotedbl     	],	
+			[	       at,	 oneeighth	]	};
+    key <AE03> {	[               3,      numbersign      ],	
+			[        sterling,             yen	]	};
+    key <AE04> {	[               4,        currency     	],	
+			[	   dollar,	      cent	]	};
+    key <AE06> {	[               6,       ampersand     	]	};
+    key <AE07> {	[               7,           slash     	],
+			[	      bar,       backslash	]	};
+    key <AE08> {	[               8,       parenleft     	],
+			[     bracketleft,       braceleft	]	};
+    key <AE09> {	[               9,      parenright	],
+			[    bracketright,      braceright	]	};
+    key <AB08> {	[           comma,       semicolon     	]	};
+    key <AE10> {	[               0,           equal     	]	};
+    key <AB09> {	[          period,           colon     	]	};
+    key <AB10> {	[           minus,      underscore     	]	};
+    key	<AC10> {	[      odiaeresis,      Odiaeresis     	],
+			[	   oslash,	    Ooblique	]	};
+    key <AE11> {	[            plus,        question      ]	};
+    key <AC11> {	[      adiaeresis,      Adiaeresis 	],
+			[              ae,		AE	]	};
+    key <AD11> {	[	    aring,           Aring     	]	};
+    key <AE12> {	[           acute,           grave	]	};
+    key <AD12> {	[       diaeresis,     asciicircum     	],
+    			[	asciitilde			]	};
+    key <BKSL> {	[      apostrophe,        asterisk	],
+			[              at			]	};
+    key <LSGT> {        [            less,         greater      ],
+                        [             bar,       brokenbar      ]       };
+    key <KPDL> {	[	KP_Delete,    KP_Separator	]	};
+
+
+    // End alphanumeric section
+
+};
+
+
+partial alphanumeric_keys 
+xkb_symbols "nodeadkeys" {
+    include "macintosh/se(basic)" // for consistent naming
+};
Index: xc/programs/xkbcomp/symbols/macintosh/us
diff -u xc/programs/xkbcomp/symbols/macintosh/us:1.1 xc/programs/xkbcomp/symbols/macintosh/us:1.3
--- xc/programs/xkbcomp/symbols/macintosh/us:1.1	Sun May 23 01:27:52 1999
+++ xc/programs/xkbcomp/symbols/macintosh/us	Fri Sep 29 04:59:49 2000
@@ -1,6 +1,10 @@
 // $XConsortium: macintosh /main/10 1996/01/29 19:54:54 kaleb $
-// $XFree86: xc/programs/xkbcomp/symbols/macintosh/us,v 1.1 1999/05/23 05:27:52 dawes Exp $
+// $XFree86: xc/programs/xkbcomp/symbols/macintosh/us,v 1.3 2000/09/29 08:59:49 eich Exp $
 
+
+// some symbols need a special charset, most symbols not added yet
+// /dev/busy
+
 xkb_symbols "extended" {
 
     name[Group1]= "US/ASCII";
@@ -8,26 +12,40 @@
 
     // Alphanumeric section
     key <TLDE> {	[ quoteleft,	asciitilde	]	};
-    key <AE01> {	[	  1,	exclam 		]	};
-    key <AE02> {	[	  2,	at		]	};
-    key <AE03> {	[	  3,	numbersign	]	};
-    key <AE04> {	[	  4,	dollar		]	};
-    key <AE05> {	[	  5,	percent		]	};
-    key <AE06> {	[	  6,	asciicircum	]	};
-    key <AE07> {	[	  7,	ampersand	]	};
-    key <AE08> {	[	  8,	asterisk	]	};
-    key <AE09> {	[	  9,	parenleft	]	};
+    key <LSGT> {	[ quoteleft,	asciitilde	]	};
+    key <AE01> {	[	  1,	exclam 		],
+			[exclamdown,    slash		]	};
+    key <AE02> {	[	  2,	at		],
+			[ trademark,    eth		]	};
+    key <AE03> {	[	  3,	numbersign	],
+			[ sterling			]	};
+    key <AE04> {	[	  4,	dollar		],
+			[      cent			]	};
+    key <AE05> {	[	  5,	percent		],
+			[  infinity			]	};
+    key <AE06> {	[	  6,	asciicircum	],
+			[ section			]	};
+    key <AE07> {	[	  7,	ampersand	],
+			[ paragraph			]	};
+    key <AE08> {	[	  8,	asterisk	],
+			[periodcentered			]	};
+    key <AE09> {	[	  9,	parenleft	],
+			[ordfeminine			]	};
     key <AE10> {	[	  0,	parenright	]	};
     key <AE11> {	[     minus,	underscore	]	};
-    key <AE12> {	[     equal,	plus		]	};
-    key <BKSP> {	[ 	Delete			]	};
+    key <AE12> {	[     equal,	plus		],
+			[  notequal,    plusminus	]	};
+    key <BKSP> {	[ BackSpace,    Delete		]	};
 
     key  <TAB> {	[ 	Tab,	ISO_Left_Tab	]	};
-    key <AD01> {	[	  q,	Q 		]	};
+    key <AD01> {	[	  q,	Q 		],
+			[        oe,	OE		]	};
     key <AD02> {	[	  w,	W		]	};
     key <AD03> {	[	  e,	E		]	};
-    key <AD04> {	[	  r,	R		]	};
-    key <AD05> {	[	  t,	T		]	};
+    key <AD04> {	[	  r,	R		],
+			[registered			]	};
+    key <AD05> {	[	  t,	T		],
+			[    dagger			]	};
     key <AD06> {	[	  y,	Y		]	};
     key <AD07> {	[	  u,	U		]	};
     key <AD08> {	[	  i,	I		]	};
@@ -35,29 +53,40 @@
     key <AD10> {	[	  p,	P		]	};
     key <AD11> {	[ bracketleft,	braceleft	]	};
     key <AD12> {	[ bracketright,	braceright	]	};
-    key <BKSL> {	[ backslash,	bar		]	};
+    key <BKSL> {	[ backslash,	bar		],
+			[guillemotleft,guillemotright	]	};
 
     key <CAPS> {	[	Caps_Lock		]	};
-    key <AC01> {	[	  a,	A 		]	};
-    key <AC02> {	[	  s,	S		]	};
-    key <AC03> {	[	  d,	D		]	};
-    key <AC04> {	[	  f,	F		]	};
-    key <AC05> {	[	  g,	G		]	};
+    key <AC01> {	[	  a,	A 		],
+			[     aring,    Aring		]	};
+    key <AC02> {	[	  s,	S		],
+			[    ssharp,    Iacute		]	};
+    key <AC03> {	[	  d,	D		],
+			[       eth,	Icircumflex	]	};
+    key <AC04> {	[	  f,	F		],
+			[		Idiaeresis	]	};
+    key <AC05> {	[	  g,	G		],
+			[ copyright			]	};
     key <AC06> {	[	  h,	H		]	};
     key <AC07> {	[	  j,	J		]	};
     key <AC08> {	[	  k,	K		]	};
-    key <AC09> {	[	  l,	L		]	};
+    key <AC09> {	[	  l,	L		],
+			[   notsign,    Ograve		]	};
     key <AC10> {	[ semicolon,	colon		]	};
-    key <AC11> {	[ quoteright,	quotedbl	]	};
+    key <AC11> {	[ quoteright,	quotedbl	],
+			[        ae,	AE		]	};
     key <RTRN> {	[ Return			]	};
 
     key <AB01> {	[	  z,	Z 		]	};
     key <AB02> {	[	  x,	X		]	};
-    key <AB03> {	[	  c,	C		]	};
+    key <AB03> {	[	  c,	C		],
+			[ ccedilla,	Ccedilla	]	};
     key <AB04> {	[	  v,	V		]	};
     key <AB05> {	[	  b,	B		]	};
-    key <AB06> {	[	  n,	N		]	};
-    key <AB07> {	[	  m,	M		]	};
+    key <AB06> {	[	  n,	N		],
+			[asciitilde			]	};
+    key <AB07> {	[	  m,	M		],
+			[        mu,	Acircumflex	]	};
     key <AB08> {	[     comma,	less		]	};
     key <AB09> {	[    period,	greater		]	};
     key <AB10> {	[     slash,	question	]	};
@@ -65,17 +94,6 @@
     key <SPCE> {	[  space			]	};
     // End alphanumeric section
 
-    // Begin modifier mappings
-    key <LMTA> {	[  Meta_L	 	]	};
-    key <LFSH> {	[  Shift_L		]	};
-    key <LCTL> {	[  Control_L		]	};
-    key <LALT> {	[  Alt_L	 	]	};
-    key <RMTA> {	[  Meta_R	 	]	};
-    key <RFSH> {	[  Shift_R		]	};
-    key <RCTL> {	[  Control_R		]	};
-    key <RALT> {	[  Alt_R	 	]	};
-    // End modifier mappings
-
     // Begin "Function" section
     key <FK01> {	[  F1			]	};
     key <FK02> {	[  F2			]	};
@@ -98,7 +116,7 @@
     key  <INS> {	[  Insert		]	};
     key <HOME> {	[  Home			]	};
     key <PGUP> {	[  Prior		]	};
-    key <DELE> {	[  BackSpace		]	};
+    key <DELE> {	[  Delete		]	};
     key  <END> {	[  End			]	};
     key <PGDN> {	[  Next			]	};
 
@@ -109,42 +127,55 @@
     // End "Editing" section
 
     // Begin "Keypad" section
-    key <KPCL> {	[  Num_Lock		]	};
-    key <KPEQ> {	[  KP_Equal		]	};
+    key <NMLK> {	[  Num_Lock		]	};
+    key <KPEQ> {	[  equal		]	};
     key <KPDV> {	[  KP_Divide		]	};
     key <KPMU> {	[  KP_Multiply		]	};
 
-    key  <KP7> {	[  KP_7			]	};
-    key  <KP8> {	[  KP_8			]	};
-    key  <KP9> {	[  KP_9			]	};
+    key  <KP7> {	[  KP_7	, KP_Home	]	};
+    key  <KP8> {	[  KP_8	, KP_Up		]	};
+    key  <KP9> {	[  KP_9	, KP_Prior	]	};
     key <KPSU> {	[  KP_Subtract		]	};
 
-    key  <KP4> {	[  KP_4			]	};
-    key  <KP5> {	[  KP_5			]	};
-    key  <KP6> {	[  KP_6			]	};
+    key  <KP4> {	[  KP_4	, KP_Left	]	};
+    key  <KP5> {	[  KP_5	, KP_Begin	]	};
+    key  <KP6> {	[  KP_6	, KP_Right	]	};
     key <KPAD> {	[  KP_Add		]	};
 
-    key  <KP1> {	[  KP_1			]	};
-    key  <KP2> {	[  KP_2			]	};
-    key  <KP3> {	[  KP_3			]	};
+    key  <KP1> {	[  KP_1	, KP_End	]	};
+    key  <KP2> {	[  KP_2	, KP_Down	]	};
+    key  <KP3> {	[  KP_3	, KP_Next	]	};
     key <KPEN> {	[  KP_Enter		]	};
 
-    key  <KP0> {	[  KP_0			]	};
-    key <KPDL> { 	[  KP_Decimal		]	};
+    key  <KP0> {	[  KP_0	, KP_Insert	]	};
+    key <KPDL> { 	[  KP_Decimal , KP_Delete ]	};
     // End "Keypad" section
 
+    // Begin modifier mappings
+//    key <LMTA> {	[  Meta_L	 	]	};
+    key <LFSH> {	[  Shift_L		]	};
+    key <LCTL> {	[  Control_L		]	};
+    key <LALT> {	[  Alt_L	 	]	};
+    key <RALT> {        [ Mode_switch,  Multi_key       ]       };
+    key <RTSH> {	[  Shift_R		]	};
+    key <RCTL> {	[  Control_R		]	};
 
+    // End modifier mappings
     // begin modifier mappings
-    modifier_map Shift  { Shift_L, Shift_R };
+    modifier_map Shift  { Shift_L , Shift_R };
     modifier_map Lock   { Caps_Lock };
     modifier_map Control{ Control_L, Control_R };
 //    modifier_map Mod1   { Meta_L, Meta_R };
 //    modifier_map Mod2   { Alt_L, Alt_R };
 //    modifier_map Mod4   { Num_Lock };
-    modifier_map Mod1   { Alt_L, Alt_R };
+//    modifier_map Mod1   { Alt_L, Alt_R };
     modifier_map Mod2   { Num_Lock };
-    modifier_map Mod4   { Meta_L, Meta_R };
-    modifier_map Mod5   { Scroll_Lock };
+    modifier_map Mod1   { Alt_L, Alt_R };
+//    modifier_map Mod4   { Meta_L, Meta_R };
+    modifier_map Mod3   { Mode_switch };
     // end modifier mappings
+
+
+
 };
 
Index: xc/programs/xload/Imakefile
diff -u xc/programs/xload/Imakefile:1.3 xc/programs/xload/Imakefile:1.5
--- xc/programs/xload/Imakefile:1.3	Thu Jun 15 16:50:05 2000
+++ xc/programs/xload/Imakefile	Tue Nov 14 13:20:39 2000
@@ -1,9 +1,9 @@
 XCOMM $XConsortium: Imakefile /main/30 1996/03/09 09:37:57 kaleb $
-XCOMM $XFree86: xc/programs/xload/Imakefile,v 1.3 2000/06/15 20:50:05 dawes Exp $
+XCOMM $XFree86: xc/programs/xload/Imakefile,v 1.5 2000/11/14 18:20:39 dawes Exp $
         DEPLIBS = XawClientDepLibs
 LOCAL_LIBRARIES = XawClientLibs
 
-#ifdef i386MachArchitecture
+#if defined(i386MachArchitecture) && !defined(GNUMachArchitecture)
   SYS_LIBRARIES = -lsys
 #elif defined(SGIArchitecture) && !defined(MipsN32Architecture)
   SYS_LIBRARIES = -lmld
@@ -15,7 +15,7 @@
   SYS_LIBRARIES = -lelf
 #elif defined(OsfArchitecture)
   SYS_LIBRARIES = -lld
-#elif defined(i386BsdArchitecture) && !defined(NetBSDArchitecture) && !defined(OpenBSDArchitecture)
+#elif defined(BSDOSArchitecture) && !defined(NetBSDArchitecture) && !defined(OpenBSDArchitecture)
   SYS_LIBRARIES = -lutil -lkvm
 #endif
            SRCS = xload.c get_load.c
Index: xc/programs/xload/get_load.c
diff -u xc/programs/xload/get_load.c:1.3 xc/programs/xload/get_load.c:1.6
--- xc/programs/xload/get_load.c:1.3	Wed Apr  5 14:14:09 2000
+++ xc/programs/xload/get_load.c	Tue Nov 14 20:36:17 2000
@@ -1,5 +1,5 @@
 /* $XConsortium: get_load.c /main/37 1996/03/09 09:38:04 kaleb $ */
-/* $XFree86: xc/programs/xload/get_load.c,v 1.3 2000/04/05 18:14:09 dawes Exp $ */
+/* $XFree86: xc/programs/xload/get_load.c,v 1.6 2000/11/15 01:36:17 dawes Exp $ */
 /*
 
 Copyright (c) 1989  X Consortium
@@ -41,6 +41,7 @@
 
 #include <X11/Xos.h>
 #include <X11/Intrinsic.h>
+#include <X11/Xlocale.h>
 #include <stdio.h>
 
 #if !defined(DGUX)
@@ -51,7 +52,7 @@
 #ifndef macII
 #ifndef apollo
 #ifndef LOADSTUB
-#if !defined(linux) && !defined(AMOEBA) && !defined(__EMX__)
+#if !defined(linux) && !defined(AMOEBA) && !defined(__EMX__) && !defined(__GNU__)
 #include <nlist.h>
 #endif /* linux || AMOEBA */
 #endif /* LOADSTUB */
@@ -417,7 +418,12 @@
 {
       static int fd = -1;
       int n;
-      char buf[10];
+      char buf[10] = {0, };
+#ifndef X_LOCALE
+      char *dp;
+      static char ldp = 0;
+#endif
+
 
       if (fd < 0)
       {
@@ -428,13 +434,25 @@
                       *(double *)call_data = 0.0;
                       return;
               }
+#ifndef X_LOCALE
+	      ldp = *localeconv()->decimal_point;
+#endif
       }
       else
               lseek(fd, 0, 0);
 
-      if ((n = read(fd, buf, sizeof(buf)-1)) > 0 &&
-          sscanf(buf, "%lf", (double *)call_data) == 1)
-                      return;
+      if ((n = read(fd, buf, sizeof(buf)-1)) > 0) {
+#ifndef X_LOCALE
+	  if (ldp != '.')
+	      while ((dp = memchr(buf,'.',sizeof(buf)-1)) != NULL) {
+		  *(char *)dp = ldp;
+	      }
+	  
+#endif
+	  if (sscanf(buf, "%lf", (double *)call_data) == 1)
+	      return;
+      }
+      
 
       *(double *)call_data = 0.0;     /* temporary hiccup */
 
@@ -443,6 +461,44 @@
 
 #else /* linux */
 
+#ifdef __GNU__
+
+#include <mach.h>
+
+static processor_set_t default_set;
+
+void InitLoadPoint()
+{
+  if (processor_set_default (mach_host_self (), &default_set) != KERN_SUCCESS)
+    xload_error("cannot get processor_set_default", "");
+}
+
+/* ARGSUSED */
+void GetLoadPoint( w, closure, call_data )
+     Widget	w;		/* unused */
+     caddr_t	closure;	/* unused */
+     caddr_t	call_data;	/* pointer to (double) return value */
+{
+  host_t host;
+  struct processor_set_basic_info info;
+  unsigned info_count;
+
+  info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
+  if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
+			  (processor_set_info_t) &info, &info_count)
+      != KERN_SUCCESS)
+    {
+      InitLoadPoint();
+      info.load_average = 0;
+    }
+
+  *(double *)call_data = info.load_average * 1000 / LOAD_SCALE;
+
+  return;
+}
+
+#else /* __GNU__ */
+
 #ifdef LOADSTUB
 
 void InitLoadPoint()
@@ -793,7 +849,7 @@
     }
 #else /* sun svr4 5.5 or later */
 
-#if (!defined(SVR4) || !defined(__STDC__)) && !defined(sgi) && !defined(MOTOROLA) && !(BSD >= 199103) && !defined(MINIX)
+#if (!defined(SVR4) || !defined(__STDC__)) && !defined(sgi) && !defined(MOTOROLA) && !(BSD >= 199103) && !defined(MINIX) && !defined(__DARWIN__)
     extern void nlist();
 #endif
 
@@ -1014,6 +1070,7 @@
 #endif /* __bsdi__ else */
 #endif /* __osf__ else */
 #endif /* LOADSTUB else */
+#endif /* __GNU__ else */
 #endif /* linux else */
 #endif /* AMOEBA else */
 #endif /* KVM_ROUTINES else */
Index: xc/programs/xman/ScrollByL.c
diff -u xc/programs/xman/ScrollByL.c:1.3 xc/programs/xman/ScrollByL.c:1.4
--- xc/programs/xman/ScrollByL.c:1.3	Fri Mar  3 18:16:25 2000
+++ xc/programs/xman/ScrollByL.c	Tue Sep 26 11:57:26 2000
@@ -28,7 +28,7 @@
 from the X Consortium.
 
 */
-/* $XFree86: xc/programs/xman/ScrollByL.c,v 1.3 2000/03/03 23:16:25 dawes Exp $ */
+/* $XFree86: xc/programs/xman/ScrollByL.c,v 1.4 2000/09/26 15:57:26 tsi Exp $ */
 
 #if ( !defined(lint) && !defined(SABER))
   static char rcs_version[] = "$Athena: ScrollByL.c,v 4.5 88/12/19 13:46:04 kit Exp $";
@@ -329,18 +329,18 @@
    case 'f':
    case 'F':
      /* move one page forward */
-     VerticalScroll(bar, NULL, (XtPointer)((int) bar->core.height));
+     VerticalScroll(bar, NULL, (XtPointer)((long) bar->core.height));
      break;
    case 'b':
    case 'B':
      /* move one page backward */
-     VerticalScroll(bar, NULL,  (XtPointer)(- (int) bar->core.height));
+     VerticalScroll(bar, NULL,  (XtPointer)(- (long) bar->core.height));
      break;
    case 'L':
    case 'l':
      /* move one line forward */
      VerticalScroll(bar, NULL, 
-		    (XtPointer)((int) atoi(params[1]) * sblw->scroll.font_height));
+		(XtPointer)((long) atoi(params[1]) * sblw->scroll.font_height));
      break;
    default:
      return;
Index: xc/programs/xman/man.c
diff -u xc/programs/xman/man.c:1.4 xc/programs/xman/man.c:1.5
--- xc/programs/xman/man.c:1.4	Tue Jun 13 19:15:53 2000
+++ xc/programs/xman/man.c	Tue Aug  1 14:53:07 2000
@@ -28,7 +28,7 @@
 from the X Consortium.
 
 */
-/* $XFree86: xc/programs/xman/man.c,v 1.4 2000/06/13 23:15:53 dawes Exp $ */
+/* $XFree86: xc/programs/xman/man.c,v 1.5 2000/08/01 18:53:07 dawes Exp $ */
 
 
 #include "globals.h"
@@ -961,20 +961,20 @@
 
 #endif /* DEBUG */
 
-#ifdef MANCONF
+
 
-#if !defined(__OpenBSD__) && !defined(__NetBSD__)
+#ifdef MANCONF
 
-#if defined(linux)
+#if defined(__FreeBSD__)
 
 /*    Function Name: ReadManConfig
- *    Description: Reads man.conf file used by BSD 4.4
+ *    Description: Reads man.conf file used by FreeBSD man
  *      Argument: manpath - char array to return path in.
  *    Returns: TRUE if read was successful.
  */
 
 Bool
-ReadManConfig(char  manpath[])
+ReadManConfig(char manpath[])
 {
   FILE        *fp;
   char        line[BUFSIZ];
@@ -986,8 +986,13 @@
 
   while (fgets(line, sizeof(line), fp)) {
     path = strtok(line, " \t\n");
-    if (!path || *path == '#' || (strcmp(path, "MANPATH") != 0))
+    if (!path || *path == '#')
       continue;
+    if (strcmp(path, "MANPATH_MAP") == 0)
+      path = strtok((char *)NULL, " \t\n");
+    else if (strcmp(path, "MANDATORY_MANPATH") != 0 &&
+	     strcmp(path, "OPTIONAL_MANPATH") != 0)
+      return(FALSE);
     path = strtok((char *)NULL, " \t\n");
     if (!path || *path == '#')
       return FALSE;
@@ -995,7 +1000,7 @@
       strcpy(manpath, path);
       firstpath = FALSE;
     }
-    else {
+    else if (!strstr(manpath,path)) {
       strcat(manpath, ":");
       strcat(manpath, path);
     }
@@ -1004,16 +1009,18 @@
   return(!firstpath);
 }
 
-#else /* linux */
 
+#elif defined(linux) /* not __FreeBSD__ */
+
 /*    Function Name: ReadManConfig
  *    Description: Reads man.conf file used by Linux man
  *      Argument: manpath - char array to return path in.
  *    Returns: TRUE if read was successful.
  */
 
+
 Bool
-ReadManConfig(char  manpath[])
+ReadManConfig(char manpath[])
 {
   FILE        *fp;
   char        line[BUFSIZ];
@@ -1025,26 +1032,25 @@
 
   while (fgets(line, sizeof(line), fp)) {
     path = strtok(line, " \t\n");
-    if (!path || *path == '#' || strcmp(path, "_default"))
+    if (!path || *path == '#' || (strcmp(path, "MANPATH") != 0))
       continue;
-    while ((path = strtok((char *)NULL, " \t\n"))) {
-      if (firstpath) {
-        strcpy(manpath, path);
-        firstpath = FALSE;
-      }
-      else {
-        strcat(manpath, ":");
-        strcat(manpath, path);
-      }
+    path = strtok((char *)NULL, " \t\n");
+    if (!path || *path == '#')
+      return FALSE;
+    if (firstpath) {
+      strcpy(manpath, path);
+      firstpath = FALSE;
+    }
+    else {
+      strcat(manpath, ":");
+      strcat(manpath, path);
     }
   }
   fclose(fp);
   return(!firstpath);
 }
-
-#endif /* linux */
 
-#else /* __OpenBSD__ || __NetBSD__ */
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
 
 /*    Function Name: ReadManConfig
  *    Description: Reads man.conf file used by Open/NetBSD
@@ -1057,7 +1063,7 @@
 #include <glob.h>
 
 Bool
-ReadManConfig(char  manpath[])
+ReadManConfig(char manpath[])
 {
     FILE        *fp;
     char        line[BUFSIZ];
@@ -1099,7 +1105,57 @@
     fclose(fp);
     return(!firstpath);
 }
+
+#elif defined(BSD)
+
+/*    Keep this ever AFTER linux, {Free,Net,Open}BSD and any other system in
+ *    which "BSD" is defined but whose man.conf doesn't follows the original
+ *    BSD 4.4 format.
+ */
+
+/*    Function Name: ReadManConfig
+ *    Description: Reads man.conf file used by BSD 4.4
+ *      Argument: manpath - char array to return path in.
+ *    Returns: TRUE if read was successful.
+ */
+
+Bool
+ReadManConfig(manpath)
+
+char  manpath[];
+
+{
+  FILE        *fp;
+  char        line[BUFSIZ];
+  char        *path;
+  Bool  firstpath = TRUE;
+
+  if (!(fp = fopen(MANCONF, "r")))
+    return(FALSE);
+
+  while (fgets(line, sizeof(line), fp)) {
+    path = strtok(line, " \t\n");
+    if (!path || *path == '#' || strcmp(path, "_default"))
+      continue;
+    while (path = strtok((char *)NULL, " \t\n")) {
+      if (firstpath) {
+        strcpy(manpath, path);
+        firstpath = FALSE;
+      }
+      else {
+        strcat(manpath, ":");
+        strcat(manpath, path);
+      }
+    }
+  }
+  fclose(fp);
+  return(!firstpath);
+}
+
+#else /* not BSD */
+
+#error "MANCONF defined (in vendor.h) for unknown operating system."
 
-#endif /* __OpenBSD__ || __NetBSD__ */
+#endif /* __FreeBSD__ ... BSD */
 
 #endif /* MANCONF */
Index: xc/programs/xman/vendor.h
diff -u xc/programs/xman/vendor.h:1.4 xc/programs/xman/vendor.h:1.5
--- xc/programs/xman/vendor.h:1.4	Fri Mar  3 18:16:29 2000
+++ xc/programs/xman/vendor.h	Tue Aug  1 14:53:07 2000
@@ -28,7 +28,7 @@
 from the X Consortium.
 
 */
-/* $XFree86: xc/programs/xman/vendor.h,v 1.4 2000/03/03 23:16:29 dawes Exp $ */
+/* $XFree86: xc/programs/xman/vendor.h,v 1.5 2000/08/01 18:53:07 dawes Exp $ */
 
 /* Vendor-specific definitions */
 
@@ -59,8 +59,12 @@
 # define SEARCHOTHER CAT
 #endif
 
-#if (defined(BSD) && (BSD >= 199103)) || defined(linux)
-# define MANCONF "/etc/man.conf"
+#if defined(__FreeBSD__)
+# define MANCONF "/etc/manpath.config"
+#else
+# if (defined(BSD) && (BSD >= 199103)) || defined(linux)
+#  define MANCONF "/etc/man.conf"
+# endif
 #endif
 
 /*
Index: xc/programs/xmessage/makeform.c
diff -u xc/programs/xmessage/makeform.c:1.4 xc/programs/xmessage/makeform.c:1.5
--- xc/programs/xmessage/makeform.c:1.4	Thu Feb 17 11:53:03 2000
+++ xc/programs/xmessage/makeform.c	Fri Oct 20 10:59:09 2000
@@ -28,7 +28,7 @@
 from the X Consortium.
 
 */
-/* $XFree86: xc/programs/xmessage/makeform.c,v 1.4 2000/02/17 16:53:03 dawes Exp $ */
+/* $XFree86: xc/programs/xmessage/makeform.c,v 1.5 2000/10/20 14:59:09 alanh Exp $ */
 
 #include <X11/Intrinsic.h>
 #include <X11/StringDefs.h>
@@ -258,6 +258,7 @@
 	Dimension scroll_size, border_width;
 	Widget label, scroll;
 	Position left, right, top, bottom;
+	char *tmp;
 	/*
 	 * A Text widget is used for the automatic scroll bars.
 	 * But Text widget doesn't automatically compute its size.
@@ -288,6 +289,19 @@
 	    XtDestroyWidget(scroll);
 	    height_addons = scroll_size + border_width;
 	}
+
+	/* This fixes the xmessage assumption that the label widget and the
+	 * text widget have the same size. In Xaw 7, the text widget has
+	 * one extra pixel between lines.
+	 * Xmessage is not internationalized, so the code bellow is harmless.
+	 */
+	tmp = msgstr;
+	while (tmp != NULL && *tmp) {
+	    ++tmp;
+	    ++height;
+	    tmp = strchr(tmp, '\n');
+	}
+
 	if (height > max_height) {
 	    height = max_height;
 	    /* add in the width of any vertical scroll bar */
Index: xc/programs/xrx/plugin/include/npapi.h
diff -u xc/programs/xrx/plugin/include/npapi.h:1.2 xc/programs/xrx/plugin/include/npapi.h:1.3
--- xc/programs/xrx/plugin/include/npapi.h:1.2	Mon Dec 30 23:19:59 1996
+++ xc/programs/xrx/plugin/include/npapi.h	Thu Aug 31 15:04:00 2000
@@ -4,7 +4,7 @@
  *  npapi.h Revision: 1.76
  *  Netscape client plug-in API spec
  */
-/* $XFree86: xc/programs/xrx/plugin/include/npapi.h,v 1.2 1996/12/31 04:19:59 dawes Exp $ */
+/* $XFree86: xc/programs/xrx/plugin/include/npapi.h,v 1.3 2000/08/31 19:04:00 tsi Exp $ */
 
 #ifndef _NPAPI_H_
 #define _NPAPI_H_
@@ -38,21 +38,13 @@
 typedef unsigned short uint16;
 #endif
 #ifndef _UINT32
-#if defined(__alpha) || defined(__alpha__)
 typedef unsigned int uint32;
-#else /* __alpha || __alpha__ */
-typedef unsigned long uint32;
-#endif /* __alpha || __alpha__ */
 #endif
 #ifndef _INT16
 typedef short int16;
 #endif
 #ifndef _INT32
-#if defined(__alpha) || defined(__alpha__)
 typedef int int32;
-#else /* __alpha || __alpha__ */
-typedef long int32;
-#endif /* __alpha || __alpha__ */
 #endif
 
 #ifndef FALSE
Index: xc/programs/xset/Imakefile
diff -u xc/programs/xset/Imakefile:3.8 xc/programs/xset/Imakefile:3.9
--- xc/programs/xset/Imakefile:3.8	Sun Feb 13 01:15:47 2000
+++ xc/programs/xset/Imakefile	Mon Aug 28 12:35:04 2000
@@ -1,8 +1,9 @@
 XCOMM $XConsortium: Imakefile,v 1.7 91/12/20 11:29:16 rws Exp $
-XCOMM $XFree86: xc/programs/xset/Imakefile,v 3.8 2000/02/13 06:15:47 dawes Exp $
+XCOMM $XFree86: xc/programs/xset/Imakefile,v 3.9 2000/08/28 16:35:04 dawes Exp $
 
         DEFINES = ExtensionDefines DPMSDefines \
-		  FontCacheExtensionDefines
+		  FontCacheExtensionDefines \
+		  XkbDefines
         DEPLIBS = $(DEPXMULIB) $(DEPXLIB) $(DEPXF86LIBS) $(DEPFONTLIBS)
 LOCAL_LIBRARIES = $(XMULIB) $(XF86LIBS) $(FONTLIBS) $(XLIB)
 
Index: xc/programs/xset/xset.c
diff -u xc/programs/xset/xset.c:3.19 xc/programs/xset/xset.c:3.20
--- xc/programs/xset/xset.c:3.19	Thu Apr 20 17:28:50 2000
+++ xc/programs/xset/xset.c	Mon Aug 28 12:35:04 2000
@@ -23,7 +23,8 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/programs/xset/xset.c,v 3.19 2000/04/20 21:28:50 tsi Exp $ */
+/* $XFree86: xc/programs/xset/xset.c,v 3.20 2000/08/28 16:35:04 dawes Exp $ */
+/* Modified by Stephen so keyboard rate is set using XKB extensions */
 
 #include <stdio.h>
 #include <ctype.h>
@@ -78,6 +79,9 @@
 #include <X11/extensions/xf86misc.h>
 #include <X11/extensions/xf86mscstr.h>
 #endif
+#ifdef XKB
+#include <X11/XKBlib.h>
+#endif
 #ifdef FONTCACHE
 #include <X11/extensions/fontcacheP.h>
 #endif
@@ -101,6 +105,10 @@
 #define KBDDELAY_DEFAULT 500
 #define KBDRATE_DEFAULT 30
 #endif
+#ifdef XKB
+#define XKBDDELAY_DEFAULT 660
+#define XKBDRATE_DEFAULT (1000/40)
+#endif
 
 #define	nextarg(i, argv) \
 	argv[i]; \
@@ -134,6 +142,9 @@
 #ifdef XF86MISC
 static void set_repeatrate(Display *dpy, int delay, int rate);
 #endif
+#ifdef XKB
+static void xkbset_repeatrate(Display *dpy, int delay, int rate);
+#endif
 
 int
 main(int argc, char *argv[])
@@ -157,6 +168,15 @@
 #ifdef XF86MISC
 int miscpresent = 1;
 int major, minor;
+#else
+int miscpresent = 0;
+#endif
+#ifdef XKB
+int xkbpresent = 1;
+int xkbmajor = XkbMajorVersion, xkbminor = XkbMinorVersion;
+int xkbopcode, xkbevent, xkberror;
+#else
+int xkbpresent = 0;
 #endif
 #ifdef FONTCACHE
 long himark, lowmark, balance;
@@ -290,7 +310,7 @@
 	      himark = atoi(arg);
 	      i++;
 	      if (himark <= 0) {
-		  usage("hi-mark must be grater than 0", NULL);
+		  usage("hi-mark must be greater than 0", NULL);
 	      }
 	      if (i >= argc) {
 		  lowmark = (himark * 70) / 100;
@@ -302,10 +322,10 @@
 		  lowmark = atoi(arg);
 		  i++;
 		  if (lowmark <= 0) {
-		      usage("low-mark must be grater than 0", NULL);
+		      usage("low-mark must be greater than 0", NULL);
 		  }
 		  if (himark <= lowmark) {
-		      usage("hi-mark must be grater than low-mark", NULL);
+		      usage("hi-mark must be greater than low-mark", NULL);
 		  }
 		  if (i >= argc) {
 		      set_font_cache(dpy, himark, lowmark, balance);
@@ -654,10 +674,10 @@
     set_repeat(dpy, key, auto_repeat_mode);
   } 
   else if (strcmp(arg, "r") == 0) {         /* Turn on one or all autorepeats */
-    auto_repeat_mode = ON;
-    key = ALL;          /* None specified */
-    arg = argv[i];
-    if (i < argc) {
+   auto_repeat_mode = ON;
+   key = ALL;          /* None specified */
+   arg = argv[i];
+   if (i < argc) {
     if (strcmp(arg, "on") == 0) {
       i++;
     } 
@@ -665,41 +685,62 @@
       auto_repeat_mode = OFF;
       i++;
     }
-#ifdef XF86MISC
+#if defined(XF86MISC) || defined(XKB)
     else if (strcmp(arg, "rate") == 0) {       /*  ...or this one. */
-      int delay=KBDDELAY_DEFAULT, rate=KBDRATE_DEFAULT;
-
-      if (!XF86MiscQueryVersion(dpy, &major, &minor)) {
+      int delay, rate;
+      int rate_set = 0;
+#ifdef XF86MISC
+      if (XF86MiscQueryVersion(dpy, &major, &minor)) {
+        delay=KBDDELAY_DEFAULT, rate=KBDRATE_DEFAULT;
+      } else {
         miscpresent = 0;
-        fprintf(stderr,
-          "server does not have extension for \"r rate\" option\n");
       }
-
+#endif
+#ifdef XKB
+      if (XkbQueryExtension(dpy, &xkbopcode, &xkbevent, &xkberror, &xkbmajor,
+				&xkbminor)) {
+        delay=XKBDDELAY_DEFAULT, rate=XKBDRATE_DEFAULT;
+      } else {
+        xkbpresent = 0;
+      }
+#endif
+      if (!miscpresent && !xkbpresent)
+        fprintf(stderr,
+            "server does not have extension for \"r rate\" option\n");
       i++;
       arg = argv[i];
       if (i < argc) {
-        if (is_number(arg, 10000)) {
+        if (is_number(arg, 10000) && atoi(arg)>0) {
 	  delay = atoi(arg);
 	  i++;
           arg = argv[i];
 	  if (i < argc) {
-            if (is_number(arg, 255)) {
+            if (is_number(arg, 255) && atoi(arg)>0) {
 	      rate = atoi(arg);
 	      i++;
             }
           }
         }
       }
-      if (miscpresent)
+#ifdef XKB
+      if (xkbpresent) {
+        xkbset_repeatrate(dpy, delay, 1000/rate);
+	rate_set = 1;
+      }
+#endif
+#ifdef XF86MISC
+      if (miscpresent && !rate_set) {
         set_repeatrate(dpy, delay, rate);
+      }
+#endif
     }
 #endif
     else if (is_number(arg, 255)) {
       key = atoi(arg);
       i++;
     }
-    } 
-    set_repeat(dpy, key, auto_repeat_mode);
+   } 
+   set_repeat(dpy, key, auto_repeat_mode);
   } 
   else if (strcmp(arg, "p") == 0) {
     if (i + 1 >= argc)
@@ -1043,6 +1084,18 @@
 }
 #endif
 
+#ifdef XKB
+static void 
+xkbset_repeatrate(Display *dpy, int delay, int interval)
+{
+  XkbDescPtr xkb = XkbGetKeyboard(dpy,XkbControlsMask,XkbUseCoreKbd);
+  XkbGetControls(dpy, XkbRepeatKeysMask, xkb);
+  xkb->ctrls->repeat_delay = delay;
+  xkb->ctrls->repeat_interval = interval;
+  XkbSetControls(dpy, XkbRepeatKeysMask, xkb);
+}
+#endif
+
 static void
 set_pixels(Display *dpy, unsigned long *pixels, caddr_t *colors, int numpixels)
 {
@@ -1171,6 +1224,11 @@
 #ifdef XF86MISC
 XF86MiscKbdSettings kbdinfo;
 #endif
+#ifdef XKB
+XkbDescPtr xkb;
+int xkbmajor = XkbMajorVersion, xkbminor = XkbMinorVersion;
+int xkbopcode, xkbevent, xkberror;
+#endif
 char **font_path; int npaths;
 int i, j;
 char buf[20];				/* big enough for 16 bit number */
@@ -1185,7 +1243,17 @@
 	on_or_off (values.global_auto_repeat,
 		   AutoRepeatModeOn, "on", AutoRepeatModeOff, "off", buf),
 	values.key_click_percent, values.led_mask);
+#ifdef XKB
+if (XkbQueryExtension(dpy, &xkbopcode, &xkbevent, &xkberror, &xkbmajor, &xkbminor)
+    && (xkb = XkbGetKeyboard(dpy,XkbControlsMask,XkbUseCoreKbd)) != NULL
+    && XkbGetControls(dpy, XkbRepeatKeysMask, xkb) == Success)
+  printf ("  auto repeat delay:  %d    repeat rate:  %d\n",
+          xkb->ctrls->repeat_delay,  1000/xkb->ctrls->repeat_interval);
 #ifdef XF86MISC
+else
+#endif
+#endif
+#ifdef XF86MISC
 if (XF86MiscGetKbdSettings(dpy, &kbdinfo))
   printf ("  auto repeat delay:  %d    repeat rate:  %d\n",
           kbdinfo.delay, kbdinfo.rate);
@@ -1431,7 +1499,7 @@
     fprintf (stderr, "    To turn auto-repeat off or on:\n");
     fprintf (stderr, "\t-r [keycode]        r off\n");
     fprintf (stderr, "\t r [keycode]        r on\n");
-#ifdef XF86MISC
+#if defined(XF86MISC) || defined(XKB)
     fprintf (stderr, "\t r rate [delay [rate]]\n");
 #endif
     fprintf (stderr, "    For screen-saver control:\n");
Index: xc/programs/xset/xset.man
diff -u xc/programs/xset/xset.man:3.8 xc/programs/xset/xset.man:3.10
--- xc/programs/xset/xset.man:3.8	Sun Oct  4 05:41:57 1998
+++ xc/programs/xset/xset.man	Tue Nov 14 16:59:26 2000
@@ -19,7 +19,7 @@
 .\" other dealings in this Software without prior written authorization
 .\" from The Open Group.
 .\" 
-.\" $XFree86: xc/programs/xset/xset.man,v 3.8 1998/10/04 09:41:57 dawes Exp $
+.\" $XFree86: xc/programs/xset/xset.man,v 3.10 2000/11/14 21:59:26 dawes Exp $
 .\" 
 .TH XSET 1 "Release 6.4" "X Version 11"
 .SH NAME
@@ -104,7 +104,9 @@
 flag followed by a DPMS state.  The `force' flags forces the server
 to immediately switch to the DPMS state specified.  The DPMS state can
 be one of `standby', `suspend', or `off'.  When numerical values are
-given, they set the inactivity period before the three modes are activated.
+given, they set the inactivity period
+(in units of seconds)
+before the three modes are activated.
 The first value given is for the `standby' mode, the second is for the
 `suspend' mode, and the third is for the `off' mode.  Setting these
 values implicitly enables the DPMS features.  A value of zero disables
@@ -187,10 +189,15 @@
 If no parameters or the 'on' flag is used, autorepeat will be enabled.
 If a specific keycode is specified as a parameter, autorepeat for that
 keycode is enabled or disabled.
-If the server supports the XFree86-Misc extension, then a parameter
-of 'rate' is accepted and should be followed by one or two numeric
+If the server supports the XFree86-Misc extension,
+or the XKB extension, then a parameter
+of 'rate' is accepted and should be followed by zero, one or two numeric
 values. The first specifies the delay before autorepeat starts and
-the second specifies the repeat rate.
+the second specifies the repeat rate.  In the case that the server
+supports the XKB extension, the delay is the number of milliseconds
+before autorepeat starts, and the rate is the number of repeats
+per second.  If the rate or delay is not given, it will be set 
+to the default value.
 .PP
 .TP 8
 .B s
Index: xc/programs/xterm/INSTALL
diff -u xc/programs/xterm/INSTALL:3.21 xc/programs/xterm/INSTALL:3.22
--- xc/programs/xterm/INSTALL:3.21	Mon Jun 12 22:28:37 2000
+++ xc/programs/xterm/INSTALL	Tue Oct 31 20:12:36 2000
@@ -1,4 +1,4 @@
--- $XFree86: xc/programs/xterm/INSTALL,v 3.21 2000/06/13 02:28:37 dawes Exp $
+-- $XFree86: xc/programs/xterm/INSTALL,v 3.22 2000/11/01 01:12:36 dawes Exp $
 -- Thomas E. Dickey
 
 Xterm is normally built as part of the X Windows source tree, using
@@ -221,6 +221,13 @@
   --enable-sco-fkeys      enable support for SCO-style function keys
 
   	Compile-in code to support SCO-style function keys.
+
+  --enable-tcap-query     enable termcap query/report
+
+	Compile-in code to support experimental DCS '+' control sequence, which
+	allows an application to ask xterm what control sequences it would
+	transmit for specified function keys, given the termcap or terminfo
+	names.
 
   --enable-toolbar        enable pulldown menus on toolbar
 
Index: xc/programs/xterm/Imakefile
diff -u xc/programs/xterm/Imakefile:3.29 xc/programs/xterm/Imakefile:3.34
--- xc/programs/xterm/Imakefile:3.29	Fri Mar  3 15:02:27 2000
+++ xc/programs/xterm/Imakefile	Thu Nov 30 11:08:22 2000
@@ -7,7 +7,7 @@
 XCOMM bcopy (or memcpy) cannot, write a routine called bcopy and link it in
 XCOMM or add -Dbcopy=mybcopy to the DEFINES list below.
 XCOMM
-XCOMM $XFree86: xc/programs/xterm/Imakefile,v 3.29 2000/03/03 20:02:27 dawes Exp $
+XCOMM $XFree86: xc/programs/xterm/Imakefile,v 3.34 2000/11/30 16:08:22 dawes Exp $
 XCOMM
 
 /* Uncomment SCROLLBAR_RIGHT if you want the scroll bar to be on the right */
@@ -92,16 +92,24 @@
 
 #ifdef UTF8support
     UTF8_OPTION = -DOPT_WIDE_CHARS
-        UTF8SRC = keysym2ucs.c
-        UTF8OBJ = keysym2ucs.o
+        UTF8SRC = charclass.c keysym2ucs.c precompose.c wcwidth.c
+        UTF8OBJ = charclass.o keysym2ucs.o precompose.o wcwidth.o
 #endif
+#if BuildXftLibrary
+#define XRenderSupport
+#endif
+#ifdef XRenderSupport
+         XRFDEF = -DXRENDERFONT
+        XRFLIBS = XftClientLibs $(XRENDERLIB)
+     XRFDEPLIBS = XftClientDepLibs $(DEPXRENDERLIB)
+#endif
 
    MAIN_DEFINES = $(UTMPDEF) $(TTYGROUPDEF) $(PUCCPTYDDEF) $(NOPOSIXTERMIOS) \
 		  -DOSMAJORVERSION=$(OSMAJORVERSION) \
 		  -DOSMINORVERSION=$(OSMINORVERSION)
    MISC_DEFINES = /* -DALLOWLOGGING -DALLOWLOGFILEEXEC */
     XKB_DEFINES = XkbClientDefines
-        DEFINES = -I. $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION)
+        DEFINES = -I. $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION) $(XRFDEF)
 
 #ifdef OS2Architecture
           MAINSRC = os2main.c
@@ -113,21 +121,21 @@
           SRCS1 = button.c charproc.c charsets.c cursor.c \
 		  data.c doublechr.c fontutils.c input.c \
 		  menu.c misc.c print.c ptydata.c \
-		  screen.c scrollbar.c tabs.c util.c \
+		  screen.c scrollbar.c tabs.c util.c xstrings.c \
 		  TekPrsTbl.c Tekproc.c VTPrsTbl.c \
 		  $(MAINSRC) $(EXTRASRC) $(UTF8SRC)
           OBJS1 = button.o charproc.o charsets.o cursor.o \
 		  data.o doublechr.o fontutils.o input.o \
 		  menu.o misc.o print.o ptydata.o \
-		  screen.o scrollbar.o tabs.o util.o \
+		  screen.o scrollbar.o tabs.o util.o xstrings.o \
 		  TekPrsTbl.o Tekproc.o VTPrsTbl.o \
 		  $(MAINOBJ) $(EXTRAOBJ) $(UTF8OBJ)
-          SRCS2 = resize.c
-          OBJS2 = resize.o
+          SRCS2 = resize.c xstrings.c
+          OBJS2 = resize.o xstrings.o
            SRCS = $(SRCS1) $(SRCS2)
            OBJS = $(OBJS1) $(OBJS2)
        PROGRAMS = ProgramTargetName(resize) ProgramTargetName(xterm)
-       DEPLIBS1 = XkbClientDepLibs XawClientDepLibs
+       DEPLIBS1 = XkbClientDepLibs XawClientDepLibs $(XRFDEPLIBS)
        DEPLIBS2 =
 
 #ifndef TermcapLibrary
@@ -153,9 +161,9 @@
 SpecialCObjectRule(data,$(_NOOP_),$(MISC_DEFINES))
 
 #if InstallXtermSetUID
-SetUIDProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(PTYLIB))
+SetUIDProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(PTYLIB))
 #else
-NormalProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(UTMPLIB) $(PTYLIB))
+NormalProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(UTMPLIB) $(PTYLIB))
 #endif
 
 #if InstallXtermSetUID && defined(SunArchitecture) && HasSharedLibraries && (OSMajorVersion < 5)
@@ -174,7 +182,10 @@
 install:: ProgramTargetName(xterm)
 	MakeDir($(DESTDIR)$(BINDIR))
 	RemoveFile(ProgramTargetName(xterm.inst))
-	LinkRule(ProgramTargetName(xterm.inst),$(CDEBUGFLAGS) $(CCOPTIONS) $(EXTRA_LDOPTIONS) $(LOCAL_LDFLAGS),$(OBJS1),$(LDOVERRIDE) XawClientLibs $(LDRESUME) $(LDLIBS) $(TERMCAPLIB) $(PTYLIB))
+	LinkRule(ProgramTargetName(xterm.inst),$(CDEBUGFLAGS) $(CCOPTIONS)
+	$(EXTRA_LDOPTIONS) $(LOCAL_LDFLAGS),$(OBJS1),$(LDOVERRIDE)
+	$(XRFLIBS) XawClientLibs $(LDRESUME) $(LDLIBS) $(TERMCAPLIB)
+	$(PTYLIB))
 	$(INSTALL) -c $(INSTPGMFLAGS) $(INSTUIDFLAGS) ProgramTargetName(xterm.inst) $(DESTDIR)$(BINDIR)/ProgramTargetName(xterm)
 	RemoveFile(ProgramTargetName(xterm.inst))
 #else
Index: xc/programs/xterm/MANIFEST
diff -u xc/programs/xterm/MANIFEST:1.6 xc/programs/xterm/MANIFEST:1.7
--- xc/programs/xterm/MANIFEST:1.6	Thu May 18 12:30:03 2000
+++ xc/programs/xterm/MANIFEST	Fri Aug 25 17:51:07 2000
@@ -1,4 +1,4 @@
-MANIFEST for xterm-133, version xterm-133
+MANIFEST for xterm-141, version xterm-141
 --------------------------------------------------------------------------------
 MANIFEST                        this file
 256colres.h                     resource-definitions for 256-color mode
@@ -16,6 +16,7 @@
 Tekparse.h                      Tek4014 parser-state definitions
 Tekproc.c                       Tek4014 parser-state functions
 Tests                           Useful tests for xterm-developers
+UXTerm.ad                       alternate resources for UTF-8
 VTPrsTbl.c                      VT100 parser state tables
 VTparse.def                     template for generating VTparse.h
 VTparse.h                       VT100 parser-state definitions
@@ -23,6 +24,8 @@
 XTerm.ad                        resource definitions for XTerm class
 aclocal.m4                      configure script: custom macros
 button.c                        mouse button and selection processing
+charclass.c                     compact character-class module
+charclass.h                     interface of charclass.c
 charproc.c                      VT100 parser functions
 charsets.c                      module to translate character-sets
 config.guess                    configure script: guess the system type
@@ -50,6 +53,8 @@
 misc.c                          miscellaneous utility functions for 'xterm'
 mkdirs.sh                       configure script: make directories for install process
 os2main.c                       main program for OS/2 EMX port of 'xterm'
+precompose.c                    table of precompose sequences
+precompose.h                    interface of precompose.c
 print.c                         VT100+ print support functions
 proto.h                         macros to simplify function prototypes
 ptydata.c                       functions to manipulate data read from pty
@@ -70,6 +75,8 @@
 version.h                       version of xterm
 vms.c                           VMS version of xterm's spawn(), etc.
 vms.h                           system headers and definitions for vms.c
+wcwidth.c                       wide-character utility functions
+wcwidth.h                       interface of wcwidth.c
 xcharmouse.h                    Jason Bacon's mouse-defs, cleaned up a little
 xterm.dat                       application defaults for VMS port of 'xterm'
 xterm.h                         common includes, definitions and prototypes for 'xterm'
@@ -88,6 +95,9 @@
 unicode/README                  description of files in ./unicode
 unicode/convmap.pl              perl script for generating the lookup table for UTF-8 to keysym
 unicode/keysym.map              keysym mapping from UTF-8
+unicode/make-precompose.sh      make precompose.c
+unicode/precompose.c.head       header of precompose.c
+unicode/precompose.c.tail       tail of precompose.c
 vttests                         subdirectory
 vttests/16colors.sh             test-script to show 16-colors
 vttests/256colors.pl            script to illustrate 256-colors
@@ -100,6 +110,3 @@
 vttests/fonts.sh                script to demonstrate font-switching sequences
 vttests/resize.sh               script to demonstrate resizing
 vttests/title.sh                test-script to show title of xterm in action
-
-
-$XFree86: xc/programs/xterm/MANIFEST,v 1.6 2000/05/18 16:30:03 dawes Exp $
Index: xc/programs/xterm/Makefile.in
diff -u xc/programs/xterm/Makefile.in:3.30 xc/programs/xterm/Makefile.in:3.34
--- xc/programs/xterm/Makefile.in:3.30	Tue Jun 13 20:16:17 2000
+++ xc/programs/xterm/Makefile.in	Wed Dec  6 05:19:43 2000
@@ -1,4 +1,4 @@
-## $XFree86: xc/programs/xterm/Makefile.in,v 3.30 2000/06/14 00:16:17 dawes Exp $ ##
+## $XFree86: xc/programs/xterm/Makefile.in,v 3.34 2000/12/06 10:19:43 dickey Exp $ ##
 
 SHELL		= /bin/sh
 
@@ -40,6 +40,7 @@
 #### End of system configuration section. ####
 
 RM              = rm -f
+LINT		= lint
 
 DESTDIR		=
 BINDIR		= $(DESTDIR)$(bindir)
@@ -57,19 +58,19 @@
           SRCS1 = button.c charproc.c charsets.c cursor.c \
 	  	  data.c doublechr.c fontutils.c input.c \
 		  $(MAINSRC) menu.c misc.c print.c ptydata.c \
-		  screen.c scrollbar.c tabs.c util.c \
+		  screen.c scrollbar.c tabs.c util.c xstrings.c \
 		  VTPrsTbl.c $(EXTRASRC)
           OBJS1 = button.o charproc.o charsets.o cursor.o \
 	  	  data.o doublechr.o fontutils.o input.o \
 		  main.o menu.o misc.o print.o ptydata.o \
-		  screen.o scrollbar.o tabs.o util.o \
+		  screen.o scrollbar.o tabs.o util.o xstrings.o \
 		  VTPrsTbl.o $(EXTRAOBJ)
-          SRCS2 = resize.c
-          OBJS2 = resize.o
+          SRCS2 = resize.c xstrings.c
+          OBJS2 = resize.o xstrings.o
            SRCS = $(SRCS1) $(SRCS2)
            OBJS = $(OBJS1) $(OBJS2)
            HDRS = VTparse.h data.h error.h main.h menu.h proto.h \
-                  ptyx.h version.h xterm.h $(EXTRAHDR)
+                  ptyx.h version.h xstrings.h xterm.h $(EXTRAHDR)
        PROGRAMS = xterm resize
 
 all:	$(PROGRAMS)
@@ -87,9 +88,10 @@
 .def.hin:
 	grep '^CASE_' $< | $(AWK) '{printf "#define %s %d\n", $$1, n++}' >$@
 
-main.o: version.h
+main.o : main.h version.h
 
 $(OBJS1) : ptyx.h xtermcfg.h
+main.o resize.o screen.o : xterm_io.h
 
 xterm : $(OBJS1)
 	@ECHO_LD@$(LINK) $(LDFLAGS) -o $@ $(OBJS1) $(X_LIBS) $(X_EXTRA_LIBS) $(LIBS) $(EXTRA_LOADFLAGS)
@@ -105,13 +107,14 @@
 	-rm -f $@
 	perl $(srcdir)/88colres.pl > $@
 
-charproc.o : @CHARPROC_DEPS@
+charproc.o : main.h @CHARPROC_DEPS@
 
 install \
 install-bin \
 install-man \
 install-full \
 install-dirs :: $(INSTALL_DIRS)
+	@echo $@ built
 
 install \
 install-bin \
@@ -178,8 +181,8 @@
 	tbl ctlseqs.ms | groff -ms >$@
 
 lint:
-	lint $(CPPFLAGS) $(SRCS1)
-	lint $(CPPFLAGS) $(SRCS2)
+	$(LINT) $(CPPFLAGS) $(SRCS1)
+	$(LINT) $(CPPFLAGS) $(SRCS2)
 
 tags:
 	ctags $(SRCS) $(HDRS)
Index: xc/programs/xterm/README.os390
diff -u xc/programs/xterm/README.os390:1.2 xc/programs/xterm/README.os390:1.3
--- xc/programs/xterm/README.os390:1.2	Fri Nov 19 08:55:13 1999
+++ xc/programs/xterm/README.os390	Fri Sep 22 06:42:05 2000
@@ -1,4 +1,4 @@
--- $XFree86: xc/programs/xterm/README.os390,v 1.2 1999/11/19 13:55:13 hohndel Exp $
+-- $XFree86: xc/programs/xterm/README.os390,v 1.3 2000/09/22 10:42:05 alanh Exp $
 
 Below are install instructions for os/390 2.5 & below and
 for os/390 2.6 & above.  The basic reasons for exporting
@@ -39,6 +39,9 @@
 this isn't strictly necessary, but will reduce the size of the executable
 by about 4M.
 
+The '-Wl,EDIT=NO' causes the Binder to produce a non-editable executable,
+dramatically reducing the size of the executable file.
+
 Good Luck!!
 Greg Smith
 rys@trex.rtpnc.epa.gov
@@ -51,7 +54,7 @@
    pax -o from=ISO8859-1,to=IBM-1047 -rf xterm.tar
    cd xterm
    export LIBS='-lXt  -lX11 -lSM -lICE'
-   export CFLAGS='-D_ALL_SOURCE'
+   export CFLAGS='-D_ALL_SOURCE -Wl,EDIT=NO'
    ./configure
    make
    export DISPLAY=my.xserver.name:0
@@ -63,9 +66,7 @@
    gunzip xterm.tar.gz
    pax -o from=ISO8859-1,to=IBM-1047 -rf xterm.tar
    cd xterm
-   export LIBS='/usr/lib/Xaw.x /usr/lib/SM.x /usr/lib/ICE.x /usr/lib/X11.x'
-   export CFLAGS='-O2 -W c,dll -D_ALL_SOURCE'
-   ./configure
+   ./configure   # LIBS, CFLAGS, and CC are defined by configure for os/390 2.6.
    [optional: edit the Makefile and remove '-lXaw -lXext -lXmu -lXt  -lSM -lICE -lX11'
               from the LIBS assignment]
    make
Index: xc/programs/xterm/UXTerm.ad
diff -u /dev/null xc/programs/xterm/UXTerm.ad:1.1
--- /dev/null	Mon Dec 18 14:36:18 2000
+++ xc/programs/xterm/UXTerm.ad	Sat Aug 26 00:33:53 2000
@@ -0,0 +1,16 @@
+! $XFree86: xc/programs/xterm/UXTerm.ad,v 1.1 2000/08/26 04:33:53 dawes Exp $
+
+! Use
+!	xterm -class UXTerm
+! to set resources for UTF-8 mode with corresponding fonts.
+
+#include "XTerm"
+
+*fontMenu.Label:  Unicode Fonts
+*VT100*utf8:	1
+*VT100*font2:	-misc-fixed-medium-r-normal--8-80-75-75-c-50-iso10646-1
+*VT100*font:	-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1
+*VT100*font3:	-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1
+*VT100*font4:	-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso10646-1
+*VT100*font5:	-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1
+*VT100*font6:	-misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1
Index: xc/programs/xterm/aclocal.m4
diff -u xc/programs/xterm/aclocal.m4:3.33 xc/programs/xterm/aclocal.m4:3.37
--- xc/programs/xterm/aclocal.m4:3.33	Mon Jun 12 22:28:37 2000
+++ xc/programs/xterm/aclocal.m4	Wed Dec  6 21:22:12 2000
@@ -1,5 +1,5 @@
 dnl
-dnl $XFree86: xc/programs/xterm/aclocal.m4,v 3.33 2000/06/13 02:28:37 dawes Exp $
+dnl $XFree86: xc/programs/xterm/aclocal.m4,v 3.37 2000/12/07 02:22:12 dickey Exp $
 dnl
 dnl ---------------------------------------------------------------------------
 dnl
@@ -26,6 +26,22 @@
 dnl
 dnl ---------------------------------------------------------------------------
 dnl ---------------------------------------------------------------------------
+dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
+AC_DEFUN([CF_ADD_CFLAGS],
+[
+for cf_add_cflags in $1
+do
+	case $cf_add_cflags in #(vi
+	-I*|-D*|-U*|-E|-P|-C) #(vi
+		CPPFLAGS="$CPPFLAGS $cf_add_cflags"
+		;;
+	*)
+		CFLAGS="$CFLAGS $cf_add_cflags"
+		;;
+	esac
+done
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
 dnl in the sharutils 4.2 distribution.
 AC_DEFUN([CF_ANSI_CC_CHECK],
@@ -34,6 +50,7 @@
 AC_CACHE_VAL(cf_cv_ansi_cc,[
 cf_cv_ansi_cc=no
 cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
 # Don't try gcc -ansi; that turns off useful extensions and
 # breaks some systems' header files.
 # AIX			-qlanglvl=ansi
@@ -49,7 +66,7 @@
 	"-Aa -D_HPUX_SOURCE" \
 	-Xc
 do
-	CFLAGS="$cf_save_CFLAGS $cf_arg"
+	CF_ADD_CFLAGS($cf_arg)
 	AC_TRY_COMPILE(
 [
 #ifndef CC_HAS_PROTOS
@@ -64,6 +81,7 @@
 	[cf_cv_ansi_cc="$cf_arg"; break])
 done
 CFLAGS="$cf_save_CFLAGS"
+CPPFLAGS="$cf_save_CPPFLAGS"
 ])
 AC_MSG_RESULT($cf_cv_ansi_cc)
 
@@ -109,11 +127,13 @@
 dnl Derive the system name, as a check for reusing the autoconf cache.
 dnl
 dnl If we've packaged config.guess and config.sub, run that (since it does a
-dnl better job than uname).
+dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
+dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
+dnl which is useful in cross-compiles.
 AC_DEFUN([CF_CHECK_CACHE],
 [
 if test -f $srcdir/config.guess ; then
-	AC_CANONICAL_HOST
+	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
 	system_name="$host_os"
 else
 	system_name="`(uname -s -r) 2>/dev/null`"
@@ -154,7 +174,7 @@
 #include <errno.h> ],
     [long x = (long) $1],
     [eval 'cf_cv_dcl_'$1'=yes'],
-    [eval 'cf_cv_dcl_'$1'=no]')
+    [eval 'cf_cv_dcl_'$1'=no'])
 ])
 
 eval 'cf_result=$cf_cv_dcl_'$1
@@ -256,7 +276,7 @@
 		[cf_cv_good_bcopy=unknown])
 		])
 	],[cf_cv_good_bcopy=no])
-	if test $cf_cv_good_bcopy = yes ; then
+	if test "$cf_cv_good_bcopy" = yes ; then
 		AC_DEFINE(USE_OK_BCOPY)
 	else
 		AC_DEFINE(USE_MY_MEMMOVE)
@@ -346,7 +366,7 @@
 dnl to documentation, unrecognized directives cause older compilers to barf.
 AC_DEFUN([CF_GCC_ATTRIBUTES],
 [
-if test -n "$GCC"
+if test "$GCC" = yes
 then
 cat > conftest.i <<EOF
 #ifndef GCC_PRINTF
@@ -362,7 +382,7 @@
 #define GCC_UNUSED /* nothing */
 #endif
 EOF
-if test -n "$GCC"
+if test "$GCC" = yes
 then
 	AC_CHECKING([for $CC __attribute__ directives])
 	changequote(,)dnl
@@ -429,7 +449,7 @@
 dnl
 AC_DEFUN([CF_GCC_WARNINGS],
 [
-if test -n "$GCC"
+if test "$GCC" = yes
 then
 	changequote(,)dnl
 	cat > conftest.$ac_ext <<EOF
@@ -481,18 +501,23 @@
 make an error
 #endif],
 	[cf_cv_gnu_source=no],
-	[cf_save="$CFLAGS"
-	 CFLAGS="$CFLAGS -D_GNU_SOURCE"
+	[cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
 	 AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifdef _XOPEN_SOURCE
 make an error
 #endif],
 	[cf_cv_gnu_source=no],
 	[cf_cv_gnu_source=yes])
-	CFLAGS="$cf_save"
+	CPPFLAGS="$cf_save"
 	])
 ])
-test "$cf_cv_gnu_source" = yes && CFLAGS="$CFLAGS -D_GNU_SOURCE"
+test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
+AC_DEFUN([CF_HELP_MESSAGE],
+[AC_DIVERT_HELP([$1])dnl
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl Use imake to obtain compiler flags.  We could, in principle, write tests to
@@ -907,7 +932,7 @@
 AC_DEFUN([CF_UPPER],
 [
 changequote(,)dnl
-$1=`echo $2 | tr '[a-z]' '[A-Z]'`
+$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 changequote([,])dnl
 ])dnl
 dnl ---------------------------------------------------------------------------
@@ -1115,14 +1140,15 @@
 for cf_path in default \
 	/usr/contrib/X11R6 \
 	/usr/contrib/X11R5 \
-	/usr/lib/X11R5
+	/usr/lib/X11R5 \
+	/usr/local
 do
 
 	if test -z "$cf_x_athena_include" ; then
-		cf_save="$CFLAGS"
+		cf_save="$CPPFLAGS"
 		cf_test=X11/$cf_x_athena/SimpleMenu.h
 		if test $cf_path != default ; then
-			CFLAGS="-I$cf_path/include $cf_save"
+			CPPFLAGS="-I$cf_path/include $cf_save"
 			AC_MSG_CHECKING(for $cf_test in $cf_path)
 		else
 			AC_MSG_CHECKING(for $cf_test)
@@ -1136,7 +1162,7 @@
 		if test "$cf_result" = yes ; then
 			cf_x_athena_include=$cf_path
 		else
-			CFLAGS="$cf_save"
+			CPPFLAGS="$cf_save"
 		fi
 	fi
 
Index: xc/programs/xterm/button.c
diff -u xc/programs/xterm/button.c:3.48 xc/programs/xterm/button.c:3.52
--- xc/programs/xterm/button.c:3.48	Mon Jun 12 22:28:37 2000
+++ xc/programs/xterm/button.c	Tue Nov 28 18:07:33 2000
@@ -50,7 +50,7 @@
  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  * SOFTWARE.
  */
-/* $XFree86: xc/programs/xterm/button.c,v 3.48 2000/06/13 02:28:37 dawes Exp $ */
+/* $XFree86: xc/programs/xterm/button.c,v 3.52 2000/11/28 23:07:33 dawes Exp $ */
 
 /*
 button.c	Handles button events in the terminal emulator.
@@ -77,7 +77,17 @@
 #include <menu.h>
 #include <xcharmouse.h>
 
+#if OPT_WIDE_CHARS
+#include <charclass.h>
+#include <wcwidth.h>
+#else
+#define CharacterClass(value) \
+	charClass[value & ((sizeof(charClass)/sizeof(charClass[0]))-1)]
+#endif
+
 #define XTERM_CELL(row,col) getXtermCell(screen, row + screen->topline, col)
+#define XTERM_CELL_C1(row,col) getXtermCellComb1(screen, row + screen->topline, col)
+#define XTERM_CELL_C2(row,col) getXtermCellComb2(screen, row + screen->topline, col)
 
       /*
        * We reserve shift modifier for cut/paste operations.  In principle we
@@ -760,6 +770,7 @@
 }
 
 #if OPT_WIDE_CHARS
+#ifndef X_HAVE_UTF8_STRING
 static Atom XA_UTF8_STRING(Display *dpy)
 {
     static AtomPtr p = NULL;
@@ -769,6 +780,7 @@
     return XmuInternAtom(dpy, p);
 }
 #endif
+#endif
 
 struct _SelectionList {
     String *params;
@@ -908,15 +920,12 @@
 	Cardinal num_params,
 	Bool utf8_failed GCC_UNUSED)	/* already tried UTF-8 */
 {
-    TScreen *screen;
     Atom selection;
     int cutbuffer;
 
     if (!IsXtermWidget(w))
 	return;
 
-    screen = &((XtermWidget)w)->screen;
-
     XmuInternStrings(XtDisplay(w), params, (Cardinal)1, &selection);
     switch (selection) {
       case XA_CUT_BUFFER0: cutbuffer = 0; break;
@@ -946,6 +955,7 @@
     } else {
 	struct _SelectionList* list;
 #if OPT_WIDE_CHARS
+	TScreen *screen = &((XtermWidget)w)->screen;
 	if (!screen->wide_chars || utf8_failed) {
 	    params++;
 	    num_params--;
@@ -1487,6 +1497,13 @@
     if (rawCol > cols) rawCol = cols;
 }
 
+#if OPT_WIDE_CHARS
+int iswide(int i)
+{
+    return (i == HIDDEN_CHAR) || (my_wcwidth(i) == 2);
+}
+#endif
+
 static void
 PointToRowCol(
     register int y,
@@ -1512,6 +1529,17 @@
 	else if(col > screen->max_col+1) {
 		col = screen->max_col+1;
 	}
+#if OPT_WIDE_CHARS
+	/*
+	 * If we got a click on the right half of a doublewidth character,
+	 * pretend it happened on the left half.
+	 */
+	if (col > 0
+	 && iswide(XTERM_CELL(row, col-1))
+	 && (XTERM_CELL(row, col) == HIDDEN_CHAR)) {
+		col -= 1;
+	}
+#endif
 	*r = row;
 	*c = col;
 }
@@ -1540,6 +1568,7 @@
 	return(i);
 }
 
+#if !OPT_WIDE_CHARS
 /*
 ** double click table for cut and paste in 8 bits
 **
@@ -1628,6 +1657,7 @@
 
     return (0);
 }
+#endif
 
 #if OPT_WIDE_CHARS
 static int class_of(TScreen *screen, int row, int col)
@@ -1639,13 +1669,18 @@
     }
 #endif
     value = XTERM_CELL(row, col);
-    if_OPT_WIDE_CHARS(screen,{
-	/*FIXME: extend the character-class table */
+    if_OPT_WIDE_CHARS(screen, {
+	return CharacterClass(value);
     })
-    return charClass[value & ((sizeof(charClass)/sizeof(charClass[0]))-1)];
+    return CharacterClass(value);
 }
+#define ClassSelects(screen, row, col, cclass) \
+	 (class_of(screen, row, col) == cclass \
+	 || XTERM_CELL(row, col) == HIDDEN_CHAR)
 #else
 #define class_of(screen,row,col) charClass[XTERM_CELL(row, col)]
+#define ClassSelects(screen, row, col, cclass) \
+	 (class_of(screen,row, col) == cclass)
 #endif
 
 /*
@@ -1665,6 +1700,21 @@
 	register int length;
 	register int cclass;
 
+#if OPT_WIDE_CHARS
+	if (startCol > 1
+	 && iswide(XTERM_CELL(startRow, startCol-1))
+	 && XTERM_CELL(startRow, startCol-0) == HIDDEN_CHAR) {
+		fprintf(stderr, "Adjusting start. Changing downwards from %i.\n", startCol);
+		startCol -= 1;
+		if (endCol == (startCol+1)) endCol--;
+	}
+
+	if (iswide(XTERM_CELL(endRow, endCol-1))
+	 && XTERM_CELL(endRow, endCol) == HIDDEN_CHAR) {
+		endCol += 1;
+	}
+#endif
+
 	if (Coordinate(startRow, startCol) <= Coordinate(endRow, endCol)) {
 		startSRow = startRRow = startRow;
 		startSCol = startRCol = startCol;
@@ -1702,9 +1752,15 @@
 					startSCol = LastTextCol(startSRow);
 				    }
 				} while (startSCol >= 0
-				 && class_of(screen,startSRow,startSCol) == cclass);
+				 && ClassSelects(screen, startSRow, startSCol, cclass));
 				++startSCol;
 			}
+
+#if OPT_WIDE_CHARS
+			if (startSCol && XTERM_CELL(startSRow, startSCol) == HIDDEN_CHAR)
+				startSCol++;
+#endif
+
 			if (endSCol > (LastTextCol(endSRow) + 1)) {
 				endSCol = 0;
 				endSRow++;
@@ -1720,7 +1776,7 @@
 					length = LastTextCol(endSRow);
 				    }
 				} while (endSCol <= length
-				 && class_of(screen,endSRow,endSCol) == cclass);
+				 && ClassSelects(screen,endSRow,endSCol, cclass));
 				/* Word select selects if pointing to any char
 				   in "word", especially in that it includes
 				   the last character in a word.  So no --endSCol
@@ -1730,6 +1786,12 @@
 					++endSRow;
 				}
 			}
+
+#if OPT_WIDE_CHARS
+			if (endSCol && XTERM_CELL(endSRow, endSCol) == HIDDEN_CHAR)
+				endSCol++;
+#endif
+
 			saveStartWRow = startSRow;
 			saveStartWCol = startSCol;
 			break;
@@ -2182,12 +2244,18 @@
 			"%s: selection too big (%d bytes), not storing in CUT_BUFFER%d\n",
 			xterm_name, termw->screen.selection_length, cutbuffer);
 	    } else {
-	      /* Cutbuffers are untyped, so in the wide chars case, we
-		 just store the raw UTF-8 data.	 It is unlikely it
-		 will be useful to anyone. */
+		/* This used to just use the UTF-8 data, which was totally
+		 * broken as not even the corresponding paste code in Xterm
+		 * understood this!  So now it converts to Latin1 first.
+		 *   Robert Brady, 2000-09-05
+		 */
+		unsigned long length = termw->screen.selection_length;
+		Char *data = (Char *)termw->screen.selection_data;
+		if_OPT_WIDE_CHARS((&(termw->screen)), {
+		    data = UTF8toLatin1(data, length, &length);
+		})
 		XStoreBuffer( XtDisplay((Widget)termw),
-			      termw->screen.selection_data,
-			      termw->screen.selection_length, cutbuffer );
+			      (char *)data, length, cutbuffer );
 	    }
 	} else if (!replyToEmacs) {
 	    have_selection |=
@@ -2261,6 +2329,10 @@
     int i = 0;
     unsigned c;
     Char *result = lp;
+#if OPT_WIDE_CHARS
+    int previous = 0;
+    unsigned c_1 = 0, c_2 = 0;
+#endif
 
     i = Length(screen, row, scol, ecol);
     ecol = scol + i;
@@ -2274,8 +2346,27 @@
     for (i = scol; i < ecol; i++) {
 	c = E2A(XTERM_CELL(row, i));
 #if OPT_WIDE_CHARS
-	if (screen->utf8_mode)
+	if (screen->utf8_mode) {
+	    c_1 = E2A(XTERM_CELL_C1(row, i));
+	    c_2 = E2A(XTERM_CELL_C2(row, i));
+	}
+
+	/* We want to strip out every occurrence of HIDDEN_CHAR AFTER a
+	 * wide character.
+	 */
+	if (c == HIDDEN_CHAR && iswide(previous)) {
+	    previous = c;
+	    continue;
+	}
+	previous = c;
+	if (screen->utf8_mode) {
 	    lp = convertToUTF8(lp, c);
+	    if (c_1) {
+		lp = convertToUTF8(lp, c_1);
+		if (c_2)
+		    lp = convertToUTF8(lp, c_2);
+	    }
+	}
 	else
 #endif
 	{
Index: xc/programs/xterm/charclass.c
diff -u /dev/null xc/programs/xterm/charclass.c:1.1
--- /dev/null	Mon Dec 18 14:36:19 2000
+++ xc/programs/xterm/charclass.c	Sat Aug 26 00:33:53 2000
@@ -0,0 +1,140 @@
+/*
+ * Compact and efficient reimplementation of the
+ * xterm character class mechanism for large character sets
+ *
+ * Markus Kuhn -- mkuhn@acm.org -- 2000-07-03
+ *
+ * Xterm allows users to select entire words with a double-click on
+ * the left mouse button. Opinions might differ on what type of
+ * characters are part of separate words, therefore xterm allows users
+ * to configure a class code for each 8-bit character. Words are
+ * maximum length sequences of neighboring characters with identical
+ * class code. Extending this mechanism to Unicode naively would
+ * create an at least 2^16 entries (128 kB) long class code table.
+ * Instead, we transform the character class table into a list
+ * of intervals, that will be accessed via a linear search.
+ * Changes made to the table by the user will be appended. A special
+ * class code -1 (default) marks characters who have their code number
+ * as the class code. We could alternatively use a sorted table of
+ * non-overlapping intervals that can be accessed via binary search,
+ * but merging in new intervals is significantly more hassle and
+ * not worth the effort here.
+ */
+/* $XFree86: xc/programs/xterm/charclass.c,v 1.1 2000/08/26 04:33:53 dawes Exp $ */
+
+#include <xterm.h>
+#include <charclass.h>
+
+#if OPT_WIDE_CHARS
+
+#include <stdlib.h>
+
+struct classentry {
+  int class;
+  int first;
+  int last;
+} *classtab;
+
+/*
+ * Special convention for classtab[0]:
+ * - classtab[0].class is the allocated number of entries in classtab
+ * - classtab[0].first = 1 (first used entry in classtab)
+ * - classtab[0].last is the last used entry in classtab
+ */
+
+int SetCharacterClassRange(int low, int high, int value)
+{
+  if (high < low)
+    return -1; /* nothing to do */
+
+  /* make sure we have at least one free entry left at table end */
+  if (classtab[0].last > classtab[0].class - 2) {
+    classtab[0].class += 5 + classtab[0].class/4;
+    classtab = realloc(classtab,
+                       classtab[0].class * sizeof(struct classentry));
+    if (!classtab)
+      abort();
+  }
+
+  /* simply append new interval to end of interval array */
+  classtab[0].last++;
+  classtab[classtab[0].last].first = low;
+  classtab[classtab[0].last].last  = high;
+  classtab[classtab[0].last].class = value;
+
+  return 0;
+}
+
+void init_classtab(void)
+{
+  const int size = 50;
+
+  classtab = (struct classentry *) malloc(size * sizeof(struct classentry));
+  if (!classtab)
+    abort();
+  classtab[0].class = size;
+  classtab[0].first = 1;
+  classtab[0].last = 0;
+  
+  /* old xterm default classes */
+  SetCharacterClassRange(0, 0, 32);
+  SetCharacterClassRange(1, 31, 1);
+  SetCharacterClassRange('\t', '\t', 32);
+  SetCharacterClassRange('0', '9', 48);
+  SetCharacterClassRange('A', 'Z', 48);
+  SetCharacterClassRange('_', '_', 48);
+  SetCharacterClassRange('a', 'z', 48);
+  SetCharacterClassRange(127, 159, 1);
+  SetCharacterClassRange(160, 191, -1);
+  SetCharacterClassRange(192, 255, 48);
+  SetCharacterClassRange(215, 215, 216);
+  SetCharacterClassRange(247, 247, 248);
+
+  /* added Unicode classes */
+  SetCharacterClassRange(0x0100, 0xffdf, 48); /* mostly characters */
+  SetCharacterClassRange(0x037e, 0x037e, -1); /* Greek question mark */
+  SetCharacterClassRange(0x0387, 0x0387, -1); /* Greek ano teleia */
+  SetCharacterClassRange(0x055a, 0x055f, -1); /* Armenian punctuation */
+  SetCharacterClassRange(0x0589, 0x0589, -1); /* Armenian full stop */
+  SetCharacterClassRange(0x0700, 0x070d, -1); /* Syriac punctuation */
+  SetCharacterClassRange(0x104a, 0x104f, -1); /* Myanmar punctuation */
+  SetCharacterClassRange(0x10fb, 0x10fb, -1); /* Georgian punctuation */
+  SetCharacterClassRange(0x1361, 0x1368, -1); /* Ethiopic punctuation */
+  SetCharacterClassRange(0x166d, 0x166e, -1); /* Canadian Syl. punctuation */
+  SetCharacterClassRange(0x17d4, 0x17dc, -1); /* Khmer punctuation */
+  SetCharacterClassRange(0x1800, 0x180a, -1); /* Mongolian punctuation */
+  SetCharacterClassRange(0x2000, 0x200a, 32); /* spaces */
+  SetCharacterClassRange(0x200b, 0x27ff, -1); /* punctuation and symbols */
+  SetCharacterClassRange(0x2070, 0x207f, 0x2070); /* superscript */
+  SetCharacterClassRange(0x2080, 0x208f, 0x2080); /* subscript */
+  SetCharacterClassRange(0x3000, 0x3000, 32); /* ideographic space */
+  SetCharacterClassRange(0x3001, 0x3020, -1); /* ideographic punctuation */
+  SetCharacterClassRange(0x3040, 0x309f, 0x3040); /* Hiragana */
+  SetCharacterClassRange(0x30a0, 0x30ff, 0x30a0); /* Katakana */
+  SetCharacterClassRange(0x3300, 0x9fff, 0x4e00); /* CJK Ideographs */
+  SetCharacterClassRange(0xac00, 0xd7a3, 0xac00); /* Hangul Syllables */
+  SetCharacterClassRange(0xf900, 0xfaff, 0x4e00); /* CJK Ideographs */
+  SetCharacterClassRange(0xfe30, 0xfe6b, -1); /* punctuation forms */
+  SetCharacterClassRange(0xff00, 0xff0f, -1); /* half/fullwidth ASCII */
+  SetCharacterClassRange(0xff1a, 0xff20, -1); /* half/fullwidth ASCII */
+  SetCharacterClassRange(0xff3b, 0xff40, -1); /* half/fullwidth ASCII */
+  SetCharacterClassRange(0xff5b, 0xff64, -1); /* half/fullwidth ASCII */
+
+  return;
+}
+
+int CharacterClass(int c)
+{
+  int i, class = -1;
+
+  for (i = classtab[0].first; i <= classtab[0].last; i++)
+    if (classtab[i].first <= c && classtab[i].last >= c)
+      class = classtab[i].class;
+
+  if (class < 0)
+    class = c;
+  
+  return class;
+}
+
+#endif
Index: xc/programs/xterm/charclass.h
diff -u /dev/null xc/programs/xterm/charclass.h:1.1
--- /dev/null	Mon Dec 18 14:36:19 2000
+++ xc/programs/xterm/charclass.h	Sat Aug 26 00:33:53 2000
@@ -0,0 +1,13 @@
+/* $XFree86: xc/programs/xterm/charclass.h,v 1.1 2000/08/26 04:33:53 dawes Exp $ */
+
+#ifndef CHARCLASS_H
+#define CHARCLASS_H
+
+extern void init_classtab(void);
+/* intialise the table. needs calling before either of the 
+   others. */
+
+extern int SetCharacterClassRange(int low, int high, int value);
+extern int CharacterClass(int c);
+
+#endif
Index: xc/programs/xterm/charproc.c
diff -u xc/programs/xterm/charproc.c:3.107 xc/programs/xterm/charproc.c:3.112
--- xc/programs/xterm/charproc.c:3.107	Tue Jun 13 20:16:17 2000
+++ xc/programs/xterm/charproc.c	Wed Nov 29 03:39:24 2000
@@ -1,6 +1,6 @@
 /*
  * $XConsortium: charproc.c /main/196 1996/12/03 16:52:46 swick $
- * $XFree86: xc/programs/xterm/charproc.c,v 3.107 2000/06/14 00:16:17 dawes Exp $
+ * $XFree86: xc/programs/xterm/charproc.c,v 3.112 2000/11/29 08:39:24 keithp Exp $
  */
 
 /*
@@ -99,6 +99,11 @@
 #include <X11/Xaw/XawImP.h>
 #endif
 
+#if OPT_WIDE_CHARS
+#include <wcwidth.h>
+#include <precompose.h>
+#endif
+
 #include <stdio.h>
 #include <ctype.h>
 
@@ -344,131 +349,138 @@
 #endif
 };
 
+#ifdef VMS
+#define OS_DEPENDENT_PRINT_COMMAND "print/delete/noflag"
+#else  /* VMS */
+#define OS_DEPENDENT_PRINT_COMMAND "lpr"
+#endif /* VMS */
+
 static XtResource resources[] = {
-Sres(XtNfont,		XtCFont,	misc.f_n,		DEFFONT),
-Sres(XtNboldFont,	XtCBoldFont,	misc.f_b,		DEFBOLDFONT),
+Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvents, FALSE),
+Bres(XtNalwaysHighlight, XtCAlwaysHighlight, screen.always_highlight, FALSE),
+Bres(XtNappcursorDefault, XtCAppcursorDefault, misc.appcursorDefault, FALSE),
+Bres(XtNappkeypadDefault, XtCAppkeypadDefault, misc.appkeypadDefault, FALSE),
+Bres(XtNautoWrap,	XtCAutoWrap,	misc.autoWrap,		TRUE),
+Bres(XtNawaitInput,	XtCAwaitInput,	screen.awaitInput,	FALSE),
+Bres(XtNbackarrowKey,	XtCBackarrowKey, screen.backarrow_key, TRUE),
+Bres(XtNboldMode,	XtCBoldMode, screen.bold_mode,		TRUE),
 Bres(XtNc132,		XtCC132,	screen.c132,		FALSE),
-Sres(XtNcharClass,	XtCCharClass,	screen.charClass,	NULL),
 Bres(XtNcurses,		XtCCurses,	screen.curses,		FALSE),
-Bres(XtNhpLowerleftBugCompat, XtCHpLowerleftBugCompat, screen.hp_ll_bc, FALSE),
-#if OPT_XMC_GLITCH
-Ires(XtNxmcGlitch,	XtCXmcGlitch,	screen.xmc_glitch,	0),
-Ires(XtNxmcAttributes,	XtCXmcAttributes, screen.xmc_attributes, 1),
-Bres(XtNxmcInline,	XtCXmcInline,	screen.xmc_inline,	FALSE),
-Bres(XtNxmcMoveSGR,	XtCXmcMoveSGR,	screen.move_sgr_ok,	TRUE),
-#endif
 Bres(XtNcutNewline,	XtCCutNewline,	screen.cutNewline,	TRUE),
 Bres(XtNcutToBeginningOfLine, XtCCutToBeginningOfLine, screen.cutToBeginningOfLine, TRUE),
-Bres(XtNhighlightSelection, XtCHighlightSelection, screen.highlight_selection, FALSE),
-Bres(XtNtrimSelection, XtCTrimSelection, screen.trim_selection, FALSE),
-{XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
-	XtOffsetOf(XtermWidgetRec, core.background_pixel),
-	XtRString, XtDefaultBackground},
-Cres(XtNforeground,	screen.foreground,	XtDefaultForeground),
-Cres(XtNcursorColor,	screen.cursorcolor,	XtDefaultForeground),
-#if OPT_BLINK_CURS
-Bres(XtNcursorBlink,	XtCCursorBlink, screen.cursor_blink,	FALSE),
-Ires(XtNcursorOnTime,	XtCCursorOnTime, screen.cursor_on,	600),
-Ires(XtNcursorOffTime,	XtCCursorOffTime, screen.cursor_off,	300),
-#endif
-Sres(XtNkeyboardDialect, XtCKeyboardDialect, screen.keyboard_dialect, DFT_KBD_DIALECT),
-Bres(XtNeightBitInput, XtCEightBitInput, screen.input_eight_bits, TRUE),
-Bres(XtNeightBitOutput, XtCEightBitOutput, screen.output_eight_bits, TRUE),
+Bres(XtNdeleteIsDEL,	XtCDeleteIsDEL,	screen.delete_is_del,	2),
+Bres(XtNdynamicColors,	XtCDynamicColors, misc.dynamicColors,	TRUE),
 Bres(XtNeightBitControl, XtCEightBitControl, screen.control_eight_bits, FALSE),
-Bres(XtNmetaSendsEscape, XtCMetaSendsEscape, screen.meta_sends_esc, FALSE),
-Sres(XtNgeometry,	XtCGeometry, misc.geo_metry,		NULL),
-Bres(XtNalwaysHighlight, XtCAlwaysHighlight, screen.always_highlight, FALSE),
-Bres(XtNappcursorDefault, XtCAppcursorDefault, misc.appcursorDefault, FALSE),
-Bres(XtNappkeypadDefault, XtCAppkeypadDefault, misc.appkeypadDefault, FALSE),
-Bres(XtNbackarrowKey, XtCBackarrowKey, screen.backarrow_key, TRUE),
-Ires(XtNbellSuppressTime, XtCBellSuppressTime, screen.bellSuppressTime, BELLSUPPRESSMSEC),
-Sres(XtNtekGeometry,	XtCGeometry, misc.T_geometry,		NULL),
-Ires(XtNinternalBorder, XtCBorderWidth, screen.border,		DEFBORDER),
+Bres(XtNeightBitInput,	XtCEightBitInput, screen.input_eight_bits, TRUE),
+Bres(XtNeightBitOutput, XtCEightBitOutput, screen.output_eight_bits, TRUE),
+Bres(XtNhighlightSelection, XtCHighlightSelection, screen.highlight_selection, FALSE),
+Bres(XtNhpLowerleftBugCompat, XtCHpLowerleftBugCompat, screen.hp_ll_bc, FALSE),
 Bres(XtNjumpScroll,	XtCJumpScroll, screen.jumpscroll,	TRUE),
-Bres(XtNoldXtermFKeys,	XtCOldXtermFKeys, screen.old_fkeys,	FALSE),
-Bres(XtNdeleteIsDEL,	XtCDeleteIsDEL,	screen.delete_is_del,	2),
-#ifdef ALLOWLOGGING
-Sres(XtNlogFile,	XtCLogfile, screen.logfile,		NULL),
-Bres(XtNlogging,	XtCLogging, misc.log_on,		FALSE),
-Bres(XtNlogInhibit,	XtCLogInhibit, misc.logInhibit,		FALSE),
-#endif
 Bres(XtNloginShell,	XtCLoginShell, misc.login_shell,	FALSE),
 Bres(XtNmarginBell,	XtCMarginBell, screen.marginbell,	FALSE),
-Cres(XtNpointerColor,	screen.mousecolor,	XtDefaultForeground),
-{XtNpointerColorBackground, XtCBackground, XtRPixel, sizeof(Pixel),
-	XtOffsetOf(XtermWidgetRec, screen.mousecolorback),
-	XtRString, "XtDefaultBackground"},
-{XtNpointerShape,XtCCursor, XtRCursor, sizeof(Cursor),
-	XtOffsetOf(XtermWidgetRec, screen.pointer_cursor),
-	XtRString, (XtPointer) "xterm"},
-Sres(XtNanswerbackString, XtCAnswerbackString, screen.answer_back, ""),
-#if OPT_PRINT_COLORS
-Ires(XtNprintAttributes, XtCPrintAttributes, screen.print_attributes, 1),
-#endif
+Bres(XtNmetaSendsEscape, XtCMetaSendsEscape, screen.meta_sends_esc, FALSE),
+Bres(XtNmultiScroll,	XtCMultiScroll, screen.multiscroll, FALSE),
+Bres(XtNoldXtermFKeys,	XtCOldXtermFKeys, screen.old_fkeys,	FALSE),
 Bres(XtNprinterAutoClose, XtCPrinterAutoClose, screen.printer_autoclose, FALSE),
-Ires(XtNprinterControlMode, XtCPrinterControlMode, screen.printer_controlmode, 0),
-#ifdef VMS
-#define OS_DEPENDENT_PRINT_COMMAND "print/delete/noflag"
-#else  /* VMS */
-#define OS_DEPENDENT_PRINT_COMMAND "lpr"
-#endif /* VMS */
-Sres(XtNprinterCommand,	XtCPrinterCommand, screen.printer_command, OS_DEPENDENT_PRINT_COMMAND),
 Bres(XtNprinterExtent,	XtCPrinterExtent, screen.printer_extent, FALSE),
 Bres(XtNprinterFormFeed, XtCPrinterFormFeed, screen.printer_formfeed, FALSE),
-Ires(XtNmultiClickTime, XtCMultiClickTime, screen.multiClickTime, MULTICLICKTIME),
-Bres(XtNmultiScroll,	XtCMultiScroll, screen.multiscroll, FALSE),
-Ires(XtNnMarginBell,	XtCColumn, screen.nmarginbell, N_MARGINBELL),
 Bres(XtNreverseVideo,	XtCReverseVideo, misc.re_verse, FALSE),
-{XtNresizeGravity, XtCResizeGravity, XtRGravity, sizeof(XtGravity),
-	XtOffsetOf(XtermWidgetRec, misc.resizeGravity),
-	XtRImmediate, (XtPointer) SouthWestGravity},
 Bres(XtNreverseWrap,	XtCReverseWrap, misc.reverseWrap,	FALSE),
-Bres(XtNautoWrap,	XtCAutoWrap,	misc.autoWrap,		TRUE),
-Ires(XtNsaveLines,	XtCSaveLines,	screen.savelines,	SAVELINES),
 Bres(XtNscrollBar,	XtCScrollBar,	misc.scrollbar,		FALSE),
-Ires(XtNlimitResize,	XtCLimitResize, misc.limit_resize,	1),
-#ifdef SCROLLBAR_RIGHT
-Bres(XtNrightScrollBar, XtCRightScrollBar, misc.useRight, FALSE),
-#endif
-Bres(XtNscrollTtyOutput, XtCScrollCond, screen.scrollttyoutput, TRUE),
 Bres(XtNscrollKey,	XtCScrollCond,	screen.scrollkey,	FALSE),
-Ires(XtNscrollLines,	XtCScrollLines,	screen.scrolllines,	SCROLLLINES),
+Bres(XtNscrollTtyOutput, XtCScrollCond, screen.scrollttyoutput, TRUE),
 Bres(XtNsignalInhibit,	XtCSignalInhibit, misc.signalInhibit,	FALSE),
-#if OPT_NUM_LOCK
-Bres(XtNnumLock,	XtCNumLock,	misc.real_NumLock,	TRUE),
-Bres(XtNalwaysUseMods,	XtCAlwaysUseMods, misc.alwaysUseMods,	FALSE),
-#endif
-#if OPT_SHIFT_KEYS
-Bres(XtNshiftKeys,	XtCShiftKeys,	misc.shift_keys,	TRUE),
-#endif
-#if OPT_SUNPC_KBD
-Ires(XtNctrlFKeys,	XtCCtrlFKeys,	misc.ctrl_fkeys,	10),
-#endif
-#if OPT_TEK4014
-Bres(XtNtekInhibit,	XtCTekInhibit,	misc.tekInhibit,	FALSE),
-Bres(XtNtekSmall,	XtCTekSmall,	misc.tekSmall,		FALSE),
-Bres(XtNtekStartup,	XtCTekStartup,	screen.TekEmu,		FALSE),
-#endif
 Bres(XtNtiteInhibit,	XtCTiteInhibit, misc.titeInhibit,	FALSE),
+Bres(XtNtrimSelection,	XtCTrimSelection, screen.trim_selection, FALSE),
+Bres(XtNunderLine,	XtCUnderLine, screen.underline,		TRUE),
 Bres(XtNvisualBell,	XtCVisualBell,	screen.visualbell,	FALSE),
-Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvents, FALSE),
-Bres(XtNawaitInput,	XtCAwaitInput,	screen.awaitInput,	FALSE),
-Sres("font1", "Font1", screen.menu_font_names[fontMenu_font1], NULL),
-Sres("font2", "Font2", screen.menu_font_names[fontMenu_font2], NULL),
-Sres("font3", "Font3", screen.menu_font_names[fontMenu_font3], NULL),
-Sres("font4", "Font4", screen.menu_font_names[fontMenu_font4], NULL),
-Sres("font5", "Font5", screen.menu_font_names[fontMenu_font5], NULL),
-Sres("font6", "Font6", screen.menu_font_names[fontMenu_font6], NULL),
+Cres(XtNcursorColor,	screen.cursorcolor,	XtDefaultForeground),
+Cres(XtNforeground,	screen.foreground,	XtDefaultForeground),
+Cres(XtNpointerColor,	screen.mousecolor,	XtDefaultForeground),
+Dres(XtNbackground,	core.background_pixel,	XtDefaultBackground),
+Dres(XtNpointerColorBackground, screen.mousecolorback, "XtDefaultBackground"),
+Ires(XtNbellSuppressTime, XtCBellSuppressTime, screen.bellSuppressTime, BELLSUPPRESSMSEC),
+Ires(XtNinternalBorder, XtCBorderWidth, screen.border,		DEFBORDER),
+Ires(XtNlimitResize,	XtCLimitResize, misc.limit_resize,	1),
+Ires(XtNmultiClickTime, XtCMultiClickTime, screen.multiClickTime, MULTICLICKTIME),
+Ires(XtNnMarginBell,	XtCColumn, screen.nmarginbell, N_MARGINBELL),
+Ires(XtNprinterControlMode, XtCPrinterControlMode, screen.printer_controlmode, 0),
+Ires(XtNsaveLines,	XtCSaveLines,	screen.savelines,	SAVELINES),
+Ires(XtNscrollLines,	XtCScrollLines,	screen.scrolllines,	SCROLLLINES),
+Sres("font1",		"Font1", screen.menu_font_names[fontMenu_font1], NULL),
+Sres("font2",		"Font2", screen.menu_font_names[fontMenu_font2], NULL),
+Sres("font3",		"Font3", screen.menu_font_names[fontMenu_font3], NULL),
+Sres("font4",		"Font4", screen.menu_font_names[fontMenu_font4], NULL),
+Sres("font5",		"Font5", screen.menu_font_names[fontMenu_font5], NULL),
+Sres("font6",		"Font6", screen.menu_font_names[fontMenu_font6], NULL),
+Sres(XtNanswerbackString, XtCAnswerbackString, screen.answer_back, ""),
+Sres(XtNboldFont,	XtCBoldFont,	misc.f_b,		DEFBOLDFONT),
+Sres(XtNcharClass,	XtCCharClass,	screen.charClass,	NULL),
+Sres(XtNdecTerminalID,	XtCDecTerminalID, screen.term_id,	DFT_DECID),
+Sres(XtNfont,		XtCFont,	misc.f_n,		DEFFONT),
+Sres(XtNgeometry,	XtCGeometry, misc.geo_metry,		NULL),
+Sres(XtNkeyboardDialect, XtCKeyboardDialect, screen.keyboard_dialect, DFT_KBD_DIALECT),
+Sres(XtNprinterCommand,	XtCPrinterCommand, screen.printer_command, OS_DEPENDENT_PRINT_COMMAND),
+Sres(XtNtekGeometry,	XtCGeometry,	misc.T_geometry,	NULL),
+
+{XtNresizeGravity, XtCResizeGravity, XtRGravity, sizeof(XtGravity),
+	XtOffsetOf(XtermWidgetRec, misc.resizeGravity),
+	XtRImmediate, (XtPointer) SouthWestGravity},
+
+{XtNpointerShape,XtCCursor, XtRCursor, sizeof(Cursor),
+	XtOffsetOf(XtermWidgetRec, screen.pointer_cursor),
+	XtRString, (XtPointer) "xterm"},
+
+#ifdef ALLOWLOGGING
+Bres(XtNlogInhibit,	XtCLogInhibit, misc.logInhibit,		FALSE),
+Bres(XtNlogging,	XtCLogging, misc.log_on,		FALSE),
+Sres(XtNlogFile,	XtCLogfile, screen.logfile,		NULL),
+#endif
+
+#ifndef NO_ACTIVE_ICON
+Bres("activeIcon",	"ActiveIcon", misc.active_icon,		FALSE),
+Ires("iconBorderWidth", XtCBorderWidth, misc.icon_border_width, 2),
+
+{"iconFont", "IconFont", XtRFontStruct, sizeof(XFontStruct),
+	XtOffsetOf(XtermWidgetRec, screen.fnt_icon),
+	XtRString, (XtPointer)XtExtdefaultfont},
+
+{"iconBorderColor", XtCBorderColor, XtRPixel, sizeof(Pixel),
+	XtOffsetOf(XtermWidgetRec, misc.icon_border_pixel),
+	XtRString, XtExtdefaultbackground},
+
+#endif /* NO_ACTIVE_ICON */
+
+#if OPT_BLINK_CURS
+Bres(XtNcursorBlink,	XtCCursorBlink, screen.cursor_blink,	FALSE),
+Ires(XtNcursorOnTime,	XtCCursorOnTime, screen.cursor_on,	600),
+Ires(XtNcursorOffTime,	XtCCursorOffTime, screen.cursor_off,	300),
+#endif
+
 #if OPT_DEC_CHRSET
 Bres(XtNfontDoublesize, XtCFontDoublesize, screen.font_doublesize, TRUE),
 Ires(XtNcacheDoublesize, XtCCacheDoublesize, screen.cache_doublesize, NUM_CHRSET),
 #endif
+
+#if OPT_HIGHLIGHT_COLOR
+Cres(XtNhighlightColor,	screen.highlightcolor,	XtDefaultForeground),
+#endif /* OPT_HIGHLIGHT_COLOR */
+
 #if OPT_INPUT_METHOD
+Bres(XtNopenIm,		XtCOpenIm,	misc.open_im,		TRUE),
 Sres(XtNinputMethod,	XtCInputMethod,	misc.input_method,	NULL),
 Sres(XtNpreeditType,	XtCPreeditType,	misc.preedit_type,	"Root"),
-Bres(XtNopenIm,		XtCOpenIm,	misc.open_im,		TRUE),
 #endif
+
 #if OPT_ISO_COLORS
+Bres(XtNboldColors,	XtCColorMode, screen.boldColors,	TRUE),
+Bres(XtNcolorAttrMode,	XtCColorMode, screen.colorAttrMode,	FALSE),
+Bres(XtNcolorBDMode,	XtCColorMode, screen.colorBDMode,	FALSE),
+Bres(XtNcolorBLMode,	XtCColorMode, screen.colorBLMode,	FALSE),
+Bres(XtNcolorMode,	XtCColorMode, screen.colorMode,		DFT_COLORMODE),
+Bres(XtNcolorRVMode,	XtCColorMode, screen.colorRVMode,	FALSE),
+Bres(XtNcolorULMode,	XtCColorMode, screen.colorULMode,	FALSE),
+
 COLOR_RES(XtNcolor0,	screen.Acolors[COLOR_0],	DFT_COLOR("black")),
 COLOR_RES(XtNcolor1,	screen.Acolors[COLOR_1],	DFT_COLOR("red3")),
 COLOR_RES(XtNcolor2,	screen.Acolors[COLOR_2],	DFT_COLOR("green3")),
@@ -485,52 +497,73 @@
 COLOR_RES(XtNcolor13,	screen.Acolors[COLOR_13],	DFT_COLOR("magenta")),
 COLOR_RES(XtNcolor14,	screen.Acolors[COLOR_14],	DFT_COLOR("cyan")),
 COLOR_RES(XtNcolor15,	screen.Acolors[COLOR_15],	DFT_COLOR("white")),
+COLOR_RES(XtNcolorBD,	screen.Acolors[COLOR_BD],	DFT_COLOR(XtDefaultForeground)),
+COLOR_RES(XtNcolorBL,	screen.Acolors[COLOR_BL],	DFT_COLOR(XtDefaultForeground)),
+COLOR_RES(XtNcolorUL,	screen.Acolors[COLOR_UL],	DFT_COLOR(XtDefaultForeground)),
+COLOR_RES(XtNcolorRV,	screen.Acolors[COLOR_RV],	DFT_COLOR(XtDefaultForeground)),
+
 #if OPT_256_COLORS
 # include <256colres.h>
 #elif OPT_88_COLORS
 # include <88colres.h>
 #endif
-COLOR_RES(XtNcolorBD,	screen.Acolors[COLOR_BD],	DFT_COLOR(XtDefaultForeground)),
-COLOR_RES(XtNcolorBL,	screen.Acolors[COLOR_BL],	DFT_COLOR(XtDefaultForeground)),
-COLOR_RES(XtNcolorUL,	screen.Acolors[COLOR_UL],	DFT_COLOR(XtDefaultForeground)),
-COLOR_RES(XtNcolorRV,	screen.Acolors[COLOR_RV],	DFT_COLOR(XtDefaultForeground)),
-Bres(XtNcolorMode,	XtCColorMode, screen.colorMode,	DFT_COLORMODE),
-Bres(XtNcolorULMode,	XtCColorMode, screen.colorULMode,	FALSE),
-Bres(XtNcolorBDMode,	XtCColorMode, screen.colorBDMode,	FALSE),
-Bres(XtNcolorBLMode,	XtCColorMode, screen.colorBLMode,	FALSE),
-Bres(XtNcolorRVMode,	XtCColorMode, screen.colorRVMode,	FALSE),
-Bres(XtNcolorAttrMode,	XtCColorMode, screen.colorAttrMode,	FALSE),
-Bres(XtNboldColors,	XtCColorMode, screen.boldColors,	TRUE),
+
 #endif /* OPT_ISO_COLORS */
-Bres(XtNdynamicColors, XtCDynamicColors, misc.dynamicColors,	TRUE),
-#if OPT_HIGHLIGHT_COLOR
-Cres(XtNhighlightColor,	screen.highlightcolor,	XtDefaultForeground),
-#endif /* OPT_HIGHLIGHT_COLOR */
-Bres(XtNboldMode,	XtCBoldMode, screen.bold_mode,		TRUE),
-Bres(XtNunderLine,	XtCUnderLine, screen.underline,		TRUE),
-Sres(XtNdecTerminalID,	XtCDecTerminalID, screen.term_id,	DFT_DECID),
-#ifndef NO_ACTIVE_ICON
-Bres("activeIcon",	"ActiveIcon", misc.active_icon,		FALSE),
-{"iconFont", "IconFont", XtRFontStruct, sizeof(XFontStruct),
-	XtOffsetOf(XtermWidgetRec, screen.fnt_icon),
-	XtRString, (XtPointer)XtExtdefaultfont},
-Ires("iconBorderWidth", XtCBorderWidth, misc.icon_border_width, 2),
-{"iconBorderColor", XtCBorderColor, XtRPixel, sizeof(Pixel),
-	XtOffsetOf(XtermWidgetRec, misc.icon_border_pixel),
-	XtRString, XtExtdefaultbackground},
-#endif /* NO_ACTIVE_ICON */
+
+#if OPT_NUM_LOCK
+Bres(XtNalwaysUseMods,	XtCAlwaysUseMods, misc.alwaysUseMods,	FALSE),
+Bres(XtNnumLock,	XtCNumLock,	misc.real_NumLock,	TRUE),
+#endif
+
+#if OPT_PRINT_COLORS
+Ires(XtNprintAttributes, XtCPrintAttributes, screen.print_attributes, 1),
+#endif
+
+#if OPT_SHIFT_KEYS
+Bres(XtNshiftKeys,	XtCShiftKeys,	misc.shift_keys,	TRUE),
+#endif
+
+#if OPT_SUNPC_KBD
+Ires(XtNctrlFKeys,	XtCCtrlFKeys,	misc.ctrl_fkeys,	10),
+#endif
+
+#if OPT_TEK4014
+Bres(XtNtekInhibit,	XtCTekInhibit,	misc.tekInhibit,	FALSE),
+Bres(XtNtekSmall,	XtCTekSmall,	misc.tekSmall,		FALSE),
+Bres(XtNtekStartup,	XtCTekStartup,	screen.TekEmu,		FALSE),
+#endif
+
 #if OPT_TOOLBAR
 {XtNmenuBar, XtCMenuBar, XtRWidget, sizeof(Widget),
 	XtOffsetOf(XtermWidgetRec, screen.fullVwin.menu_bar),
 	XtRWidget, (XtPointer) 0},
 Ires(XtNmenuHeight, XtCMenuHeight, screen.fullVwin.menu_height, 25),
 #endif
+
 #if OPT_WIDE_CHARS
 {XtNutf8, XtCUtf8, XtRInt, sizeof(int),
 	XtOffsetOf(XtermWidgetRec, screen.utf8_mode),
 	XtRString, defaultUTF8},
-Bres(XtNwideChars, XtCWideChars, screen.wide_chars, FALSE),
+Bres(XtNwideChars,	XtCWideChars,		screen.wide_chars,	FALSE),
+Sres(XtNwideBoldFont,	XtCWideBoldFont,	misc.f_wb,		DEFWIDEBOLDFONT),
+Sres(XtNwideFont,	XtCWideFont,		misc.f_w,		DEFWIDEFONT),
+#endif
+
+#if OPT_XMC_GLITCH
+Bres(XtNxmcInline,	XtCXmcInline,	screen.xmc_inline,	FALSE),
+Bres(XtNxmcMoveSGR,	XtCXmcMoveSGR,	screen.move_sgr_ok,	TRUE),
+Ires(XtNxmcAttributes,	XtCXmcAttributes, screen.xmc_attributes, 1),
+Ires(XtNxmcGlitch,	XtCXmcGlitch,	screen.xmc_glitch,	0),
 #endif
+
+#ifdef SCROLLBAR_RIGHT
+Bres(XtNrightScrollBar, XtCRightScrollBar, misc.useRight, FALSE),
+#endif
+
+#ifdef XRENDERFONT
+Ires(XtNfaceSize,	XtCFaceSize,	misc.face_size,		DEFFACESIZE),
+Sres(XtNfaceName,	XtCFaceName,	misc.face_name,		DEFFACENAME),
+#endif
 };
 
 static Boolean VTSetValues (Widget cur, Widget request, Widget new_arg, ArgList args, Cardinal *num_args);
@@ -763,6 +796,8 @@
 	    XSelectInput(XtDisplay((t)), XtWindow((t)), (s)->event_mask);	\
 	}
 
+extern int last_written_col, last_written_row;
+
 static void VTparse(void)
 {
 	/* Buffer for processing printable text */
@@ -788,6 +823,7 @@
 	int lastchar;		/* positive iff we had a graphic character */
 	int nextstate;
 	int laststate;
+	int last_was_wide;
 
 	/* We longjmp back to this point in VTReset() */
 	(void)setjmp(vtjmpbuf);
@@ -802,11 +838,49 @@
 	string_mode = 0;
 	lastchar = -1;		/* not a legal IChar */
 	nextstate = -1;		/* not a legal state */
+	last_was_wide = 0;
 
 	for( ; ; ) {
 	    int thischar = -1;
 	    c = doinput();
 
+#if OPT_WIDE_CHARS
+	    if (screen->wide_chars
+	     && my_wcwidth(c) == 0) {
+		unsigned single = 0;
+		int prev, precomposed;
+
+		if (screen->curss) {
+		    dotext(screen, screen->gsets[(int)(screen->curss)],
+			   print_area, 1);
+		    screen->curss = 0;
+		    single++;
+		}
+		if (print_used > single) {
+		    dotext(screen,
+			    screen->gsets[(int)(screen->curgl)],
+			    print_area + single,
+			    print_used - single);
+		}
+		print_used = 0;
+
+		prev = getXtermCell(screen, last_written_row, last_written_col);
+		precomposed = do_precomposition(prev, c);
+
+		if (precomposed != -1) {
+		    putXtermCell(screen, last_written_row, last_written_col, precomposed);
+		    ScrnRefresh(screen, last_written_row, last_written_col, 1, 1, 1);
+		    continue;
+		} else {
+		    addXtermCombining(screen, last_written_row, last_written_col, c);
+		    if (!screen->scroll_amt)
+			ScrnRefresh(screen, last_written_row, last_written_col, 1, 1, 1);
+			/* does this suffice? */
+		    continue;
+		}
+	    }
+#endif
+
 	    /* Intercept characters for printer controller mode */
 	    if (screen->printer_controlmode == 2) {
 		if ((c = xtermPrinterControl(c)) == 0)
@@ -859,6 +933,31 @@
 #endif
 	      nextstate = parsestate[E2A(c)];
 
+#if OPT_WIDE_CHARS
+	    /* if this character is a different width than
+	       the last one, put the previous text into
+	       the buffer and draw it now */
+
+	    if (iswide(c) != last_was_wide) {
+		unsigned single = 0;
+
+		if (screen->curss) {
+		    dotext(screen,
+			    screen->gsets[(int)(screen->curss)],
+			    print_area, 1);
+		    screen->curss = 0;
+		    single++;
+		}
+		if (print_used > single) {
+		    dotext(screen,
+			    screen->gsets[(int)(screen->curgl)],
+			    print_area + single,
+			    print_used - single);
+		}
+		print_used = 0;
+	    }
+#endif
+
 	    /*
 	     * Accumulate string for printable text.  This may be 8/16-bit
 	     * characters.
@@ -884,6 +983,9 @@
 		print_area = new_string;
 		print_size = new_length;
 		print_area[print_used++] = lastchar = thischar = c;
+#if OPT_WIDE_CHARS
+		last_was_wide = iswide(c);
+#endif
 		if (morePtyData(&VTbuffer)) {
 		    continue;
 		}
@@ -2399,11 +2501,11 @@
 		    /* strip parity bit */
 		    for(i = VTbuffer.cnt, cp = VTbuffer.ptr ; i > 0 ; i--)
 			*cp++ &= 0177; /* originally CHAR */
-			if(screen->scrollWidget && screen->scrollttyoutput &&
-			    screen->topline < 0)
-			    /* Scroll to bottom */
-			 WindowScroll(screen, 0);
-			break;
+		    if(screen->scrollWidget && screen->scrollttyoutput &&
+			screen->topline < 0)
+			/* Scroll to bottom */
+		    WindowScroll(screen, 0);
+		    break;
 		}
 	    }
 	    else {
@@ -2598,16 +2700,22 @@
 	IChar	*buf,		/* start of characters to process */
 	Cardinal len)		/* end */
 {
-	int this_col;		/* must be signed */
-	Cardinal n, next_col, offset, last_col;
+#if OPT_WIDE_CHARS
+	Cardinal chars_chomped;
+#else
+	int next_col, last_col, this_col;	/* must be signed */
+#endif
+	Cardinal offset;
 
 #if OPT_WIDE_CHARS
 	if (!screen->utf8_mode || charset == '0') /* don't translate if we use UTF-8 */
 #endif
+
 	if (!xtermCharSetOut(buf, buf+len, charset))
 		return;
 
 	if_OPT_XMC_GLITCH(screen,{
+		Cardinal n;
 		if (charset != '?') {
 			for (n = 0; n < len; n++) {
 				if (buf[n] == XMC_GLITCH)
@@ -2616,27 +2724,42 @@
 		}
 	})
 
-	for (offset = 0; offset < len; offset += this_col) {
-		last_col = CurMaxCol(screen, screen->cur_row);
-		this_col = last_col - screen->cur_col +1;
-		if (this_col <= 1) {
-			if (screen->do_wrap && (term->flags & WRAPAROUND)) {
-			    /* mark that we had to wrap this line */
-			    ScrnSetWrapped(screen, screen->cur_row);
-			    xtermAutoPrint('\n');
-			    xtermIndex(screen, 1);
-			    screen->cur_col = 0;
-			    screen->do_wrap = 0;
-			    this_col = last_col + 1;
-			} else
-			    this_col = 1;
+
+#if OPT_WIDE_CHARS
+	for (offset = 0; offset < len; offset += chars_chomped) {
+		int width_available = screen->max_col - screen->cur_col + 1;
+		int width_here = 0, need_wrap = 0;
+		chars_chomped = 0;
+
+		if (screen->do_wrap && (term->flags & WRAPAROUND)) {
+			/* mark that we had to wrap this line */
+			ScrnSetWrapped(screen, screen->cur_row);
+			xtermAutoPrint('\n');
+			xtermIndex(screen, 1);
+			screen->cur_col = 0;
+			screen->do_wrap = 0;
+			width_available = screen->max_col - screen->cur_col + 1;
 		}
-		if (offset + this_col > len) {
-			this_col = len - offset;
+
+		while (width_here <= width_available && chars_chomped < (len - offset)) {
+			width_here += my_wcwidth(buf[chars_chomped + offset]);
+			chars_chomped ++;
 		}
-		next_col = screen->cur_col + this_col;
 
-#if OPT_WIDE_CHARS
+		if (width_here > width_available) {
+			chars_chomped --;
+			width_here -= my_wcwidth(buf[chars_chomped + offset]);
+			need_wrap = 1;
+		}
+
+		if (width_here == width_available) {
+			need_wrap = 1;
+		}
+
+		if (chars_chomped != (len - offset)) {
+			need_wrap = 1;
+		}
+
 		/*
 		 * Split the wide characters back into separate arrays of 8-bit
 		 * characters so we can use the existing interface.
@@ -2651,12 +2774,12 @@
 			Boolean both = False;
 			unsigned j, k;
 
-			if (this_col >= (int) limit) {
-				limit = (this_col + 1) * 2;
+			if (chars_chomped >= limit) {
+				limit = (chars_chomped + 1) * 2;
 				lobyte = (Char *)XtRealloc((char *)lobyte, limit);
 				hibyte = (Char *)XtRealloc((char *)hibyte, limit);
 			}
-			for (j = offset; j < offset+this_col; j++) {
+			for (j = offset; j < offset+chars_chomped; j++) {
 				k = j-offset;
 				lobyte[k] = buf[j];
 				if (buf[j] > 255) {
@@ -2669,13 +2792,35 @@
 
 			WriteText(screen, PAIRED_CHARS(
 				lobyte,
-				both ? hibyte : 0), this_col);
+				both ? hibyte : 0), chars_chomped);
 		}
+		screen->do_wrap = need_wrap;
+	}
 #else
+
+	for (offset = 0; offset < len; offset += this_col) {
+		last_col = CurMaxCol(screen, screen->cur_row);
+		this_col = last_col - screen->cur_col +1;
+		if (this_col <= 1) {
+			if (screen->do_wrap && (term->flags & WRAPAROUND)) {
+			    /* mark that we had to wrap this line */
+			    ScrnSetWrapped(screen, screen->cur_row);
+			    xtermAutoPrint('\n');
+			    xtermIndex(screen, 1);
+			    screen->cur_col = 0;
+			    screen->do_wrap = 0;
+			    this_col = last_col + 1;
+			} else
+			    this_col = 1;
+		}
+		if (offset + this_col > len) {
+			this_col = len - offset;
+		}
+		next_col = screen->cur_col + this_col;
+
 		WriteText(screen, PAIRED_CHARS(
 			buf+offset,
 			buf2 ? buf2+offset : 0), this_col);
-#endif
 
 		/*
 		 * the call to WriteText updates screen->cur_col.
@@ -2684,6 +2829,8 @@
 		 */
 		screen->do_wrap = (screen->cur_col < (int)next_col);
 	}
+
+#endif
 }
 
 #if HANDLE_STRUCT_NOTIFY
@@ -2699,6 +2846,24 @@
 static int mapstate = -1;
 #endif /* HANDLE_STRUCT_NOTIFY */
 
+#if OPT_WIDE_CHARS
+int visual_width(PAIRED_CHARS(Char *str, Char *str2), Cardinal len) {
+	/* returns the visual width of a string (doublewide characters count
+	   as 2, normalwide characters count as 1) */
+	int my_len = 0;
+	while (len) {
+		int ch = *str;
+		if (str2) ch |= *str2 << 8;
+		if (str) str++;
+		if (str2) str2++;
+		if (iswide(ch)) my_len += 2;
+		else my_len++;
+		len--;
+	}
+	return my_len;
+}
+#endif
+
 /*
  * write a string str of length len onto the screen at
  * the current cursor position.  update cursor position.
@@ -2720,8 +2885,9 @@
 		if(screen->cursor_state)
 			HideCursor();
 
-		if (flags & INSERT)
-			InsertChar(screen, len);
+		if (flags & INSERT) {
+			InsertChar(screen, visual_width(PAIRED_CHARS(str, str2), len));
+		}
 		if (!AddToRefresh(screen)) {
 			/* make sure that the correct GC is current */
 			currentGC = updatedXtermGC(screen, flags, fg_bg, False);
@@ -2745,7 +2911,7 @@
 				CurCursorX(screen, screen->cur_row, screen->cur_col),
 				CursorY(screen, screen->cur_row),
 				curXtermChrSet(screen->cur_row),
-				PAIRED_CHARS(str, str2), len);
+				PAIRED_CHARS(str, str2), len, 0);
 
 			resetXtermGC(screen, flags, False);
 
@@ -2762,7 +2928,7 @@
 		}
 	}
 	ScreenWrite(screen, PAIRED_CHARS(str, str2), flags, fg_bg, len);
-	CursorForward(screen, len);
+	CursorForward(screen, visual_width(PAIRED_CHARS(str, str2), len));
 #if OPT_ZICONBEEP
 	/* Flag icon name with "***"  on window output when iconified.
 	 */
@@ -2960,7 +3126,7 @@
 		case 8:			/* DECARM			*/
 			/* ignore autorepeat */
 			break;
-		case SET_X10_MOUSE:     /* MIT bogus sequence           */
+		case SET_X10_MOUSE:	/* MIT bogus sequence		*/
 			MotionOff( screen, termw );
 			set_mousemode(X10_MOUSE);
 			break;
@@ -3201,7 +3367,7 @@
 		case 47:		/* alternate buffer		*/
 			DoSM(DP_X_ALTSCRN, screen->alternate);
 			break;
-		case SET_VT200_MOUSE:   /* mouse bogus sequence         */
+		case SET_VT200_MOUSE:	/* mouse bogus sequence		*/
 		case SET_VT200_HIGHLIGHT_MOUSE:
 		case SET_BTN_EVENT_MOUSE:
 		case SET_ANY_EVENT_MOUSE:
@@ -3274,7 +3440,7 @@
 		case 8:			/* DECARM			*/
 			/* ignore autorepeat */
 			break;
-		case SET_X10_MOUSE:     /* MIT bogus sequence           */
+		case SET_X10_MOUSE:	/* MIT bogus sequence		*/
 			DoRM(DP_X_X10MSE, screen->send_mouse_pos);
 			break;
 		case 40:		/* 132 column mode		*/
@@ -3316,7 +3482,7 @@
 			    /* update_altscreen done by ToAlt and FromAlt */
 			}
 			break;
-		case SET_VT200_MOUSE:   /* mouse bogus sequence         */
+		case SET_VT200_MOUSE:	/* mouse bogus sequence		*/
 		case SET_VT200_HIGHLIGHT_MOUSE:
 		case SET_BTN_EVENT_MOUSE:
 		case SET_ANY_EVENT_MOUSE:
@@ -3614,6 +3780,22 @@
 #ifdef AMOEBA
 	if (ttypreprocess(c)) return;
 #endif
+#if OPT_TCAP_QUERY
+	/*
+	 * If we're returning a termcap string, it has to be translated since
+	 * a DCS must not contain any characters except for the normal 7-bit
+	 * printable ASCII (counting tab, carriage return, etc).  For now,
+	 * just use hexadecimal for the whole thing.
+	 */
+	if (screen->tc_query >= 0) {
+		char tmp[3];
+		sprintf(tmp, "%02X", c & 0xFF);
+		buf[0] = tmp[0];
+		buf[1] = tmp[1];
+		i = 2;
+	}
+	else
+#endif
 	if((buf[0] = c) == '\r' && (term->flags & LINEFEED)) {
 		buf[1] = '\n';
 		i++;
@@ -4067,7 +4249,7 @@
 
    wnew->screen.term_id = request->screen.term_id;
    for (s = request->screen.term_id; *s; s++) {
-	if (!isalpha(*s))
+	if (!isalpha(CharOf(*s)))
 	    break;
    }
    wnew->screen.terminal_id = atoi(s);
@@ -4103,6 +4285,9 @@
    wnew->misc.tekSmall = request->misc.tekSmall;
    wnew->screen.TekEmu = request->screen.TekEmu;
 #endif
+#if OPT_TCAP_QUERY
+   wnew->screen.tc_query = -1;
+#endif
    wnew->misc.re_verse0 =
    wnew->misc.re_verse = request->misc.re_verse;
    wnew->screen.multiClickTime = request->screen.multiClickTime;
@@ -4223,11 +4408,16 @@
       TRACE(("initialized UTF-8 mode\n"));
    }
    if (wnew->screen.wide_chars != False)
-      wnew->num_ptrs = (OFF_WIDEC+1);
+      wnew->num_ptrs = (OFF_COM2H+1);
 #endif
 
    wnew->screen.bold_mode = request->screen.bold_mode;
    wnew->screen.underline = request->screen.underline;
+#ifdef XRENDERFONT
+   wnew->screen.renderFont = 0;
+   wnew->screen.renderFontBold = 0;
+   wnew->screen.renderDraw = 0;
+#endif
 
    wnew->cur_foreground = 0;
    wnew->cur_background = 0;
@@ -4334,13 +4524,25 @@
 	TabReset (term->tabs);
 
 	screen->menu_font_names[fontMenu_fontdefault] = term->misc.f_n;
-	screen->fnt_norm = screen->fnt_bold = NULL;
-	if (!xtermLoadFont(screen, term->misc.f_n, term->misc.f_b, False, 0)) {
+	screen->fnt_norm = NULL;
+	screen->fnt_bold = NULL;
+#if OPT_WIDE_CHARS
+	screen->fnt_dwd = NULL;
+	screen->fnt_dwdb = NULL;
+#endif
+	if (!xtermLoadFont(screen,
+			   VT_FONTSET(term->misc.f_n,
+				      term->misc.f_b,
+				      term->misc.f_w,
+				      term->misc.f_wb),
+			   False, 0)) {
 	    if (XmuCompareISOLatin1(term->misc.f_n, "fixed") != 0) {
 		fprintf (stderr,
 		     "%s:  unable to open font \"%s\", trying \"fixed\"....\n",
 		     xterm_name, term->misc.f_n);
-		(void) xtermLoadFont (screen, "fixed", NULL, False, 0);
+		(void) xtermLoadFont (screen,
+				      VT_FONTSET("fixed", NULL, NULL, NULL),
+				      False, 0);
 		screen->menu_font_names[fontMenu_fontdefault] = "fixed";
 	    }
 	}
@@ -4582,11 +4784,11 @@
 	    SysError(ERROR_VINIT);
 
 	for(ns = s; ns && *s;) {
-	    while (*s && isspace(*s)) s++;
+	    while (*s && isspace(CharOf(*s))) s++;
 	    if (!*s) break;
 	    if ((ns = end = strchr(s, ',')) == 0)
 		end = s + strlen(s);
-	    while ((end != s) && isspace(end[-1])) end--;
+	    while ((end != s) && isspace(CharOf(end[-1]))) end--;
 
 	    if (end != s) {
 		strcpy(t, "@im=");
@@ -4619,13 +4821,13 @@
 
     found = False;
     for(s = term->misc.preedit_type; s && !found;) {
-	while (*s && isspace(*s)) s++;
+	while (*s && isspace(CharOf(*s))) s++;
 	if (!*s) break;
 	if ((ns = end = strchr(s, ',')) != 0)
 	    ns++;
 	else
 	    end = s + strlen(s);
-	while ((end != s) && isspace(end[-1])) end--;
+	while ((end != s) && isspace(CharOf(end[-1]))) end--;
 
 	if (end != s) {	/* just in case we have a spurious comma */
 	    if (!strncmp(s, "OverTheSpot", end - s)) {
@@ -4701,8 +4903,10 @@
 	if(curvt->misc.f_n != newvt->misc.f_n)
 	    newvt->screen.menu_font_names[fontMenu_fontdefault] = newvt->misc.f_n;
 	if (xtermLoadFont(&newvt->screen,
-			newvt->screen.menu_font_names[curvt->screen.menu_font_number],
-			newvt->screen.menu_font_names[curvt->screen.menu_font_number],
+			VT_FONTSET(newvt->screen.menu_font_names[curvt->screen.menu_font_number],
+				   newvt->screen.menu_font_names[curvt->screen.menu_font_number],
+				   NULL,
+				   NULL),
 			TRUE, newvt->screen.menu_font_number)) {
 	    /* resizing does the redisplay, so don't ask for it here */
 	    refresh_needed = TRUE;
@@ -4757,6 +4961,11 @@
 #endif
 #if OPT_WIDE_CHARS
 	Char	chi = 0;
+	Char    c1h = 0;
+	Char    c1l = 0;
+	Char    c2h = 0;
+	Char    c2l = 0;
+	int	base;
 #endif
 
 	if (screen->cursor_state == BLINKED_OFF)
@@ -4777,11 +4986,22 @@
 	}
 #endif /* NO_ACTIVE_ICON */
 
+#if OPT_WIDE_CHARS
+	base  =
+#endif
 	clo   = SCRN_BUF_CHARS(screen, screen->cursor_row)[screen->cursor_col];
 	flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[screen->cursor_col];
 
 	if_OPT_WIDE_CHARS(screen,{
+	    int my_col = screen->cursor_col;
 	    chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[screen->cursor_col];
+	    base = (chi << 8) | clo;
+	    if (iswide(base))
+		my_col += 1;
+	    c1l = SCRN_BUF_COM1L(screen, screen->cursor_row)[my_col];
+	    c1h = SCRN_BUF_COM1H(screen, screen->cursor_row)[my_col];
+	    c2l = SCRN_BUF_COM2L(screen, screen->cursor_row)[my_col];
+	    c2h = SCRN_BUF_COM2H(screen, screen->cursor_row)[my_col];
 	})
 
 	if (clo == 0
@@ -4886,8 +5106,23 @@
 		x = CurCursorX(screen, screen->cur_row, screen->cur_col),
 		y = CursorY(screen, screen->cur_row),
 		curXtermChrSet(screen->cur_row),
-		PAIRED_CHARS(&clo, &chi), 1);
+		PAIRED_CHARS(&clo, &chi), 1, 0);
+
+#if OPT_WIDE_CHARS
+	if (c1l || c1h) {
+		drawXtermText(screen, flags, currentGC,
+			      x, y,
+			      curXtermChrSet(screen->cur_row),
+			      PAIRED_CHARS(&c1l, &c1h), 1, iswide(base));
 
+		if (c2l || c2h)
+			drawXtermText(screen, flags, currentGC,
+				      x, y,
+				      curXtermChrSet(screen->cur_row),
+				      PAIRED_CHARS(&c2l, &c2h), 1, iswide(base));
+	}
+#endif
+
 	if (!screen->select && !screen->always_highlight) {
 		screen->box->x = x;
 		screen->box->y = y;
@@ -4909,10 +5144,16 @@
 	GC	currentGC;
 	register int flags;
 	register int fg_bg = 0;
+	int x, y;
 	Char	clo;
 	Boolean	in_selection;
 #if OPT_WIDE_CHARS
 	Char	chi = 0;
+	Char    c1h = 0;
+	Char    c1l = 0;
+	Char    c2h = 0;
+	Char    c2l = 0;
+	int	base;
 #endif
 
 	if (screen->cursor_state == OFF)	/* FIXME */
@@ -4927,6 +5168,9 @@
 	}
 #endif /* NO_ACTIVE_ICON */
 
+#if OPT_WIDE_CHARS
+	base  =
+#endif
 	clo   = SCRN_BUF_CHARS(screen, screen->cursor_row)[screen->cursor_col];
 	flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[screen->cursor_col];
 
@@ -4939,7 +5183,15 @@
 	})
 
 	if_OPT_WIDE_CHARS(screen,{
+	    int my_col = screen->cursor_col;
 	    chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[screen->cursor_col];
+	    base = (chi << 8) | clo;
+	    if (iswide(base))
+		my_col += 1;
+	    c1l = SCRN_BUF_COM1L(screen, screen->cursor_row)[my_col];
+	    c1h = SCRN_BUF_COM1H(screen, screen->cursor_row)[my_col];
+	    c2l = SCRN_BUF_COM2L(screen, screen->cursor_row)[my_col];
+	    c2h = SCRN_BUF_COM2H(screen, screen->cursor_row)[my_col];
 	})
 
 	if (screen->cursor_row > screen->endHRow ||
@@ -4965,11 +5217,25 @@
 	TRACE(("%s @%d, HideCursor calling drawXtermText cur(%d,%d)\n", __FILE__, __LINE__,
 		screen->cursor_row, screen->cursor_col));
 	drawXtermText(screen, flags, currentGC,
-		CurCursorX(screen, screen->cursor_row, screen->cursor_col),
-		CursorY(screen, screen->cursor_row),
+		x = CurCursorX(screen, screen->cursor_row, screen->cursor_col),
+		y = CursorY(screen, screen->cursor_row),
 		curXtermChrSet(screen->cursor_row),
-		PAIRED_CHARS(&clo, &chi), 1);
+		PAIRED_CHARS(&clo, &chi), 1, 0);
 
+#if OPT_WIDE_CHARS
+	if (c1l || c1h) {
+		drawXtermText (screen, flags, currentGC,
+				x, y,
+				curXtermChrSet(screen->cur_row),
+				PAIRED_CHARS(&c1l, &c1h), 1, iswide(base));
+
+		if (c2l || c2h)
+			drawXtermText (screen, flags, currentGC,
+					x, y,
+					curXtermChrSet(screen->cur_row),
+					PAIRED_CHARS(&c2l, &c2h), 1, iswide(base));
+	}
+#endif
 	screen->cursor_state = OFF;
 	resetXtermGC(screen, flags, in_selection);
 }
@@ -5134,7 +5400,7 @@
 /*
  * set_character_class - takes a string of the form
  *
- *                 low[-high]:val[,low[-high]:val[...]]
+ *   low[-high]:val[,low[-high]:val[...]]
  *
  * and sets the indicated ranges to the indicated values.
  */
@@ -5157,7 +5423,7 @@
 
     for (i = 0, len = strlen (s), acc = 0, numbers = digits = 0;
 	 i < len; i++) {
-	char c = s[i];
+	Char c = s[i];
 
 	if (isspace(c)) {
 	    continue;
@@ -5270,7 +5536,7 @@
 
     (void) sprintf( pmapName, "%sKeymap", params[0] );
     (void) strcpy( pmapClass, pmapName );
-    if (islower(pmapClass[0])) pmapClass[0] = toupper(pmapClass[0]);
+    if (islower(CharOf(pmapClass[0]))) pmapClass[0] = toupper(pmapClass[0]);
     XtGetSubresources( w, (XtPointer)&keymap, pmapName, pmapClass,
 		       key_resources, (Cardinal)1, NULL, (Cardinal)0 );
     if (keymap != NULL)
@@ -5343,7 +5609,7 @@
 	   we are a little more liberal here. */
 	if (len > 1000  ||  strchr(val, '\n'))
 	    return;
-	if (!xtermLoadFont (&term->screen, val, NULL, True, fontMenu_fontsel))
+	if (!xtermLoadFont (&term->screen, VT_FONTSET(val, NULL, NULL, NULL), True, fontMenu_fontsel))
 	    Bell(XkbBI_MinorError,0);
     }
 }
Index: xc/programs/xterm/config.guess
diff -u xc/programs/xterm/config.guess:1.8 xc/programs/xterm/config.guess:1.11
--- xc/programs/xterm/config.guess:1.8	Tue Jun 13 20:16:18 2000
+++ xc/programs/xterm/config.guess	Fri Oct 27 14:31:11 2000
@@ -1,7 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
-#
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+#   Free Software Foundation, Inc.
+
+version='2000-10-23'
+
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
@@ -22,7 +25,7 @@
 # the same distribution terms that you use for the rest of that program.
 
 # Written by Per Bothner <bothner@cygnus.com>.
-# The master version of this file is at the FSF in /home/gd/gnu/lib.
+# Please send patches to <config-patches@gnu.org>.
 #
 # This script attempts to guess a canonical system name similar to
 # config.sub.  If it succeeds, it prints the system name on stdout, and
@@ -35,6 +38,60 @@
 # (but try to keep the structure clean).
 #
 
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of this system.
+
+Operation modes:
+  -h, --help               print this help, then exit
+  -V, --version            print version number, then exit"
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case "$1" in
+    --version | --vers* | -V )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       exec >&2
+       echo "$me: invalid option $1"
+       echo "$help"
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+# Use $HOST_CC if defined. $CC may point to a cross-compiler
+if test x"$CC_FOR_BUILD" = x; then
+  if test x"$HOST_CC" != x; then
+    CC_FOR_BUILD="$HOST_CC"
+  else
+    if test x"$CC" != x; then
+      CC_FOR_BUILD="$CC"
+    else
+      CC_FOR_BUILD=cc
+    fi
+  fi
+fi
+
+
 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
 # (ghazi@noc.rutgers.edu 8/24/94.)
 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
@@ -46,11 +103,52 @@
 UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
-trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
 
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    i?86:OS/2:*:*)
+        echo "i386-unknown-os2"
+	exit 0;;
+    *:NetBSD:*:*)
+	# Netbsd (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	# Determine the machine/vendor (is the vendor relevant).
+	case "${UNAME_MACHINE}" in
+	    amiga) machine=m68k-unknown ;;
+	    arm32) machine=arm-unknown ;;
+	    atari*) machine=m68k-atari ;;
+	    sun3*) machine=m68k-sun ;;
+	    mac68k) machine=m68k-apple ;;
+	    macppc) machine=powerpc-apple ;;
+	    hp3[0-9][05]) machine=m68k-hp ;;
+	    ibmrt|romp-ibm) machine=romp-ibm ;;
+	    *) machine=${UNAME_MACHINE}-unknown ;;
+	esac
+	# The Operating System including object format.
+	if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+		| grep __ELF__ >/dev/null
+	then
+	    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+	    # Return netbsd for either.  FIX?
+	    os=netbsd
+	else
+	    os=netbsdelf
+	fi
+	# The OS release
+	release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit 0 ;;
     alpha:OSF1:*:*)
 	if test $UNAME_RELEASE = "V4.0"; then
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -59,56 +157,69 @@
 	# A Tn.n version is a released field test version.
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
-	cat <<EOF >dummy.s
+	cat <<EOF >$dummy.s
+	.data
+\$Lformat:
+	.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+	.text
 	.globl main
+	.align 4
 	.ent main
 main:
-	.frame \$30,0,\$26,0
-	.prologue 0
-	.long 0x47e03d80 # implver $0
-	lda \$2,259
-	.long 0x47e20c21 # amask $2,$1
-	srl \$1,8,\$2
-	sll \$2,2,\$2
-	sll \$0,3,\$0
-	addl \$1,\$0,\$0
-	addl \$2,\$0,\$0
-	ret \$31,(\$26),1
+	.frame \$30,16,\$26,0
+	ldgp \$29,0(\$27)
+	.prologue 1
+	.long 0x47e03d80 # implver \$0
+	lda \$2,-1
+	.long 0x47e20c21 # amask \$2,\$1
+	lda \$16,\$Lformat
+	mov \$0,\$17
+	not \$1,\$18
+	jsr \$26,printf
+	ldgp \$29,0(\$26)
+	mov 0,\$16
+	jsr \$26,exit
 	.end main
 EOF
-	${CC-cc} dummy.s -o dummy 2>/dev/null
+	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
 	if test "$?" = 0 ; then
-		./dummy
-		case "$?" in
-			7)
+		case `./$dummy` in
+			0-0)
 				UNAME_MACHINE="alpha"
 				;;
-			15)
+			1-0)
 				UNAME_MACHINE="alphaev5"
 				;;
-			14)
+			1-1)
 				UNAME_MACHINE="alphaev56"
 				;;
-			10)
+			1-101)
 				UNAME_MACHINE="alphapca56"
 				;;
-			16)
+			2-303)
 				UNAME_MACHINE="alphaev6"
 				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
 		esac
 	fi
-	rm -f dummy.s dummy
-	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
+	rm -f $dummy.s $dummy
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit 0 ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
 	exit 0 ;;
     21064:Windows_NT:50:3)
 	echo alpha-dec-winnt3.5
 	exit 0 ;;
     Amiga*:UNIX_System_V:4.0:*)
-	echo m68k-cbm-sysv4
+	echo m68k-unknown-sysv4
 	exit 0;;
-    amiga:NetBSD:*:*)
-      echo m68k-cbm-netbsd${UNAME_RELEASE}
-      exit 0 ;;
     amiga:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
@@ -133,16 +244,16 @@
     wgrisc:OpenBSD:*:*)
 	echo mipsel-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit 0 ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
 	exit 0;;
-    arm32:NetBSD:*:*)
-	echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-	exit 0 ;;
     SR2?01:HI-UX/MPP:*:*)
 	echo hppa1.1-hitachi-hiuxmpp
 	exit 0;;
-    Pyramid*:OSx*:*:*|MIS*:OSx*:*:*|MIS*:SMP_DC-OSx*:*:*)
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
 	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
 	if test "`(/bin/universe) 2>/dev/null`" = att ; then
 		echo pyramid-pyramid-sysv3
@@ -150,10 +261,7 @@
 		echo pyramid-pyramid-bsd
 	fi
 	exit 0 ;;
-    "Power Macintosh":Rhapsody:*:*)
-	echo powerpc-apple-rhapsody`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit 0 ;;
-    NILE:*:*:dcosx)
+    NILE*:*:*:dcosx)
 	echo pyramid-pyramid-svr4
 	exit 0 ;;
     sun4H:SunOS:5.*:*)
@@ -198,21 +306,38 @@
     aushp:SunOS:*:*)
 	echo sparc-auspex-sunos${UNAME_RELEASE}
 	exit 0 ;;
-    atari*:NetBSD:*:*)
-	echo m68k-atari-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     atari*:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    sun3*:NetBSD:*:*)
-	echo m68k-sun-netbsd${UNAME_RELEASE}
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
 	exit 0 ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit 0 ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit 0 ;;
     sun3*:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    mac68k:NetBSD:*:*)
-	echo m68k-apple-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     mac68k:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
@@ -225,9 +350,6 @@
     powerpc:machten:*:*)
 	echo powerpc-apple-machten${UNAME_RELEASE}
 	exit 0 ;;
-    macppc:NetBSD:*:*)
-        echo powerpc-apple-netbsd${UNAME_RELEASE}
-        exit 0 ;;
     RISC*:Mach:*:*)
 	echo mips-dec-mach_bsd4.3
 	exit 0 ;;
@@ -241,8 +363,13 @@
 	echo clipper-intergraph-clix${UNAME_RELEASE}
 	exit 0 ;;
     mips:*:*:UMIPS | mips:*:*:RISCos)
-	sed 's/^	//' << EOF >dummy.c
-	int main (argc, argv) int argc; char **argv; {
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
 	#if defined (host_mips) && defined (MIPSEB)
 	#if defined (SYSTYPE_SYSV)
 	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
@@ -257,10 +384,10 @@
 	  exit (-1);
 	}
 EOF
-	${CC-cc} dummy.c -o dummy \
-	  && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
-	  && rm dummy.c dummy && exit 0
-	rm -f dummy.c dummy
+	$CC_FOR_BUILD $dummy.c -o $dummy \
+	  && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+	  && rm $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
 	echo mips-mips-riscos${UNAME_RELEASE}
 	exit 0 ;;
     Night_Hawk:Power_UNIX:*:*)
@@ -278,15 +405,18 @@
     AViiON:dgux:*:*)
         # DG/UX returns AViiON for all architectures
         UNAME_PROCESSOR=`/usr/bin/uname -p`
-        if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
-	if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
-	     -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
 		echo m88k-dg-dgux${UNAME_RELEASE}
-	else
+	    else
 		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
 	fi
-        else echo i586-dg-dgux${UNAME_RELEASE}
-        fi
  	exit 0 ;;
     M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
 	echo m88k-dolphin-sysv3
@@ -310,13 +440,9 @@
     i?86:AIX:*:*)
 	echo i386-ibm-aix
 	exit 0 ;;
-    *:MVS:*:* | *:OS390:*:*|*:OS/390:*:*)
-			       # uname -m gives a processor model number  /* S/390 -- gil -- 1389 */
-	echo s390-ibm-os390    # on R1 and R2, uname -s reports OS390
-	exit 0 ;;              # on R3, uname -s reports OS/390
     *:AIX:2:3)
 	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
-		sed 's/^		//' << EOF >dummy.c
+		sed 's/^		//' << EOF >$dummy.c
 		#include <sys/systemcfg.h>
 
 		main()
@@ -327,8 +453,8 @@
 			exit(0);
 			}
 EOF
-		${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
-		rm -f dummy.c dummy
+		$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+		rm -f $dummy.c $dummy
 		echo rs6000-ibm-aix3.2.5
 	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
 		echo rs6000-ibm-aix3.2.4
@@ -356,7 +482,7 @@
     ibmrt:4.4BSD:*|romp-ibm:BSD:*)
 	echo romp-ibm-bsd4.4
 	exit 0 ;;
-    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC NetBSD and
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
 	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
 	exit 0 ;;                           # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
@@ -375,8 +501,10 @@
 	case "${UNAME_MACHINE}" in
 	    9000/31? )            HP_ARCH=m68000 ;;
 	    9000/[34]?? )         HP_ARCH=m68k ;;
-	    9000/6?? | 9000/7?? | 9000/80[024] | 9000/8?[13679] | 9000/892 )
-              sed 's/^              //' << EOF >dummy.c
+	    9000/[678][0-9][0-9])
+              sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
               #include <stdlib.h>
               #include <unistd.h>
 
@@ -407,14 +535,14 @@
                   exit (0);
               }
 EOF
-	(${CC-cc} dummy.c -o dummy 2>/dev/null ) && HP_ARCH=`./dummy`
-	rm -f dummy.c dummy
+	(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+	rm -f $dummy.c $dummy
 	esac
 	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
 	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
 	exit 0 ;;
     3050*:HI-UX:*:*)
-	sed 's/^	//' << EOF >dummy.c
+	sed 's/^	//' << EOF >$dummy.c
 	#include <unistd.h>
 	int
 	main ()
@@ -439,8 +567,8 @@
 	  exit (0);
 	}
 EOF
-	${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
-	rm -f dummy.c dummy
+	$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
 	echo unknown-hitachi-hiuxwe2
 	exit 0 ;;
     9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
@@ -449,6 +577,9 @@
     9000/8??:4.3bsd:*:*)
 	echo hppa1.0-hp-bsd
 	exit 0 ;;
+    *9??*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit 0 ;;
     hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
 	echo hppa1.1-hp-osf
 	exit 0 ;;
@@ -465,6 +596,9 @@
     parisc*:Lites*:*:*)
 	echo hppa1.1-hp-lites
 	exit 0 ;;
+    hppa*:OpenBSD:*:*)
+	echo hppa-unknown-openbsd
+	exit 0 ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
 	echo c1-convex-bsd
         exit 0 ;;
@@ -495,37 +629,40 @@
 	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
 	exit 0 ;;
     CRAY*TS:*:*:*)
-	echo t90-cray-unicos${UNAME_RELEASE}
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*T3E:*:*:*)
+	echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
     CRAY-2:*:*:*)
 	echo cray2-cray-unicos
         exit 0 ;;
     F300:UNIX_System_V:*:*)
-        FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
         FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
         echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
         exit 0 ;;
     F301:UNIX_System_V:*:*)
        echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
        exit 0 ;;
-    hp3[0-9][05]:NetBSD:*:*)
-	echo m68k-hp-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     hp300:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
+    i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit 0 ;;
     sparc*:BSD/OS:*:*)
 	echo sparc-unknown-bsdi${UNAME_RELEASE}
 	exit 0 ;;
-    i?86:BSD/386:*:* | *:BSD/OS:*:*)
-	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     *:FreeBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit 0 ;;
-    *:NetBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-	exit 0 ;;
     *:OpenBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
 	exit 0 ;;
@@ -535,6 +672,18 @@
     i*:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit 0 ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit 0 ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i386-pc-interix
+	exit 0 ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit 0 ;;
     p*:CYGWIN*:*)
 	echo powerpcle-unknown-cygwin
 	exit 0 ;;
@@ -544,86 +693,160 @@
     *:GNU:*:*)
 	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
 	exit 0 ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit 0 ;;
     *:Linux:*:*)
-	# uname on the ARM produces all sorts of strangeness, and we need to
-	# filter it out.
-	case "$UNAME_MACHINE" in
-	  arm* | sa110*)	      UNAME_MACHINE="arm" ;;
-	esac
 
 	# The BFD linker knows what the default object file format is, so
-	# first see if it will tell us.
-	ld_help_string=`ld --help 2>&1`
-	ld_supported_emulations=`echo $ld_help_string \
+	# first see if it will tell us. cd to the root directory to prevent
+	# problems with other programs or directories called `ld' in the path.
+	ld_supported_emulations=`cd /; ld --help 2>&1 \
 			 | sed -ne '/supported emulations:/!d
 				    s/[ 	][ 	]*/ /g
 				    s/.*supported emulations: *//
 				    s/ .*//
 				    p'`
         case "$ld_supported_emulations" in
-	  i?86linux)  echo "${UNAME_MACHINE}-pc-linux-gnuaout"      ; exit 0 ;;
-	  i?86coff)   echo "${UNAME_MACHINE}-pc-linux-gnucoff"      ; exit 0 ;;
-	  sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
-	  armlinux)   echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
-	  m68klinux)  echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
-	  elf32ppc*)  echo "powerpc-unknown-linux-gnu"              ; exit 0 ;;
-	  elf64_ia64) echo "${UNAME_MACHINE}-unknown-linux-gnu"     ; exit 0 ;;
+	  *ia64)
+		echo "${UNAME_MACHINE}-unknown-linux"
+		exit 0
+		;;
+	  i?86linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit 0
+		;;
+	  elf_i?86)
+		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+		;;
+	  i?86coff)
+		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+		exit 0
+		;;
+	  sparclinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  armlinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  elf32arm*)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
+		exit 0
+		;;
+	  armelf_linux*)
+		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		exit 0
+		;;
+	  m68klinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  elf32ppc | elf32ppclinux)
+		# Determine Lib Version
+		cat >$dummy.c <<EOF
+#include <features.h>
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+     int argc;
+     char *argv[];
+{
+#if defined(__GLIBC__)
+  printf("%s %s\n", __libc_version, __libc_release);
+#else
+  printf("unkown\n");
+#endif
+  return 0;
+}
+EOF
+		LIBC=""
+		$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+		if test "$?" = 0 ; then
+			./$dummy | grep 1\.99 > /dev/null
+			if test "$?" = 0 ; then
+				LIBC="libc1"
+			fi
+		fi
+		rm -f $dummy.c $dummy
+		echo powerpc-unknown-linux-gnu${LIBC}
+		exit 0
+		;;
+	  shelf_linux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		exit 0
+		;;
 	esac
 
 	if test "${UNAME_MACHINE}" = "alpha" ; then
-		sed 's/^	//'  <<EOF >dummy.s
-		.globl main
-		.ent main
-	main:
-		.frame \$30,0,\$26,0
-		.prologue 0
-		.long 0x47e03d80 # implver $0
-		lda \$2,259
-		.long 0x47e20c21 # amask $2,$1
-		srl \$1,8,\$2
-		sll \$2,2,\$2
-		sll \$0,3,\$0
-		addl \$1,\$0,\$0
-		addl \$2,\$0,\$0
-		ret \$31,(\$26),1
-		.end main
+		cat <<EOF >$dummy.s
+			.data
+		\$Lformat:
+			.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+			.text
+			.globl main
+			.align 4
+			.ent main
+		main:
+			.frame \$30,16,\$26,0
+			ldgp \$29,0(\$27)
+			.prologue 1
+			.long 0x47e03d80 # implver \$0
+			lda \$2,-1
+			.long 0x47e20c21 # amask \$2,\$1
+			lda \$16,\$Lformat
+			mov \$0,\$17
+			not \$1,\$18
+			jsr \$26,printf
+			ldgp \$29,0(\$26)
+			mov 0,\$16
+			jsr \$26,exit
+			.end main
 EOF
 		LIBC=""
-		${CC-cc} dummy.s -o dummy 2>/dev/null
+		$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
 		if test "$?" = 0 ; then
-			./dummy
-			case "$?" in
-			7)
+			case `./$dummy` in
+			0-0)
 				UNAME_MACHINE="alpha"
 				;;
-			15)
+			1-0)
 				UNAME_MACHINE="alphaev5"
 				;;
-			14)
+			1-1)
 				UNAME_MACHINE="alphaev56"
 				;;
-			10)
+			1-101)
 				UNAME_MACHINE="alphapca56"
 				;;
-			16)
+			2-303)
 				UNAME_MACHINE="alphaev6"
 				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
 			esac
 
-			objdump --private-headers dummy | \
+			objdump --private-headers $dummy | \
 			  grep ld.so.1 > /dev/null
 			if test "$?" = 0 ; then
 				LIBC="libc1"
 			fi
 		fi
-		rm -f dummy.s dummy
+		rm -f $dummy.s $dummy
 		echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
 	elif test "${UNAME_MACHINE}" = "mips" ; then
-	  cat >dummy.c <<EOF
-main(argc, argv)
-     int argc;
-     char *argv[];
-{
+	  cat >$dummy.c <<EOF
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
 #ifdef __MIPSEB__
   printf ("%s-unknown-linux-gnu\n", argv[1]);
 #endif
@@ -633,16 +856,34 @@
   return 0;
 }
 EOF
-	  ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
-	  rm -f dummy.c dummy
+	  $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+	  rm -f $dummy.c $dummy
+	elif test "${UNAME_MACHINE}" = "s390"; then
+	  echo s390-ibm-linux && exit 0
+	elif test "${UNAME_MACHINE}" = "x86_64"; then
+	  echo x86_64-unknown-linux-gnu && exit 0
+	elif test "${UNAME_MACHINE}" = "parisc" -o "${UNAME_MACHINE}" = "hppa"; then
+	  # Look for CPU level
+	  case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+	    PA7*)
+		echo hppa1.1-unknown-linux-gnu
+		;;
+	    PA8*)
+		echo hppa2.0-unknown-linux-gnu
+		;;
+	    *)
+		echo hppa-unknown-linux-gnu
+		;;
+	  esac
+	  exit 0
 	else
 	  # Either a pre-BFD a.out linker (linux-gnuoldld)
 	  # or one that does not give us useful --help.
 	  # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
 	  # If ld does not provide *any* "supported emulations:"
 	  # that means it is gnuoldld.
-	  echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
-	  test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+	  test -z "$ld_supported_emulations" \
+	    && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
 
 	  case "${UNAME_MACHINE}" in
 	  i?86)
@@ -653,15 +894,17 @@
 	    ;;
 	  esac
 	  # Determine whether the default compiler is a.out or elf
-	  cat >dummy.c <<EOF
+	  cat >$dummy.c <<EOF
 #include <features.h>
-main(argc, argv)
-     int argc;
-     char *argv[];
-{
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
 #ifdef __ELF__
 # ifdef __GLIBC__
-#  if (__GLIBC__ >= 2)
+#  if __GLIBC__ >= 2
     printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
 #  else
     printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
@@ -675,8 +918,9 @@
   return 0;
 }
 EOF
-	  ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
-	  rm -f dummy.c dummy
+	  $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+	  rm -f $dummy.c $dummy
+	  test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
 	fi ;;
 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
 # are messed up and put the nodename in both sysname and nodename.
@@ -691,25 +935,21 @@
         # Use sysv4.2uw... so that sysv4* matches it.
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
 	exit 0 ;;
-    # SysVr5/Unixware7
-    i?86:*:5*:* | i?86:SYSTEM_V:5*:*)
-	 if uname -a | grep SCO >/dev/null 2>/dev/null ; then
-	    (/bin/uname -s|egrep UnixWare >/dev/null) && UNAME_VER=uw${UNAME_VERSION}
-	    if /bin/uname -X 2>/dev/null >/dev/null ; then
-		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
-		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
-			&& UNAME_MACHINE=i586
-	    fi
-		echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}${UNAME_VER}
+    i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
 	else
-		echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
 	fi
 	exit 0 ;;
-    i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
-	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-		echo ${UNAME_MACHINE}-univel-sysv4.2uw${UNAME_VERSION}
+    i?86:*:5:7*)
+        # Fixed at (any) Pentium or better
+        UNAME_MACHINE=i586
+        if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
+	    echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
 	else
-		echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+	    echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
 	fi
 	exit 0 ;;
     i?86:*:3.2:*)
@@ -721,19 +961,20 @@
 		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
 		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
 			&& UNAME_MACHINE=i586
+		(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
 		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
 	else
 		echo ${UNAME_MACHINE}-pc-sysv32
 	fi
 	exit 0 ;;
-    i?86:UnixWare:*:*)
-	if /bin/uname -X 2>/dev/null >/dev/null ; then
-	  (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
-	    && UNAME_MACHINE=i586
-	fi
-	echo ${UNAME_MACHINE}-unixware-${UNAME_RELEASE}-${UNAME_VERSION}
+    i?86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
 	exit 0 ;;
     pc:*:*:*)
+	# Left here for compatibility:
         # uname -m prints for DJGPP always 'pc', but it prints nothing about
         # the processor, so we play safe by assuming i386.
 	echo i386-pc-msdosdjgpp
@@ -757,7 +998,7 @@
 	exit 0 ;;
     M68*:*:R3V[567]*:*)
 	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
-    3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
 	OS_REL=''
 	test -r /etc/.relid \
 	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -774,7 +1015,7 @@
     mc68030:UNIX_System_V:4.*:*)
 	echo m68k-atari-sysv4
 	exit 0 ;;
-    i?86:LynxOS:2.*:*)
+    i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
 	echo i386-unknown-lynxos${UNAME_RELEASE}
 	exit 0 ;;
     TSUNAMI:LynxOS:2.*:*)
@@ -786,6 +1027,9 @@
     SM[BE]S:UNIX_SV:*:*)
 	echo mips-dde-sysv${UNAME_RELEASE}
 	exit 0 ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
     RM*:SINIX-*:*:*)
 	echo mips-sni-sysv4
 	exit 0 ;;
@@ -813,16 +1057,16 @@
     mc68*:A/UX:*:*)
 	echo m68k-apple-aux${UNAME_RELEASE}
 	exit 0 ;;
-    news*:NEWS-OS:*:6*)
+    news*:NEWS-OS:6*:*)
 	echo mips-sony-newsos6
 	exit 0 ;;
-    R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R4000:UNIX_SV:*:*)
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
 	if [ -d /usr/nec ]; then
-		echo mips-nec-sysv${UNAME_RELEASE}
+	        echo mips-nec-sysv${UNAME_RELEASE}
 	else
-		echo mips-unknown-sysv${UNAME_RELEASE}
+	        echo mips-unknown-sysv${UNAME_RELEASE}
 	fi
-	exit 0 ;;
+        exit 0 ;;
     BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
 	echo powerpc-be-beos
 	exit 0 ;;
@@ -831,19 +1075,60 @@
 	exit 0 ;;
     BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
 	echo i586-pc-beos
+	exit 0 ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
 	exit 0 ;;
-    Power*Macintosh:Rhapsody:*:*)
+    Power*:Rhapsody:*:*)
 	echo powerpc-apple-rhapsody${UNAME_RELEASE}
 	exit 0 ;;
     *:Rhapsody:*:*)
 	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
 	exit 0 ;;
+    *:Darwin:*:*)
+	echo `uname -p`-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	if test "${UNAME_MACHINE}" = "x86pc"; then
+		UNAME_MACHINE=pc
+	fi
+	echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+	exit 0 ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit 0 ;;
+    NSR-[KW]:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit 0 ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit 0 ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-unknown-plan9
+	exit 0 ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
 
-cat >dummy.c <<EOF
+cat >$dummy.c <<EOF
 #ifdef _SEQUENT_
 # include <sys/types.h>
 # include <sys/utsname.h>
@@ -881,7 +1166,10 @@
 #endif
   int version;
   version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
   exit (0);
 #endif
 
@@ -941,8 +1229,8 @@
 }
 EOF
 
-${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
-rm -f dummy.c dummy
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
 
 # Apollos put the system type in the environment.
 
@@ -973,7 +1261,48 @@
 	exit 0 ;;
     esac
 fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
 
-#echo '(Unable to guess system type)' 1>&2
+The $version version of this script cannot recognize your system type.
+Please download the most up to date version of the config scripts:
 
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess version = $version
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
 exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "version='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
Index: xc/programs/xterm/config.sub
diff -u xc/programs/xterm/config.sub:1.8 xc/programs/xterm/config.sub:1.11
--- xc/programs/xterm/config.sub:1.8	Tue Jun 13 20:16:18 2000
+++ xc/programs/xterm/config.sub	Fri Oct 27 14:31:11 2000
@@ -1,6 +1,10 @@
 #! /bin/sh
 # Configuration validation subroutine script, version 1.1.
-#   Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+#   Free Software Foundation, Inc.
+
+version='2000-10-25'
+
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
 # can handle that machine.  It does not imply ALL GNU software can.
@@ -25,6 +29,8 @@
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
+# Please send patches to <config-patches@gnu.org>.
+#
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
 # If it is invalid, we print an error message on stderr and exit with code 1.
@@ -45,34 +51,61 @@
 #	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
 # It is wrong to echo any other type of specification.
 
-if [ x$1 = x ]
-then
-	echo Configuration name missing. 1>&2
-	echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
-	echo "or     $0 ALIAS" 1>&2
-	echo where ALIAS is a recognized configuration type. 1>&2
-	exit 1
-fi
+me=`echo "$0" | sed -e 's,.*/,,'`
 
-# First pass through any local machine types.
-case $1 in
-	*local*)
-		echo $1
-		exit 0
-		;;
-	*)
-	;;
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help               print this help, then exit
+  -V, --version            print version number, then exit"
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case "$1" in
+    --version | --vers* | -V )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       exec >&2
+       echo "$me: invalid option $1"
+       echo "$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
 esac
 
 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  hurd-gnu*)
-    os=$maybe_os
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
-    ;;
-  linux-gnu*)
+  nto-qnx* | linux-gnu*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
@@ -89,6 +122,9 @@
 ### recognize some manufacturers as not being operating systems, so we
 ### can provide default operating systems below.
 case $os in
+	-os2)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86/'`
+		;;
 	-sun*os*)
 		# Prevent following clause from handling this invalid input.
 		;;
@@ -98,15 +134,25 @@
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple)
+	-apple | -axis)
 		os=
 		basic_machine=$1
 		;;
+	-sim | -cisco | -oki | -wec | -winbond)
+		os=
+		basic_machine=$1
+		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
 	-hiux*)
 		os=-hiuxwe2
 		;;
 	-sco5)
-		os=sco3.2v5
+		os=-sco3.2v5
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco4)
@@ -125,6 +171,9 @@
 		os=-sco3.2v2
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
 	-isc)
 		os=-isc2.2
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -147,27 +196,46 @@
 	-psos*)
 		os=-psos
 		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
 esac
 
 # Decode aliases for certain CPU-COMPANY combinations.
 case $basic_machine in
 	# Recognize the basic CPU types without company name.
 	# Some are omitted here because they have special meanings below.
-	tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
-		| arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
+	tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
+		| arme[lb] | armv[2345] | armv[345][lb] | pyramid | mn10200 | mn10300 | tron | a29k \
 		| 580 | i960 | h8300 \
-		| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w \
-		| alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
-		| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
-		| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
-		| mipstx39 | mipstx39el \
-		| sparc | sparclet | sparclite | sparc64 | v850 | ia64)
+		| x86 | ppcbe | mipsbe | mipsle | shbe | shle | armbe | armle \
+		| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+		| hppa64 \
+		| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+		| alphaev6[78] \
+		| we32k | ns16k | clipper | i370 | sh | sh[34] \
+		| powerpc | powerpcle \
+		| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+		| mips64orion | mips64orionel | mipstx39 | mipstx39el \
+		| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+		| mips64vr5000 | miprs64vr5000el | mcore \
+		| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
+		| thumb | d10v | d30v | fr30 | avr)
+		basic_machine=$basic_machine-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
 		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
 		;;
+
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
-	i[34567]86)
+	i[234567]86 | x86_64)
 	  basic_machine=$basic_machine-pc
 	  ;;
 	# Object if more than one company name word.
@@ -176,28 +244,49 @@
 		exit 1
 		;;
 	# Recognize the basic CPU types with company name.
-	vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
+	# FIXME: clean up the formatting here.
+	vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
 	      | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
 	      | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
-	      | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
+	      | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
 	      | xmp-* | ymp-* \
+	      | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* | armbe-* | armle-* \
 	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
-	      | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
-	      | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
+	      | hppa2.0n-* | hppa64-* \
+	      | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+	      | alphaev6[78]-* \
+	      | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+	      | clipper-* | orion-* \
 	      | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
-	      | sparc64-* | mips64-* | mipsel-* \
-	      | mips64el-* | mips64orion-* | mips64orionel-*  \
-	      | mipstx39-* | mipstx39el-* \
-	      | f301-* | ia64-*)
+	      | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+	      | mips64el-* | mips64orion-* | mips64orionel-* \
+	      | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+	      | mipstx39-* | mipstx39el-* | mcore-* \
+	      | f301-* | armv*-* | s390-* | sv1-* | t3e-* \
+	      | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+	      | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
+	      | bs2000-* | tic54x-* | c54x-* | x86_64-*)
 		;;
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
 	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
 		basic_machine=m68000-att
 		;;
 	3b*)
 		basic_machine=we32k-att
 		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
 	alliant | fx80)
 		basic_machine=fx80-alliant
 		;;
@@ -213,20 +302,24 @@
 		os=-sysv
 		;;
 	amiga | amiga-*)
-		basic_machine=m68k-cbm
+		basic_machine=m68k-unknown
 		;;
 	amigaos | amigados)
-		basic_machine=m68k-cbm
+		basic_machine=m68k-unknown
 		os=-amigaos
 		;;
 	amigaunix | amix)
-		basic_machine=m68k-cbm
+		basic_machine=m68k-unknown
 		os=-sysv4
 		;;
 	apollo68)
 		basic_machine=m68k-apollo
 		os=-sysv
 		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
 	aux)
 		basic_machine=m68k-apple
 		os=-aux
@@ -270,6 +363,9 @@
 	crds | unos)
 		basic_machine=m68k-crds
 		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
 	da30 | da30-*)
 		basic_machine=m68k-da30
 		;;
@@ -303,6 +399,10 @@
 	encore | umax | mmax)
 		basic_machine=ns32k-encore
 		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
 	fx2800)
 		basic_machine=i860-alliant
 		;;
@@ -321,6 +421,14 @@
 		basic_machine=h8300-hitachi
 		os=-hms
 		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
 	harris)
 		basic_machine=m88k-harris
 		os=-sysv3
@@ -336,31 +444,48 @@
 		basic_machine=m68k-hp
 		os=-hpux
 		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
 	hp9k2[0-9][0-9] | hp9k31[0-9])
 		basic_machine=m68000-hp
 		;;
 	hp9k3[2-9][0-9])
 		basic_machine=m68k-hp
+		;;
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
 		;;
-	hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
 		basic_machine=hppa1.1-hp
 		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
+		basic_machine=hppa1.1-hp
+		;;
 	hp9k8[0-9][0-9] | hp8[0-9][0-9])
 		basic_machine=hppa1.0-hp
 		;;
 	hppa-next)
 		os=-nextstep3
 		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
-		os=-mvs
-		;;
-	s390 | s390-ibm*)
-# OS/390 support after:
-#  Linkname: Mortice Kern Systems (MKS) Inc. - OS/390 OpenEdition -- GNU Utilities Downloads
-#       URL: http://www.mks.com/s390/gnu/download.htm#autoconf
-		basic_machine=s390-ibm  #  /* S/390 -- gil -- 1419 */
-		os=-os390
 		;;
 # I'm not sure what "Sysv32" means.  Should this be sysv3.2?
 	i[34567]86v32)
@@ -379,6 +504,26 @@
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-solaris2
 		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	i386-go32 | go32)
+		basic_machine=i386-unknown
+		os=-go32
+		;;
+	i386-mingw32 | mingw32)
+		basic_machine=i386-unknown
+		os=-mingw32
+		;;
+	i[34567]86-pw32 | pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
 	iris | iris4d)
 		basic_machine=mips-sgi
 		case $os in
@@ -407,6 +552,10 @@
 	miniframe)
 		basic_machine=m68000-convergent
 		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
 	mipsel*-linux*)
 		basic_machine=mipsel-unknown
 		os=-linux-gnu
@@ -421,10 +570,34 @@
 	mips3*)
 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
 		;;
+	mmix*)
+		basic_machine=mmix-knuth
+		os=-mmixware
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	msdos)
+		basic_machine=i386-unknown
+		os=-msdos
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
 	ncr3000)
 		basic_machine=i486-ncr
 		os=-sysv4
 		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
 	news | news700 | news800 | news900)
 		basic_machine=m68k-sony
 		os=-newsos
@@ -437,6 +610,10 @@
 		basic_machine=mips-sony
 		os=-newsos
 		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
 	next | m*-next )
 		basic_machine=m68k-next
 		case $os in
@@ -462,9 +639,32 @@
 		basic_machine=i960-intel
 		os=-nindy
 		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
 	np1)
 		basic_machine=np1-gould
 		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
 	pa-hitachi)
 		basic_machine=hppa1.1-hitachi
 		os=-hiuxwe2
@@ -482,19 +682,19 @@
         pc532 | pc532-*)
 		basic_machine=ns32k-pc532
 		;;
-	pentium | p5 | k5 | nexen)
+	pentium | p5 | k5 | k6 | nexgen)
 		basic_machine=i586-pc
 		;;
-	pentiumpro | p6 | k6 | 6x86)
+	pentiumpro | p6 | 6x86 | athlon)
 		basic_machine=i686-pc
 		;;
 	pentiumii | pentium2)
 		basic_machine=i786-pc
 		;;
-	pentium-* | p5-* | k5-* | nexen-*)
+	pentium-* | p5-* | k5-* | k6-* | nexgen-*)
 		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
-	pentiumpro-* | p6-* | k6-* | 6x86-*)
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	pentiumii-* | pentium2-*)
@@ -518,12 +718,20 @@
 	ps2)
 		basic_machine=i386-ibm
 		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
 	rm[46]00)
 		basic_machine=mips-siemens
 		;;
 	rtpc | rtpc-*)
 		basic_machine=romp-ibm
 		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
 	sequent)
 		basic_machine=i386-sequent
 		;;
@@ -531,6 +739,10 @@
 		basic_machine=sh-hitachi
 		os=-hms
 		;;
+	sparclite-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
 	sps7)
 		basic_machine=m68k-bull
 		os=-sysv2
@@ -538,6 +750,13 @@
 	spur)
 		basic_machine=spur-unknown
 		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
 	sun2)
 		basic_machine=m68000-sun
 		;;
@@ -578,10 +797,22 @@
 	sun386 | sun386i | roadrunner)
 		basic_machine=i386-sun
 		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
 	symmetry)
 		basic_machine=i386-sequent
 		os=-dynix
 		;;
+	t3e)
+		basic_machine=t3e-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
 	tx39)
 		basic_machine=mipstx39-unknown
 		;;
@@ -599,6 +830,10 @@
 		basic_machine=a29k-nyu
 		os=-sym1
 		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
 	vaxv)
 		basic_machine=vax-dec
 		os=-sysv
@@ -622,6 +857,14 @@
 		basic_machine=a29k-wrs
 		os=-vxworks
 		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
 	xmp)
 		basic_machine=xmp-cray
 		os=-unicos
@@ -629,6 +872,10 @@
         xps | xps100)
 		basic_machine=xps100-honeywell
 		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
 	none)
 		basic_machine=none-none
 		os=-none
@@ -636,6 +883,15 @@
 
 # Here we handle the default manufacturer of certain CPU types.  It is in
 # some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
 	mips)
 		if [ x$os = x-linux-gnu ]; then
 			basic_machine=mips-unknown
@@ -657,8 +913,11 @@
 		;;
 	we32k)
 		basic_machine=we32k-att
+		;;
+	sh3 | sh4)
+		basic_machine=sh-unknown
 		;;
-	sparc)
+	sparc | sparcv9)
 		basic_machine=sparc-sun
 		;;
         cydra)
@@ -670,6 +929,16 @@
 	orion105)
 		basic_machine=clipper-highlevel
 		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	c4x*)
+		basic_machine=c4x-none
+		os=-coff
+		;;
 	*)
 		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
 		exit 1
@@ -720,28 +989,53 @@
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -aos* \
-	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* | -os390* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
-	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
+	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -rhapsody* )
+	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i[34567]86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto*)
+		os=-nto-qnx
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -os2 \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
 	-linux*)
 		os=`echo $os | sed -e 's|linux|linux-gnu|'`
 		;;
-	-hurd*)
-		os=`echo $os `
-		;;
 	-sunos5*)
 		os=`echo $os | sed -e 's|sunos5|solaris2|'`
 		;;
 	-sunos6*)
 		os=`echo $os | sed -e 's|sunos6|solaris3|'`
 		;;
+	-opened*)
+		os=-openedition
+		;;
+	-wince*)
+		os=-wince
+		;;
 	-osfrose*)
 		os=-osfrose
 		;;
@@ -757,12 +1051,18 @@
 	-acis*)
 		os=-aos
 		;;
+	-386bsd)
+		os=-bsd
+		;;
 	-ctix* | -uts*)
 		os=-sysv
 		;;
 	-ns2 )
 	        os=-nextstep2
 		;;
+	-nsk*)
+		os=-nsk
+		;;
 	# Preserve the version number of sinix5.
 	-sinix5.*)
 		os=`echo $os | sed -e 's|sinix|sysv|'`
@@ -788,9 +1088,18 @@
 	# This must come after -sysvr4.
 	-sysv*)
 		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
 	-xenix)
 		os=-xenix
 		;;
+        -*mint | -*MiNT)
+	        os=-mint
+		;;
 	-none)
 		;;
 	*)
@@ -816,6 +1125,9 @@
 	*-acorn)
 		os=-riscix1.2
 		;;
+	arm*-rebel)
+		os=-linux
+		;;
 	arm*-semi)
 		os=-aout
 		;;
@@ -837,6 +1149,15 @@
 		# default.
 		# os=-sunos4
 		;;
+	m68*-cisco)
+		os=-aout
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
 	*-tti)	# must be before sparc entry or we get the wrong os.
 		os=-sysv3
 		;;
@@ -846,12 +1167,18 @@
 	*-be)
 		os=-beos
 		;;
-	s390-ibm)
-		os=-os390  #  /* S/390 -- gil -- 1451 */
-		;;
 	*-ibm)
 		os=-aix
 		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
 	*-hp)
 		os=-hpux
 		;;
@@ -915,6 +1242,18 @@
 	f301-fujitsu)
 		os=-uxpv
 		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
 	*)
 		os=-none
 		;;
@@ -936,9 +1275,15 @@
 			-aix*)
 				vendor=ibm
 				;;
+			-beos*)
+				vendor=be
+				;;
 			-hpux*)
 				vendor=hp
 				;;
+			-mpeix*)
+				vendor=hp
+				;;
 			-hiux*)
 				vendor=hitachi
 				;;
@@ -954,7 +1299,7 @@
 			-genix*)
 				vendor=ns
 				;;
-			-mvs*)
+			-mvs* | -opened*)
 				vendor=ibm
 				;;
 			-ptx*)
@@ -966,9 +1311,26 @@
 			-aux*)
 				vendor=apple
 				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -*MiNT)
+				vendor=atari
+				;;
 		esac
 		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
 		;;
 esac
 
 echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "version='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
Index: xc/programs/xterm/configure
diff -u xc/programs/xterm/configure:3.49 xc/programs/xterm/configure:3.54
--- xc/programs/xterm/configure:3.49	Mon Jun 12 22:28:38 2000
+++ xc/programs/xterm/configure	Wed Dec  6 21:22:12 2000
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13.19990117 
+# Generated automatically using autoconf version 2.13.20000819 
 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #
 # This configure script is free software; the Free Software Foundation
@@ -191,13 +191,14 @@
   --with-terminal-id[=V]  set default decTerminalID (default: vt100)
   --with-terminal-type=T  set default \$TERM (default: xterm)
   --with-own-terminfo=P   set default \$TERMINFO (default: from environment)
+Optional Features:
   --disable-active-icon   disable X11R6.3 active-icon feature
   --disable-ansi-color    disable ANSI color
   --disable-16-color      disable 16-color support
   --enable-256-color      enable 256-color support
-  --enable-88-color       enable 88-color support
 EOF
 cat <<EOF
+  --enable-88-color       enable 88-color support
   --disable-blink-cursor  disable support for blinking cursor
   --disable-bold-color    disable PC-style mapping of bold colors
   --disable-color-mode    disable default colorMode resource
@@ -209,23 +210,25 @@
   --disable-i18n          disable internationalization
   --disable-initial-erase disable setup for stty erase
   --disable-input-method  disable input-method
-  --enable-logging        enable logging
 EOF
 cat <<EOF
+  --enable-logging        enable logging
   --enable-logfile-exec   enable exec'd logfile filter
   --disable-maximize      disable actions for iconify/deiconify/maximize/restore
   --disable-num-lock      disable NumLock keypad support
   --disable-rightbar      disable right-scrollbar support
   --disable-samename      disable check for redundant name-change
+  --enable-tcap-query     compile-in termcap-query support
   --disable-tek4014       disable tek4014 emulation
   --enable-toolbar        compile-in toolbar for pulldown menus
   --disable-vt52          disable VT52 emulation
   --enable-wide-chars     enable wide-character support
   --enable-dec-locator    enable DECterm Locator support
-  --disable-ziconbeep     disable -ziconbeep option
-  --enable-trace          test: set to enable debugging traces
 EOF
 cat <<EOF
+  --disable-ziconbeep     disable -ziconbeep option
+Testing/development Options:
+  --enable-trace          test: set to enable debugging traces
   --disable-echo          display "compiling" commands
   --enable-xmc-glitch     test: enable xmc magic-cookie emulation
   --enable-warnings       test: turn on GCC compiler warnings
@@ -379,7 +382,7 @@
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.13.19990117"
+    echo "configure generated by autoconf version 2.13.20000819"
     exit 0 ;;
 
   -with-* | --with-*)
@@ -596,7 +599,7 @@
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:600: checking host system type" >&5
+echo "configure:603: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -644,10 +647,17 @@
 
 
 ###	checks for alternative programs
+
+case "$host_os" in
+openedition)	: ${CFLAGS="-O2 -Wc,dll -D_ALL_SOURCE -Wl,EDIT=NO"}
+		: ${LIBS="/usr/lib/Xaw.x /usr/lib/SM.x /usr/lib/ICE.x /usr/lib/X11.x"}
+		: ${CC=c89};;
+esac
+
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:651: checking for $ac_word" >&5
+echo "configure:661: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -677,7 +687,7 @@
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:681: checking for $ac_word" >&5
+echo "configure:691: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -728,7 +738,7 @@
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:732: checking for $ac_word" >&5
+echo "configure:742: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -760,7 +770,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:764: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:774: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -771,12 +781,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 775 "configure"
+#line 785 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -802,12 +812,12 @@
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:806: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:816: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:811: checking whether we are using GNU C" >&5
+echo "configure:821: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -816,7 +826,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:820: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:830: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -835,7 +845,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:839: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:849: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -867,7 +877,7 @@
 fi
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:871: checking how to run the C preprocessor" >&5
+echo "configure:881: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -882,13 +892,13 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 886 "configure"
+#line 896 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:892: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:902: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -899,13 +909,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 903 "configure"
+#line 913 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:909: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:919: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -916,13 +926,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 920 "configure"
+#line 930 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:926: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:936: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -948,13 +958,13 @@
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:952: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:962: checking whether ${CC-cc} needs -traditional" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
     ac_pattern="Autoconf.*'x'"
   cat > conftest.$ac_ext <<EOF
-#line 958 "configure"
+#line 968 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
@@ -972,7 +982,7 @@
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 976 "configure"
+#line 986 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
@@ -998,7 +1008,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1002: checking for $ac_word" >&5
+echo "configure:1012: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1039,7 +1049,7 @@
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1043: checking for a BSD compatible install" >&5
+echo "configure:1053: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1094,9 +1104,9 @@
 
 ###	checks for UNIX variants that set C preprocessor variables
 echo $ac_n "checking for AIX""... $ac_c" 1>&6
-echo "configure:1098: checking for AIX" >&5
+echo "configure:1108: checking for AIX" >&5
 cat > conftest.$ac_ext <<EOF
-#line 1100 "configure"
+#line 1110 "configure"
 #include "confdefs.h"
 #ifdef _AIX
   yes
@@ -1118,7 +1128,7 @@
 
 
 echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:1122: checking for POSIXized ISC" >&5
+echo "configure:1132: checking for POSIXized ISC" >&5
 if test -d /etc/conf/kconfig.d &&
   grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
 then
@@ -1140,17 +1150,17 @@
 
 ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
-echo "configure:1144: checking for minix/config.h" >&5
+echo "configure:1154: checking for minix/config.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1149 "configure"
+#line 1159 "configure"
 #include "confdefs.h"
 #include <minix/config.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1154: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1164: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1197,17 +1207,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1201: checking for $ac_hdr" >&5
+echo "configure:1211: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1206 "configure"
+#line 1216 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1211: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1221: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1237,13 +1247,13 @@
 ###	checks for typedefs
 
 echo $ac_n "checking for size_t in <sys/types.h> or <stdio.h>""... $ac_c" 1>&6
-echo "configure:1241: checking for size_t in <sys/types.h> or <stdio.h>" >&5
+echo "configure:1251: checking for size_t in <sys/types.h> or <stdio.h>" >&5
 if eval "test \"`echo '$''{'cf_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 	cat > conftest.$ac_ext <<EOF
-#line 1247 "configure"
+#line 1257 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -1256,7 +1266,7 @@
 size_t x
 ; return 0; }
 EOF
-if { (eval echo configure:1260: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1270: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_type_size_t=yes
 else
@@ -1276,12 +1286,12 @@
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1280: checking for ANSI C header files" >&5
+echo "configure:1290: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1285 "configure"
+#line 1295 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1289,7 +1299,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1293: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1303: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1306,7 +1316,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1310 "configure"
+#line 1320 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1324,7 +1334,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1328 "configure"
+#line 1338 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1345,7 +1355,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1349 "configure"
+#line 1359 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1356,7 +1366,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:1360: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1380,12 +1390,12 @@
 fi
 
 echo $ac_n "checking for time_t""... $ac_c" 1>&6
-echo "configure:1384: checking for time_t" >&5
+echo "configure:1394: checking for time_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_time_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1389 "configure"
+#line 1399 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1423,12 +1433,12 @@
 	
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1427: checking for $ac_func" >&5
+echo "configure:1437: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1432 "configure"
+#line 1442 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1451,7 +1461,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1477,12 +1487,12 @@
 
 
 echo $ac_n "checking for memmove""... $ac_c" 1>&6
-echo "configure:1481: checking for memmove" >&5
+echo "configure:1491: checking for memmove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_memmove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1486 "configure"
+#line 1496 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char memmove(); below.  */
@@ -1505,7 +1515,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1519: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_memmove=yes"
 else
@@ -1524,12 +1534,12 @@
   echo "$ac_t""no" 1>&6
 
 echo $ac_n "checking for bcopy""... $ac_c" 1>&6
-echo "configure:1528: checking for bcopy" >&5
+echo "configure:1538: checking for bcopy" >&5
 if eval "test \"`echo '$''{'ac_cv_func_bcopy'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1533 "configure"
+#line 1543 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char bcopy(); below.  */
@@ -1552,7 +1562,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1556: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_bcopy=yes"
 else
@@ -1568,7 +1578,7 @@
   echo "$ac_t""yes" 1>&6
   
 	echo $ac_n "checking if bcopy does overlapping moves""... $ac_c" 1>&6
-echo "configure:1572: checking if bcopy does overlapping moves" >&5
+echo "configure:1582: checking if bcopy does overlapping moves" >&5
 if eval "test \"`echo '$''{'cf_cv_good_bcopy'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1577,7 +1587,7 @@
   cf_cv_good_bcopy=unknown
 else
   cat > conftest.$ac_ext <<EOF
-#line 1581 "configure"
+#line 1591 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1590,7 +1600,7 @@
 }
 		
 EOF
-if { (eval echo configure:1594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cf_cv_good_bcopy=yes
 else
@@ -1612,7 +1622,7 @@
 cf_cv_good_bcopy=no
 fi
 
-	if test $cf_cv_good_bcopy = yes ; then
+	if test "$cf_cv_good_bcopy" = yes ; then
 		cat >> confdefs.h <<\EOF
 #define USE_OK_BCOPY 1
 EOF
@@ -1628,7 +1638,7 @@
 
 
 echo $ac_n "checking for full tgetent function""... $ac_c" 1>&6
-echo "configure:1632: checking for full tgetent function" >&5
+echo "configure:1642: checking for full tgetent function" >&5
 if eval "test \"`echo '$''{'cf_cv_lib_tgetent'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1643,7 +1653,7 @@
   echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&5
 else
   cat > conftest.$ac_ext <<EOF
-#line 1647 "configure"
+#line 1657 "configure"
 #include "confdefs.h"
 
 /* terminfo implementations ignore the buffer argument, making it useless for
@@ -1657,7 +1667,7 @@
 	tgetent(buffer, "vt100");
 	exit(buffer[0] == 0); }
 EOF
-if { (eval echo configure:1661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1671: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&5
 	 if test -n "$cf_termlib" ; then
@@ -1693,7 +1703,7 @@
 EOF
 
 	cat > conftest.$ac_ext <<EOF
-#line 1697 "configure"
+#line 1707 "configure"
 #include "confdefs.h"
 
 #include <termcap.h>
@@ -1704,7 +1714,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:1708: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1718: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_TERMCAP_H 1
@@ -1722,7 +1732,7 @@
         # validate values for the TERM environment variable given to
         # child processes.
 	echo $ac_n "checking for partial tgetent function""... $ac_c" 1>&6
-echo "configure:1726: checking for partial tgetent function" >&5
+echo "configure:1736: checking for partial tgetent function" >&5
 if eval "test \"`echo '$''{'cf_cv_lib_part_tgetent'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1731,14 +1741,14 @@
 	for cf_termlib in $cf_TERMLIB ; do
 		LIBS="$cf_save_LIBS -l$cf_termlib"
 		cat > conftest.$ac_ext <<EOF
-#line 1735 "configure"
+#line 1745 "configure"
 #include "confdefs.h"
 
 int main() {
 tgetent(0, 0)
 ; return 0; }
 EOF
-if { (eval echo configure:1742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "there is a terminfo/tgetent in $cf_termlib" 1>&5
 			 cf_cv_lib_part_tgetent="-l$cf_termlib"
@@ -1761,17 +1771,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1765: checking for $ac_hdr" >&5
+echo "configure:1775: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1770 "configure"
+#line 1780 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1775: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1785: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1812,17 +1822,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1816: checking for $ac_hdr" >&5
+echo "configure:1826: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1821 "configure"
+#line 1831 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1826: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1836: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1849,13 +1859,13 @@
 done
 
 echo $ac_n "checking for lastlog path""... $ac_c" 1>&6
-echo "configure:1853: checking for lastlog path" >&5
+echo "configure:1863: checking for lastlog path" >&5
 if eval "test \"`echo '$''{'cf_cv_path_lastlog'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 1859 "configure"
+#line 1869 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -1870,7 +1880,7 @@
 char *path = _PATH_LASTLOG
 ; return 0; }
 EOF
-if { (eval echo configure:1874: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1884: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_path_lastlog="_PATH_LASTLOG"
 else
@@ -1897,7 +1907,7 @@
 
 
 echo $ac_n "checking for utmp implementation""... $ac_c" 1>&6
-echo "configure:1901: checking for utmp implementation" >&5
+echo "configure:1911: checking for utmp implementation" >&5
 if eval "test \"`echo '$''{'cf_cv_have_utmp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1905,7 +1915,7 @@
 	cf_cv_have_utmp=no
 for cf_header in utmpx utmp ; do
 	cat > conftest.$ac_ext <<EOF
-#line 1909 "configure"
+#line 1919 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -1921,7 +1931,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:1925: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1935: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_have_utmp=$cf_header
 	 break
@@ -1931,7 +1941,7 @@
   rm -rf conftest*
   
 	cat > conftest.$ac_ext <<EOF
-#line 1935 "configure"
+#line 1945 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -1947,7 +1957,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:1951: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1961: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_have_utmp=$cf_header
 	 cat >> confdefs.h <<\EOF
@@ -1982,13 +1992,13 @@
 
 if test $cf_cv_have_utmp != no ; then
 echo $ac_n "checking if utmp.ut_host is declared""... $ac_c" 1>&6
-echo "configure:1986: checking if utmp.ut_host is declared" >&5
+echo "configure:1996: checking if utmp.ut_host is declared" >&5
 if eval "test \"`echo '$''{'cf_cv_have_utmp_ut_host'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 	cat > conftest.$ac_ext <<EOF
-#line 1992 "configure"
+#line 2002 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -1997,7 +2007,7 @@
 struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]
 ; return 0; }
 EOF
-if { (eval echo configure:2001: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2011: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_have_utmp_ut_host=yes
 else
@@ -2021,7 +2031,7 @@
 
 if test $cf_cv_have_utmp != no ; then
 echo $ac_n "checking for exit-status in $cf_cv_have_utmp""... $ac_c" 1>&6
-echo "configure:2025: checking for exit-status in $cf_cv_have_utmp" >&5
+echo "configure:2035: checking for exit-status in $cf_cv_have_utmp" >&5
 if eval "test \"`echo '$''{'cf_cv_have_utmp_ut_xstatus'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2033,7 +2043,7 @@
 	ut_exit.ut_exit
 do
 cat > conftest.$ac_ext <<EOF
-#line 2037 "configure"
+#line 2047 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2042,7 +2052,7 @@
 struct $cf_cv_have_utmp x; long y = x.$cf_result = 0
 ; return 0; }
 EOF
-if { (eval echo configure:2046: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_have_utmp_ut_xstatus=$cf_result
 	 break
@@ -2074,13 +2084,13 @@
 
 if test $cf_cv_have_utmp != no ; then
 echo $ac_n "checking if utmp.ut_xtime is declared""... $ac_c" 1>&6
-echo "configure:2078: checking if utmp.ut_xtime is declared" >&5
+echo "configure:2088: checking if utmp.ut_xtime is declared" >&5
 if eval "test \"`echo '$''{'cf_cv_have_utmp_ut_xtime'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 	cat > conftest.$ac_ext <<EOF
-#line 2084 "configure"
+#line 2094 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2089,7 +2099,7 @@
 struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0
 ; return 0; }
 EOF
-if { (eval echo configure:2093: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2103: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_have_utmp_ut_xtime=yes
 else
@@ -2097,7 +2107,7 @@
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 2101 "configure"
+#line 2111 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2106,7 +2116,7 @@
 struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec
 ; return 0; }
 EOF
-if { (eval echo configure:2110: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2120: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_have_utmp_ut_xtime=define
 else
@@ -2141,13 +2151,13 @@
 
 if test $cf_cv_have_utmp != no ; then
 echo $ac_n "checking if utmp.ut_session is declared""... $ac_c" 1>&6
-echo "configure:2145: checking if utmp.ut_session is declared" >&5
+echo "configure:2155: checking if utmp.ut_session is declared" >&5
 if eval "test \"`echo '$''{'cf_cv_have_utmp_ut_session'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 	cat > conftest.$ac_ext <<EOF
-#line 2151 "configure"
+#line 2161 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2156,7 +2166,7 @@
 struct $cf_cv_have_utmp x; long y = x.ut_session
 ; return 0; }
 EOF
-if { (eval echo configure:2160: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2170: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_have_utmp_ut_session=yes
 else
@@ -2181,14 +2191,14 @@
 	
 
 echo $ac_n "checking if $cf_cv_have_utmp is SYSV flavor""... $ac_c" 1>&6
-echo "configure:2185: checking if $cf_cv_have_utmp is SYSV flavor" >&5
+echo "configure:2195: checking if $cf_cv_have_utmp is SYSV flavor" >&5
 if eval "test \"`echo '$''{'cf_cv_sysv_utmp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
 cat > conftest.$ac_ext <<EOF
-#line 2192 "configure"
+#line 2202 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -2202,7 +2212,7 @@
 	end${cf_prefix}ent();
 ; return 0; }
 EOF
-if { (eval echo configure:2206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2216: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_cv_sysv_utmp=yes
 else
@@ -2225,7 +2235,7 @@
 
 
 echo $ac_n "checking if you want to link with utempter""... $ac_c" 1>&6
-echo "configure:2229: checking if you want to link with utempter" >&5
+echo "configure:2239: checking if you want to link with utempter" >&5
 
 # Check whether --with-utempter or --without-utempter was given.
 if test "${with_utempter+set}" = set; then
@@ -2240,7 +2250,7 @@
 if test $use_utempter = yes ; then
 	
 echo $ac_n "checking if we can link with utempter library""... $ac_c" 1>&6
-echo "configure:2244: checking if we can link with utempter library" >&5
+echo "configure:2254: checking if we can link with utempter library" >&5
 if eval "test \"`echo '$''{'cf_cv_have_utempter'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2248,7 +2258,7 @@
 cf_save_LIBS="$LIBS"
 LIBS="-lutempter $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2252 "configure"
+#line 2262 "configure"
 #include "confdefs.h"
 
 #include <utempter.h>
@@ -2260,7 +2270,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2264: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2274: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
 	cf_cv_have_utempter=yes
@@ -2291,13 +2301,13 @@
 
 
 echo $ac_n "checking if external errno is declared""... $ac_c" 1>&6
-echo "configure:2295: checking if external errno is declared" >&5
+echo "configure:2305: checking if external errno is declared" >&5
 if eval "test \"`echo '$''{'cf_cv_dcl_errno'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     cat > conftest.$ac_ext <<EOF
-#line 2301 "configure"
+#line 2311 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_STDLIB_H
@@ -2310,7 +2320,7 @@
 long x = (long) errno
 ; return 0; }
 EOF
-if { (eval echo configure:2314: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2324: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval 'cf_cv_dcl_'errno'=yes'
 else
@@ -2330,7 +2340,7 @@
 if test "$cf_result" = no ; then
     eval 'cf_result=DECL_'errno
     
-cf_result=`echo $cf_result | tr '[a-z]' '[A-Z]'`
+cf_result=`echo "$cf_result" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
     cat >> confdefs.h <<EOF
 #define $cf_result 1
@@ -2341,13 +2351,13 @@
 # It's possible (for near-UNIX clones) that the data doesn't exist
 
 echo $ac_n "checking if external errno exists""... $ac_c" 1>&6
-echo "configure:2345: checking if external errno exists" >&5
+echo "configure:2355: checking if external errno exists" >&5
 if eval "test \"`echo '$''{'cf_cv_have_errno'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     cat > conftest.$ac_ext <<EOF
-#line 2351 "configure"
+#line 2361 "configure"
 #include "confdefs.h"
 
 #undef errno
@@ -2357,7 +2367,7 @@
 errno = 2
 ; return 0; }
 EOF
-if { (eval echo configure:2361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2371: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval 'cf_cv_have_'errno'=yes'
 else
@@ -2376,7 +2386,7 @@
 if test "$cf_result" = yes ; then
     eval 'cf_result=HAVE_'errno
     
-cf_result=`echo $cf_result | tr '[a-z]' '[A-Z]'`
+cf_result=`echo "$cf_result" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
     cat >> confdefs.h <<EOF
 #define $cf_result 1
@@ -2389,7 +2399,7 @@
 
 
 echo $ac_n "checking for tty group name""... $ac_c" 1>&6
-echo "configure:2393: checking for tty group name" >&5
+echo "configure:2403: checking for tty group name" >&5
 if eval "test \"`echo '$''{'cf_cv_tty_group_name'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2447,7 +2457,7 @@
 
 
 echo $ac_n "checking if we may use tty group""... $ac_c" 1>&6
-echo "configure:2451: checking if we may use tty group" >&5
+echo "configure:2461: checking if we may use tty group" >&5
 if eval "test \"`echo '$''{'cf_cv_tty_group'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2456,7 +2466,7 @@
   cf_cv_tty_group=unknown
 else
   cat > conftest.$ac_ext <<EOF
-#line 2460 "configure"
+#line 2470 "configure"
 #include "confdefs.h"
 
 #include <unistd.h>
@@ -2481,7 +2491,7 @@
 }
 	
 EOF
-if { (eval echo configure:2485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cf_cv_tty_group=yes
 else
@@ -2506,13 +2516,14 @@
 ###	checks for compiler characteristics
 
 echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6
-echo "configure:2510: checking for ${CC-cc} option to accept ANSI C" >&5
+echo "configure:2520: checking for ${CC-cc} option to accept ANSI C" >&5
 if eval "test \"`echo '$''{'cf_cv_ansi_cc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cf_cv_ansi_cc=no
 cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
 # Don't try gcc -ansi; that turns off useful extensions and
 # breaks some systems' header files.
 # AIX			-qlanglvl=ansi
@@ -2527,10 +2538,22 @@
 	-Ae \
 	"-Aa -D_HPUX_SOURCE" \
 	-Xc
+do
+	
+for cf_add_cflags in $cf_arg
 do
-	CFLAGS="$cf_save_CFLAGS $cf_arg"
+	case $cf_add_cflags in #(vi
+	-I*|-D*|-U*|-E|-P|-C) #(vi
+		CPPFLAGS="$CPPFLAGS $cf_add_cflags"
+		;;
+	*)
+		CFLAGS="$CFLAGS $cf_add_cflags"
+		;;
+	esac
+done
+
 	cat > conftest.$ac_ext <<EOF
-#line 2534 "configure"
+#line 2557 "configure"
 #include "confdefs.h"
 
 #ifndef CC_HAS_PROTOS
@@ -2546,7 +2569,7 @@
 	struct s2 {int (*f) (double a);};
 ; return 0; }
 EOF
-if { (eval echo configure:2550: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2573: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_ansi_cc="$cf_arg"; break
 else
@@ -2556,6 +2579,7 @@
 rm -f conftest*
 done
 CFLAGS="$cf_save_CFLAGS"
+CPPFLAGS="$cf_save_CPPFLAGS"
 
 fi
 
@@ -2573,12 +2597,12 @@
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:2577: checking for working const" >&5
+echo "configure:2601: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2582 "configure"
+#line 2606 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -2627,7 +2651,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2631: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2655: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -2651,12 +2675,12 @@
 ###	checks for system services and user specified options
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:2655: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:2679: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2660 "configure"
+#line 2684 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -2672,7 +2696,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:2676: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2700: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -2695,13 +2719,13 @@
 
 
 echo $ac_n "checking for POSIX wait functions""... $ac_c" 1>&6
-echo "configure:2699: checking for POSIX wait functions" >&5
+echo "configure:2723: checking for POSIX wait functions" >&5
 if eval "test \"`echo '$''{'cf_cv_posix_wait'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 2705 "configure"
+#line 2729 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -2719,7 +2743,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_cv_posix_wait=yes
 else
@@ -2740,13 +2764,13 @@
 
 
 echo $ac_n "checking if this platform has SYSV flavor""... $ac_c" 1>&6
-echo "configure:2744: checking if this platform has SYSV flavor" >&5
+echo "configure:2768: checking if this platform has SYSV flavor" >&5
 if eval "test \"`echo '$''{'cf_cv_sysv'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 2750 "configure"
+#line 2774 "configure"
 #include "confdefs.h"
 
 #include <curses.h>
@@ -2771,7 +2795,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2775: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2799: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_sysv=yes
 else
@@ -2792,7 +2816,7 @@
 
 
 echo $ac_n "checking for elf_begin in -lelf""... $ac_c" 1>&6
-echo "configure:2796: checking for elf_begin in -lelf" >&5
+echo "configure:2820: checking for elf_begin in -lelf" >&5
 ac_lib_var=`echo elf'_'elf_begin | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2800,7 +2824,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lelf  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2804 "configure"
+#line 2828 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2811,7 +2835,7 @@
 elf_begin()
 ; return 0; }
 EOF
-if { (eval echo configure:2815: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2828,13 +2852,13 @@
   echo "$ac_t""yes" 1>&6
   
 echo $ac_n "checking if this is an SVR4 system""... $ac_c" 1>&6
-echo "configure:2832: checking if this is an SVR4 system" >&5
+echo "configure:2856: checking if this is an SVR4 system" >&5
 if eval "test \"`echo '$''{'cf_cv_svr4'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 2838 "configure"
+#line 2862 "configure"
 #include "confdefs.h"
 
 #include <elf.h>
@@ -2855,7 +2879,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2859: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2883: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_svr4=yes
 else
@@ -2881,13 +2905,13 @@
 
 
 echo $ac_n "checking if we must define _GNU_SOURCE""... $ac_c" 1>&6
-echo "configure:2885: checking if we must define _GNU_SOURCE" >&5
+echo "configure:2909: checking if we must define _GNU_SOURCE" >&5
 if eval "test \"`echo '$''{'cf_cv_gnu_source'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 2891 "configure"
+#line 2915 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int main() {
@@ -2897,17 +2921,17 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:2901: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2925: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_gnu_source=no
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
-  cf_save="$CFLAGS"
-	 CFLAGS="$CFLAGS -D_GNU_SOURCE"
+  cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
 	 cat > conftest.$ac_ext <<EOF
-#line 2911 "configure"
+#line 2935 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int main() {
@@ -2917,7 +2941,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:2921: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2945: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_gnu_source=no
 else
@@ -2927,7 +2951,7 @@
   cf_cv_gnu_source=yes
 fi
 rm -f conftest*
-	CFLAGS="$cf_save"
+	CPPFLAGS="$cf_save"
 	
 fi
 rm -f conftest*
@@ -2935,14 +2959,14 @@
 fi
 
 echo "$ac_t""$cf_cv_gnu_source" 1>&6
-test "$cf_cv_gnu_source" = yes && CFLAGS="$CFLAGS -D_GNU_SOURCE"
+test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
 
 # If we find X, set shell vars x_includes and x_libraries to the
 # paths, otherwise set no_x=yes.
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:2946: checking for X" >&5
+echo "configure:2970: checking for X" >&5
 
 
 # Check whether --with-x or --without-x was given.
@@ -3005,12 +3029,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 3009 "configure"
+#line 3033 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3014: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3038: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3079,14 +3103,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3083 "configure"
+#line 3107 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:3090: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3114: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -3186,7 +3210,7 @@
 	# FIXME: modify the library lookup in autoconf to
 	# allow _s.a suffix ahead of .a
 	echo $ac_n "checking for open in -lc_s""... $ac_c" 1>&6
-echo "configure:3190: checking for open in -lc_s" >&5
+echo "configure:3214: checking for open in -lc_s" >&5
 ac_lib_var=`echo c_s'_'open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3194,7 +3218,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lc_s  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3198 "configure"
+#line 3222 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3205,7 +3229,7 @@
 open()
 ; return 0; }
 EOF
-if { (eval echo configure:3209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3233: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3222,7 +3246,7 @@
   echo "$ac_t""yes" 1>&6
   LIBS="-lc_s $LIBS"
 	echo $ac_n "checking for gethostname in -lbsd""... $ac_c" 1>&6
-echo "configure:3226: checking for gethostname in -lbsd" >&5
+echo "configure:3250: checking for gethostname in -lbsd" >&5
 ac_lib_var=`echo bsd'_'gethostname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3230,7 +3254,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lbsd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3234 "configure"
+#line 3258 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3241,7 +3265,7 @@
 gethostname()
 ; return 0; }
 EOF
-if { (eval echo configure:3245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3258,7 +3282,7 @@
   echo "$ac_t""yes" 1>&6
   LIBS="-lbsd $LIBS"
 	echo $ac_n "checking for gethostname in -lnsl_s""... $ac_c" 1>&6
-echo "configure:3262: checking for gethostname in -lnsl_s" >&5
+echo "configure:3286: checking for gethostname in -lnsl_s" >&5
 ac_lib_var=`echo nsl_s'_'gethostname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3266,7 +3290,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl_s  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3270 "configure"
+#line 3294 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3277,7 +3301,7 @@
 gethostname()
 ; return 0; }
 EOF
-if { (eval echo configure:3281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3294,7 +3318,7 @@
   echo "$ac_t""yes" 1>&6
   LIBS="-lnsl_s $LIBS"
 	echo $ac_n "checking for XOpenDisplay in -lX11_s""... $ac_c" 1>&6
-echo "configure:3298: checking for XOpenDisplay in -lX11_s" >&5
+echo "configure:3322: checking for XOpenDisplay in -lX11_s" >&5
 ac_lib_var=`echo X11_s'_'XOpenDisplay | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3302,7 +3326,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lX11_s  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3306 "configure"
+#line 3330 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3313,7 +3337,7 @@
 XOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:3317: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3330,7 +3354,7 @@
   echo "$ac_t""yes" 1>&6
   LIBS="-lX11_s $LIBS"
 	echo $ac_n "checking for XtAppInitialize in -lXt_s""... $ac_c" 1>&6
-echo "configure:3334: checking for XtAppInitialize in -lXt_s" >&5
+echo "configure:3358: checking for XtAppInitialize in -lXt_s" >&5
 ac_lib_var=`echo Xt_s'_'XtAppInitialize | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3338,7 +3362,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXt_s  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3342 "configure"
+#line 3366 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3349,7 +3373,7 @@
 XtAppInitialize()
 ; return 0; }
 EOF
-if { (eval echo configure:3353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3390,7 +3414,7 @@
 	;;
 *)
 	echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:3394: checking for socket in -lsocket" >&5
+echo "configure:3418: checking for socket in -lsocket" >&5
 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3398,7 +3422,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3402 "configure"
+#line 3426 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3409,7 +3433,7 @@
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:3413: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3437,7 +3461,7 @@
 fi
 
 	echo $ac_n "checking for gethostname in -lnsl""... $ac_c" 1>&6
-echo "configure:3441: checking for gethostname in -lnsl" >&5
+echo "configure:3465: checking for gethostname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3445,7 +3469,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3449 "configure"
+#line 3473 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3456,7 +3480,7 @@
 gethostname()
 ; return 0; }
 EOF
-if { (eval echo configure:3460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3484: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3507,17 +3531,17 @@
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:3511: checking whether -R must be followed by a space" >&5
+echo "configure:3535: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 3514 "configure"
+#line 3538 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -3533,14 +3557,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 3537 "configure"
+#line 3561 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -3572,7 +3596,7 @@
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:3576: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:3600: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3580,7 +3604,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3584 "configure"
+#line 3608 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3591,7 +3615,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:3595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3613,7 +3637,7 @@
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:3617: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:3641: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3621,7 +3645,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3625 "configure"
+#line 3649 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3632,7 +3656,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:3636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3661,12 +3685,12 @@
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:3665: checking for gethostbyname" >&5
+echo "configure:3689: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3670 "configure"
+#line 3694 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -3689,7 +3713,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3693: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -3710,7 +3734,7 @@
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:3714: checking for gethostbyname in -lnsl" >&5
+echo "configure:3738: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3718,7 +3742,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3722 "configure"
+#line 3746 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3729,7 +3753,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:3733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3759,12 +3783,12 @@
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:3763: checking for connect" >&5
+echo "configure:3787: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3768 "configure"
+#line 3792 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -3787,7 +3811,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3815: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -3808,7 +3832,7 @@
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:3812: checking for connect in -lsocket" >&5
+echo "configure:3836: checking for connect in -lsocket" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3816,7 +3840,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3820 "configure"
+#line 3844 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3827,7 +3851,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:3831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3851,12 +3875,12 @@
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:3855: checking for remove" >&5
+echo "configure:3879: checking for remove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3860 "configure"
+#line 3884 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -3879,7 +3903,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3883: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3907: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -3900,7 +3924,7 @@
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:3904: checking for remove in -lposix" >&5
+echo "configure:3928: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3908,7 +3932,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3912 "configure"
+#line 3936 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3919,7 +3943,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:3923: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3947: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3943,12 +3967,12 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:3947: checking for shmat" >&5
+echo "configure:3971: checking for shmat" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3952 "configure"
+#line 3976 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -3971,7 +3995,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -3992,7 +4016,7 @@
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:3996: checking for shmat in -lipc" >&5
+echo "configure:4020: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4000,7 +4024,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4004 "configure"
+#line 4028 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4011,7 +4035,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:4015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4044,7 +4068,7 @@
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:4048: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:4072: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4052,7 +4076,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lICE $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4056 "configure"
+#line 4080 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4063,7 +4087,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:4067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4090,7 +4114,7 @@
 	LDFLAGS="$LDFLAGS $X_LIBS"
 	CFLAGS="$CFLAGS $X_CFLAGS"
 	echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6
-echo "configure:4094: checking for XOpenDisplay in -lX11" >&5
+echo "configure:4118: checking for XOpenDisplay in -lX11" >&5
 ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4098,7 +4122,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4102 "configure"
+#line 4126 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4109,7 +4133,7 @@
 XOpenDisplay()
 ; return 0; }
 EOF
-if { (eval echo configure:4113: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4130,7 +4154,7 @@
 fi
 
 	echo $ac_n "checking for XtAppInitialize in -lXt""... $ac_c" 1>&6
-echo "configure:4134: checking for XtAppInitialize in -lXt" >&5
+echo "configure:4158: checking for XtAppInitialize in -lXt" >&5
 ac_lib_var=`echo Xt'_'XtAppInitialize | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4138,7 +4162,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4142 "configure"
+#line 4166 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4149,7 +4173,7 @@
 XtAppInitialize()
 ; return 0; }
 EOF
-if { (eval echo configure:4153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4206,17 +4230,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4210: checking for $ac_hdr" >&5
+echo "configure:4234: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4215 "configure"
+#line 4239 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4220: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4244: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4264,7 +4288,7 @@
 
 
 echo $ac_n "checking for XextCreateExtension in -lXext""... $ac_c" 1>&6
-echo "configure:4268: checking for XextCreateExtension in -lXext" >&5
+echo "configure:4292: checking for XextCreateExtension in -lXext" >&5
 ac_lib_var=`echo Xext'_'XextCreateExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4272,7 +4296,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXext  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4276 "configure"
+#line 4300 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4283,7 +4307,7 @@
 XextCreateExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:4287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4310,22 +4334,23 @@
 for cf_path in default \
 	/usr/contrib/X11R6 \
 	/usr/contrib/X11R5 \
-	/usr/lib/X11R5
+	/usr/lib/X11R5 \
+	/usr/local
 do
 
 	if test -z "$cf_x_athena_include" ; then
-		cf_save="$CFLAGS"
+		cf_save="$CPPFLAGS"
 		cf_test=X11/$cf_x_athena/SimpleMenu.h
 		if test $cf_path != default ; then
-			CFLAGS="-I$cf_path/include $cf_save"
+			CPPFLAGS="-I$cf_path/include $cf_save"
 			echo $ac_n "checking for $cf_test in $cf_path""... $ac_c" 1>&6
-echo "configure:4323: checking for $cf_test in $cf_path" >&5
+echo "configure:4348: checking for $cf_test in $cf_path" >&5
 		else
 			echo $ac_n "checking for $cf_test""... $ac_c" 1>&6
-echo "configure:4326: checking for $cf_test" >&5
+echo "configure:4351: checking for $cf_test" >&5
 		fi
 		cat > conftest.$ac_ext <<EOF
-#line 4329 "configure"
+#line 4354 "configure"
 #include "confdefs.h"
 
 #include <X11/Intrinsic.h>
@@ -4334,7 +4359,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4338: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4363: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_result=yes
 else
@@ -4348,7 +4373,7 @@
 		if test "$cf_result" = yes ; then
 			cf_x_athena_include=$cf_path
 		else
-			CFLAGS="$cf_save"
+			CPPFLAGS="$cf_save"
 		fi
 	fi
 
@@ -4360,21 +4385,21 @@
 			if test $cf_path != default ; then
 				LIBS="-L$cf_path/lib $cf_lib $LIBS"
 				echo $ac_n "checking for $cf_lib in $cf_path""... $ac_c" 1>&6
-echo "configure:4364: checking for $cf_lib in $cf_path" >&5
+echo "configure:4389: checking for $cf_lib in $cf_path" >&5
 			else
 				LIBS="$cf_lib $LIBS"
 				echo $ac_n "checking for $cf_test in $cf_lib""... $ac_c" 1>&6
-echo "configure:4368: checking for $cf_test in $cf_lib" >&5
+echo "configure:4393: checking for $cf_test in $cf_lib" >&5
 			fi
 			cat > conftest.$ac_ext <<EOF
-#line 4371 "configure"
+#line 4396 "configure"
 #include "confdefs.h"
 
 int main() {
 $cf_test()
 ; return 0; }
 EOF
-if { (eval echo configure:4378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4403: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_result=yes
 else
@@ -4403,7 +4428,7 @@
 fi
 
 
-CF_X_ATHENA_LIBS=`echo HAVE_LIB_$cf_x_athena | tr '[a-z]' '[A-Z]'`
+CF_X_ATHENA_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
 cat >> confdefs.h <<EOF
 #define $CF_X_ATHENA_LIBS 1
@@ -4412,13 +4437,13 @@
 
 
 echo $ac_n "checking for declaration of fd_set""... $ac_c" 1>&6
-echo "configure:4416: checking for declaration of fd_set" >&5
+echo "configure:4441: checking for declaration of fd_set" >&5
 if eval "test \"`echo '$''{'cf_cv_type_fd_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   echo "trying sys/types alone" 1>&5
 cat > conftest.$ac_ext <<EOF
-#line 4422 "configure"
+#line 4447 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -4426,7 +4451,7 @@
 fd_set x
 ; return 0; }
 EOF
-if { (eval echo configure:4430: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4455: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_type_fd_set=sys/types.h
 else
@@ -4435,7 +4460,7 @@
   rm -rf conftest*
   echo "trying X11/Xpoll.h" 1>&5
 cat > conftest.$ac_ext <<EOF
-#line 4439 "configure"
+#line 4464 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_X11_XPOLL_H
@@ -4445,7 +4470,7 @@
 fd_set x
 ; return 0; }
 EOF
-if { (eval echo configure:4449: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4474: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_type_fd_set=X11/Xpoll.h
 else
@@ -4454,7 +4479,7 @@
   rm -rf conftest*
   echo "trying sys/select.h" 1>&5
 cat > conftest.$ac_ext <<EOF
-#line 4458 "configure"
+#line 4483 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -4463,7 +4488,7 @@
 fd_set x
 ; return 0; }
 EOF
-if { (eval echo configure:4467: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4492: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_type_fd_set=sys/select.h
 else
@@ -4489,13 +4514,13 @@
 
 
 echo $ac_n "checking for IRIX 6.5 baud-rate redefinitions""... $ac_c" 1>&6
-echo "configure:4493: checking for IRIX 6.5 baud-rate redefinitions" >&5
+echo "configure:4518: checking for IRIX 6.5 baud-rate redefinitions" >&5
 if eval "test \"`echo '$''{'cf_cv_termio_c_ispeed'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 4499 "configure"
+#line 4524 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -4508,7 +4533,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4512: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4537: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_termio_c_ispeed=yes
 
@@ -4538,12 +4563,12 @@
 for ac_func in grantpt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4542: checking for $ac_func" >&5
+echo "configure:4567: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4547 "configure"
+#line 4572 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4566,7 +4591,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4570: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4588,7 +4613,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for openpty in -lutil""... $ac_c" 1>&6
-echo "configure:4592: checking for openpty in -lutil" >&5
+echo "configure:4617: checking for openpty in -lutil" >&5
 ac_lib_var=`echo util'_'openpty | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4596,7 +4621,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lutil  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4600 "configure"
+#line 4625 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4607,7 +4632,7 @@
 openpty()
 ; return 0; }
 EOF
-if { (eval echo configure:4611: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4641,7 +4666,7 @@
 # Extract the first word of "xterm", so it can be a program name with args.
 set dummy xterm; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4645: checking for $ac_word" >&5
+echo "configure:4670: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_XTERM_PATH'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4679,12 +4704,12 @@
 	
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4683: checking for $ac_func" >&5
+echo "configure:4708: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4688 "configure"
+#line 4713 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4707,7 +4732,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4733,7 +4758,7 @@
 
 
 echo $ac_n "checking if we should use imake to help""... $ac_c" 1>&6
-echo "configure:4737: checking if we should use imake to help" >&5
+echo "configure:4762: checking if we should use imake to help" >&5
 
 # Check whether --enable-imake or --disable-imake was given.
 if test "${enable_imake+set}" = set; then
@@ -4758,7 +4783,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4762: checking for $ac_word" >&5
+echo "configure:4787: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_IMAKE'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4897,7 +4922,7 @@
 
 
 echo $ac_n "checking for default terminal-id""... $ac_c" 1>&6
-echo "configure:4901: checking for default terminal-id" >&5
+echo "configure:4926: checking for default terminal-id" >&5
 
 # Check whether --with-terminal-id or --without-terminal-id was given.
 if test "${with_terminal_id+set}" = set; then
@@ -4918,7 +4943,7 @@
 
 
 echo $ac_n "checking for default terminal-type""... $ac_c" 1>&6
-echo "configure:4922: checking for default terminal-type" >&5
+echo "configure:4947: checking for default terminal-type" >&5
 
 # Check whether --with-terminal-type or --without-terminal-type was given.
 if test "${with_terminal_type+set}" = set; then
@@ -4935,7 +4960,7 @@
 
 
 echo $ac_n "checking for private terminfo-directory""... $ac_c" 1>&6
-echo "configure:4939: checking for private terminfo-directory" >&5
+echo "configure:4964: checking for private terminfo-directory" >&5
 
 # Check whether --with-own-terminfo or --without-own-terminfo was given.
 if test "${with_own_terminfo+set}" = set; then
@@ -4972,9 +4997,11 @@
 
 
 
-###	checks for optional features
+###############################################################################
+
+
 echo $ac_n "checking if you want active-icons""... $ac_c" 1>&6
-echo "configure:4978: checking if you want active-icons" >&5
+echo "configure:5005: checking if you want active-icons" >&5
 
 # Check whether --enable-active-icon or --disable-active-icon was given.
 if test "${enable_active_icon+set}" = set; then
@@ -5000,7 +5027,7 @@
 fi
 
 echo $ac_n "checking if you want ANSI color""... $ac_c" 1>&6
-echo "configure:5004: checking if you want ANSI color" >&5
+echo "configure:5031: checking if you want ANSI color" >&5
 
 # Check whether --enable-ansi-color or --disable-ansi-color was given.
 if test "${enable_ansi_color+set}" = set; then
@@ -5026,7 +5053,7 @@
 if test $enable_ansi_color = yes ; then
 
 	echo $ac_n "checking if you want 16 colors like aixterm""... $ac_c" 1>&6
-echo "configure:5030: checking if you want 16 colors like aixterm" >&5
+echo "configure:5057: checking if you want 16 colors like aixterm" >&5
 	
 # Check whether --enable-16-color or --disable-16-color was given.
 if test "${enable_16_color+set}" = set; then
@@ -5050,7 +5077,7 @@
 
 
 	echo $ac_n "checking if you want 256 colors""... $ac_c" 1>&6
-echo "configure:5054: checking if you want 256 colors" >&5
+echo "configure:5081: checking if you want 256 colors" >&5
 	
 # Check whether --enable-256-color or --disable-256-color was given.
 if test "${enable_256_color+set}" = set; then
@@ -5077,7 +5104,7 @@
 
 	else
 	echo $ac_n "checking if you want 88 colors""... $ac_c" 1>&6
-echo "configure:5081: checking if you want 88 colors" >&5
+echo "configure:5108: checking if you want 88 colors" >&5
 	
 # Check whether --enable-88-color or --disable-88-color was given.
 if test "${enable_88_color+set}" = set; then
@@ -5108,7 +5135,7 @@
 fi
 
 echo $ac_n "checking if you want blinking cursor""... $ac_c" 1>&6
-echo "configure:5112: checking if you want blinking cursor" >&5
+echo "configure:5139: checking if you want blinking cursor" >&5
 
 # Check whether --enable-blink-cursor or --disable-blink-cursor was given.
 if test "${enable_blink_cursor+set}" = set; then
@@ -5134,7 +5161,7 @@
 if test $enable_ansi_color = yes ; then
 
 	echo $ac_n "checking if you want bold colors mapped like IBM PC""... $ac_c" 1>&6
-echo "configure:5138: checking if you want bold colors mapped like IBM PC" >&5
+echo "configure:5165: checking if you want bold colors mapped like IBM PC" >&5
 	
 # Check whether --enable-bold-color or --disable-bold-color was given.
 if test "${enable_bold_color+set}" = set; then
@@ -5158,7 +5185,7 @@
 
 
 	echo $ac_n "checking if you want color-mode enabled by default""... $ac_c" 1>&6
-echo "configure:5162: checking if you want color-mode enabled by default" >&5
+echo "configure:5189: checking if you want color-mode enabled by default" >&5
 	
 # Check whether --enable-color-mode or --disable-color-mode was given.
 if test "${enable_color_mode+set}" = set; then
@@ -5184,7 +5211,7 @@
 fi
 
 echo $ac_n "checking if you want support for color highlighting""... $ac_c" 1>&6
-echo "configure:5188: checking if you want support for color highlighting" >&5
+echo "configure:5215: checking if you want support for color highlighting" >&5
 
 # Check whether --enable-highlighting or --disable-highlighting was given.
 if test "${enable_highlighting+set}" = set; then
@@ -5208,7 +5235,7 @@
 
 
 echo $ac_n "checking if you want support for doublesize characters""... $ac_c" 1>&6
-echo "configure:5212: checking if you want support for doublesize characters" >&5
+echo "configure:5239: checking if you want support for doublesize characters" >&5
 
 # Check whether --enable-doublechars or --disable-doublechars was given.
 if test "${enable_doublechars+set}" = set; then
@@ -5232,7 +5259,7 @@
 
 
 echo $ac_n "checking if you want fallback-support for box characters""... $ac_c" 1>&6
-echo "configure:5236: checking if you want fallback-support for box characters" >&5
+echo "configure:5263: checking if you want fallback-support for box characters" >&5
 
 # Check whether --enable-boxchars or --disable-boxchars was given.
 if test "${enable_boxchars+set}" = set; then
@@ -5256,7 +5283,7 @@
 
 
 echo $ac_n "checking if you want support for HP-style function keys""... $ac_c" 1>&6
-echo "configure:5260: checking if you want support for HP-style function keys" >&5
+echo "configure:5287: checking if you want support for HP-style function keys" >&5
 
 # Check whether --enable-hp-fkeys or --disable-hp-fkeys was given.
 if test "${enable_hp_fkeys+set}" = set; then
@@ -5282,7 +5309,7 @@
 fi
 
 echo $ac_n "checking if you want support for SCO-style function keys""... $ac_c" 1>&6
-echo "configure:5286: checking if you want support for SCO-style function keys" >&5
+echo "configure:5313: checking if you want support for SCO-style function keys" >&5
 
 # Check whether --enable-sco-fkeys or --disable-sco-fkeys was given.
 if test "${enable_sco_fkeys+set}" = set; then
@@ -5308,7 +5335,7 @@
 fi
 
 echo $ac_n "checking if you want support for internationalization""... $ac_c" 1>&6
-echo "configure:5312: checking if you want support for internationalization" >&5
+echo "configure:5339: checking if you want support for internationalization" >&5
 
 # Check whether --enable-i18n or --disable-i18n was given.
 if test "${enable_i18n+set}" = set; then
@@ -5334,7 +5361,7 @@
 fi
 
 echo $ac_n "checking if you want support for initial-erase setup""... $ac_c" 1>&6
-echo "configure:5338: checking if you want support for initial-erase setup" >&5
+echo "configure:5365: checking if you want support for initial-erase setup" >&5
 
 # Check whether --enable-initial-erase or --disable-initial-erase was given.
 if test "${enable_initial_erase+set}" = set; then
@@ -5360,7 +5387,7 @@
 fi
 
 echo $ac_n "checking if you want support for input-method""... $ac_c" 1>&6
-echo "configure:5364: checking if you want support for input-method" >&5
+echo "configure:5391: checking if you want support for input-method" >&5
 
 # Check whether --enable-input-method or --disable-input-method was given.
 if test "${enable_input_method+set}" = set; then
@@ -5380,13 +5407,13 @@
 echo "$ac_t""$enable_ximp" 1>&6
 
 echo $ac_n "checking if X libraries support input-method""... $ac_c" 1>&6
-echo "configure:5384: checking if X libraries support input-method" >&5
+echo "configure:5411: checking if X libraries support input-method" >&5
 if eval "test \"`echo '$''{'cf_cv_input_method'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 5390 "configure"
+#line 5417 "configure"
 #include "confdefs.h"
 
 #include <X11/IntrinsicP.h>
@@ -5413,7 +5440,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_cv_input_method=yes
 else
@@ -5436,7 +5463,7 @@
 fi
 
 echo $ac_n "checking if you want support for logging""... $ac_c" 1>&6
-echo "configure:5440: checking if you want support for logging" >&5
+echo "configure:5467: checking if you want support for logging" >&5
 
 # Check whether --enable-logging or --disable-logging was given.
 if test "${enable_logging+set}" = set; then
@@ -5460,7 +5487,7 @@
 EOF
 
 	echo $ac_n "checking if you want to allow logging via a pipe""... $ac_c" 1>&6
-echo "configure:5464: checking if you want to allow logging via a pipe" >&5
+echo "configure:5491: checking if you want to allow logging via a pipe" >&5
 	
 # Check whether --enable-logfile-exec or --disable-logfile-exec was given.
 if test "${enable_logfile_exec+set}" = set; then
@@ -5487,7 +5514,7 @@
 fi
 
 echo $ac_n "checking if you want support for iconify/maximize translations""... $ac_c" 1>&6
-echo "configure:5491: checking if you want support for iconify/maximize translations" >&5
+echo "configure:5518: checking if you want support for iconify/maximize translations" >&5
 
 # Check whether --enable-maximize or --disable-maximize was given.
 if test "${enable_maximize+set}" = set; then
@@ -5511,7 +5538,7 @@
 
 
 echo $ac_n "checking if you want NumLock to override keyboard tables""... $ac_c" 1>&6
-echo "configure:5515: checking if you want NumLock to override keyboard tables" >&5
+echo "configure:5542: checking if you want NumLock to override keyboard tables" >&5
 
 # Check whether --enable-num-lock or --disable-num-lock was given.
 if test "${enable_num_lock+set}" = set; then
@@ -5535,7 +5562,7 @@
 
 
 echo $ac_n "checking if you want support for right-scrollbar""... $ac_c" 1>&6
-echo "configure:5539: checking if you want support for right-scrollbar" >&5
+echo "configure:5566: checking if you want support for right-scrollbar" >&5
 
 # Check whether --enable-rightbar or --disable-rightbar was given.
 if test "${enable_rightbar+set}" = set; then
@@ -5561,7 +5588,7 @@
 fi
 
 echo $ac_n "checking if you want check for redundant name-change""... $ac_c" 1>&6
-echo "configure:5565: checking if you want check for redundant name-change" >&5
+echo "configure:5592: checking if you want check for redundant name-change" >&5
 
 # Check whether --enable-samename or --disable-samename was given.
 if test "${enable_samename+set}" = set; then
@@ -5584,8 +5611,32 @@
 EOF
 
 
+echo $ac_n "checking if you want to use termcap-query/report""... $ac_c" 1>&6
+echo "configure:5616: checking if you want to use termcap-query/report" >&5
+
+# Check whether --enable-tcap-query or --disable-tcap-query was given.
+if test "${enable_tcap_query+set}" = set; then
+  enableval="$enable_tcap_query"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_tcap_query=yes 
+  else
+    enable_tcap_query=no
+  fi
+else
+  enableval=no 
+  enable_tcap_query=no
+  
+fi
+
+echo "$ac_t""$enable_tcap_query" 1>&6
+test $enable_tcap_query = yes && cat >> confdefs.h <<\EOF
+#define OPT_TCAP_QUERY 1
+EOF
+
+
 echo $ac_n "checking if you want support for tek4014""... $ac_c" 1>&6
-echo "configure:5589: checking if you want support for tek4014" >&5
+echo "configure:5640: checking if you want support for tek4014" >&5
 
 # Check whether --enable-tek4014 or --disable-tek4014 was given.
 if test "${enable_tek4014+set}" = set; then
@@ -5615,7 +5666,7 @@
 fi
 
 echo $ac_n "checking if you want pulldown menus with a toolbar""... $ac_c" 1>&6
-echo "configure:5619: checking if you want pulldown menus with a toolbar" >&5
+echo "configure:5670: checking if you want pulldown menus with a toolbar" >&5
 
 # Check whether --enable-toolbar or --disable-toolbar was given.
 if test "${enable_toolbar+set}" = set; then
@@ -5639,7 +5690,7 @@
 
 
 echo $ac_n "checking if you want VT52 emulation""... $ac_c" 1>&6
-echo "configure:5643: checking if you want VT52 emulation" >&5
+echo "configure:5694: checking if you want VT52 emulation" >&5
 
 # Check whether --enable-vt52 or --disable-vt52 was given.
 if test "${enable_vt52+set}" = set; then
@@ -5663,7 +5714,7 @@
 
 
 echo $ac_n "checking if you want wide-character support""... $ac_c" 1>&6
-echo "configure:5667: checking if you want wide-character support" >&5
+echo "configure:5718: checking if you want wide-character support" >&5
 
 # Check whether --enable-wide-chars or --disable-wide-chars was given.
 if test "${enable_wide_chars+set}" = set; then
@@ -5686,13 +5737,13 @@
 #define OPT_WIDE_CHARS 1
 EOF
 
-	EXTRAHDRS="$EXTRAHDRS keysym2ucs.h"
-	EXTRASRCS="$EXTRASRCS keysym2ucs.c"
-	EXTRAOBJS="$EXTRAOBJS keysym2ucs.o"
+	EXTRAHDRS="$EXTRAHDRS charclass.h keysym2ucs.h precompose.h wcwidth.h"
+	EXTRASRCS="$EXTRASRCS charclass.c keysym2ucs.c precompose.c wcwidth.c"
+	EXTRAOBJS="$EXTRAOBJS charclass.o keysym2ucs.o precompose.o wcwidth.o"
 fi
 
 echo $ac_n "checking if you want DECterm Locator support""... $ac_c" 1>&6
-echo "configure:5696: checking if you want DECterm Locator support" >&5
+echo "configure:5747: checking if you want DECterm Locator support" >&5
 
 # Check whether --enable-dec-locator or --disable-dec-locator was given.
 if test "${enable_dec_locator+set}" = set; then
@@ -5718,7 +5769,7 @@
 fi
 
 echo $ac_n "checking if you want -ziconbeep option""... $ac_c" 1>&6
-echo "configure:5722: checking if you want -ziconbeep option" >&5
+echo "configure:5773: checking if you want -ziconbeep option" >&5
 
 # Check whether --enable-ziconbeep or --disable-ziconbeep was given.
 if test "${enable_ziconbeep+set}" = set; then
@@ -5740,10 +5791,12 @@
 #define OPT_ZICONBEEP 0
 EOF
 
+
+###############################################################################
+
 
-# development/testing aids
 echo $ac_n "checking if you want debugging traces""... $ac_c" 1>&6
-echo "configure:5747: checking if you want debugging traces" >&5
+echo "configure:5800: checking if you want debugging traces" >&5
 
 # Check whether --enable-trace or --disable-trace was given.
 if test "${enable_trace+set}" = set; then
@@ -5772,7 +5825,7 @@
 
 
 echo $ac_n "checking if you want to see long compiling messages""... $ac_c" 1>&6
-echo "configure:5776: checking if you want to see long compiling messages" >&5
+echo "configure:5829: checking if you want to see long compiling messages" >&5
 
 # Check whether --enable-echo or --disable-echo was given.
 if test "${enable_echo+set}" = set; then
@@ -5812,7 +5865,7 @@
 
 
 echo $ac_n "checking if you want magic cookie emulation""... $ac_c" 1>&6
-echo "configure:5816: checking if you want magic cookie emulation" >&5
+echo "configure:5869: checking if you want magic cookie emulation" >&5
 
 # Check whether --enable-xmc-glitch or --disable-xmc-glitch was given.
 if test "${enable_xmc_glitch+set}" = set; then
@@ -5841,7 +5894,7 @@
 
 if test -n "$GCC" ; then
 echo $ac_n "checking if you want to turn on gcc warnings""... $ac_c" 1>&6
-echo "configure:5845: checking if you want to turn on gcc warnings" >&5
+echo "configure:5898: checking if you want to turn on gcc warnings" >&5
 
 # Check whether --enable-warnings or --disable-warnings was given.
 if test "${enable_warnings+set}" = set; then
@@ -5862,7 +5915,7 @@
 if test "$with_warnings" = yes
 then
 	
-if test -n "$GCC"
+if test "$GCC" = yes
 then
 cat > conftest.i <<EOF
 #ifndef GCC_PRINTF
@@ -5878,12 +5931,12 @@
 #define GCC_UNUSED /* nothing */
 #endif
 EOF
-if test -n "$GCC"
+if test "$GCC" = yes
 then
 	echo "checking for $CC __attribute__ directives" 1>&6
-echo "configure:5885: checking for $CC __attribute__ directives" >&5
+echo "configure:5938: checking for $CC __attribute__ directives" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 5887 "configure"
+#line 5940 "configure"
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -5905,7 +5958,7 @@
 		for cf_attribute in scanf printf unused noreturn
 	do
 		
-CF_ATTRIBUTE=`echo $cf_attribute | tr '[a-z]' '[A-Z]'`
+CF_ATTRIBUTE=`echo "$cf_attribute" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
 
 		cf_directive="__attribute__(($cf_attribute))"
 		echo "checking for $CC $cf_directive" 1>&5
@@ -5921,7 +5974,7 @@
 EOF
 			;;
 		esac
-		if { (eval echo configure:5925: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+		if { (eval echo configure:5978: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
 			test -n "$verbose" && echo "$ac_t""... $cf_attribute" 1>&6
 			cat conftest.h >>confdefs.h
 #		else
@@ -5935,14 +5988,14 @@
 fi
 
 	
-if test -n "$GCC"
+if test "$GCC" = yes
 then
 		cat > conftest.$ac_ext <<EOF
-#line 5942 "configure"
+#line 5995 "configure"
 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
 EOF
 		echo "checking for $CC warning options" 1>&6
-echo "configure:5946: checking for $CC warning options" >&5
+echo "configure:5999: checking for $CC warning options" >&5
 	cf_save_CFLAGS="$CFLAGS"
 	EXTRA_CFLAGS="-W -Wall"
 	cf_warn_CONST=""
@@ -5960,7 +6013,7 @@
 		Wstrict-prototypes $cf_warn_CONST
 	do
 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
-		if { (eval echo configure:5964: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+		if { (eval echo configure:6017: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
 			test -n "$verbose" && echo "$ac_t""... -$cf_opt" 1>&6
 			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
 			test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
@@ -6079,7 +6132,7 @@
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.13.19990117"
+    echo "$CONFIG_STATUS generated by autoconf version 2.13.20000819"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
Index: xc/programs/xterm/configure.in
diff -u xc/programs/xterm/configure.in:3.41 xc/programs/xterm/configure.in:3.44
--- xc/programs/xterm/configure.in:3.41	Mon Jun 12 22:28:39 2000
+++ xc/programs/xterm/configure.in	Tue Oct 31 20:12:38 2000
@@ -1,5 +1,5 @@
 dnl
-dnl $XFree86: xc/programs/xterm/configure.in,v 3.41 2000/06/13 02:28:39 dawes Exp $
+dnl $XFree86: xc/programs/xterm/configure.in,v 3.44 2000/11/01 01:12:38 dawes Exp $
 dnl
 dnl ---------------------------------------------------------------------------
 dnl
@@ -27,12 +27,21 @@
 dnl ---------------------------------------------------------------------------
 dnl Process this file with autoconf to produce a configure script.
 dnl
-AC_PREREQ(2.13.19990117)
+AC_PREREQ(2.13.20000819)
 AC_INIT(charproc.c)
 AC_CONFIG_HEADER(xtermcfg.h:xtermcfg.hin)
 CF_CHECK_CACHE
 
 ###	checks for alternative programs
+
+dnl Only add to this case statement when a system has a compiler that is not
+dnl detected by AC_PROG_CC.
+case "$host_os" in
+openedition)	: ${CFLAGS="-O2 -Wc,dll -D_ALL_SOURCE -Wl,EDIT=NO"}
+		: ${LIBS="/usr/lib/Xaw.x /usr/lib/SM.x /usr/lib/ICE.x /usr/lib/X11.x"}
+		: ${CC=c89};;
+esac
+
 AC_PROG_CC
 AC_PROG_CPP
 AC_GCC_TRADITIONAL
@@ -190,7 +199,9 @@
 AC_SUBST(TERMINFO_DIR)
 AC_SUBST(SET_TERMINFO)
 
-###	checks for optional features
+###############################################################################
+CF_HELP_MESSAGE(Optional Features:)
+
 AC_MSG_CHECKING(if you want active-icons)
 CF_ARG_DISABLE(active-icon,
 	[  --disable-active-icon   disable X11R6.3 active-icon feature],
@@ -402,6 +413,14 @@
 AC_MSG_RESULT($enable_samename)
 test $enable_samename = no && AC_DEFINE(OPT_SAME_NAME,0)
 
+AC_MSG_CHECKING(if you want to use termcap-query/report)
+CF_ARG_ENABLE(tcap-query,
+	[  --enable-tcap-query     compile-in termcap-query support],
+	[enable_tcap_query=yes],
+	[enable_tcap_query=no])
+AC_MSG_RESULT($enable_tcap_query)
+test $enable_tcap_query = yes && AC_DEFINE(OPT_TCAP_QUERY,1)
+
 AC_MSG_CHECKING(if you want support for tek4014)
 CF_ARG_DISABLE(tek4014,
 	[  --disable-tek4014       disable tek4014 emulation],
@@ -440,9 +459,9 @@
 AC_MSG_RESULT($enable_wchar)
 if test $enable_wchar = yes ; then
 	AC_DEFINE(OPT_WIDE_CHARS,1)
-	EXTRAHDRS="$EXTRAHDRS keysym2ucs.h"
-	EXTRASRCS="$EXTRASRCS keysym2ucs.c"
-	EXTRAOBJS="$EXTRAOBJS keysym2ucs.o"
+	EXTRAHDRS="$EXTRAHDRS charclass.h keysym2ucs.h precompose.h wcwidth.h"
+	EXTRASRCS="$EXTRASRCS charclass.c keysym2ucs.c precompose.c wcwidth.c"
+	EXTRAOBJS="$EXTRAOBJS charclass.o keysym2ucs.o precompose.o wcwidth.o"
 fi
 
 AC_MSG_CHECKING(if you want DECterm Locator support)
@@ -462,8 +481,10 @@
 	[enable_ziconbeep=yes])
 AC_MSG_RESULT($enable_ziconbeep)
 test $enable_ziconbeep = no && AC_DEFINE(OPT_ZICONBEEP,0)
+
+###############################################################################
+CF_HELP_MESSAGE(Testing/development Options:)
 
-# development/testing aids
 AC_MSG_CHECKING(if you want debugging traces)
 CF_ARG_ENABLE(trace,
 	[  --enable-trace          test: set to enable debugging traces],
Index: xc/programs/xterm/data.c
diff -u xc/programs/xterm/data.c:3.19 xc/programs/xterm/data.c:3.20
--- xc/programs/xterm/data.c:3.19	Thu Feb 10 13:57:38 2000
+++ xc/programs/xterm/data.c	Fri Sep 22 06:42:07 2000
@@ -1,6 +1,6 @@
 /*
  *	$XConsortium: data.c,v 1.12 95/04/05 19:58:47 kaleb Exp $
- *	$XFree86: xc/programs/xterm/data.c,v 3.19 2000/02/10 18:57:38 dawes Exp $
+ *	$XFree86: xc/programs/xterm/data.c,v 3.20 2000/09/22 10:42:07 alanh Exp $
  */
 
 /*
@@ -26,10 +26,6 @@
  * SOFTWARE.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <xtermcfg.h>
-#endif
-
 #include <ptyx.h>		/* gets Xt stuff, too */
 #include <data.h>
 
@@ -68,12 +64,12 @@
 #endif /* OPT_ZICONBEEP */
 
 #if OPT_SAME_NAME
-Boolean sameName;            /* Don't change the title or icon name if it
+Boolean sameName;	/* Don't change the title or icon name if it
 			is the same.  This prevents flicker on the screen at
 			the cost of an extra request to the server */
 #endif
 
-int am_slave = 0;	/* set to 1 if running as a slave process */
+int am_slave = -1;	/* set to file-descriptor if we're a slave process */
 int max_plus1;
 #ifdef VMS
 int Select_mask;
Index: xc/programs/xterm/fontutils.c
diff -u xc/programs/xterm/fontutils.c:1.18 xc/programs/xterm/fontutils.c:1.27
--- xc/programs/xterm/fontutils.c:1.18	Fri Jun 16 20:27:35 2000
+++ xc/programs/xterm/fontutils.c	Sun Dec  3 14:09:26 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/xterm/fontutils.c,v 1.18 2000/06/17 00:27:35 dawes Exp $
+ * $XFree86: xc/programs/xterm/fontutils.c,v 1.27 2000/12/03 19:09:26 keithp Exp $
  */
 
 /************************************************************
@@ -92,14 +92,20 @@
 typedef struct {
      /* registry, foundry, family */
      char *beginning;
-     char *width;
-     /* slant, width, add_style */
-     char *middle;
+     /* weight */
+     char *weight;
+     /* slant */
+     char *slant;
+     /* wideness */
+     char *wideness;
+     /* add style */
+     char *add_style;
      int pixel_size;
      char *point_size;
      int res_x;
      int res_y;
      char *spacing;
+     int average_width;
      /* charset registry, charset encoding */
      char *end;
 } FontNameProperties;
@@ -196,13 +202,21 @@
 		return 0;
 
 	/* weight is the next */
-	if ((props.width = n_fields(&name, 1, 1)) == 0)
+	if ((props.weight = n_fields(&name, 1, 1)) == 0)
 		return 0;
 
-	/* slant, width, add style */
-	if ((props.middle = n_fields(&name, 1, 3)) == 0)
+	/* slant */
+	if ((props.slant = n_fields(&name, 1, 1)) == 0)
 		return 0;
 
+	/* width */
+	if ((props.wideness = n_fields(&name, 1, 1)) == 0)
+		return 0;
+
+	/* add style */
+	if ((props.add_style = n_fields(&name, 1, 1)) == 0)
+		return 0;
+
 	/* pixel size */
 	if ((str = n_fields(&name, 1, 1)) == 0)
 		return 0;
@@ -229,9 +243,11 @@
 	if ((props.spacing = n_fields(&name, 1, 1)) == 0)
 		return 0;
 
-	/* skip the average width */
+	/* average width */
 	if ((str = n_fields(&name, 1, 1)) == 0)
 		return 0;
+	if ((props.average_width = atoi(str)) == 0)
+		return 0;
 
 	/* the rest: charset registry and charset encoding */
 	props.end = name;
@@ -253,19 +269,48 @@
       * Put together something in the form
       * "<beginning>-bold-<middle>-<pixel_size>-<point_size>-<res_x>-<res_y>"\
       * "-<spacing>-*-<end>"
+      */
+     sprintf(ret, "%s-bold-%s-%s-%s-%d-%s-%d-%d-%s-*-%s",
+	     props->beginning,
+	     props->slant,
+	     props->wideness,
+	     props->add_style,
+	     props->pixel_size,
+	     props->point_size,
+	     props->res_x,
+	     props->res_y,
+	     props->spacing,
+	     props->end);
+     return ret;
+}
+
+#if OPT_WIDE_CHARS
+/* like bold_font_name, but doubles AVERAGE_WIDTH */
+static char *
+wide_font_name(FontNameProperties *props)
+{
+     static char ret[MAX_FONTNAME];
+
+     /*
+      * Put together something in the form
+      * "<beginning>-bold-<middle>-<pixel_size>-<point_size>-<res_x>-<res_y>"\
+      * "-<spacing>-*-<end>"
       */
-     sprintf(ret, "%s-bold-%s-%d-%s-%d-%d-%s-*-%s",
+     sprintf(ret, "%s-%s-%s-*-*-%d-%s-%d-%d-%s-%i-%s",
 	     props->beginning,
-	     props->middle,
+	     props->weight,
+	     props->slant,
 	     props->pixel_size,
 	     props->point_size,
 	     props->res_x,
 	     props->res_y,
 	     props->spacing,
+	     props->average_width * 2,
 	     props->end);
 
      return ret;
 }
+#endif /* OPT_WIDE_CHARS */
 
 #if OPT_DEC_CHRSET
 /*
@@ -301,7 +346,7 @@
 	if (atts & BOLD)
 		width = "bold";
 	else
-		width = props->width;
+		width = props->weight;
 
 	if (CSET_DOUBLE(chrset))
 		res_x *= 2;
@@ -330,10 +375,12 @@
 	}
 #endif
 
-	sprintf(tmp, "%s-%s-%s-%d-%s-%d-%d-%s-*-%s",
+	sprintf(tmp, "%s-%s-%s-%s-%s-%d-%s-%d-%d-%s-*-%s",
 		props->beginning,
 		width,
-		props->middle,
+		props->slant,
+		props->wideness,
+		props->add_style,
 		pixel_size,
 		props->point_size,
 		res_x,
@@ -350,12 +397,17 @@
 
 /*
  * Case-independent comparison for font-names, including wildcards.
+ * XLFD allows '?' as a wildcard, but we do not handle that (no one seems
+ * to use it).
  */
 static Boolean
 same_font_name(char *pattern, char *match)
 {
 	while (*pattern && *match) {
-		if (*pattern == '*') {
+		if (*pattern == *match) {
+			pattern++;
+			match++;
+		} else if (*pattern == '*' || *match == '*') {
 			if (same_font_name(pattern+1, match)) {
 				return True;
 			} else if (same_font_name(pattern, match+1)) {
@@ -384,11 +436,10 @@
 static int
 got_bold_font(Display *dpy, XFontStruct *fs, char *requested)
 {
-	FontNameProperties *fp;
 	char actual[MAX_FONTNAME];
 	int got;
 
-	if ((fp = get_font_name_props(dpy, fs, actual)) == 0)
+	if (get_font_name_props(dpy, fs, actual) == 0)
 		got = 0;
 	else
 		got = same_font_name(requested, actual);
@@ -421,17 +472,18 @@
 	return (fs->min_bounds.width == fs->max_bounds.width
 	   &&   fs->min_bounds.width == fs->min_bounds.width);
 }
+
+#define EmptyFont(fs) (fs != 0 \
+		   && ((fs)->ascent + (fs)->descent == 0 \
+		    || (fs)->max_bounds.width == 0))
 
-#define EmptyFont(fs) ((fs)->ascent + (fs)->descent == 0 \
-		   ||  (fs)->max_bounds.width == 0)
 #define FontSize(fs) (((fs)->ascent + (fs)->descent) \
 		    *  (fs)->max_bounds.width)
 
 int
 xtermLoadFont (
 	TScreen *screen,
-	char *nfontname,
-	char *bfontname,
+	VT_FONTSET(char *nfontname, char *bfontname, char *wfontname, char *wbfontname),
 	Bool doresize,
 	int fontnum)
 {
@@ -439,6 +491,10 @@
 	FontNameProperties *fp;
 	XFontStruct *nfs = NULL;
 	XFontStruct *bfs = NULL;
+#if OPT_WIDE_CHARS
+	XFontStruct *wfs = NULL;
+	XFontStruct *wbfs = NULL;
+#endif
 	XGCValues xgcv;
 	unsigned long mask;
 	GC new_normalGC      = NULL;
@@ -468,6 +524,7 @@
 	if (EmptyFont(nfs))
 		goto bad;		/* can't use a 0-sized font */
 
+
 	strcpy(normal, nfontname);
 	if (bfontname == 0) {
 		fp = get_font_name_props(screen->display, nfs, normal);
@@ -479,8 +536,10 @@
 		 || (bfs = XLoadQueryFont (screen->display, bfontname)) == 0) {
 			bfs = nfs;
 			TRACE(("...cannot load a matching bold font\n"));
-		} else if (!same_font_size(nfs, bfs)
-		 || !got_bold_font(screen->display, bfs, bfontname)) {
+		} else if (same_font_size(nfs, bfs)
+		 && got_bold_font(screen->display, bfs, bfontname)) {
+			TRACE(("...got a matching bold font\n"));
+		} else {
 			XFreeFont(screen->display, bfs);
 			bfs = nfs;
 			TRACE(("...did not get a matching bold font\n"));
@@ -490,6 +549,39 @@
 		TRACE(("...cannot load bold font %s\n", bfontname));
 	}
 
+	/*
+	 * If there is no widefont specified, fake it by doubling AVERAGE_WIDTH
+	 * of normal fonts XLFD, and asking for it.  This plucks out 18x18ja
+	 * and 12x13ja as the corresponding fonts for 9x18 and 6x13.
+	 */
+	if_OPT_WIDE_CHARS(screen, {
+		if (wfontname == 0) {
+			fp = get_font_name_props(screen->display, nfs, normal);
+			if (fp != 0) {
+				wfontname = wide_font_name(fp);
+				TRACE(("...derived wide %s\n", wfontname));
+			}
+		}
+		if (wfontname
+		 && (wfs = XLoadQueryFont(screen->display, wfontname)) == 0) {
+		}
+		if (wbfontname) {
+			wbfs = XLoadQueryFont(screen->display, wbfontname);
+		} else {
+			wbfs = wfs;
+			TRACE(("...cannot load wide bold font %s\n", wbfontname));
+		}
+		if (EmptyFont(wbfs))
+			goto bad;	/* can't use a 0-sized font */
+	})
+
+	/*
+	 * Most of the time this call to load the font will succeed, even if
+	 * there is no wide font :  the X server doubles the width of the
+	 * normal font, or similar.
+	 *
+	 * But if it did fail for some reason, then nevermind.
+	 */
 	if (EmptyFont(bfs))
 		goto bad;		/* can't use a 0-sized font */
 
@@ -507,13 +599,33 @@
 		 */
 		if (bfontname != 0) {
 			return xtermLoadFont (screen,
-					      nfontname,
+					      VT_FONTSET(nfontname,
 					      NULL,	/* throw it away! */
+					      wfontname,
+					      wbfontname),
 					      doresize,
 					      fontnum);
 		}
 	}
 
+	if_OPT_WIDE_CHARS(screen, {
+	  if (!same_font_size(wfs, wbfs)
+	      && (is_fixed_font(wfs) && is_fixed_font(wbfs))) {
+	    XFreeFont(screen->display, wbfs);
+	    wbfs = wfs;
+	    TRACE(("...fixing mismatched normal/bold wide fonts\n"));
+	    if (bfontname != 0) {
+	      return xtermLoadFont (screen,
+				    VT_FONTSET(nfontname,
+					       bfontname,
+					       wfontname,
+					       NULL),
+				    doresize,
+				    fontnum);
+	    }
+	  }
+	})
+
 	/*
 	 * Normal/bold fonts should be the same width.  Also, the min/max
 	 * values should be the same.
@@ -529,6 +641,22 @@
 		proportional = True;
 	}
 
+	if_OPT_WIDE_CHARS(screen, {
+	  if (!is_fixed_font(wfs)
+	      || !is_fixed_font(wbfs)
+	      || wfs->max_bounds.width != wbfs->max_bounds.width) {
+	    TRACE(("Proportional font! wide %d/%d, wide bold %d/%d\n",
+		   wfs->min_bounds.width,
+		   wfs->max_bounds.width,
+		   wbfs->min_bounds.width,
+		   wbfs->max_bounds.width));
+	    proportional = True;
+	  }
+	})
+
+	/* TODO : enforce that the width of the wide font is 2* the width
+	   of the narrow font */
+
 	mask = (GCFont | GCForeground | GCBackground | GCGraphicsExposures |
 	GCFunction);
 
@@ -592,6 +720,10 @@
 
 	screen->fnt_norm = nfs;
 	screen->fnt_bold = bfs;
+#if OPT_WIDE_CHARS
+	screen->fnt_dwd = wfs;
+	screen->fnt_dwdb = wbfs;
+#endif
 	screen->fnt_prop = proportional;
 	screen->fnt_boxes = True;
 
@@ -659,6 +791,12 @@
 		XFreeFont (screen->display, nfs);
 	if (bfs && nfs != bfs)
 		XFreeFont (screen->display, bfs);
+#if OPT_WIDE_CHARS
+	if (wfs)
+		XFreeFont (screen->display, wfs);
+	if (wbfs && wbfs != wfs)
+		XFreeFont (screen->display, wbfs);
+#endif
 	return 0;
 }
 
@@ -685,18 +823,55 @@
 void
 xtermComputeFontInfo (TScreen *screen, struct _vtwin *win, XFontStruct *font, int sbwidth)
 {
-	int i, j, width, height;
+    int i, j, width, height;
 
+#ifdef XRENDERFONT
+    Display			    *dpy = screen->display;
+    if (!screen->renderFont && term->misc.face_name &&
+	XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))))
+    {
+	screen->renderFont = XftFontOpen (dpy, DefaultScreen (dpy),
+					  XFT_FAMILY, XftTypeString, term->misc.face_name,
+					  XFT_FAMILY, XftTypeString, "mono",
+					  XFT_SIZE, XftTypeInteger, term->misc.face_size,
+					  XFT_SPACING, XftTypeInteger, XFT_MONO,
+					  0);
+	if (screen->renderFont)
+	{
+	    screen->renderFontBold = XftFontOpen (dpy, DefaultScreen (dpy),
+						  XFT_FAMILY, XftTypeString, term->misc.face_name,
+						  XFT_FAMILY, XftTypeString, "mono",
+						  XFT_SIZE, XftTypeInteger, term->misc.face_size,
+						  XFT_WEIGHT, XftTypeInteger, XFT_WEIGHT_BOLD,
+						  XFT_SPACING, XftTypeInteger, XFT_MONO,
+						  XFT_CHAR_WIDTH, XftTypeInteger, 
+						    screen->renderFont->max_advance_width,
+						  0);
+	}
+    }
+    if (screen->renderFont)
+    {
+	win->f_width = screen->renderFont->max_advance_width;
+	win->f_height = screen->renderFont->height;
+	win->f_ascent = screen->renderFont->ascent;
+	win->f_descent = screen->renderFont->descent;
+    }
+    else
+#endif
+    {
 	win->f_width  = (font->max_bounds.width);
 	win->f_height = (font->ascent + font->descent);
-	i = 2 * screen->border + sbwidth;
-	j = 2 * screen->border;
-	width  = (screen->max_col + 1) * win->f_width + i;
-	height = (screen->max_row + 1) * win->f_height + j;
-	win->fullwidth  = width;
-	win->fullheight = height;
-	win->width  = width - i;
-	win->height = height - j;
+	win->f_ascent = font->ascent;
+	win->f_descent = font->descent;
+    }
+    i = 2 * screen->border + sbwidth;
+    j = 2 * screen->border;
+    width  = (screen->max_col + 1) * win->f_width + i;
+    height = (screen->max_row + 1) * win->f_height + j;
+    win->fullwidth  = width;
+    win->fullheight = height;
+    win->width  = width - i;
+    win->height = height - j;
 }
 
 
@@ -762,6 +937,9 @@
 		else {
 			CI_GET_CHAR_INFO_2D (font, (ch >> 8), (ch & 0xff), tmp, pc);
 		}
+#else
+
+		if (!pc) return False; /* Urgh! */
 #endif
 
 		if (CI_NONEXISTCHAR(pc)) {
@@ -1082,7 +1260,7 @@
 			m = n;
 	}
 	if (m >= 0) {
-		SetVTFont (m, TRUE, NULL, NULL);
+		SetVTFont (m, TRUE, VT_FONTSET(NULL, NULL, NULL, NULL));
 	} else {
 		Bell(XkbBI_MinorError,0);
 	}
@@ -1108,7 +1286,7 @@
 			m = n;
 	}
 	if (m >= 0) {
-		SetVTFont (m, TRUE, NULL, NULL);
+		SetVTFont (m, TRUE, VT_FONTSET(NULL, NULL, NULL, NULL));
 	} else {
 		Bell(XkbBI_MinorError,0);
 	}
@@ -1124,7 +1302,7 @@
 	Cardinal *param_count)
 {
     int fontnum;
-    char *name1 = NULL, *name2 = NULL;
+    char *name1 = NULL, *name2 = NULL, *name3 = NULL, *name4 = NULL;
 
     if (*param_count == 0) {
 	fontnum = fontMenu_fontdefault;
@@ -1147,7 +1325,7 @@
 	  case '6':
 	    fontnum = fontMenu_font6; break;
 	  case 'e': case 'E':
-	    fontnum = fontMenu_fontescape; maxparams = 3; break;
+	    fontnum = fontMenu_fontescape; maxparams = 5; break;
 	  case 's': case 'S':
 	    fontnum = fontMenu_fontsel; maxparams = 2; break;
 	  default:
@@ -1159,6 +1337,12 @@
 	    return;
 	}
 	switch (*param_count) {		/* assign 'em */
+	  case 5:
+	    name4 = params[4];
+	    /* FALLTHRU */
+	  case 4:
+	    name3 = params[3];
+	    /* FALLTHRU */
 	  case 3:
 	    name2 = params[2];
 	    /* FALLTHRU */
@@ -1168,14 +1352,13 @@
 	}
     }
 
-    SetVTFont (fontnum, True, name1, name2);
+    SetVTFont (fontnum, True, VT_FONTSET(name1, name2, name3, name4));
 }
 
 void SetVTFont (
 	int i,
 	Bool doresize,
-	char *name1,
-	char *name2)
+	VT_FONTSET(char *name1, char *name2, char *name3, char *name4))
 {
     TScreen *screen = &term->screen;
 
@@ -1190,7 +1373,7 @@
 	} else {
 	    if (name1 == 0)
 		name1 = screen->menu_font_names[i];
-	    if (xtermLoadFont(screen, name1, name2, doresize, i)) {
+	    if (xtermLoadFont(screen, VT_FONTSET(name1, name2, name3, name4), doresize, i)) {
 		return;
 	    }
 	}
Index: xc/programs/xterm/fontutils.h
diff -u xc/programs/xterm/fontutils.h:1.7 xc/programs/xterm/fontutils.h:1.9
--- xc/programs/xterm/fontutils.h:1.7	Mon Jun 12 22:28:39 2000
+++ xc/programs/xterm/fontutils.h	Tue Oct 31 20:12:39 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/xterm/fontutils.h,v 1.7 2000/06/13 02:28:39 dawes Exp $
+ * $XFree86: xc/programs/xterm/fontutils.h,v 1.9 2000/11/01 01:12:39 dawes Exp $
  */
 
 /************************************************************
@@ -40,9 +40,17 @@
 #include <ptyx.h>
 #include <proto.h>
 
-extern int xtermLoadFont (TScreen *screen, char *nfontname, char *bfontname, Bool doresize, int fontnum);
+#if OPT_WIDE_CHARS
+#define VT_FONTSET(n,b,w,wb) n, b, w, wb
+#else
+#define VT_FONTSET(n,b,w,wb) n, b
+#endif
+
+extern int xtermLoadFont (TScreen *screen,
+			  VT_FONTSET(char *nfontname, char *bfontname, char *wfontname, char *wbfontname),
+			  Bool doresize, int fontnum);
 extern void HandleSetFont PROTO_XT_ACTIONS_ARGS;
-extern void SetVTFont (int i, Bool doresize, char *name1, char *name2);
+extern void SetVTFont (int i, Bool doresize, VT_FONTSET(char *name1, char *name2, char *name3, char *name4));
 extern void xtermComputeFontInfo (TScreen *screen, struct _vtwin *win, XFontStruct *font, int sbwidth);
 extern void xtermSaveFontInfo (TScreen *screen, XFontStruct *font);
 extern void xtermSetCursorBox (TScreen *screen);
Index: xc/programs/xterm/input.c
diff -u xc/programs/xterm/input.c:3.47 xc/programs/xterm/input.c:3.50
--- xc/programs/xterm/input.c:3.47	Mon Jun 12 22:28:39 2000
+++ xc/programs/xterm/input.c	Wed Dec  6 21:40:00 2000
@@ -1,6 +1,6 @@
 /*
  *	$XConsortium: input.c /main/21 1996/04/17 15:54:23 kaleb $
- *	$XFree86: xc/programs/xterm/input.c,v 3.47 2000/06/13 02:28:39 dawes Exp $
+ *	$XFree86: xc/programs/xterm/input.c,v 3.50 2000/12/07 02:40:00 dickey Exp $
  */
 
 /*
@@ -342,6 +342,14 @@
 	if (keyboard->flags & MODE_KAM)
 		return;
 
+#if OPT_TCAP_QUERY
+	if (screen->tc_query >= 0) {
+		keysym = screen->tc_query;
+		nbytes = 0;
+		strbuf[0] = 0;
+	}
+	else
+#endif
 #if OPT_I18N_SUPPORT
 	if (screen->xic
 #if OPT_WIDE_CHARS
@@ -724,7 +732,7 @@
 }
 
 void
-StringInput ( register TScreen *screen, register char *string, size_t nbytes)
+StringInput ( register TScreen *screen, Char *string, size_t nbytes)
 {
 	int	pty	= screen->respond;
 
@@ -995,7 +1003,7 @@
 		    if ((state != 0
 		      || !isalnum(prv))
 		     && ((keyword[++state] == 0)
-		      && !isalnum(*p))) {
+		      && !isalnum(CharOf(*p)))) {
 			result = True;
 			break;
 		    }
@@ -1085,3 +1093,124 @@
     }
 }
 #endif /* OPT_NUM_LOCK */
+
+#if OPT_TCAP_QUERY
+	static int
+hex2int(int c)
+{
+	if (c >= '0' && c <= '9')
+		return c - '0';
+	if (c >= 'a' && c <= 'f')
+		return c - 'a' + 10;
+	if (c >= 'A' && c <= 'F')
+		return c - 'A' + 10;
+	return -1;
+}
+
+/*
+ * Parse the termcap/terminfo name from the string, returning a positive number
+ * (the keysym) if found, otherwise -1.  Update the string pointer.
+ * Returns the (shift, control) state in *state.
+ */
+int
+xtermcapKeycode(char *params, unsigned *state)
+{
+#define DATA(tc,ti,x,y) { tc, ti, x, y }
+	static struct {
+		char *tc;
+		char *ti;
+		int code;
+		unsigned state;
+	} table[] = {
+		DATA(	"#2",	"kHOM",		XK_Home,	ShiftMask),
+		DATA(	"#4",	"kLFT",		XK_Left,	ShiftMask),
+		DATA(	"%1",	"khlp",		XK_Help,	0),
+		DATA(	"%i",	"kRIT",		XK_Right,	ShiftMask),
+		DATA(	"*6",	"kslt",		XK_Select,	0),
+		DATA(	"*7",	"kEND",		XK_End,		ShiftMask),
+		DATA(	"@0",	"kfnd",		XK_Find,	0),
+		DATA(	"@7",	"kend",		XK_End,		0),
+		DATA(	"F1",	"kf11",		XK_F11,		0),
+		DATA(	"F2",	"kf12",		XK_F12,		0),
+		DATA(	"F3",	"kf13",		XK_F13,		0),
+		DATA(	"F4",	"kf14",		XK_F14,		0),
+		DATA(	"F5",	"kf15",		XK_F15,		0),
+		DATA(	"F6",	"kf16",		XK_F16,		0),
+		DATA(	"F7",	"kf17",		XK_F17,		0),
+		DATA(	"F8",	"kf18",		XK_F18,		0),
+		DATA(	"F9",	"kf19",		XK_F19,		0),
+		DATA(	"FA",	"kf20",		XK_F20,		0),
+		DATA(	"FB",	"kf21",		XK_F21,		0),
+		DATA(	"FC",	"kf22",		XK_F22,		0),
+		DATA(	"FD",	"kf23",		XK_F23,		0),
+		DATA(	"FE",	"kf24",		XK_F24,		0),
+		DATA(	"FF",	"kf25",		XK_F25,		0),
+		DATA(	"FG",	"kf26",		XK_F26,		0),
+		DATA(	"FH",	"kf27",		XK_F27,		0),
+		DATA(	"FI",	"kf28",		XK_F28,		0),
+		DATA(	"FJ",	"kf29",		XK_F29,		0),
+		DATA(	"FK",	"kf30",		XK_F30,		0),
+		DATA(	"FL",	"kf31",		XK_F31,		0),
+		DATA(	"FM",	"kf32",		XK_F32,		0),
+		DATA(	"FN",	"kf33",		XK_F33,		0),
+		DATA(	"FO",	"kf34",		XK_F34,		0),
+		DATA(	"FP",	"kf35",		XK_F35,		0),
+		DATA(	"FQ",	"kf36",		SunXK_F36,	0),
+		DATA(	"FR",	"kf37",		SunXK_F37,	0),
+		DATA(	"K1",	"ka1",		XK_KP_Home,	0),
+		DATA(	"K4",	"kc1",		XK_KP_End,	0),
+		DATA(	"k1",	"kf1",		XK_F1,		0),
+		DATA(	"k2",	"kf2",		XK_F2,		0),
+		DATA(	"k3",	"kf3",		XK_F3,		0),
+		DATA(	"k4",	"kf4",		XK_F4,		0),
+		DATA(	"k5",	"kf5",		XK_F5,		0),
+		DATA(	"k6",	"kf6",		XK_F6,		0),
+		DATA(	"k7",	"kf7",		XK_F7,		0),
+		DATA(	"k8",	"kf8",		XK_F8,		0),
+		DATA(	"k9",	"kf9",		XK_F9,		0),
+		DATA(	"k;",	"kf10",		XK_F10,		0),
+#ifdef XK_ISO_Left_Tab
+		DATA(	"kB",	"kcbt",		XK_ISO_Left_Tab,0),
+#endif
+		DATA(	"kC",	"kclr",		XK_Clear,	0),
+		DATA(	"kD",	"kdch1",	XK_Delete,	0),
+		DATA(	"kI",	"kich1",	XK_Insert,	0),
+		DATA(	"kN",	"knp",		XK_Next,	0),
+		DATA(	"kP",	"kpp",		XK_Prior,	0),
+		DATA(	"kb",	"kbs",		XK_BackSpace,	0),
+		DATA(	"kd",	"kcud1",	XK_Down,	0),
+		DATA(	"kh",	"khome",	XK_Home,	0),
+		DATA(	"kl",	"kcub1",	XK_Left,	0),
+		DATA(	"kr",	"kcuf1",	XK_Right,	0),
+		DATA(	"ku",	"kcuu1",	XK_Up,		0),
+# if OPT_ISO_COLORS
+		/* XK_COLORS is a fake code. */
+		DATA(	"Co",	"colors",	XK_COLORS,	0),
+# endif
+	};
+	Cardinal n;
+	unsigned len = 0;
+	int code = -1;
+#define MAX_TNAME_LEN 6
+	char name[MAX_TNAME_LEN];
+	char *p;
+
+	/* Convert hex encoded name to ascii */
+	for (p = params; hex2int(p[0]) >= 0 && hex2int(p[1]) >= 0; p += 2) {
+		if (len == MAX_TNAME_LEN - 1)
+			return -1;
+		name[len++] = (hex2int(p[0]) << 4) + hex2int(p[1]);
+	}
+	if (*p)
+		return -1;
+	name[len] = 0;
+	for (n = 0; n < XtNumber(table); n++) {
+		if (!strcmp(table[n].ti, name) || !strcmp(table[n].tc, name)) {
+			code = table[n].code;
+			*state = table[n].state;
+			break;
+		}
+	}
+	return code;
+}
+#endif
Index: xc/programs/xterm/main.c
diff -u xc/programs/xterm/main.c:3.115 xc/programs/xterm/main.c:3.122
--- xc/programs/xterm/main.c:3.115	Tue Jun 20 01:08:50 2000
+++ xc/programs/xterm/main.c	Tue Oct 31 20:12:39 2000
@@ -64,7 +64,7 @@
 
 ******************************************************************/
 
-/* $XFree86: xc/programs/xterm/main.c,v 3.115 2000/06/20 05:08:50 dawes Exp $ */
+/* $XFree86: xc/programs/xterm/main.c,v 3.122 2000/11/01 01:12:39 dawes Exp $ */
 
 
 /* main.c */
@@ -89,7 +89,13 @@
 #include <data.h>
 #include <error.h>
 #include <menu.h>
+#include <main.h>
+#include <xstrings.h>
 
+#if OPT_WIDE_CHARS
+#include <charclass.h>
+#endif
+
 #ifdef AMOEBA
 #include <amoeba.h>
 #include <cmdreg.h>
@@ -126,36 +132,19 @@
 #endif
 #endif /* MINIX */
 
-#ifdef att
-#define ATT
-#endif
-
 #ifdef __osf__
 #define USE_SYSV_SIGNALS
 #define WTMP
 #endif
 
-#ifdef SVR4
-#undef  SYSV			/* predefined on Solaris 2.4 */
-#define SYSV			/* SVR4 is (approx) superset of SVR3 */
-#define ATT
-#ifndef __sgi
+#if defined(SVR4) && !defined(__sgi)
 #define USE_TERMIOS
 #endif
-#endif
 
-#if defined(SYSV) && defined(i386) && !defined(SVR4)
-#define ATT
-#define USE_HANDSHAKE
+#ifdef USE_ISPTS_FLAG
 static Bool IsPts = False;
 #endif
 
-#if (defined(ATT) && !defined(__sgi)) || (defined(SYSV) && defined(i386)) || (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
-#define USE_USG_PTYS
-#else
-#define USE_HANDSHAKE
-#endif
-
 #if defined(SYSV) && !defined(SVR4) && !defined(ISC22) && !defined(ISC30)
 /* older SYSV systems cannot ignore SIGHUP.
    Shell hangs, or you get extra shells, or something like that */
@@ -187,7 +176,6 @@
 #ifdef __MVS__
 #define SVR4
 #define USE_POSIX_TERMIOS
-#define USE_USG_PTYS
 #define USE_SYSV_PGRP
 #define USE_SYSV_SIGNALS
 #undef  HAS_LTCHARS
@@ -196,6 +184,7 @@
 #ifdef __CYGWIN__
 #define SYSV
 #define SVR4
+#define LASTLOG
 #define WTMP
 #define ATT
 #endif
@@ -448,13 +437,8 @@
 
 #ifdef  PUCC_PTYD
 #include <local/openpty.h>
-int	Ptyfd;
 #endif /* PUCC_PTYD */
 
-#ifdef sequent
-#define USE_GET_PSEUDOTTY
-#endif
-
 #ifndef UTMP_FILENAME
 #ifdef UTMP_FILE
 #define UTMP_FILENAME UTMP_FILE
@@ -532,10 +516,12 @@
 #ifndef VMS
 static SIGNAL_T reapchild (int n);
 static int spawn (void);
-static int pty_search (int *pty);
 static void remove_termcap_entry (char *buf, char *str);
+#ifdef USE_PTY_SEARCH
+static int pty_search (int *pty);
+#endif
 #endif /* ! VMS */
-static char *base_name (char *name);
+
 static void get_terminal (void);
 static void resize (TScreen *s, char *oldtc, char *newtc);
 
@@ -758,7 +744,7 @@
 #endif
 
 static int inhibit;
-static char passedPty[2];	/* name if pty if slave */
+static char passedPty[PTYCHARLEN + 1];	/* name if pty if slave */
 
 #if defined(TIOCCONS) || defined(SRIOCSREDIR)
 static int Console;
@@ -866,15 +852,15 @@
 #undef offset
 
 static char *fallback_resources[] = {
-    "XTerm*SimpleMenu*menuLabel.vertSpace: 100",
-    "XTerm*SimpleMenu*HorizontalMargins: 16",
-    "XTerm*SimpleMenu*Sme.height: 16",
-    "XTerm*SimpleMenu*Cursor: left_ptr",
-    "XTerm*mainMenu.Label:  Main Options (no app-defaults)",
-    "XTerm*vtMenu.Label:  VT Options (no app-defaults)",
-    "XTerm*fontMenu.Label:  VT Fonts (no app-defaults)",
+    "*SimpleMenu*menuLabel.vertSpace: 100",
+    "*SimpleMenu*HorizontalMargins: 16",
+    "*SimpleMenu*Sme.height: 16",
+    "*SimpleMenu*Cursor: left_ptr",
+    "*mainMenu.Label:  Main Options (no app-defaults)",
+    "*vtMenu.Label:  VT Options (no app-defaults)",
+    "*fontMenu.Label:  VT Fonts (no app-defaults)",
 #if OPT_TEK4014
-    "XTerm*tekMenu.Label:  Tek Options (no app-defaults)",
+    "*tekMenu.Label:  Tek Options (no app-defaults)",
 #endif
     NULL
 };
@@ -904,6 +890,7 @@
 {"-cb",		"*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "off"},
 {"+cb",		"*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "on"},
 {"-cc",		"*charClass",	XrmoptionSepArg,	(caddr_t) NULL},
+{"-class",	NULL,		XrmoptionSkipArg,	(caddr_t) NULL},
 {"-cm",		"*colorMode",	XrmoptionNoArg,		(caddr_t) "off"},
 {"+cm",		"*colorMode",	XrmoptionNoArg,		(caddr_t) "on"},
 {"-cn",		"*cutNewline",	XrmoptionNoArg,		(caddr_t) "off"},
@@ -918,6 +905,14 @@
 #ifndef NO_ACTIVE_ICON
 {"-fi",		"*iconFont",	XrmoptionSepArg,	(caddr_t) NULL},
 #endif /* NO_ACTIVE_ICON */
+#ifdef XRENDERFONT
+{"-fa",		"*faceName",	XrmoptionSepArg,	(caddr_t) NULL},
+{"-fs",		"*faceSize",	XrmoptionSepArg,	(caddr_t) NULL},
+#endif
+#if OPT_WIDE_CHARS
+{"-fw",		"*wideFont",	XrmoptionSepArg,	(caddr_t) NULL},
+{"-fwb",	"*wideBoldFont", XrmoptionSepArg,	(caddr_t) NULL},
+#endif
 #if OPT_HIGHLIGHT_COLOR
 {"-hc",		"*highlightColor", XrmoptionSepArg,	(caddr_t) NULL},
 #endif
@@ -1030,8 +1025,14 @@
 { "-bd color",             "border color" },
 { "-bw number",            "border width in pixels" },
 { "-fn fontname",          "normal text font" },
+{ "-fb fontname",          "bold text font" },
+#if OPT_WIDE_CHARS
+{ "-fw fontname",          "doublewidth text font" },
+{ "-fwb fontname",         "doublewidth bold text font" },
+#endif
 { "-iconic",               "start iconic" },
 { "-name string",          "client instance, icon, and title strings" },
+{ "-class string",         "class string (XTerm)" },
 { "-title string",         "title string" },
 { "-xrm resourcestring",   "additional resource specifications" },
 { "-/+132",                "turn on/off column switch inhibiting" },
@@ -1052,7 +1053,6 @@
 { "-cr color",             "text cursor color" },
 { "-/+cu",                 "turn on/off curses emulation" },
 { "-/+dc",		   "turn off/on dynamic color selection" },
-{ "-fb fontname",          "bold text font" },
 #if OPT_HIGHLIGHT_COLOR
 { "-hc",		   "selection background color" },
 #endif
@@ -1128,12 +1128,12 @@
 #else
 { "-C",                    "intercept console messages (not supported)" },
 #endif
-{ "-Sxxd",                 "slave mode on \"ttyxx\", file descriptor \"d\"" },
+{ "-Sccn",                 "slave mode on \"ttycc\", file descriptor \"n\"" },
 #if OPT_ZICONBEEP
 { "-ziconbeep percent",    "beep and flag icon of window having hidden output" },
 #endif
 #if OPT_SAME_NAME
-{"-/+sameName",	   "Turn on/off the no flicker option for title and icon name" },
+{"-/+samename",            "turn on/off the no-flicker option for title and icon name" },
 #endif
 { NULL, NULL }};
 
@@ -1296,12 +1296,118 @@
 
 Atom wm_delete_window;
 
+/*
+ * Some platforms use names such as /dev/tty01, others /dev/pts/1.  Parse off
+ * the "tty01" or "pts/1" portion, and return that for use as an identifier for
+ * utmp.
+ */
+static char *
+my_pty_name(char *device)
+{
+	size_t len = strlen(device);
+	Boolean name = False;
+
+	while (len != 0) {
+		int ch = device[len-1];
+		if (isdigit(ch)) {
+			len--;
+		} else if (ch == '/') {
+			if (name)
+				break;
+			len--;
+		} else if (isalpha(ch)) {
+			name = True;
+			len--;
+		} else {
+			break;
+		}
+	}
+	TRACE(("my_pty_name(%s) -> '%s'\n", device, device + len));
+	return device + len;
+}
+
+/*
+ * If the name contains a '/', it is a "pts/1" case.  Otherwise, return the
+ * last few characters for a utmp identifier.
+ */
+static char *
+my_pty_id(char *device)
+{
+	char *name = my_pty_name(device);
+	char *leaf = x_basename(name);
+
+	if (name == leaf) {	/* no '/' in the name */
+		int len = strlen(leaf);
+		if (PTYCHARLEN < len)
+			leaf = leaf + (len - PTYCHARLEN);
+	}
+	TRACE(("my_pty_id  (%s) -> '%s'\n", device, leaf));
+	return leaf;
+}
+
+/*
+ * Set the tty/pty identifier
+ */
+static void
+set_pty_id(char *device, char *id)
+{
+	char *name = my_pty_name(device);
+	char *leaf = x_basename(name);
+
+	if (name == leaf) {
+		strcpy(my_pty_id(device), id);
+	} else {
+		strcpy(leaf, id);
+	}
+	TRACE(("set_pty_id(%s) -> '%s'\n", id, device));
+}
+
+/*
+ * The original -S option accepts two characters to identify the pty, and a
+ * file-descriptor (assumed to be nonzero).  That is not general enough, so we
+ * check first if the option contains a '/' to delimit the two fields, and if
+ * not, fall-thru to the original logic.
+ */
+static Boolean
+ParseSccn(char *option)
+{
+	char *leaf = x_basename(option);
+	Boolean code = False;
+
+	if (leaf != option) {
+		if (leaf - option > 1
+		 && leaf - option <= PTYCHARLEN
+		 && sscanf(leaf, "%d", &am_slave) == 1) {
+			size_t len = leaf - option - 1;
+			/*
+			 * If the given length is less than PTYCHARLEN, that is
+			 * all right because the calling application may be
+			 * giving us a path for /dev/pts, which would be
+			 * followed by one or more decimal digits.
+			 *
+			 * For fixed-width fields, it is up to the calling
+			 * application to provide leading 0's, if needed.
+			 */
+			strncpy(passedPty, option, len);
+			passedPty[len] = 0;
+			code = True;
+		}
+	} else {
+		code = (sscanf(option, "%c%c%d",
+			passedPty, passedPty+1, &am_slave) == 3);
+	}
+	TRACE(("ParseSccn(%s) = '%s' %d (%s)\n", option,
+		passedPty, am_slave, code ? "OK" : "ERR"));
+	return code;
+}
+
 int
 main (int argc, char *argv[])
 {
 	Widget form_top, menu_top;
 	register TScreen *screen;
 	int mode;
+	char *my_class = DEFCLASS;
 
 	/* Do these first, since we may not be able to open the display */
 	ProgramName = argv[0];
@@ -1311,6 +1417,12 @@
 			Version();
 		if (abbrev(argv[1], "-help"))
 			Help();
+		for (n = 1; n < argc; n++) {
+			if (strlen(argv[n]) > 2
+			 && abbrev(argv[n], "-class"))
+				if ((my_class = argv[++n]) == 0)
+					Help();
+		}
 	}
 
 	/* This dumps core on HP-UX 9.05 with X11R5 */
@@ -1319,10 +1431,10 @@
 #endif
 
 #ifndef AMOEBA
-	/* +2 in case longer tty name like /dev/ttyq255 */
-	ttydev = (char *) malloc (sizeof(TTYDEV) + 2);
-#ifndef __osf__
-	ptydev = (char *) malloc (sizeof(PTYDEV) + 2);
+	/* extra length in case longer tty name like /dev/ttyq255 */
+	ttydev = (char *) malloc (sizeof(TTYDEV) + 80);
+#ifdef USE_PTY_DEVICE
+	ptydev = (char *) malloc (sizeof(PTYDEV) + 80);
 	if (!ttydev || !ptydev)
 #else
 	if (!ttydev)
@@ -1334,7 +1446,7 @@
 	    exit (1);
 	}
 	strcpy (ttydev, TTYDEV);
-#ifndef __osf__
+#ifdef USE_PTY_DEVICE
 	strcpy (ptydev, PTYDEV);
 #endif
 
@@ -1619,7 +1731,7 @@
 #endif
 
 	    XtSetErrorHandler(xt_error);
-	    toplevel = XtAppInitialize (&app_con, "XTerm",
+	    toplevel = XtAppInitialize (&app_con, my_class,
 					optionDescList,
 					XtNumber(optionDescList),
 					&argc, argv, fallback_resources,
@@ -1702,6 +1814,11 @@
 	XtSetValues (toplevel, ourTopLevelShellArgs,
 		     number_ourTopLevelShellArgs);
 
+#if OPT_WIDE_CHARS
+	/* seems as good a place as any */
+	init_classtab();
+#endif
+
 	/* Parse the rest of the command line */
 	for (argc--, argv++ ; argc > 0 ; argc--, argv++) {
 	    if(**argv != '-') Syntax (*argv);
@@ -1732,8 +1849,7 @@
 #endif	/* TIOCCONS */
 		continue;
 	     case 'S':
-		if (sscanf(*argv + 2, "%c%c%d", passedPty, passedPty+1,
-			   &am_slave) != 3)
+		if (!ParseSccn(*argv + 2))
 		    Syntax(*argv);
 		continue;
 #ifdef DEBUG
@@ -1741,6 +1857,8 @@
 		debug = TRUE;
 		continue;
 #endif	/* DEBUG */
+	     case 'c':	/* -class */
+		break;
 	     case 'e':
 		if (argc <= 1) Syntax (*argv);
 		command_to_exec = ++argv;
@@ -1808,7 +1926,7 @@
 
 	    if (!resource.title) {
 		if (command_to_exec) {
-		    resource.title = base_name (command_to_exec[0]);
+		    resource.title = x_basename (command_to_exec[0]);
 		} /* else not reached */
 	    }
 
@@ -1880,7 +1998,7 @@
 	/* Realize procs have now been executed */
 
 #ifndef AMOEBA
-	if (am_slave) { /* Write window id so master end can read and use */
+	if (am_slave >= 0) { /* Write window id so master end can read and use */
 	    char buf[80];
 
 	    buf[0] = '\0';
@@ -1968,30 +2086,37 @@
 	}
 }
 
-static char *
-base_name(char *name)
-{
-	register char *cp;
-
-	cp = strrchr(name, '/');
-	return(cp ? cp + 1 : name);
-}
-
 #ifndef AMOEBA
-/* This function opens up a pty master and stuffs its value into pty.
+/*
+ * This function opens up a pty master and stuffs its value into pty.
+ *
  * If it finds one, it returns a value of 0.  If it does not find one,
  * it returns a value of !0.  This routine is designed to be re-entrant,
  * so that if a pty master is found and later, we find that the slave
  * has problems, we can re-enter this function and get another one.
  */
-
 static int
-get_pty (int *pty)
+get_pty (int *pty, char *from GCC_UNUSED)
 {
-#if defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS))
+	int result = 1;
+#ifdef PUCC_PTYD
+
+	result = ((*pty = openrpty(ttydev, ptydev,
+				(resource.utmpInhibit ? OPTY_NOP : OPTY_LOGIN),
+				getuid(), from)) < 0);
+
+#elif defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS))
+
 	int tty;
-	return (openpty(pty, &tty, ttydev, NULL, NULL));
-#elif (defined(SYSV) && defined(i386) && !defined(SVR4)) || defined(__QNXNTO__)
+	result = openpty(pty, &tty, ttydev, NULL, NULL);
+
+#elif defined(__QNXNTO__)
+
+	result = pty_search(pty);
+
+#else
+#if defined(USE_ISPTS_FLAG)
+
 	/*
 	  The order of this code is *important*.  On SYSV/386 we want to open
 	  a /dev/ttyp? first if at all possible.  If none are available, then
@@ -2015,91 +2140,101 @@
 	  for the "if (IsPts)" statement in spawn(); we have two different
 	  device types which need to be handled differently.
 	  */
-	if (pty_search(pty) == 0)
-	    return 0;
-	return 1;
-#elif defined(USE_USG_PTYS) || defined(__CYGWIN__)
+	result = pty_search(pty);
+
+#endif
+#if defined(USE_USG_PTYS) || defined(__CYGWIN__)
+
 #ifdef __GLIBC__ /* if __GLIBC__ and USE_USG_PTYS, we know glibc >= 2.1 */
 	/* GNU libc 2 allows us to abstract away from having to know the
 	   master pty device name. */
-	if ((*pty = getpt()) < 0) {
-	    return 1;
+	if ((*pty = getpt()) >= 0) {
+	    strcpy(ttydev, ptsname(*pty));
+	    result = 0;
 	}
-	strcpy(ttydev, ptsname(*pty));
 #elif defined(__MVS__)
-	return pty_search(pty);
+	result = pty_search(pty);
 #else
-	if ((*pty = open ("/dev/ptmx", O_RDWR)) < 0) {
-	    return 1;
-	}
+	result = ((*pty = open ("/dev/ptmx", O_RDWR)) < 0);
 #endif
-#if defined(SVR4) || defined(SCO325) || (defined(i386) && defined(SYSV))
-	strcpy(ttydev, ptsname(*pty));
-#if defined (SYSV) && defined(i386) && !defined(SVR4)
-	IsPts = True;
+#if defined(SVR4) || defined(SCO325) || defined(USE_ISPTS_FLAG)
+	if (!result)
+	    strcpy(ttydev, ptsname(*pty));
+#ifdef USE_ISPTS_FLAG
+	IsPts = !result;	/* true if we're successful */
 #endif
 #endif
-	return 0;
+
 #elif defined(AIXV3)
-	if ((*pty = open ("/dev/ptc", O_RDWR)) < 0) {
-	    return 1;
+
+	if ((*pty = open ("/dev/ptc", O_RDWR)) >= 0) {
+	    strcpy(ttydev, ttyname(*pty));
+	    result = 0;
 	}
-	strcpy(ttydev, ttyname(*pty));
-	return 0;
-#elif defined(__sgi) && (OSMAJORVERSION >= 4)
-	char    *tty_name;
 
-	tty_name = _getpty (pty, O_RDWR, 0622, 0);
-	if (tty_name == 0)
-	    return 1;
-	strcpy (ttydev, tty_name);
-	return 0;
 #elif defined(__convex__)
-	char *pty_name, *getpty();
+
+	char *pty_name;
+	extern char *getpty(void);
 
 	while ((pty_name = getpty()) != NULL) {
 	    if ((*pty = open (pty_name, O_RDWR)) >= 0) {
 		strcpy(ptydev, pty_name);
 		strcpy(ttydev, pty_name);
-		ttydev[5] = 't';
-		return 0;
+		*x_basename(ttydev) = 't';
+		result = 0;
+		break;
 	    }
 	}
-	return 1;
-#elif defined(USE_GET_PSEUDOTTY)
-	return ((*pty = getpseudotty (&ttydev, &ptydev)) >= 0 ? 0 : 1);
+
+#elif defined(sequent)
+
+	result = ((*pty = getpseudotty (&ttydev, &ptydev)) < 0);
+
+#elif defined(__sgi) && (OSMAJORVERSION >= 4)
+
+	char    *tty_name;
+
+	tty_name = _getpty (pty, O_RDWR, 0622, 0);
+	if (tty_name != 0) {
+	    strcpy (ttydev, tty_name);
+	    result = 0;
+	}
+
 #elif (defined(__sgi) && (OSMAJORVERSION < 4)) || (defined(umips) && defined (SYSTYPE_SYSV))
+
 	struct stat fstat_buf;
 
 	*pty = open ("/dev/ptc", O_RDWR);
-	if (*pty < 0 || (fstat (*pty, &fstat_buf)) < 0) {
-	  return(1);
+	if (*pty >= 0 && (fstat (*pty, &fstat_buf)) >= 0) {
+	    result = 0;
+	    sprintf (ttydev, "/dev/ttyq%d", minor(fstat_buf.st_rdev));
 	}
-	sprintf (ttydev, "/dev/ttyq%d", minor(fstat_buf.st_rdev));
-#ifndef __sgi
-	sprintf (ptydev, "/dev/ptyq%d", minor(fstat_buf.st_rdev));
-	if ((*tty = open (ttydev, O_RDWR)) < 0) {
-	  close (*pty);
-	  return(1);
-	}
-#endif /* !__sgi */
-	/* got one! */
-	return(0);
-#else /* __sgi or umips */
 
-#ifdef __hpux
+#elif defined(__hpux)
+
 	/*
 	 * Use the clone device if it works, otherwise use pty_search logic.
 	 */
 	if ((*pty = open("/dev/ptym/clone", O_RDWR)) >= 0) {
-		strcpy(ttydev, ptsname(*pty));
-		return(0);
+	    strcpy(ttydev, ptsname(*pty));
+	    result = 0;
+	} else {
+	    result = pty_search(pty);
 	}
-#endif
+
+#else
 
-	return pty_search(pty);
+	result = pty_search(pty);
 
 #endif
+#endif
+
+	TRACE(("get_pty(ttydev=%s, ptydev=%s) %s fd=%d\n",
+		ttydev != 0 ? ttydev : "?",
+		ptydev != 0 ? ptydev : "?",
+		result ? "FAIL" : "OK", *pty));
+	return result;
 }
 
 /*
@@ -2108,34 +2243,34 @@
  * a functional interface for allocating a pty.
  * Returns 0 if found a pty, 1 if fails.
  */
+#ifdef USE_PTY_SEARCH
 static int
 pty_search(int *pty)
 {
     static int devindex = 0, letter = 0;
 
 #if defined(CRAY) || defined(__MVS__)
-    for (; devindex < MAXPTTYS; devindex++) {
+    while (devindex < MAXPTTYS) {
 	sprintf (ttydev, TTYFORMAT, devindex);
 	sprintf (ptydev, PTYFORMAT, devindex);
+	devindex++;
 
+	TRACE(("pty_search(ttydev=%s, ptydev=%s)\n", ttydev, ptydev));
 	if ((*pty = open (ptydev, O_RDWR)) >= 0) {
-	    /* We need to set things up for our next entry
-	     * into this function!
-	     */
-	    (void) devindex++;
 	    return 0;
 	}
     }
 #else /* CRAY || __MVS__ */
     while (PTYCHAR1[letter]) {
-	ttydev [strlen(ttydev) - 2]  = ptydev [strlen(ptydev) - 2] =
-	    PTYCHAR1 [letter];
+	ttydev [strlen(ttydev) - 2] =
+	ptydev [strlen(ptydev) - 2] = PTYCHAR1 [letter];
 
 	while (PTYCHAR2[devindex]) {
-	    ttydev [strlen(ttydev) - 1] = ptydev [strlen(ptydev) - 1] =
-		PTYCHAR2 [devindex];
-	    /* for next time around loop or next entry to this function */
+	    ttydev [strlen(ttydev) - 1] =
+	    ptydev [strlen(ptydev) - 1] = PTYCHAR2 [devindex];
 	    devindex++;
+
+	    TRACE(("pty_search(ttydev=%s, ptydev=%s)\n", ttydev, ptydev));
 	    if ((*pty = open (ptydev, O_RDWR)) >= 0) {
 #ifdef sun
 		/* Need to check the process group of the pty.
@@ -2152,7 +2287,7 @@
 	    }
 	}
 	devindex = 0;
-	(void) letter++;
+	letter++;
     }
 #endif /* CRAY else */
     /*
@@ -2161,6 +2296,7 @@
      */
     return 1;
 }
+#endif /* USE_PTY_SEARCH */
 #endif /* AMOEBA */
 
 static void
@@ -2295,7 +2431,7 @@
  * temporary hack to get xterm working on att ptys
  */
 static void
-HsSysError(int pf, int error)
+HsSysError(int pf GCC_UNUSED, int error)
 {
     fprintf(stderr, "%s: fatal pty error %d (errno=%d) on tty %s\n",
 	    xterm_name, error, errno, ttydev);
@@ -2337,12 +2473,12 @@
 	register TScreen *screen = &term->screen;
 #ifdef USE_HANDSHAKE
 	handshake_t handshake;
+	int done;
 #endif
 #if OPT_INITIAL_ERASE
 	int initial_erase = VAL_INITIAL_ERASE;
 #endif
 	int tty = -1;
-	int done;
 #ifdef USE_SYSV_TERMIO
 	struct termio tio;
 #ifdef TIOCLSET
@@ -2402,14 +2538,12 @@
 	signal(SIGTTOU,SIG_IGN);
 #endif
 
-	if (am_slave) {
+	if (am_slave >= 0) {
 		screen->respond = am_slave;
-#ifndef __osf__
-		ptydev[strlen(ptydev) - 2] = ttydev[strlen(ttydev) - 2] =
-			passedPty[0];
-		ptydev[strlen(ptydev) - 1] = ttydev[strlen(ttydev) - 1] =
-			passedPty[1];
-#endif /* __osf__ */
+		set_pty_id(ttydev, passedPty);
+#ifdef USE_PTY_DEVICE
+		set_pty_id(ptydev, passedPty);
+#endif
 		setgid (screen->gid);
 		setuid (screen->uid);
 	} else {
@@ -2517,12 +2651,8 @@
 #else   /* !USE_SYSV_TERMIO && !USE_POSIX_TERMIOS */
 				initial_erase = sg.sg_erase;
 #endif	/* USE_SYSV_TERMIO */
-			}
-			if (resource.backarrow_is_erase)
-			if (initial_erase == 127) {	/* see input.c */
-				term->keyboard.flags &= ~MODE_DECBKM;
 			}
-			TRACE(("%s @%d, ptyInitialErase:%d, backspace_is_erase:%d, initial_erase:%d\n",
+			TRACE(("%s @%d, ptyInitialErase:%d, backarrow_is_erase:%d, initial_erase:%d (from /dev/tty)\n",
 				__FILE__, __LINE__,
 				resource.ptyInitialErase,
 				resource.backarrow_is_erase,
@@ -2540,29 +2670,41 @@
 			tty = -1;
 		}
 
-#ifdef	PUCC_PTYD
-		if(-1 == (screen->respond = openrpty(ttydev, ptydev,
-				(resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN),
-				getuid(), XDisplayString(screen->display))))
-#else /* not PUCC_PTYD */
-		if (get_pty (&screen->respond))
-#endif /* PUCC_PTYD */
+		TRACE(("%s @%d, calling get_pty...\n", __FILE__, __LINE__));
+		if (get_pty (&screen->respond, XDisplayString(screen->display)))
 		{
 			/*  no ptys! */
 			(void) fprintf(stderr, "%s: no available ptys: %s\n",
 				       xterm_name, strerror(errno));
 			exit (ERROR_PTYS);
 		}
-#ifdef PUCC_PTYD
-		  else {
-			/*
-			 *  set the fd of the master in a global var so
-			 *  we can undo all this on exit
-			 *
-			 */
-			Ptyfd = screen->respond;
-		  }
-#endif /* PUCC_PTYD */
+
+#if OPT_INITIAL_ERASE
+		if (resource.ptyInitialErase) {
+#ifdef USE_SYSV_TERMIO
+			struct termio my_tio;
+			if(ioctl(screen->respond, TCGETA, &my_tio) == 0)
+				initial_erase = my_tio.c_cc[VERASE];
+#elif defined(USE_POSIX_TERMIOS)
+			struct termios my_tio;
+			if (tcgetattr(screen->respond, &my_tio) == 0)
+				initial_erase = my_tio.c_cc[VERASE];
+#else   /* !USE_SYSV_TERMIO && !USE_POSIX_TERMIOS */
+			struct sgttyb my_sg;
+			if(ioctl(screen->respond, TIOCGETP, (char *)&my_sg) == 0)
+				initial_erase = my_sg.sg_erase;
+#endif	/* USE_SYSV_TERMIO */
+		}
+		if (resource.backarrow_is_erase)
+		if (initial_erase == 127) {	/* see input.c */
+			term->keyboard.flags &= ~MODE_DECBKM;
+		}
+		TRACE(("%s @%d, ptyInitialErase:%d, backarrow_is_erase:%d, initial_erase:%d (from pty)\n",
+			__FILE__, __LINE__,
+			resource.ptyInitialErase,
+			resource.backarrow_is_erase,
+			initial_erase));
+#endif
 	}
 
 	/* avoid double MapWindow requests */
@@ -2623,7 +2765,7 @@
 	}
 
 #if OPT_INITIAL_ERASE
-	TRACE(("%s @%d, resource ptyInitialErase:%d, backspace_is_erase:%d\n",
+	TRACE(("%s @%d, resource ptyInitialErase:%d, backarrow_is_erase:%d\n",
 		__FILE__, __LINE__,
 		resource.ptyInitialErase,
 		resource.backarrow_is_erase));
@@ -2691,7 +2833,7 @@
 	}
 #endif
 
-	if (!am_slave) {
+	if (am_slave < 0) {
 #ifdef USE_HANDSHAKE
 	    if (pipe(pc_pipe) || pipe(cp_pipe))
 		SysError (ERROR_FORK);
@@ -2705,19 +2847,15 @@
 		 */
 		TRACE_CHILD
 #if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(SCO325) || defined(__QNX__)
-		int pgrp = setsid();
+		int pgrp = setsid();	/* variable may not be used... */
 #else
 		int pgrp = getpid();
 #endif
-#if defined(HAVE_UTMP) && defined(USE_SYSV_UTMP)
-		char* ptyname;
-		char* ptynameptr = 0;
-#endif
 
 #ifdef USE_USG_PTYS
-#if defined(SYSV) && defined(i386) && !defined(SVR4)
+#ifdef USE_ISPTS_FLAG
 		if (IsPts) {	/* SYSV386 supports both, which did we open? */
-#endif /* SYSV && i386 && !SVR4 */
+#endif
 		int ptyfd;
 
 		setpgrp();
@@ -2763,9 +2901,9 @@
 			ws.ws_ypixel = FullHeight(screen);
 		}
 #endif
-#if defined(SYSV) && defined(i386) && !defined(SVR4)
+#ifdef USE_ISPTS_FLAG
 		} else {	/* else pty, not pts */
-#endif /* SYSV && i386 && !SVR4 */
+#endif
 #endif /* USE_USG_PTYS */
 
 #ifdef USE_HANDSHAKE		/* warning, goes for a long ways */
@@ -2885,9 +3023,9 @@
 			}
 			(void) strcpy(ttydev, ptr);
 		}
-#if defined(SYSV) && defined(i386) && !defined(SVR4)
+#ifdef USE_ISPTS_FLAG
 		} /* end of IsPts else clause */
-#endif /* SYSV && i386 && !SVR4 */
+#endif
 
 #endif /* USE_HANDSHAKE -- from near fork */
 
@@ -3280,7 +3418,9 @@
 #endif /* CRAY */
 		}
 
-#ifndef	USE_SYSV_PGRP
+#if defined(__QNX__)
+		tcsetpgrp( 0, pgrp /*setsid()*/ );
+#elif !defined(USE_SYSV_PGRP)
 #ifdef TIOCSCTTY
 		setsid();
 		ioctl(0, TIOCSCTTY, 0);
@@ -3291,10 +3431,6 @@
 		setpgrp (0, pgrp);
 #endif /* !USE_SYSV_PGRP */
 
-#if defined(__QNX__)
-		tcsetpgrp( 0, pgrp /*setsid()*/ );
-#endif
-
 #endif /* AMOEBA */
 
 #ifdef Lynx
@@ -3323,31 +3459,10 @@
 		**   - We need to do it before we go and change our
 		**     user and group id's.
 		*/
-#ifdef CRAY
-#define PTYCHARLEN 4
-#endif
-
-#ifdef __osf__
-#define PTYCHARLEN 5
-#endif
-
-#ifndef PTYCHARLEN
-#define PTYCHARLEN 2
-#endif
-
 		(void) setutent ();
 		/* set up entry to search for */
-		ptyname = ttydev;
 		bzero((char *)&utmp, sizeof(utmp));
-#ifndef __sgi
-		if (PTYCHARLEN >= (int)strlen(ptyname))
-		    ptynameptr = ptyname;
-		else
-		    ptynameptr = ptyname + strlen(ptyname) - PTYCHARLEN;
-#else
-		ptynameptr = ptyname + sizeof("/dev/tty")-1;
-#endif
-		(void) strncpy(utmp.ut_id, ptynameptr, sizeof (utmp.ut_id));
+		(void) strncpy(utmp.ut_id, my_pty_id(ttydev), sizeof (utmp.ut_id));
 
 		utmp.ut_type = DEAD_PROCESS;
 
@@ -3369,10 +3484,10 @@
 			       (pw && pw->pw_name) ? pw->pw_name : "????",
 			       sizeof(utmp.ut_user));
 
-		/* why are we copying this string again? look up 16 lines. */
-		(void)strncpy(utmp.ut_id, ptynameptr, sizeof(utmp.ut_id));
+		/* why are we copying this string again?  (see above) */
+		(void) strncpy(utmp.ut_id, my_pty_id(ttydev), sizeof(utmp.ut_id));
 		(void) strncpy (utmp.ut_line,
-			ptyname + strlen("/dev/"), sizeof (utmp.ut_line));
+			my_pty_name(ttydev), sizeof (utmp.ut_line));
 
 #ifdef HAVE_UTMP_UT_HOST
 		(void) strncpy(buf, DisplayString(screen->display),
@@ -3432,7 +3547,7 @@
 			    (i = open(etc_utmp, O_WRONLY)) >= 0) {
 				bzero((char *)&utmp, sizeof(utmp));
 				(void) strncpy(utmp.ut_line,
-					       ttydev + strlen("/dev/"),
+					       my_pty_name(ttydev),
 					       sizeof(utmp.ut_line));
 				(void) strncpy(utmp.ut_name, pw->pw_name,
 					       sizeof(utmp.ut_name));
@@ -3484,8 +3599,8 @@
 		if (term->misc.login_shell &&
 		(i = open(etc_lastlog, O_WRONLY)) >= 0) {
 		    bzero((char *)&lastlog, sizeof (struct lastlog));
-		    (void) strncpy(lastlog.ll_line, ttydev +
-			sizeof("/dev"),
+		    (void) strncpy(lastlog.ll_line,
+		        my_pty_name(ttydev),
 			sizeof (lastlog.ll_line));
 		    (void) strncpy(lastlog.ll_host,
 			  XDisplayString (screen->display),
@@ -3650,10 +3765,7 @@
 		 *(ptr = pw->pw_shell) == 0))
 #endif	/* HAVE_UTMP */
 			ptr = "/bin/sh";
-		if ((shname = strrchr(ptr, '/')) != 0)
-			shname++;
-		else
-			shname = ptr;
+		shname = x_basename(ptr);
 		shname_minus = (char *)malloc(strlen(shname) + 2);
 		(void) strcpy(shname_minus, "-");
 		(void) strcat(shname_minus, shname);
@@ -3708,7 +3820,7 @@
 			 * another one.
 			 */
 			(void) close(screen->respond);
-			if (get_pty(&screen->respond)) {
+			if (get_pty(&screen->respond, XDisplayString(screen->display))) {
 			    /* no more ptys! */
 			    fprintf(stderr,
 				    "%s: child process can find no available ptys: %s\n",
@@ -3849,10 +3961,7 @@
 
 	if ((path = getenv("PATH")) == NULL)
 	    path = DEF_PATH;
-	if ((name = strrchr(program, '/')) != NULL)
-	    name++;
-	else
-	    name = program;
+	name = x_basename(program);
 
 	do {
 	    register char *p = programpath;
@@ -4077,11 +4186,7 @@
 
 	if ((shell = getenv("SHELL")) == NULL)
 	    shell = DEF_SHELL; /* "cannot happen" */
-	if ((shname = strrchr(shell, '/')) != NULL)
-	    shname++;
-	else
-	    shname = shell;
-
+	shname = x_basename(shell);
 	shname_minus = malloc(strlen(shname) + 2);
 	(void) strcpy(shname_minus, "-");
 	(void) strcat(shname_minus, shname);
@@ -4166,11 +4271,8 @@
 	struct utmp utmp;
 	struct utmp *utptr;
 #endif
-	char* ptyname;
-	char* ptynameptr = 0;
 #if defined(WTMP) && !defined(SVR4) && !(defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !(defined(__powerpc__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)))
 	int fd;			/* for /etc/wtmp */
-	int i;
 #endif
 
 	/* don't do this more than once */
@@ -4179,7 +4281,7 @@
 	xterm_exiting = True;
 
 #ifdef PUCC_PTYD
-	closepty(ttydev, ptydev, (resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN), Ptyfd);
+	closepty(ttydev, ptydev, (resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN), screen->respond);
 #endif /* PUCC_PTYD */
 
 	/* cleanup the utmp entry we forged earlier */
@@ -4188,13 +4290,8 @@
 	    && added_utmp_entry
 #endif /* USE_HANDSHAKE */
 	    ) {
-	    ptyname = ttydev;
 	    utmp.ut_type = USER_PROCESS;
-	    if (PTYCHARLEN >= (int)strlen(ptyname))
-		ptynameptr = ptyname;
-	    else
-		ptynameptr = ptyname + strlen(ptyname) - PTYCHARLEN;
-	    (void) strncpy(utmp.ut_id, ptynameptr, sizeof(utmp.ut_id));
+	    (void) strncpy(utmp.ut_id, my_pty_id(ttydev), sizeof(utmp.ut_id));
 	    (void) setutent();
 	    utptr = getutid(&utmp);
 	    /* write it out only if it exists, and the pid's match */
@@ -4223,8 +4320,8 @@
 		    /* set wtmp entry if wtmp file exists */
 		    if (term->misc.login_shell &&
 			(fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
-		      i = write(fd, utptr, sizeof(*utptr));
-		      i = close(fd);
+			write(fd, utptr, sizeof(*utptr));
+			close(fd);
 		    }
 #endif
 #endif
@@ -4237,7 +4334,7 @@
 	struct utmp utmp;
 
 	if (!resource.utmpInhibit && added_utmp_entry &&
-	    (!am_slave && tslot > 0 && (wfd = open(etc_utmp, O_WRONLY)) >= 0)){
+	    (am_slave < 0 && tslot > 0 && (wfd = open(etc_utmp, O_WRONLY)) >= 0)){
 		bzero((char *)&utmp, sizeof(utmp));
 		lseek(wfd, (long)(tslot * sizeof(utmp)), 0);
 		write(wfd, (char *)&utmp, sizeof(utmp));
@@ -4245,12 +4342,12 @@
 #ifdef WTMP
 		if (term->misc.login_shell &&
 		    (wfd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
-			register int i;
-			(void) strncpy(utmp.ut_line, ttydev +
-			    sizeof("/dev"), sizeof (utmp.ut_line));
+			(void) strncpy(utmp.ut_line,
+		 	    my_pty_name(ttydev),
+			    sizeof (utmp.ut_line));
 			time(&utmp.ut_time);
-			i = write(wfd, (char *)&utmp, sizeof(utmp));
-			i = close(wfd);
+			write(wfd, (char *)&utmp, sizeof(utmp));
+			close(wfd);
 		}
 #endif /* WTMP */
 	}
@@ -4265,10 +4362,10 @@
 #endif
 
 #ifndef AMOEBA
-	if (!am_slave) {
+	if (am_slave < 0) {
 		/* restore ownership of tty and pty */
 		set_owner (ttydev, 0, 0, 0666);
-#if (!defined(__sgi) && !defined(__osf__) && !defined(__hpux))
+#if (defined(USE_PTY_DEVICE) && !defined(__sgi) && !defined(__hpux))
 		set_owner (ptydev, 0, 0, 0666);
 #endif
 	}
@@ -4288,13 +4385,13 @@
 	register char *temp;
 
 	TRACE(("resize %s\n", oldtc));
-	if ((ptr1 = strindex (oldtc, "co#")) == NULL){
+	if ((ptr1 = x_strindex (oldtc, "co#")) == NULL){
 		strcat (oldtc, "co#80:");
-		ptr1 = strindex (oldtc, "co#");
+		ptr1 = x_strindex (oldtc, "co#");
 	}
-	if ((ptr2 = strindex (oldtc, "li#")) == NULL){
+	if ((ptr2 = x_strindex (oldtc, "li#")) == NULL){
 		strcat (oldtc, "li#24:");
-		ptr2 = strindex (oldtc, "li#");
+		ptr2 = x_strindex (oldtc, "li#");
 	}
 	if(ptr1 > ptr2) {
 		li_first++;
@@ -4410,7 +4507,7 @@
 	} else if (*buf == ':') {
 	    first = buf;
 	    count = 0;
-	} else if (!isspace(*buf)) {
+	} else if (!isspace(CharOf(*buf))) {
 	    count++;
 	}
 	if (*buf != 0)
@@ -4434,7 +4531,7 @@
     int count = 0;
 
     while (1) {
-	while (*s && isascii(*s) && isspace(*s)) s++;
+	while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s))) s++;
 	if (!*s) return count;
 
 	for (mp = modelist; mp->name; mp++) {
@@ -4443,7 +4540,7 @@
 	if (!mp->name) return -1;
 
 	s += mp->len;
-	while (*s && isascii(*s) && isspace(*s)) s++;
+	while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s))) s++;
 	if (!*s) return -1;
 
 	if (*s == '^') {
Index: xc/programs/xterm/main.h
diff -u xc/programs/xterm/main.h:3.1 xc/programs/xterm/main.h:3.4
--- xc/programs/xterm/main.h:3.1	Wed Jan 10 00:51:41 1996
+++ xc/programs/xterm/main.h	Tue Oct 31 20:12:40 2000
@@ -1,6 +1,6 @@
 /*
  *	$XConsortium: main.h,v 1.5 91/02/06 16:00:15 gildea Exp $
- *	$XFree86: xc/programs/xterm/main.h,v 3.1 1996/01/10 05:51:41 dawes Exp $
+ *	$XFree86: xc/programs/xterm/main.h,v 3.4 2000/11/01 01:12:40 dawes Exp $
  */
 
 /*
@@ -26,6 +26,11 @@
  * SOFTWARE.
  */
 
-#define	DEFFONT			"fixed"
-#define	DEFBOLDFONT		NULL 	/* no bold font uses overstriking */
-#define	DEFBORDER		2
+#define DEFCLASS		"XTerm"
+#define DEFFONT			"fixed"
+#define DEFWIDEFONT		NULL	/* grab one which is 2x as wide */
+#define DEFWIDEBOLDFONT		NULL
+#define DEFBOLDFONT		NULL	/* no bold font uses overstriking */
+#define DEFBORDER		2
+#define DEFFACENAME		NULL
+#define DEFFACESIZE		14
Index: xc/programs/xterm/menu.c
diff -u xc/programs/xterm/menu.c:3.35 xc/programs/xterm/menu.c:3.38
--- xc/programs/xterm/menu.c:3.35	Tue Jun 13 20:16:19 2000
+++ xc/programs/xterm/menu.c	Tue Oct 31 20:12:40 2000
@@ -1,5 +1,5 @@
 /* $XConsortium: menu.c /main/66 1996/12/01 23:46:59 swick $ */
-/* $XFree86: xc/programs/xterm/menu.c,v 3.35 2000/06/14 00:16:19 dawes Exp $ */
+/* $XFree86: xc/programs/xterm/menu.c,v 3.38 2000/11/01 01:12:40 dawes Exp $ */
 /*
 
 Copyright 1999-2000 by Thomas E. Dickey
@@ -469,7 +469,7 @@
 
     if ((mw = obtain_menu(w, me)) == 0
      || sizeof_menu(w, me) == 0) {
-	mw = create_menu (w, term, me);
+	mw = create_menu (w, term, (MenuIndex) me);
 	created = (mw != 0);
     }
     if (mw == 0)
@@ -1193,7 +1193,7 @@
 
     for (i = 0; i < NMENUFONTS; i++) {
 	if (strcmp (entryname, fontMenuEntries[i].name) == 0) {
-	    SetVTFont (i, True, (char *)0, (char *)0);
+	    SetVTFont (i, True, VT_FONTSET(NULL, NULL, NULL, NULL));
 	    return;
 	}
     }
Index: xc/programs/xterm/misc.c
diff -u xc/programs/xterm/misc.c:3.53 xc/programs/xterm/misc.c:3.59
--- xc/programs/xterm/misc.c:3.53	Tue Jun 13 20:16:19 2000
+++ xc/programs/xterm/misc.c	Thu Dec  7 05:12:33 2000
@@ -1,6 +1,6 @@
 /*
  *	$XConsortium: misc.c /main/112 1996/11/29 10:34:07 swick $
- *	$XFree86: xc/programs/xterm/misc.c,v 3.53 2000/06/14 00:16:19 dawes Exp $
+ *	$XFree86: xc/programs/xterm/misc.c,v 3.59 2000/12/07 10:12:33 dickey Exp $
  */
 
 /*
@@ -58,15 +58,11 @@
 
 #include <xterm.h>
 
-#include <X11/Xos.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <stdio.h>
 #include <signal.h>
 #include <ctype.h>
 #include <pwd.h>
-
-#include <sys/types.h>
 #include <sys/wait.h>
 
 #include <X11/Xatom.h>
@@ -91,6 +87,7 @@
 #include <menu.h>
 #include <fontutils.h>
 #include <xcharmouse.h>
+#include <VTparse.h>
 
 #if (XtSpecificationRelease < 6)
 #ifndef X_GETTIMEOFDAY
@@ -272,9 +269,10 @@
     if (*nparams != 1) return;
 
     if ((*params)[0] == '0' && (*params)[1] == 'x' && (*params)[2] != '\0') {
-	char c, *p, hexval[2];
+	Char c, *p;
+	Char hexval[2];
 	hexval[0] = hexval[1] = 0;
-	for (p = *params+2; (c = *p); p++) {
+	for (p = (Char *)(*params+2); (c = *p); p++) {
 	    hexval[0] *= 16;
 	    if (isupper(c)) c = tolower(c);
 	    if (c >= '0' && c <= '9')
@@ -287,7 +285,7 @@
 	    StringInput (screen, hexval, 1);
     }
     else {
-	StringInput (screen, *params, strlen(*params));
+	StringInput (screen, (Char *)*params, strlen(*params));
     }
 }
 
@@ -939,12 +937,6 @@
 #ifdef ALLOWLOGFILEEXEC
 	register char *cp;
 	register int i = 0;
-#ifdef SYSV
-	/* SYSV has another pointer which should be part of the
-	** FILE structure but is actually a separate array.
-	*/
-	unsigned char *old_bufend;
-#endif	/* SYSV */
 #endif /* ALLOWLOGFILEEXEC */
 
 	if(screen->logging || (screen->inhibit & I_LOG))
@@ -1229,7 +1221,7 @@
 			state = 3;
 			/* FALLTHRU */
 		default:
-			if (!isprint(*cp & 0x7f))
+			if (ansi_table[CharOf(*cp)] != CASE_PRINT)
 				return;
 		}
 	}
@@ -1315,7 +1307,7 @@
 			    buf++;
 			}
 
-			if (isdigit(*buf)) {
+			if (isdigit(CharOf(*buf))) {
 			    int val = atoi(buf);
 			    if (rel > 0)
 				num += val;
@@ -1336,7 +1328,7 @@
 			    break;
 			}
 		    }
-		    SetVTFont (fontMenu_fontescape, True, buf, NULL);
+		    SetVTFont (fontMenu_fontescape, True, VT_FONTSET(buf, NULL, NULL, NULL));
 		}
 		break;
 	case 51:
@@ -1385,13 +1377,23 @@
 void
 do_dcs(Char *dcsbuf, size_t dcslen)
 {
-	register TScreen *screen = &term->screen;
+	TScreen *screen = &term->screen;
+	char reply[BUFSIZ];
 	char *cp = (char *)dcsbuf;
+	Bool okay;
+	Bool clear_all;
+	Bool lock_keys;
+
+	TRACE(("do_dcs(%s:%d)\n", (char *)dcsbuf, dcslen));
 
-	if (*cp == '$') { /* DECRQSS */
-		char reply[BUFSIZ];
-		Bool okay = True;
+	if (dcslen != strlen(cp))
+		/* shouldn't have nulls in the string */
+		return;
 
+	switch (*cp) {		/* intermediate character, or parameter */
+	case '$':		/* DECRQSS */
+		okay = True;
+
 		cp++;
 		if (*cp++ == 'q') {
 			if (!strcmp(cp, "\"q")) {		/* DECSCA */
@@ -1481,68 +1483,112 @@
 		} else {
 			unparseputc(CAN, screen->respond);
 		}
-	} else { /* DECUDK */
-		Bool clear_all = True;
-		Bool lock_keys = True;
-
-		if (dcslen != strlen(cp))
-			/* shouldn't have nulls in the string */
-			return;
+		break;
+#if OPT_TCAP_QUERY
+	case '+':
+		cp++;
+		if (*cp == 'q') {
+			unsigned state;
+			int code;
+			char *tmp;
 
-		if (*cp == '0') {
-			cp++;
-		} else if (*cp == '1') {
-			cp++;
-			clear_all = False;
+			++cp;
+			code = xtermcapKeycode(cp, &state);
+			unparseputc1(DCS, screen->respond);
+			unparseputc(code >= 0 ? '1' : '0', screen->respond);
+			unparseputc('+', screen->respond);
+			unparseputc('r', screen->respond);
+			for (tmp = cp; *tmp; ++tmp)
+				unparseputc(*tmp, screen->respond);
+			if (code >= 0) {
+				unparseputc('=', screen->respond);
+				screen->tc_query = code;
+				/* XK_COLORS is a fake code for the "Co" entry (maximum
+				 * number of colors) */
+				if (code == XK_COLORS) {
+# if OPT_256_COLORS
+					unparseputc('2', screen->respond);
+					unparseputc('5', screen->respond);
+					unparseputc('6', screen->respond);
+# elif OPT_88_COLORS
+					unparseputc('8', screen->respond);
+					unparseputc('8', screen->respond);
+# else
+					unparseputc('1', screen->respond);
+					unparseputc('6', screen->respond);
+# endif
+				}
+				else {
+					XKeyEvent event;
+					event.state = state;
+					Input(&(term->keyboard), screen, &event, False);
+				}
+				screen->tc_query = -1;
+			}
+			unparseputc1(ST, screen->respond);
 		}
+		break;
+#endif
+	default:
+		if (isdigit(CharOf(*cp))) { /* digits are DECUDK, otherwise ignore */
+			clear_all = True;
+			lock_keys = True;
 
-		if (*cp == ';')
-			cp++;
-		else if (*cp != '|')
-			return;
+			if (*cp == '0') {
+				cp++;
+			} else if (*cp == '1') {
+				cp++;
+				clear_all = False;
+			}
 
-		if (*cp == '0') {
-			cp++;
-		} else if (*cp == '1') {
-			cp++;
-			lock_keys = False;
-		}
+			if (*cp == ';')
+				cp++;
+			else if (*cp != '|')
+				return;
 
-		if (*cp++ != '|')
-			return;
+			if (*cp == '0') {
+				cp++;
+			} else if (*cp == '1') {
+				cp++;
+				lock_keys = False;
+			}
 
-		if (clear_all)
-			reset_decudk();
+			if (*cp++ != '|')
+				return;
 
-		while (*cp) {
-			char *str = (char *)malloc(strlen(cp) + 2);
-			unsigned key = 0;
-			int len = 0;
-
-			while (isdigit(*cp))
-				key = (key * 10) + (*cp++ - '0');
-			if (*cp == '/') {
-				cp++;
-				while (*cp != ';' && *cp != '\0') {
-					int hi = hexvalue(*cp++);
-					int lo = hexvalue(*cp++);
-					if (hi >= 0 && lo >= 0)
+			if (clear_all)
+				reset_decudk();
+
+			while (*cp) {
+				char *str = (char *)malloc(strlen(cp) + 2);
+				unsigned key = 0;
+				int len = 0;
+
+				while (isdigit(CharOf(*cp)))
+					key = (key * 10) + (*cp++ - '0');
+				if (*cp == '/') {
+					cp++;
+					while (*cp != ';' && *cp != '\0') {
+						int hi = hexvalue(*cp++);
+						int lo = hexvalue(*cp++);
+						if (hi < 0 || lo < 0)
+							return;
 						str[len++] = (hi << 4) | lo;
-					else
-						return;
+					}
 				}
+				if (len > 0 && key < MAX_UDK) {
+					if (user_keys[key].str != 0)
+						free(user_keys[key].str);
+					user_keys[key].str = str;
+					user_keys[key].len = len;
+				} else {
+					free(str);
+				}
+				if (*cp == ';')
+					cp++;
 			}
-			if (len > 0 && key < MAX_UDK) {
-				if (user_keys[key].str != 0)
-					free(user_keys[key].str);
-				user_keys[key].str = str;
-				user_keys[key].len = len;
-			} else {
-				free(str);
-			}
-			if (*cp == ';')
-				cp++;
 		}
+		break;
 	}
 }
 
@@ -1557,11 +1603,12 @@
 }
 
 static void
-ChangeGroup(String attribute, XtArgVal value)
+ChangeGroup(String attribute, char * value)
 {
 	Arg args[1];
 	char *name = (value != 0) ? (char *)value : "";
 
+	TRACE(("ChangeGroup(attribute=%s, value=%s)\n", attribute, name));
 #if OPT_SAME_NAME
 	/* If the attribute isn't going to change, then don't bother... */
 
@@ -1592,17 +1639,17 @@
 	}
 	strcpy(newname, "*** ");
 	strcat(newname, name);
-	ChangeGroup( XtNiconName, (XtArgVal)newname );
+	ChangeGroup( XtNiconName, newname );
 	free(newname);
     } else
 #endif /* OPT_ZICONBEEP */
-	ChangeGroup( XtNiconName, (XtArgVal)name );
+	ChangeGroup( XtNiconName, name );
 }
 
 void
 Changetitle(register char *name)
 {
-    ChangeGroup( XtNtitle, (XtArgVal)name );
+    ChangeGroup( XtNtitle, name );
 }
 
 #define Strlen(s) strlen((char *)(s))
@@ -1931,23 +1978,6 @@
 	(void) strcpy (environ [envindex], var);
 	strcat (environ [envindex], value);
 	environ [++envindex] = NULL;
-}
-
-/*
- * returns a pointer to the first occurrence of s2 in s1,
- * or NULL if there are none.
- */
-char *strindex ( register char *s1, register char *s2)
-{
-	register char	*s3;
-	size_t s2len = strlen (s2);
-
-	while ((s3=strchr(s1, *s2)) != NULL) {
-		if (strncmp(s3, s2, s2len) == 0)
-			return (s3);
-		s1 = ++s3;
-	}
-	return (NULL);
 }
 
 /*ARGSUSED*/
Index: xc/programs/xterm/os2main.c
diff -u xc/programs/xterm/os2main.c:3.38 xc/programs/xterm/os2main.c:3.41
--- xc/programs/xterm/os2main.c:3.38	Tue Jun 20 01:08:51 2000
+++ xc/programs/xterm/os2main.c	Tue Oct 31 20:12:41 2000
@@ -5,7 +5,7 @@
 #ifndef lint
 static char *rid="$XConsortium: main.c,v 1.227.1.2 95/06/29 18:13:15 kaleb Exp $";
 #endif /* lint */
-/* $XFree86: xc/programs/xterm/os2main.c,v 3.38 2000/06/20 05:08:51 dawes Exp $ */
+/* $XFree86: xc/programs/xterm/os2main.c,v 3.41 2000/11/01 01:12:41 dawes Exp $ */
 
 /***********************************************************
 
@@ -88,6 +88,8 @@
 #include <data.h>
 #include <error.h>
 #include <menu.h>
+#include <main.h>
+#include <xstrings.h>
 
 #include <sys/termio.h>
 
@@ -106,7 +108,6 @@
 #include <signal.h>
 
 static SIGNAL_T reapchild (int n);
-static char *base_name (char *name);
 static int spawn (void);
 static void get_terminal (void);
 static void resize (TScreen *s, char *oldtc, char *newtc);
@@ -304,15 +305,15 @@
 #undef offset
 
 static char *fallback_resources[] = {
-    "XTerm*SimpleMenu*menuLabel.vertSpace: 100",
-    "XTerm*SimpleMenu*HorizontalMargins: 16",
-    "XTerm*SimpleMenu*Sme.height: 16",
-    "XTerm*SimpleMenu*Cursor: left_ptr",
-    "XTerm*mainMenu.Label:  Main Options (no app-defaults)",
-    "XTerm*vtMenu.Label:  VT Options (no app-defaults)",
-    "XTerm*fontMenu.Label:  VT Fonts (no app-defaults)",
+    "*SimpleMenu*menuLabel.vertSpace: 100",
+    "*SimpleMenu*HorizontalMargins: 16",
+    "*SimpleMenu*Sme.height: 16",
+    "*SimpleMenu*Cursor: left_ptr",
+    "*mainMenu.Label:  Main Options (no app-defaults)",
+    "*vtMenu.Label:  VT Options (no app-defaults)",
+    "*fontMenu.Label:  VT Fonts (no app-defaults)",
 #if OPT_TEK4014
-    "XTerm*tekMenu.Label:  Tek Options (no app-defaults)",
+    "*tekMenu.Label:  Tek Options (no app-defaults)",
 #endif
     NULL
 };
@@ -342,6 +343,7 @@
 {"-cb",		"*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "off"},
 {"+cb",		"*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "on"},
 {"-cc",		"*charClass",	XrmoptionSepArg,	(caddr_t) NULL},
+{"-class",	NULL,		XrmoptionSkipArg,	(caddr_t) NULL},
 {"-cm",		"*colorMode",	XrmoptionNoArg,		(caddr_t) "off"},
 {"+cm",		"*colorMode",	XrmoptionNoArg,		(caddr_t) "on"},
 {"-cn",		"*cutNewline",	XrmoptionNoArg,		(caddr_t) "off"},
@@ -464,6 +466,7 @@
 { "-fn fontname",          "normal text font" },
 { "-iconic",               "start iconic" },
 { "-name string",          "client instance, icon, and title strings" },
+{ "-class string",         "class string (XTerm)" },
 { "-title string",         "title string" },
 { "-xrm resourcestring",   "additional resource specifications" },
 { "-/+132",                "turn on/off column switch inhibiting" },
@@ -548,12 +551,12 @@
 { "-T string",             "title name for window" },
 { "-n string",             "icon name for window" },
 { "-C",                    "intercept console messages" },
-{ "-Sxxd",                 "slave mode on \"ttyxx\", file descriptor \"d\"" },
+{ "-Sccn",                 "slave mode on \"ttycc\", file descriptor \"n\"" },
 #if OPT_ZICONBEEP
 { "-ziconbeep percent",    "beep and flag icon of window having hidden output" },
 #endif
 #if OPT_SAME_NAME
-{"-/+sameName",	   "Turn on/off the no flicker option for title and icon name" },
+{"-/+samename",	           "turn on/off the no flicker option for title and icon name" },
 #endif
 { NULL, NULL }};
 
@@ -833,6 +836,7 @@
 	Widget form_top, menu_top;
 	register TScreen *screen;
 	int mode;
+	char *my_class = DEFCLASS;
 
 	/* Do these first, since we may not be able to open the display */
 	ProgramName = argv[0];
@@ -842,6 +846,12 @@
 			Version();
 		if (abbrev(argv[1], "-help"))
 			Help();
+		for (n = 1; n < argc; n++) {
+			if (strlen(argv[n]) > 2
+			 && abbrev(argv[n], "-class"))
+				if ((my_class = argv[++n]) == 0)
+					Help();
+		}
 	}
 
 	/* XXX: for some obscure reason EMX seems to lose the value of
@@ -859,7 +869,7 @@
 	ptydev = (char *) malloc (PTMS_BUFSZ);
 	if (!ttydev || !ptydev) {
 	    fprintf (stderr,
-	    	     "%s:  unable to allocate memory for ttydev or ptydev\n",
+		     "%s:  unable to allocate memory for ttydev or ptydev\n",
 		     ProgramName);
 	    exit (1);
 	}
@@ -874,20 +884,20 @@
 	*/
 	d_tio.c_iflag = ICRNL|IXON;
 	d_tio.c_oflag = OPOST|ONLCR|TAB3;
-    	d_tio.c_cflag = B38400|CS8|CREAD|PARENB|HUPCL;
-    	d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
+	d_tio.c_cflag = B38400|CS8|CREAD|PARENB|HUPCL;
+	d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
 	d_tio.c_line = 0;
 	d_tio.c_cc[VINTR] = CONTROL('C');	/* '^C'	*/
 	d_tio.c_cc[VERASE] = 0x7f;		/* DEL	*/
 	d_tio.c_cc[VKILL] = CONTROL('U');	/* '^U'	*/
 	d_tio.c_cc[VQUIT] = CQUIT;		/* '^\'	*/
-    	d_tio.c_cc[VEOF] = CEOF;		/* '^D'	*/
+	d_tio.c_cc[VEOF] = CEOF;		/* '^D' */
 	d_tio.c_cc[VEOL] = CEOL;		/* '^@'	*/
 
 	/* Init the Toolkit. */
 	{
 	    XtSetErrorHandler(xt_error);
-	    toplevel = XtAppInitialize (&app_con, "XTerm",
+	    toplevel = XtAppInitialize (&app_con, my_class,
 					optionDescList,
 					XtNumber(optionDescList),
 					&argc, argv, fallback_resources,
@@ -986,6 +996,8 @@
 		debug = TRUE;
 		continue;
 #endif	/* DEBUG */
+	     case 'c':	/* -class */
+		break;
 	     case 'e':
 		if (argc <= 1) Syntax (*argv);
 		command_to_exec = ++argv;
@@ -1039,7 +1051,7 @@
 
 	    if (!resource.title) {
 		if (command_to_exec) {
-		    resource.title = base_name (command_to_exec[0]);
+		    resource.title = x_basename (command_to_exec[0]);
 		} /* else not reached */
 	    }
 
@@ -1066,7 +1078,7 @@
 	 so the debug feature is disabled by default. */
 	int i = -1;
 	if(debug) {
-	        creat_as (getuid(), getgid(), True, "xterm.debug.log", 0666);
+		creat_as (getuid(), getgid(), True, "xterm.debug.log", 0666);
 		i = open ("xterm.debug.log", O_WRONLY | O_TRUNC, 0666);
 	}
 	if(i >= 0) {
@@ -1088,7 +1100,7 @@
 
 	/* Realize procs have now been executed */
 
-	if (am_slave) { /* Write window id so master end can read and use */
+	if (am_slave >= 0) { /* Write window id so master end can read and use */
 	    char buf[80];
 
 	    buf[0] = '\0';
@@ -1138,15 +1150,6 @@
 	return 0;
 }
 
-static char *
-base_name(char *name)
-{
-	register char *cp;
-
-	cp = strrchr(name, '/');
-	return(cp ? cp + 1 : name);
-}
-
 /*
  * Called from get_pty to iterate over likely pseudo terminals
  * we might allocate.  Used on those systems that do not have
@@ -1163,7 +1166,7 @@
 	if (fd && ptioctl(fd,PTMS_GETPTY,namebuf)==0) {
 		strcpy(ttydev,namebuf);
 		strcpy(ptydev,namebuf);
-		ttydev[5] = 't';
+		*x_basename(ttydev) = 't';
 		close (fd);
 		if ((*pty = open(ptydev, O_RDWR)) >= 0) {
 #ifdef PTYDEBUG
@@ -1175,24 +1178,25 @@
 	return 1;
 }
 
-/* This function opens up a pty master and stuffs its value into pty.
+/*
+ * This function opens up a pty master and stuffs its value into pty.
+ *
  * If it finds one, it returns a value of 0.  If it does not find one,
  * it returns a value of !0.  This routine is designed to be re-entrant,
  * so that if a pty master is found and later, we find that the slave
  * has problems, we can re-enter this function and get another one.
  */
-
 static int
 get_pty (int *pty)
 {
 	return pty_search(pty);
 }
 
-static void
-get_terminal (void)
 /*
  * sets up X and initializes the terminal structure except for term.buf.fildes.
  */
+static void
+get_terminal (void)
 {
 	register TScreen *screen = &term->screen;
 
@@ -1320,12 +1324,12 @@
 	screen->uid = getuid();
 	screen->gid = getgid();
 
-	if (am_slave) {
+	if (am_slave >= 0) {
 		screen->respond = am_slave;
-		ptydev[strlen(ptydev) - 2] = ttydev[strlen(ttydev) - 2] =
-			passedPty[0];
-		ptydev[strlen(ptydev) - 1] = ttydev[strlen(ttydev) - 1] =
-			passedPty[1];
+		ptydev[strlen(ptydev) - 2] =
+		ttydev[strlen(ttydev) - 2] = passedPty[0];
+		ptydev[strlen(ptydev) - 1] =
+		ttydev[strlen(ttydev) - 1] = passedPty[1];
 
 		setgid (screen->gid);
 		setuid (screen->uid);
@@ -1372,8 +1376,8 @@
 			 * if started directly from xdm or xinit,
 			 * in which case we just use the defaults as above.
 			 */
-/**/		        if(ioctl(tty, TCGETA, &tio) == -1)
-			        tio = d_tio;
+/**/			if(ioctl(tty, TCGETA, &tio) == -1)
+				tio = d_tio;
 
 			close (tty);
 			/* tty is no longer an open fd! */
@@ -1470,7 +1474,7 @@
 		ws.ws_ypixel = FullHeight(screen);
 	}
 
-	if (!am_slave) {
+	if (am_slave < 0) {
 
 		char sema[40];
 		HEV sev;
@@ -1504,7 +1508,7 @@
 			if ((tty = open(ttydev, O_RDWR, 0)) < 0) {
 				/* dumm gelaufen */
 				fprintf(stderr, "Cannot open slave side of PTY\n");
-		        	exit(1);
+				exit(1);
 			}
 
 			/* use the same tty name that everyone else will use
@@ -1649,14 +1653,8 @@
 			if (!ptr) ptr = getenv("SHELL");
 			if (!ptr) ptr = getenv("OS2_SHELL");
 			if (!ptr) ptr = "SORRY_NO_SHELL_FOUND";
-
-			if (shname = strrchr(ptr, '/'))
-				shname++;
-			else if (shname = strrchr(ptr,'\\'))
-				shname++;
-			else
-				shname = ptr;
 
+			shname = x_basename(ptr);
 			if (command_to_exec) {
 				char *exargv[10]; /*XXX*/
 
@@ -1722,7 +1720,7 @@
 	if(screen->logging)
 		CloseLog(screen);
 #endif
-	if (!am_slave) {
+	if (am_slave < 0) {
 		/* restore ownership of tty and pty */
 		chown (ttydev, 0, 0);
 		chown (ptydev, 0, 0);
@@ -1794,7 +1792,7 @@
     int count = 0;
 
     while (1) {
-	while (*s && isascii(*s) && isspace(*s)) s++;
+	while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s))) s++;
 	if (!*s) return count;
 
 	for (mp = modelist; mp->name; mp++) {
@@ -1803,7 +1801,7 @@
 	if (!mp->name) return -1;
 
 	s += mp->len;
-	while (*s && isascii(*s) && isspace(*s)) s++;
+	while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s))) s++;
 	if (!*s) return -1;
 
 	if (*s == '^') {
Index: xc/programs/xterm/precompose.c
diff -u /dev/null xc/programs/xterm/precompose.c:1.2
--- /dev/null	Mon Dec 18 14:36:24 2000
+++ xc/programs/xterm/precompose.c	Tue Oct 31 20:12:41 2000
@@ -0,0 +1,1026 @@
+/*
+ * Canonical Compositions
+ *
+ * DO NOT EDIT BY HAND! This is generated by the script
+ * unicode/make-precompose.sh
+ */
+/* $XFree86: xc/programs/xterm/precompose.c,v 1.2 2000/11/01 01:12:41 dawes Exp $ */
+
+#include <precompose.h>
+
+struct {
+  int replacement;
+  int base;
+  int comb; 
+} precompositions[] = {
+{ 0x226E, 0x003C, 0x0338},
+{ 0x2260, 0x003D, 0x0338},
+{ 0x226F, 0x003E, 0x0338},
+{ 0x00C0, 0x0041, 0x0300},
+{ 0x00C1, 0x0041, 0x0301},
+{ 0x00C2, 0x0041, 0x0302},
+{ 0x00C3, 0x0041, 0x0303},
+{ 0x0100, 0x0041, 0x0304},
+{ 0x0102, 0x0041, 0x0306},
+{ 0x0226, 0x0041, 0x0307},
+{ 0x00C4, 0x0041, 0x0308},
+{ 0x1EA2, 0x0041, 0x0309},
+{ 0x00C5, 0x0041, 0x030A},
+{ 0x01CD, 0x0041, 0x030C},
+{ 0x0200, 0x0041, 0x030F},
+{ 0x0202, 0x0041, 0x0311},
+{ 0x1EA0, 0x0041, 0x0323},
+{ 0x1E00, 0x0041, 0x0325},
+{ 0x0104, 0x0041, 0x0328},
+{ 0x1E02, 0x0042, 0x0307},
+{ 0x1E04, 0x0042, 0x0323},
+{ 0x1E06, 0x0042, 0x0331},
+{ 0x0106, 0x0043, 0x0301},
+{ 0x0108, 0x0043, 0x0302},
+{ 0x010A, 0x0043, 0x0307},
+{ 0x010C, 0x0043, 0x030C},
+{ 0x00C7, 0x0043, 0x0327},
+{ 0x1E0A, 0x0044, 0x0307},
+{ 0x010E, 0x0044, 0x030C},
+{ 0x1E0C, 0x0044, 0x0323},
+{ 0x1E10, 0x0044, 0x0327},
+{ 0x1E12, 0x0044, 0x032D},
+{ 0x1E0E, 0x0044, 0x0331},
+{ 0x00C8, 0x0045, 0x0300},
+{ 0x00C9, 0x0045, 0x0301},
+{ 0x00CA, 0x0045, 0x0302},
+{ 0x1EBC, 0x0045, 0x0303},
+{ 0x0112, 0x0045, 0x0304},
+{ 0x0114, 0x0045, 0x0306},
+{ 0x0116, 0x0045, 0x0307},
+{ 0x00CB, 0x0045, 0x0308},
+{ 0x1EBA, 0x0045, 0x0309},
+{ 0x011A, 0x0045, 0x030C},
+{ 0x0204, 0x0045, 0x030F},
+{ 0x0206, 0x0045, 0x0311},
+{ 0x1EB8, 0x0045, 0x0323},
+{ 0x0228, 0x0045, 0x0327},
+{ 0x0118, 0x0045, 0x0328},
+{ 0x1E18, 0x0045, 0x032D},
+{ 0x1E1A, 0x0045, 0x0330},
+{ 0x1E1E, 0x0046, 0x0307},
+{ 0x01F4, 0x0047, 0x0301},
+{ 0x011C, 0x0047, 0x0302},
+{ 0x1E20, 0x0047, 0x0304},
+{ 0x011E, 0x0047, 0x0306},
+{ 0x0120, 0x0047, 0x0307},
+{ 0x01E6, 0x0047, 0x030C},
+{ 0x0122, 0x0047, 0x0327},
+{ 0x0124, 0x0048, 0x0302},
+{ 0x1E22, 0x0048, 0x0307},
+{ 0x1E26, 0x0048, 0x0308},
+{ 0x021E, 0x0048, 0x030C},
+{ 0x1E24, 0x0048, 0x0323},
+{ 0x1E28, 0x0048, 0x0327},
+{ 0x1E2A, 0x0048, 0x032E},
+{ 0x00CC, 0x0049, 0x0300},
+{ 0x00CD, 0x0049, 0x0301},
+{ 0x00CE, 0x0049, 0x0302},
+{ 0x0128, 0x0049, 0x0303},
+{ 0x012A, 0x0049, 0x0304},
+{ 0x012C, 0x0049, 0x0306},
+{ 0x0130, 0x0049, 0x0307},
+{ 0x00CF, 0x0049, 0x0308},
+{ 0x1EC8, 0x0049, 0x0309},
+{ 0x01CF, 0x0049, 0x030C},
+{ 0x0208, 0x0049, 0x030F},
+{ 0x020A, 0x0049, 0x0311},
+{ 0x1ECA, 0x0049, 0x0323},
+{ 0x012E, 0x0049, 0x0328},
+{ 0x1E2C, 0x0049, 0x0330},
+{ 0x0134, 0x004A, 0x0302},
+{ 0x1E30, 0x004B, 0x0301},
+{ 0x01E8, 0x004B, 0x030C},
+{ 0x1E32, 0x004B, 0x0323},
+{ 0x0136, 0x004B, 0x0327},
+{ 0x1E34, 0x004B, 0x0331},
+{ 0x0139, 0x004C, 0x0301},
+{ 0x013D, 0x004C, 0x030C},
+{ 0x1E36, 0x004C, 0x0323},
+{ 0x013B, 0x004C, 0x0327},
+{ 0x1E3C, 0x004C, 0x032D},
+{ 0x1E3A, 0x004C, 0x0331},
+{ 0x1E3E, 0x004D, 0x0301},
+{ 0x1E40, 0x004D, 0x0307},
+{ 0x1E42, 0x004D, 0x0323},
+{ 0x01F8, 0x004E, 0x0300},
+{ 0x0143, 0x004E, 0x0301},
+{ 0x00D1, 0x004E, 0x0303},
+{ 0x1E44, 0x004E, 0x0307},
+{ 0x0147, 0x004E, 0x030C},
+{ 0x1E46, 0x004E, 0x0323},
+{ 0x0145, 0x004E, 0x0327},
+{ 0x1E4A, 0x004E, 0x032D},
+{ 0x1E48, 0x004E, 0x0331},
+{ 0x00D2, 0x004F, 0x0300},
+{ 0x00D3, 0x004F, 0x0301},
+{ 0x00D4, 0x004F, 0x0302},
+{ 0x00D5, 0x004F, 0x0303},
+{ 0x014C, 0x004F, 0x0304},
+{ 0x014E, 0x004F, 0x0306},
+{ 0x022E, 0x004F, 0x0307},
+{ 0x00D6, 0x004F, 0x0308},
+{ 0x1ECE, 0x004F, 0x0309},
+{ 0x0150, 0x004F, 0x030B},
+{ 0x01D1, 0x004F, 0x030C},
+{ 0x020C, 0x004F, 0x030F},
+{ 0x020E, 0x004F, 0x0311},
+{ 0x01A0, 0x004F, 0x031B},
+{ 0x1ECC, 0x004F, 0x0323},
+{ 0x01EA, 0x004F, 0x0328},
+{ 0x1E54, 0x0050, 0x0301},
+{ 0x1E56, 0x0050, 0x0307},
+{ 0x0154, 0x0052, 0x0301},
+{ 0x1E58, 0x0052, 0x0307},
+{ 0x0158, 0x0052, 0x030C},
+{ 0x0210, 0x0052, 0x030F},
+{ 0x0212, 0x0052, 0x0311},
+{ 0x1E5A, 0x0052, 0x0323},
+{ 0x0156, 0x0052, 0x0327},
+{ 0x1E5E, 0x0052, 0x0331},
+{ 0x015A, 0x0053, 0x0301},
+{ 0x015C, 0x0053, 0x0302},
+{ 0x1E60, 0x0053, 0x0307},
+{ 0x0160, 0x0053, 0x030C},
+{ 0x1E62, 0x0053, 0x0323},
+{ 0x0218, 0x0053, 0x0326},
+{ 0x015E, 0x0053, 0x0327},
+{ 0x1E6A, 0x0054, 0x0307},
+{ 0x0164, 0x0054, 0x030C},
+{ 0x1E6C, 0x0054, 0x0323},
+{ 0x021A, 0x0054, 0x0326},
+{ 0x0162, 0x0054, 0x0327},
+{ 0x1E70, 0x0054, 0x032D},
+{ 0x1E6E, 0x0054, 0x0331},
+{ 0x00D9, 0x0055, 0x0300},
+{ 0x00DA, 0x0055, 0x0301},
+{ 0x00DB, 0x0055, 0x0302},
+{ 0x0168, 0x0055, 0x0303},
+{ 0x016A, 0x0055, 0x0304},
+{ 0x016C, 0x0055, 0x0306},
+{ 0x00DC, 0x0055, 0x0308},
+{ 0x1EE6, 0x0055, 0x0309},
+{ 0x016E, 0x0055, 0x030A},
+{ 0x0170, 0x0055, 0x030B},
+{ 0x01D3, 0x0055, 0x030C},
+{ 0x0214, 0x0055, 0x030F},
+{ 0x0216, 0x0055, 0x0311},
+{ 0x01AF, 0x0055, 0x031B},
+{ 0x1EE4, 0x0055, 0x0323},
+{ 0x1E72, 0x0055, 0x0324},
+{ 0x0172, 0x0055, 0x0328},
+{ 0x1E76, 0x0055, 0x032D},
+{ 0x1E74, 0x0055, 0x0330},
+{ 0x1E7C, 0x0056, 0x0303},
+{ 0x1E7E, 0x0056, 0x0323},
+{ 0x1E80, 0x0057, 0x0300},
+{ 0x1E82, 0x0057, 0x0301},
+{ 0x0174, 0x0057, 0x0302},
+{ 0x1E86, 0x0057, 0x0307},
+{ 0x1E84, 0x0057, 0x0308},
+{ 0x1E88, 0x0057, 0x0323},
+{ 0x1E8A, 0x0058, 0x0307},
+{ 0x1E8C, 0x0058, 0x0308},
+{ 0x1EF2, 0x0059, 0x0300},
+{ 0x00DD, 0x0059, 0x0301},
+{ 0x0176, 0x0059, 0x0302},
+{ 0x1EF8, 0x0059, 0x0303},
+{ 0x0232, 0x0059, 0x0304},
+{ 0x1E8E, 0x0059, 0x0307},
+{ 0x0178, 0x0059, 0x0308},
+{ 0x1EF6, 0x0059, 0x0309},
+{ 0x1EF4, 0x0059, 0x0323},
+{ 0x0179, 0x005A, 0x0301},
+{ 0x1E90, 0x005A, 0x0302},
+{ 0x017B, 0x005A, 0x0307},
+{ 0x017D, 0x005A, 0x030C},
+{ 0x1E92, 0x005A, 0x0323},
+{ 0x1E94, 0x005A, 0x0331},
+{ 0x00E0, 0x0061, 0x0300},
+{ 0x00E1, 0x0061, 0x0301},
+{ 0x00E2, 0x0061, 0x0302},
+{ 0x00E3, 0x0061, 0x0303},
+{ 0x0101, 0x0061, 0x0304},
+{ 0x0103, 0x0061, 0x0306},
+{ 0x0227, 0x0061, 0x0307},
+{ 0x00E4, 0x0061, 0x0308},
+{ 0x1EA3, 0x0061, 0x0309},
+{ 0x00E5, 0x0061, 0x030A},
+{ 0x01CE, 0x0061, 0x030C},
+{ 0x0201, 0x0061, 0x030F},
+{ 0x0203, 0x0061, 0x0311},
+{ 0x1EA1, 0x0061, 0x0323},
+{ 0x1E01, 0x0061, 0x0325},
+{ 0x0105, 0x0061, 0x0328},
+{ 0x1E03, 0x0062, 0x0307},
+{ 0x1E05, 0x0062, 0x0323},
+{ 0x1E07, 0x0062, 0x0331},
+{ 0x0107, 0x0063, 0x0301},
+{ 0x0109, 0x0063, 0x0302},
+{ 0x010B, 0x0063, 0x0307},
+{ 0x010D, 0x0063, 0x030C},
+{ 0x00E7, 0x0063, 0x0327},
+{ 0x1E0B, 0x0064, 0x0307},
+{ 0x010F, 0x0064, 0x030C},
+{ 0x1E0D, 0x0064, 0x0323},
+{ 0x1E11, 0x0064, 0x0327},
+{ 0x1E13, 0x0064, 0x032D},
+{ 0x1E0F, 0x0064, 0x0331},
+{ 0x00E8, 0x0065, 0x0300},
+{ 0x00E9, 0x0065, 0x0301},
+{ 0x00EA, 0x0065, 0x0302},
+{ 0x1EBD, 0x0065, 0x0303},
+{ 0x0113, 0x0065, 0x0304},
+{ 0x0115, 0x0065, 0x0306},
+{ 0x0117, 0x0065, 0x0307},
+{ 0x00EB, 0x0065, 0x0308},
+{ 0x1EBB, 0x0065, 0x0309},
+{ 0x011B, 0x0065, 0x030C},
+{ 0x0205, 0x0065, 0x030F},
+{ 0x0207, 0x0065, 0x0311},
+{ 0x1EB9, 0x0065, 0x0323},
+{ 0x0229, 0x0065, 0x0327},
+{ 0x0119, 0x0065, 0x0328},
+{ 0x1E19, 0x0065, 0x032D},
+{ 0x1E1B, 0x0065, 0x0330},
+{ 0x1E1F, 0x0066, 0x0307},
+{ 0x01F5, 0x0067, 0x0301},
+{ 0x011D, 0x0067, 0x0302},
+{ 0x1E21, 0x0067, 0x0304},
+{ 0x011F, 0x0067, 0x0306},
+{ 0x0121, 0x0067, 0x0307},
+{ 0x01E7, 0x0067, 0x030C},
+{ 0x0123, 0x0067, 0x0327},
+{ 0x0125, 0x0068, 0x0302},
+{ 0x1E23, 0x0068, 0x0307},
+{ 0x1E27, 0x0068, 0x0308},
+{ 0x021F, 0x0068, 0x030C},
+{ 0x1E25, 0x0068, 0x0323},
+{ 0x1E29, 0x0068, 0x0327},
+{ 0x1E2B, 0x0068, 0x032E},
+{ 0x1E96, 0x0068, 0x0331},
+{ 0x00EC, 0x0069, 0x0300},
+{ 0x00ED, 0x0069, 0x0301},
+{ 0x00EE, 0x0069, 0x0302},
+{ 0x0129, 0x0069, 0x0303},
+{ 0x012B, 0x0069, 0x0304},
+{ 0x012D, 0x0069, 0x0306},
+{ 0x00EF, 0x0069, 0x0308},
+{ 0x1EC9, 0x0069, 0x0309},
+{ 0x01D0, 0x0069, 0x030C},
+{ 0x0209, 0x0069, 0x030F},
+{ 0x020B, 0x0069, 0x0311},
+{ 0x1ECB, 0x0069, 0x0323},
+{ 0x012F, 0x0069, 0x0328},
+{ 0x1E2D, 0x0069, 0x0330},
+{ 0x0135, 0x006A, 0x0302},
+{ 0x01F0, 0x006A, 0x030C},
+{ 0x1E31, 0x006B, 0x0301},
+{ 0x01E9, 0x006B, 0x030C},
+{ 0x1E33, 0x006B, 0x0323},
+{ 0x0137, 0x006B, 0x0327},
+{ 0x1E35, 0x006B, 0x0331},
+{ 0x013A, 0x006C, 0x0301},
+{ 0x013E, 0x006C, 0x030C},
+{ 0x1E37, 0x006C, 0x0323},
+{ 0x013C, 0x006C, 0x0327},
+{ 0x1E3D, 0x006C, 0x032D},
+{ 0x1E3B, 0x006C, 0x0331},
+{ 0x1E3F, 0x006D, 0x0301},
+{ 0x1E41, 0x006D, 0x0307},
+{ 0x1E43, 0x006D, 0x0323},
+{ 0x01F9, 0x006E, 0x0300},
+{ 0x0144, 0x006E, 0x0301},
+{ 0x00F1, 0x006E, 0x0303},
+{ 0x1E45, 0x006E, 0x0307},
+{ 0x0148, 0x006E, 0x030C},
+{ 0x1E47, 0x006E, 0x0323},
+{ 0x0146, 0x006E, 0x0327},
+{ 0x1E4B, 0x006E, 0x032D},
+{ 0x1E49, 0x006E, 0x0331},
+{ 0x00F2, 0x006F, 0x0300},
+{ 0x00F3, 0x006F, 0x0301},
+{ 0x00F4, 0x006F, 0x0302},
+{ 0x00F5, 0x006F, 0x0303},
+{ 0x014D, 0x006F, 0x0304},
+{ 0x014F, 0x006F, 0x0306},
+{ 0x022F, 0x006F, 0x0307},
+{ 0x00F6, 0x006F, 0x0308},
+{ 0x1ECF, 0x006F, 0x0309},
+{ 0x0151, 0x006F, 0x030B},
+{ 0x01D2, 0x006F, 0x030C},
+{ 0x020D, 0x006F, 0x030F},
+{ 0x020F, 0x006F, 0x0311},
+{ 0x01A1, 0x006F, 0x031B},
+{ 0x1ECD, 0x006F, 0x0323},
+{ 0x01EB, 0x006F, 0x0328},
+{ 0x1E55, 0x0070, 0x0301},
+{ 0x1E57, 0x0070, 0x0307},
+{ 0x0155, 0x0072, 0x0301},
+{ 0x1E59, 0x0072, 0x0307},
+{ 0x0159, 0x0072, 0x030C},
+{ 0x0211, 0x0072, 0x030F},
+{ 0x0213, 0x0072, 0x0311},
+{ 0x1E5B, 0x0072, 0x0323},
+{ 0x0157, 0x0072, 0x0327},
+{ 0x1E5F, 0x0072, 0x0331},
+{ 0x015B, 0x0073, 0x0301},
+{ 0x015D, 0x0073, 0x0302},
+{ 0x1E61, 0x0073, 0x0307},
+{ 0x0161, 0x0073, 0x030C},
+{ 0x1E63, 0x0073, 0x0323},
+{ 0x0219, 0x0073, 0x0326},
+{ 0x015F, 0x0073, 0x0327},
+{ 0x1E6B, 0x0074, 0x0307},
+{ 0x1E97, 0x0074, 0x0308},
+{ 0x0165, 0x0074, 0x030C},
+{ 0x1E6D, 0x0074, 0x0323},
+{ 0x021B, 0x0074, 0x0326},
+{ 0x0163, 0x0074, 0x0327},
+{ 0x1E71, 0x0074, 0x032D},
+{ 0x1E6F, 0x0074, 0x0331},
+{ 0x00F9, 0x0075, 0x0300},
+{ 0x00FA, 0x0075, 0x0301},
+{ 0x00FB, 0x0075, 0x0302},
+{ 0x0169, 0x0075, 0x0303},
+{ 0x016B, 0x0075, 0x0304},
+{ 0x016D, 0x0075, 0x0306},
+{ 0x00FC, 0x0075, 0x0308},
+{ 0x1EE7, 0x0075, 0x0309},
+{ 0x016F, 0x0075, 0x030A},
+{ 0x0171, 0x0075, 0x030B},
+{ 0x01D4, 0x0075, 0x030C},
+{ 0x0215, 0x0075, 0x030F},
+{ 0x0217, 0x0075, 0x0311},
+{ 0x01B0, 0x0075, 0x031B},
+{ 0x1EE5, 0x0075, 0x0323},
+{ 0x1E73, 0x0075, 0x0324},
+{ 0x0173, 0x0075, 0x0328},
+{ 0x1E77, 0x0075, 0x032D},
+{ 0x1E75, 0x0075, 0x0330},
+{ 0x1E7D, 0x0076, 0x0303},
+{ 0x1E7F, 0x0076, 0x0323},
+{ 0x1E81, 0x0077, 0x0300},
+{ 0x1E83, 0x0077, 0x0301},
+{ 0x0175, 0x0077, 0x0302},
+{ 0x1E87, 0x0077, 0x0307},
+{ 0x1E85, 0x0077, 0x0308},
+{ 0x1E98, 0x0077, 0x030A},
+{ 0x1E89, 0x0077, 0x0323},
+{ 0x1E8B, 0x0078, 0x0307},
+{ 0x1E8D, 0x0078, 0x0308},
+{ 0x1EF3, 0x0079, 0x0300},
+{ 0x00FD, 0x0079, 0x0301},
+{ 0x0177, 0x0079, 0x0302},
+{ 0x1EF9, 0x0079, 0x0303},
+{ 0x0233, 0x0079, 0x0304},
+{ 0x1E8F, 0x0079, 0x0307},
+{ 0x00FF, 0x0079, 0x0308},
+{ 0x1EF7, 0x0079, 0x0309},
+{ 0x1E99, 0x0079, 0x030A},
+{ 0x1EF5, 0x0079, 0x0323},
+{ 0x017A, 0x007A, 0x0301},
+{ 0x1E91, 0x007A, 0x0302},
+{ 0x017C, 0x007A, 0x0307},
+{ 0x017E, 0x007A, 0x030C},
+{ 0x1E93, 0x007A, 0x0323},
+{ 0x1E95, 0x007A, 0x0331},
+{ 0x1FED, 0x00A8, 0x0300},
+{ 0x0385, 0x00A8, 0x0301},
+{ 0x1FC1, 0x00A8, 0x0342},
+{ 0x1EA6, 0x00C2, 0x0300},
+{ 0x1EA4, 0x00C2, 0x0301},
+{ 0x1EAA, 0x00C2, 0x0303},
+{ 0x1EA8, 0x00C2, 0x0309},
+{ 0x01DE, 0x00C4, 0x0304},
+{ 0x01FA, 0x00C5, 0x0301},
+{ 0x01FC, 0x00C6, 0x0301},
+{ 0x01E2, 0x00C6, 0x0304},
+{ 0x1E08, 0x00C7, 0x0301},
+{ 0x1EC0, 0x00CA, 0x0300},
+{ 0x1EBE, 0x00CA, 0x0301},
+{ 0x1EC4, 0x00CA, 0x0303},
+{ 0x1EC2, 0x00CA, 0x0309},
+{ 0x1E2E, 0x00CF, 0x0301},
+{ 0x1ED2, 0x00D4, 0x0300},
+{ 0x1ED0, 0x00D4, 0x0301},
+{ 0x1ED6, 0x00D4, 0x0303},
+{ 0x1ED4, 0x00D4, 0x0309},
+{ 0x1E4C, 0x00D5, 0x0301},
+{ 0x022C, 0x00D5, 0x0304},
+{ 0x1E4E, 0x00D5, 0x0308},
+{ 0x022A, 0x00D6, 0x0304},
+{ 0x01FE, 0x00D8, 0x0301},
+{ 0x01DB, 0x00DC, 0x0300},
+{ 0x01D7, 0x00DC, 0x0301},
+{ 0x01D5, 0x00DC, 0x0304},
+{ 0x01D9, 0x00DC, 0x030C},
+{ 0x1EA7, 0x00E2, 0x0300},
+{ 0x1EA5, 0x00E2, 0x0301},
+{ 0x1EAB, 0x00E2, 0x0303},
+{ 0x1EA9, 0x00E2, 0x0309},
+{ 0x01DF, 0x00E4, 0x0304},
+{ 0x01FB, 0x00E5, 0x0301},
+{ 0x01FD, 0x00E6, 0x0301},
+{ 0x01E3, 0x00E6, 0x0304},
+{ 0x1E09, 0x00E7, 0x0301},
+{ 0x1EC1, 0x00EA, 0x0300},
+{ 0x1EBF, 0x00EA, 0x0301},
+{ 0x1EC5, 0x00EA, 0x0303},
+{ 0x1EC3, 0x00EA, 0x0309},
+{ 0x1E2F, 0x00EF, 0x0301},
+{ 0x1ED3, 0x00F4, 0x0300},
+{ 0x1ED1, 0x00F4, 0x0301},
+{ 0x1ED7, 0x00F4, 0x0303},
+{ 0x1ED5, 0x00F4, 0x0309},
+{ 0x1E4D, 0x00F5, 0x0301},
+{ 0x022D, 0x00F5, 0x0304},
+{ 0x1E4F, 0x00F5, 0x0308},
+{ 0x022B, 0x00F6, 0x0304},
+{ 0x01FF, 0x00F8, 0x0301},
+{ 0x01DC, 0x00FC, 0x0300},
+{ 0x01D8, 0x00FC, 0x0301},
+{ 0x01D6, 0x00FC, 0x0304},
+{ 0x01DA, 0x00FC, 0x030C},
+{ 0x1EB0, 0x0102, 0x0300},
+{ 0x1EAE, 0x0102, 0x0301},
+{ 0x1EB4, 0x0102, 0x0303},
+{ 0x1EB2, 0x0102, 0x0309},
+{ 0x1EB1, 0x0103, 0x0300},
+{ 0x1EAF, 0x0103, 0x0301},
+{ 0x1EB5, 0x0103, 0x0303},
+{ 0x1EB3, 0x0103, 0x0309},
+{ 0x1E14, 0x0112, 0x0300},
+{ 0x1E16, 0x0112, 0x0301},
+{ 0x1E15, 0x0113, 0x0300},
+{ 0x1E17, 0x0113, 0x0301},
+{ 0x1E50, 0x014C, 0x0300},
+{ 0x1E52, 0x014C, 0x0301},
+{ 0x1E51, 0x014D, 0x0300},
+{ 0x1E53, 0x014D, 0x0301},
+{ 0x1E64, 0x015A, 0x0307},
+{ 0x1E65, 0x015B, 0x0307},
+{ 0x1E66, 0x0160, 0x0307},
+{ 0x1E67, 0x0161, 0x0307},
+{ 0x1E78, 0x0168, 0x0301},
+{ 0x1E79, 0x0169, 0x0301},
+{ 0x1E7A, 0x016A, 0x0308},
+{ 0x1E7B, 0x016B, 0x0308},
+{ 0x1E9B, 0x017F, 0x0307},
+{ 0x1EDC, 0x01A0, 0x0300},
+{ 0x1EDA, 0x01A0, 0x0301},
+{ 0x1EE0, 0x01A0, 0x0303},
+{ 0x1EDE, 0x01A0, 0x0309},
+{ 0x1EE2, 0x01A0, 0x0323},
+{ 0x1EDD, 0x01A1, 0x0300},
+{ 0x1EDB, 0x01A1, 0x0301},
+{ 0x1EE1, 0x01A1, 0x0303},
+{ 0x1EDF, 0x01A1, 0x0309},
+{ 0x1EE3, 0x01A1, 0x0323},
+{ 0x1EEA, 0x01AF, 0x0300},
+{ 0x1EE8, 0x01AF, 0x0301},
+{ 0x1EEE, 0x01AF, 0x0303},
+{ 0x1EEC, 0x01AF, 0x0309},
+{ 0x1EF0, 0x01AF, 0x0323},
+{ 0x1EEB, 0x01B0, 0x0300},
+{ 0x1EE9, 0x01B0, 0x0301},
+{ 0x1EEF, 0x01B0, 0x0303},
+{ 0x1EED, 0x01B0, 0x0309},
+{ 0x1EF1, 0x01B0, 0x0323},
+{ 0x01EE, 0x01B7, 0x030C},
+{ 0x01EC, 0x01EA, 0x0304},
+{ 0x01ED, 0x01EB, 0x0304},
+{ 0x01E0, 0x0226, 0x0304},
+{ 0x01E1, 0x0227, 0x0304},
+{ 0x1E1C, 0x0228, 0x0306},
+{ 0x1E1D, 0x0229, 0x0306},
+{ 0x0230, 0x022E, 0x0304},
+{ 0x0231, 0x022F, 0x0304},
+{ 0x01EF, 0x0292, 0x030C},
+{ 0x0344, 0x0308, 0x0301},
+{ 0x1FBA, 0x0391, 0x0300},
+{ 0x0386, 0x0391, 0x0301},
+{ 0x1FB9, 0x0391, 0x0304},
+{ 0x1FB8, 0x0391, 0x0306},
+{ 0x1F08, 0x0391, 0x0313},
+{ 0x1F09, 0x0391, 0x0314},
+{ 0x1FBC, 0x0391, 0x0345},
+{ 0x1FC8, 0x0395, 0x0300},
+{ 0x0388, 0x0395, 0x0301},
+{ 0x1F18, 0x0395, 0x0313},
+{ 0x1F19, 0x0395, 0x0314},
+{ 0x1FCA, 0x0397, 0x0300},
+{ 0x0389, 0x0397, 0x0301},
+{ 0x1F28, 0x0397, 0x0313},
+{ 0x1F29, 0x0397, 0x0314},
+{ 0x1FCC, 0x0397, 0x0345},
+{ 0x1FDA, 0x0399, 0x0300},
+{ 0x038A, 0x0399, 0x0301},
+{ 0x1FD9, 0x0399, 0x0304},
+{ 0x1FD8, 0x0399, 0x0306},
+{ 0x03AA, 0x0399, 0x0308},
+{ 0x1F38, 0x0399, 0x0313},
+{ 0x1F39, 0x0399, 0x0314},
+{ 0x1FF8, 0x039F, 0x0300},
+{ 0x038C, 0x039F, 0x0301},
+{ 0x1F48, 0x039F, 0x0313},
+{ 0x1F49, 0x039F, 0x0314},
+{ 0x1FEC, 0x03A1, 0x0314},
+{ 0x1FEA, 0x03A5, 0x0300},
+{ 0x038E, 0x03A5, 0x0301},
+{ 0x1FE9, 0x03A5, 0x0304},
+{ 0x1FE8, 0x03A5, 0x0306},
+{ 0x03AB, 0x03A5, 0x0308},
+{ 0x1F59, 0x03A5, 0x0314},
+{ 0x1FFA, 0x03A9, 0x0300},
+{ 0x038F, 0x03A9, 0x0301},
+{ 0x1F68, 0x03A9, 0x0313},
+{ 0x1F69, 0x03A9, 0x0314},
+{ 0x1FFC, 0x03A9, 0x0345},
+{ 0x1FB4, 0x03AC, 0x0345},
+{ 0x1FC4, 0x03AE, 0x0345},
+{ 0x1F70, 0x03B1, 0x0300},
+{ 0x03AC, 0x03B1, 0x0301},
+{ 0x1FB1, 0x03B1, 0x0304},
+{ 0x1FB0, 0x03B1, 0x0306},
+{ 0x1F00, 0x03B1, 0x0313},
+{ 0x1F01, 0x03B1, 0x0314},
+{ 0x1FB6, 0x03B1, 0x0342},
+{ 0x1FB3, 0x03B1, 0x0345},
+{ 0x1F72, 0x03B5, 0x0300},
+{ 0x03AD, 0x03B5, 0x0301},
+{ 0x1F10, 0x03B5, 0x0313},
+{ 0x1F11, 0x03B5, 0x0314},
+{ 0x1F74, 0x03B7, 0x0300},
+{ 0x03AE, 0x03B7, 0x0301},
+{ 0x1F20, 0x03B7, 0x0313},
+{ 0x1F21, 0x03B7, 0x0314},
+{ 0x1FC6, 0x03B7, 0x0342},
+{ 0x1FC3, 0x03B7, 0x0345},
+{ 0x1F76, 0x03B9, 0x0300},
+{ 0x03AF, 0x03B9, 0x0301},
+{ 0x1FD1, 0x03B9, 0x0304},
+{ 0x1FD0, 0x03B9, 0x0306},
+{ 0x03CA, 0x03B9, 0x0308},
+{ 0x1F30, 0x03B9, 0x0313},
+{ 0x1F31, 0x03B9, 0x0314},
+{ 0x1FD6, 0x03B9, 0x0342},
+{ 0x1F78, 0x03BF, 0x0300},
+{ 0x03CC, 0x03BF, 0x0301},
+{ 0x1F40, 0x03BF, 0x0313},
+{ 0x1F41, 0x03BF, 0x0314},
+{ 0x1FE4, 0x03C1, 0x0313},
+{ 0x1FE5, 0x03C1, 0x0314},
+{ 0x1F7A, 0x03C5, 0x0300},
+{ 0x03CD, 0x03C5, 0x0301},
+{ 0x1FE1, 0x03C5, 0x0304},
+{ 0x1FE0, 0x03C5, 0x0306},
+{ 0x03CB, 0x03C5, 0x0308},
+{ 0x1F50, 0x03C5, 0x0313},
+{ 0x1F51, 0x03C5, 0x0314},
+{ 0x1FE6, 0x03C5, 0x0342},
+{ 0x1F7C, 0x03C9, 0x0300},
+{ 0x03CE, 0x03C9, 0x0301},
+{ 0x1F60, 0x03C9, 0x0313},
+{ 0x1F61, 0x03C9, 0x0314},
+{ 0x1FF6, 0x03C9, 0x0342},
+{ 0x1FF3, 0x03C9, 0x0345},
+{ 0x1FD2, 0x03CA, 0x0300},
+{ 0x0390, 0x03CA, 0x0301},
+{ 0x1FD7, 0x03CA, 0x0342},
+{ 0x1FE2, 0x03CB, 0x0300},
+{ 0x03B0, 0x03CB, 0x0301},
+{ 0x1FE7, 0x03CB, 0x0342},
+{ 0x1FF4, 0x03CE, 0x0345},
+{ 0x03D3, 0x03D2, 0x0301},
+{ 0x03D4, 0x03D2, 0x0308},
+{ 0x0407, 0x0406, 0x0308},
+{ 0x04D0, 0x0410, 0x0306},
+{ 0x04D2, 0x0410, 0x0308},
+{ 0x0403, 0x0413, 0x0301},
+{ 0x0400, 0x0415, 0x0300},
+{ 0x04D6, 0x0415, 0x0306},
+{ 0x0401, 0x0415, 0x0308},
+{ 0x04C1, 0x0416, 0x0306},
+{ 0x04DC, 0x0416, 0x0308},
+{ 0x04DE, 0x0417, 0x0308},
+{ 0x040D, 0x0418, 0x0300},
+{ 0x04E2, 0x0418, 0x0304},
+{ 0x0419, 0x0418, 0x0306},
+{ 0x04E4, 0x0418, 0x0308},
+{ 0x040C, 0x041A, 0x0301},
+{ 0x04E6, 0x041E, 0x0308},
+{ 0x04EE, 0x0423, 0x0304},
+{ 0x040E, 0x0423, 0x0306},
+{ 0x04F0, 0x0423, 0x0308},
+{ 0x04F2, 0x0423, 0x030B},
+{ 0x04F4, 0x0427, 0x0308},
+{ 0x04F8, 0x042B, 0x0308},
+{ 0x04EC, 0x042D, 0x0308},
+{ 0x04D1, 0x0430, 0x0306},
+{ 0x04D3, 0x0430, 0x0308},
+{ 0x0453, 0x0433, 0x0301},
+{ 0x0450, 0x0435, 0x0300},
+{ 0x04D7, 0x0435, 0x0306},
+{ 0x0451, 0x0435, 0x0308},
+{ 0x04C2, 0x0436, 0x0306},
+{ 0x04DD, 0x0436, 0x0308},
+{ 0x04DF, 0x0437, 0x0308},
+{ 0x045D, 0x0438, 0x0300},
+{ 0x04E3, 0x0438, 0x0304},
+{ 0x0439, 0x0438, 0x0306},
+{ 0x04E5, 0x0438, 0x0308},
+{ 0x045C, 0x043A, 0x0301},
+{ 0x04E7, 0x043E, 0x0308},
+{ 0x04EF, 0x0443, 0x0304},
+{ 0x045E, 0x0443, 0x0306},
+{ 0x04F1, 0x0443, 0x0308},
+{ 0x04F3, 0x0443, 0x030B},
+{ 0x04F5, 0x0447, 0x0308},
+{ 0x04F9, 0x044B, 0x0308},
+{ 0x04ED, 0x044D, 0x0308},
+{ 0x0457, 0x0456, 0x0308},
+{ 0x0476, 0x0474, 0x030F},
+{ 0x0477, 0x0475, 0x030F},
+{ 0x04DA, 0x04D8, 0x0308},
+{ 0x04DB, 0x04D9, 0x0308},
+{ 0x04EA, 0x04E8, 0x0308},
+{ 0x04EB, 0x04E9, 0x0308},
+{ 0xFB2E, 0x05D0, 0x05B7},
+{ 0xFB2F, 0x05D0, 0x05B8},
+{ 0xFB30, 0x05D0, 0x05BC},
+{ 0xFB31, 0x05D1, 0x05BC},
+{ 0xFB4C, 0x05D1, 0x05BF},
+{ 0xFB32, 0x05D2, 0x05BC},
+{ 0xFB33, 0x05D3, 0x05BC},
+{ 0xFB34, 0x05D4, 0x05BC},
+{ 0xFB4B, 0x05D5, 0x05B9},
+{ 0xFB35, 0x05D5, 0x05BC},
+{ 0xFB36, 0x05D6, 0x05BC},
+{ 0xFB38, 0x05D8, 0x05BC},
+{ 0xFB1D, 0x05D9, 0x05B4},
+{ 0xFB39, 0x05D9, 0x05BC},
+{ 0xFB3A, 0x05DA, 0x05BC},
+{ 0xFB3B, 0x05DB, 0x05BC},
+{ 0xFB4D, 0x05DB, 0x05BF},
+{ 0xFB3C, 0x05DC, 0x05BC},
+{ 0xFB3E, 0x05DE, 0x05BC},
+{ 0xFB40, 0x05E0, 0x05BC},
+{ 0xFB41, 0x05E1, 0x05BC},
+{ 0xFB43, 0x05E3, 0x05BC},
+{ 0xFB44, 0x05E4, 0x05BC},
+{ 0xFB4E, 0x05E4, 0x05BF},
+{ 0xFB46, 0x05E6, 0x05BC},
+{ 0xFB47, 0x05E7, 0x05BC},
+{ 0xFB48, 0x05E8, 0x05BC},
+{ 0xFB49, 0x05E9, 0x05BC},
+{ 0xFB2A, 0x05E9, 0x05C1},
+{ 0xFB2B, 0x05E9, 0x05C2},
+{ 0xFB4A, 0x05EA, 0x05BC},
+{ 0xFB1F, 0x05F2, 0x05B7},
+{ 0x0622, 0x0627, 0x0653},
+{ 0x0623, 0x0627, 0x0654},
+{ 0x0625, 0x0627, 0x0655},
+{ 0x0624, 0x0648, 0x0654},
+{ 0x0626, 0x064A, 0x0654},
+{ 0x06C2, 0x06C1, 0x0654},
+{ 0x06D3, 0x06D2, 0x0654},
+{ 0x06C0, 0x06D5, 0x0654},
+{ 0x0958, 0x0915, 0x093C},
+{ 0x0959, 0x0916, 0x093C},
+{ 0x095A, 0x0917, 0x093C},
+{ 0x095B, 0x091C, 0x093C},
+{ 0x095C, 0x0921, 0x093C},
+{ 0x095D, 0x0922, 0x093C},
+{ 0x0929, 0x0928, 0x093C},
+{ 0x095E, 0x092B, 0x093C},
+{ 0x095F, 0x092F, 0x093C},
+{ 0x0931, 0x0930, 0x093C},
+{ 0x0934, 0x0933, 0x093C},
+{ 0x09DC, 0x09A1, 0x09BC},
+{ 0x09DD, 0x09A2, 0x09BC},
+{ 0x09DF, 0x09AF, 0x09BC},
+{ 0x09CB, 0x09C7, 0x09BE},
+{ 0x09CC, 0x09C7, 0x09D7},
+{ 0x0A59, 0x0A16, 0x0A3C},
+{ 0x0A5A, 0x0A17, 0x0A3C},
+{ 0x0A5B, 0x0A1C, 0x0A3C},
+{ 0x0A5E, 0x0A2B, 0x0A3C},
+{ 0x0A33, 0x0A32, 0x0A3C},
+{ 0x0A36, 0x0A38, 0x0A3C},
+{ 0x0B5C, 0x0B21, 0x0B3C},
+{ 0x0B5D, 0x0B22, 0x0B3C},
+{ 0x0B4B, 0x0B47, 0x0B3E},
+{ 0x0B48, 0x0B47, 0x0B56},
+{ 0x0B4C, 0x0B47, 0x0B57},
+{ 0x0B94, 0x0B92, 0x0BD7},
+{ 0x0BCA, 0x0BC6, 0x0BBE},
+{ 0x0BCC, 0x0BC6, 0x0BD7},
+{ 0x0BCB, 0x0BC7, 0x0BBE},
+{ 0x0C48, 0x0C46, 0x0C56},
+{ 0x0CC0, 0x0CBF, 0x0CD5},
+{ 0x0CCA, 0x0CC6, 0x0CC2},
+{ 0x0CC7, 0x0CC6, 0x0CD5},
+{ 0x0CC8, 0x0CC6, 0x0CD6},
+{ 0x0CCB, 0x0CCA, 0x0CD5},
+{ 0x0D4A, 0x0D46, 0x0D3E},
+{ 0x0D4C, 0x0D46, 0x0D57},
+{ 0x0D4B, 0x0D47, 0x0D3E},
+{ 0x0DDA, 0x0DD9, 0x0DCA},
+{ 0x0DDC, 0x0DD9, 0x0DCF},
+{ 0x0DDE, 0x0DD9, 0x0DDF},
+{ 0x0DDD, 0x0DDC, 0x0DCA},
+{ 0x0F69, 0x0F40, 0x0FB5},
+{ 0x0F43, 0x0F42, 0x0FB7},
+{ 0x0F4D, 0x0F4C, 0x0FB7},
+{ 0x0F52, 0x0F51, 0x0FB7},
+{ 0x0F57, 0x0F56, 0x0FB7},
+{ 0x0F5C, 0x0F5B, 0x0FB7},
+{ 0x0F73, 0x0F71, 0x0F72},
+{ 0x0F75, 0x0F71, 0x0F74},
+{ 0x0F81, 0x0F71, 0x0F80},
+{ 0x0FB9, 0x0F90, 0x0FB5},
+{ 0x0F93, 0x0F92, 0x0FB7},
+{ 0x0F9D, 0x0F9C, 0x0FB7},
+{ 0x0FA2, 0x0FA1, 0x0FB7},
+{ 0x0FA7, 0x0FA6, 0x0FB7},
+{ 0x0FAC, 0x0FAB, 0x0FB7},
+{ 0x0F76, 0x0FB2, 0x0F80},
+{ 0x0F78, 0x0FB3, 0x0F80},
+{ 0x1026, 0x1025, 0x102E},
+{ 0x1E38, 0x1E36, 0x0304},
+{ 0x1E39, 0x1E37, 0x0304},
+{ 0x1E5C, 0x1E5A, 0x0304},
+{ 0x1E5D, 0x1E5B, 0x0304},
+{ 0x1E68, 0x1E62, 0x0307},
+{ 0x1E69, 0x1E63, 0x0307},
+{ 0x1EAC, 0x1EA0, 0x0302},
+{ 0x1EB6, 0x1EA0, 0x0306},
+{ 0x1EAD, 0x1EA1, 0x0302},
+{ 0x1EB7, 0x1EA1, 0x0306},
+{ 0x1EC6, 0x1EB8, 0x0302},
+{ 0x1EC7, 0x1EB9, 0x0302},
+{ 0x1ED8, 0x1ECC, 0x0302},
+{ 0x1ED9, 0x1ECD, 0x0302},
+{ 0x1F02, 0x1F00, 0x0300},
+{ 0x1F04, 0x1F00, 0x0301},
+{ 0x1F06, 0x1F00, 0x0342},
+{ 0x1F80, 0x1F00, 0x0345},
+{ 0x1F03, 0x1F01, 0x0300},
+{ 0x1F05, 0x1F01, 0x0301},
+{ 0x1F07, 0x1F01, 0x0342},
+{ 0x1F81, 0x1F01, 0x0345},
+{ 0x1F82, 0x1F02, 0x0345},
+{ 0x1F83, 0x1F03, 0x0345},
+{ 0x1F84, 0x1F04, 0x0345},
+{ 0x1F85, 0x1F05, 0x0345},
+{ 0x1F86, 0x1F06, 0x0345},
+{ 0x1F87, 0x1F07, 0x0345},
+{ 0x1F0A, 0x1F08, 0x0300},
+{ 0x1F0C, 0x1F08, 0x0301},
+{ 0x1F0E, 0x1F08, 0x0342},
+{ 0x1F88, 0x1F08, 0x0345},
+{ 0x1F0B, 0x1F09, 0x0300},
+{ 0x1F0D, 0x1F09, 0x0301},
+{ 0x1F0F, 0x1F09, 0x0342},
+{ 0x1F89, 0x1F09, 0x0345},
+{ 0x1F8A, 0x1F0A, 0x0345},
+{ 0x1F8B, 0x1F0B, 0x0345},
+{ 0x1F8C, 0x1F0C, 0x0345},
+{ 0x1F8D, 0x1F0D, 0x0345},
+{ 0x1F8E, 0x1F0E, 0x0345},
+{ 0x1F8F, 0x1F0F, 0x0345},
+{ 0x1F12, 0x1F10, 0x0300},
+{ 0x1F14, 0x1F10, 0x0301},
+{ 0x1F13, 0x1F11, 0x0300},
+{ 0x1F15, 0x1F11, 0x0301},
+{ 0x1F1A, 0x1F18, 0x0300},
+{ 0x1F1C, 0x1F18, 0x0301},
+{ 0x1F1B, 0x1F19, 0x0300},
+{ 0x1F1D, 0x1F19, 0x0301},
+{ 0x1F22, 0x1F20, 0x0300},
+{ 0x1F24, 0x1F20, 0x0301},
+{ 0x1F26, 0x1F20, 0x0342},
+{ 0x1F90, 0x1F20, 0x0345},
+{ 0x1F23, 0x1F21, 0x0300},
+{ 0x1F25, 0x1F21, 0x0301},
+{ 0x1F27, 0x1F21, 0x0342},
+{ 0x1F91, 0x1F21, 0x0345},
+{ 0x1F92, 0x1F22, 0x0345},
+{ 0x1F93, 0x1F23, 0x0345},
+{ 0x1F94, 0x1F24, 0x0345},
+{ 0x1F95, 0x1F25, 0x0345},
+{ 0x1F96, 0x1F26, 0x0345},
+{ 0x1F97, 0x1F27, 0x0345},
+{ 0x1F2A, 0x1F28, 0x0300},
+{ 0x1F2C, 0x1F28, 0x0301},
+{ 0x1F2E, 0x1F28, 0x0342},
+{ 0x1F98, 0x1F28, 0x0345},
+{ 0x1F2B, 0x1F29, 0x0300},
+{ 0x1F2D, 0x1F29, 0x0301},
+{ 0x1F2F, 0x1F29, 0x0342},
+{ 0x1F99, 0x1F29, 0x0345},
+{ 0x1F9A, 0x1F2A, 0x0345},
+{ 0x1F9B, 0x1F2B, 0x0345},
+{ 0x1F9C, 0x1F2C, 0x0345},
+{ 0x1F9D, 0x1F2D, 0x0345},
+{ 0x1F9E, 0x1F2E, 0x0345},
+{ 0x1F9F, 0x1F2F, 0x0345},
+{ 0x1F32, 0x1F30, 0x0300},
+{ 0x1F34, 0x1F30, 0x0301},
+{ 0x1F36, 0x1F30, 0x0342},
+{ 0x1F33, 0x1F31, 0x0300},
+{ 0x1F35, 0x1F31, 0x0301},
+{ 0x1F37, 0x1F31, 0x0342},
+{ 0x1F3A, 0x1F38, 0x0300},
+{ 0x1F3C, 0x1F38, 0x0301},
+{ 0x1F3E, 0x1F38, 0x0342},
+{ 0x1F3B, 0x1F39, 0x0300},
+{ 0x1F3D, 0x1F39, 0x0301},
+{ 0x1F3F, 0x1F39, 0x0342},
+{ 0x1F42, 0x1F40, 0x0300},
+{ 0x1F44, 0x1F40, 0x0301},
+{ 0x1F43, 0x1F41, 0x0300},
+{ 0x1F45, 0x1F41, 0x0301},
+{ 0x1F4A, 0x1F48, 0x0300},
+{ 0x1F4C, 0x1F48, 0x0301},
+{ 0x1F4B, 0x1F49, 0x0300},
+{ 0x1F4D, 0x1F49, 0x0301},
+{ 0x1F52, 0x1F50, 0x0300},
+{ 0x1F54, 0x1F50, 0x0301},
+{ 0x1F56, 0x1F50, 0x0342},
+{ 0x1F53, 0x1F51, 0x0300},
+{ 0x1F55, 0x1F51, 0x0301},
+{ 0x1F57, 0x1F51, 0x0342},
+{ 0x1F5B, 0x1F59, 0x0300},
+{ 0x1F5D, 0x1F59, 0x0301},
+{ 0x1F5F, 0x1F59, 0x0342},
+{ 0x1F62, 0x1F60, 0x0300},
+{ 0x1F64, 0x1F60, 0x0301},
+{ 0x1F66, 0x1F60, 0x0342},
+{ 0x1FA0, 0x1F60, 0x0345},
+{ 0x1F63, 0x1F61, 0x0300},
+{ 0x1F65, 0x1F61, 0x0301},
+{ 0x1F67, 0x1F61, 0x0342},
+{ 0x1FA1, 0x1F61, 0x0345},
+{ 0x1FA2, 0x1F62, 0x0345},
+{ 0x1FA3, 0x1F63, 0x0345},
+{ 0x1FA4, 0x1F64, 0x0345},
+{ 0x1FA5, 0x1F65, 0x0345},
+{ 0x1FA6, 0x1F66, 0x0345},
+{ 0x1FA7, 0x1F67, 0x0345},
+{ 0x1F6A, 0x1F68, 0x0300},
+{ 0x1F6C, 0x1F68, 0x0301},
+{ 0x1F6E, 0x1F68, 0x0342},
+{ 0x1FA8, 0x1F68, 0x0345},
+{ 0x1F6B, 0x1F69, 0x0300},
+{ 0x1F6D, 0x1F69, 0x0301},
+{ 0x1F6F, 0x1F69, 0x0342},
+{ 0x1FA9, 0x1F69, 0x0345},
+{ 0x1FAA, 0x1F6A, 0x0345},
+{ 0x1FAB, 0x1F6B, 0x0345},
+{ 0x1FAC, 0x1F6C, 0x0345},
+{ 0x1FAD, 0x1F6D, 0x0345},
+{ 0x1FAE, 0x1F6E, 0x0345},
+{ 0x1FAF, 0x1F6F, 0x0345},
+{ 0x1FB2, 0x1F70, 0x0345},
+{ 0x1FC2, 0x1F74, 0x0345},
+{ 0x1FF2, 0x1F7C, 0x0345},
+{ 0x1FB7, 0x1FB6, 0x0345},
+{ 0x1FCD, 0x1FBF, 0x0300},
+{ 0x1FCE, 0x1FBF, 0x0301},
+{ 0x1FCF, 0x1FBF, 0x0342},
+{ 0x1FC7, 0x1FC6, 0x0345},
+{ 0x1FF7, 0x1FF6, 0x0345},
+{ 0x1FDD, 0x1FFE, 0x0300},
+{ 0x1FDE, 0x1FFE, 0x0301},
+{ 0x1FDF, 0x1FFE, 0x0342},
+{ 0x219A, 0x2190, 0x0338},
+{ 0x219B, 0x2192, 0x0338},
+{ 0x21AE, 0x2194, 0x0338},
+{ 0x21CD, 0x21D0, 0x0338},
+{ 0x21CF, 0x21D2, 0x0338},
+{ 0x21CE, 0x21D4, 0x0338},
+{ 0x2204, 0x2203, 0x0338},
+{ 0x2209, 0x2208, 0x0338},
+{ 0x220C, 0x220B, 0x0338},
+{ 0x2224, 0x2223, 0x0338},
+{ 0x2226, 0x2225, 0x0338},
+{ 0x2241, 0x223C, 0x0338},
+{ 0x2244, 0x2243, 0x0338},
+{ 0x2247, 0x2245, 0x0338},
+{ 0x2249, 0x2248, 0x0338},
+{ 0x226D, 0x224D, 0x0338},
+{ 0x2262, 0x2261, 0x0338},
+{ 0x2270, 0x2264, 0x0338},
+{ 0x2271, 0x2265, 0x0338},
+{ 0x2274, 0x2272, 0x0338},
+{ 0x2275, 0x2273, 0x0338},
+{ 0x2278, 0x2276, 0x0338},
+{ 0x2279, 0x2277, 0x0338},
+{ 0x2280, 0x227A, 0x0338},
+{ 0x2281, 0x227B, 0x0338},
+{ 0x22E0, 0x227C, 0x0338},
+{ 0x22E1, 0x227D, 0x0338},
+{ 0x2284, 0x2282, 0x0338},
+{ 0x2285, 0x2283, 0x0338},
+{ 0x2288, 0x2286, 0x0338},
+{ 0x2289, 0x2287, 0x0338},
+{ 0x22E2, 0x2291, 0x0338},
+{ 0x22E3, 0x2292, 0x0338},
+{ 0x22AC, 0x22A2, 0x0338},
+{ 0x22AD, 0x22A8, 0x0338},
+{ 0x22AE, 0x22A9, 0x0338},
+{ 0x22AF, 0x22AB, 0x0338},
+{ 0x22EA, 0x22B2, 0x0338},
+{ 0x22EB, 0x22B3, 0x0338},
+{ 0x22EC, 0x22B4, 0x0338},
+{ 0x22ED, 0x22B5, 0x0338},
+{ 0x3094, 0x3046, 0x3099},
+{ 0x304C, 0x304B, 0x3099},
+{ 0x304E, 0x304D, 0x3099},
+{ 0x3050, 0x304F, 0x3099},
+{ 0x3052, 0x3051, 0x3099},
+{ 0x3054, 0x3053, 0x3099},
+{ 0x3056, 0x3055, 0x3099},
+{ 0x3058, 0x3057, 0x3099},
+{ 0x305A, 0x3059, 0x3099},
+{ 0x305C, 0x305B, 0x3099},
+{ 0x305E, 0x305D, 0x3099},
+{ 0x3060, 0x305F, 0x3099},
+{ 0x3062, 0x3061, 0x3099},
+{ 0x3065, 0x3064, 0x3099},
+{ 0x3067, 0x3066, 0x3099},
+{ 0x3069, 0x3068, 0x3099},
+{ 0x3070, 0x306F, 0x3099},
+{ 0x3071, 0x306F, 0x309A},
+{ 0x3073, 0x3072, 0x3099},
+{ 0x3074, 0x3072, 0x309A},
+{ 0x3076, 0x3075, 0x3099},
+{ 0x3077, 0x3075, 0x309A},
+{ 0x3079, 0x3078, 0x3099},
+{ 0x307A, 0x3078, 0x309A},
+{ 0x307C, 0x307B, 0x3099},
+{ 0x307D, 0x307B, 0x309A},
+{ 0x309E, 0x309D, 0x3099},
+{ 0x30F4, 0x30A6, 0x3099},
+{ 0x30AC, 0x30AB, 0x3099},
+{ 0x30AE, 0x30AD, 0x3099},
+{ 0x30B0, 0x30AF, 0x3099},
+{ 0x30B2, 0x30B1, 0x3099},
+{ 0x30B4, 0x30B3, 0x3099},
+{ 0x30B6, 0x30B5, 0x3099},
+{ 0x30B8, 0x30B7, 0x3099},
+{ 0x30BA, 0x30B9, 0x3099},
+{ 0x30BC, 0x30BB, 0x3099},
+{ 0x30BE, 0x30BD, 0x3099},
+{ 0x30C0, 0x30BF, 0x3099},
+{ 0x30C2, 0x30C1, 0x3099},
+{ 0x30C5, 0x30C4, 0x3099},
+{ 0x30C7, 0x30C6, 0x3099},
+{ 0x30C9, 0x30C8, 0x3099},
+{ 0x30D0, 0x30CF, 0x3099},
+{ 0x30D1, 0x30CF, 0x309A},
+{ 0x30D3, 0x30D2, 0x3099},
+{ 0x30D4, 0x30D2, 0x309A},
+{ 0x30D6, 0x30D5, 0x3099},
+{ 0x30D7, 0x30D5, 0x309A},
+{ 0x30D9, 0x30D8, 0x3099},
+{ 0x30DA, 0x30D8, 0x309A},
+{ 0x30DC, 0x30DB, 0x3099},
+{ 0x30DD, 0x30DB, 0x309A},
+{ 0x30F7, 0x30EF, 0x3099},
+{ 0x30F8, 0x30F0, 0x3099},
+{ 0x30F9, 0x30F1, 0x3099},
+{ 0x30FA, 0x30F2, 0x3099},
+{ 0x30FE, 0x30FD, 0x3099},
+{ 0xFB2C, 0xFB49, 0x05C1},
+{ 0xFB2D, 0xFB49, 0x05C2},
+};
+
+int do_precomposition(int base, int comb) {
+  int min = 0;
+  int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1;
+  int mid;
+  unsigned int sought = ((unsigned)base << 16) | (unsigned)comb, that;
+
+  /* binary search */
+  while (max >= min) {
+    mid = (min + max) / 2;
+    that = ((unsigned)precompositions[mid].base << 16) | ((unsigned)precompositions[mid].comb);
+    if (that < sought) {
+      min = mid + 1;
+    } else if (that > sought) {
+      max = mid - 1;
+    } else {
+      return precompositions[mid].replacement;
+    }
+  }
+  /* no match */
+  return -1;
+}
Index: xc/programs/xterm/precompose.h
diff -u /dev/null xc/programs/xterm/precompose.h:1.1
--- /dev/null	Mon Dec 18 14:36:25 2000
+++ xc/programs/xterm/precompose.h	Sat Aug 26 00:33:54 2000
@@ -0,0 +1,11 @@
+/* $XFree86: xc/programs/xterm/precompose.h,v 1.1 2000/08/26 04:33:54 dawes Exp $ */
+
+#ifndef PRECOMPOSE_H
+#define PRECOMPOSE_H
+
+int do_precomposition(int base, int comb);
+
+/* returns unicode value if a canonical composition exists,
+   otherwise -1 */
+
+#endif
Index: xc/programs/xterm/ptydata.c
diff -u xc/programs/xterm/ptydata.c:1.12 xc/programs/xterm/ptydata.c:1.13
--- xc/programs/xterm/ptydata.c:1.12	Mon Jun 12 22:28:40 2000
+++ xc/programs/xterm/ptydata.c	Fri Sep 22 06:42:08 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/xterm/ptydata.c,v 1.12 2000/06/13 02:28:40 dawes Exp $
+ * $XFree86: xc/programs/xterm/ptydata.c,v 1.13 2000/09/22 10:42:08 alanh Exp $
  */
 
 /************************************************************
@@ -133,6 +133,10 @@
 			    } else {
 			      screen->utf_char <<= 6;
 			      screen->utf_char |= (c & 0x3f);
+			    }
+			    if ((screen->utf_char >= 0xd800 && screen->utf_char <= 0xdfff) ||
+				(screen->utf_char == 0xfffe) || (screen->utf_char == 0xffff)) {
+			      screen->utf_char = UCS_REPL;
 			    }
 			    screen->utf_count--;
 			    if (screen->utf_count == 0)
Index: xc/programs/xterm/ptyx.h
diff -u xc/programs/xterm/ptyx.h:3.75 xc/programs/xterm/ptyx.h:3.81
--- xc/programs/xterm/ptyx.h:3.75	Mon Jun 12 22:28:40 2000
+++ xc/programs/xterm/ptyx.h	Wed Nov 29 03:39:26 2000
@@ -1,6 +1,6 @@
 /*
  *	$XConsortium: ptyx.h /main/67 1996/11/29 10:34:19 swick $
- *	$XFree86: xc/programs/xterm/ptyx.h,v 3.75 2000/06/13 02:28:40 dawes Exp $
+ *	$XFree86: xc/programs/xterm/ptyx.h,v 3.81 2000/11/29 08:39:26 keithp Exp $
  */
 
 /*
@@ -70,6 +70,10 @@
 #include <X11/Xfuncs.h>
 #include <X11/Xosdefs.h>
 #include <X11/Xmu/Converters.h>
+#ifdef XRENDERFONT
+#include <X11/extensions/Xrender.h>
+#include <X11/Xft/Xft.h>
+#endif
 
 /* adapted from IntrinsicI.h */
 #define MyStackAlloc(size, stack_cache_array)     \
@@ -95,6 +99,16 @@
 ** System V definitions
 */
 
+#ifdef att
+#define ATT
+#endif
+
+#ifdef SVR4
+#undef  SYSV			/* predefined on Solaris 2.4 */
+#define SYSV			/* SVR4 is (approx) superset of SVR3 */
+#define ATT
+#endif
+
 #ifdef SYSV
 #ifdef X_NOT_POSIX
 #ifndef CRAY
@@ -105,6 +119,35 @@
 #endif /* SYSV */
 
 /*
+** Definitions to simplify ifdef's for pty's.
+*/
+#define USE_PTY_DEVICE 1
+#define USE_PTY_SEARCH 1
+
+#if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
+#undef USE_PTY_DEVICE
+#undef USE_PTY_SEARCH
+#define USE_PTS_DEVICE 1
+#elif defined(VMS)
+#undef USE_PTY_DEVICE
+#undef USE_PTY_SEARCH
+#elif defined(PUCC_PTYD)
+#undef USE_PTY_SEARCH
+#endif
+
+#if defined(SYSV) && defined(i386) && !defined(SVR4)
+#define ATT
+#define USE_HANDSHAKE
+#define USE_ISPTS_FLAG 1
+#endif
+
+#if (defined(ATT) && !defined(__sgi)) || defined(__MVS__) || (defined(SYSV) && defined(i386)) || (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
+#define USE_USG_PTYS
+#else
+#define USE_HANDSHAKE
+#endif
+
+/*
 ** allow for mobility of the pty master/slave directories
 */
 #ifndef PTYDEV
@@ -112,7 +155,7 @@
 #define	PTYDEV		"/dev/ptym/ptyxx"
 #elif defined(__MVS__)
 #define	PTYDEV		"/dev/ptypxxxx"
-#elif !defined(__osf__)
+#else
 #define	PTYDEV		"/dev/ptyxx"
 #endif
 #endif	/* !PTYDEV */
@@ -122,8 +165,8 @@
 #define TTYDEV		"/dev/pty/ttyxx"
 #elif defined(__MVS__)
 #define TTYDEV		"/dev/ptypxxxx"
-#elif defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1))
-#define TTYDEV		"/dev/ttydirs/xxx/xxxxxxxxxxxxxx"
+#elif defined(USE_PTS_DEVICE)
+#define TTYDEV		"/dev/pts/0"
 #else
 #define	TTYDEV		"/dev/ttyxx"
 #endif
@@ -173,6 +216,16 @@
 #endif
 #endif /* PTYFORMAT */
 
+#ifndef PTYCHARLEN
+#ifdef CRAY
+#define PTYCHARLEN 3
+#elif defined(__MVS__)
+#define PTYCHARLEN 4
+#else
+#define PTYCHARLEN 2
+#endif
+#endif
+
 #ifndef MAXPTTYS
 #ifdef CRAY
 #define MAXPTTYS 256
@@ -194,7 +247,7 @@
 typedef unsigned char Char;		/* to support 8 bit chars */
 typedef Char **ScrnBuf;
 
-#define CharOf(n) ((n) & 0xff)
+#define CharOf(n) ((unsigned char)(n))
 
 /*
  * ANSI emulation, special character codes
@@ -333,6 +386,10 @@
 	{RES_NAME(name), XtCForeground, XtRPixel, sizeof(Pixel), \
 	 RES_OFFSET(offset), XtRString, value}
 
+#define Dres(name,offset,value) \
+	{RES_NAME(name), XtCBackground, XtRPixel, sizeof(Pixel), \
+	 RES_OFFSET(offset), XtRString, value}
+
 #define Ires(name,class,offset,value) \
 	{RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \
 	 RES_OFFSET(offset), XtRImmediate, (XtPointer) value}
@@ -461,6 +518,10 @@
 #define OPT_SUNPC_KBD	1 /* true if xterm supports Sun/PC keyboard map */
 #endif
 
+#ifndef OPT_TCAP_QUERY
+#define OPT_TCAP_QUERY	0 /* true for experimental termcap query */
+#endif
+
 #ifndef OPT_TEK4014
 #define OPT_TEK4014     1 /* true if we're using tek4014 emulation */
 #endif
@@ -567,6 +628,12 @@
 		      (( (flags & INVERSE) && !hilite) || \
 		       (!(flags & INVERSE) &&  hilite)) ))
 
+/* Define a fake XK code, we need it for the fake color response in
+ * xtermcapKeycode(). */
+#ifdef OPT_TCAP_QUERY
+# define XK_COLORS 0x0003
+#endif
+
 #else	/* !OPT_ISO_COLORS */
 
 #define if_OPT_ISO_COLORS(screen, code) /* nothing */
@@ -754,6 +821,10 @@
 #endif
 #if OPT_WIDE_CHARS
 	, OFF_WIDEC
+	, OFF_COM1L
+	, OFF_COM1H
+	, OFF_COM2L
+	, OFF_COM2H
 #endif
 } BufOffsets;
 
@@ -766,6 +837,10 @@
 #define BUF_BGRND(buf, row) (buf[MAX_PTRS * (row) + OFF_BGRND])
 #define BUF_CSETS(buf, row) (buf[MAX_PTRS * (row) + OFF_CSETS])
 #define BUF_WIDEC(buf, row) (buf[MAX_PTRS * (row) + OFF_WIDEC])
+#define BUF_COM1L(buf, row) (buf[MAX_PTRS * (row) + OFF_COM1L])
+#define BUF_COM1H(buf, row) (buf[MAX_PTRS * (row) + OFF_COM1H])
+#define BUF_COM2L(buf, row) (buf[MAX_PTRS * (row) + OFF_COM2L])
+#define BUF_COM2H(buf, row) (buf[MAX_PTRS * (row) + OFF_COM2H])
 
 	/* TScreen-level macros */
 #define SCRN_BUF_FLAGS(screen, row) BUF_FLAGS(screen->visbuf, row)
@@ -776,6 +851,10 @@
 #define SCRN_BUF_BGRND(screen, row) BUF_BGRND(screen->visbuf, row)
 #define SCRN_BUF_CSETS(screen, row) BUF_CSETS(screen->visbuf, row)
 #define SCRN_BUF_WIDEC(screen, row) BUF_WIDEC(screen->visbuf, row)
+#define SCRN_BUF_COM1L(screen, row) BUF_COM1L(screen->visbuf, row)
+#define SCRN_BUF_COM2L(screen, row) BUF_COM2L(screen->visbuf, row)
+#define SCRN_BUF_COM1H(screen, row) BUF_COM1H(screen->visbuf, row)
+#define SCRN_BUF_COM2H(screen, row) BUF_COM2H(screen->visbuf, row)
 
 typedef struct {
 	unsigned	chrset;
@@ -865,6 +944,8 @@
 	int		fullheight;	/* full height of window	*/
 	int		f_width;	/* width of fonts in pixels	*/
 	int		f_height;	/* height of fonts in pixels	*/
+	int		f_ascent;	/* ascent of font in pixels	*/
+	int		f_descent;	/* descent of font in pixels	*/
 	int		scrollbar;	/* if > 0, width of scrollbar,	*/
 					/* and scrollbar is showing	*/
 	GC		normalGC;	/* normal painting		*/
@@ -891,6 +972,9 @@
 	Display		*display;	/* X display for screen		*/
 	int		respond;	/* socket for responses
 					   (position report, etc.)	*/
+#if OPT_TCAP_QUERY
+	int		tc_query;
+#endif
 #ifdef AMOEBA
 	capability      proccap;        /* process capability           */
 	struct circbuf  *tty_inq;       /* tty server input queue       */
@@ -992,6 +1076,10 @@
 	Dimension	fnt_high;
 	XFontStruct	*fnt_norm;	/* normal font of terminal	*/
 	XFontStruct	*fnt_bold;	/* bold font of terminal	*/
+#if OPT_WIDE_CHARS
+	XFontStruct	*fnt_dwd;	/* wide font of terminal	*/
+	XFontStruct	*fnt_dwdb;	/* wide bold font of terminal	*/
+#endif
 #ifndef NO_ACTIVE_ICON
 	XFontStruct	*fnt_icon;	/* icon font */
 #endif /* NO_ACTIVE_ICON */
@@ -1146,6 +1234,11 @@
 	unsigned long	menu_font_sizes[NMENUFONTS];
 	int		menu_font_number;
 	XIC		xic;
+#ifdef XRENDERFONT
+	XftFont		*renderFont;
+	XftFont		*renderFontBold;
+	XftDraw		*renderDraw;
+#endif
 } TScreen;
 
 typedef struct _TekPart {
@@ -1187,6 +1280,10 @@
     char *T_geometry;
     char *f_n;
     char *f_b;
+#if OPT_WIDE_CHARS
+    char *f_w;
+    char *f_wb;
+#endif
     int limit_resize;
 #ifdef ALLOWLOGGING
     Boolean log_on;
@@ -1241,6 +1338,10 @@
     unsigned long meta_left;	/* modifier for Meta_L */
     unsigned long meta_right;	/* modifier for Meta_R */
 #endif
+#ifdef XRENDERFONT
+    char *face_name;
+    int face_size;
+#endif
 } Misc;
 
 typedef struct {int foo;} XtermClassPart, TekClassPart;
@@ -1386,9 +1487,9 @@
 #define FontWidth(screen)	((screen)->whichVwin->f_width)
 #define FontHeight(screen)	((screen)->whichVwin->f_height)
 #define FontAscent(screen)	(IsIcon(screen) ? (screen)->fnt_icon->ascent \
-						: (screen)->fnt_norm->ascent)
+						: (screen)->whichVwin->f_ascent)
 #define FontDescent(screen)	(IsIcon(screen) ? (screen)->fnt_icon->descent \
-						: (screen)->fnt_norm->descent)
+						: (screen)->whichVwin->f_descent)
 #define Scrollbar(screen)	((screen)->whichVwin->scrollbar)
 #define NormalGC(screen)	((screen)->whichVwin->normalGC)
 #define ReverseGC(screen)	((screen)->whichVwin->reverseGC)
@@ -1413,8 +1514,8 @@
 #define FullHeight(screen)	((screen)->fullVwin.fullheight)
 #define FontWidth(screen)	((screen)->fullVwin.f_width)
 #define FontHeight(screen)	((screen)->fullVwin.f_height)
-#define FontAscent(screen)	((screen)->fnt_norm->ascent)
-#define FontDescent(screen)	((screen)->fnt_norm->descent)
+#define FontAscent(screen)	((screen)->fullVwin.f_ascent)
+#define FontDescent(screen)	((screen)->fullVwin.f_descent)
 #define Scrollbar(screen)	((screen)->fullVwin.scrollbar)
 #define NormalGC(screen)	((screen)->fullVwin.normalGC)
 #define ReverseGC(screen)	((screen)->fullVwin.reverseGC)
Index: xc/programs/xterm/resize.c
diff -u xc/programs/xterm/resize.c:3.41 xc/programs/xterm/resize.c:3.43
--- xc/programs/xterm/resize.c:3.41	Wed May 17 20:33:21 2000
+++ xc/programs/xterm/resize.c	Tue Oct 31 20:12:42 2000
@@ -1,6 +1,6 @@
 /*
  *	$XConsortium: resize.c,v 1.34 95/05/24 22:12:04 gildea Exp $
- *	$XFree86: xc/programs/xterm/resize.c,v 3.41 2000/05/18 00:33:21 dawes Exp $
+ *	$XFree86: xc/programs/xterm/resize.c,v 3.43 2000/11/01 01:12:42 dawes Exp $
  */
 
 /*
@@ -43,12 +43,14 @@
 #include <X11/Xos.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <xstrings.h>
 
 #if defined(att)
 #define ATT
 #endif
 
 #if defined(sgi) && defined(SVR4)
+#undef SYSV
 #undef SVR4
 #define SYSV
 #endif
@@ -159,7 +161,7 @@
 #ifdef USE_SYSV_TERMIO
 #ifdef X_NOT_POSIX
 #if !defined(SYSV) && !defined(i386)
-extern struct passwd *getpwuid(); 	/* does ANYBODY need this? */
+extern struct passwd *getpwuid();	/* does ANYBODY need this? */
 #endif /* SYSV && i386 */
 #endif /* X_NOT_POSIX */
 #define	bzero(s, n)	memset(s, 0, n)
@@ -190,6 +192,8 @@
 #define ESC(string) "\033" string
 #endif
 
+#define CharOf(ch) ((unsigned char)(ch))
+
 #define	EMULATIONS	2
 #define	SUN		1
 #define	VT100		0
@@ -293,10 +297,6 @@
 #endif /* HAVE_TERMCAP_H  */
 #endif
 
-#ifdef USE_TERMCAP
-static char *strindex (char *s1, char *s2);
-#endif
-
 #define TERMCAP_SIZE 1500		/* 1023 is standard; 'screen' exceeds */
 
 /*
@@ -340,9 +340,7 @@
 	extern char *ttyname();
 #endif
 
-	ptr = strrchr(myname = argv[0], '/');
-	if(ptr)
-		myname = ptr + 1;
+	myname = x_basename(argv[0]);
 	if(strcmp(myname, sunname) == 0)
 		emu = SUN;
 	for(argv++, argc-- ; argc > 0 && **argv == '-' ; argv++, argc--) {
@@ -373,11 +371,7 @@
 			/* this is the same default that xterm uses */
 			ptr = "/bin/sh";
 
-		shell = strrchr(ptr, '/');
-		if(shell)
-			shell++;
-		else
-			shell = ptr;
+		shell = x_basename(ptr);
 
 		/* now that we know, what kind is it? */
 		for (i = 0; shell_list[i].name; i++)
@@ -448,7 +442,7 @@
 	tio.c_cc[VMIN] = 6;
 	tio.c_cc[VTIME] = 1;
 #else	/* not USE_TERMIOS */
- 	ioctl (tty, TIOCGETP, &sgorig);
+	ioctl (tty, TIOCGETP, &sgorig);
 	sg = sgorig;
 	sg.sg_flags |= RAW;
 	sg.sg_flags &= ~ECHO;
@@ -535,7 +529,7 @@
 	if (ok_tcap) {
 		/* update termcap string */
 		/* first do columns */
-		if ((ptr = strindex (termcap, "co#")) == NULL) {
+		if ((ptr = x_strindex (termcap, "co#")) == NULL) {
 			fprintf(stderr, "%s: No `co#'\n", myname);
 			exit (1);
 		}
@@ -547,7 +541,7 @@
 		strcat (newtc, ptr);
 
 		/* now do lines */
-		if ((ptr = strindex (newtc, "li#")) == NULL) {
+		if ((ptr = x_strindex (newtc, "li#")) == NULL) {
 			fprintf(stderr, "%s: No `li#'\n", myname);
 			exit (1);
 		}
@@ -587,31 +581,11 @@
 	exit(0);
 }
 
-#ifdef USE_TERMCAP
-static char *
-strindex (register char *s1, register char *s2)
-/*
-   returns a pointer to the first occurrence of s2 in s1, or NULL if there are
-   none.
- */
-{
-	register char *s3;
-	size_t s2len = strlen (s2);
-
-	while ((s3 = strchr(s1, *s2)) != NULL)
-	{
-		if (strncmp (s3, s2, s2len) == 0) return (s3);
-		s1 = ++s3;
-	}
-	return (NULL);
-}
-#endif
-
 static int
 checkdigits(register char *str)
 {
 	while(*str) {
-		if(!isdigit(*str))
+		if(!isdigit(CharOf(*str)))
 			return(0);
 		str++;
 	}
Index: xc/programs/xterm/screen.c
diff -u xc/programs/xterm/screen.c:3.50 xc/programs/xterm/screen.c:3.52
--- xc/programs/xterm/screen.c:3.50	Tue Jun 13 20:16:20 2000
+++ xc/programs/xterm/screen.c	Fri Sep 22 06:42:08 2000
@@ -54,10 +54,11 @@
  * SOFTWARE.
  */
 
-/* $XFree86: xc/programs/xterm/screen.c,v 3.50 2000/06/14 00:16:20 dawes Exp $ */
+/* $XFree86: xc/programs/xterm/screen.c,v 3.52 2000/09/22 10:42:08 alanh Exp $ */
 
 /* screen.c */
 
+#include <stdio.h>
 #include <xterm.h>
 #include <error.h>
 #include <data.h>
@@ -65,19 +66,11 @@
 
 #include <signal.h>
 
-#ifdef att
-#define ATT
-#endif
-
 #ifdef SVR4
-#undef SYSV
-#define SYSV
 #include <termios.h>
-#else
-#ifndef __CYGWIN__
+#elif !defined(__CYGWIN__)
 #include <sys/ioctl.h>
 #endif
-#endif
 
 #if defined(__CYGWIN__) && !defined(TIOCSPGRP)
 #include <termios.h>
@@ -88,10 +81,6 @@
 #include <sys/termio.h>
 #endif
 
-#if (defined(ATT) && !defined(__sgi)) || (defined(SYSV) && defined(i386)) || (defined (__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
-#define USE_USG_PTYS
-#endif
-
 #ifdef SYSV
 #if !defined(DGUX)			/* Intel DG/ux uses termios.h */
 #include <sys/termio.h>
@@ -274,6 +263,9 @@
 	return move_down ? move_down : -move_up; /* convert to rows */
 }
 
+int last_written_row = -1;
+int last_written_col = -1;
+
 /*
  * Writes str into buf at screen's current row and column.  Characters are set
  * to match flags.
@@ -302,6 +294,16 @@
 	int avail  = screen->max_col - screen->cur_col + 1;
 	Char *col;
 	int wrappedbit;
+ 	Char starcol, starcol2; 
+#if OPT_WIDE_CHARS
+ 	Char *comb1l = 0, *comb1h = 0, *comb2l = 0, *comb2h = 0;
+#endif
+ 
+#if OPT_WIDE_CHARS
+ 	int real_width = visual_width(PAIRED_CHARS(str, str2), length);
+#else
+ 	int real_width = length;
+#endif
 
 	if (length > avail)
 	    length = avail;
@@ -311,6 +313,13 @@
 	col   = SCRN_BUF_CHARS(screen, screen->cur_row) + screen->cur_col;
 	attrs = SCRN_BUF_ATTRS(screen, screen->cur_row) + screen->cur_col;
 
+	if_OPT_WIDE_CHARS(screen,{
+		comb1l   = SCRN_BUF_COM1L(screen, screen->cur_row) + screen->cur_col;
+		comb1h   = SCRN_BUF_COM1H(screen, screen->cur_row) + screen->cur_col;
+		comb2l   = SCRN_BUF_COM2L(screen, screen->cur_row) + screen->cur_col;
+		comb2h   = SCRN_BUF_COM2H(screen, screen->cur_row) + screen->cur_col;
+	})
+
 	if_OPT_EXT_COLORS(screen,{
 		fbf = SCRN_BUF_FGRND(screen, screen->cur_row) + screen->cur_col;
 		fbb = SCRN_BUF_BGRND(screen, screen->cur_row) + screen->cur_col;
@@ -324,36 +333,107 @@
 
 	wrappedbit = ScrnTstWrapped(screen, screen->cur_row);
 
+	starcol = *col;
+	starcol2 = col[length-1];
+
 	/* write blanks if we're writing invisible text */
 	if (flags & INVISIBLE) {
+#if OPT_WIDE_CHARS
+		memset(col, ' ', real_width);
+#else
 		memset(col, ' ', length);
+#endif
 	} else {
-		memcpy(col, str, length);
+		memcpy(col, str, length); /* This can stand for the present. If it
+                                             is wrong, we will scribble over it */
 	}
+#define ERROR_1 0x20
+#define ERROR_2 0x00
 	if_OPT_WIDE_CHARS(screen,{
+
 		Char *wc;
+
+		if (real_width != length) {
+			Char *c = col;
+			wc = SCRN_BUF_WIDEC(screen, screen->cur_row);
+			wc += screen->cur_col;
+			if (screen->cur_col && starcol == HIDDEN_LO && *wc == HIDDEN_HI
+			    && iswide(c[-1] | (wc[-1] << 8))) {
+				c[-1] = ERROR_1;
+				wc[-1] = ERROR_2;
+			}
+			/* if we are overwriting the right hand half of a
+                           wide character, make the other half vanish */
+			while (length) {
+				int ch = *str;
+				if (str2) ch |= *str2 << 8;
+
+				*c = *str;
+				c++; str++;
+				
+				if (str2) { *wc = *str2; str2++; } else *wc = 0;
+				wc++;
+				length--;
+
+				if (iswide(ch)) {
+					*c = HIDDEN_LO; *wc = HIDDEN_HI;
+					c++; wc++;
+				}
+			}
+
+			if (*c == HIDDEN_LO && *wc == HIDDEN_HI && c[-1] == HIDDEN_LO && wc[-1] == HIDDEN_HI) {
+				*c = ERROR_1;
+				*wc = ERROR_2;
+			}
+			/* if we are overwriting the left hand half of a
+                           wide character, make the other half vanish */
+		}
+
+		else {
+
 		if ((wc = SCRN_BUF_WIDEC(screen, screen->cur_row)) != 0) {
 			wc += screen->cur_col;
+			if (screen->cur_col && starcol == HIDDEN_LO && *wc == HIDDEN_HI
+			    && iswide(col[-1] | (wc[-1] << 8))) {
+				col[-1] = ERROR_1;
+				wc[-1] = ERROR_2;
+			}
+			/* if we are overwriting the right hand half of a
+                           wide character, make the other half vanish */
+			if (col[length] == HIDDEN_LO && wc[length] == HIDDEN_HI &&
+                            iswide(starcol2 | (wc[length-1]<<8))) {
+				col[length] = ERROR_1;
+				wc[length] = ERROR_2;
+			}
+			/* if we are overwriting the left hand half of a
+                           wide character, make the other half vanish */
 			if ((flags & INVISIBLE) || (str2 == 0))
 				memset(wc, 0, length);
 			else
 				memcpy(wc, str2, length);
 		}
+        }
 	})
 
 	flags &= ATTRIBUTES;
 	flags |= CHARDRAWN;
-	memset( attrs, flags,  length);
+	memset( attrs, flags,  real_width);
 
+	if_OPT_WIDE_CHARS(screen,{
+		memset( comb1l,   0, real_width);
+		memset( comb2l,   0, real_width);
+		memset( comb1h,   0, real_width);
+		memset( comb2h,   0, real_width);
+	})
 	if_OPT_EXT_COLORS(screen,{
-		memset( fbf,  cur_fg_bg >> 8, length);
-		memset( fbb,  cur_fg_bg & 0xff, length);
+		memset( fbf,  cur_fg_bg >> 8, real_width);
+		memset( fbb,  cur_fg_bg & 0xff, real_width);
 	})
 	if_OPT_ISO_TRADITIONAL_COLORS(screen,{
-		memset( fb,   cur_fg_bg, length);
+		memset( fb,   cur_fg_bg, real_width);
 	})
 	if_OPT_DEC_CHRSET({
-		memset( cb,   curXtermChrSet(screen->cur_row), length);
+		memset( cb,   curXtermChrSet(screen->cur_row), real_width);
 	})
 
 	if (wrappedbit)
@@ -361,6 +441,9 @@
 	else
 	    ScrnClrWrapped(screen, screen->cur_row);
 
+	last_written_col = screen->cur_col + real_width - 1;
+	last_written_row = screen->cur_row;
+
 	if_OPT_XMC_GLITCH(screen,{
 		Resolve_XMC(screen);
 	})
@@ -542,6 +625,22 @@
 	    ptr = BUF_WIDEC(sb, row);
 	    memmove(ptr + col + n, ptr + col, nbytes);
 	    memset(ptr + col, 0, n);
+
+	    ptr = BUF_COM1L(sb, row);
+	    memmove(ptr + col + n, ptr + col, nbytes);
+	    memset(ptr + col, 0, n);
+	    
+	    ptr = BUF_COM1H(sb, row);
+	    memmove(ptr + col + n, ptr + col, nbytes);
+	    memset(ptr + col, 0, n);
+	    
+	    ptr = BUF_COM2L(sb, row);
+	    memmove(ptr + col + n, ptr + col, nbytes);
+	    memset(ptr + col, 0, n);
+	    
+	    ptr = BUF_COM2H(sb, row);
+	    memmove(ptr + col + n, ptr + col, nbytes);
+	    memset(ptr + col, 0, n);
 	})
 
 	if (wrappedbit)
@@ -598,6 +697,22 @@
 	    ptr = BUF_WIDEC(sb, row);
 	    memmove(ptr + col, ptr + col + n, nbytes);
 	    memset(ptr + size - n, 0, n);
+
+	    ptr = BUF_COM1L(sb, row);
+	    memmove(ptr + col, ptr + col + n, nbytes);
+	    memset(ptr + size - n, 0, n);
+	      
+	    ptr = BUF_COM1H(sb, row);
+	    memmove(ptr + col, ptr + col + n, nbytes);
+	    memset(ptr + size - n, 0, n);
+	      
+	    ptr = BUF_COM2L(sb, row);
+	    memmove(ptr + col, ptr + col + n, nbytes);
+	    memset(ptr + size - n, 0, n);
+	      
+	    ptr = BUF_COM2H(sb, row);
+	    memmove(ptr + col, ptr + col + n, nbytes);
+	    memset(ptr + size - n, 0, n);
 	})
 	ScrnClrWrapped(screen, row);
 }
@@ -616,7 +731,8 @@
 	int leftcol,
 	int nrows,
 	int ncols,
-	Bool force)			/* ... leading/trailing spaces */
+	Bool force
+)			/* ... leading/trailing spaces */
 {
 	int y = toprow * FontHeight(screen) + screen->border;
 	int row;
@@ -628,6 +744,7 @@
 #ifdef __CYGWIN__
 	static char first_time = 1;
 #endif
+        static int recurse = 0;
 
 	TRACE(("ScrnRefresh (%d,%d) - (%d,%d)%s\n",
 		toprow, leftcol,
@@ -653,6 +770,7 @@
 	   Char *cb = 0;
 #endif
 #if OPT_WIDE_CHARS
+	   int wideness = 0;
 	   Char *widec = 0;
 #define WIDEC_PTR(cell) widec ? &widec[cell] : 0
 #endif
@@ -688,6 +806,25 @@
 		widec = SCRN_BUF_WIDEC(screen, lastind + topline);
 	   })
 
+	   if_OPT_WIDE_CHARS(screen,{
+		/* This fixes an infinite recursion bug, that leads
+		   to display anomalies. It seems to be related to 
+		   problems with the selection. */
+		if (recurse < 3) {
+		    /* adjust to redraw all of a widechar if we just wanted 
+		      to draw the right hand half */
+		    if (iswide(chars[leftcol - 1] | (widec[leftcol -1]<<8)) &&
+			(chars[leftcol] | (widec[leftcol]<<8))==HIDDEN_CHAR)
+		    {
+			leftcol--;
+			ncols++;
+			col = leftcol;
+		    }
+	       } else {
+		    fprintf(stderr, "This should not happen. Why is it so?\n");
+	       }
+	   })
+
 	   if (row < screen->startHRow || row > screen->endHRow ||
 	       (row == screen->startHRow && maxcol < screen->startHCol) ||
 	       (row == screen->endHRow && col >= screen->endHCol))
@@ -723,11 +860,13 @@
 	   else {
 	       /* row intersects selection; split into pieces of single type */
 	       if (row == screen->startHRow && col < screen->startHCol) {
+		   recurse++;
 		   ScrnRefresh(screen, row, col, 1, screen->startHCol - col,
 			       force);
 		   col = screen->startHCol;
 	       }
 	       if (row == screen->endHRow && maxcol >= screen->endHCol) {
+		   recurse++;
 		   ScrnRefresh(screen, row, screen->endHCol, 1,
 			       maxcol - screen->endHCol + 1, force);
 		   maxcol = screen->endHCol - 1;
@@ -775,6 +914,12 @@
 	   })
 
 	   flags = attrs[col];
+#if OPT_WIDE_CHARS
+	   if (widec)
+	     wideness = iswide(chars[col] | (widec[col]<<8));
+	   else
+	     wideness = 0;
+#endif
 	   if_OPT_EXT_COLORS(screen,{
 		fbf = SCRN_BUF_FGRND(screen, lastind + topline);
 		fbb = SCRN_BUF_BGRND(screen, lastind + topline);
@@ -808,6 +953,11 @@
 		 || ((flags & BG_COLOR) && (extract_bg(fb[col],attrs[col]) != bg))
 #endif
 #endif
+#if OPT_WIDE_CHARS
+                 || (widec 
+                     && ((iswide(chars[col] | (widec[col]<<8))) != wideness)
+                     && !((chars[col] | (widec[col]<<8))==HIDDEN_CHAR))
+#endif
 #if OPT_DEC_CHRSET
 		 || (cb[col] != cs)
 #endif
@@ -819,9 +969,37 @@
 				PAIRED_CHARS(&chars[lastind], WIDEC_PTR(lastind)),
 				col - lastind)));
 		   x = drawXtermText(screen, flags, gc, x, y,
-		   	cs,
+			cs,
 			PAIRED_CHARS(&chars[lastind], WIDEC_PTR(lastind)),
-			col - lastind);
+			col - lastind, 0);
+ 
+		   if_OPT_WIDE_CHARS(screen, 
+ 		   {
+ 			int i;
+  	       	 	Char *comb1l = BUF_COM1L(screen->visbuf, row + topline);
+ 			Char *comb2l = BUF_COM2L(screen->visbuf, row + topline);
+  	       	 	Char *comb1h = BUF_COM1H(screen->visbuf, row + topline);
+ 			Char *comb2h = BUF_COM2H(screen->visbuf, row + topline);
+ 			for (i = lastind ; i < col; i++) {
+			    int my_x = CurCursorX(screen, row + topline, i);
+			    int base = chars[i] | (widec[i] << 8);
+			    int comb1 = comb1l[i] | (comb1h[i] << 8);
+			    int comb2 = comb2l[i] | (comb2h[i] << 8);
+
+			    if (iswide(base)) my_x = CurCursorX(screen, row + topline, i-1);
+
+			    if (comb1 != 0) {
+				    drawXtermText(screen, flags, gc, my_x, y, cs,
+						  PAIRED_CHARS(comb1l+i, comb1h+i), 1, iswide(base));
+			    }
+
+			    if (comb2 != 0) {
+				    drawXtermText(screen, flags, gc, my_x, y, cs,
+						  PAIRED_CHARS(comb2l+i, comb2h+i), 1, iswide(base));
+			    }
+ 			}
+ 	   	   })
+ 
 		   resetXtermGC(screen, flags, hilite);
 
 		   lastind = col;
@@ -843,6 +1021,10 @@
 		   if_OPT_DEC_CHRSET({
 		        cs = cb[col];
 		   })
+#if OPT_WIDE_CHARS
+		   if (widec)
+                     wideness = iswide(chars[col] | (widec[col]<<8));
+#endif
 	   	   gc = updatedXtermGC(screen, flags, fg_bg, hilite);
 	   	   gc_changes |= (flags & (FG_COLOR|BG_COLOR));
 		}
@@ -862,7 +1044,34 @@
 	   drawXtermText(screen, flags, gc, x, y,
 	   	cs,
 		PAIRED_CHARS(&chars[lastind], WIDEC_PTR(lastind)),
-		col - lastind);
+		col - lastind, 0);
+
+	   if_OPT_WIDE_CHARS(screen, {
+		int i;
+		Char *comb1l = BUF_COM1L(screen->visbuf, row + topline);
+		Char *comb2l = BUF_COM2L(screen->visbuf, row + topline);
+		Char *comb1h = BUF_COM1H(screen->visbuf, row + topline);
+		Char *comb2h = BUF_COM2H(screen->visbuf, row + topline);
+		for (i = lastind ; i < col; i++) {
+		    int my_x = CurCursorX(screen, row + topline, i);
+		    int base = chars[i] | (widec[i] << 8);
+		    int comb1 = comb1l[i] | (comb1h[i] << 8);
+		    int comb2 = comb2l[i] | (comb2h[i] << 8);
+
+		    if (iswide(base)) my_x = CurCursorX(screen, row + topline, i-1);
+
+		    if (comb1 != 0) {
+			    drawXtermText(screen, flags, gc, my_x, y, cs,
+					  PAIRED_CHARS(comb1l+i, comb1h+i), 1, iswide(base));
+		    }
+
+		    if (comb2 != 0) {
+			    drawXtermText(screen, flags, gc, my_x, y, cs,
+					  PAIRED_CHARS(comb2l+i, comb2h+i), 1, iswide(base));
+		    }
+		}
+	   })
+
 	   resetXtermGC(screen, flags, hilite);
 	}
 
@@ -890,6 +1099,7 @@
 		ioctl (screen->respond, TIOCSWINSZ, (char *)&ws);
 	}
 #endif
+	recurse--;
 }
 
 /*
@@ -924,6 +1134,10 @@
 	    })
 	    if_OPT_WIDE_CHARS(screen,{
 		memset(BUF_WIDEC(buf, row), 0, len);
+		memset(BUF_COM1L(buf, row), 0, len);
+		memset(BUF_COM1H(buf, row), 0, len);
+		memset(BUF_COM2L(buf, row), 0, len);
+		memset(BUF_COM2H(buf, row), 0, len);
 	    })
 	}
 }
Index: xc/programs/xterm/termcap
diff -u xc/programs/xterm/termcap:3.25 xc/programs/xterm/termcap:3.27
--- xc/programs/xterm/termcap:3.25	Mon Feb 28 22:09:29 2000
+++ xc/programs/xterm/termcap	Tue Oct 31 20:12:42 2000
@@ -1,5 +1,5 @@
 # $XConsortium: termcap,v 1.13 94/10/13 21:24:32 gildea Exp $
-# $XFree86: xc/programs/xterm/termcap,v 3.25 2000/02/29 03:09:29 dawes Exp $
+# $XFree86: xc/programs/xterm/termcap,v 3.27 2000/11/01 01:12:42 dawes Exp $
 #
 # Note:
 #	termcap format is limited to 1023 characters.  This set of descriptions
@@ -17,33 +17,27 @@
 #	the resolved length of each entry in a comment at the end - T.Dickey
 #
 xf|xterm-xfree86|XFree86 xterm:\
-	:is=\E[!p\E[?3;4l\E[4l\E>:\
-	:rs=\E[!p\E[?3;4l\E[4l\E>:\
-	:AL=\E[%dL:DL=\E[%dM:DC=\E[%dP:DO=\E[%dB:UP=\E[%dA:\
-	:LE=\E[%dD:RI=\E[%dC:\
-	:al=\E[L:am:bl=^G:\
-	:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:co#80:\
-	:cs=\E[%i%d;%dr:ct=\E[3g:\
-	:dc=\E[P:dl=\E[M:ho=\E[H:\
-	:im=\E[4h:ei=\E[4l:mi:\
-	:ks=\E[?1h\E=:ke=\E[?1l\E>:\
 	:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\
 	:k5=\E[15~:k6=\E[17~:k7=\E[18~:k8=\E[19~:\
 	:k9=\E[20~:k;=\E[21~:F1=\E[23~:F2=\E[24~:\
-	:kn#12:km:\
-	:kH=\EOF::@7=\EOF:kh=\EOH:\
-	:@0=\EOH:kI=\E[2~:kD=\E[3~:\
-	:*6=\EOF:kP=\E[5~:kN=\E[6~:\
-	:kb=^H:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:\
-	:li#24:md=\E[1m:me=\E[m^O:mr=\E[7m:ms:nd=\E[C:\
-	:eA=\E)0:as=^N:ae=^O:ml=\El:mu=\Em:\
-	:sc=\E7:rc=\E8:sf=\n:so=\E[7m:se=\E[27m:sr=\EM:st=\EH:\
-	:ti=\E[?1049h:te=\E[?1049l:\
-	:vi=\E[?25l:ve=\E[?25h:\
-	:up=\E[A:us=\E[4m:ue=\E[24m:xn:\
-	:ut:Co#8:op=\E[39;49m:AB=\E[4%dm:AF=\E[3%dm:\
-	:pa#64:Sf=\E[3%dm:Sb=\E[4%dm:
-#
+	:kH=\EOF:@7=\EOF:kI=\E[2~:\
+	:kh=\EOH:*6=\EOF:kP=\E[5~:kN=\E[6~:\
+	:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:Km=\E[M:tc=xterm-basic:
+#
+# This chunk is used for building the VT220/Sun/PC keyboard variants.
+xb|xterm-basic|xterm common (XFree86):\
+	:li#24:co#80:am:kn#12:km:mi:ms:xn:bl=^G:\
+	:is=\E[!p\E[?3;4l\E[4l\E>:rs=\E[!p\E[?3;4l\E[4l\E>:\
+	:AL=\E[%dL:DL=\E[%dM:DC=\E[%dP:al=\E[L:dc=\E[P:dl=\E[M:\
+	:UP=\E[%dA:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:\
+	:ho=\E[H:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:\
+	:im=\E[4h:ei=\E[4l:ks=\E[?1h\E=:ke=\E[?1l\E>:kD=\E[3~:kb=^H:\
+	:sf=\n:sr=\EM:st=\EH:ct=\E[3g:sc=\E7:rc=\E8:\
+	:eA=\E(B\E)0:as=^N:ae=^O:ml=\El:mu=\Em:up=\E[A:nd=\E[C:\
+	:md=\E[1m:me=\E[m^O:mr=\E[7m:so=\E[7m:se=\E[27m:us=\E[4m:ue=\E[24m:\
+	:ti=\E[?1049h:te=\E[?1049l:vi=\E[?25l:ve=\E[?25h:\
+	:ut:Co#8:pa#64:op=\E[39;49m:AB=\E[4%dm:AF=\E[3%dm:\
+
 # The xterm-xfree86 description has all of the features, but is not completely
 # compatible with vt220.  If you are using a Sun or PC keyboard, set the
 # sunKeyboard resource to true:
@@ -54,9 +48,7 @@
 #	+ uses DEC-style control sequences for the application keypad.
 #
 vt|xterm-vt220|xterm emulating vt220:\
-	:kH=\E[4~::@7=\E[4~:*6=\E[4~:\
-	:kh=\E[1~:\
-	:tc=xterm-xfree86:
+	:kH=\E[4~::@7=\E[4~:*6=\E[4~:kh=\E[1~:Km=\E[M:tc=xterm-basic:
 
 v1|xterm-24|xterms|vs100|24x80 xterm:\
 	:li#24:\
@@ -64,12 +56,10 @@
 v2|xterm-65|65x80 xterm:\
 	:li#65:tc=xterm:
 vb|xterm-bold|xterm with bold for underline:\
-	:us=\E[1m:tc=xterm:
+	:so=\E[7m:us=\E[1m:tc=xterm:
 vb|xterm-boldso|xterm with bold for standout:\
 	:se=\E[m:so=\E[1m:tc=xterm:
-vm|xtermm|monochrome xterm:\
-	:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:F5=\E[28~:\
-	:F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:FA=\E[34~:\
+vm|xterm-mono|monochrome xterm:\
 	:kn#20:\
 	:st@:ut@:Co@:NC@:op@:AB@:AF@:pa@:Sf@:Sb@:tc=xterm:
 #
@@ -79,20 +69,18 @@
 	kl=\E[D:kd=\E[B:kr=\E[C:ku=\E[A:ks=\E=:ke=\E>:ti@:te@:tc=xterm:
 #
 # This should work for the commonly used "color xterm" variations (XFree86
-# xterm, color_xterm, nxterm, rxvt).  You may have trouble with this using
-# conventional termcap because ncurses reports it is longer than 1023
-# characters.  That is because resolving it adds the alternate character-set
-# (you can suppress it with "ac@").
+# xterm, color_xterm, nxterm, rxvt).  Note that it does not set 'bce', so for
+# XFree86 and and rxvt, some applications that use colors will be less
+# efficient, and in a few special cases (with "smart" optimization) the wrong
+# color will be painted in spots.
 vc|xterm-color|generic "ANSI" color xterm:\
-	:Co#8:NC@:pa#64:op=\E[m:AB=\E[4%dm:AF=\E[3%dm:tc=xterm-r6:
+	:Co#8:NC@:pa#64:op=\E[m:AB=\E[4%dm:AF=\E[3%dm:ac@:tc=xterm-r6:
 #
 # These aliases are for compatibility with the terminfo; termcap cannot provide
 # the extra features, but termcap applications still want the names.
-v5|xterm-vt52|xterm alias:tc=vt52:
-x1|xterm-16color|xterm alias:tc=xterm:
-x2|xterm-88color|xterm alias:tc=xterm:
-x3|xterm-256color|xterm alias:tc=xterm:
-xm|xterm-mono|xterm alias:tc=xtermm:
+x1|xterm-16color|xterm alias:tc=xterm-xfree86:
+x2|xterm-88color|xterm alias:tc=xterm-256color:
+x3|xterm-256color|xterm alias:tc=xterm-xfree86:
 xn|xterm-nrc|xterm alias:tc=xterm:
 xr|xterm-rep|xterm alias:tc=xterm:
 xx|xterm-xmc|xterm alias:sg#1:tc=xterm:
@@ -100,70 +88,77 @@
 # An 8-bit description is doable with termcap, but there are probably no
 # termcap (or BSD curses) applications that are able to use it.
 x8|xterm-8bit|xterm terminal emulator 8-bit controls (X Window System):\
-	:am:km:mi:ms:xn:\
-	:co#80:it#8:li#24:\
+	:co#80:li#24:\
+	:it#8:am:km:mi:ms:xn:\
 	:AL=\233%dL:DC=\233%dP:DL=\233%dM:DO=\233%dB:IC=\233%d@:LE=\233%dD:\
 	:RI=\233%dC:UP=\233%dA:ae=^O:al=\233L:as=^N:bl=^G:bt=\233Z:\
 	:cd=\233J:ce=\233K:cl=\233H\2332J:cm=\233%i%d;%dH:cr=^M:\
-	:cs=\233%i%d;%dr:ct=\2333g:dc=\233P:dl=\233M:do=^J:\
+	:cs=\233%i%d;%dr:ct=\2333g:dc=\233P:dl=\233M:do=^J:up=\233A:nd=\233C:\
 	:ei=\2334l:ho=\233H:im=\2334h:\
-	:is=\E7\E G\233r\233m\233?7h\233?1;3;4;6l\2334l\E8\E>:\
+	:is=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8:\
 	:k1=\23311~:k2=\23312~:k3=\23313~:k4=\23314~:k5=\23315~:\
 	:k6=\23317~:k7=\23318~:k8=\23319~:k9=\23320~:kD=\2333~:\
 	:kI=\2332~:kN=\2336~:kP=\2335~:kb=^H:kd=\217B:\
 	:ke=\233?1l\E>:kh=\2331~:kl=\217D:kr=\217C:ks=\233?1h\E=:\
 	:ku=\217A:le=^H:mb=\2335m:md=\2331m:me=\233m^O:mr=\2337m:\
-	:nd=\233C:rc=\E8:sc=\E7:se=\23327m:sf=^J:so=\2337m:sr=\215:\
-	:st=\210:ta=^I:te=\233?1049l:ti=\233?1049h:ue=\23324m:\
-	:up=\233A:us=\2334m:vb=\233?5h\233?5l:ve=\233?25h:\
-	:vi=\233?25l:
+	:rc=\E8:sc=\E7:se=\23327m:sf=^J:so=\2337m:sr=\215:\
+	:st=\210:ta=^I:te=\233?1049l:ti=\233?1049h:ue=\23324m:us=\2334m:\
+	:vb=\233?5h\233?5l:ve=\233?25h:vi=\233?25l:Km=\233M:
 #
 hp|xterm-hp|XFree86 xterm with hpterm function keys:\
-	:k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:\
-	:k6=\Eu:k7=\Ev:k8=\Ew:\
-	:kC=\EJ:kD=\EP:@7=\EF:\
-	:kI=\EQ:kN=\ES:kP=\ET:kh=\Eh:\
-	:kd=\EB:kl=\ED:kr=\EC:ku=\EA:tc=xterm:
+	:k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:k6=\Eu:k7=\Ev:k8=\Ew:\
+	:kC=\EJ:kD=\EP:@7=\EF:kI=\EQ:kN=\ES:kP=\ET:kh=\Eh:\
+	:kd=\EB:kl=\ED:kr=\EC:ku=\EA:tc=xterm-basic:
+#
+xS|xterm-sco|XFree86 xterm with SCO function keys:\
+	:kl=\E[D:kd=\E[B:kr=\E[C:ku=\E[A:@7=\E[F:\
+	:k1=\E[M:k2=\E[N:k3=\E[O:k4=\E[P:k5=\E[Q:\
+	:k6=\E[R:k7=\E[S:k8=\E[T:k9=\E[U:k;=\E[V:\
+	:F1=\E[W:F2=\E[X:F3=\E[Y:F5=\E[a:F6=\E[b:\
+	:F7=\E[c:F8=\E[d:F9=\E[e:FA=\E[f:FB=\E[g:\
+	:FC=\E[h:FD=\E[i:FE=\E[j:FF=\E[k:\
+	:kh=\E[H:kI=\E[L:kN=\E[G:kP=\E[I:ac@:tc=xterm-basic:
 #
-# This won't come close to fitting unless we cancel the alternate character set.
-# The function keys F1-F12, plus editing keypad are then usable:
+v5|xterm-vt52|xterm emulating vt52:\
+	:bs:\
+	:co#80:it#8:li#24:\
+	:ae=\EG:as=\EF:bl=^G:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :\
+	:cr=^M:do=\EB:ho=\EH:kb=^H:kd=\EB:kl=\ED:kr=\EC:ku=\EA:\
+	:le=\ED:nd=\EC:nw=^M^J:sf=^J:sr=\EI:ta=^I:up=\EA:
+#
 xs|xterm-sun|xterm with Sun functionkeys:\
 	:k1=\E[224z:k2=\E[225z:k3=\E[226z:k4=\E[227z:\
 	:k5=\E[228z:k6=\E[229z:k7=\E[230z:k8=\E[231z:\
 	:k9=\E[232z:k;=\E[233z:F1=\E[192z:F2=\E[193z:\
 	:%1=\E[196z:&8=\E[195z:@0=\E[200z:kI=\E[2z:\
-	:kN=\E[222z:kP=\E[216z:kh=\E[214z:kD=^?:as@:ae@:ac@:tc=xterm:
+	:kN=\E[222z:kP=\E[216z:kh=\E[214z:kD=^?:\
+	:Km=\E[M:@5=\E[197z::@7=\E[220z:\
+	:tc=xterm-basic:
 #
 # vi may work better with this entry, because vi doesn't use insert mode much.
 # |xterm-ic|xterm-vi|xterm with insert character instead of insert mode:\
 vi|xterm-ic|xterm-vi|xterm with insert char:\
 	:im@:ei@:mi@:ic=\E[@:IC=\E[%d@:tc=xterm:
 #
-# Compatible with the R6 xterm
+# Compatible with the X11R6.3 xterm
 r6|xterm-r6|xterm-old|X11R6 xterm:\
-	:is=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>:\
-	:rs=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>:\
+	:is=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:\
+	:rs=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:\
 	:AL=\E[%dL:DL=\E[%dM:DC=\E[%dP:DO=\E[%dB:UP=\E[%dA:\
-	:LE=\E[%dD:RI=\E[%dC:\
-	:al=\E[L:am:bl=^G:\
+	:LE=\E[%dD:RI=\E[%dC:al=\E[L:am:bl=^G:\
 	:bs:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:co#80:\
 	:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:ho=\E[H:\
-	:im=\E[4h:ei=\E[4l:mi:\
-	:ks=\E[?1h\E=:ke=\E[?1l\E>:@7=\E[4~:kh=\E[1~:\
+	:im=\E[4h:ei=\E[4l:mi:ks=\E[?1h\E=:ke=\E[?1l\E>:@7=\E[4~:kh=\E[1~:\
 	:k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:k5=\E[15~:\
 	:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:\
 	:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:F5=\E[28~:\
 	:F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:FA=\E[34~:\
-	:kn#20:km:\
-	:@0=\E[1~:kI=\E[2~:kD=^?:\
-	:*6=\E[4~:kP=\E[5~:kN=\E[6~:\
+	:kn#20:km:@0=\E[1~:kI=\E[2~:kD=^?:*6=\E[4~:kP=\E[5~:kN=\E[6~:\
 	:kb=^H:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:\
 	:li#24:md=\E[1m:me=\E[m:mr=\E[7m:ms:nd=\E[C:pt:\
-	:eA=\E)0:as=^N:ae=^O:\
-	:ml=\El:mu=\Em:\
+	:eA=\E)0:as=^N:ae=^O:ml=\El:mu=\Em:\
 	:sc=\E7:rc=\E8:sf=\n:so=\E[7m:se=\E[m:sr=\EM:\
-	:ti=\E7\E[?47h:te=\E[2J\E[?47l\E8:\
-	:up=\E[A:us=\E[4m:ue=\E[m:xn:
+	:ti=\E7\E[?47h:te=\E[2J\E[?47l\E8:up=\E[A:us=\E[4m:ue=\E[m:xn:
 #
 # Compatible with the R5 xterm
 r5|xterm-r5|X11R5 xterm X11R5:\
Index: xc/programs/xterm/terminfo
diff -u xc/programs/xterm/terminfo:3.40 xc/programs/xterm/terminfo:3.42
--- xc/programs/xterm/terminfo:3.40	Mon Jun 12 22:28:41 2000
+++ xc/programs/xterm/terminfo	Tue Oct 31 20:12:42 2000
@@ -1,5 +1,5 @@
 # $XConsortium: terminfo,v 1.11 94/10/13 21:24:31 gildea Exp $
-# $XFree86: xc/programs/xterm/terminfo,v 3.40 2000/06/13 02:28:41 dawes Exp $
+# $XFree86: xc/programs/xterm/terminfo,v 3.42 2000/11/01 01:12:42 dawes Exp $
 #
 # XFree86 updates/notes/new entries (including xterm-8bit, xterm-16color)
 # - Thomas E. Dickey
@@ -77,6 +77,8 @@
 # keycodes.  To get a VMS-bias, make these substitutions:
 #	1. change khome to kfnd
 #	2. change kend to kslt
+# The original xterm-r6 entry does in fact have a VMS bias.
+#
 # Some legacy applications using the termcap emulation may expect kll where
 # we have specified kend.
 #
@@ -406,6 +408,51 @@
 	knp=\ES,
 	kpp=\ET,
 	use=xterm-basic,
+xterm-sco|XFree86 xterm with SCO function keys,
+	kcub1=\E[D,
+	kcud1=\E[B,
+	kcuf1=\E[C,
+	kcuu1=\E[A,
+	kend=\E[F,
+	kf1=\E[M,
+	kf10=\E[V,
+	kf11=\E[W,
+	kf12=\E[X,
+	kf13=\E[Y,
+	kf15=\E[a,
+	kf16=\E[b,
+	kf17=\E[c,
+	kf18=\E[d,
+	kf19=\E[e,
+	kf2=\E[N,
+	kf20=\E[f,
+	kf21=\E[g,
+	kf22=\E[h,
+	kf23=\E[i,
+	kf24=\E[j,
+	kf25=\E[k,
+	kf26=\E[l,
+	kf27=\E[m,
+	kf28=\E[n,
+	kf29=\E[o,
+	kf3=\E[O,
+	kf30=\E[p,
+	kf31=\E[q,
+	kf32=\E[r,
+	kf33=\E[s,
+	kf34=\E[t,
+	kf35=\E[u,
+	kf4=\E[P,
+	kf5=\E[Q,
+	kf6=\E[R,
+	kf7=\E[S,
+	kf8=\E[T,
+	kf9=\E[U,
+	khome=\E[H,
+	kich1=\E[L,
+	knp=\E[G,
+	kpp=\E[I,
+	use=xterm-basic,
 #
 # Other variants:
 xterm-24|xterms|vs100|xterm terminal emulator (X Window System),
@@ -422,7 +469,8 @@
 	rmso=\E[m,
 	smso=\E[1m,
 	use=xterm,
-xterm-mono|monochrome xterm (X Window System),
+xterm-mono|monochrome xterm,
+	bce@,
 	colors@,
 	ncv@,
 	pairs@,
@@ -503,14 +551,14 @@
 # to ncurses).
 xterm-xmc|xterm with magic-cookie glitch,
 	xmc#1,
-	use=xterm,
+	use=xterm-xfree86,
 #
 # This one also is primarily for testing ncurses; while the ISO 6429 defines
 # the REP control, none of the DEC VTxxx terminals (VT52 through VT420) support
 # it.
 xterm-rep|xterm with repeat-character control,
 	rep=%p1%c\E[%p2%{1}%-%db,
-	use=xterm,
+	use=xterm-xfree86,
 #
 # This is mainly for testing xterm; the real VT220 will not let you switch
 # character sets without first altering the keyboard language in the setup
@@ -520,7 +568,7 @@
 xterm-nrc|xterm with VT220 national replacement character sets,
 	csnm=%?%p1%{1}%=%tNorth American%e%p1%{2}%=%tBritish%e%p1%{3}%=%tFlemish%e%p1%{4}%=%tFrench Canadian%e%p1%{5}%=%tDanish%e%p1%{6}%=%tFinnish%e%p1%{7}%=%tGerman%e%p1%{8}%=%tDutch%e%p1%{9}%=%tItalian%e%p1%{10}%=%tSwiss (French)%e%p1%{11}%=%tSwiss (German)%e%p1%{12}%=%tSwedish%e%p1%{13}%=%tNorwegian%e%p1%{14}%=%tFrench/Belgian%e%p1%{15}%=%tSpanish%;,
 	scs=%?%p1%{1}%=%t\E(B%e%p1%{2}%=%t\E(A%e%p1%{3}%=%t\E(R%e%p1%{4}%=%t\E(9%e%p1%{5}%=%t\E(E%e%p1%{6}%=%t\E(5%e%p1%{7}%=%t\E(K%e%p1%{8}%=%t\E(4%e%p1%{9}%=%t\E(Y%e%p1%{10}%=%t\E(=%e%p1%{11}%=%t\E(=%e%p1%{12}%=%t\E(7%e%p1%{13}%=%t\E(E%e%p1%{14}%=%t\E(R%e%p1%{15}%=%t\E(Z%;,
-	use=xterm,
+	use=xterm-xfree86,
 #
 # Foreground 0-15 maps (with toggles) into 30-37 & 90-97
 # Background 0-15 maps (with toggles) into 40-47 & 100-107
@@ -622,7 +670,7 @@
 	il1=\233L,
 	ind=^J,
 	invis=\2338m,
-	is2=\E7\E G\233r\233m\233?7h\233?1;3;4;6l\2334l\E8\E>,
+	is2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8,
 	ka1=\217w,
 	ka3=\217u,
 	kb2=\217y,
@@ -680,7 +728,7 @@
 	rmso=\23327m,
 	rmul=\23324m,
 	rs1=\Ec,
-	rs2=\E7\E[62"p\E G\233r\233m\233?7h\233?1;3;4;6l\2334l\E8\E>,
+	rs2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8,
 	sc=\E7,
 	setab=\2334%p1%dm,
 	setaf=\2333%p1%dm,
@@ -707,7 +755,7 @@
 #	  alternate character set)
 #	+ added u6, u7, u8, u9 strings for Daniel Weaver's tack program.
 #	+ added kmous string for ncurses.
-#	+ added khome/kend strings.
+#	+ added khome/kend strings (which conflict with kfnd/kslt, see note).
 xterm-r6|xterm-old|xterm X11R6 version,
 	am,
 	km,
@@ -745,7 +793,7 @@
 	il=\E[%p1%dL,
 	il1=\E[L,
 	ind=^J,
-	is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>,
+	is2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8,
 	kbs=^H,
 	kcub1=\EOD,
 	kcud1=\EOB,
@@ -789,7 +837,7 @@
 	rmkx=\E[?1l\E>,
 	rmso=\E[m,
 	rmul=\E[m,
-	rs2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>,
+	rs2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8,
 	sc=\E7,
 	sgr0=\E[m,
 	smacs=^N,
@@ -814,6 +862,8 @@
 #	+ make khome consistent with other entries.
 #	+ use rmul/smul, rmir/smir from termcap, but not rmcup/smcup because
 #	  not everyone wants the alternate screen.
+#	+ added u6, u7, u8, u9 strings for Daniel Weaver's tack program.
+#	+ added kmous string for ncurses.
 xterm-r5|xterm R5 version,
 	am,
 	km,
@@ -876,6 +926,7 @@
 	khome=\E[1~,
 	kich1=\E[2~,
 	kil1=\E[30~,
+	kmous=\E[M,
 	knp=\E[6~,
 	kpp=\E[5~,
 	rc=\E8,
@@ -894,6 +945,10 @@
 	smso=\E[7m,
 	smul=\E[4m,
 	tbc=\E[3g,
+	u6=\E[%i%d;%dR,
+	u7=\E[6n,
+	u8=\E[?1;2c,
+	u9=\E[c,
 #
 # This is the only entry which you should have to customize, since "xterm"
 # is widely used for a variety of incompatible terminal emulations including
Index: xc/programs/xterm/trace.h
diff -u xc/programs/xterm/trace.h:3.9 xc/programs/xterm/trace.h:3.10
--- xc/programs/xterm/trace.h:3.9	Mon Jun 12 22:28:41 2000
+++ xc/programs/xterm/trace.h	Fri Sep 22 06:42:09 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/xterm/trace.h,v 3.9 2000/06/13 02:28:41 dawes Exp $
+ * $XFree86: xc/programs/xterm/trace.h,v 3.10 2000/09/22 10:42:09 alanh Exp $
  */
 
 /************************************************************
@@ -32,10 +32,6 @@
  */
 #ifndef	included_trace_h
 #define	included_trace_h
-
-#ifdef HAVE_CONFIG_H
-#include <xtermcfg.h>
-#endif
 
 #include <ptyx.h>
 
Index: xc/programs/xterm/util.c
diff -u xc/programs/xterm/util.c:3.54 xc/programs/xterm/util.c:3.61
--- xc/programs/xterm/util.c:3.54	Tue Jun 13 20:16:20 2000
+++ xc/programs/xterm/util.c	Thu Nov 30 22:27:58 2000
@@ -1,6 +1,6 @@
 /*
  *	$XConsortium: util.c /main/33 1996/12/01 23:47:10 swick $
- *	$XFree86: xc/programs/xterm/util.c,v 3.54 2000/06/14 00:16:20 dawes Exp $
+ *	$XFree86: xc/programs/xterm/util.c,v 3.61 2000/12/01 03:27:58 keithp Exp $
  */
 
 /*
@@ -64,6 +64,10 @@
 #include <menu.h>
 #include <fontutils.h>
 
+#if OPT_WIDE_CHARS
+#include <wcwidth.h>
+#endif
+
 #include <stdio.h>
 #include <ctype.h>
 
@@ -496,9 +500,14 @@
 void
 InsertChar (TScreen *screen, int n)
 {
+	register int width;
+
 	if(screen->cursor_state)
 		HideCursor();
 	screen->do_wrap = 0;
+	if (n > (width = screen->max_col + 1 - screen->cur_col))
+	    n = width;
+
 	if(screen->cur_row - screen->topline <= screen->max_row) {
 	    if(!AddToRefresh(screen)) {
 		int col = screen->max_col + 1 - n;
@@ -544,7 +553,7 @@
 		HideCursor();
 	screen->do_wrap = 0;
 	if (n > (width = screen->max_col + 1 - screen->cur_col))
-	  	n = width;
+		n = width;
 
 	if(screen->cur_row - screen->topline <= screen->max_row) {
 	    if(!AddToRefresh(screen)) {
@@ -732,6 +741,10 @@
 	})
 	if_OPT_WIDE_CHARS(screen,{
 		memset(SCRN_BUF_WIDEC(screen, row) + col, 0, len);
+		memset(SCRN_BUF_COM1L(screen, row) + col, 0, len);
+		memset(SCRN_BUF_COM1H(screen, row) + col, 0, len);
+		memset(SCRN_BUF_COM2L(screen, row) + col, 0, len);
+		memset(SCRN_BUF_COM2H(screen, row) + col, 0, len);
 	})
 
 	return rc;
@@ -813,7 +826,7 @@
 
 	if (saved_mode == DEC_PROTECT
 	 && saved_mode != mode)
-	 	screen->protected_mode = OFF_PROTECT;
+		screen->protected_mode = OFF_PROTECT;
 
 	switch (param) {
 	case -1:	/* DEFAULT */
@@ -846,7 +859,7 @@
 
 	if (saved_mode == DEC_PROTECT
 	 && saved_mode != mode)
-	 	screen->protected_mode = OFF_PROTECT;
+		screen->protected_mode = OFF_PROTECT;
 
 	switch (param) {
 	case -1:	/* DEFAULT */
@@ -1156,7 +1169,6 @@
 ChangeColors(XtermWidget tw, ScrnColors *pNew)
 {
 	TScreen *screen = &tw->screen;
-	Bool	newCursor=	TRUE;
 #if OPT_TEK4014
 	Window tek = TWindow(screen);
 #endif
@@ -1172,7 +1184,6 @@
 		 (COLOR_DEFINED(pNew,TEXT_FG))) {
 	    screen->cursorcolor=	COLOR_VALUE(pNew,TEXT_FG);
 	}
-	else newCursor=	FALSE;
 
 	if (COLOR_DEFINED(pNew,TEXT_FG)) {
 	    Pixel	fg=	COLOR_VALUE(pNew,TEXT_FG);
@@ -1363,6 +1374,51 @@
 #define SAVE_FONT_INFO(screen) xtermSaveFontInfo (screen, screen->fnt_norm)
 #endif
 
+#ifdef XRENDERFONT
+static XftColor *
+getColor(Pixel pixel)
+{
+#define CACHE_SIZE  4
+    static struct {
+	XftColor	color;
+	int		use;
+    } cache[CACHE_SIZE];
+    static int	    use;
+    int		    i;
+    int		    oldest, oldestuse;
+    XColor	    color;
+    
+    oldestuse = 0x7fffffff;
+    oldest = 0;
+    for (i = 0; i < CACHE_SIZE; i++)
+    {
+	if (cache[i].use)
+	{
+	    if (cache[i].color.pixel == pixel) 
+	    {
+		cache[i].use = ++use;
+		return &cache[i].color;
+	    }
+	}
+	if (cache[i].use < oldestuse)
+	{
+	    oldestuse = cache[i].use;
+	    oldest = i;
+	}
+    }
+    i = oldest;
+    color.pixel = pixel;
+    XQueryColor (term->screen.display, term->core.colormap, &color);
+    cache[i].color.color.red = color.red;
+    cache[i].color.color.green = color.green;
+    cache[i].color.color.blue = color.blue;
+    cache[i].color.color.alpha = 0xffff;
+    cache[i].color.pixel = pixel;
+    cache[i].use = ++use;
+    return &cache[i].color;
+}
+#endif
+
 /*
  * Draws text with the specified combination of bold/underline
  */
@@ -1375,8 +1431,49 @@
 	int y,
 	int chrset,
 	PAIRED_CHARS(Char *text, Char *text2),
-	Cardinal len)
+	Cardinal len,
+	int on_wide)
 {
+    int real_length = len;
+    int draw_len;
+
+#ifdef XRENDERFONT
+    if (screen->renderFont)
+    {
+	Display		*dpy = screen->display;
+	XftFont		*font;
+	XGCValues	values;
+	
+	if (!screen->renderDraw)
+	{
+	    int			    scr;
+	    Drawable		    draw = VWindow(screen);
+	    Visual		    *visual;
+
+	    scr = DefaultScreen (dpy);
+	    visual = DefaultVisual (dpy, scr);
+	    screen->renderDraw = XftDrawCreate (dpy, draw, visual, 
+						DefaultColormap (dpy, scr));
+	}
+	if ((flags & (BOLD|BLINK)) && screen->renderFontBold)
+	    font = screen->renderFontBold;
+	else
+	    font = screen->renderFont;
+	XGetGCValues (dpy, gc, GCForeground|GCBackground, &values);
+	XftDrawRect (screen->renderDraw, 
+		     getColor (values.background),
+		     x, y, 
+		     len * FontWidth(screen), FontHeight(screen));
+			
+	y += font->ascent;
+	XftDrawString8 (screen->renderDraw,
+			getColor (values.foreground),
+			font,
+			x, y, (unsigned char *) text, len);
+
+	return x + len * FontWidth(screen);
+    }
+#endif
 #if OPT_WIDE_CHARS
 	/*
 	 * It's simpler to pass in a null pointer for text2 in places where
@@ -1470,14 +1567,14 @@
 					x = drawXtermText(screen, flags, gc2,
 						x, y, 0,
 						PAIRED_CHARS(text++, text2++),
-						1);
+						1, on_wide);
 					x += FontWidth(screen);
 				}
 			} else {
 				x = drawXtermText(screen, flags, gc2,
 					x, y, 0,
 					PAIRED_CHARS(text, text2),
-					len);
+					len, on_wide);
 				x += len * FontWidth(screen);
 			}
 
@@ -1502,7 +1599,7 @@
 				temp[n++] = *text++;
 				temp[n++] = ' ';
 			}
-			x = drawXtermText(screen, flags, gc, x, y, 0, PAIRED_CHARS(temp, wide), n);
+			x = drawXtermText(screen, flags, gc, x, y, 0, PAIRED_CHARS(temp, wide), n, on_wide);
 			free(temp);
 			if_OPT_WIDE_CHARS(screen,{
 				free(wide);
@@ -1549,7 +1646,7 @@
 			adj = (FontWidth(screen) - width) / 2;
 			(void)drawXtermText(screen, flags, gc, x + adj, y,
 					    chrset,
-					    PAIRED_CHARS(text++, text2++), 1);
+					    PAIRED_CHARS(text++, text2++), 1, on_wide);
 			x += FontWidth(screen);
 		}
 		screen->fnt_prop = True;
@@ -1566,25 +1663,71 @@
 
 #if OPT_WIDE_CHARS
 		if (screen->wide_chars) {
+			int ascent_adjust = 0;
 			static XChar2b *sbuf;
 			static Cardinal slen;
 			Cardinal n;
+			int ch = text[0] | (text2[0] << 8);
+			int wideness = (on_wide || iswide(ch)!=0) && (screen->fnt_dwd!=NULL);
+			unsigned char *endtext = text + len;
 			if (slen < len) {
 				slen = (len + 1) * 2;
 				sbuf = (XChar2b *)XtRealloc((char *)sbuf, slen * sizeof(*sbuf));
 			}
 			for (n = 0; n < len; n++) {
-				sbuf[n].byte2 = text[n];
-				sbuf[n].byte1 = text2[n];
+				sbuf[n].byte2 = *text;
+				sbuf[n].byte1 = *text2;
+				text++; text2++;
+				if (wideness) {
+					/* filter out those pesky fake characters. */
+					while (text < endtext
+					 && *text == HIDDEN_HI
+					 && *text2 == HIDDEN_LO) {
+						text++; text2++;
+						len--;
+					}
+				}
+			}
+			/* This is probably wrong. But it works. */
+			draw_len = len;
+			if (wideness && (screen->fnt_dwd->fid || screen->fnt_dwdb->fid)) {
+				draw_len = real_length = len * 2;
+				if (flags & (BOLD|BLINK) && screen->fnt_dwdb->fid) {
+				  XSetFont(screen->display, gc, screen->fnt_dwdb->fid);
+				  ascent_adjust = screen->fnt_dwdb->ascent - screen->fnt_norm->ascent;
+				}
+				else {
+				  XSetFont(screen->display, gc, screen->fnt_dwd->fid);
+				  ascent_adjust = screen->fnt_dwd->ascent - screen->fnt_norm->ascent;
+				}
+				/* fix ascent */
 			}
-			XDrawImageString16(screen->display, VWindow(screen), gc,
-				x, y, sbuf, len);
+			else if (flags & (BOLD|BLINK) && screen->fnt_bold->fid)
+				XSetFont(screen->display, gc, screen->fnt_bold->fid);
+			else
+				XSetFont(screen->display, gc, screen->fnt_norm->fid);
+
+			if (my_wcwidth(ch) == 0)
+				XDrawString16(screen->display,
+					      VWindow(screen), gc,
+					      x, y + ascent_adjust,
+					      sbuf, n);
+			else
+				XDrawImageString16(screen->display,
+						   VWindow(screen), gc,
+						   x, y + ascent_adjust,
+						   sbuf, n);
+
 		} else
 #endif
 		{
 		XDrawImageString(screen->display, VWindow(screen), gc,
 			x, y,  (char *)text, len);
-
+		draw_len = len;
+#if !OPT_WIDE_CHARS
+		/* FIXME: This is rather broken with wide chars. It should
+		 * use XDrawString16 where appropriate.
+		 */
 		if ((flags & (BOLD|BLINK)) && screen->enbolden) {
 #if OPT_CLIP_BOLD
 			/*
@@ -1611,32 +1754,39 @@
 			XSetClipMask(screen->display, gc, None);
 #endif
 		}
+#endif /* !OPT_WIDE_CHARS */
 		}
 
 		if ((flags & UNDERLINE) && screen->underline) {
 			if (FontDescent(screen) > 1)
 				y++;
 			XDrawLine(screen->display, VWindow(screen), gc,
-				x, y, x + len * screen->fnt_wide - 1, y);
+				x, y, x + draw_len * screen->fnt_wide - 1, y);
 		}
 #if OPT_BOX_CHARS
 #define DrawX(col) x + (col * (screen->fnt_wide))
-#define DrawSegment(first,last) (void)drawXtermText(screen, flags, gc, DrawX(first), y, chrset, PAIRED_CHARS(text+first, text2+first), last-first)
+#define DrawSegment(first,last) (void)drawXtermText(screen, flags, gc, DrawX(first), y, chrset, PAIRED_CHARS(text+first, text2+first), last-first, on_wide)
 	} else {	/* fill in missing box-characters */
 		XFontStruct *font = (flags & BOLD)
 				  ? screen->fnt_bold
 				  : screen->fnt_norm;
 		Cardinal last, first = 0;
 		Boolean save_force = screen->force_box_chars;
-
 		screen->fnt_boxes = True;
 		for (last = 0; last < len; last++) {
 			unsigned ch = text[last];
+			Boolean isMissing;
 #if OPT_WIDE_CHARS
 			if (text2 != 0)
 				ch |= (text2[last] << 8);
+			isMissing = xtermMissingChar(ch,
+					((on_wide || iswide(ch)) && screen->fnt_dwd)
+					? screen->fnt_dwd
+					: font);
+#else
+			isMissing = xtermMissingChar(ch, font);
 #endif
-			if (xtermMissingChar(ch, font)) {
+			if (isMissing) {
 				if (last > first) {
 					screen->force_box_chars = False;
 					DrawSegment(first,last);
@@ -1655,7 +1805,7 @@
 #endif
 	}
 
-	return x + len * FontWidth(screen);
+	return x + real_length * FontWidth(screen);
 }
 
 /*
@@ -1843,6 +1993,22 @@
     return ch;
 }
 
+unsigned getXtermCellComb1 (TScreen *screen, int row, int col)
+{
+    unsigned ch = SCRN_BUF_COM1L(screen, row)[col];
+    ch |= (SCRN_BUF_COM1H(screen, row)[col] << 8);
+    return ch;
+}
+
+
+unsigned getXtermCellComb2 (TScreen *screen, int row, int col)
+{
+    unsigned ch = SCRN_BUF_COM2L(screen, row)[col];
+    ch |= (SCRN_BUF_COM2H(screen, row)[col] << 8);
+    return ch;
+}
+
+
 /*
  * Sets a single 8/16-bit number for the given cell
  */
@@ -1851,7 +2017,26 @@
     SCRN_BUF_CHARS(screen, row)[col] = ch;
     if_OPT_WIDE_CHARS(screen,{
 	SCRN_BUF_WIDEC(screen, row)[col] = (ch >> 8);
+	SCRN_BUF_COM1L(screen, row)[col] = 0;
+	SCRN_BUF_COM1H(screen, row)[col] = 0;
+	SCRN_BUF_COM2L(screen, row)[col] = 0;
+	SCRN_BUF_COM2H(screen, row)[col] = 0;
     })
+}
+
+/*
+ * Add a the combining character for the given cell
+ */
+void addXtermCombining (TScreen *screen, int row, int col, int ch)
+{
+    if (!SCRN_BUF_COM1L(screen, row)[col]
+     && !SCRN_BUF_COM1H(screen, row)[col]) {
+	    SCRN_BUF_COM1L(screen, row)[col] = ch & 0xff;
+	    SCRN_BUF_COM1H(screen, row)[col] = ch >> 8;
+    } else if (!SCRN_BUF_COM2H(screen, row)[col]) {
+	    SCRN_BUF_COM2L(screen, row)[col] = ch & 0xff;
+	    SCRN_BUF_COM2H(screen, row)[col] = ch >> 8;
+    }
 }
 #endif
 
Index: xc/programs/xterm/version.h
diff -u xc/programs/xterm/version.h:3.57 xc/programs/xterm/version.h:3.62
--- xc/programs/xterm/version.h:3.57	Fri Jun 30 14:27:03 2000
+++ xc/programs/xterm/version.h	Wed Dec  6 21:50:05 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/xterm/version.h,v 3.57 2000/06/30 18:27:03 dawes Exp $ */
+/* $XFree86: xc/programs/xterm/version.h,v 3.62 2000/12/07 02:50:05 dickey Exp $ */
 
 /*
  * These definitions are used to build the string that's printed in response to
@@ -6,5 +6,5 @@
  * XFree86 to which this version of xterm has been built.  The number in
  * parentheses is my patch number (T.Dickey).
  */
-#define XTERM_PATCH   139
-#define XFREE86_VERSION "XFree86 4.0.1"
+#define XTERM_PATCH   149
+#define XFREE86_VERSION "XFree86 4.0.1h"
Index: xc/programs/xterm/wcwidth.c
diff -u /dev/null xc/programs/xterm/wcwidth.c:1.1
--- /dev/null	Mon Dec 18 14:36:27 2000
+++ xc/programs/xterm/wcwidth.c	Sat Aug 26 00:33:54 2000
@@ -0,0 +1,131 @@
+/*
+ * This is an implementation of wcwidth() and wcswidth() as defined in
+ * "The Single UNIX Specification, Version 2, The Open Group, 1997"
+ * <http://www.UNIX-systems.org/online.html>
+ *
+ * Markus Kuhn -- 2000-02-08 -- public domain
+ */
+
+/* $XFree86: xc/programs/xterm/wcwidth.c,v 1.1 2000/08/26 04:33:54 dawes Exp $ */
+
+#include <wcwidth.h>
+
+/* These functions define the column width of an ISO 10646 character
+ * as follows:
+ *
+ *    - The null character (U+0000) has a column width of 0.
+ *
+ *    - Other C0/C1 control characters and DEL will lead to a return
+ *      value of -1.
+ *
+ *    - Non-spacing and enclosing combining characters (general
+ *      category code Mn or Me in the Unicode database) have a
+ *      column width of 0.
+ *
+ *    - Spacing characters in the East Asian Wide (W) or East Asian
+ *      FullWidth (F) category as defined in Unicode Technical
+ *      Report #11 have a column width of 2.
+ *
+ *    - All remaining characters (including all printable
+ *      ISO 8859-1 and WGL4 characters, Unicode control characters,
+ *      etc.) have a column width of 1.
+ *
+ * This implementation assumes that wchar_t characters are encoded
+ * in ISO 10646.
+ */
+
+int my_wcwidth(wchar_t ucs)
+{
+  /* sorted list of non-overlapping intervals of non-spacing characters */
+  static const struct interval {
+    unsigned short first;
+    unsigned short last;
+  } combining[] = {
+    { 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 },
+    { 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
+    { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
+    { 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 },
+    { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
+    { 0x0711, 0x0711 }, { 0x0730, 0x074A }, { 0x07A6, 0x07B0 },
+    { 0x0901, 0x0902 }, { 0x093C, 0x093C }, { 0x0941, 0x0948 },
+    { 0x094D, 0x094D }, { 0x0951, 0x0954 }, { 0x0962, 0x0963 },
+    { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 },
+    { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 }, { 0x0A02, 0x0A02 },
+    { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 },
+    { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 },
+    { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 },
+    { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C },
+    { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D },
+    { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 },
+    { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 },
+    { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBF, 0x0CBF },
+    { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, { 0x0D41, 0x0D43 },
+    { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 },
+    { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A },
+    { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 },
+    { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 },
+    { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 },
+    { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 },
+    { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 },
+    { 0x102D, 0x1030 }, { 0x1032, 0x1032 }, { 0x1036, 0x1037 },
+    { 0x1039, 0x1039 }, { 0x1058, 0x1059 }, { 0x17B7, 0x17BD },
+    { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x18A9, 0x18A9 },
+    { 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
+    { 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }
+  };
+  int min = 0;
+  int max = sizeof(combining) / sizeof(struct interval) - 1;
+  int mid;
+
+  /* test for 8-bit control characters */
+  if (ucs == 0)
+    return 0;
+  if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) {
+    return -1;
+  }
+
+  /* first quick check for Latin-1 etc. characters */
+  if (ucs < combining[0].first)
+    return 1;
+
+  /* binary search in table of non-spacing characters */
+  while (max >= min) {
+    mid = (min + max) / 2;
+    if (combining[mid].last < ucs)
+      min = mid + 1;
+    else if (combining[mid].first > ucs)
+      max = mid - 1;
+    else if (combining[mid].first <= ucs && combining[mid].last >= ucs)
+      return 0;
+  }
+
+  /* if we arrive here, ucs is not a combining or C0/C1 control character */
+
+  /* fast test for majority of non-wide scripts */
+  if (ucs < 0x1100)
+    return 1;
+
+  return 1 +
+    ((ucs >= 0x1100 && ucs <= 0x115f) || /* Hangul Jamo */
+     (ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
+      ucs != 0x303f) ||                  /* CJK ... Yi */
+     (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
+     (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
+     (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
+     (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
+     (ucs >= 0xffe0 && ucs <= 0xffe6));
+}
+
+
+int wcswidth(const wchar_t *pwcs, size_t n)
+{
+  int w, width = 0;
+
+  for (;*pwcs && n-- > 0; pwcs++)
+    if ((w = my_wcwidth(*pwcs)) < 0)
+      return -1;
+    else
+      width += w;
+
+  return width;
+}
Index: xc/programs/xterm/wcwidth.h
diff -u /dev/null xc/programs/xterm/wcwidth.h:1.1
--- /dev/null	Mon Dec 18 14:36:27 2000
+++ xc/programs/xterm/wcwidth.h	Sat Aug 26 00:33:55 2000
@@ -0,0 +1,11 @@
+/* $XFree86: xc/programs/xterm/wcwidth.h,v 1.1 2000/08/26 04:33:55 dawes Exp $ */
+
+#ifndef	included_wcwidth_h
+#define	included_wcwidth_h 1
+
+#include <stddef.h>
+
+extern int my_wcwidth(wchar_t ucs);
+extern int wcswidth(const wchar_t *pwcs, size_t n);
+
+#endif /* included_wcwidth_h */
Index: xc/programs/xterm/xstrings.c
diff -u /dev/null xc/programs/xterm/xstrings.c:1.1
--- /dev/null	Mon Dec 18 14:36:28 2000
+++ xc/programs/xterm/xstrings.c	Fri Sep 22 06:44:29 2000
@@ -0,0 +1,68 @@
+/* $XFree86: xc/programs/xterm/xstrings.c,v 1.1 2000/09/22 10:44:29 alanh Exp $ */
+
+/************************************************************
+
+Copyright 2000 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#include <sys/types.h>
+#include <string.h>
+#include <xstrings.h>
+
+char *
+x_basename(char *name)
+{
+    char *cp;
+
+    cp = strrchr(name, '/');
+#ifdef __EMX__
+    if (cp == 0)
+	cp = strrchr(name, '\\');
+#endif
+    return (cp ? cp + 1 : name);
+}
+
+/*
+ * Returns a pointer to the first occurrence of s2 in s1,
+ * or NULL if there are none.
+ */
+char *
+x_strindex(char *s1, char *s2)
+{
+    char *s3;
+    size_t s2len = strlen(s2);
+
+    while ((s3 = strchr(s1, *s2)) != NULL) {
+	if (strncmp(s3, s2, s2len) == 0)
+	    return (s3);
+	s1 = ++s3;
+    }
+    return (NULL);
+}
Index: xc/programs/xterm/xstrings.h
diff -u /dev/null xc/programs/xterm/xstrings.h:1.1
--- /dev/null	Mon Dec 18 14:36:28 2000
+++ xc/programs/xterm/xstrings.h	Fri Sep 22 06:44:29 2000
@@ -0,0 +1,41 @@
+/* $XFree86: xc/programs/xterm/xstrings.h,v 1.1 2000/09/22 10:44:29 alanh Exp $ */
+
+/************************************************************
+
+Copyright 2000 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#ifndef included_xstrings_h
+#define included_xstrings_h 1
+
+extern char *x_basename(char *name);
+extern char *x_strindex(char *s1, char *s2);
+
+#endif /* included_xstrings_h */
Index: xc/programs/xterm/xterm.h
diff -u xc/programs/xterm/xterm.h:3.60 xc/programs/xterm/xterm.h:3.65
--- xc/programs/xterm/xterm.h:3.60	Tue Jun 13 20:16:21 2000
+++ xc/programs/xterm/xterm.h	Thu Dec  7 05:12:34 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/xterm/xterm.h,v 3.60 2000/06/14 00:16:21 dawes Exp $ */
+/* $XFree86: xc/programs/xterm/xterm.h,v 3.65 2000/12/07 10:12:34 dickey Exp $ */
 
 /************************************************************
 
@@ -182,6 +182,12 @@
 #undef HAVE_WAITPID
 #endif
 
+#if OPT_WIDE_CHARS
+#define HIDDEN_HI 0xff
+#define HIDDEN_LO 0xff
+#define HIDDEN_CHAR 0xffff
+#endif
+
 /***====================================================================***/
 
 #include <proto.h>
@@ -271,6 +277,9 @@
 #define XtNeightBitInput	"eightBitInput"
 #define XtNeightBitOutput	"eightBitOutput"
 #define XtNfontDoublesize	"fontDoublesize"
+#define XtNfontStyle		"fontStyle"
+#define XtNfaceName		"faceName"
+#define XtNfaceSize		"faceSize"
 #define XtNhighlightColor	"highlightColor"
 #define XtNhighlightSelection	"highlightSelection"
 #define XtNhpLowerleftBugCompat	"hpLowerleftBugCompat"
@@ -321,6 +330,8 @@
 #define XtNutf8			"utf8"
 #define XtNvisualBell		"visualBell"
 #define XtNwideChars		"wideChars"
+#define XtNwideFont		"wideFont"
+#define XtNwideBoldFont		"wideBoldFont"
 #define XtNxmcAttributes	"xmcAttributes"
 #define XtNxmcGlitch		"xmcGlitch"
 #define XtNxmcInline		"xmcInline"
@@ -356,7 +367,10 @@
 #define XtCEightBitControl	"EightBitControl"
 #define XtCEightBitInput	"EightBitInput"
 #define XtCEightBitOutput	"EightBitOutput"
+#define XtCFaceName		"FaceName"
+#define XtCFaceSize		"FaceSize"
 #define XtCFontDoublesize	"FontDoublesize"
+#define XtCFontStyle		"FontStyle"
 #define XtCHighlightSelection	"HighlightSelection"
 #define XtCHpLowerleftBugCompat	"HpLowerleftBugCompat"
 #define XtCJumpScroll		"JumpScroll"
@@ -399,6 +413,8 @@
 #define XtCUtf8			"Utf8"
 #define XtCVisualBell		"VisualBell"
 #define XtCWideChars		"WideChars"
+#define XtCWideFont		"WideFont"
+#define XtCWideBoldFont		"WideBoldFont"
 #define XtCXmcAttributes	"XmcAttributes"
 #define XtCXmcGlitch		"XmcGlitch"
 #define XtCXmcInline		"XmcInline"
@@ -468,6 +484,10 @@
 extern void InitLocatorFilter (XtermWidget w);
 #endif	/* OPT_DEC_LOCATOR */
 
+#if OPT_WIDE_CHARS
+extern int iswide(int i);
+#endif
+
 /* charproc.c */
 extern int VTInit (void);
 extern int v_write (int f, Char *d, int len);
@@ -525,12 +545,16 @@
 /* input.c */
 extern Boolean xtermDeleteIsDEL (void);
 extern void Input (TKeyboard *keyboard, TScreen *screen, XKeyEvent *event, Bool eightbit);
-extern void StringInput (TScreen *screen, char *string, size_t nbytes);
+extern void StringInput (TScreen *screen, Char *string, size_t nbytes);
 
 #if OPT_NUM_LOCK
 extern void VTInitModifiers(void);
 #endif
 
+#if OPT_TCAP_QUERY
+extern int xtermcapKeycode(char *params, unsigned *state);
+#endif
+
 #if OPT_WIDE_CHARS
 extern int convertFromUTF8(unsigned long c, Char *strbuf);
 #endif
@@ -558,7 +582,6 @@
 /* misc.c */
 extern Cursor make_colored_cursor (unsigned cursorindex, unsigned long fg, unsigned long bg);
 extern char *SysErrorMsg (int n);
-extern char *strindex (char *s1, char *s2);
 extern char *udk_lookup (int keycode, int *len);
 extern int XStrCmp (char *s1, char *s2);
 extern int creat_as (int uid, int gid, Boolean append, char *pathname, int mode);
@@ -649,7 +672,7 @@
 extern void ScrnDeleteLine (TScreen *screen, ScrnBuf sb, int n, int last, int size, int where);
 extern void ScrnInsertChar (TScreen *screen, int n);
 extern void ScrnInsertLine (TScreen *screen, ScrnBuf sb, int last, int where, int n, int size);
-extern void ScrnRefresh (TScreen *screen, int toprow, int leftcol, int nrows, int ncols, int force);
+extern void ScrnRefresh (TScreen *screen, int toprow, int leftcol, int nrows, int ncols, Bool force);
 
 #define ScrnClrWrapped(screen, row) \
 	SCRN_BUF_FLAGS(screen, row + screen->topline) = \
@@ -689,7 +712,7 @@
 extern int AddToRefresh (TScreen *screen);
 extern int HandleExposure (TScreen *screen, XEvent *event);
 extern int char2lower(int ch);
-extern int drawXtermText (TScreen *screen, unsigned flags, GC gc, int x, int y, int chrset, PAIRED_CHARS(Char *text, Char *text2), Cardinal len);
+extern int drawXtermText (TScreen *screen, unsigned flags, GC gc, int x, int y, int chrset, PAIRED_CHARS(Char *text, Char *text2), Cardinal len, int on_wide);
 extern void ChangeAnsiColors (XtermWidget tw);
 extern void ChangeColors (XtermWidget tw, ScrnColors *pNew);
 extern void ClearRight (TScreen *screen, int n);
@@ -779,6 +802,9 @@
 
 #if OPT_WIDE_CHARS
 extern unsigned getXtermCell (TScreen *screen, int row, int col);
+extern unsigned getXtermCellComb1 (TScreen *screen, int row, int col);
+extern unsigned getXtermCellComb2 (TScreen *screen, int row, int col);
+extern void addXtermCombining (TScreen *screen, int row, int col, int ch);
 extern void putXtermCell (TScreen *screen, int row, int col, int ch);
 #else
 #define getXtermCell(screen,row,col) SCRN_BUF_CHARS(screen, row)[col]
@@ -789,6 +815,12 @@
 extern void Mark_XMC (TScreen *screen, int param);
 extern void Jump_XMC (TScreen *screen);
 extern void Resolve_XMC (TScreen *screen);
+#endif
+
+#if OPT_WIDE_CHARS
+int visual_width(PAIRED_CHARS(Char *str, Char *str2), Cardinal len);
+#else
+#define visual_width(a, b) (b)
 #endif
 
 #ifdef	__cplusplus
Index: xc/programs/xterm/xterm.log.html
diff -u xc/programs/xterm/xterm.log.html:1.56 xc/programs/xterm/xterm.log.html:1.61
--- xc/programs/xterm/xterm.log.html:1.56	Tue Jun 20 01:08:51 2000
+++ xc/programs/xterm/xterm.log.html	Wed Dec  6 21:50:06 2000
@@ -20,7 +20,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   *
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.            *
  *****************************************************************************
-  $XFree86: xc/programs/xterm/xterm.log.html,v 1.56 2000/06/20 05:08:51 dawes Exp $
+  $XFree86: xc/programs/xterm/xterm.log.html,v 1.61 2000/12/07 02:50:06 dickey Exp $
   -->
 <HTML>
 <HEAD>
@@ -42,6 +42,16 @@
 xc/programs/Xserver/hw/xfree86).
 
 <UL>
+<LI><A HREF="#xterm_149">Patch #149 - 2000/12/6 - XFree86 4.0.1h</A>
+<LI><A HREF="#xterm_148">Patch #148 - 2000/10/31 - XFree86 4.0.1d</A>
+<LI><A HREF="#xterm_147">Patch #147 - 2000/10/26 - XFree86 4.0.1c</A>
+<LI><A HREF="#xterm_146">Patch #146 - 2000/9/12 - XFree86 4.0.1c</A>
+<LI><A HREF="#xterm_145">Patch #145 - 2000/9/11 - XFree86 4.0.1c</A>
+<LI><A HREF="#xterm_144">Patch #144 - 2000/8/23 - XFree86 4.0.1b</A>
+<LI><A HREF="#xterm_143">Patch #143 - 2000/8/19 - XFree86 4.0.1b</A>
+<LI><A HREF="#xterm_142">Patch #142 - 2000/8/18 - XFree86 4.0.1b</A>
+<LI><A HREF="#xterm_141">Patch #141 - 2000/7/14 - XFree86 4.0.1b</A>
+<LI><A HREF="#xterm_140">Patch #140 - 2000/7/23 - XFree86 4.0.1</A>
 <LI><A HREF="#xterm_139">Patch #139 - 2000/6/17 - XFree86 4.0d</A>
 <LI><A HREF="#xterm_138">Patch #138 - 2000/6/15 - XFree86 4.0c</A>
 <LI><A HREF="#xterm_137">Patch #137 - 2000/6/10 - XFree86 4.0b</A>
@@ -183,6 +193,253 @@
 <LI><A HREF="#xterm_02">Patch #2 - 1996/1/7</A>
 <LI><A HREF="#xterm_01">Patch #1 - 1996/1/6</A>
 </UL>
+
+<H1><A NAME="xterm_149">Patch #149 - 2000/12/6 - XFree86 4.0.1h</A></H1>
+<ul>
+	<li>expanded description of environment variables in manual-page.
+
+	<li>modify OPT_TCAP_QUERY feature to always return the termcap or
+	  terminfo capability string in the response, and to read/write the
+	  names in hexadecimal form to allow for the special case of termcap's
+	  <code>k;</code> name (patch by Bram Moolenaar).
+
+	<li>add OPT_SAME_NAME and OPT_TCAP_QUERY to xtermcfg.hin, so the
+	  corresponding configure options work (patch by Bram Moolenaar).
+
+	<li>resync with XFree86 4.0.1g:
+	<ul>
+	  <li>Rewrite Xft library for Render extension/core text and font management
+	    Change xterm to use new interface (Keith Packard).
+	</ul>
+</ul>
+
+<H1><A NAME="xterm_148">Patch #148 - 2000/10/31 - XFree86 4.0.1d</A></H1>
+<ul>
+	<li>document logfile options in man-page.
+
+	<li>correct spelling of <code>-samename</code> option in help message.
+
+	<li>add configure script option <code>--enable-tcap-query</code>
+	  (request by Bram Moolenaar).
+
+	<li>patch by Bram Moolenaar to add a
+	  "Co" or "colors" entry to the OPT_TCAP_QUERY feature.
+	<li>patch by Kiyokazu SUTO &lt;suto@ks-and-ks.ne.jp&gt;:
+	<ul>
+	  <li>add support for bold font for double width characters.
+	     The font name may be specified with the command line option
+	     <code>-fwb</code> or with resource
+	     <code>wideBoldFont</code> (class <code>WideBoldFont</code>).
+	  <li>correct underlining of double width character string, which
+	     was drawn only half width.
+	  <li>correct binary search of precomposed character table, which
+	     may return wrong result when <code>int</code> is just 32 bits.
+	  </ul>
+
+	<li>some changes to align terminfo with ncurses 5.2:
+	<ul>
+	  <li>remove xtermm description, retaining xterm-mono since the former
+	    conflicts with ncurses.
+	  <li>modify initialization and reset strings to avoid putting the
+	    save/restore cursor operations bracketing changes to video
+	    attributes, since the changes could be lost when the cursor is
+	    restored.  This affects xterm-r6 and xterm-8bit (the xterm-xfree86
+	    entry uses the soft-reset feature which resets scrolling margins
+	    and origin mode without requiring us to save/restore the cursor
+	    position).
+	  <li>make a few entries explicitly inherit from xterm-xfree86 rather
+	    than xterm: xterm-rep, xterm-xmc, xterm-nrc
+	</ul>
+
+	<li>ensure that sign-extension does not affect <code>ctype</code>
+	  macros by using <code>CharOf()</code> macro to coerce the parameter
+	  to an unsigned char.
+
+	<li>resync with XFree86 4.0.1d:
+	<ul>
+	  <li>Add primitive support in xterm for Xft based fonts (Keith Packard).
+	    The changes are ifdef'd with <code>-DXRENDERFONT</code>.
+	</ul>
+</ul>
+
+<H1><A NAME="xterm_147">Patch #147 - 2000/10/26 - XFree86 4.0.1c</A></H1>
+<ul>
+	<li>correct implementation of <code>ptyInitialErase</code>:  the
+	  value assigned to <code>initial_erase</code> was for the control
+	  terminal, which is correct as far as it goes.  But there was no
+	  following test for the pseudo-terminal's erase value, which would
+	  overwrite the default obtained from the control terminal
+	  (reported by Christian Weisgerber &lt;naddy@mips.inka.de&gt;).
+
+	<li>modify check for printable-characters in OSC string to use xterm's
+	  ansi_table rather than isprint() macro, to isolate this check from
+	  locale settings.  This fixes a problem using 8-bit characters to
+	  set the title (reported by Ricardas Cepas &lt;rch@richard.eu.org&gt;).
+
+	<li>modify sample scripts to check for printf before print, since the
+	  latter is not as well standardized (e.g., on Linux).
+
+	<li>updated config.sub, config.guess to reflect changes on
+	  subversions.gnu.org
+</ul>
+
+<H1><A NAME="xterm_146">Patch #146 - 2000/9/12 - XFree86 4.0.1c</A></H1>
+<ul>
+	<li>correct two instances overlooked from patch #141 which assumed
+	  UTF-8 mode without checking, causing a core dump in non-UTF-8 mode
+	  (one instance was reported by Tommi Virtanen &lt;tv@debian.org&gt;).
+
+	<li>correct a problem selecting from the scrollback buffer in UTF-8
+	  mode by changing remaining getXtermCell() calls to XTERM_CELL() as in
+	  the non-UTF-8 cases (report by Markus Kuhn, patch by Robert Brady).
+</ul>
+
+<H1><A NAME="xterm_145">Patch #145 - 2000/9/11 - XFree86 4.0.1c</A></H1>
+<ul>
+	<li>several changes from Robert Brady for UTF-8 configuration:
+	<ul>
+	  <li>doublewide characters don't lose their accents when the cursor
+	    moves onto or from them (a visual bug)
+
+	  <li>fix logic in addXtermCombining, which mean that if the low byte
+	    of a cell's first combining char was 0, a following combining char
+	    would go into combining slot 1, not 2.
+
+	  <li>modify logic for cut-buffers so UTF-8 data is first converted
+	    to Latin1.
+
+	  <li>collapse surrogates, 0xfffe, 0xffff to UCS_REPL.
+
+	  <li>modify to allow xterm to to show combining characters
+	   attached to doublewidth characters.
+
+	  <li>correct bug in linewrap with -u8 option (reported by
+	    Andreas Koenig &lt;andreas.koenig@anima.de&gt;).
+	</ul>
+
+	<li>several changes to PTY logic (based on request by Tim Ryan
+	  &lt;timryan@nortelnetworks.com&gt;).
+	<ul>
+	  <li>modify treatment of <code>-S</code> option to to make it work with
+	    Unix98 PTY's.
+
+	  <li>restore sense of IsPts flag in <code>get_pty()</code>, which was
+	    lost in Unix98 changes.
+
+	  <li>use new functions <code>my_pty_id()</code> and
+	    <code>my_pty_name()</code> to simplify/fix strings used for utmp,
+	    wtmp identifiers.
+
+	  <li>simplify <code>get_pty()</code> function, making it have a single
+	    return point so its inputs/outputs can be identified.
+	</ul>
+
+	<li>update config.guess and config.sub and scripts to my 20000819 patch,
+	   adding cases for OS/2 EMX.
+
+	<li>add special case for os390 compiler options to configure script
+	  (patch by Paul Gilmartin)
+
+	<li>fix some unused-variable compiler warnings (reported by
+	  Zdenek Sekera).
+
+	<li>split-out some string functions into xstrings.c, to use them
+	  more consistently among main.c, os2main.c and resize.c
+
+	<li>align termcap/terminfo files, adding entries to make them match.
+	  The termcap entries are necessarily less complete than the terminfo,
+	  to fit within 1023 character per entry.
+
+	<li>add terminfo entry for xterm-sco (SCO function keys).
+
+	<li>modify <code>same_font_name()</code> to properly handle wildcard
+	  introduced in <code>bold_font_name()</code>, making comparison for
+	  different fonts succeed when only the normal font is specified.  This
+	  is needed to decide if 1-pixel offset should be used.  (reported
+	  in a newsgroup by Bart Oldeman &lt;enbeo@enbeo.resnet.bris.ac.uk&gt;)
+
+	<li>correct preprocessor line for OPT_WIDE_CHARS in drawXtermText()
+	  from patch #141 which resulted in overstriking for bold fonts not
+	  working.
+
+	<li>correct Imakefile from 4.0.1c resync so UTF-8 modules are in
+	  UTF8SRC, UTF8OBJ lists, allowing build without UTF-8 support.
+</ul>
+
+<H1><A NAME="xterm_144">Patch #144 - 2000/8/23 - XFree86 4.0.1b</A></H1>
+<ul>
+	<li>remove a spurious assignment in ScreenWrite() from Robert Brady's
+	  patch which set a null at the "end" of the buffer to be written. 
+	  That made the autowrap feature write a blank in the first column for
+	  the non-UTF-8 configuration, rather than the actual character
+	  (reported by Alan Citterman &lt;alan@mticket.com&gt;).
+</ul>
+
+<H1><A NAME="xterm_143">Patch #143 - 2000/8/19 - XFree86 4.0.1b</A></H1>
+<ul>
+	<li>add a check to ensure that <code>-class</code> command-line option
+	  is not confused with <code>-c</code> (reported by Paul Townsend
+	  &lt;aab@aab.cc.purdue.edu&gt;).
+</ul>
+
+<H1><A NAME="xterm_142">Patch #142 - 2000/8/18 - XFree86 4.0.1b</A></H1>
+<ul>
+	<li>correction to precompose scripts, so 0061 + 0300 will now be really
+	  be displayed as 00C0 (patch by Robert Brady
+	  &lt;robert@susu.org.uk&gt;).
+
+	<li>correct macro ClassSelects() in button.c, used to hide ifdef's for
+	  OPT_WIDE_CHARS in patch #141 (reported by Andreas Paul
+	  &lt;paula@informatik.tu-muenchen.de&gt;).
+
+	<li>change wcwidth.h to include stddef.h rather than wchar.h, which is
+	  not present on OpenBSD and FreeBSD (reported by Christian
+	  Weisgerber and Bram Moolenaar).
+
+	<li>newer config.sub and config.guess, from lynx 2.8.4dev.7
+</ul>
+
+<H1><A NAME="xterm_141">Patch #141 - 2000/8/14 - XFree86 4.0.1b</A></H1>
+<ul>
+	<li>Most of this patch is an integration of Robert Brady's patch #11
+	  for doublewidth and combining characters, from
+	  http://www.ecs.soton.ac.uk/~rwb197/xterm/.  In this context,
+	  doublewidth refers to 16-bit character sets which may have glyphs
+	  occupying two cells.
+
+	<li>add command-line option <code>-class</code>, which allows one
+	  to override xterm's resource class.  Also add resource file
+	  <code>UXTerm.ad</code>, which simplifies using xterm for both
+	  8-bit character sets and UTF-8.
+
+	<li>fixes/improvements to OPT_TCAP_QUERY logic (patches by Bram
+	  Moolenaar, Steve Wall).
+</ul>
+
+<H1><A NAME="xterm_140">Patch #140 - 2000/7/23 - XFree86 4.0.1</A></H1>
+<ul>
+	<li>modify Makefile.in to circumvent GNU make's built-in suffix rule
+	  for ".sh" which confuses install.sh with the "make install" target
+	  (report/patch by Paul Gilmartin).
+
+	<li>implement an experimental control sequence which an application may
+	  use to query the terminal to determine what sequence of characters it
+	  would send for a given function key.  This is ifdef'd with
+	  OPT_TCAP_QUERY (request by Bram Moolenaar).
+
+	<li>add /usr/local to search path in CF_X_ATHENA configure macro
+	  to build with Xaw3d on OpenBSD (patch by Christian Weisgerber).
+
+	<li>add missing <code>#undef HAVE_TERMIO_C_ISPEED</code> to
+	  xtermcfg.hin, omitted in patch #133 fix for IRIX 6.5 baudrate (report
+	  by Alain Filbois &lt;Alain.Filbois@loria.fr&gt;).
+
+	<li>correct a few errors in xterm.man:  font in filename example for
+	  Tektronix emulation, and description of -nul/+nul command-line
+	  options (report by Eric Fischer &lt;enf@pobox.com&gt;).
+
+	<li>update config.guess and config.sub (from tin and lynx)
+</ul>
 
 <H1><A NAME="xterm_139">Patch #139 - 2000/6/17 - XFree86 4.0d</A></H1>
 <ul>
Index: xc/programs/xterm/xterm.man
diff -u xc/programs/xterm/xterm.man:3.62 xc/programs/xterm/xterm.man:3.66
--- xc/programs/xterm/xterm.man:3.62	Tue Jun 13 20:16:23 2000
+++ xc/programs/xterm/xterm.man	Wed Dec  6 21:43:00 2000
@@ -1,5 +1,5 @@
 .\" $XConsortium: xterm.man /main/85 1996/12/09 17:10:53 kaleb $
-.\" $XFree86: xc/programs/xterm/xterm.man,v 3.62 2000/06/14 00:16:23 dawes Exp $
+.\" $XFree86: xc/programs/xterm/xterm.man,v 3.66 2000/12/07 02:43:00 dickey Exp $
 .\"
 .\"
 .\" Copyright 1996,1997,1998,1999,2000 by Thomas E. Dickey
@@ -123,7 +123,7 @@
 .B Tektronix
 menu; see below).
 The name of the file will be
-``\fBCOPY\fIyyyy\fB\-\fIMM\fB\-\fIdd\fB.\fIhh\fB:\fImm\fB:\fIss\fP'', where
+``\fBCOPY\fIyyyy\fB\-\fIMM\fB\-\fIdd\fB.\fIhh\fB:\fImm\fB:\fIss\fR'', where
 .IR yyyy ,
 .IR MM ,
 .IR dd ,
@@ -279,6 +279,11 @@
 This sets classes indicated by the given ranges for using in selecting by
 words.  See the section specifying character classes.
 .TP 8
+.BI \-class " string"
+This option allows you to override \fIxterm\fP's resource class.
+Normally it is ``XTerm'', but
+can be set to another class such as ``UXTerm'' to override selected resources.
+.TP 8
 .B "\-cm"
 This option disables recognition of ANSI color-change escape sequences.
 .TP 8
@@ -339,6 +344,22 @@
 normal font and the bold font will be produced by overstriking this font.
 The default is to do overstriking of the normal font.
 .TP 8
+.B \-fw \fIfont\fP
+This option specifies the font to be used for displaying wide text.
+By default,
+it will attempt to use a font twice as wide as the font that will be used to
+draw normal text.
+If no doublewidth font is found, it will improvise, by stretching 
+the normal font.
+.TP 8
+.B \-fwb \fIfont\fP
+This option specifies the font to be used for displaying bold wide text.
+By default,
+it will attempt to use a font twice as wide as the font that will be used to
+draw normal text.
+If no doublewidth font is found, it will improvise, by stretching 
+the normal font.
+.TP 8
 .B \-fi
 This option sets the font for active icons if that feature was compiled
 into xterm.
@@ -394,10 +415,22 @@
 .B \+j
 This option indicates that \fIxterm\fP should not do jump scrolling.
 .TP 8
+.B \-l
+Turn logging on.
+Normally logging is not supported, due to security concerns.
+Some versions of \fIxterm\fP may have logging enabled.
+.TP 8
+.B \+l
+Turn logging off.
+.TP 8
 .B \-leftbar
 Force scrollbar to the left side of VT100 screen.
 This is the default, unless you have set the rightScrollBar resource.
 .TP 8
+.BI \-lf " filename
+Specify the log-filename.
+See the \fB\-l\fP option.
+.TP 8
 .B \-ls
 This option indicates that the shell that is started in the \fIxterm\fP window
 will be a login shell (i.e., the first character of argv[0] will be a dash,
@@ -439,10 +472,10 @@
 at which the margin bell, if enabled, will ring.  The default is 10.
 .TP 8
 .B "\-nul"
-This option enables the display of underlining.
+This option disables the display of underlining.
 .TP 8
 .B "\+nul"
-This option disables the display of underlining.
+This option enables the display of underlining.
 .TP 8
 .B \-pc
 This option enables the PC-style use of bold colors (see boldColors
@@ -638,12 +671,22 @@
 ownership of the console device in order to get this option to work.
 .TP 8
 .B \-S\fIccn\fP
-This option specifies the last two letters of the name of a pseudo-terminal
-to use in slave mode, plus the number of the inherited file descriptor.
-The option is parsed ``%c%c%d''.
-This allows \fIxterm\fP to be used as an input and
+This option allows \fIxterm\fP to be used as an input and
 output channel for an existing program and is sometimes used in specialized
 applications.
+The option value specifies the last few letters of the name of a pseudo-terminal
+to use in slave mode, plus the number of the inherited file descriptor.
+If the option contains a ``/'' character, that delimits the characters
+used for the pseudo-terminal name from the file descriptor.
+Otherwise, exactly two characters are used from the option for
+the pseudo-terminal name, the remainder is the file descriptor.
+Examples:
+.nf
+.RS 15
+-S123/45
+-Sab34
+.RE
+.fi
 .PP
 The following command line arguments are provided for compatibility with
 older versions.  They may not be supported in the next release as the X
@@ -718,6 +761,10 @@
 This option indicates that reverse video should be simulated by swapping
 the foreground and background colors.
 .TP 8
+.B \+rv
+Disable the simulation of reverse video by swapping foreground and background
+colors.
+.TP 8
 .B \-title \fIstring\fP
 This option specifies the window title string, which may be displayed by
 window managers if the user so chooses.  The default title is the command
@@ -1951,11 +1998,12 @@
 series of comma-separated
 of \fIrange\fP:\fIvalue\fP pairs.  The
 \fIrange\fP is either a single number or \fIlow\fP-\fIhigh\fP in the range of 0
-to 255, corresponding to the 8-bit code for the character or characters to be
+to 65535, corresponding to the code for the character or characters to be
 set.  The \fIvalue\fP is arbitrary, although the default table uses the
-character number of the first character occurring in the set.
+character number of the first character occurring in the set. When not in 
+UTF-8 mode, only the first 256 bytes of this table will be used.
 .PP
-The default table is
+The default table starts as follows -
 .sp
 .in +8
 .ft C			\" Courier
@@ -2050,9 +2098,10 @@
 above or below the base volume.
 .TP 8
 .B "clear-saved-lines()"
-This action does \fBhard-reset()\fP (see above) and also clears the history
+This action does \fBhard-reset()\fP (see below) and also clears the history
 of lines saved off the top of the screen.
 It is also invoked from the \fBclearsavedlines\fP entry in \fIvtMenu\fP.
+The effect is identical to a hardware reset (RIS) control sequence.
 .TP 8
 .B "create-menu(\fIm/v/f/t\fP)"
 This action creates one of the menus used by \fIxterm\fP,
@@ -2340,14 +2389,15 @@
 used when
 \fIxterm\fP was started), \fI1\fP through \fI6\fP indicate the fonts
 specified by the \fIfont1\fP through \fIfont6\fP resources, \fIe\fP or \fIE\fP
-indicate the normal and bold fonts that have been set through escape codes
-(or specified as the second and third action arguments, respectively), and
+indicate the normal, bold and wide fonts that have been set through escape codes
+(or specified as the second, third and fourth action arguments, respectively), and
 \fIs\fP or \fIS\fP indicate the font selection (as made by programs such as
 \fIxfontsel(1)\fP) indicated by the second action argument.
 .TP 8
 .B "soft-reset()"
 This action resets the scrolling region and is also invoked from the
 \fBsoftreset\fP entry in \fIvtMenu\fP.
+The effect is identical to a soft reset (DECSTR) control sequence.
 .TP 8
 .B "start-extend()"
 This action is similar to \fBselect-start\fP except that the
@@ -2510,14 +2560,40 @@
 terminals, or from more widely used standards such as ISO 6429.
 .SH ENVIRONMENT
 .I Xterm
-sets the environment variables ``TERM'' and ``TERMCAP'' properly for the
-size window you have created.
+sets the environment variables ``TERM'' for the window you have created.
 It also uses and sets the environment
 variable ``DISPLAY'' to specify which bit map display terminal to use.
 The environment variable ``WINDOWID'' is set to the X window id number
 of the
 .I xterm
 window.
+.PP
+Depending on your system configuration, \fIxterm\fP may also set the
+following:
+.TP 5
+COLUMNS
+the width of the \fIxterm\fP in characters (cf: "stty columns").
+.TP 5
+HOME
+when \fIxterm\fP is configured to update utmp.
+.TP 5
+LINES
+the height of the \fIxterm\fP in characters (cf: "stty rows").
+.TP 5
+LOGNAME
+when \fIxterm\fP is configured to update utmp.
+.TP 5
+SHELL
+when \fIxterm\fP is configured to update utmp.
+.TP 5
+TERMCAP
+the contents of the termcap entry corresponding to $TERM,
+with lines and columns values substituted
+for the actual size window you have created.
+.TP 5
+TERMINFO
+may be defined to a nonstandard location in the configure script.
+.\"
 .SH FILES
 The actual pathnames given may differ on your system.
 .TP 5
Index: xc/programs/xterm/xterm_io.h
diff -u /dev/null xc/programs/xterm/xterm_io.h:1.1
--- /dev/null	Mon Dec 18 14:36:30 2000
+++ xc/programs/xterm/xterm_io.h	Wed Dec  6 05:19:43 2000
@@ -0,0 +1,271 @@
+/*
+ * $XFree86: xc/programs/xterm/xterm_io.h,v 1.1 2000/12/06 10:19:43 dickey Exp $
+ */
+
+/*
+ * Copyright 2000 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ */
+
+#ifndef	included_xterm_io_h
+#define	included_xterm_io_h
+
+#include <xterm.h>
+
+/*
+ * System-specific definitions (keep these chunks one-per-system!).
+ *
+ * FIXME:  some, such as those defining USE_TERMIOS should be moved to xterm.h
+ * as they are integrated with the configure script.
+ */
+#ifdef AMOEBA
+#define USE_TERMIOS
+#define _POSIX_SOURCE
+#endif
+
+#ifdef CSRG_BASED
+#define USE_TERMIOS
+#endif
+
+#ifdef __CYGWIN__
+#define ATT
+#define SVR4
+#define SYSV
+#define USE_SYSV_TERMIO
+#endif
+
+#ifdef __EMX__
+#define USE_SYSV_TERMIO
+#endif
+
+#ifdef __FreeBSD__
+#define USE_POSIX_TERMIOS
+#endif
+
+#ifdef linux
+#define USE_TERMIOS
+#endif
+
+#ifdef Lynx
+#define USE_SYSV_TERMIO
+#endif
+
+#ifdef macII
+#undef SYSV				/* pretend to be bsd (sgtty.h) */
+#endif /* macII */
+
+#ifdef MINIX
+#define USE_SYSV_TERMIO
+#define USE_TERMIOS
+#endif
+
+#ifdef __MVS__
+#define SVR4
+#define USE_POSIX_TERMIOS
+#endif
+
+#ifdef __QNX__
+#define USE_POSIX_TERMIOS
+#endif
+
+#if defined(__osf__)
+#define USE_POSIX_TERMIOS
+#undef SYSV
+#endif
+
+/*
+ * Indirect system dependencies
+ */
+#if defined(SVR4) && !defined(__sgi)
+#define USE_TERMIOS
+#endif
+
+#ifdef SYSV
+#define USE_SYSV_TERMIO
+#endif
+
+#if defined(USE_POSIX_TERMIOS) && !defined(USE_TERMIOS)
+#define USE_TERMIOS
+#endif
+
+/*
+ * Low-level ioctl, where it is needed or non-conflicting with termio/etc.
+ */
+#ifdef __QNX__
+#include <ioctl.h>
+#elif !defined(__CYGWIN__)
+#include <sys/ioctl.h>
+#endif
+
+/*
+ * Terminal I/O includes (termio, termios, sgtty headers).
+ */
+#if defined(USE_POSIX_TERMIOS)
+#include <termios.h>
+#elif defined(USE_TERMIOS)
+#include <termios.h>
+/* this hacked termios support only works on SYSV */
+#define USE_ANY_SYSV_TERMIO
+#define termio termios
+#undef  TCGETA
+#define TCGETA TCGETS
+#undef  TCSETA
+#define TCSETA TCSETS
+#undef  TCSETAW
+#define TCSETAW TCSETSW
+#elif defined(USE_SYSV_TERMIO)
+# define USE_ANY_SYSV_TERMIO
+# ifdef Lynx
+#  include <termio.h>
+# else
+#  include <sys/termio.h>
+# endif
+#elif defined(SYSV) || defined(ISC)
+# include <sys/termio.h>
+#elif !defined(VMS)
+# include <sgtty.h>
+#endif /* USE_POSIX_TERMIOS */
+
+/*
+ * Stream includes, which declare struct winsize or ttysize.
+ */
+#ifdef SYSV
+#ifdef USE_USG_PTYS
+#include <sys/stream.h>			/* get typedef used in ptem.h */
+#if !defined(SVR4) || defined(SCO325)
+#include <sys/ptem.h>			/* get struct winsize */
+#endif
+#endif /* USE_USG_PTYS */
+#elif defined(sun) && !defined(SVR4)
+#include <sys/ttycom.h>
+#ifdef TIOCSWINSZ
+#undef TIOCSSIZE
+#endif
+#endif /* SYSV */
+
+/*
+ * Special cases (structures and definitions that have to be adjusted).
+ */
+#if defined(__CYGWIN__) && !defined(TIOCSPGRP)
+#include <termios.h>
+#define TIOCSPGRP (_IOW('t', 118, pid_t))
+#endif
+
+#ifdef __EMX__
+#define XFREE86_PTY	0x76
+
+#define XTY_TIOCSETA	0x48
+#define XTY_TIOCSETAW	0x49
+#define XTY_TIOCSETAF	0x4a
+#define XTY_TIOCCONS	0x4d
+#define XTY_TIOCSWINSZ	0x53
+#define XTY_ENADUP	0x5a
+#define XTY_TRACE	0x5b
+#define XTY_TIOCGETA	0x65
+#define XTY_TIOCGWINSZ	0x66
+#define PTMS_GETPTY	0x64
+#define PTMS_BUFSZ	14
+
+#ifndef NCCS
+#define NCCS 11
+#endif
+
+#define TIOCSWINSZ	113
+#define TIOCGWINSZ	117
+
+struct pt_termios
+{
+        unsigned short  c_iflag;
+        unsigned short  c_oflag;
+        unsigned short  c_cflag;
+        unsigned short  c_lflag;
+        unsigned char   c_cc[NCCS];
+        long            _reserved_[4];
+};
+
+struct winsize {
+	unsigned short	ws_row;		/* rows, in characters */
+	unsigned short	ws_col;		/* columns, in characters */
+	unsigned short	ws_xpixel;	/* horizontal size, pixels */
+	unsigned short	ws_ypixel;	/* vertical size, pixels */
+};
+
+extern int ptioctl(int fd, int func, void* data);
+#define ioctl ptioctl
+
+#endif /* __EMX__ */
+
+#ifdef ISC
+#define TIOCGPGRP TCGETPGRP
+#define TIOCSPGRP TCSETPGRP
+#endif
+
+#ifdef Lynx
+#include <resource.h>
+#elif !(defined(SYSV) || defined(linux) || defined(VMS))
+#include <sys/resource.h>
+#endif
+
+#ifdef macII
+#undef FIOCLEX
+#undef FIONCLEX
+#endif /* macII */
+
+#ifdef MINIX
+#define termio termios
+#define TCGETA TCGETS
+#define TCSETAW TCSETSW
+#endif
+
+#ifdef __QNX__
+#undef TIOCSLTC			/* <sgtty.h> conflicts with <termios.h> */
+#undef TIOCLSET
+#endif
+
+#if defined(__sgi) && (OSMAJORVERSION >= 5)
+#undef TIOCLSET				/* defined, but not useable */
+#endif
+
+#if defined(__GNU__) || defined(__MVS__) || defined(__osf__)
+#undef TIOCLSET
+#undef TIOCSLTC
+#endif
+
+#if defined (__sgi) || (defined(__linux__) && defined(__sparc__))
+#undef TIOCLSET /* XXX why is this undef-ed again? */
+#endif
+
+#ifdef sun
+#include <sys/filio.h>
+#endif
+
+#if defined(TIOCSLTC) && ! (defined(linux) || defined(__MVS__) || defined(Lynx) || defined(SVR4))
+#define HAS_LTCHARS
+#endif
+
+#endif	/* included_xterm_io_h */
Index: xc/programs/xterm/xtermcfg.hin
diff -u xc/programs/xterm/xtermcfg.hin:3.33 xc/programs/xterm/xtermcfg.hin:3.35
--- xc/programs/xterm/xtermcfg.hin:3.33	Mon Jun 12 22:28:42 2000
+++ xc/programs/xterm/xtermcfg.hin	Wed Dec  6 21:22:12 2000
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/programs/xterm/xtermcfg.hin,v 3.33 2000/06/13 02:28:42 dawes Exp $
+ * $XFree86: xc/programs/xterm/xtermcfg.hin,v 3.35 2000/12/07 02:22:12 dickey Exp $
  */
 
 /************************************************************
@@ -47,6 +47,7 @@
 #undef HAVE_TCGETATTR		/* AC_CHECK_FUNCS(tcgetattr) */
 #undef HAVE_TERMCAP_H		/* AC_CHECK_HEADERS(termcap.h) */
 #undef HAVE_TERMIOS_H		/* AC_CHECK_HEADERS(termios.h) */
+#undef HAVE_TERMIO_C_ISPEED	/* CF_TERMIO_C_ISPEED */
 #undef HAVE_UNISTD_H		/* AC_CHECK_HEADERS(unistd.h) */
 #undef HAVE_UTMP		/* CF_UTMP */
 #undef HAVE_UTMP_UT_HOST	/* CF_UTMP_UT_HOST */
@@ -83,6 +84,8 @@
 #undef OPT_WIDE_CHARS		/* CF_ARG_ENABLE(wide-chars) */
 #undef OPT_XMC_GLITCH		/* CF_ARG_ENABLE(xmc-glitch) */
 #undef OPT_ZICONBEEP		/* CF_ARG_DISABLE(ziconbeep) */
+#undef OPT_SAME_NAME
+#undef OPT_TCAP_QUERY
 #undef OWN_TERMINFO_DIR		/* AC_ARG_WITH(own-terminfo) */
 #undef SCROLLBAR_RIGHT		/* CF_ARG_ENABLE(rightbar) */
 #undef SVR4			/* CF_SVR4, imake */
Index: xc/programs/xterm/unicode/README
diff -u xc/programs/xterm/unicode/README:1.2 xc/programs/xterm/unicode/README:1.4
--- xc/programs/xterm/unicode/README:1.2	Mon Jun 12 22:28:44 2000
+++ xc/programs/xterm/unicode/README	Tue Oct 31 20:12:47 2000
@@ -1,4 +1,4 @@
--- $XFree86: xc/programs/xterm/unicode/README,v 1.2 2000/06/13 02:28:44 dawes Exp $
+-- $XFree86: xc/programs/xterm/unicode/README,v 1.4 2000/11/01 01:12:47 dawes Exp $
 -- Thomas E. Dickey
 
 These are some scripts and datafiles used for generating tables used in the
@@ -13,6 +13,11 @@
 
 convmap.pl is used to generate ../keysym2ucs.c, e.g.,
 
-	./convmap.plp >../keysym2ucs.c
+	./convmap.pl >../keysym2ucs.c
 
 keysym.map is input data for convmap.pl
+
+
+The make-precompose.sh script makes the precompose.c file, which is used to
+handle canonical composition. This also needs UnicodeData-Latest.txt. It uses
+precompose.c.head and precompose.c.tail as templates.
Index: xc/programs/xterm/unicode/make-precompose.sh
diff -u /dev/null xc/programs/xterm/unicode/make-precompose.sh:1.1
--- /dev/null	Mon Dec 18 14:36:32 2000
+++ xc/programs/xterm/unicode/make-precompose.sh	Fri Aug 25 17:51:18 2000
@@ -0,0 +1,6 @@
+#!/bin/sh
+cat precompose.c.head
+cut UnicodeData-Latest.txt -d ";" -f 1,6 | \
+ grep ";[0-9,A-F]" | grep " " | \
+ sed -e "s/ /, 0x/;s/^/{ 0x/;s/;/, 0x/;s/$/},/" | sort +2
+cat precompose.c.tail
Index: xc/programs/xterm/unicode/precompose.c.head
diff -u /dev/null xc/programs/xterm/unicode/precompose.c.head:1.1
--- /dev/null	Mon Dec 18 14:36:33 2000
+++ xc/programs/xterm/unicode/precompose.c.head	Fri Aug 25 17:51:18 2000
@@ -0,0 +1,14 @@
+/*
+ * Canonical Compositions
+ *
+ * DO NOT EDIT BY HAND! This is generated by the script
+ * unicode/make-precompose.sh
+ */
+
+#include <precompose.h>
+
+struct {
+  int replacement;
+  int base;
+  int comb; 
+} precompositions[] = {
Index: xc/programs/xterm/unicode/precompose.c.tail
diff -u /dev/null xc/programs/xterm/unicode/precompose.c.tail:1.2
--- /dev/null	Mon Dec 18 14:36:33 2000
+++ xc/programs/xterm/unicode/precompose.c.tail	Tue Oct 31 20:12:47 2000
@@ -0,0 +1,23 @@
+};
+
+int do_precomposition(int base, int comb) {
+  int min = 0;
+  int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1;
+  int mid;
+  unsigned int sought = ((unsigned)base << 16) | (unsigned)comb, that;
+
+  /* binary search */
+  while (max >= min) {
+    mid = (min + max) / 2;
+    that = ((unsigned)precompositions[mid].base << 16) | ((unsigned)precompositions[mid].comb);
+    if (that < sought) {
+      min = mid + 1;
+    } else if (that > sought) {
+      max = mid - 1;
+    } else {
+      return precompositions[mid].replacement;
+    }
+  }
+  /* no match */
+  return -1;
+}
Index: xc/programs/xterm/vttests/16colors.sh
diff -u xc/programs/xterm/vttests/16colors.sh:1.2 xc/programs/xterm/vttests/16colors.sh:1.3
--- xc/programs/xterm/vttests/16colors.sh:1.2	Sun Apr 25 06:03:08 1999
+++ xc/programs/xterm/vttests/16colors.sh	Fri Oct 27 14:31:17 2000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $XFree86: xc/programs/xterm/vttests/16colors.sh,v 1.2 1999/04/25 10:03:08 dawes Exp $
+# $XFree86: xc/programs/xterm/vttests/16colors.sh,v 1.3 2000/10/27 18:31:17 dawes Exp $
 #
 # -- Thomas Dickey (1999/3/27)
 # Show a simple 16-color test pattern.  It is a little more confusing than
@@ -12,7 +12,7 @@
 OPT='-n'
 SUF=''
 TMP=/tmp/xterm$$
-for verb in print printf ; do
+for verb in printf print ; do
     rm -f $TMP
     eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
     if test -f $TMP ; then
Index: xc/programs/xterm/vttests/8colors.sh
diff -u xc/programs/xterm/vttests/8colors.sh:1.2 xc/programs/xterm/vttests/8colors.sh:1.3
--- xc/programs/xterm/vttests/8colors.sh:1.2	Sun Apr 25 06:03:08 1999
+++ xc/programs/xterm/vttests/8colors.sh	Fri Oct 27 14:31:17 2000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $XFree86: xc/programs/xterm/vttests/8colors.sh,v 1.2 1999/04/25 10:03:08 dawes Exp $
+# $XFree86: xc/programs/xterm/vttests/8colors.sh,v 1.3 2000/10/27 18:31:17 dawes Exp $
 #
 # -- Thomas Dickey (1999/3/27)
 # Show a simple 8-color test pattern
@@ -9,7 +9,7 @@
 OPT='-n'
 SUF=''
 TMP=/tmp/xterm$$
-for verb in print printf ; do
+for verb in printf print ; do
     rm -f $TMP
     eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
     if test -f $TMP ; then
Index: xc/programs/xterm/vttests/doublechars.sh
diff -u xc/programs/xterm/vttests/doublechars.sh:1.2 xc/programs/xterm/vttests/doublechars.sh:1.3
--- xc/programs/xterm/vttests/doublechars.sh:1.2	Sat Sep 25 10:38:51 1999
+++ xc/programs/xterm/vttests/doublechars.sh	Fri Oct 27 14:31:17 2000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $XFree86: xc/programs/xterm/vttests/doublechars.sh,v 1.2 1999/09/25 14:38:51 dawes Exp $
+# $XFree86: xc/programs/xterm/vttests/doublechars.sh,v 1.3 2000/10/27 18:31:17 dawes Exp $
 #
 # -- Thomas Dickey (1999/7/7)
 # Illustrate the use of double-size characters by drawing successive lines in
@@ -13,7 +13,7 @@
 OPT='-n'
 SUF=''
 TMP=/tmp/xterm$$
-for verb in print printf ; do
+for verb in printf print ; do
     rm -f $TMP
     eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
     if test -f $TMP ; then
Index: xc/programs/xterm/vttests/dynamic.sh
diff -u xc/programs/xterm/vttests/dynamic.sh:1.2 xc/programs/xterm/vttests/dynamic.sh:1.3
--- xc/programs/xterm/vttests/dynamic.sh:1.2	Sun Apr 11 09:11:43 1999
+++ xc/programs/xterm/vttests/dynamic.sh	Fri Oct 27 14:31:17 2000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $XFree86: xc/programs/xterm/vttests/dynamic.sh,v 1.2 1999/04/11 13:11:43 dawes Exp $
+# $XFree86: xc/programs/xterm/vttests/dynamic.sh,v 1.3 2000/10/27 18:31:17 dawes Exp $
 #
 # -- Thomas Dickey (1999/3/27)
 # Demonstrate the use of dynamic colors by setting the background successively
@@ -10,7 +10,7 @@
 OPT='-n'
 SUF=''
 TMP=/tmp/xterm$$
-for verb in print printf ; do
+for verb in printf print ; do
     rm -f $TMP
     eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
     if test -f $TMP ; then
Index: xc/programs/xterm/vttests/fonts.sh
diff -u xc/programs/xterm/vttests/fonts.sh:1.1 xc/programs/xterm/vttests/fonts.sh:1.2
--- xc/programs/xterm/vttests/fonts.sh:1.1	Sun Apr 11 09:11:43 1999
+++ xc/programs/xterm/vttests/fonts.sh	Fri Oct 27 14:31:17 2000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $XFree86: xc/programs/xterm/vttests/fonts.sh,v 1.1 1999/04/11 13:11:43 dawes Exp $
+# $XFree86: xc/programs/xterm/vttests/fonts.sh,v 1.2 2000/10/27 18:31:17 dawes Exp $
 #
 # -- Thomas Dickey (1999/3/27)
 # Demonstrate the use of dynamic colors by setting the background successively
@@ -10,7 +10,7 @@
 OPT='-n'
 SUF=''
 TMP=/tmp/xterm$$
-for verb in print printf ; do
+for verb in printf print ; do
     rm -f $TMP
     eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
     if test -f $TMP ; then
Index: xc/programs/xterm/vttests/resize.sh
diff -u xc/programs/xterm/vttests/resize.sh:1.2 xc/programs/xterm/vttests/resize.sh:1.3
--- xc/programs/xterm/vttests/resize.sh:1.2	Sun Apr 11 09:11:44 1999
+++ xc/programs/xterm/vttests/resize.sh	Fri Oct 27 14:31:17 2000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $XFree86: xc/programs/xterm/vttests/resize.sh,v 1.2 1999/04/11 13:11:44 dawes Exp $
+# $XFree86: xc/programs/xterm/vttests/resize.sh,v 1.3 2000/10/27 18:31:17 dawes Exp $
 #
 # -- Thomas Dickey (1999/3/27)
 # Obtain the current screen size, then resize the terminal to the nominal
@@ -10,7 +10,7 @@
 OPT='-n'
 SUF=''
 TMP=/tmp/xterm$$
-for verb in print printf ; do
+for verb in printf print ; do
     rm -f $TMP
     eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
     if test -f $TMP ; then
Index: xc/programs/xterm/vttests/title.sh
diff -u xc/programs/xterm/vttests/title.sh:1.3 xc/programs/xterm/vttests/title.sh:1.4
--- xc/programs/xterm/vttests/title.sh:1.3	Sun Apr 25 06:03:09 1999
+++ xc/programs/xterm/vttests/title.sh	Fri Oct 27 14:31:17 2000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $XFree86: xc/programs/xterm/vttests/title.sh,v 1.3 1999/04/25 10:03:09 dawes Exp $
+# $XFree86: xc/programs/xterm/vttests/title.sh,v 1.4 2000/10/27 18:31:17 dawes Exp $
 #
 # -- Thomas Dickey (1999/3/27)
 # Obtain the current title of the window, set up a simple clock which runs
@@ -10,7 +10,7 @@
 OPT='-n'
 SUF=''
 TMP=/tmp/xterm$$
-for verb in print printf ; do
+for verb in printf print ; do
     rm -f $TMP
     eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
     if test -f $TMP ; then
Index: xc/programs/xvidtune/xvidtune.c
diff -u xc/programs/xvidtune/xvidtune.c:3.25 xc/programs/xvidtune/xvidtune.c:3.26
--- xc/programs/xvidtune/xvidtune.c:3.25	Sun Mar 21 02:35:41 1999
+++ xc/programs/xvidtune/xvidtune.c	Tue Sep 26 11:57:27 2000
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/xvidtune/xvidtune.c,v 3.25 1999/03/21 07:35:41 dawes Exp $ */
+/* $XFree86: xc/programs/xvidtune/xvidtune.c,v 3.26 2000/09/26 15:57:27 tsi Exp $ */
 
 /*
 
@@ -576,7 +576,7 @@
 static void
 AdjustCB(Widget w, XtPointer client, XtPointer call)
 {
-   int what = (int) client;
+   int what = (long) client;
    Boolean state;
    
    switch (what) {
@@ -807,7 +807,7 @@
     fields findex;
     ScrollData* sdp;
     Boolean state;
-    int what = (int)client;
+    int what = (long) client;
 
 
     if (what < 0)
@@ -878,7 +878,7 @@
 {
     float percent = *(float*) call;
     int ipercent = percent * 100;
-    int fieldindex = (int) client;
+    int fieldindex = (long) client;
     ScrollData* sdp = &AppRes.field[fieldindex];
 
 
@@ -915,7 +915,7 @@
     XF86VidModeLockModeSwitch(XtDisplay(w), DefaultScreen (XtDisplay (w)),
 			      FALSE);
     XF86VidModeSwitchMode(XtDisplay(w), DefaultScreen (XtDisplay (w)),
-			  (int)client);
+			  (int)(long) client);
     XF86VidModeLockModeSwitch(XtDisplay(w), DefaultScreen (XtDisplay (w)),
 			      TRUE);
     FetchCB(w, NULL, NULL);
Index: xc/programs/xvinfo/Imakefile
diff -u /dev/null xc/programs/xvinfo/Imakefile:1.3
--- /dev/null	Mon Dec 18 14:36:37 2000
+++ xc/programs/xvinfo/Imakefile	Mon Dec 11 11:40:55 2000
@@ -0,0 +1,9 @@
+
+XCOMM $XFree86: xc/programs/xvinfo/Imakefile,v 1.3 2000/12/11 16:40:55 dawes Exp $
+
+        DEPLIBS = $(DEPXVLIB) $(DEPXLIB)
+LOCAL_LIBRARIES = $(XVLIB) $(XLIB)
+           SRCS = xvinfo.c
+           OBJS = xvinfo.o
+
+ComplexProgramTarget(xvinfo)
Index: xc/programs/xvinfo/xvinfo.c
diff -u /dev/null xc/programs/xvinfo/xvinfo.c:1.4
--- /dev/null	Mon Dec 18 14:36:37 2000
+++ xc/programs/xvinfo/xvinfo.c	Tue Oct 24 18:45:17 2000
@@ -0,0 +1,265 @@
+/* $XFree86: xc/programs/xvinfo/xvinfo.c,v 1.4 2000/10/24 22:45:17 dawes Exp $ */
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xvlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+static void
+PrintUsage(void)
+{
+   fprintf(stderr, "Usage:  xvinfo [-display host:dpy]\n");
+   exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+    Display *dpy;
+    unsigned int ver, rev, eventB, reqB, errorB; 
+    int i, j, k, n; 
+    unsigned int nencode, nadaptors;
+    int nscreens, nattr, numImages;
+    XvAdaptorInfo *ainfo;
+    XvAttribute *attributes;
+    XvEncodingInfo *encodings;
+    XvFormat *format;
+    XvImageFormatValues *formats;
+    char * disname = NULL;
+
+    if((argc != 1) && (argc != 3))
+       PrintUsage();
+
+    if(argc != 1) {
+       if(strcmp(argv[1], "-display"))
+	  PrintUsage();
+	disname = argv[2];
+    }
+
+
+    if(!(dpy = XOpenDisplay(disname))) 
+    {
+	fprintf(stderr, "xvinfo:  Unable to open display %s\n",
+                       (disname != NULL) ? disname : XDisplayName(NULL));
+	exit(-1);
+    }
+
+    if((Success != XvQueryExtension(dpy, &ver, &rev, &reqB, &eventB, &errorB))) 
+    {
+	fprintf(stderr, "xvinfo: No X-Video Extension on %s\n",
+                        (disname != NULL) ? disname : XDisplayName(NULL));
+	exit(0);
+    } 
+    else
+    {
+	fprintf(stdout, "X-Video Extension version %i.%i\n", ver, rev);
+    }
+
+    nscreens = ScreenCount(dpy);
+
+    for(i = 0; i < nscreens; i++) {
+  	fprintf(stdout, "screen #%i\n", i);
+	XvQueryAdaptors(dpy, RootWindow(dpy, i), &nadaptors, &ainfo);
+
+	if(!nadaptors) {
+	    fprintf(stdout, " no adaptors present\n");
+	    continue;
+	} 
+
+	for(j = 0; j < nadaptors; j++) {
+	    fprintf(stdout, "  Adaptor #%i: \"%s\"\n", j, ainfo[j].name);
+	    fprintf(stdout, "    number of ports: %i\n", ainfo[j].num_ports);
+	    fprintf(stdout, "    port base: %i\n", ainfo[j].base_id);
+	    fprintf(stdout, "    operations supported: ");
+	    switch(ainfo[j].type & (XvInputMask | XvOutputMask)) {
+	    case XvInputMask:
+	     if(ainfo[j].type & XvVideoMask) 
+		fprintf(stdout, "PutVideo ");
+	     if(ainfo[j].type & XvStillMask) 
+		fprintf(stdout, "PutStill ");
+	     if(ainfo[j].type & XvImageMask) 
+		fprintf(stdout, "PutImage ");
+	     break;
+	    case XvOutputMask:
+	     if(ainfo[j].type & XvVideoMask) 
+		fprintf(stdout, "GetVideo ");
+	     if(ainfo[j].type & XvStillMask) 
+		fprintf(stdout, "GetStill ");
+	     break;
+	    default:
+		fprintf(stdout, "none ");
+		break;
+	    }
+	    fprintf(stdout, "\n");
+
+	    format = ainfo[j].formats;
+
+	    fprintf(stdout, "    supported visuals:\n");
+	    for(k = 0; k < ainfo[j].num_formats; k++, format++) {
+	         fprintf(stdout, "      depth %i, visualID 0x%2x\n",
+				 format->depth, format->visual_id);
+	    }
+
+	    attributes = XvQueryPortAttributes(dpy, ainfo[j].base_id, &nattr);
+
+	    if(attributes && nattr) {
+		fprintf(stdout, "    number of attributes: %i\n", nattr);
+		
+		for(k = 0; k < nattr; k++) {
+		    fprintf(stdout, "      \"%s\" (range %i to %i)\n",
+					attributes[k].name, 
+					attributes[k].min_value,
+					attributes[k].max_value);
+
+		    if(attributes[k].flags & XvSettable)
+		    	fprintf(stdout, "              client settable attribute\n");
+
+		    if(attributes[k].flags & XvGettable) {
+			Atom the_atom;
+			int value;
+
+		    	fprintf(stdout, "              client gettable attribute");
+			the_atom = XInternAtom(dpy, attributes[k].name, True);
+
+			if(the_atom != None){
+			   if((Success == XvGetPortAttribute(dpy, 
+					ainfo[j].base_id, the_atom, &value)))
+		    	       fprintf(stdout, " (current value is %i)", value);
+			}
+		        fprintf(stdout, "\n");
+		    }
+
+		}
+		XFree(attributes);
+	    } else {
+		fprintf(stdout, "    no port attributes defined\n");
+	    }
+
+	    XvQueryEncodings(dpy, ainfo[j].base_id,
+						&nencode, &encodings);
+
+	    if(encodings && nencode) {
+		int ImageEncodings = 0;
+
+		for(n = 0; n < nencode; n++) {
+		    if(!strcmp(encodings[n].name, "XV_IMAGE"))
+			ImageEncodings++;
+		}
+
+		if(nencode - ImageEncodings) {
+		    fprintf(stdout, "    number of encodings: %i\n", 
+						nencode - ImageEncodings);
+
+		    for(n = 0; n < nencode; n++) {
+		    	if(strcmp(encodings[n].name, "XV_IMAGE")) {
+			    fprintf(stdout, "      encoding ID #%i: \"%s\"\n",
+					encodings[n].encoding_id,
+					encodings[n].name);
+			    fprintf(stdout, "        size: %i x %i\n",
+					encodings[n].width,
+					encodings[n].height);
+			    fprintf(stdout, "        rate: %f\n",
+					(float)encodings[n].rate.numerator/
+					(float)encodings[n].rate.denominator);
+			}
+		    }
+		}
+
+		if(ImageEncodings && (ainfo[j].type & XvImageMask)) {
+		   char imageName[5] = {0, 0, 0, 0, 0};
+
+		   for(n = 0; n < nencode; n++) {
+		      if(!strcmp(encodings[n].name, "XV_IMAGE")) {
+			fprintf(stdout, 
+				"    maximum XvImage size: %i x %i\n",	
+				encodings[n].width, encodings[n].height);
+			break;
+		      }
+		   }
+
+                   formats = XvListImageFormats(
+				dpy, ainfo[i].base_id, &numImages);
+
+		   fprintf(stdout, "    Number of image formats: %i\n",
+						numImages);
+
+		   for(n = 0; n < numImages; n++) {
+			memcpy(imageName, &(formats[n].id), 4);
+			fprintf(stdout, "      id: 0x%x", formats[n].id);
+			if(isprint(imageName[0]) && isprint(imageName[1]) &&
+			  isprint(imageName[2]) && isprint(imageName[3])) 
+			{
+			  fprintf(stdout, " (%s)\n", imageName);
+			} else {
+			  fprintf(stdout, "\n");
+			}
+			fprintf(stdout, "        guid: ");
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[0]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[1]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[2]);
+			fprintf(stdout, "%02x-", (unsigned char) 
+						formats[n].guid[3]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[4]);
+			fprintf(stdout, "%02x-", (unsigned char) 
+						formats[n].guid[5]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[6]);
+			fprintf(stdout, "%02x-", (unsigned char) 
+						formats[n].guid[7]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[8]);
+			fprintf(stdout, "%02x-", (unsigned char) 
+						formats[n].guid[9]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[10]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[11]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[12]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[13]);
+			fprintf(stdout, "%02x", (unsigned char) 
+						formats[n].guid[14]);
+			fprintf(stdout, "%02x\n", (unsigned char) 
+						formats[n].guid[15]);
+
+			fprintf(stdout, "        bits per pixel: %i\n",
+					formats[n].bits_per_pixel);
+			fprintf(stdout, "        number of planes: %i\n",
+					formats[n].num_planes);
+			fprintf(stdout, "        type: %s (%s)\n", 
+			 (formats[n].type == XvRGB) ? "RGB" : "YUV",
+			 (formats[n].format == XvPacked) ? "packed" : "planar");
+
+			if(formats[n].type == XvRGB) {
+			    fprintf(stdout, "        depth: %i\n", 
+			    		formats[n].depth == XvRGB);
+
+			    fprintf(stdout, "        red, green, blue masks: " 
+					"0x%lx, 0x%lx, 0x%lx\n", 
+					formats[n].red_mask,
+					formats[n].green_mask,
+					formats[n].blue_mask);
+			} else {
+
+			}
+			
+	
+		   }
+		   if(formats) XFree(formats);
+		}
+
+		XvFreeEncodingInfo(encodings);
+	    }
+	    
+	}
+
+	XvFreeAdaptorInfo(ainfo);
+    }
+    return 1;
+}
Index: xc/programs/xvinfo/xvinfo.man
diff -u /dev/null xc/programs/xvinfo/xvinfo.man:1.1
--- /dev/null	Mon Dec 18 14:36:38 2000
+++ xc/programs/xvinfo/xvinfo.man	Tue Sep 19 02:08:11 2000
@@ -0,0 +1,29 @@
+
+.\" $XFree86: xc/programs/xvinfo/xvinfo.man,v 1.1 2000/09/19 06:08:11 mvojkovi Exp $
+.\"
+.TH xvinfo 1 "Release 6.4" "X Version 11"
+.SH NAME
+xvinfo - Print out X-Video extension adaptor information
+.SH SYNOPSIS
+.B "xvinfo"
+[-display \fIdisplayname\fP] 
+.SH DESCRIPTION
+.PP
+.B xvinfo
+prints out the capabilities of any video adaptors associated
+with the display that are accesible through the X-Video extension. 
+.SH OPTIONS
+.PP
+.TP 8
+.B "-display \fIdisplay\fP"
+This argument allows you to specify the server to query; see \fIX(1)\fP.
+.SH ENVIRONMENT
+.PP
+.TP 8
+.B DISPLAY
+This variable may be used to specify the server to query.
+
+.SH SEE ALSO
+xdpyinfo(1)
+.SH AUTHORS
+Mark Vojkovich
Index: xc/programs/xwd/xwd.c
diff -u xc/programs/xwd/xwd.c:3.5 xc/programs/xwd/xwd.c:3.6
--- xc/programs/xwd/xwd.c:3.5	Sun Mar  7 06:41:37 1999
+++ xc/programs/xwd/xwd.c	Thu Nov 30 19:24:36 2000
@@ -21,7 +21,7 @@
 in this Software without prior written authorization from The Open Group.
 
 */
-/* $XFree86: xc/programs/xwd/xwd.c,v 3.5 1999/03/07 11:41:37 dawes Exp $ */
+/* $XFree86: xc/programs/xwd/xwd.c,v 3.6 2000/12/01 00:24:36 dawes Exp $ */
 
 /*
  * xwd.c MIT Project Athena, X Window system window raster image dumper.
@@ -646,14 +646,12 @@
     register char *sp;
 
     while (bp < ep) {
-	sp = bp + 3;
-	c = *sp;
-	*sp = *bp;
-	*bp++ = c;
-	sp = bp + 1;
-	c = *sp;
-	*sp = *bp;
-	*bp++ = c;
-	bp += 2;
+        c = bp[3];
+        bp[3] = bp[0];
+        bp[0] = c;
+        c = bp[2];
+        bp[2] = bp[1];
+        bp[1] = c;
+        bp += 4;
     }
 }
Index: xc/util/memleak/fmalloc.c
diff -u xc/util/memleak/fmalloc.c:3.8 xc/util/memleak/fmalloc.c:3.10
--- xc/util/memleak/fmalloc.c:3.8	Wed Jun 14 21:26:22 2000
+++ xc/util/memleak/fmalloc.c	Fri Dec  8 16:43:22 2000
@@ -22,7 +22,7 @@
  * Author:  Keith Packard, MIT X Consortium
  */
 
-/* $XFree86: xc/util/memleak/fmalloc.c,v 3.8 2000/06/15 01:26:22 dawes Exp $ */
+/* $XFree86: xc/util/memleak/fmalloc.c,v 3.10 2000/12/08 21:43:22 keithp Exp $ */
 
 
 /*
@@ -102,9 +102,7 @@
 
 typedef struct _tail {
     magic    	    tailMagic;
-#if defined(__alpha) || defined(__alpha__)
     magic    	    tailPad;
-#endif
 } TailRec, *TailPtr;
 
 #define Header(p)	((HeadPtr) (((char *) (p)) - sizeof (HeadRec)))
@@ -486,6 +484,7 @@
 {
     mem	foo;
 
+    foo = 1;
     fprintf (stderr, "\nCheckMemory\n");
     fprintf (stderr, "%d bytes active memory in %d allocations\n",
 	     activeMemoryTotal, activeMemoryCount);
Index: xc/util/memleak/getreti386.c
diff -u xc/util/memleak/getreti386.c:3.3 xc/util/memleak/getreti386.c:3.4
--- xc/util/memleak/getreti386.c:3.3	Sun Dec 26 19:56:42 1999
+++ xc/util/memleak/getreti386.c	Fri Dec  8 16:44:05 2000
@@ -4,7 +4,7 @@
  * Copyright (c) 1995 Jeffrey Hsu
  */
 
-/* $XFree86: xc/util/memleak/getreti386.c,v 3.3 1999/12/27 00:56:42 robin Exp $ */
+/* $XFree86: xc/util/memleak/getreti386.c,v 3.4 2000/12/08 21:44:05 keithp Exp $ */
 
 #define get_current_fp(first_local)	((unsigned)&(first_local) + 4)
 #define prev_fp_from_fp(fp)		*((unsigned *) fp)
@@ -40,8 +40,12 @@
 
 	while (ret_addr > CRT0_ADDRESS && max-- > 1) {
 	  *results++ = ret_addr;
+	  if (fp < (unsigned long) &first_local)
+	    break;
 	  fp = prev_fp_from_fp(fp);
 	  if (!fp)
+	    break;
+	  if (fp < (unsigned long) &first_local)
 	    break;
 	  ret_addr = ret_addr_from_fp(fp);
 	}
